void PA_Stream::Initialize() { OSStatus ret; AudioObjectID oid; ret = AudioObjectCreate(plugin->GetInterface(), device->GetObjectID(), kAudioStreamClassID, &oid); if (ret != kAudioHardwareNoError) { DebugLog("AudioObjectCreate() failed with %d", (int) ret); return; } SetObjectID(oid); DebugLog("New stream has ID %d", (int) oid); if (!isInput) { muteControl = new PA_MuteControl(plugin, this); muteControl->Initialize(); volumeControl = new PA_VolumeControl(plugin, this); volumeControl->Initialize(); } }
void SHP_PlugIn::InitializeWithObjectID(AudioObjectID inObjectID) { // initialize the super class HP_HardwarePlugIn::InitializeWithObjectID(inObjectID); // instantiate a new AudioDevice object in the HAL AudioDeviceID theNewDeviceID = 0; #if (MAC_OS_X_VERSION_MAX_ALLOWED < MAC_OS_X_VERSION_10_4) OSStatus theError = AudioHardwareClaimAudioDeviceID(GetInterface(), &theNewDeviceID); #else OSStatus theError = AudioObjectCreate(GetInterface(), kAudioObjectSystemObject, kAudioDeviceClassID, &theNewDeviceID); #endif ThrowIfError(theError, CAException(theError), "SHP_PlugIn::InitializeWithObjectID: couldn't instantiate the AudioDevice object"); // make a device object mDevice = new SHP_Device(theNewDeviceID, this); mDevice->Initialize(); // restore it's settings if necessary UInt32 isMaster = 0; UInt32 theSize = sizeof(UInt32); AudioHardwareGetProperty(kAudioHardwarePropertyProcessIsMaster, &theSize, &isMaster); if(isMaster != 0) { HP_DeviceSettings::RestoreFromPrefs(*mDevice, HP_DeviceSettings::sStandardControlsToSave, HP_DeviceSettings::kStandardNumberControlsToSave); } // set the object state mutex HP_Object::SetObjectStateMutexForID(theNewDeviceID, mDevice->GetObjectStateMutex()); // tell the HAL about the device #if (MAC_OS_X_VERSION_MAX_ALLOWED < MAC_OS_X_VERSION_10_4) theError = AudioHardwareDevicesCreated(GetInterface(), 1, &theNewDeviceID); #else theError = AudioObjectsPublishedAndDied(GetInterface(), kAudioObjectSystemObject, 1, &theNewDeviceID, 0, NULL); #endif AssertNoError(theError, "SHP_PlugIn::InitializeWithObjectID: got an error telling the HAL a device died"); }