add device notification for a property change (e.g. if the number of channels is changed)
This commit is contained in:
parent
cdeb89e514
commit
fbcb7f717a
1 changed files with 37 additions and 6 deletions
|
@ -533,15 +533,28 @@ void CSound::Start()
|
||||||
// setup callback for xruns (only for input is enough)
|
// setup callback for xruns (only for input is enough)
|
||||||
AudioObjectPropertyAddress stPropertyAddress;
|
AudioObjectPropertyAddress stPropertyAddress;
|
||||||
|
|
||||||
stPropertyAddress.mSelector = kAudioDeviceProcessorOverload;
|
|
||||||
stPropertyAddress.mElement = kAudioObjectPropertyElementMaster;
|
stPropertyAddress.mElement = kAudioObjectPropertyElementMaster;
|
||||||
stPropertyAddress.mScope = kAudioObjectPropertyScopeGlobal;
|
stPropertyAddress.mScope = kAudioObjectPropertyScopeGlobal;
|
||||||
|
|
||||||
|
stPropertyAddress.mSelector = kAudioDeviceProcessorOverload;
|
||||||
|
|
||||||
AudioObjectAddPropertyListener ( audioInputDevice[lCurDev],
|
AudioObjectAddPropertyListener ( audioInputDevice[lCurDev],
|
||||||
&stPropertyAddress,
|
&stPropertyAddress,
|
||||||
deviceNotification,
|
deviceNotification,
|
||||||
this );
|
this );
|
||||||
|
|
||||||
|
stPropertyAddress.mSelector = kAudioDevicePropertyDeviceHasChanged;
|
||||||
|
|
||||||
|
AudioObjectAddPropertyListener ( audioInputDevice[lCurDev],
|
||||||
|
&stPropertyAddress,
|
||||||
|
deviceNotification,
|
||||||
|
this );
|
||||||
|
|
||||||
|
AudioObjectAddPropertyListener ( audioOutputDevice[lCurDev],
|
||||||
|
&stPropertyAddress,
|
||||||
|
deviceNotification,
|
||||||
|
this );
|
||||||
|
|
||||||
// register the callback function for input and output
|
// register the callback function for input and output
|
||||||
AudioDeviceCreateIOProcID ( audioInputDevice[lCurDev],
|
AudioDeviceCreateIOProcID ( audioInputDevice[lCurDev],
|
||||||
callbackIO,
|
callbackIO,
|
||||||
|
@ -574,10 +587,23 @@ void CSound::Stop()
|
||||||
// unregister the callback function for xruns
|
// unregister the callback function for xruns
|
||||||
AudioObjectPropertyAddress stPropertyAddress;
|
AudioObjectPropertyAddress stPropertyAddress;
|
||||||
|
|
||||||
stPropertyAddress.mSelector = kAudioDeviceProcessorOverload;
|
|
||||||
stPropertyAddress.mElement = kAudioObjectPropertyElementMaster;
|
stPropertyAddress.mElement = kAudioObjectPropertyElementMaster;
|
||||||
stPropertyAddress.mScope = kAudioObjectPropertyScopeGlobal;
|
stPropertyAddress.mScope = kAudioObjectPropertyScopeGlobal;
|
||||||
|
|
||||||
|
stPropertyAddress.mSelector = kAudioDevicePropertyDeviceHasChanged;
|
||||||
|
|
||||||
|
AudioObjectRemovePropertyListener( audioOutputDevice[lCurDev],
|
||||||
|
&stPropertyAddress,
|
||||||
|
deviceNotification,
|
||||||
|
this );
|
||||||
|
|
||||||
|
AudioObjectRemovePropertyListener( audioInputDevice[lCurDev],
|
||||||
|
&stPropertyAddress,
|
||||||
|
deviceNotification,
|
||||||
|
this );
|
||||||
|
|
||||||
|
stPropertyAddress.mSelector = kAudioDeviceProcessorOverload;
|
||||||
|
|
||||||
AudioObjectRemovePropertyListener( audioInputDevice[lCurDev],
|
AudioObjectRemovePropertyListener( audioInputDevice[lCurDev],
|
||||||
&stPropertyAddress,
|
&stPropertyAddress,
|
||||||
deviceNotification,
|
deviceNotification,
|
||||||
|
@ -679,13 +705,18 @@ UInt32 CSound::SetBufferSize ( AudioDeviceID& audioDeviceID,
|
||||||
|
|
||||||
OSStatus CSound::deviceNotification ( AudioDeviceID,
|
OSStatus CSound::deviceNotification ( AudioDeviceID,
|
||||||
UInt32,
|
UInt32,
|
||||||
const AudioObjectPropertyAddress* /* inAddresses */,
|
const AudioObjectPropertyAddress* inAddresses,
|
||||||
void* /* inRefCon */ )
|
void* inRefCon )
|
||||||
{
|
{
|
||||||
// TODO: Do we need this anymore? If not, we can completely remove this function...
|
|
||||||
/*
|
|
||||||
CSound* pSound = static_cast<CSound*> ( inRefCon );
|
CSound* pSound = static_cast<CSound*> ( inRefCon );
|
||||||
|
|
||||||
|
if ( inAddresses->mSelector == kAudioDevicePropertyDeviceHasChanged )
|
||||||
|
{
|
||||||
|
// if any property of the device has changed, to a full reload
|
||||||
|
pSound->EmitReinitRequestSignal ( RS_RELOAD_RESTART_AND_INIT );
|
||||||
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
if ( inAddresses->mSelector == kAudioDeviceProcessorOverload )
|
if ( inAddresses->mSelector == kAudioDeviceProcessorOverload )
|
||||||
{
|
{
|
||||||
// xrun handling (it is important to act on xruns under CoreAudio
|
// xrun handling (it is important to act on xruns under CoreAudio
|
||||||
|
|
Loading…
Reference in a new issue