Updated WASAPI code from v0.1 to v0.2.
authorGary Scavone <gary@music.mcgill.ca>
Wed, 2 Apr 2014 17:41:27 +0000 (13:41 -0400)
committerGary Scavone <gary@music.mcgill.ca>
Wed, 2 Apr 2014 17:41:27 +0000 (13:41 -0400)
RtAudio.cpp
tests/Windows/audioprobe.dsp

index c5a2a87afd99ed280a9881a3c8a89d348cbdb6aa..202de261a46668af3e8b6e0fb857c4e41f2f793c 100644 (file)
@@ -4560,11 +4560,7 @@ void RtApiWasapi::wasapiThread()
     EXIT_ON_ERROR( hr, RtAudioError::DRIVER_ERROR, "Unable to get capture buffer size" );\r
 \r
     // scale outBufferSize according to stream->user sample rate ratio\r
-    // (outBufferSize must be a multiple of the input channel count)\r
-    unsigned int outBufferSize = ( unsigned int ) ( stream_.bufferSize * stream_.nDeviceChannels[INPUT] * captureSrRatio );\r
-    if ( outBufferSize % stream_.nDeviceChannels[INPUT] )\r
-      outBufferSize += stream_.nDeviceChannels[INPUT] - ( outBufferSize % stream_.nDeviceChannels[INPUT] );\r
-\r
+    unsigned int outBufferSize = ( unsigned int ) ( stream_.bufferSize * captureSrRatio ) * stream_.nDeviceChannels[INPUT];\r
     inBufferSize *= stream_.nDeviceChannels[INPUT];\r
 \r
     // set captureBuffer size\r
@@ -4620,12 +4616,7 @@ void RtApiWasapi::wasapiThread()
     EXIT_ON_ERROR( hr, RtAudioError::DRIVER_ERROR, "Unable to get render buffer size" );\r
 \r
     // scale inBufferSize according to user->stream sample rate ratio\r
-    // (inBufferSize must be a multiple of the output channel count)\r
-    unsigned int inBufferSize = ( unsigned int ) ( stream_.bufferSize * stream_.nDeviceChannels[OUTPUT] * renderSrRatio );\r
-    if ( inBufferSize % stream_.nDeviceChannels[OUTPUT] ) {\r
-      inBufferSize += stream_.nDeviceChannels[OUTPUT] - ( inBufferSize % stream_.nDeviceChannels[OUTPUT] );\r
-    }\r
-\r
+    unsigned int inBufferSize = ( unsigned int ) ( stream_.bufferSize * renderSrRatio ) * stream_.nDeviceChannels[OUTPUT];\r
     outBufferSize *= stream_.nDeviceChannels[OUTPUT];\r
 \r
     // set renderBuffer size\r
@@ -4660,14 +4651,14 @@ void RtApiWasapi::wasapiThread()
   char* convBuffer = NULL;\r
 \r
   if ( stream_.mode == INPUT ) {\r
-    convBuffer = ( char* ) malloc( ( size_t ) ( stream_.bufferSize * stream_.nDeviceChannels[INPUT] * captureSrRatio * formatBytes( stream_.deviceFormat[INPUT] ) ) );\r
+    convBuffer = ( char* ) malloc( ( size_t ) ( stream_.bufferSize * captureSrRatio ) * stream_.nDeviceChannels[INPUT] * formatBytes( stream_.deviceFormat[INPUT] ) );\r
   }\r
   else if ( stream_.mode == OUTPUT ) {\r
-    convBuffer = ( char* ) malloc( ( size_t ) ( stream_.bufferSize * stream_.nDeviceChannels[OUTPUT] * renderSrRatio * formatBytes( stream_.deviceFormat[OUTPUT] ) ) );\r
+    convBuffer = ( char* ) malloc( ( size_t ) ( stream_.bufferSize * renderSrRatio ) * stream_.nDeviceChannels[OUTPUT] * formatBytes( stream_.deviceFormat[OUTPUT] ) );\r
   }\r
   else if ( stream_.mode == DUPLEX ) {\r
-    convBuffer = ( char* ) malloc( max( ( size_t ) ( stream_.bufferSize * stream_.nDeviceChannels[INPUT] * captureSrRatio * formatBytes( stream_.deviceFormat[INPUT] ) ),\r
-                                        ( size_t ) ( stream_.bufferSize * stream_.nDeviceChannels[OUTPUT] * renderSrRatio * formatBytes( stream_.deviceFormat[OUTPUT] ) ) ) );\r
+    convBuffer = ( char* ) malloc( max( ( size_t ) ( stream_.bufferSize * captureSrRatio ) * stream_.nDeviceChannels[INPUT] * formatBytes( stream_.deviceFormat[INPUT] ),\r
+                                        ( size_t ) ( stream_.bufferSize * renderSrRatio ) * stream_.nDeviceChannels[OUTPUT] * formatBytes( stream_.deviceFormat[OUTPUT] ) ) );\r
   }\r
 \r
   // stream process loop\r
@@ -4682,7 +4673,7 @@ void RtApiWasapi::wasapiThread()
       if ( captureAudioClient ) {\r
         // Pull callback buffer from inputBuffer\r
         callbackPulled = captureBuffer.pullBuffer( convBuffer,\r
-                                                   ( unsigned int ) ( stream_.bufferSize * stream_.nDeviceChannels[INPUT] * captureSrRatio ),\r
+                                                   ( unsigned int ) ( stream_.bufferSize * captureSrRatio ) * stream_.nDeviceChannels[INPUT],\r
                                                    stream_.deviceFormat[INPUT] );\r
 \r
         if ( callbackPulled ) {\r
index cbdc11ad844eaddb949ee108ecb65ca999b230cb..2eebcc3565579930fe7905f8b82750d28cffb62f 100755 (executable)
@@ -42,7 +42,7 @@ RSC=rc.exe
 # PROP Ignore_Export_Lib 0\r
 # PROP Target_Dir ""\r
 # ADD BASE CPP /nologo /W3 /GX /O2 /D "WIN32" /D "NDEBUG" /D "_CONSOLE" /D "_MBCS" /YX /FD /c\r
-# ADD CPP /nologo /MT /W3 /GX /O2 /I "../../" /I "../../include" /D "NDEBUG" /D "__WINDOW_DS__" /D "__WINDOWS_DS__" /D "__WINDOWS_ASIO__" /D "WIN32" /D "_CONSOLE" /D "_MBCS" /YX /FD /c\r
+# ADD CPP /nologo /MT /W3 /GX /O2 /I "../../" /I "../../include" /D "NDEBUG" /D "__WINDOWS_DS__" /D "__WINDOWS_ASIO__" /D "WIN32" /D "_CONSOLE" /D "_MBCS" /YX /FD /c\r
 # ADD BASE RSC /l 0x409 /d "NDEBUG"\r
 # ADD RSC /l 0x409 /d "NDEBUG"\r
 BSC32=bscmake.exe\r