mirror of
https://github.com/bluekitchen/btstack.git
synced 2025-03-28 08:37:22 +00:00
esp32: implement audio sink interface
This commit is contained in:
parent
0402264ca0
commit
195e44814f
@ -103,7 +103,7 @@ static void driver_timer_handler(btstack_timer_source_t * ts){
|
||||
btstack_run_loop_add_timer(ts);
|
||||
}
|
||||
|
||||
static int btstack_audio_esp32_init(
|
||||
static int btstack_audio_esp32_sink_init(
|
||||
uint8_t channels,
|
||||
uint32_t samplerate,
|
||||
void (*playback)(int16_t * buffer, uint16_t num_samples),
|
||||
@ -140,7 +140,7 @@ static int btstack_audio_esp32_init(
|
||||
return 0;
|
||||
}
|
||||
|
||||
static void btstack_audio_esp32_start_stream(void){
|
||||
static void btstack_audio_esp32_sink_start_stream(void){
|
||||
|
||||
if (playback_callback){
|
||||
// pre-fill HAL buffers
|
||||
@ -162,7 +162,7 @@ static void btstack_audio_esp32_start_stream(void){
|
||||
btstack_run_loop_add_timer(&driver_timer);
|
||||
}
|
||||
|
||||
static void btstack_audio_esp32_close(void){
|
||||
static void btstack_audio_esp32_sink_close(void){
|
||||
// stop timer
|
||||
btstack_run_loop_remove_timer(&driver_timer);
|
||||
|
||||
@ -173,12 +173,26 @@ static void btstack_audio_esp32_close(void){
|
||||
i2s_driver_uninstall(i2s_num);
|
||||
}
|
||||
|
||||
static const btstack_audio_t btstack_audio_esp32 = {
|
||||
/* int (*init)(..);*/ &btstack_audio_esp32_init,
|
||||
/* void (*start_stream(void));*/ &btstack_audio_esp32_start_stream,
|
||||
/* void (*close)(void); */ &btstack_audio_esp32_close
|
||||
static const btstack_audio_t btstack_audio_sink_esp32 = {
|
||||
/* int (*init)(..);*/ &btstack_audio_esp32_sink_init,
|
||||
/* void (*start_stream(void));*/ &btstack_audio_esp32_sink_start_stream,
|
||||
/* void (*close)(void); */ &btstack_audio_esp32_sink_close
|
||||
};
|
||||
|
||||
const btstack_audio_t * btstack_audio_esp32_get_instance(void){
|
||||
return &btstack_audio_esp32;
|
||||
#if 0
|
||||
static const btstack_audio_t btstack_audio_source_esp32 = {
|
||||
/* int (*init)(..);*/ &btstack_audio_esp32_source_init,
|
||||
/* void (*start_stream(void));*/ &btstack_audio_esp32_source_start_stream,
|
||||
/* void (*close)(void); */ &btstack_audio_esp32_source_close
|
||||
};
|
||||
#endif
|
||||
|
||||
const btstack_audio_sink_t * btstack_audio_esp32_sink_get_instance(void){
|
||||
return &btstack_audio_esp32_sink;
|
||||
}
|
||||
|
||||
#if 0
|
||||
const btstack_audio_source_t * btstack_audio_esp32_source_get_instance(void){
|
||||
return &btstack_audio_esp32_source;
|
||||
}
|
||||
#endif
|
||||
|
@ -385,8 +385,8 @@ int app_main(void){
|
||||
hci_event_callback_registration.callback = &packet_handler;
|
||||
hci_add_event_handler(&hci_event_callback_registration);
|
||||
|
||||
// setup i2s audio
|
||||
btstack_audio_set_instance(btstack_audio_esp32_get_instance());
|
||||
// setup i2s audio sink
|
||||
btstack_audio_sink_set_instance(btstack_audio_esp32_sink_get_instance());
|
||||
|
||||
btstack_main(0, NULL);
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user