BT non-absolute volume handling

This commit is contained in:
Philippe G
2021-03-07 16:33:26 -08:00
parent b0d8401274
commit b9466bf7b2
2 changed files with 4 additions and 6 deletions

View File

@@ -295,6 +295,9 @@ static void bt_av_hdl_a2d_evt(uint16_t event, void *p_param)
if (ESP_A2D_AUDIO_STATE_STARTED == a2d->audio_stat.state) { if (ESP_A2D_AUDIO_STATE_STARTED == a2d->audio_stat.state) {
s_audio = AUDIO_CONNECTED; s_audio = AUDIO_CONNECTED;
// send memorized volume for devices that can't do absolute volume
(*bt_app_a2d_cmd_cb)(BT_SINK_VOLUME, s_volume);
// verify that we can take control // verify that we can take control
if ((*bt_app_a2d_cmd_cb)(BT_SINK_AUDIO_STARTED, s_sample_rate)) { if ((*bt_app_a2d_cmd_cb)(BT_SINK_AUDIO_STARTED, s_sample_rate)) {

View File

@@ -31,8 +31,6 @@ extern log_level loglevel;
static bool enable_bt_sink; static bool enable_bt_sink;
static bool enable_airplay; static bool enable_airplay;
static unsigned bt_volume;
#define RAOP_OUTPUT_SIZE (((RAOP_SAMPLE_RATE * BYTES_PER_FRAME * 2 * 120) / 100) & ~BYTES_PER_FRAME) #define RAOP_OUTPUT_SIZE (((RAOP_SAMPLE_RATE * BYTES_PER_FRAME * 2 * 120) / 100) & ~BYTES_PER_FRAME)
#define SYNC_WIN_SLOW 32 #define SYNC_WIN_SLOW 32
#define SYNC_WIN_CHECK 8 #define SYNC_WIN_CHECK 8
@@ -108,12 +106,10 @@ static bool bt_sink_cmd_handler(bt_sink_cmd_t cmd, va_list args)
LOCK_D; LOCK_D;
if (cmd != BT_SINK_VOLUME && cmd != BT_SINK_AUDIO_STARTED) LOCK_O; if (cmd != BT_SINK_VOLUME) LOCK_O;
switch(cmd) { switch(cmd) {
case BT_SINK_AUDIO_STARTED: case BT_SINK_AUDIO_STARTED:
if (output.external != DECODE_BT) set_volume(bt_volume, bt_volume);
LOCK_O;
output.next_sample_rate = output.current_sample_rate = va_arg(args, u32_t); output.next_sample_rate = output.current_sample_rate = va_arg(args, u32_t);
output.external = DECODE_BT; output.external = DECODE_BT;
output.state = OUTPUT_STOPPED; output.state = OUTPUT_STOPPED;
@@ -151,7 +147,6 @@ static bool bt_sink_cmd_handler(bt_sink_cmd_t cmd, va_list args)
u32_t volume = va_arg(args, u32_t); u32_t volume = va_arg(args, u32_t);
volume = 65536 * powf(volume / 128.0f, 3); volume = 65536 * powf(volume / 128.0f, 3);
set_volume(volume, volume); set_volume(volume, volume);
bt_volume = volume;
break; break;
default: default:
break; break;