esp_audio library mutex

chr1st0s
Posts: 15
Joined: Fri Nov 01, 2019 10:05 am

esp_audio library mutex

Postby chr1st0s » Sat Dec 28, 2019 6:49 pm

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

jason.mao
Posts: 98
Joined: Mon Nov 19, 2018 2:05 am

Re: esp_audio library mutex

Postby jason.mao » Mon Jan 06, 2020 7:55 am

Hi chr1st0s,

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

chr1st0s
Posts: 15
Joined: Fri Nov 01, 2019 10:05 am

Re: esp_audio library mutex

Postby chr1st0s » Wed Jan 08, 2020 12:08 pm

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

jason.mao
Posts: 98
Joined: Mon Nov 19, 2018 2:05 am

Re: esp_audio library mutex

Postby jason.mao » Wed Jan 08, 2020 12:39 pm

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.

chr1st0s
Posts: 15
Joined: Fri Nov 01, 2019 10:05 am

Re: esp_audio library mutex

Postby chr1st0s » Fri Jan 10, 2020 11:07 am

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.

jason.mao
Posts: 98
Joined: Mon Nov 19, 2018 2:05 am

Re: esp_audio library mutex

Postby jason.mao » Mon Jan 20, 2020 11:05 am

Hi Christos,

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

Thanks.

Who is online

Users browsing this forum: No registered users and 52 guests