PhantomAudioDevice.cpp [plain text]
#include "PhantomAudioDevice.h"
#include "PhantomAudioEngine.h"
#include <IOKit/audio/IOAudioControl.h>
#include <IOKit/audio/IOAudioDefines.h>
#include <IOKit/IOLib.h>
#define super IOAudioDevice
OSDefineMetaClassAndStructors(PhantomAudioDevice, IOAudioDevice)
bool PhantomAudioDevice::initHardware(IOService *provider)
{
bool result = false;
IOLog("PhantomAudioDevice[%p]::initHardware(%p)\n", this, provider);
if (!super::initHardware(provider)) {
goto Done;
}
setDeviceName("DeviceName");
setDeviceShortName("DeviceShortName");
setManufacturerName("ManufacturerName");
setProperty (kIOAudioDeviceLocalizedBundleKey, "PhantomAudioDriver.kext");
if (!createAudioEngines()) {
goto Done;
}
result = true;
Done:
return result;
}
bool PhantomAudioDevice::createAudioEngines()
{
bool result = false;
OSArray *audioEngineArray;
IOLog("PhantomAudioDevice[%p]::createAudioEngine()\n", this);
audioEngineArray = OSDynamicCast(OSArray, getProperty(AUDIO_ENGINES_KEY));
if (audioEngineArray) {
OSCollectionIterator *audioEngineIterator;
audioEngineIterator = OSCollectionIterator::withCollection(audioEngineArray);
if (audioEngineIterator) {
OSDictionary *audioEngineDict;
while (audioEngineDict = (OSDictionary *)audioEngineIterator->getNextObject()) {
if (OSDynamicCast(OSDictionary, audioEngineDict) != NULL) {
PhantomAudioEngine *audioEngine;
audioEngine = new PhantomAudioEngine;
if (audioEngine) {
if (audioEngine->init(audioEngineDict)) {
activateAudioEngine(audioEngine);
}
audioEngine->release();
}
}
}
audioEngineIterator->release();
}
} else {
IOLog("PhantomAudioDevice[%p]::createAudioEngine() - Error: no AudioEngine array in personality.\n", this);
goto Done;
}
result = true;
Done:
return result;
}
IOReturn PhantomAudioDevice::volumeChangeHandler(IOService *target, IOAudioControl *volumeControl, SInt32 oldValue, SInt32 newValue)
{
IOReturn result = kIOReturnBadArgument;
PhantomAudioDevice *audioDevice;
audioDevice = (PhantomAudioDevice *)target;
if (audioDevice) {
result = audioDevice->volumeChanged(volumeControl, oldValue, newValue);
}
return result;
}
IOReturn PhantomAudioDevice::volumeChanged(IOAudioControl *volumeControl, SInt32 oldValue, SInt32 newValue)
{
IOLog("PhantomAudioDevice[%p]::volumeChanged(%p, %ld, %ld)\n", this, volumeControl, oldValue, newValue);
if (volumeControl) {
IOLog("\t-> Channel %ld\n", volumeControl->getChannelID());
}
return kIOReturnSuccess;
}
IOReturn PhantomAudioDevice::outputMuteChangeHandler(IOService *target, IOAudioControl *muteControl, SInt32 oldValue, SInt32 newValue)
{
IOReturn result = kIOReturnBadArgument;
PhantomAudioDevice *audioDevice;
audioDevice = (PhantomAudioDevice *)target;
if (audioDevice) {
result = audioDevice->outputMuteChanged(muteControl, oldValue, newValue);
}
return result;
}
IOReturn PhantomAudioDevice::outputMuteChanged(IOAudioControl *muteControl, SInt32 oldValue, SInt32 newValue)
{
IOLog("PhantomAudioDevice[%p]::outputMuteChanged(%p, %ld, %ld)\n", this, muteControl, oldValue, newValue);
if (muteControl) {
IOLog("\t-> Channel %ld\n", muteControl->getChannelID());
}
return kIOReturnSuccess;
}
IOReturn PhantomAudioDevice::gainChangeHandler(IOService *target, IOAudioControl *gainControl, SInt32 oldValue, SInt32 newValue)
{
IOReturn result = kIOReturnBadArgument;
PhantomAudioDevice *audioDevice;
audioDevice = (PhantomAudioDevice *)target;
if (audioDevice) {
result = audioDevice->gainChanged(gainControl, oldValue, newValue);
}
return result;
}
IOReturn PhantomAudioDevice::gainChanged(IOAudioControl *gainControl, SInt32 oldValue, SInt32 newValue)
{
IOLog("PhantomAudioDevice[%p]::gainChanged(%p, %ld, %ld)\n", this, gainControl, oldValue, newValue);
if (gainControl) {
IOLog("\t-> Channel %ld\n", gainControl->getChannelID());
}
return kIOReturnSuccess;
}
IOReturn PhantomAudioDevice::inputMuteChangeHandler(IOService *target, IOAudioControl *muteControl, SInt32 oldValue, SInt32 newValue)
{
IOReturn result = kIOReturnBadArgument;
PhantomAudioDevice *audioDevice;
audioDevice = (PhantomAudioDevice *)target;
if (audioDevice) {
result = audioDevice->inputMuteChanged(muteControl, oldValue, newValue);
}
return result;
}
IOReturn PhantomAudioDevice::inputMuteChanged(IOAudioControl *muteControl, SInt32 oldValue, SInt32 newValue)
{
IOLog("PhantomAudioDevice[%p]::inputMuteChanged(%p, %ld, %ld)\n", this, muteControl, oldValue, newValue);
if (muteControl) {
IOLog("\t-> Channel %ld\n", muteControl->getChannelID());
}
return kIOReturnSuccess;
}
IOReturn PhantomAudioDevice::passThruChangeHandler(IOService *target, IOAudioControl *passThruControl, SInt32 oldValue, SInt32 newValue)
{
IOReturn result = kIOReturnBadArgument;
PhantomAudioDevice *audioDevice;
audioDevice = (PhantomAudioDevice *)target;
if (audioDevice) {
result = audioDevice->passThruChanged(passThruControl, oldValue, newValue);
}
return result;
}
IOReturn PhantomAudioDevice::passThruChanged(IOAudioControl *passThruControl, SInt32 oldValue, SInt32 newValue)
{
IOLog("PhantomAudioDevice[%p]::passThruChanged(%p, %ld, %ld)\n", this, passThruControl, oldValue, newValue);
if (passThruControl) {
IOLog("\t-> Channel %ld\n", passThruControl->getChannelID());
}
return kIOReturnSuccess;
}