Sync BGMDevice volume with output device correctly on BGMApp startup

The listener proc in BGMDeviceControlSync was being triggered during the
initial CopyVolume call. This fix just waits until after the initial
sync to register the listener proc.
This commit is contained in:
Kyle Neideck 2016-02-23 18:57:47 +11:00
parent 5336a5a670
commit 646c00ceb6

View file

@ -60,6 +60,10 @@ void BGMDeviceControlSync::Activate()
BGM_DeviceNotSetException(),
"BGMDeviceControlSync::Activate: Both the output device and BGMDevice must be set to start synchronizing their controls");
// Init BGMDevice controls to match output device
CopyVolume(mOutputDevice, mBGMDevice, kAudioObjectPropertyScopeOutput);
CopyMute(mOutputDevice, mBGMDevice, kAudioObjectPropertyScopeOutput);
if(!mActive)
{
// Register listeners for volume and mute values
@ -75,10 +79,6 @@ void BGMDeviceControlSync::Activate()
throw;
}
// Init BGMDevice controls to match output device
CopyVolume(mOutputDevice, mBGMDevice, kAudioObjectPropertyScopeOutput);
CopyMute(mOutputDevice, mBGMDevice, kAudioObjectPropertyScopeOutput);
mActive = true;
}
}
@ -325,6 +325,8 @@ OSStatus BGMDeviceControlSync::BGMDeviceListenerProc(AudioObjectID inObjectID
// refCon (reference context) is the instance that registered this listener proc
BGMDeviceControlSync* refCon = static_cast<BGMDeviceControlSync*>(inClientData);
if(refCon->mActive)
{
ThrowIf(inObjectID != refCon->mBGMDevice.GetObjectID(),
CAException(kAudioHardwareBadObjectError),
"BGMDeviceControlSync::BGMDeviceListenerProc: notified about audio object other than BGMDevice");
@ -349,6 +351,7 @@ OSStatus BGMDeviceControlSync::BGMDeviceListenerProc(AudioObjectID inObjectID
break;
}
}
}
return 0;
}