schreibfaul1 / ESP32-audioI2S

Play mp3 files from SD via I2S
GNU General Public License v3.0
1.12k stars 289 forks source link

Arduino 3.0.0 Error 263 #755

Closed rvbc1 closed 3 months ago

rvbc1 commented 5 months ago

Hi,

Today I was testing the new release of stable Arduino 3.0.0. When I uploaded the code, the audio plays (but is not clear), and I also see message spam on the serial port:


[140469][E][Audio.cpp:4799] playSample(): ESP32 Errorcode 263
[140475][E][Audio.cpp:4799] playSample(): ESP32 Errorcode 263
[140498][E][Audio.cpp:4799] playSample(): ESP32 Errorcode 263
[140519][E][Audio.cpp:4799] playSample(): ESP32 Errorcode 263
[140537][E][Audio.cpp:4799] playSample(): ESP32 Errorcode 263
[140544][E][Audio.cpp:4799] playSample(): ESP32 Errorcode 263
[140565][E][Audio.cpp:4799] playSample(): ESP32 Errorcode 263
[140575][E][Audio.cpp:4799] playSample(): ESP32 Errorcode 263
[140590][E][Audio.cpp:4799] playSample(): ESP32 Errorcode 263
[140600][E][Audio.cpp:4799] playSample(): ESP32 Errorcode 263
[140621][E][Audio.cpp:4799] playSample(): ESP32 Errorcode 263
[140636][E][Audio.cpp:4799] playSample(): ESP32 Errorcode 263
[140646][E][Audio.cpp:4799] playSample(): ESP32 Errorcode 263
[140661][E][Audio.cpp:4799] playSample(): ESP32 Errorcode 263
[140672][E][Audio.cpp:4799] playSample(): ESP32 Errorcode 263
[140681][E][Audio.cpp:4799] playSample(): ESP32 Errorcode 263
[140702][E][Audio.cpp:4799] playSample(): ESP32 Errorcode 263
[140725][E][Audio.cpp:4799] playSample(): ESP32 Errorcode 263
[140749][E][Audio.cpp:4799] playSample(): ESP32 Errorcode 263
[140765][E][Audio.cpp:4799] playSample(): ESP32 Errorcode 263
[140775][E][Audio.cpp:4799] playSample(): ESP32 Errorcode 263
[140785][E][Audio.cpp:4799] playSample(): ESP32 Errorcode 263
[140809][E][Audio.cpp:4799] playSample(): ESP32 Errorcode 263
[140830][E][Audio.cpp:4799] playSample(): ESP32 Errorcode 263
[140846][E][Audio.cpp:4799] playSample(): ESP32 Errorcode 263
[140856][E][Audio.cpp:4799] playSample(): ESP32 Errorcode 263

I’m using the ESP32 Wrover on a custom board. Here is my PlatformIO configuration:

[env]
platform = https://github.com/platformio/platform-espressif32.git#v6.7.0

platform_packages=
  framework-arduinoespressif32 @ https://github.com/espressif/arduino-esp32.git#3.0.0
  framework-arduinoespressif32-libs @ https://github.com/espressif/arduino-esp32/releases/download/3.0.0/esp32-arduino-libs-3.0.0.zip

board = esp32dev
framework = arduino

lib_deps = 
    https://github.com/schreibfaul1/ESP32-audioI2S.git#3.0.8

build_flags = 
    -std=gnu++17
    -DBOARD_HAS_PSRAM 
    -mfix-esp32-psram-cache-issue

build_unflags = 
    -std=gnu++11
    -std=gnu99
rvbc1 commented 5 months ago

Without these lines:

platform_packages=
  framework-arduinoespressif32 @ https://github.com/espressif/arduino-esp32.git#3.0.0
  framework-arduinoespressif32-libs @ https://github.com/espressif/arduino-esp32/releases/download/3.0.0/esp32-arduino-libs-3.0.0.zip

the Arduino version is 2.0.16 (as in PlatformIO 6.7.0), and everything works fine with the same code.

AJR1010 commented 5 months ago

Probably the same problem here. I'm using the Arduino IDE with esp32 platform. The following minimal code runs fine (switches between two streams, playing each for a few seconds) using the esp32 platform 2.0.17. When I switch to platform 3.0.0 the 2nd stream hangs (see 2nd printout below). I'm using a ESP32-WROVER-E module which has a ESP32-DOWD-V3 dual-core chip and PSRAM.

#include <Arduino.h>
#include <WiFi.h>
#include "Audio.h"

#define I2S_DOUT      25
#define I2S_BCLK      27
#define I2S_LRC       26

Audio audio;

String ssid =     "___";
String password = "___";

String stations[] ={
        "0n-80s.radionetz.de:8000/0n-70s.mp3",
        "mp3.ffh.de/radioffh/hqlivestream.aac", //  128k aac
};

long t;
int c=0;
void setup() {
    Serial.begin(115200);
    WiFi.begin(ssid.c_str(), password.c_str());
    while (WiFi.status() != WL_CONNECTED){ delay(2000); }
    audio.setPinout(I2S_BCLK, I2S_LRC, I2S_DOUT);
    audio.setVolume(10); 
    audio.connecttohost(stations[c].c_str());
    t = millis();
}

void loop() {
    audio.loop();
    if(millis()>(t+7000)) {
      audio.connecttohost(stations[c].c_str());
      c = (c+1) % 2;
      t = millis();
    }
}

void audio_info(const char *info){
    Serial.print("audio_info: "); Serial.println(info);
}

Using platform 2.0.17, it works fine:

audio_info: PSRAM found, inputBufferSize: 638965 bytes
audio_info: buffers freed, free Heap: 209840 bytes
audio_info: Connection has been established in 148 ms, free Heap: 208580 bytes
audio_info: MP3Decoder has been initialized, free Heap: 184184 bytes , free stack 6220 DWORDs
audio_info: stream ready
audio_info: syncword found at pos 0
audio_info: Channels: 2
audio_info: SampleRate: 44100
audio_info: BitsPerSample: 16
audio_info: BitRate: 128000
audio_info: StreamTitle='The Rubettes - Sugar Baby Love '
audio_info: Connect to new host: "http://0n-80s.radionetz.de:8000/0n-70s.mp3"
audio_info: buffers freed, free Heap: 208824 bytes
audio_info: Connection has been established in 137 ms, free Heap: 208584 bytes
audio_info: MP3Decoder has been initialized, free Heap: 184188 bytes , free stack 6220 DWORDs
audio_info: stream ready
audio_info: syncword found at pos 0
audio_info: Channels: 2
audio_info: SampleRate: 44100
audio_info: BitsPerSample: 16
audio_info: BitRate: 128000
audio_info: StreamTitle='The Rubettes - Sugar Baby Love '
audio_info: Connect to new host: "http://mp3.ffh.de/radioffh/hqlivestream.aac"
audio_info: buffers freed, free Heap: 208824 bytes
audio_info: Connection has been established in 262 ms, free Heap: 208604 bytes
audio_info: AACDecoder has been initialized, free Heap: 186936 bytes , free stack 6220 DWORDs
audio_info: stream ready
audio_info: syncword found at pos 0
audio_info: Channels: 2
audio_info: SampleRate: 22050
audio_info: BitsPerSample: 16
audio_info: BitRate: 127993
audio_info: AAC HeaderFormat: ADTS
audio_info: AAC Codec: MPEG-2 LowComplexity
audio_info: StreamTitle='Genesis - Land Of Confusion'
audio_info: Connect to new host: "http://0n-80s.radionetz.de:8000/0n-70s.mp3"
audio_info: buffers freed, free Heap: 209400 bytes
audio_info: Connection has been established in 158 ms, free Heap: 208608 bytes
audio_info: MP3Decoder has been initialized, free Heap: 184216 bytes , free stack 6220 DWORDs

After upgrading to 3.0.0, it fails playing after switching to the second stream; sometimes it returns playing the first stream but not always. (to switch platforms I go to Tools->Board->BoardsManager, search for "esp32", chose the one from espressif, choose the version from the dropdown list).

audio_info: PSRAM found, inputBufferSize: 638965 bytes
audio_info: buffers freed, free Heap: 211348 bytes
audio_info: Connection has been established in 182 ms, free Heap: 210216 bytes
audio_info: MP3Decoder has been initialized, free Heap: 185820 bytes , free stack 6332 DWORDs
audio_info: stream ready
audio_info: syncword found at pos 0
audio_info: Channels: 2
audio_info: SampleRate: 44100
audio_info: BitsPerSample: 16
audio_info: BitRate: 128000
audio_info: StreamTitle='Sweet - Teenage Rampage '
audio_info: slow stream, dropouts are possible
audio_info: Connect to new host: "http://0n-80s.radionetz.de:8000/0n-70s.mp3"
audio_info: buffers freed, free Heap: 210640 bytes
audio_info: Connection has been established in 147 ms, free Heap: 210012 bytes
audio_info: MP3Decoder has been initialized, free Heap: 185824 bytes , free stack 6332 DWORDs
audio_info: stream ready
audio_info: syncword found at pos 0
audio_info: Channels: 2
audio_info: SampleRate: 44100
audio_info: BitsPerSample: 16
audio_info: BitRate: 128000
audio_info: StreamTitle='Sweet - Teenage Rampage '
audio_info: slow stream, dropouts are possible
audio_info: Connect to new host: "http://mp3.ffh.de/radioffh/hqlivestream.aac"
audio_info: buffers freed, free Heap: 211004 bytes
audio_info: Request http://mp3.ffh.de/radioffh/hqlivestream.aac failed!
audio_info: Connect to new host: "http://0n-80s.radionetz.de:8000/0n-70s.mp3"
audio_info: buffers freed, free Heap: 211024 bytes
audio_info: Connection has been established in 187 ms, free Heap: 210420 bytes
audio_info: MP3Decoder has been initialized, free Heap: 185828 bytes , free stack 6332 DWORDs
audio_info: stream ready
audio_info: syncword found at pos 0
audio_info: Channels: 2
audio_info: SampleRate: 44100
audio_info: BitsPerSample: 16
audio_info: BitRate: 128000
audio_info: StreamTitle='Sweet - Teenage Rampage '
audio_info: Connect to new host: "http://mp3.ffh.de/radioffh/hqlivestream.aac"
audio_info: buffers freed, free Heap: 210632 bytes
**audio_info: Request http://mp3.ffh.de/radioffh/hqlivestream.aac failed!**
audio_info: Connect to new host: "http://0n-80s.radionetz.de:8000/0n-70s.mp3"
audio_info: buffers freed, free Heap: 211024 bytes
audio_info: Connection has been established in 178 ms, free Heap: 210420 bytes
audio_info: MP3Decoder has been initialized, free Heap: 185836 bytes , free stack 6332 DWORDs
audio_info: stream ready

Thank you for consideration. Let me know if more details are needed.

shbgr commented 5 months ago

Arduino 3.0 brings IDF 5 with this new error code 263. Likely the mass of debug messages causes some stuttering. 54 bytes (4ms @ 115.2kBaud) every 6.5 ms (@44.1kHz) keep the cpu quite busy. Maybe try again without debug messages. Or patch the lib for the error. The 263 code is handled in master, but likely not in the release.

schreibfaul1 commented 5 months ago

You must have used PlatformIO. https://github.com/platformio/platform-espressif32/issues/1225#issuecomment-2141654957

I tested it yesterday with the Arduino IDE. There is no "263", but sometimes there are DNS problems. If you change the URL several times, the host can no longer be reached.

rvbc1 commented 4 months ago

Update: I tested it on Arduino versions 3.0.0, 3.0.1, and 3.0.2, and the issue still exists. However, I was testing with the following library dependency:

lib_deps = 
    https://github.com/schreibfaul1/ESP32-audioI2S.git#3.0.8

On the current version 3.0.11e (commit 0a1674329449581a70c8e8ca7fff0e406b23d820), everything sounds okay.

lib_deps = 
    https://github.com/schreibfaul1/ESP32-audioI2S.git#0a1674329449581a70c8e8ca7fff0e406b23d820
github-actions[bot] commented 3 months ago

This issue is stale because it has been open for 30 days with no activity.

github-actions[bot] commented 3 months ago

This issue was closed because it has been inactive for 14 days since being marked as stale.