Skip to content

Commit

Permalink
Merge branch 'feature/sink_support_mono' into 'master'
Browse files Browse the repository at this point in the history
bt: Fixed sink not being able to output mono audio because it can only decode dual channel audio data

Closes BT-2698

See merge request espressif/esp-idf!19759
  • Loading branch information
wmy-espressif committed Sep 7, 2022
2 parents c6610ec + 697755d commit a026d98
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -415,7 +415,8 @@ static void btc_a2dp_sink_handle_decoder_reset(tBTC_MEDIA_SINK_CFG_UPDATE *p_msg
a2dp_sink_local_param.btc_aa_snk_cb.rx_flush = FALSE;
APPL_TRACE_EVENT("Reset to sink role");
status = OI_CODEC_SBC_DecoderReset(&a2dp_sink_local_param.context, a2dp_sink_local_param.contextData,
sizeof(a2dp_sink_local_param.contextData), 2, 2, FALSE, FALSE);
sizeof(a2dp_sink_local_param.contextData), a2dp_sink_local_param.btc_aa_snk_cb.channel_count,
a2dp_sink_local_param.btc_aa_snk_cb.channel_count, FALSE, FALSE);
if (!OI_SUCCESS(status)) {
APPL_TRACE_ERROR("OI_CODEC_SBC_DecoderReset failed with error code %d\n", status);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -302,6 +302,7 @@ static void bt_av_hdl_a2d_evt(uint16_t event, void *p_param)
/* for now only SBC stream is supported */
if (a2d->audio_cfg.mcc.type == ESP_A2D_MCT_SBC) {
int sample_rate = 16000;
int ch_count = 2;
char oct0 = a2d->audio_cfg.mcc.cie.sbc[0];
if (oct0 & (0x01 << 6)) {
sample_rate = 32000;
Expand All @@ -310,12 +311,18 @@ static void bt_av_hdl_a2d_evt(uint16_t event, void *p_param)
} else if (oct0 & (0x01 << 4)) {
sample_rate = 48000;
}

if (oct0 & (0x01 << 3)) {
ch_count = 1;
}
#ifdef CONFIG_EXAMPLE_A2DP_SINK_OUTPUT_INTERNAL_DAC
i2s_set_clk(0, sample_rate, 16, 2);
i2s_set_clk(0, sample_rate, 16, ch_count);
#else
i2s_channel_disable(tx_chan);
i2s_std_clk_config_t clk_cfg = I2S_STD_CLK_DEFAULT_CONFIG(sample_rate);
i2s_std_slot_config_t slot_cfg = I2S_STD_MSB_SLOT_DEFAULT_CONFIG(I2S_DATA_BIT_WIDTH_16BIT, ch_count);
i2s_channel_reconfig_std_clock(tx_chan, &clk_cfg);
i2s_channel_reconfig_std_slot(tx_chan, &slot_cfg);
i2s_channel_enable(tx_chan);
#endif
ESP_LOGI(BT_AV_TAG, "Configure audio player: %x-%x-%x-%x",
Expand Down

0 comments on commit a026d98

Please sign in to comment.