mirror of
https://github.com/bluekitchen/btstack.git
synced 2025-01-30 15:32:41 +00:00
example/sco_demo_util: drop ENABLE_SCO_STEREO_PLAYBACK code
This commit is contained in:
parent
324a1b416e
commit
0b5a695acc
@ -76,7 +76,6 @@
|
||||
// number of sco packets until 'report' on console
|
||||
#define SCO_REPORT_PERIOD 100
|
||||
|
||||
// #define ENABLE_SCO_STEREO_PLAYBACK
|
||||
|
||||
#ifdef HAVE_POSIX_FILE_IO
|
||||
// length and name of wav file on disk
|
||||
@ -210,11 +209,7 @@ static void playback_callback(int16_t * buffer, uint16_t num_samples){
|
||||
// fill with silence while paused
|
||||
if (audio_output_paused){
|
||||
if (btstack_ring_buffer_bytes_available(&audio_output_ring_buffer) < prebuffer_bytes){
|
||||
#ifdef ENABLE_SCO_STEREO_PLAYBACK
|
||||
memset(buffer, 0, num_samples * BYTES_PER_FRAME * 2);
|
||||
#else
|
||||
memset(buffer, 0, num_samples * BYTES_PER_FRAME);
|
||||
#endif
|
||||
return;
|
||||
} else {
|
||||
// resume playback
|
||||
@ -224,32 +219,13 @@ static void playback_callback(int16_t * buffer, uint16_t num_samples){
|
||||
|
||||
// get data from ringbuffer
|
||||
uint32_t bytes_read = 0;
|
||||
#ifdef ENABLE_SCO_STEREO_PLAYBACK
|
||||
while (num_samples){
|
||||
int16_t temp[16];
|
||||
unsigned int bytes_to_read = btstack_min(num_samples * BYTES_PER_FRAME, sizeof(temp));
|
||||
btstack_ring_buffer_read(&audio_output_ring_buffer, (uint8_t *) &temp[0], bytes_to_read, &bytes_read);
|
||||
if (bytes_read == 0) break;
|
||||
unsigned int i;
|
||||
for (i=0;i<bytes_read / BYTES_PER_FRAME;i++){
|
||||
*buffer++ = temp[i];
|
||||
*buffer++ = temp[i];
|
||||
num_samples--;
|
||||
}
|
||||
}
|
||||
#else
|
||||
btstack_ring_buffer_read(&audio_output_ring_buffer, (uint8_t *) buffer, num_samples * BYTES_PER_FRAME, &bytes_read);
|
||||
num_samples -= bytes_read / BYTES_PER_FRAME;
|
||||
buffer += bytes_read / BYTES_PER_FRAME;
|
||||
#endif
|
||||
|
||||
// fill with 0 if not enough
|
||||
if (num_samples){
|
||||
#ifdef ENABLE_SCO_STEREO_PLAYBACK
|
||||
memset(buffer, 0, num_samples * BYTES_PER_FRAME * 2);
|
||||
#else
|
||||
memset(buffer, 0, num_samples * BYTES_PER_FRAME);
|
||||
#endif
|
||||
audio_output_paused = 1;
|
||||
}
|
||||
}
|
||||
@ -273,11 +249,7 @@ static int audio_initialize(int sample_rate){
|
||||
const btstack_audio_sink_t * audio_sink = btstack_audio_sink_get_instance();
|
||||
if (!audio_sink) return 0;
|
||||
|
||||
#ifdef ENABLE_SCO_STEREO_PLAYBACK
|
||||
audio_sink->init(2, sample_rate, &playback_callback);
|
||||
#else
|
||||
audio_sink->init(1, sample_rate, &playback_callback);
|
||||
#endif
|
||||
audio_sink->start_stream();
|
||||
|
||||
audio_output_paused = 1;
|
||||
|
Loading…
x
Reference in New Issue
Block a user