]> Repos - portaudio/commitdiff
OSS: clear trigger direction bits at correct time
authoraknudsen <aknudsen@0f58301d-fd10-0410-b4af-bbb618454e57>
Thu, 5 Jun 2008 21:13:54 +0000 (21:13 +0000)
committeraknudsen <aknudsen@0f58301d-fd10-0410-b4af-bbb618454e57>
Thu, 5 Jun 2008 21:13:54 +0000 (21:13 +0000)
src/hostapi/oss/pa_unix_oss.c

index 74068d8fc00c32c9241ad39fb2c0d5af6db1e784..225c028d8265cb68f327848e0335342ca9c1176a 100644 (file)
@@ -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 );