MrBuddyCasino / ESP32_MP3_Decoder

A internet radio and bluetooth speaker project for the Espressif ESP32
782 stars 182 forks source link

A2DP keep repeating same sound when calling on phone. #25

Closed fanthos closed 7 years ago

fanthos commented 7 years ago

I am using this project as bluetooth speaker. After connect my phone to ESP32, when I am making a call, the player keep repeating same sound until I stop calling.

The solution is call renderer_stop on a2dp receiving status 0.

Right now there is another problem. When renderer_start called, there's some noise before playing the audio. I am looking for a way to deal with that.

fanthos commented 7 years ago

I have current WIP code at https://github.com/fanthos/esp32-bt-iap.

MrBuddyCasino commented 7 years ago

Alright, wanna make a pull request?

fanthos commented 7 years ago

Put the code to this function: bt_app_av.c: bt_av_hdl_a2d_evt

    case ESP_A2D_AUDIO_STATE_EVT: {
        a2d = (esp_a2d_cb_param_t *)(p_param);
        ESP_LOGI(BT_AV_TAG, "a2dp audio_state_cb state %d", a2d->audio_stat.state);
        m_audio_state = a2d->audio_stat.state;
        if (ESP_A2D_AUDIO_STATE_STARTED == a2d->audio_stat.state) {
            m_pkt_cnt = 0;
            renderer_start();
        } else if (ESP_A2D_AUDIO_STATE_REMOTE_SUSPEND == a2d->audio_stat.state){
            renderer_stop();
        } else if (ESP_A2D_AUDIO_STATE_STOPPED == a2d->audio_stat.state){
            renderer_stop();
        }
        break;
    }
MrBuddyCasino commented 7 years ago

Thanks for contributing, merged.