Unable to set/get headset mic volume
Unable to set/get headset mic volume
- Subject: Unable to set/get headset mic volume
- From: Symadept <email@hidden>
- Date: Mon, 14 Dec 2009 23:21:47 +0800
Hi,
I am using the following method to retrieve the Mic volume, but AudioHardwareServiceHasProperty is failing. I realized that my mic has 1 input channel than the master. But the property, kAudioHardwareServiceDeviceProperty_VirtualMasterVolume documentation says irrespective of the way the volume channels, it shall give me the aggregate volume level. Can anybody help me what is wrong in the following code?
+ (float)volumeOfDeviceId:(AudioDeviceID)deviceId isInput:(BOOL)isInput
{
NSLog(@"\n\nVolumeOfDeviceId:[%x] isInput:[%d]", deviceId, isInput);
Float32 outputVolume;
UInt32 propertySize = 0;
OSStatus status = noErr;
AudioObjectPropertyAddress propertyAOPA;
propertyAOPA.mElement = kAudioObjectPropertyElementMaster;
propertyAOPA.mSelector = kAudioHardwareServiceDeviceProperty_VirtualMasterVolume;
propertyAOPA.mScope = (isInput? kAudioDevicePropertyScopeInput: kAudioDevicePropertyScopeOutput);
AudioDeviceID outputDeviceID = deviceId;//[KNVolumeControl defaultOutputDeviceID];
if (outputDeviceID == kAudioObjectUnknown)
{
NSLog(@"Unknown device");
return 0.0;
}
if (!AudioHardwareServiceHasProperty(outputDeviceID, &propertyAOPA))
{
NSLog(@"ServiceFailed: No volume returned for device 0x%0x", outputDeviceID);
return 0.0;
}
propertySize = sizeof(Float32);
status = AudioHardwareServiceGetPropertyData(outputDeviceID, &propertyAOPA, 0, NULL, &propertySize, &outputVolume);
if (status)
{
NSLog(@"PropertyData failed: No volume returned for device 0x%0x", outputDeviceID);
return 0.0;
}
if (outputVolume < 0.0 || outputVolume > 1.0) return 0.0;
return outputVolume;
}
Regards
Mustafa Shaik
email@hidden
_______________________________________________
Do not post admin requests to the list. They will be ignored.
Coreaudio-api mailing list (email@hidden)
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden