Merge pull request #10828 from gemu2015/i2s

fix i2s audio
This commit is contained in:
Theo Arends 2021-02-04 14:14:11 +01:00 committed by GitHub
commit 08f8adf1fa
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 4 additions and 5 deletions

View File

@ -197,8 +197,8 @@ bool AudioOutputI2S::ConsumeSample(int16_t sample[2])
// Deprecated. Use i2s_write // Deprecated. Use i2s_write
// return i2s_write_bytes((i2s_port_t)portNo, (const char*)&s32, sizeof(uint32_t), 0); // return i2s_write_bytes((i2s_port_t)portNo, (const char*)&s32, sizeof(uint32_t), 0);
size_t bytes_written; size_t bytes_written;
return (ESP_OK == i2s_write((i2s_port_t)portNo, (const char*)&s32, sizeof(uint32_t), &bytes_written, 0)); i2s_write((i2s_port_t)portNo, (const char*)&s32, sizeof(uint32_t), &bytes_written, 0);
// return bytes_written; return bytes_written;
#else #else
uint32_t s32 = ((Amplify(ms[RIGHTCHANNEL]))<<16) | (Amplify(ms[LEFTCHANNEL]) & 0xffff); uint32_t s32 = ((Amplify(ms[RIGHTCHANNEL]))<<16) | (Amplify(ms[LEFTCHANNEL]) & 0xffff);
return i2s_write_sample_nb(s32); // If we can't store it, return false. OTW true return i2s_write_sample_nb(s32); // If we can't store it, return false. OTW true
@ -225,5 +225,3 @@ bool AudioOutputI2S::stop()
#endif #endif
return true; return true;
} }

View File

@ -99,7 +99,8 @@ bool AudioOutputI2SNoDAC::ConsumeSample(int16_t sample[2])
// Deprecated. Use i2s_write // Deprecated. Use i2s_write
// if (!i2s_write_bytes((i2s_port_t)portNo, (const char *)dsBuff, sizeof(uint32_t) * (oversample/32), 0)) // if (!i2s_write_bytes((i2s_port_t)portNo, (const char *)dsBuff, sizeof(uint32_t) * (oversample/32), 0))
size_t bytes_written; size_t bytes_written;
if (ESP_OK != i2s_write((i2s_port_t)portNo, (const char *)dsBuff, sizeof(uint32_t) * (oversample/32), &bytes_written, 0)) i2s_write((i2s_port_t)portNo, (const char *)dsBuff, sizeof(uint32_t) * (oversample/32), &bytes_written, 0);
if (!bytes_written)
return false; return false;
#else #else
if (!i2s_write_sample_nb(dsBuff[0])) return false; // No room at the inn if (!i2s_write_sample_nb(dsBuff[0])) return false; // No room at the inn