From 700509ec311ceae6b0bdf0c7a6c960d3b71e8742 Mon Sep 17 00:00:00 2001 From: aknudsen Date: Thu, 5 Jun 2008 21:13:54 +0000 Subject: [PATCH] OSS: clear trigger direction bits at correct time --- src/hostapi/oss/pa_unix_oss.c | 22 +++++++++++++--------- 1 file changed, 13 insertions(+), 9 deletions(-) diff --git a/src/hostapi/oss/pa_unix_oss.c b/src/hostapi/oss/pa_unix_oss.c index 74068d8..225c028 100644 --- a/src/hostapi/oss/pa_unix_oss.c +++ b/src/hostapi/oss/pa_unix_oss.c @@ -782,11 +782,15 @@ error: return result; } +/** Open input and output devices. + * + * @param idev: Returned input device file descriptor. + * @param odev: Returned output device file descriptor. + */ static PaError OpenDevices( const char *idevName, const char *odevName, int *idev, int *odev ) { PaError result = paNoError; int flags = O_NONBLOCK, duplex = 0; - int enableBits = 0; *idev = *odev = -1; if( idevName && odevName ) @@ -806,10 +810,6 @@ static PaError OpenDevices( const char *idevName, const char *odevName, int *ide { ENSURE_( *idev = open( idevName, flags ), paDeviceUnavailable ); PA_ENSURE( ModifyBlocking( *idev, 1 ) ); /* Blocking */ - - /* Initially disable */ - enableBits = ~PCM_ENABLE_INPUT; - ENSURE_( ioctl( *idev, SNDCTL_DSP_SETTRIGGER, &enableBits ), paUnanticipatedHostError ); } if( odevName ) { @@ -817,10 +817,6 @@ static PaError OpenDevices( const char *idevName, const char *odevName, int *ide { ENSURE_( *odev = open( odevName, flags ), paDeviceUnavailable ); PA_ENSURE( ModifyBlocking( *odev, 1 ) ); /* Blocking */ - - /* Initially disable */ - enableBits = ~PCM_ENABLE_OUTPUT; - ENSURE_( ioctl( *odev, SNDCTL_DSP_SETTRIGGER, &enableBits ), paUnanticipatedHostError ); } else { @@ -973,6 +969,8 @@ static int CalcHigherLogTwo( int n ) return log2; } +/** Configure stream component device parameters. + */ static PaError PaOssStreamComponent_Configure( PaOssStreamComponent *component, double sampleRate, unsigned long framesPerBuffer, StreamMode streamMode, PaOssStreamComponent *master ) { @@ -1434,6 +1432,12 @@ static PaError PaOssStream_Prepare( PaOssStream *stream ) if( stream->triggered ) return result; + /* The OSS reference instructs us to clear direction bits before setting them.*/ + if( stream->playback ) + ENSURE_( ioctl( stream->playback->fd, SNDCTL_DSP_SETTRIGGER, &enableBits ), paUnanticipatedHostError ); + if( stream->capture ) + ENSURE_( ioctl( stream->capture->fd, SNDCTL_DSP_SETTRIGGER, &enableBits ), paUnanticipatedHostError ); + if( stream->playback ) { size_t bufSz = PaOssStreamComponent_BufferSize( stream->playback ); -- 2.43.0