example/a2dp_sink_demo: don't store sbc data in file

This commit is contained in:
Matthias Ringwald 2022-05-22 20:20:27 +02:00
parent 328627d19a
commit 527e8cd27e

View File

@ -85,8 +85,7 @@
#ifdef HAVE_POSIX_FILE_IO
#include "wav_util.h"
#define STORE_TO_SBC_FILE
#define STORE_TO_WAV_FILE
#define STORE_TO_WAV_FILE
#endif
#define NUM_CHANNELS 2
@ -124,11 +123,6 @@ static uint32_t audio_frame_count = 0;
static char * wav_filename = "a2dp_sink_demo.wav";
#endif
#ifdef STORE_TO_SBC_FILE
static FILE * sbc_file;
static char * sbc_filename = "av2dp_sink_demo.sbc";
#endif
typedef struct {
int reconfigure;
@ -391,10 +385,6 @@ static int media_processing_init(media_codec_configuration_sbc_t configuration){
wav_writer_open(wav_filename, configuration.num_channels, configuration.sampling_frequency);
#endif
#ifdef STORE_TO_SBC_FILE
sbc_file = fopen(sbc_filename, "wb");
#endif
btstack_ring_buffer_init(&sbc_frame_ring_buffer, sbc_frame_storage, sizeof(sbc_frame_storage));
btstack_ring_buffer_init(&decoded_audio_ring_buffer, decoded_audio_storage, sizeof(decoded_audio_storage));
btstack_resample_init(&resample_instance, configuration.num_channels);
@ -444,10 +434,6 @@ static void media_processing_close(void){
printf("WAV Writer: Wrote %u audio frames to wav file: %s\n", audio_frame_count, wav_filename);
#endif
#ifdef STORE_TO_SBC_FILE
fclose(sbc_file);
#endif
// stop audio playback
const btstack_audio_sink_t * audio = btstack_audio_sink_get_instance();
if (audio){
@ -477,10 +463,6 @@ static void handle_l2cap_media_data_packet(uint8_t seid, uint8_t *packet, uint16
avdtp_sbc_codec_header_t sbc_header;
if (!read_sbc_header(packet, size, &pos, &sbc_header)) return;
#ifdef STORE_TO_SBC_FILE
fwrite(packet+pos, size-pos, 1, sbc_file);
#endif
const btstack_audio_sink_t * audio = btstack_audio_sink_get_instance();
// process data right away if there's no audio implementation active, e.g. on posix systems to store as .wav
if (!audio){