possible fix for a crash for some external audio interfaces

This commit is contained in:
Volker Fischer 2015-07-04 08:47:46 +00:00
parent 066d8abfaa
commit 423cec2ff2

View file

@ -243,16 +243,22 @@ void CSound::GetAudioDeviceInfos ( const AudioDeviceID DeviceID,
&iPropertySize, &iPropertySize,
&sPropertyStringValue ); &sPropertyStringValue );
// convert CFString in c-string (quick hack!) and then in QString // first check if the string is not empty
char* sC_strPropValue = strDeviceName = "UNKNOWN"; // init value in case no name is available
(char*) malloc ( CFStringGetLength ( sPropertyStringValue ) + 1 );
CFStringGetCString ( sPropertyStringValue, if ( CFStringGetLength ( sPropertyStringValue ) > 0 )
sC_strPropValue, {
CFStringGetLength ( sPropertyStringValue ) + 1, // convert CFString in c-string (quick hack!) and then in QString
kCFStringEncodingISOLatin1 ); 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?) // 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 // we do this by trying to set the current device for the audio unit