portaudio: cleanup debug output, don't try closing twice

This commit is contained in:
Matthias Ringwald 2019-02-24 18:37:06 +01:00
parent 6fd4ca9efb
commit 24cc6ccc6d

View File

@ -192,7 +192,7 @@ static int btstack_audio_portaudio_sink_init(
if (!portaudio_initialized){ if (!portaudio_initialized){
err = Pa_Initialize(); err = Pa_Initialize();
if (err != paNoError){ if (err != paNoError){
log_error("Error initializing portaudio: \"%s\"\n", Pa_GetErrorText(err)); log_error("Portudio: error initializing portaudio: \"%s\"\n", Pa_GetErrorText(err));
return err; return err;
} }
portaudio_initialized = 1; portaudio_initialized = 1;
@ -208,7 +208,7 @@ static int btstack_audio_portaudio_sink_init(
const PaDeviceInfo *outputDeviceInfo; const PaDeviceInfo *outputDeviceInfo;
outputDeviceInfo = Pa_GetDeviceInfo( theOutputParameters.device ); outputDeviceInfo = Pa_GetDeviceInfo( theOutputParameters.device );
log_info("PortAudio: Output device: %s", outputDeviceInfo->name); log_info("PortAudio: sink device: %s", outputDeviceInfo->name);
/* -- setup stream -- */ /* -- setup stream -- */
err = Pa_OpenStream( err = Pa_OpenStream(
@ -222,13 +222,13 @@ static int btstack_audio_portaudio_sink_init(
NULL ); NULL );
if (err != paNoError){ if (err != paNoError){
log_error("Error initializing portaudio: \"%s\"\n", Pa_GetErrorText(err)); log_error("Portudio: error initializing portaudio: \"%s\"\n", Pa_GetErrorText(err));
return err; return err;
} }
log_info("PortAudio: stream opened"); log_info("PortAudio: sink stream created");
const PaStreamInfo * stream_info = Pa_GetStreamInfo(stream_source); const PaStreamInfo * stream_info = Pa_GetStreamInfo(stream_source);
log_info("PortAudio: Output latency: %f", stream_info->outputLatency); log_info("PortAudio: sink latency: %f", stream_info->outputLatency);
playback_callback = playback; playback_callback = playback;
@ -256,7 +256,7 @@ static int btstack_audio_portaudio_source_init(
if (!portaudio_initialized){ if (!portaudio_initialized){
err = Pa_Initialize(); err = Pa_Initialize();
if (err != paNoError){ if (err != paNoError){
log_error("Error initializing portaudio: \"%s\"\n", Pa_GetErrorText(err)); log_error("Portudio: Error initializing portaudio: \"%s\"\n", Pa_GetErrorText(err));
return err; return err;
} }
portaudio_initialized = 1; portaudio_initialized = 1;
@ -272,7 +272,7 @@ static int btstack_audio_portaudio_source_init(
const PaDeviceInfo *inputDeviceInfo; const PaDeviceInfo *inputDeviceInfo;
inputDeviceInfo = Pa_GetDeviceInfo( theInputParameters.device ); inputDeviceInfo = Pa_GetDeviceInfo( theInputParameters.device );
log_info("PortAudio: Input device: %s", inputDeviceInfo->name); log_info("PortAudio: source device: %s", inputDeviceInfo->name);
/* -- setup stream -- */ /* -- setup stream -- */
err = Pa_OpenStream( err = Pa_OpenStream(
@ -289,10 +289,10 @@ static int btstack_audio_portaudio_source_init(
log_error("Error initializing portaudio: \"%s\"\n", Pa_GetErrorText(err)); log_error("Error initializing portaudio: \"%s\"\n", Pa_GetErrorText(err));
return err; return err;
} }
log_info("PortAudio: stream opened"); log_info("PortAudio: source stream created");
const PaStreamInfo * stream_info = Pa_GetStreamInfo(stream_sink); const PaStreamInfo * stream_info = Pa_GetStreamInfo(stream_sink);
log_info("PortAudio: Input latency: %f", stream_info->inputLatency); log_info("PortAudio: source latency: %f", stream_info->inputLatency);
recording_callback = recording; recording_callback = recording;
@ -314,7 +314,7 @@ static void btstack_audio_portaudio_sink_start_stream(void){
/* -- start stream -- */ /* -- start stream -- */
PaError err = Pa_StartStream(stream_source); PaError err = Pa_StartStream(stream_source);
if (err != paNoError){ if (err != paNoError){
log_error("Error starting the stream: \"%s\"\n", Pa_GetErrorText(err)); log_error("PortAudio: error starting sink stream: \"%s\"\n", Pa_GetErrorText(err));
return; return;
} }
@ -333,7 +333,7 @@ static void btstack_audio_portaudio_source_start_stream(void){
/* -- start stream -- */ /* -- start stream -- */
PaError err = Pa_StartStream(stream_sink); PaError err = Pa_StartStream(stream_sink);
if (err != paNoError){ if (err != paNoError){
log_error("Error starting the stream: \"%s\"\n", Pa_GetErrorText(err)); log_error("PortAudio: error starting source stream: \"%s\"\n", Pa_GetErrorText(err));
return; return;
} }
@ -353,12 +353,13 @@ static void btstack_audio_portaudio_sink_stop_stream(void){
// stop timer // stop timer
btstack_run_loop_remove_timer(&driver_timer_sink); btstack_run_loop_remove_timer(&driver_timer_sink);
log_info("PortAudio: Stream closed");
PaError err = Pa_StopStream(stream_sink); PaError err = Pa_StopStream(stream_sink);
if (err != paNoError){ if (err != paNoError){
log_error("Error stopping the stream: \"%s\"", Pa_GetErrorText(err)); log_error("PortAudio: error stopping sink stream: \"%s\"", Pa_GetErrorText(err));
return; return;
} }
sink_active = 0;
} }
static void btstack_audio_portaudio_source_stop_stream(void){ static void btstack_audio_portaudio_source_stop_stream(void){
@ -369,12 +370,13 @@ static void btstack_audio_portaudio_source_stop_stream(void){
// stop timer // stop timer
btstack_run_loop_remove_timer(&driver_timer_source); btstack_run_loop_remove_timer(&driver_timer_source);
log_info("PortAudio: Stream closed");
PaError err = Pa_StopStream(stream_source); PaError err = Pa_StopStream(stream_source);
if (err != paNoError){ if (err != paNoError){
log_error("Error stopping the stream: \"%s\"", Pa_GetErrorText(err)); log_error("PortAudio: error stopping source stream: \"%s\"", Pa_GetErrorText(err));
return; return;
} }
source_active = 0;
} }
static void btstack_audio_portaudio_close_pa_if_not_needed(void){ static void btstack_audio_portaudio_close_pa_if_not_needed(void){
@ -382,7 +384,7 @@ static void btstack_audio_portaudio_close_pa_if_not_needed(void){
if (sink_initialized) return; if (sink_initialized) return;
PaError err = Pa_Terminate(); PaError err = Pa_Terminate();
if (err != paNoError){ if (err != paNoError){
log_error("Error terminating portaudio: \"%s\"", Pa_GetErrorText(err)); log_error("Portudio: Error terminating portaudio: \"%s\"", Pa_GetErrorText(err));
return; return;
} }
} }
@ -397,7 +399,7 @@ static void btstack_audio_portaudio_sink_close(void){
PaError err = Pa_CloseStream(stream_sink); PaError err = Pa_CloseStream(stream_sink);
if (err != paNoError){ if (err != paNoError){
log_error("Error closing the stream: \"%s\"", Pa_GetErrorText(err)); log_error("PortAudio: error closing sink stream: \"%s\"", Pa_GetErrorText(err));
return; return;
} }
@ -416,7 +418,7 @@ static void btstack_audio_portaudio_source_close(void){
PaError err = Pa_CloseStream(stream_source); PaError err = Pa_CloseStream(stream_source);
if (err != paNoError){ if (err != paNoError){
log_error("Error closing the stream: \"%s\"", Pa_GetErrorText(err)); log_error("PortAudio: error closing source stream: \"%s\"", Pa_GetErrorText(err));
return; return;
} }