Core Audio output: Properly apply or remove default device change listener when switching preferences between the 'System Default Device' setting and manually setting the device to the current default
parent
8435416cd7
commit
8e895c88c0
|
@ -127,9 +127,6 @@ default_device_changed(AudioObjectID inObjectID, UInt32 inNumberAddresses, const
|
||||||
}
|
}
|
||||||
|
|
||||||
if (audioQueue) {
|
if (audioQueue) {
|
||||||
if (outputDeviceID == deviceID)
|
|
||||||
return noErr;
|
|
||||||
|
|
||||||
AudioObjectPropertyAddress defaultDeviceAddress = theAddress;
|
AudioObjectPropertyAddress defaultDeviceAddress = theAddress;
|
||||||
|
|
||||||
if (listenerapplied && !defaultDevice) {
|
if (listenerapplied && !defaultDevice) {
|
||||||
|
@ -137,6 +134,7 @@ default_device_changed(AudioObjectID inObjectID, UInt32 inNumberAddresses, const
|
||||||
listenerapplied = NO;
|
listenerapplied = NO;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (outputDeviceID != deviceID) {
|
||||||
printf("DEVICE: %i\n", deviceID);
|
printf("DEVICE: %i\n", deviceID);
|
||||||
outputDeviceID = deviceID;
|
outputDeviceID = deviceID;
|
||||||
|
|
||||||
|
@ -162,6 +160,7 @@ default_device_changed(AudioObjectID inObjectID, UInt32 inNumberAddresses, const
|
||||||
CFRelease(theDeviceUID);
|
CFRelease(theDeviceUID);
|
||||||
if (running)
|
if (running)
|
||||||
[self start];
|
[self start];
|
||||||
|
}
|
||||||
|
|
||||||
if (!listenerapplied && defaultDevice) {
|
if (!listenerapplied && defaultDevice) {
|
||||||
AudioObjectAddPropertyListener(kAudioObjectSystemObject, &defaultDeviceAddress, default_device_changed, (__bridge void * _Nullable)(self));
|
AudioObjectAddPropertyListener(kAudioObjectSystemObject, &defaultDeviceAddress, default_device_changed, (__bridge void * _Nullable)(self));
|
||||||
|
|
Loading…
Reference in New Issue