osx - Core Audio and the Phantom Device ID -
osx - Core Audio and the Phantom Device ID -
so here's going on.
i attempting work core audio, input devices. want mute, alter volume, etc, etc. i've encountered absolutely bizarre cannot figure out. far, google has been of no help.
when query scheme , inquire list of sound devices, returned array of device ids. in case, 261, 259, 263, 257.
using kaudiodevicepropertydevicename, following:
261: built-in microphone 259: built-in input 263: built-in output 257: iphonesimulatoraudiodevice
this , good.
// method returns nsarray of sound devices on system, both input , // on system, returns 261, 259, 263, 257 - (nsarray*)getaudiodevices { audioobjectpropertyaddress propertyaddress = { kaudiohardwarepropertydevices, kaudioobjectpropertyscopeglobal, kaudioobjectpropertyelementmaster }; uint32 datasize = 0; osstatus status = audioobjectgetpropertydatasize(kaudioobjectsystemobject, &propertyaddress, 0, null, &datasize); if(kaudiohardwarenoerror != status) { mzlog(@"unable number of sound devices. error: %d",status); homecoming null; } uint32 devicecount = datasize / sizeof(audiodeviceid); audiodeviceid *audiodevices = malloc(datasize); status = audioobjectgetpropertydata(kaudioobjectsystemobject, &propertyaddress, 0, null, &datasize, audiodevices); if(kaudiohardwarenoerror != status) { mzlog(@"audioobjectgetpropertydata failed when getting device ids. error: %d",status); free(audiodevices), audiodevices = null; homecoming null; } nsmutablearray* devices = [nsmutablearray array]; for(uint32 = 0; < devicecount; i++) { mzlog(@"device found: %d",audiodevices[i]); [devices addobject:[nsnumber numberwithint:audiodevices[i]]]; } free(audiodevices); homecoming [nsarray arraywitharray:devices]; }
the problem crops when query scheme , inquire id of default input device. method returns id of 269, not listed in array of devices.
if effort utilize kaudiodevicepropertydevicename name of device, returned empty string. although doesn't appear have name, if mute device id, built-in microphone mute. conversely, if mute 261 id, named "built-in microphone", microphone not mute.
// gets current default sound input device // on system, returns 269, not listed in array of sound devices - (audiodeviceid)defaultinputdevice { audiodeviceid defaultaudiodevice; uint32 propertysize = 0; osstatus status = noerr; audioobjectpropertyaddress propertyaopa; propertyaopa.melement = kaudioobjectpropertyelementmaster; propertyaopa.mscope = kaudioobjectpropertyscopeglobal; propertyaopa.mselector = kaudiohardwarepropertydefaultinputdevice; propertysize = sizeof(audiodeviceid); status = audiohardwareservicegetpropertydata(kaudioobjectsystemobject, &propertyaopa, 0, null, &propertysize, &defaultaudiodevice); if(status) { //error nslog(@"error %d retreiving default input device",status); homecoming 0; } homecoming defaultaudiodevice; }
to farther confuse things, if manually switch input "line in" , re-run program, id of 259 when querying default input device, is listed in array of devices.
so, summarize:
i attempting interact input devices in system. if seek interact device id 261 "built-in microphone", nil happens. if seek interact device id 269 is, apparently, phantom id, built-in microphone affected. 269 id returned when query scheme default input device, not listed when query scheme list of devices.
does know happening? going insane?
thanks in advance!
fixed it.
first off, phantom device id virtual device scheme using.
secondly, reason couldn't mute or actual devices because using audiohardwareservicesetpropertydata instead of audioobjectsetpropertydata.
it works now.
osx cocoa audio core-audio carbon
Comments
Post a Comment