objective c - AUHAL with USB audio device -
i've got usb audio device (presonus audiobox) , want able switch audio output of program between usb device , default output device (the internal speakers). apple documentation tells me have use auhal:
if need connect [..] hardware device other default output device, need use auhal.
normally, make device description , if exists. wrote function test this:
-(osstatus) showauhaldevices { //show available auhal devices // create description audiocomponentdescription test_desc; test_desc.componenttype = kaudiounittype_output; test_desc.componentsubtype = kaudiounitsubtype_haloutput; test_desc.componentmanufacturer = kaudiounitmanufacturer_apple; test_desc.componentflags = 0; test_desc.componentflagsmask = 0; // determine number of available components uint32 count = audiocomponentcount(&test_desc); // print result osstatus err = noerr; cfstringref compname; audiocomponent test_comp; (uint32 = 0; < count; i++) { test_comp = audiocomponentfindnext(nil, &test_desc); err = audiocomponentcopyname(test_comp, &compname); nslog(@"audio component number %u/%u: %@", (i+1), count, compname); } return err; }
the problem here cannot set test_desc.componentmanufacturer = kaudiounitmanufacturer_apple;
manufacturer apple, usb device doesn't show in list printed in log.
what missing? , far know, not driver issue.
thanks in advance.
edit
i've set properties zero, usb device still doesn't show between 98 different components. can find [avcapturedevice deviceswithmediatype:avmediatypeaudio]
though, can set input, not output..
componentmanufacture
can set 0 treat wildcard (as can componenttype
, componentsubtype
).
//show available auhal devices // create description audiocomponentdescription test_desc; test_desc.componenttype = kaudiounittype_output; test_desc.componentsubtype = kaudiounitsubtype_haloutput; test_desc.componentmanufacturer = 0; test_desc.componentflags = 0; test_desc.componentflagsmask = 0;
additionally, usage of audiocomponentfindnext
wrong in how pass nil
first parameter. first parameter should component wish begin search from. pass nil first time , result of first call second time , on.
audiocomponent test_comp = nullptr; (uint32 = 0; < count; i++) { test_comp = audiocomponentfindnext(test_comp, &test_desc); ... }
Comments
Post a Comment