Page 1 of 1

esp_audio library mutex

Posted: Sat Dec 28, 2019 6:49 pm
by chr1st0s
Hi,

Background: We are using IDF v3.2.2 with ADF pipelines for https and fatfs input streaming to I2S audio output. The I2C for configuring the external codec IC is shared with multiple peripherals, so we used a mutex to regulate access to this bus without the audio glitching. This required a modification in ADF mutex definition (in components/audio_sal/include/audio_mutex.h using extern), and it has been well tested and works very smoothly.

Now: I found the esp_audio library offers many features that could speedup our development. Unfortunately, it seems that the library doesn't use the same mutex so the audio glitches when other components try to access the same I2C bus. Do you know if the esp_audio exposes its I2C mutex/functions? Or we could somehow "extern" it in our project code?

Thank you,
Christos

Re: esp_audio library mutex

Posted: Mon Jan 06, 2020 7:55 am
by jason.mao
Hi chr1st0s,

Which I2C APIS did you used ? `esp-idf/components/driver/i2c.c` or `components/esp_peripherals/driver/i2c_bus/i2c_bus.c`.

Re: esp_audio library mutex

Posted: Wed Jan 08, 2020 12:08 pm
by chr1st0s
Apologies for the delay, I didn't receive a notification for your reply.

We are using `esp-idf/components/driver/i2c.c` in our project. Do you believe that esp_audio uses i2c_bus module? In that case, we can expose the `_busLock` since we already have the esp-adf modified.

Thank you,
Christos

Re: esp_audio library mutex

Posted: Wed Jan 08, 2020 12:39 pm
by jason.mao
Hi Christos,

The esp_audio only one situation could use i2c via audio_hal for get/set volume,not i2c_bus. The configuration of the esp_audio by the `esp_audio_cfg_t`,

Code: Select all

    cfg.vol_handle = board_handle->audio_hal;
    cfg.vol_set = (audio_volume_set)audio_hal_set_volume;
    cfg.vol_get = (audio_volume_get)audio_hal_get_volume;
If you can ensure the `audio_hal_set_volume` and `audio_hal_get_volume` use same lock, I think could fix your problem.

Re: esp_audio library mutex

Posted: Fri Jan 10, 2020 11:07 am
by chr1st0s
Hi jason.mao,

I added some log messages in the audio lock hooks and confirmed that esp_audio uses the same mutex. Tuning the variables in application layer cancelled the major audio distortion out.

Thank you,
Christos.

Re: esp_audio library mutex

Posted: Mon Jan 20, 2020 11:05 am
by jason.mao
Hi Christos,

We have modified the codec driver for use i2c_bus interfaces. Please refer to a91879f1144984ae7df8e6a6743bd08ca4c182eb.

Thanks.