mirror of
https://github.com/sle118/squeezelite-esp32.git
synced 2025-12-07 20:17:04 +03:00
BT non-absolute volume handling
This commit is contained in:
@@ -296,6 +296,9 @@ static void bt_av_hdl_a2d_evt(uint16_t event, void *p_param)
|
||||
if (ESP_A2D_AUDIO_STATE_STARTED == a2d->audio_stat.state) {
|
||||
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
|
||||
if ((*bt_app_a2d_cmd_cb)(BT_SINK_AUDIO_STARTED, s_sample_rate)) {
|
||||
|
||||
|
||||
@@ -31,8 +31,6 @@ extern log_level loglevel;
|
||||
static bool enable_bt_sink;
|
||||
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 SYNC_WIN_SLOW 32
|
||||
#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;
|
||||
|
||||
if (cmd != BT_SINK_VOLUME && cmd != BT_SINK_AUDIO_STARTED) LOCK_O;
|
||||
if (cmd != BT_SINK_VOLUME) LOCK_O;
|
||||
|
||||
switch(cmd) {
|
||||
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.external = DECODE_BT;
|
||||
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);
|
||||
volume = 65536 * powf(volume / 128.0f, 3);
|
||||
set_volume(volume, volume);
|
||||
bt_volume = volume;
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
|
||||
Reference in New Issue
Block a user