-
-
Notifications
You must be signed in to change notification settings - Fork 326
Open
Description
Problem Description
Hi, I wrote a simple A2DP sink to HTTP Server WAV to be able to stream a bluetooth device to a uPNP/DNLA player.
The application compiles and starts correctly, this is the serial output:
Connecting to WiFi.
Connected! Stream URL: http://192.168.1.39/stream.wav
Starting Bluetooth...
[I] A2DPStream.h : 142 - Connecting to A2DP-Streamer
[I] A2DPStream.h : 183 - Starting a2dp_sink...
[W] A2DPStream.h : 347 - ==> state: Connecting
E (11752) I2S: i2s_set_clk(1620): I2S0 has not installed yet
[ 11790][E][BluetoothA2DPOutput.cpp:170] set_sample_rate(): [BT_AV] i2s_set_clk failed with samplerate=44100
[W] A2DPStream.h : 347 - ==> state: Connected
[I] A2DPStream.h : 196 - a2dp_sink is connected...
Starting HTTP Server...
[I] CodecWAV.h : 577 - sample_rate: 44100
[I] CodecWAV.h : 578 - channels: 2
[I] CodecWAV.h : 589 - is_streamed! because length is 2147418112
[I] CodecWAV.h : 577 - sample_rate: 44100
[I] CodecWAV.h : 578 - channels: 2
[I] CodecWAV.h : 589 - is_streamed! because length is 4294967295
IP address: 192.168.1.39
System Ready.
Once I connect the HTTP player I receive this error:
[I] AudioServerT.h : 265 - New Client:
[ 40389][E][WiFiClient.cpp:67] fillBuffer(): Not enough memory to allocate buffer
[ 40397][E][WiFiClient.cpp:474] read(): fail on fd 49, errno: 11, "No more processes"
[I] AudioServerT.h : 265 - New Client:
[I] AudioServerT.h : 275 - Request: GET /stream.wav HTTP/1.1
[I] AudioServerT.h : 275 - Request: Host: 192.168.1.39
[I] AudioServerT.h : 275 - Request: User-Agent: curl/8.7.1
[I] AudioServerT.h : 275 - Request: Accept: */*
[I] AudioServerT.h : 275 - Request:
[I] AudioEncodedServerT.h : 165 - sendReply - Returning encoded stream...
[I] StreamCopy.h : 63 - buffer_size=1024
Guru Meditation Error: Core 0 panic'ed (StoreProhibited). Exception was unhandled.
Core 0 register dump:
PC : 0x4011630b PS : 0x00060d30 A0 : 0x801156e4 A1 : 0x3ffeb250
A2 : 0x3fffe884 A3 : 0x000003cd A4 : 0x000002ab A5 : 0x00000080
A6 : 0x3fffe88c A7 : 0x00000000 A8 : 0x00001100 A9 : 0x3ffeb230
A10 : 0x00000000 A11 : 0x3fffe88d A12 : 0x000002ab A13 : 0x00060023
A14 : 0x00060021 A15 : 0x00000001 SAR : 0x0000001a EXCCAUSE: 0x0000001d
EXCVADDR: 0x00000002 LBEG : 0x40091d00 LEND : 0x40091d16 LCOUNT : 0xffffffff
Backtrace: 0x40116308:0x3ffeb250 0x401156e1:0x3ffeb280 0x4014d089:0x3ffeb2a0 0x4013e6a1:0x3ffeb2e0 0x4013e637:0x3ffeb300
This is the decoded backtrace:
0x40116308: reassemble_and_dispatch at /home/runner/work/esp32-arduino-lib-builder/esp32-arduino-lib-builder/esp-idf/components/bt/host/bluedroid/hci/packet_fragmenter.c:178
0x40116308: reassemble_and_dispatch at /home/runner/work/esp32-arduino-lib-builder/esp32-arduino-lib-builder/esp-idf/components/bt/host/bluedroid/hci/packet_fragmenter.c:136
0x401156e1: hal_says_packet_ready at /home/runner/work/esp32-arduino-lib-builder/esp32-arduino-lib-builder/esp-idf/components/bt/host/bluedroid/hci/hci_layer.c:416
0x4014d089: hci_hal_h4_hdl_rx_packet at /home/runner/work/esp32-arduino-lib-builder/esp32-arduino-lib-builder/esp-idf/components/bt/host/bluedroid/hci/hci_hal_h4.c:471
0x4014d089: hci_upstream_data_handler at /home/runner/work/esp32-arduino-lib-builder/esp32-arduino-lib-builder/esp-idf/components/bt/host/bluedroid/hci/hci_hal_h4.c:231
0x4013e6a1: osi_thread_generic_event_handler at /home/runner/work/esp32-arduino-lib-builder/esp32-arduino-lib-builder/esp-idf/components/bt/common/osi/thread.c:425
0x4013e6a1: osi_thread_generic_event_handler at /home/runner/work/esp32-arduino-lib-builder/esp32-arduino-lib-builder/esp-idf/components/bt/common/osi/thread.c:418
0x4013e637: osi_thread_run at /home/runner/work/esp32-arduino-lib-builder/esp32-arduino-lib-builder/esp-idf/components/bt/common/osi/thread.c:165
Any help/suggestion is well accepted.
Device Description
M5Stack Atom Lite
M5Camera
Sketch
/**
* ESP32 Bluetooth A2DP to HTTP WAV Streamer
* * Flow: Bluetooth (Source) -> A2DPStream -> StreamCopy -> WAVEncoder -> AudioServer (HTTP)
*/
#include <Arduino.h>
#include <WiFi.h>
// 1. Include AudioTools
#include "AudioTools.h"
#include "AudioTools/Communication/AudioHttp.h"
// 2. Include the A2DP Library extensions
// Note: We use A2DPStream which wraps the ESP32-A2DP library into a streamable object
#include "AudioTools/Communication/A2DPStream.h"
// --- Configuration ---
const char *ssid = "***";
const char *password = "***";
const char *bt_name = "A2DP-Streamer";
// --- Global Objects ---
// The Audio Server acts as the Output destination (Sink)
// It creates a webserver on port 80
AudioEncoderServer server(new WAVEncoder(),ssid,password,);
// The A2DP Stream acts as the Audio Source (Input)
// It internally manages the BluetoothA2DPSink
A2DPStream in;
void setup() {
Serial.begin(115200);
AudioLogger::instance().begin(Serial, AudioLogger::Info);
// 1. Setup Wi-Fi
WiFi.mode(WIFI_STA);
WiFi.begin(ssid, password);
Serial.print("Connecting to WiFi");
while (WiFi.status() != WL_CONNECTED) {
delay(500);
Serial.print(".");
}
Serial.println();
Serial.print("Connected! Stream URL: http://");
Serial.print(WiFi.localIP());
Serial.println("/stream.wav");
// 2. Setup A2DP Source
Serial.println("Starting Bluetooth...");
auto cfg = in.defaultConfig(RX_MODE);
cfg.name = bt_name;
in.begin(cfg);
// // 3. Setup HTTP Server
Serial.println("Starting HTTP Server...");
server.begin(in);
Serial.println("System Ready.");
}
void loop() {
// This is the core engine. It checks if data is available from Bluetooth
// and copies it to the HTTP server buffer.
// The AudioServer handles client connections automatically in the background.
server.doLoop();
}Other Steps to Reproduce
Compile and upload, connect bluetooth device, open http endpoint
What is your development environment (incl. core version info)
PlatformIO
[env:esp32dev]
platform = espressif32
board = m5stack-atom
framework = arduino
monitor_speed = 115200
upload_speed = 115200
; High CPU frequency is recommended for audio processing
board_build.f_cpu = 240000000L
; Increase partition size for app (Audio libraries are large)
board_build.partitions = huge_app.csv
lib_deps =
; The core audio framework
https://github.com/pschatzmann/arduino-audio-tools.git
; The Bluetooth A2DP library
https://github.com/pschatzmann/ESP32-A2DP.git
build_flags =
-DCORE_DEBUG_LEVEL=1
; Essential to prevent WiFi sleep from killing the audio stream jitter
-DCONFIG_WIFI_ENABLED=1
I have checked existing issues, discussions and online documentation (incl. the Wiki)
- I confirm I have checked existing issues, discussions and online documentation
Metadata
Metadata
Assignees
Labels
No labels