From 12954aea68ab3622617a4a0e21973755b93e41f6 Mon Sep 17 00:00:00 2001 From: gemu2015 Date: Thu, 4 Feb 2021 10:42:05 +0100 Subject: [PATCH 1/2] fix i2s audio --- lib/lib_audio/ESP8266Audio/src/AudioOutputI2S.cpp | 6 ++---- lib/lib_audio/ESP8266Audio/src/AudioOutputI2SNoDAC.cpp | 2 +- 2 files changed, 3 insertions(+), 5 deletions(-) diff --git a/lib/lib_audio/ESP8266Audio/src/AudioOutputI2S.cpp b/lib/lib_audio/ESP8266Audio/src/AudioOutputI2S.cpp index 5ef967d6a..c028df105 100644 --- a/lib/lib_audio/ESP8266Audio/src/AudioOutputI2S.cpp +++ b/lib/lib_audio/ESP8266Audio/src/AudioOutputI2S.cpp @@ -197,8 +197,8 @@ bool AudioOutputI2S::ConsumeSample(int16_t sample[2]) // Deprecated. Use i2s_write // return i2s_write_bytes((i2s_port_t)portNo, (const char*)&s32, sizeof(uint32_t), 0); size_t bytes_written; - return (ESP_OK == i2s_write((i2s_port_t)portNo, (const char*)&s32, sizeof(uint32_t), &bytes_written, 0)); -// return bytes_written; + i2s_write((i2s_port_t)portNo, (const char*)&s32, sizeof(uint32_t), &bytes_written, 0); + return bytes_written; #else 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 @@ -225,5 +225,3 @@ bool AudioOutputI2S::stop() #endif return true; } - - diff --git a/lib/lib_audio/ESP8266Audio/src/AudioOutputI2SNoDAC.cpp b/lib/lib_audio/ESP8266Audio/src/AudioOutputI2SNoDAC.cpp index e8cfd2352..e83f02234 100644 --- a/lib/lib_audio/ESP8266Audio/src/AudioOutputI2SNoDAC.cpp +++ b/lib/lib_audio/ESP8266Audio/src/AudioOutputI2SNoDAC.cpp @@ -99,7 +99,7 @@ bool AudioOutputI2SNoDAC::ConsumeSample(int16_t sample[2]) // Deprecated. Use i2s_write // if (!i2s_write_bytes((i2s_port_t)portNo, (const char *)dsBuff, sizeof(uint32_t) * (oversample/32), 0)) size_t bytes_written; - if (ESP_OK != i2s_write((i2s_port_t)portNo, (const char *)dsBuff, sizeof(uint32_t) * (oversample/32), &bytes_written, 0)) + if (!i2s_write((i2s_port_t)portNo, (const char *)dsBuff, sizeof(uint32_t) * (oversample/32), &bytes_written, 0)) return false; #else if (!i2s_write_sample_nb(dsBuff[0])) return false; // No room at the inn From a2ba525913f9e1d59c0db6331601d9ed811cf33a Mon Sep 17 00:00:00 2001 From: gemu2015 Date: Thu, 4 Feb 2021 11:03:01 +0100 Subject: [PATCH 2/2] Update AudioOutputI2SNoDAC.cpp --- lib/lib_audio/ESP8266Audio/src/AudioOutputI2SNoDAC.cpp | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/lib/lib_audio/ESP8266Audio/src/AudioOutputI2SNoDAC.cpp b/lib/lib_audio/ESP8266Audio/src/AudioOutputI2SNoDAC.cpp index e83f02234..4f7b21ff7 100644 --- a/lib/lib_audio/ESP8266Audio/src/AudioOutputI2SNoDAC.cpp +++ b/lib/lib_audio/ESP8266Audio/src/AudioOutputI2SNoDAC.cpp @@ -99,7 +99,8 @@ bool AudioOutputI2SNoDAC::ConsumeSample(int16_t sample[2]) // Deprecated. Use i2s_write // if (!i2s_write_bytes((i2s_port_t)portNo, (const char *)dsBuff, sizeof(uint32_t) * (oversample/32), 0)) size_t bytes_written; - if (!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; #else if (!i2s_write_sample_nb(dsBuff[0])) return false; // No room at the inn