From 9d0703f03ac2972409816f147e2141b3fe315a54 Mon Sep 17 00:00:00 2001 From: Gary Scavone Date: Sat, 28 Dec 2013 08:38:15 -0800 Subject: A few small memory leak fixes from MK --- RtAudio.cpp | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) (limited to 'RtAudio.cpp') 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 -- cgit v1.2.3