mirror of
https://github.com/bluekitchen/btstack.git
synced 2025-04-01 04:20:33 +00:00
avdtp source: move buffer storage to the app
This commit is contained in:
parent
432dd4e851
commit
1bb14c3802
@ -50,12 +50,6 @@
|
||||
#include "avdtp_acceptor.h"
|
||||
#include "avdtp_initiator.h"
|
||||
|
||||
static uint8_t audio_samples_storage[44100*4]; // 1s buffer
|
||||
// static btstack_ring_buffer_t audio_ring_buffer;
|
||||
|
||||
static uint8_t sbc_samples_storage[44100*4];
|
||||
// static btstack_ring_buffer_t sbc_ring_buffer;
|
||||
|
||||
static void (*handle_media_data)(avdtp_stream_endpoint_t * stream_endpoint, uint8_t *packet, uint16_t size);
|
||||
|
||||
void avdtp_register_media_transport_category(avdtp_stream_endpoint_t * stream_endpoint){
|
||||
@ -196,6 +190,22 @@ avdtp_connection_t * avdtp_create_connection(bd_addr_t remote_addr, avdtp_contex
|
||||
return connection;
|
||||
}
|
||||
|
||||
void avdtp_init_audio_buffer(avdtp_stream_endpoint_t * stream_endpoint, uint8_t * storage, int storage_size){
|
||||
if (!stream_endpoint){
|
||||
printf("cannot init audio buffer, no stream_endpoint\n");
|
||||
return;
|
||||
}
|
||||
btstack_ring_buffer_init(&stream_endpoint->audio_ring_buffer, storage, storage_size);
|
||||
}
|
||||
|
||||
void avdtp_init_sbc_buffer(avdtp_stream_endpoint_t * stream_endpoint, uint8_t * storage, int storage_size){
|
||||
if (!stream_endpoint){
|
||||
printf("cannot init audio buffer, no stream_endpoint\n");
|
||||
return;
|
||||
}
|
||||
btstack_ring_buffer_init(&stream_endpoint->sbc_ring_buffer, storage, storage_size);
|
||||
}
|
||||
|
||||
avdtp_stream_endpoint_t * avdtp_create_stream_endpoint(avdtp_sep_type_t sep_type, avdtp_media_type_t media_type, avdtp_context_t * context){
|
||||
avdtp_stream_endpoint_t * stream_endpoint = btstack_memory_avdtp_stream_endpoint_get();
|
||||
memset(stream_endpoint, 0, sizeof(avdtp_stream_endpoint_t));
|
||||
@ -203,14 +213,6 @@ avdtp_stream_endpoint_t * avdtp_create_stream_endpoint(avdtp_sep_type_t sep_type
|
||||
stream_endpoint->sep.seid = context->stream_endpoints_id_counter;
|
||||
stream_endpoint->sep.media_type = media_type;
|
||||
stream_endpoint->sep.type = sep_type;
|
||||
|
||||
memset(audio_samples_storage, 0, sizeof(audio_samples_storage));
|
||||
btstack_ring_buffer_init(&stream_endpoint->audio_ring_buffer, audio_samples_storage, sizeof(audio_samples_storage));
|
||||
|
||||
memset(sbc_samples_storage, 0, sizeof(sbc_samples_storage));
|
||||
btstack_ring_buffer_init(&stream_endpoint->sbc_ring_buffer, sbc_samples_storage, sizeof(sbc_samples_storage));
|
||||
|
||||
|
||||
btstack_linked_list_add(&context->stream_endpoints, (btstack_linked_item_t *) stream_endpoint);
|
||||
return stream_endpoint;
|
||||
}
|
||||
|
@ -496,6 +496,9 @@ void avdtp_set_configuration(uint16_t con_handle, uint8_t int_seid, uint8_t acp_
|
||||
void avdtp_reconfigure(uint16_t con_handle, uint8_t acp_seid, uint16_t configured_services_bitmap, avdtp_capabilities_t configuration, avdtp_context_t * context);
|
||||
void avdtp_suspend(uint16_t con_handle, uint8_t acp_seid, avdtp_context_t * context);
|
||||
|
||||
void avdtp_init_audio_buffer(avdtp_stream_endpoint_t * stream_endpoint, uint8_t * storage, int storage_size);
|
||||
void avdtp_init_sbc_buffer(avdtp_stream_endpoint_t * stream_endpoint, uint8_t * storage, int storage_size);
|
||||
|
||||
#if defined __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
@ -468,6 +468,11 @@ typedef struct {
|
||||
int right_phase;
|
||||
} paTestData;
|
||||
|
||||
static uint8_t audio_samples_storage[44100*4]; // 1s buffer
|
||||
// static btstack_ring_buffer_t audio_ring_buffer;
|
||||
|
||||
static uint8_t sbc_samples_storage[44100*4];
|
||||
// static btstack_ring_buffer_t sbc_ring_buffer;
|
||||
static paTestData sin_data;
|
||||
|
||||
static void fill_sbc_ring_buffer(uint8_t * sbc_frame, int sbc_frame_size, avdtp_stream_endpoint_t * stream_endpoint){
|
||||
@ -699,6 +704,12 @@ int btstack_main(int argc, const char * argv[]){
|
||||
gap_set_class_of_device(0x200408);
|
||||
|
||||
avdtp_set_fill_audio_ring_buffer_timeout_ms(local_stream_endpoint, 50);
|
||||
memset(audio_samples_storage, 0, sizeof(audio_samples_storage));
|
||||
memset(sbc_samples_storage, 0, sizeof(sbc_samples_storage));
|
||||
|
||||
avdtp_init_audio_buffer(local_stream_endpoint, audio_samples_storage, sizeof(audio_samples_storage));
|
||||
avdtp_init_sbc_buffer(local_stream_endpoint, sbc_samples_storage, sizeof(sbc_samples_storage));
|
||||
|
||||
/* initialise sinusoidal wavetable */
|
||||
int i;
|
||||
for (i=0; i<TABLE_SIZE_441HZ; i++){
|
||||
|
Loading…
x
Reference in New Issue
Block a user