pschatzmann / ESP32-A2DP

A Simple ESP32 Bluetooth A2DP Library (to implement a Music Receiver or Sender) that supports Arduino, PlatformIO and Espressif IDF
Apache License 2.0
1.65k stars 270 forks source link

setVolume() #444

Closed mitchjs closed 1 year ago

mitchjs commented 1 year ago

its been a while, where i thought my project was dead, has been resurrected and i ran in to this, i know its above you library but maybe someone seen this issue and solved.

IDF v4.4.x, latest ESP-A2DP

using a2dp sink, default volume, I'm using a rotatory encoder to change volume. when I rotate slow no issue, its when i go fast, and really its not that fast. all I do is call a2dp_sink.set_volume(level) and level is calculated by encoder.

I (2563469) BT_AV: Volume is set locally to: 44 I (2563469) MyMain: ========================> AVRC (local) volume change to 44 I (2563509) BT_AV: AVRC register event notification: 13, param: 0x0 E (2563509) BT_BTC: Event id not registered: event_id = d I (2563529) BT_AV: set_volume 60 I (2563529) BT_AV: Volume is set locally to: 47 I (2563529) MyMain: ========================> AVRC (local) volume change to 47 I (2563599) BT_AV: AVRC register event notification: 13, param: 0x0 E (2563609) BT_BTC: Event id not registered: event_id = d I (2563689) BT_AV: AVRC register event notification: 13, param: 0x0 I (2564179) BT_AV: set_volume 64

BT_BTC is above your lib also it seems volume is working... despite those errors but like i said, if i go fast (lots of set_volumes()) i get that error slow no issue prob could create a xtask to simulate volume ramps

also should we see ESP_AVRC_TG_REGISTER_NOTIFICATION_EVT on every volume change?

thanks again, Mitch

mitchjs commented 1 year ago

i have it solved, i added a callback after ESP_AVRC_TG_REGISTER_NOTIFICATION_EVT (eventid == ESP_AVRC_RN_VOLUME_CHANGE) and used that to tell my code that another volume change can be allowed (re-enabled the rotary interrupts) and when i send a local volume change, i disable the rotary encoder)

i got a bunch of other adds to the LIB, i will do a PR soon

mitch