From 423cec2ff20f40b7ed839b84033b49c7a2a3551b Mon Sep 17 00:00:00 2001 From: Volker Fischer Date: Sat, 4 Jul 2015 08:47:46 +0000 Subject: [PATCH] possible fix for a crash for some external audio interfaces --- mac/sound.cpp | 22 ++++++++++++++-------- 1 file changed, 14 insertions(+), 8 deletions(-) diff --git a/mac/sound.cpp b/mac/sound.cpp index c1b41aae..595a3ed9 100755 --- a/mac/sound.cpp +++ b/mac/sound.cpp @@ -243,16 +243,22 @@ void CSound::GetAudioDeviceInfos ( const AudioDeviceID DeviceID, &iPropertySize, &sPropertyStringValue ); - // convert CFString in c-string (quick hack!) and then in QString - char* sC_strPropValue = - (char*) malloc ( CFStringGetLength ( sPropertyStringValue ) + 1 ); + // first check if the string is not empty + strDeviceName = "UNKNOWN"; // init value in case no name is available - CFStringGetCString ( sPropertyStringValue, - sC_strPropValue, - CFStringGetLength ( sPropertyStringValue ) + 1, - kCFStringEncodingISOLatin1 ); + if ( CFStringGetLength ( sPropertyStringValue ) > 0 ) + { + // convert CFString in c-string (quick hack!) and then in QString + char* sC_strPropValue = + (char*) malloc ( CFStringGetLength ( sPropertyStringValue ) + 1 ); - strDeviceName = sC_strPropValue; + CFStringGetCString ( sPropertyStringValue, + sC_strPropValue, + CFStringGetLength ( sPropertyStringValue ) + 1, + kCFStringEncodingISOLatin1 ); + + strDeviceName = sC_strPropValue; + } // check if device is input or output or both (is that possible?) // we do this by trying to set the current device for the audio unit