/[pcsx2_0.9.7]/trunk/3rdparty/portaudio/src/hostapi/dsound/pa_win_ds.c
ViewVC logotype

Diff of /trunk/3rdparty/portaudio/src/hostapi/dsound/pa_win_ds.c

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

--- trunk/3rdparty/portaudio/src/hostapi/dsound/pa_win_ds.c	2010/11/12 00:35:47	272
+++ trunk/3rdparty/portaudio/src/hostapi/dsound/pa_win_ds.c	2010/11/12 01:10:22	273
@@ -1,5 +1,5 @@
 /*
- * $Id: pa_win_ds.c 1450 2010-02-03 00:28:29Z rossb $
+ * $Id: pa_win_ds.c 1534 2010-08-03 21:02:52Z dmitrykos $
  * Portable Audio I/O Library DirectSound implementation
  *
  * Authors: Phil Burk, Robert Marsanyi & Ross Bencina
@@ -27,13 +27,13 @@
  */
 
 /*
- * The text above constitutes the entire PortAudio license; however,
+ * The text above constitutes the entire PortAudio license; however, 
  * the PortAudio community also makes the following non-binding requests:
  *
  * Any person wishing to distribute modifications to the Software is
  * requested to send the modifications to the original developer so that
- * they can be incorporated into the canonical version. It is also
- * requested that these non-binding requests be included along with the
+ * they can be incorporated into the canonical version. It is also 
+ * requested that these non-binding requests be included along with the 
  * license above.
  */
 
@@ -41,7 +41,7 @@
  @ingroup hostapi_src
 
     @todo implement paInputOverflow callback status flag
-
+    
     @todo implement paNeverDropInput.
 
     @todo implement host api specific extension to set i/o buffer sizes in frames
@@ -244,7 +244,7 @@
     /* Try to detect play buffer underflows. */
     LARGE_INTEGER        perfCounterTicksPerBuffer; /* counter ticks it should take to play a full buffer */
     LARGE_INTEGER        previousPlayTime;
-    UINT                 previousPlayCursor;
+    DWORD                previousPlayCursor;
     UINT                 outputUnderflowCount;
     BOOL                 outputIsRunning;
     INT                  finalZeroBytesWritten; /* used to determine when we've flushed the whole buffer */
@@ -256,7 +256,7 @@
     UINT                 readOffset;      /* last read position */
     UINT                 inputSize;
 
-
+    
     MMRESULT         timerID;
     int              framesPerDSBuffer;
     double           framesWritten;
@@ -267,7 +267,7 @@
     PaStreamFlags    streamFlags;
     int              callbackResult;
     HANDLE           processingCompleted;
-
+    
 /* FIXME - move all below to PaUtilStreamRepresentation */
     volatile int     isStarted;
     volatile int     isActive;
@@ -284,7 +284,7 @@
 static char *DuplicateDeviceNameString( PaUtilAllocationGroup *allocations, const char* src )
 {
     char *result = 0;
-
+    
     if( src != NULL )
     {
         size_t len = strlen(src);
@@ -341,7 +341,7 @@
     guidVector->items = (DSDeviceNameAndGUID*)LocalAlloc( LMEM_FIXED, sizeof(DSDeviceNameAndGUID) * guidVector->free );
     if( guidVector->items == NULL )
         result = paInsufficientMemory;
-
+    
     return result;
 }
 
@@ -350,7 +350,7 @@
     PaError result = paNoError;
     DSDeviceNameAndGUID *newItems;
     int i;
-
+    
     /* double size of vector */
     int size = guidVector->count + guidVector->free;
     guidVector->free += size;
@@ -379,7 +379,7 @@
 
         LocalFree( guidVector->items );
         guidVector->items = newItems;
-    }
+    }                                
 
     return result;
 }
@@ -403,7 +403,7 @@
 }
 
 /************************************************************************************
-** Collect preliminary device information during DirectSound enumeration
+** Collect preliminary device information during DirectSound enumeration 
 */
 static BOOL CALLBACK CollectGUIDsProc(LPGUID lpGUID,
                                      LPCTSTR lpszDesc,
@@ -424,7 +424,7 @@
             return FALSE;
         }
     }
-
+    
     /* Set GUID pointer, copy GUID to storage in DSDeviceNameAndGUIDVector. */
     if( lpGUID == NULL )
     {
@@ -434,7 +434,7 @@
     {
         namesAndGUIDs->items[namesAndGUIDs->count].lpGUID =
                 &namesAndGUIDs->items[namesAndGUIDs->count].guid;
-
+      
         memcpy( &namesAndGUIDs->items[namesAndGUIDs->count].guid, lpGUID, sizeof(GUID) );
     }
 
@@ -450,7 +450,7 @@
 
     ++namesAndGUIDs->count;
     --namesAndGUIDs->free;
-
+    
     return TRUE;
 }
 
@@ -479,7 +479,7 @@
             if( deviceNamesAndGUIDs->outputNamesAndGUIDs.items[i].lpGUID
                 && memcmp( &data->DeviceId, deviceNamesAndGUIDs->outputNamesAndGUIDs.items[i].lpGUID, sizeof(GUID) ) == 0 )
             {
-                deviceNamesAndGUIDs->outputNamesAndGUIDs.items[i].pnpInterface =
+                deviceNamesAndGUIDs->outputNamesAndGUIDs.items[i].pnpInterface = 
                         (char*)DuplicateWCharString( deviceNamesAndGUIDs->winDsHostApi->allocations, data->Interface );
                 break;
             }
@@ -492,7 +492,7 @@
             if( deviceNamesAndGUIDs->inputNamesAndGUIDs.items[i].lpGUID
                 && memcmp( &data->DeviceId, deviceNamesAndGUIDs->inputNamesAndGUIDs.items[i].lpGUID, sizeof(GUID) ) == 0 )
             {
-                deviceNamesAndGUIDs->inputNamesAndGUIDs.items[i].pnpInterface =
+                deviceNamesAndGUIDs->inputNamesAndGUIDs.items[i].pnpInterface = 
                         (char*)DuplicateWCharString( deviceNamesAndGUIDs->winDsHostApi->allocations, data->Interface );
                 break;
             }
@@ -503,13 +503,13 @@
 }
 
 
-static GUID pawin_CLSID_DirectSoundPrivate =
+static GUID pawin_CLSID_DirectSoundPrivate = 
 { 0x11ab3ec0, 0x25ec, 0x11d1, 0xa4, 0xd8, 0x00, 0xc0, 0x4f, 0xc2, 0x8a, 0xca };
 
-static GUID pawin_DSPROPSETID_DirectSoundDevice =
+static GUID pawin_DSPROPSETID_DirectSoundDevice = 
 { 0x84624f82, 0x25ec, 0x11d1, 0xa4, 0xd8, 0x00, 0xc0, 0x4f, 0xc2, 0x8a, 0xca };
 
-static GUID pawin_IID_IKsPropertySet =
+static GUID pawin_IID_IKsPropertySet = 
 { 0x31efac30, 0x515c, 0x11d0, 0xa9, 0xaa, 0x00, 0xaa, 0x00, 0x61, 0xbe, 0x93 };
 
 
@@ -517,17 +517,17 @@
     FindDevicePnpInterfaces fills in the pnpInterface fields in deviceNamesAndGUIDs
     with UNICODE file paths to the devices. The DS documentation mentions
     at least two techniques by which these Interface paths can be found using IKsPropertySet on
-    the DirectSound class object. One is using the DSPROPERTY_DIRECTSOUNDDEVICE_DESCRIPTION
+    the DirectSound class object. One is using the DSPROPERTY_DIRECTSOUNDDEVICE_DESCRIPTION 
     property, and the other is using DSPROPERTY_DIRECTSOUNDDEVICE_ENUMERATE.
     I tried both methods and only the second worked. I found two postings on the
-    net from people who had the same problem with the first method, so I think the method used here is
+    net from people who had the same problem with the first method, so I think the method used here is 
     more common/likely to work. The probem is that IKsPropertySet_Get returns S_OK
     but the fields of the device description are not filled in.
 
-    The mechanism we use works by registering an enumeration callback which is called for
+    The mechanism we use works by registering an enumeration callback which is called for 
     every DSound device. Our callback searches for a device in our deviceNamesAndGUIDs list
     with the matching GUID and copies the pointer to the Interface path.
-    Note that we could have used this enumeration callback to perform the original
+    Note that we could have used this enumeration callback to perform the original 
     device enumeration, however we choose not to so we can disable this step easily.
 
     Apparently the IKsPropertySet mechanism was added in DirectSound 9c 2004
@@ -538,11 +538,11 @@
 static void FindDevicePnpInterfaces( DSDeviceNamesAndGUIDs *deviceNamesAndGUIDs )
 {
     IClassFactory *pClassFactory;
-
+   
     if( paWinDsDSoundEntryPoints.DllGetClassObject(&pawin_CLSID_DirectSoundPrivate, &IID_IClassFactory, (PVOID *) &pClassFactory) == S_OK ){
         IKsPropertySet *pPropertySet;
         if( pClassFactory->lpVtbl->CreateInstance( pClassFactory, NULL, &pawin_IID_IKsPropertySet, (PVOID *) &pPropertySet) == S_OK ){
-
+            
             DSPROPERTY_DIRECTSOUNDDEVICE_ENUMERATE_W_DATA data;
             ULONG bytesReturned;
 
@@ -558,14 +558,14 @@
                 sizeof(data),
                 &bytesReturned
             );
-
+            
             IKsPropertySet_Release( pPropertySet );
         }
         pClassFactory->lpVtbl->Release( pClassFactory );
     }
 
     /*
-        The following code fragment, which I chose not to use, queries for the
+        The following code fragment, which I chose not to use, queries for the 
         device interface for a device with a specific GUID:
 
         ULONG BytesReturned;
@@ -573,7 +573,7 @@
 
         memset (&Property, 0, sizeof(Property));
         Property.DataFlow = DIRECTSOUNDDEVICE_DATAFLOW_RENDER;
-        Property.DeviceId = *lpGUID;
+        Property.DeviceId = *lpGUID;  
 
         hr = IKsPropertySet_Get( pPropertySet,
             &pawin_DSPROPSETID_DirectSoundDevice,
@@ -594,7 +594,7 @@
 #endif /* PAWIN_USE_WDMKS_DEVICE_INFO */
 
 
-/*
+/* 
     GUIDs for emulated devices which we blacklist below.
     are there more than two of them??
 */
@@ -638,7 +638,7 @@
         memcpy( &winDsDeviceInfo->guid, lpGUID, sizeof(GUID) );
         winDsDeviceInfo->lpGUID = &winDsDeviceInfo->guid;
     }
-
+    
     if( lpGUID )
     {
         if (IsEqualGUID (&IID_IRolandVSCEmulated1,lpGUID) ||
@@ -669,7 +669,7 @@
         hr = IDirectSound_Initialize( lpDirectSound, lpGUID );
     }
     */
-
+    
     if( hr != DS_OK )
     {
         if (hr == DSERR_ALLOCATED)
@@ -695,7 +695,7 @@
     else
     {
         /* Query device characteristics. */
-        memset( &caps, 0, sizeof(caps) );
+        memset( &caps, 0, sizeof(caps) ); 
         caps.dwSize = sizeof(caps);
         hr = IDirectSound_GetCaps( lpDirectSound, &caps );
         if( hr != DS_OK )
@@ -726,7 +726,7 @@
                    set deviceOutputChannelCountIsKnown to 0 (unknown).
                    In this case OpenStream will try to open the device
                    when the user requests more than 2 channels, rather than
-                   returning an error.
+                   returning an error. 
                 */
                 if( caps.dwFlags & DSCAPS_PRIMARYSTEREO )
                 {
@@ -739,7 +739,7 @@
                     winDsDeviceInfo->deviceOutputChannelCountIsKnown = 1;
                 }
 
-                /* Guess channels count from speaker configuration. We do it only when
+                /* Guess channels count from speaker configuration. We do it only when 
                    pnpInterface is NULL or when PAWIN_USE_WDMKS_DEVICE_INFO is undefined.
                 */
 #ifdef PAWIN_USE_WDMKS_DEVICE_INFO
@@ -792,9 +792,9 @@
                 deviceInfo->defaultLowOutputLatency = 0.;   /** @todo IMPLEMENT ME */
                 deviceInfo->defaultHighInputLatency = 0.;   /** @todo IMPLEMENT ME */
                 deviceInfo->defaultHighOutputLatency = 0.;  /** @todo IMPLEMENT ME */
-
+                
                 /* initialize defaultSampleRate */
-
+                
                 if( caps.dwFlags & DSCAPS_CONTINUOUSRATE )
                 {
                     /* initialize to caps.dwMaxSecondarySampleRate incase none of the standard rates match */
@@ -841,7 +841,7 @@
 
 
                 //printf( "min %d max %d\n", caps.dwMinSecondarySampleRate, caps.dwMaxSecondarySampleRate );
-                // dwFlags | DSCAPS_CONTINUOUSRATE
+                // dwFlags | DSCAPS_CONTINUOUSRATE 
             }
         }
 
@@ -854,7 +854,7 @@
 
         if( lpGUID == NULL )
             hostApi->info.defaultOutputDevice = hostApi->info.deviceCount;
-
+            
         hostApi->info.deviceCount++;
     }
 
@@ -880,7 +880,7 @@
     DSCCAPS                       caps;
     int                           deviceOK = TRUE;
     PaError                       result = paNoError;
-
+    
     /* Copy GUID to the device info structure. Set pointer. */
     if( lpGUID == NULL )
     {
@@ -1016,7 +1016,7 @@
                 else deviceInfo->defaultSampleRate = 0.;
             }
         }
-
+        
         IDirectSoundCapture_Release( lpDirectSoundCapture );
     }
 
@@ -1049,7 +1049,7 @@
         If COM is already initialized CoInitialize will either return
         FALSE, or RPC_E_CHANGED_MODE if it was initialised in a different
         threading mode. In either case we shouldn't consider it an error
-        but we need to be careful to not call CoUninitialize() if
+        but we need to be careful to not call CoUninitialize() if 
         RPC_E_CHANGED_MODE was returned.
     */
 
@@ -1087,12 +1087,12 @@
     (*hostApi)->info.structVersion = 1;
     (*hostApi)->info.type = paDirectSound;
     (*hostApi)->info.name = "Windows DirectSound";
-
+    
     (*hostApi)->info.deviceCount = 0;
     (*hostApi)->info.defaultInputDevice = paNoDevice;
     (*hostApi)->info.defaultOutputDevice = paNoDevice;
 
-
+    
 /* DSound - enumerate devices to count them and to gather their GUIDs */
 
     result = InitializeDSDeviceNameAndGUIDVector( &deviceNamesAndGUIDs.inputNamesAndGUIDs, winDsHostApi->allocations );
@@ -1177,7 +1177,7 @@
             if( result != paNoError )
                 goto error;
         }
-    }
+    }    
 
     result = TerminateDSDeviceNameAndGUIDVector( &deviceNamesAndGUIDs.inputNamesAndGUIDs );
     if( result != paNoError )
@@ -1187,7 +1187,7 @@
     if( result != paNoError )
         goto error;
 
-
+    
     (*hostApi)->Terminate = Terminate;
     (*hostApi)->OpenStream = OpenStream;
     (*hostApi)->IsFormatSupported = IsFormatSupported;
@@ -1213,7 +1213,7 @@
             PaUtil_FreeAllAllocations( winDsHostApi->allocations );
             PaUtil_DestroyAllocationGroup( winDsHostApi->allocations );
         }
-
+                
         PaUtil_FreeMemory( winDsHostApi );
     }
 
@@ -1349,7 +1349,7 @@
 
         outputChannelCount = outputParameters->channelCount;
         outputSampleFormat = outputParameters->sampleFormat;
-
+        
         /* unless alternate device specification is supported, reject the use of
             paUseHostApiSpecificDeviceSpecification */
 
@@ -1370,7 +1370,7 @@
     {
         outputChannelCount = 0;
     }
-
+    
     /*
         IMPLEMENT ME:
 
@@ -1439,12 +1439,12 @@
 static HRESULT InitFullDuplexInputOutputBuffers( PaWinDsStream *stream,
                                        PaWinDsDeviceInfo *inputDevice,
                                        PaSampleFormat hostInputSampleFormat,
-                                       WORD inputChannelCount,
+                                       WORD inputChannelCount, 
                                        int bytesPerInputBuffer,
                                        PaWinWaveFormatChannelMask inputChannelMask,
                                        PaWinDsDeviceInfo *outputDevice,
                                        PaSampleFormat hostOutputSampleFormat,
-                                       WORD outputChannelCount,
+                                       WORD outputChannelCount, 
                                        int bytesPerOutputBuffer,
                                        PaWinWaveFormatChannelMask outputChannelMask,
                                        unsigned long nFrameRate
@@ -1461,7 +1461,7 @@
     // capture buffer description
 
     // only try wave format extensible. assume it's available on all ds 8 systems
-    PaWin_InitializeWaveFormatExtensible( &captureWaveFormat, inputChannelCount,
+    PaWin_InitializeWaveFormatExtensible( &captureWaveFormat, inputChannelCount, 
                 hostInputSampleFormat, PaWin_SampleFormatToLinearWaveFormatTag( hostInputSampleFormat ),
                 nFrameRate, inputChannelMask );
 
@@ -1473,7 +1473,7 @@
 
     // render buffer description
 
-    PaWin_InitializeWaveFormatExtensible( &renderWaveFormat, outputChannelCount,
+    PaWin_InitializeWaveFormatExtensible( &renderWaveFormat, outputChannelCount, 
                 hostOutputSampleFormat, PaWin_SampleFormatToLinearWaveFormatTag( hostOutputSampleFormat ),
                 nFrameRate, outputChannelMask );
 
@@ -1485,7 +1485,7 @@
 
     /* note that we don't create a primary buffer here at all */
 
-    hr = paWinDsDSoundEntryPoints.DirectSoundFullDuplexCreate8(
+    hr = paWinDsDSoundEntryPoints.DirectSoundFullDuplexCreate8( 
             inputDevice->lpGUID, outputDevice->lpGUID,
             &captureDesc, &secondaryRenderDesc,
             GetDesktopWindow(), /* see InitOutputBuffer() for a discussion of whether this is a good idea */
@@ -1493,7 +1493,7 @@
             &stream->pDirectSoundFullDuplex8,
             &pCaptureBuffer8,
             &pRenderBuffer8,
-            NULL /* pUnkOuter must be NULL */
+            NULL /* pUnkOuter must be NULL */ 
         );
 
     if( hr == DS_OK )
@@ -1502,10 +1502,10 @@
 
         /* retrieve the pre ds 8 buffer interfaces which are used by the rest of the code */
 
-        hr = IUnknown_QueryInterface( pCaptureBuffer8, &IID_IDirectSoundCaptureBuffer, &stream->pDirectSoundInputBuffer );
-
+        hr = IUnknown_QueryInterface( pCaptureBuffer8, &IID_IDirectSoundCaptureBuffer, (LPVOID *)&stream->pDirectSoundInputBuffer );
+        
         if( hr == DS_OK )
-            hr = IUnknown_QueryInterface( pRenderBuffer8, &IID_IDirectSoundBuffer, &stream->pDirectSoundOutputBuffer );
+            hr = IUnknown_QueryInterface( pRenderBuffer8, &IID_IDirectSoundBuffer, (LPVOID *)&stream->pDirectSoundOutputBuffer );
 
         /* release the ds 8 interfaces, we don't need them */
         IUnknown_Release( pCaptureBuffer8 );
@@ -1524,7 +1524,7 @@
                 IUnknown_Release( stream->pDirectSoundOutputBuffer );
                 stream->pDirectSoundOutputBuffer = NULL;
             }
-
+            
             IUnknown_Release( stream->pDirectSoundFullDuplex8 );
             stream->pDirectSoundFullDuplex8 = NULL;
         }
@@ -1544,8 +1544,8 @@
     DSCBUFFERDESC  captureDesc;
     PaWinWaveFormat waveFormat;
     HRESULT        result;
-
-    if( (result = paWinDsDSoundEntryPoints.DirectSoundCaptureCreate(
+    
+    if( (result = paWinDsDSoundEntryPoints.DirectSoundCaptureCreate( 
             device->lpGUID, &stream->pDirectSoundCapture, NULL) ) != DS_OK ){
          ERR_RPT(("PortAudio: DirectSoundCaptureCreate() failed!\n"));
          return result;
@@ -1557,18 +1557,18 @@
     captureDesc.dwFlags = 0;
     captureDesc.dwBufferBytes = bytesPerBuffer;
     captureDesc.lpwfxFormat = (WAVEFORMATEX*)&waveFormat;
-
+    
     // Create the capture buffer
 
     // first try WAVEFORMATEXTENSIBLE. if this fails, fall back to WAVEFORMATEX
-    PaWin_InitializeWaveFormatExtensible( &waveFormat, nChannels,
+    PaWin_InitializeWaveFormatExtensible( &waveFormat, nChannels, 
                 sampleFormat, PaWin_SampleFormatToLinearWaveFormatTag( sampleFormat ),
                 nFrameRate, channelMask );
 
     if( IDirectSoundCapture_CreateCaptureBuffer( stream->pDirectSoundCapture,
                   &captureDesc, &stream->pDirectSoundInputBuffer, NULL) != DS_OK )
     {
-        PaWin_InitializeWaveFormatEx( &waveFormat, nChannels, sampleFormat,
+        PaWin_InitializeWaveFormatEx( &waveFormat, nChannels, sampleFormat, 
                 PaWin_SampleFormatToLinearWaveFormatTag( sampleFormat ), nFrameRate );
 
         if ((result = IDirectSoundCapture_CreateCaptureBuffer( stream->pDirectSoundCapture,
@@ -1588,8 +1588,8 @@
     PaWinWaveFormat waveFormat;
     DSBUFFERDESC   primaryDesc;
     DSBUFFERDESC   secondaryDesc;
-
-    if( (hr = paWinDsDSoundEntryPoints.DirectSoundCreate(
+    
+    if( (hr = paWinDsDSoundEntryPoints.DirectSoundCreate( 
                 device->lpGUID, &stream->pDirectSound, NULL )) != DS_OK ){
         ERR_RPT(("PortAudio: DirectSoundCreate() failed!\n"));
         return hr;
@@ -1632,13 +1632,13 @@
     // Set the primary buffer's format
 
     // first try WAVEFORMATEXTENSIBLE. if this fails, fall back to WAVEFORMATEX
-    PaWin_InitializeWaveFormatExtensible( &waveFormat, nChannels,
+    PaWin_InitializeWaveFormatExtensible( &waveFormat, nChannels, 
                 sampleFormat, PaWin_SampleFormatToLinearWaveFormatTag( sampleFormat ),
                 nFrameRate, channelMask );
 
     if( IDirectSoundBuffer_SetFormat( stream->pDirectSoundPrimaryBuffer, (WAVEFORMATEX*)&waveFormat) != DS_OK )
     {
-        PaWin_InitializeWaveFormatEx( &waveFormat, nChannels, sampleFormat,
+        PaWin_InitializeWaveFormatEx( &waveFormat, nChannels, sampleFormat, 
                 PaWin_SampleFormatToLinearWaveFormatTag( sampleFormat ), nFrameRate );
 
         if((result = IDirectSoundBuffer_SetFormat( stream->pDirectSoundPrimaryBuffer, (WAVEFORMATEX*)&waveFormat)) != DS_OK)
@@ -1656,7 +1656,7 @@
     if ((result = IDirectSound_CreateSoundBuffer( stream->pDirectSound,
                   &secondaryDesc, &stream->pDirectSoundOutputBuffer, NULL)) != DS_OK)
       goto error;
-
+    
     return DS_OK;
 
 error:
@@ -1708,7 +1708,7 @@
 
         /* IDEA: the following 3 checks could be performed by default by pa_front
             unless some flag indicated otherwise */
-
+            
         /* unless alternate device specification is supported, reject the use of
             paUseHostApiSpecificDeviceSpecification */
         if( inputParameters->device == paUseHostApiSpecificDeviceSpecification )
@@ -1718,7 +1718,7 @@
         if( inputWinDsDeviceInfo->deviceInputChannelCountIsKnown
                 && inputChannelCount > inputDeviceInfo->maxInputChannels )
             return paInvalidChannelCount;
-
+            
         /* validate hostApiSpecificStreamInfo */
         inputStreamInfo = (PaWinDirectSoundStreamInfo*)inputParameters->hostApiSpecificStreamInfo;
 		result = ValidateWinDirectSoundSpecificStreamInfo( inputParameters, inputStreamInfo );
@@ -1759,7 +1759,7 @@
         /* validate hostApiSpecificStreamInfo */
         outputStreamInfo = (PaWinDirectSoundStreamInfo*)outputParameters->hostApiSpecificStreamInfo;
 		result = ValidateWinDirectSoundSpecificStreamInfo( outputParameters, outputStreamInfo );
-		if( result != paNoError ) return result;
+		if( result != paNoError ) return result;   
 
         if( outputStreamInfo && outputStreamInfo->flags & paWinDirectSoundUseChannelMask )
             outputChannelMask = outputStreamInfo->channelMask;
@@ -1823,7 +1823,7 @@
         PaUtil_InitializeStreamRepresentation( &stream->streamRepresentation,
                                                &winDsHostApi->blockingStreamInterface, streamCallback, userData );
     }
-
+    
     streamRepresentationIsInitialized = 1;
 
     stream->streamFlags = streamFlags;
@@ -1878,15 +1878,15 @@
             PaUtil_GetBufferProcessorOutputLatency(&stream->bufferProcessor);    /* FIXME: not initialised anywhere else */
     stream->streamRepresentation.streamInfo.sampleRate = sampleRate;
 
-
-/* DirectSound specific initialization */
+    
+/* DirectSound specific initialization */ 
     {
         HRESULT          hr;
         int              bytesPerDirectSoundInputBuffer, bytesPerDirectSoundOutputBuffer;
         int              userLatencyFrames;
         int              minLatencyFrames;
         unsigned long    integerSampleRate = (unsigned long) (sampleRate + 0.5);
-
+    
         stream->timerID = 0;
 
         stream->processingCompleted = CreateEvent( NULL, /* bManualReset = */ TRUE, /* bInitialState = */ FALSE, NULL );
@@ -1941,7 +1941,7 @@
             PaDeviceInfo *deviceInfo = hostApi->deviceInfos[ outputParameters->device ];
             DBUG(("PaHost_OpenStream: deviceID = 0x%x\n", outputParameters->device));
             */
-
+            
             int bytesPerSample = Pa_GetSampleSize(hostOutputSampleFormat);
             bytesPerDirectSoundOutputBuffer = stream->framesPerDSBuffer * outputParameters->channelCount * bytesPerSample;
             if( bytesPerDirectSoundOutputBuffer < DSBSIZE_MIN )
@@ -1983,7 +1983,7 @@
             PaDeviceInfo *deviceInfo = hostApi->deviceInfos[ inputParameters->device ];
             DBUG(("PaHost_OpenStream: deviceID = 0x%x\n", inputParameters->device));
             */
-
+            
             int bytesPerSample = Pa_GetSampleSize(hostInputSampleFormat);
             bytesPerDirectSoundInputBuffer = stream->framesPerDSBuffer * inputParameters->channelCount * bytesPerSample;
             if( bytesPerDirectSoundInputBuffer < DSBSIZE_MIN )
@@ -2010,7 +2010,7 @@
         assert( stream->pDirectSound == NULL );
         assert( stream->pDirectSoundPrimaryBuffer == NULL );
         assert( stream->pDirectSoundOutputBuffer == NULL );
-
+        
 
         if( inputParameters && outputParameters )
         {
@@ -2030,14 +2030,14 @@
                                        integerSampleRate
                                         );
             DBUG(("InitFullDuplexInputOutputBuffers() returns %x\n", hr));
-            /* ignore any error returned by InitFullDuplexInputOutputBuffers.
+            /* ignore any error returned by InitFullDuplexInputOutputBuffers. 
                 we retry opening the buffers below */
 #endif /* PAWIN_USE_DIRECTSOUNDFULLDUPLEXCREATE */
         }
 
-        /*  create half duplex buffers. also used for full-duplex streams which didn't
+        /*  create half duplex buffers. also used for full-duplex streams which didn't 
             succeed when using the full duplex API. that could happen because
-            DX8 or greater isnt installed, the i/o devices aren't the same
+            DX8 or greater isnt installed, the i/o devices aren't the same 
             physical device. etc.
         */
 
@@ -2205,11 +2205,11 @@
 
         /*
             From MSDN:
-                The write cursor indicates the position at which it is safe
+                The write cursor indicates the position at which it is safe  
             to write new data to the buffer. The write cursor always leads the
             play cursor, typically by about 15 milliseconds' worth of audio
             data.
-                It is always safe to change data that is behind the position
+                It is always safe to change data that is behind the position 
             indicated by the lpdwCurrentPlayCursor parameter.
         */
 
@@ -2234,7 +2234,7 @@
     HRESULT           hresult;
     double            outputLatency = 0;
     PaStreamCallbackTimeInfo timeInfo = {0,0,0}; /** @todo implement inputBufferAdcTime */
-
+    
 /* Input */
     LPBYTE            lpInBuf1 = NULL;
     LPBYTE            lpInBuf2 = NULL;
@@ -2265,7 +2265,7 @@
         }
             // FIXME: what happens if IDirectSoundCaptureBuffer_GetCurrentPosition fails?
 
-        framesToXfer = numInFramesReady = bytesFilled / stream->bytesPerInputFrame;
+        framesToXfer = numInFramesReady = bytesFilled / stream->bytesPerInputFrame; 
         outputLatency = ((double)bytesFilled) * stream->secondsPerHostByte;  // FIXME: this doesn't look right. we're calculating output latency in input branch. also secondsPerHostByte is only initialized for the output stream
 
         /** @todo Check for overflow */
@@ -2301,7 +2301,7 @@
 
         PaUtil_BeginBufferProcessing( &stream->bufferProcessor, &timeInfo, stream->callbackFlags );
         stream->callbackFlags = 0;
-
+        
     /* Input */
         if( stream->bufferProcessor.inputChannelCount > 0 )
         {
@@ -2363,7 +2363,7 @@
 
         numFrames = PaUtil_EndBufferProcessing( &stream->bufferProcessor, &stream->callbackResult );
         stream->framesWritten += numFrames;
-
+        
         if( stream->bufferProcessor.outputChannelCount > 0 )
         {
         /* FIXME: an underflow could happen here */
@@ -2386,7 +2386,7 @@
         }
 error2:
 
-        PaUtil_EndCpuLoadMeasurement( &stream->cpuLoadMeasurer, numFrames );
+        PaUtil_EndCpuLoadMeasurement( &stream->cpuLoadMeasurer, numFrames );        
     }
 
     if( stream->callbackResult == paComplete && !PaUtil_IsBufferProcessorOutputEmpty( &stream->bufferProcessor ) )
@@ -2444,7 +2444,7 @@
     (void) uMsg;
     (void) dw1;
     (void) dw2;
-
+    
     stream = (PaWinDsStream *) dwUser;
     if( stream == NULL ) return;
 
@@ -2475,8 +2475,8 @@
             int callbackResult = TimeSlice( stream );
             if( callbackResult != paContinue )
             {
-                /* FIXME implement handling of paComplete and paAbort if possible
-                   At the moment this should behave as if paComplete was called and
+                /* FIXME implement handling of paComplete and paAbort if possible 
+                   At the moment this should behave as if paComplete was called and 
                    flush the buffer.
                 */
 
@@ -2577,7 +2577,7 @@
     // Unlock the DS buffer
     if ((hr = IDirectSoundBuffer_Unlock( stream->pDirectSoundOutputBuffer, pDSBuffData, dwDataLen, NULL, 0)) != DS_OK)
         return hr;
-
+    
     // Let DSound set the starting write position because if we set it to zero, it looks like the
     // buffer is full to begin with. This causes a long pause before sound starts when using large buffers.
     if ((hr = IDirectSoundBuffer_GetCurrentPosition( stream->pDirectSoundOutputBuffer,
@@ -2594,10 +2594,10 @@
     PaError          result = paNoError;
     PaWinDsStream   *stream = (PaWinDsStream*)s;
     HRESULT          hr;
-
+        
     stream->callbackResult = paContinue;
     PaUtil_ResetBufferProcessor( &stream->bufferProcessor );
-
+    
     ResetEvent( stream->processingCompleted );
 
     if( stream->bufferProcessor.inputChannelCount > 0 )
@@ -2674,7 +2674,7 @@
         resolution = msecPerWakeup/4;
         stream->timerID = timeSetEvent( msecPerWakeup, resolution, (LPTIMECALLBACK) TimerCallback,
                                              (DWORD_PTR) stream, TIME_PERIODIC | TIME_KILL_SYNCHRONOUS );
-
+    
         if( stream->timerID == 0 )
         {
             stream->isActive = 0;
@@ -2854,7 +2854,7 @@
 
     /* suppress unused variable warnings */
     (void) stream;
-
+    
     /* IMPLEMENT ME, see portaudio.h for required behavior*/
 
     return 0;

 

  ViewVC Help
Powered by ViewVC 1.1.22