I needed to use the ESP32 as a2dp_sink.
I tried out the example project provided with the 4.0 release - this also works - however I found out, that changing the volume on the smartphone side, does not affect the volume of the outcoming samples on the i2s-port. It is always the same loudness.
But in the debug-information, I saw, that the commands for changing the volume were received correctly.
Here a short workaround how to fix this:
1. Go to bt_app_av.c
->go to following line
Code: Select all
static uint8_t s_volume = 0;
and remove the "static".
2. Go to bt_app_av.h
-> declare the s_volume variable as extern by adding the following statement:
Code: Select all
extern uint8_t s_volume;
-> add following include statement
Code: Select all
#include "bt_app_av.h
Now go to the bt_i2s_task_handler where the samples are written to the i2s buffer and change it to following:
Code: Select all
static void bt_i2s_task_handler(void *arg)
{
uint8_t *data = NULL;
size_t item_size = 0;
size_t bytes_written = 0;
for (;;) {
data = (uint8_t *)xRingbufferReceive(s_ringbuf_i2s, &item_size, (portTickType)portMAX_DELAY);
if (item_size != 0){
int16_t * pcmdata = (int16_t *)data;
for (int i=0; i<item_size/2; i++) {
*pcmdata = ((*pcmdata)*s_volume)/127;
pcmdata++;
}
i2s_write(0, data, item_size, &bytes_written, portMAX_DELAY);
vRingbufferReturnItem(s_ringbuf_i2s,(void *)data);
}
}
}
Markus