Wasap bug(?) fix in destructor; Update to record.cpp for default device selection.
authorGary Scavone <gary@music.mcgill.ca>
Sat, 26 Apr 2014 12:44:43 +0000 (08:44 -0400)
committerGary Scavone <gary@music.mcgill.ca>
Sat, 26 Apr 2014 12:44:43 +0000 (08:44 -0400)
RtAudio.cpp
tests/record.cpp

index 039b5d03a362d74fcbae609a7d2b534022549ccc..a31a54bc421a162b487c63fcf79d4b84abfda94c 100644 (file)
@@ -3850,7 +3850,6 @@ RtApiWasapi::RtApiWasapi()
 {\r
   // WASAPI can run either apartment or multi-threaded\r
   HRESULT hr = CoInitialize( NULL );\r
-\r
   if ( !FAILED( hr ) )\r
     coInitialized_ = true;\r
 \r
@@ -3869,16 +3868,14 @@ RtApiWasapi::RtApiWasapi()
 \r
 RtApiWasapi::~RtApiWasapi()\r
 {\r
-  // if this object previously called CoInitialize()\r
-  if ( coInitialized_ ) {\r
-    CoUninitialize();\r
-  }\r
-\r
-  if ( stream_.state != STREAM_CLOSED ) {\r
+  if ( stream_.state != STREAM_CLOSED )\r
     closeStream();\r
-  }\r
 \r
   SAFE_RELEASE( deviceEnumerator_ );\r
+\r
+  // If this object previously called CoInitialize()\r
+  if ( coInitialized_ )\r
+    CoUninitialize();\r
 }\r
 \r
 //=============================================================================\r
@@ -5095,7 +5092,6 @@ Exit:
   CoTaskMemFree( captureFormat );\r
   CoTaskMemFree( renderFormat );\r
 \r
-  //delete convBuffer;\r
   free ( convBuffer );\r
 \r
   CoUninitialize();\r
index d16ea4955efac57ea451753696fb2a88dbfdb863..0e48f77e02dfe87e7cf521cb56837c3e61a7c441 100644 (file)
@@ -117,7 +117,10 @@ int main( int argc, char *argv[] )
   // Set our stream parameters for input only.
   bufferFrames = 512;
   RtAudio::StreamParameters iParams;
-  iParams.deviceId = device;
+  if ( device == 0 )
+    iParams.deviceId = adc.getDefaultInputDevice();
+  else
+    iParams.deviceId = device;
   iParams.nChannels = channels;
   iParams.firstChannel = offset;