Input_key_listener and audio_event_iface_listener don't work simultaneously?!
Posted: 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.
2.
3. 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.
2.
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?
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);
Code: Select all
esp_periph_handle_t button_handle = periph_button_init(&btn_cfg);
esp_periph_start(set, button_handle);
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);
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);
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);
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?