Input_key_listener and audio_event_iface_listener don't work simultaneously?!

esplen
Posts: 1
Joined: Sat Oct 14, 2023 12:49 am

Input_key_listener and audio_event_iface_listener don't work simultaneously?!

Postby esplen » Sat Oct 14, 2023 1:30 am

Hi there,
I was trying to implement an audio player like the one in examples/player/pipeline_sdcard_mp3_control example that can stream the audio to a bluetooth sink like examples/player/pipeline_a2dp_source_stream.
For this i need the 4 buttons Play,Set,Volup, Voldown which are handled by the Input_key_listener like this:
1.

Code: Select all

esp_periph_config_t periph_cfg = DEFAULT_ESP_PERIPH_SET_CONFIG();
esp_periph_set_handle_t set = esp_periph_set_init(&periph_cfg);
2.

Code: Select all

esp_periph_handle_t button_handle = periph_button_init(&btn_cfg);
esp_periph_start(set, button_handle);
3.

Code: Select all

input_key_service_info_t input_key_info[] = INPUT_KEY_DEFAULT_INFO();
input_key_service_cfg_t input_cfg = INPUT_KEY_SERVICE_DEFAULT_CONFIG();
input_cfg.handle = set;
periph_service_handle_t input_ser = input_key_service_create(&input_cfg);
input_key_service_add_key(input_ser, input_key_info, INPUT_KEY_NUM);
periph_service_set_callback(input_ser, input_key_service_cb, (void *)board_handle);
where "input_key_service_cb" is the custom callback function.

This works fine unless I also set an audio event listener. I do this with the following lines of code:
1.

Code: Select all

esp_periph_handle_t bt_periph = bt_create_periph();
esp_periph_start(set, bt_periph);
2.

Code: Select all

audio_event_iface_cfg_t evt_cfg = AUDIO_EVENT_IFACE_DEFAULT_CFG();
audio_event_iface_handle_t evt = audio_event_iface_init(&evt_cfg);
audio_event_iface_set_listener(esp_periph_set_get_event_iface(set), evt);
I only use this audio event listener just for some Bluetooth_events! However it also listens for button events because the buttons are also an esp_peripheral and need to be initialised and started for the input_key_service to work with the "esp_periph_set_handle_t set".

As soon as the "audio_event_iface_set_listener(esp_periph_set_get_event_iface(set), evt);" line is called, the input key listener from above doesn't work anymore.

Does anyone have a solution for this?
Or am i missing something obvious here?

Ajmal shariff
Posts: 6
Joined: Thu Jun 01, 2023 12:45 pm

Re: Input_key_listener and audio_event_iface_listener don't work simultaneously?!

Postby Ajmal shariff » Mon Dec 11, 2023 2:06 pm

Hi

I am also facing the same issue , did you solve this issue?

GerryBriggs
Posts: 20
Joined: Tue Oct 24, 2023 10:11 pm

Re: Input_key_listener and audio_event_iface_listener don't work simultaneously?!

Postby GerryBriggs » Mon May 27, 2024 5:44 pm

I also had that problem. I just removed that line ( audio_event_iface_set_listener(esp_periph_set_get_event_iface(set), evt); ) entirely and somehow mine worked, with the buttons working as input_ser peripheral as normal.

I see that after over 6 months ESP-ADF (ie J.M. )doesn't reply to anything anymore

GerryBriggs
Posts: 20
Joined: Tue Oct 24, 2023 10:11 pm

Re: Input_key_listener and audio_event_iface_listener don't work simultaneously?!

Postby GerryBriggs » Mon May 27, 2024 7:05 pm

I looked back at this and realized that I got it to work with a different function:

audio_pipeline_set_listener(pipeline, evt)

Maybe this is some kind of legacy function, but it works. I dont see it in some of the newer examples

Who is online

Users browsing this forum: No registered users and 30 guests