Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix crash in Bluetooth-sink mode (speaker) #236

Closed
wants to merge 6 commits into from
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
20 changes: 9 additions & 11 deletions src/Bluetooth.cpp
Expand Up @@ -24,27 +24,25 @@
#endif

#ifdef BLUETOOTH_ENABLE
const char *getType() {
// for esp_a2d_connection_state_t see https://docs.espressif.com/projects/esp-idf/en/latest/esp32/api-reference/bluetooth/esp_a2dp.html#_CPPv426esp_a2d_connection_state_t
void connection_state_changed(esp_a2d_connection_state_t state, void *ptr) {
if (System_GetOperationMode() == OPMODE_BLUETOOTH_SINK) {
return "sink";
Log_Printf(LOGLEVEL_INFO, "Bluetooth sink => connection state: %s", a2dp_sink->to_str(state));
} else {
return "source";
Log_Printf(LOGLEVEL_INFO, "Bluetooth source => connection state: %s", a2dp_source->to_str(state));
}
}
#endif

#ifdef BLUETOOTH_ENABLE
// for esp_a2d_connection_state_t see https://docs.espressif.com/projects/esp-idf/en/latest/esp32/api-reference/bluetooth/esp_a2dp.html#_CPPv426esp_a2d_connection_state_t
void connection_state_changed(esp_a2d_connection_state_t state, void *ptr) {
Log_Printf(LOGLEVEL_INFO, "Bluetooth %s => connection state: %s", getType(), a2dp_source->to_str(state));
}
#endif


#ifdef BLUETOOTH_ENABLE
// for esp_a2d_audio_state_t see https://docs.espressif.com/projects/esp-idf/en/latest/esp32/api-reference/bluetooth/esp_a2dp.html#_CPPv421esp_a2d_audio_state_t
void audio_state_changed(esp_a2d_audio_state_t state, void *ptr) {
Log_Printf(LOGLEVEL_INFO, "Bluetooth %s => audio state: %s", getType(), a2dp_source->to_str(state));
if (System_GetOperationMode() == OPMODE_BLUETOOTH_SINK) {
Log_Printf(LOGLEVEL_INFO, "Bluetooth sink => audio state: %s", a2dp_sink->to_str(state));
} else {
Log_Printf(LOGLEVEL_INFO, "Bluetooth source => audio state: %s", a2dp_source->to_str(state));
}
}
#endif

Expand Down