fixed two warnings

This commit is contained in:
Volker Fischer 2015-11-13 21:41:07 +00:00
parent 233c34ba45
commit 15e44213a7

View File

@ -139,7 +139,8 @@ CSound::CSound ( void (*fpNewProcessCallback) ( CVector<short>& psData, void* ar
// Get available input/output devices -------------------------------------- // Get available input/output devices --------------------------------------
UInt32 iPropertySize; UInt32 iPropertySize;
AudioObjectPropertyAddress stPropertyAddress;
// first get property size of devices array and allocate memory // first get property size of devices array and allocate memory
AudioHardwareGetPropertyInfo ( kAudioHardwarePropertyDevices, AudioHardwareGetPropertyInfo ( kAudioHardwarePropertyDevices,
@ -160,13 +161,13 @@ CSound::CSound ( void (*fpNewProcessCallback) ( CVector<short>& psData, void* ar
lNumDevs = 0; lNumDevs = 0;
strDriverNames[lNumDevs] = "System Default In/Out Devices"; strDriverNames[lNumDevs] = "System Default In/Out Devices";
iPropertySize = sizeof ( AudioDeviceID ); iPropertySize = sizeof ( AudioDeviceID );
AudioObjectPropertyAddress ePropertyInDevAddress = { kAudioHardwarePropertyDefaultInputDevice, stPropertyAddress.mSelector = kAudioHardwarePropertyDefaultInputDevice;
kAudioObjectPropertyScopeGlobal, stPropertyAddress.mScope = kAudioObjectPropertyScopeGlobal;
kAudioObjectPropertyElementMaster }; stPropertyAddress.mElement = kAudioObjectPropertyElementMaster;
if ( AudioObjectGetPropertyData ( kAudioObjectSystemObject, if ( AudioObjectGetPropertyData ( kAudioObjectSystemObject,
&ePropertyInDevAddress, &stPropertyAddress,
0, 0,
NULL, NULL,
&iPropertySize, &iPropertySize,
@ -176,13 +177,13 @@ CSound::CSound ( void (*fpNewProcessCallback) ( CVector<short>& psData, void* ar
"It seems that no sound card is available in the system." ) ); "It seems that no sound card is available in the system." ) );
} }
iPropertySize = sizeof ( AudioDeviceID ); iPropertySize = sizeof ( AudioDeviceID );
AudioObjectPropertyAddress ePropertyOutDevAddress = { kAudioHardwarePropertyDefaultOutputDevice, stPropertyAddress.mSelector = kAudioHardwarePropertyDefaultOutputDevice;
kAudioObjectPropertyScopeGlobal, stPropertyAddress.mScope = kAudioObjectPropertyScopeGlobal;
kAudioObjectPropertyElementMaster }; stPropertyAddress.mElement = kAudioObjectPropertyElementMaster;
if ( AudioObjectGetPropertyData ( kAudioObjectSystemObject, if ( AudioObjectGetPropertyData ( kAudioObjectSystemObject,
&ePropertyOutDevAddress, &stPropertyAddress,
0, 0,
NULL, NULL,
&iPropertySize, &iPropertySize,
@ -247,16 +248,48 @@ void CSound::GetAudioDeviceInfos ( const AudioDeviceID DeviceID,
bool& bIsInput, bool& bIsInput,
bool& bIsOutput ) bool& bIsOutput )
{ {
// 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
// with the parameter input and output and then we simply check the
// error/ok result
bIsInput = !AudioUnitSetProperty ( audioInputUnit,
kAudioOutputUnitProperty_CurrentDevice,
kAudioUnitScope_Global,
1,
&DeviceID,
sizeof ( AudioDeviceID ) );
bIsOutput = !AudioUnitSetProperty ( audioOutputUnit,
kAudioOutputUnitProperty_CurrentDevice,
kAudioUnitScope_Global,
0,
&DeviceID,
sizeof ( AudioDeviceID ) );
// get property name // get property name
UInt32 iPropertySize = sizeof ( CFStringRef ); UInt32 iPropertySize = sizeof ( CFStringRef );
CFStringRef sPropertyStringValue; CFStringRef sPropertyStringValue;
AudioDeviceGetProperty ( DeviceID, AudioObjectPropertyAddress stPropertyAddress;
0, stPropertyAddress.mSelector = kAudioObjectPropertyName;
false,
kAudioObjectPropertyName, if ( bIsInput )
&iPropertySize, {
&sPropertyStringValue ); stPropertyAddress.mScope = kAudioDevicePropertyScopeInput;
}
else
{
stPropertyAddress.mScope = kAudioDevicePropertyScopeOutput;
}
stPropertyAddress.mElement = 0; // channel
AudioObjectGetPropertyData ( DeviceID,
&stPropertyAddress,
0,
NULL,
&iPropertySize,
&sPropertyStringValue );
// first check if the string is not empty // first check if the string is not empty
strDeviceName = "UNKNOWN"; // init value in case no name is available strDeviceName = "UNKNOWN"; // init value in case no name is available
@ -275,24 +308,6 @@ void CSound::GetAudioDeviceInfos ( const AudioDeviceID DeviceID,
strDeviceName = sC_strPropValue; 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
// with the parameter input and output and then we simply check the
// error/ok result
bIsInput = !AudioUnitSetProperty ( audioInputUnit,
kAudioOutputUnitProperty_CurrentDevice,
kAudioUnitScope_Global,
1,
&DeviceID,
sizeof ( AudioDeviceID ) );
bIsOutput = !AudioUnitSetProperty ( audioOutputUnit,
kAudioOutputUnitProperty_CurrentDevice,
kAudioUnitScope_Global,
0,
&DeviceID,
sizeof ( AudioDeviceID ) );
} }
QString CSound::LoadAndInitializeDriver ( int iDriverIdx ) QString CSound::LoadAndInitializeDriver ( int iDriverIdx )