Tweaking the delay a bit... 0,050 s for output seems too little; it results in choppy audio and ultimately, a heap of errors. 0,100 seems ok for the output buffer. But the input buffer needs to be much larger else it overflows. Also, an extra stop stream before terminating to make sure all audio from the audio buffer is played.

This commit is contained in:
Jiri Wichern
2014-06-07 20:49:35 +02:00
parent 5dd236ec96
commit 74fa117850
3 changed files with 42 additions and 13 deletions

View File

@@ -98,8 +98,14 @@ initOpts (dsd_opts * opts)
opts->scoperate = 15;
sprintf (opts->audio_in_dev, "/dev/audio");
opts->audio_in_fd = -1;
#ifdef USE_PORTAUDIO
opts->audio_in_pa_stream = NULL;
#endif
sprintf (opts->audio_out_dev, "/dev/audio");
opts->audio_out_fd = -1;
#ifdef USE_PORTAUDIO
opts->audio_out_pa_stream = NULL;
#endif
opts->split = 0;
opts->playoffset = 0;
opts->mbe_out_dir[0] = 0;
@@ -364,20 +370,33 @@ cleanupAndExit (dsd_opts * opts, dsd_state * state)
printf("Terminating portaudio.\n");
PaError err = paNoError;
if(opts->audio_in_pa_stream != NULL)
err = Pa_CloseStream( opts->audio_in_pa_stream );
if( err != paNoError )
{
fprintf( stderr, "An error occured while closing the portaudio input stream\n" );
fprintf( stderr, "Error number: %d\n", err );
fprintf( stderr, "Error message: %s\n", Pa_GetErrorText( err ) );
err = Pa_CloseStream( opts->audio_in_pa_stream );
if( err != paNoError )
{
fprintf( stderr, "An error occured while closing the portaudio input stream\n" );
fprintf( stderr, "Error number: %d\n", err );
fprintf( stderr, "Error message: %s\n", Pa_GetErrorText( err ) );
}
}
if(opts->audio_out_pa_stream != NULL)
err = Pa_CloseStream( opts->audio_out_pa_stream );
if( err != paNoError )
{
fprintf( stderr, "An error occured while closing the portaudio output stream\n" );
fprintf( stderr, "Error number: %d\n", err );
fprintf( stderr, "Error message: %s\n", Pa_GetErrorText( err ) );
err = Pa_IsStreamActive( opts->audio_out_pa_stream );
if(err == 1)
err = Pa_StopStream( opts->audio_out_pa_stream );
if( err != paNoError )
{
fprintf( stderr, "An error occured while closing the portaudio output stream\n" );
fprintf( stderr, "Error number: %d\n", err );
fprintf( stderr, "Error message: %s\n", Pa_GetErrorText( err ) );
}
err = Pa_CloseStream( opts->audio_out_pa_stream );
if( err != paNoError )
{
fprintf( stderr, "An error occured while closing the portaudio output stream\n" );
fprintf( stderr, "Error number: %d\n", err );
fprintf( stderr, "Error message: %s\n", Pa_GetErrorText( err ) );
}
}
err = Pa_Terminate();
if( err != paNoError )