From 9d0703f03ac2972409816f147e2141b3fe315a54 Mon Sep 17 00:00:00 2001 From: Gary Scavone Date: Sat, 28 Dec 2013 08:38:15 -0800 Subject: [PATCH] A few small memory leak fixes from MK --- RtAudio.cpp | 7 ++++++- RtAudio.h | 5 ++--- 2 files changed, 8 insertions(+), 4 deletions(-) diff --git a/RtAudio.cpp b/RtAudio.cpp index 1562e85..f9259df 100644 --- a/RtAudio.cpp +++ b/RtAudio.cpp @@ -5358,6 +5358,8 @@ RtAudio::DeviceInfo RtApiAlsa :: getDeviceInfo( unsigned int device ) goto probeParameters; } } + else + snd_ctl_close( chandle ); result = snd_pcm_open( &phandle, name, stream, openMode | SND_PCM_NONBLOCK); if ( result < 0 ) { @@ -5470,6 +5472,7 @@ RtAudio::DeviceInfo RtApiAlsa :: getDeviceInfo( unsigned int device ) // Check that we have at least one supported format if ( info.nativeFormats == 0 ) { + snd_pcm_close( phandle ); errorStream_ << "RtApiAlsa::getDeviceInfo: pcm device (" << name << ") data format not supported by RtAudio."; errorText_ = errorStream_.str(); error( RtAudioError::WARNING ); @@ -5479,8 +5482,10 @@ RtAudio::DeviceInfo RtApiAlsa :: getDeviceInfo( unsigned int device ) // Get the device name char *cardname; result = snd_card_get_name( card, &cardname ); - if ( result >= 0 ) + if ( result >= 0 ) { sprintf( name, "hw:%s,%d", cardname, subdevice ); + free( cardname ); + } info.name = name; // That's all ... close the device and return diff --git a/RtAudio.h b/RtAudio.h index 2be313d..d1fbd65 100644 --- 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. */ /************************************************************************/ -- 2.30.2