A few small memory leak fixes from MK
authorGary Scavone <gary@music.mcgill.ca>
Sat, 28 Dec 2013 16:38:15 +0000 (08:38 -0800)
committerGary Scavone <gary@music.mcgill.ca>
Sat, 28 Dec 2013 16:38:15 +0000 (08:38 -0800)
RtAudio.cpp
RtAudio.h

index 1562e858629f6f92e0deea89bcaf6d180aa932d8..f9259df42dd2ee34f18ffb22a5ad7f27330be63d 100644 (file)
@@ -5358,6 +5358,8 @@ RtAudio::DeviceInfo RtApiAlsa :: getDeviceInfo( unsigned int device )
       goto probeParameters;\r
     }\r
   }\r
+  else\r
+    snd_ctl_close( chandle );\r
 \r
   result = snd_pcm_open( &phandle, name, stream, openMode | SND_PCM_NONBLOCK);\r
   if ( result < 0 ) {\r
@@ -5470,6 +5472,7 @@ RtAudio::DeviceInfo RtApiAlsa :: getDeviceInfo( unsigned int device )
 \r
   // Check that we have at least one supported format\r
   if ( info.nativeFormats == 0 ) {\r
+    snd_pcm_close( phandle );\r
     errorStream_ << "RtApiAlsa::getDeviceInfo: pcm device (" << name << ") data format not supported by RtAudio.";\r
     errorText_ = errorStream_.str();\r
     error( RtAudioError::WARNING );\r
@@ -5479,8 +5482,10 @@ RtAudio::DeviceInfo RtApiAlsa :: getDeviceInfo( unsigned int device )
   // Get the device name\r
   char *cardname;\r
   result = snd_card_get_name( card, &cardname );\r
-  if ( result >= 0 )\r
+  if ( result >= 0 ) {\r
     sprintf( name, "hw:%s,%d", cardname, subdevice );\r
+    free( cardname );\r
+  }\r
   info.name = name;\r
 \r
   // That's all ... close the device and return\r
index 2be313da4fc8b76b2bc423500d9413821b008d8a..d1fbd65253196922db5031913e56f062997d221b 100644 (file)
--- a/RtAudio.h
+++ b/RtAudio.h
@@ -190,9 +190,8 @@ typedef int (*RtAudioCallback)( void *outputBuffer, void *inputBuffer,
     \brief Exception handling class for RtAudio.
 
     The RtAudioError class is quite simple but it does allow errors to be
-    "caught" by RtAudioError::Type. See the RtAudio and RtMidi
-    documentation to know which methods can throw an RtAudioError.
-
+    "caught" by RtAudioError::Type. See the RtAudio documentation to know
+    which methods can throw an RtAudioError.
 */
 /************************************************************************/