MCPcopy Create free account
hub / github.com/briankendall/proxy-audio-device / QueryInterface

Method QueryInterface

proxyAudioDevice/ProxyAudioDevice.cpp:415–459  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

413#pragma mark Inheritence
414
415HRESULT ProxyAudioDevice::QueryInterface(void *inDriver, REFIID inUUID, LPVOID *outInterface) {
416 // This function is called by the HAL to get the interface to talk to the plug-in through.
417 // AudioServerPlugIns are required to support the IUnknown interface and the
418 // AudioServerPlugInDriverInterface. As it happens, all interfaces must also provide the
419 // IUnknown interface, so we can always just return the single interface we made with
420 // gAudioServerPlugInDriverInterfacePtr regardless of which one is asked for.
421
422 // declare the local variables
423 HRESULT theAnswer = 0;
424 CFUUIDRef theRequestedUUID = NULL;
425
426 // validate the arguments
427 FailWithAction(inDriver != gAudioServerPlugInDriverRef,
428 theAnswer = kAudioHardwareBadObjectError,
429 Done,
430 "ProxyAudio_QueryInterface: bad driver reference");
431 FailWithAction(outInterface == NULL,
432 theAnswer = kAudioHardwareIllegalOperationError,
433 Done,
434 "ProxyAudio_QueryInterface: no place to store the returned interface");
435
436 // make a CFUUIDRef from inUUID
437 theRequestedUUID = CFUUIDCreateFromUUIDBytes(NULL, inUUID);
438 FailWithAction(theRequestedUUID == NULL,
439 theAnswer = kAudioHardwareIllegalOperationError,
440 Done,
441 "ProxyAudio_QueryInterface: failed to create the CFUUIDRef");
442
443 // AudioServerPlugIns only support two interfaces, IUnknown (which has to be supported by all
444 // CFPlugIns and AudioServerPlugInDriverInterface (which is the actual interface the HAL will
445 // use).
446 if (CFEqual(theRequestedUUID, IUnknownUUID) || CFEqual(theRequestedUUID, kAudioServerPlugInDriverInterfaceUUID)) {
447 CAMutex::Locker locker(stateMutex);
448 ++gPlugIn_RefCount;
449 *outInterface = gAudioServerPlugInDriverRef;
450 } else {
451 theAnswer = E_NOINTERFACE;
452 }
453
454 // make sure to release the UUID we created
455 CFRelease(theRequestedUUID);
456
457Done:
458 return theAnswer;
459}
460
461ULONG ProxyAudioDevice::AddRef(void *inDriver) {
462 // This call returns the resulting reference count after the increment.

Callers 1

Calls

no outgoing calls

Tested by

no test coverage detected