static void handle_pcm_data(int16_t * data, int num_samples, int num_channels, int sample_rate, void * context){ UNUSED(sample_rate); UNUSED(context); #ifdef STORE_SBC_TO_WAV_FILE wav_writer_write_int16(num_samples*num_channels, data); frame_count++; #endif total_num_samples+=num_samples*num_channels; #ifdef HAVE_PORTAUDIO if (!pa_stream_started){ /* -- start stream -- */ PaError err = Pa_StartStream(stream); if (err != paNoError){ printf("Error starting the stream: \"%s\"\n", Pa_GetErrorText(err)); return; } pa_stream_started = 1; pa_stream_paused = 1; } btstack_ring_buffer_write(&ring_buffer, (uint8_t *)data, num_samples*num_channels*2); #endif }
static void handle_pcm_data(int16_t * data, int num_samples, int num_channels, int sample_rate, void * context){ UNUSED(context); UNUSED(sample_rate); UNUSED(data); UNUSED(num_samples); UNUSED(num_channels); #if (SCO_DEMO_MODE == SCO_DEMO_MODE_SINE) || (SCO_DEMO_MODE == SCO_DEMO_MODE_MICROPHONE) // printf("handle_pcm_data num samples %u, sample rate %d\n", num_samples, num_channels); #ifdef HAVE_PORTAUDIO // samples in callback in host endianess, ready for PortAudio playback btstack_ring_buffer_write(&pa_output_ring_buffer, (uint8_t *)data, num_samples*num_channels*2); #endif /* HAVE_PORTAUDIO */ #ifdef SCO_WAV_FILENAME if (!num_samples_to_write) return; num_samples = btstack_min(num_samples, num_samples_to_write); num_samples_to_write -= num_samples; wav_writer_write_int16(num_samples, data); if (num_samples_to_write == 0){ wav_writer_close(); } #endif /* SCO_WAV_FILENAME */ #endif /* Demo mode sine or microphone */ }
static void handle_pcm_data(int16_t * data, int num_samples, int num_channels, int sample_rate, void * context){ UNUSED(sample_rate); UNUSED(context); #ifdef STORE_SBC_TO_WAV_FILE wav_writer_write_int16(num_samples*num_channels, data); frame_count++; #endif #ifdef HAVE_PORTAUDIO // store pcm samples in ring buffer btstack_ring_buffer_write(&ring_buffer, (uint8_t *)data, num_samples*num_channels*2); if (!audio_stream_started){ audio_stream_paused = 1; /* -- start stream -- */ PaError err = Pa_StartStream(stream); if (err != paNoError){ printf("Error starting the stream: \"%s\"\n", Pa_GetErrorText(err)); return; } audio_stream_started = 1; } #endif #ifdef HAVE_AUDIO_DMA // store in ring buffer uint8_t * write_data = start_of_buffer(write_buffer); uint16_t len = num_samples*num_channels*2; memcpy(write_data, data, len); audio_samples_len[write_buffer] = len; // add/drop audio frame to fix drift if (sbc_samples_fix > 0){ memcpy(write_data + len, write_data + len - 4, 4); audio_samples_len[write_buffer] += 4; } if (sbc_samples_fix < 0){ audio_samples_len[write_buffer] -= 4; } write_buffer = next_buffer(write_buffer); #endif }
static void write_wav_data(int16_t * data, int num_frames, int num_channels, int sample_rate){ (void)sample_rate; wav_writer_write_int16(num_frames*num_channels, data); total_num_samples+=num_frames*num_channels; if (total_num_samples>5*SAMPLE_RATE) wav_writer_close(); }