aboutsummaryrefslogtreecommitdiffstats
path: root/alc/backends/coreaudio.cpp
diff options
context:
space:
mode:
authorChris Robinson <[email protected]>2023-05-31 22:11:15 -0700
committerChris Robinson <[email protected]>2023-06-01 06:33:41 -0700
commitedc20c87d3cd37608e8fa50556d718cd32755f3d (patch)
treeca712a140ff79a21ba2c49d5c13b686c9679a143 /alc/backends/coreaudio.cpp
parentd684c7617f2e13572b1c3f9a933a23e1f0e32d49 (diff)
Specify the device type for the event callback
Diffstat (limited to 'alc/backends/coreaudio.cpp')
-rw-r--r--alc/backends/coreaudio.cpp28
1 files changed, 14 insertions, 14 deletions
diff --git a/alc/backends/coreaudio.cpp b/alc/backends/coreaudio.cpp
index a9419e3d..1e8423b7 100644
--- a/alc/backends/coreaudio.cpp
+++ b/alc/backends/coreaudio.cpp
@@ -273,39 +273,39 @@ void EnumerateDevices(std::vector<DeviceEntry> &list, bool isCapture)
newdevs.swap(list);
}
-struct DeviceHelper
-{
-public:
+struct DeviceHelper {
DeviceHelper()
{
- AudioObjectPropertyAddress addr = {kAudioHardwarePropertyDefaultOutputDevice,
- kAudioObjectPropertyScopeGlobal, kAudioObjectPropertyElementMain};
+ AudioObjectPropertyAddress addr{kAudioHardwarePropertyDefaultOutputDevice,
+ kAudioObjectPropertyScopeGlobal, kAudioObjectPropertyElementMain};
OSStatus status = AudioObjectAddPropertyListener(kAudioObjectSystemObject, &addr, DeviceListenerProc, nil);
if (status != noErr)
ERR("AudioObjectAddPropertyListener fail: %d", status);
}
~DeviceHelper()
{
- AudioObjectPropertyAddress addr = {kAudioHardwarePropertyDefaultOutputDevice,
- kAudioObjectPropertyScopeGlobal, kAudioObjectPropertyElementMain};
+ AudioObjectPropertyAddress addr{kAudioHardwarePropertyDefaultOutputDevice,
+ kAudioObjectPropertyScopeGlobal, kAudioObjectPropertyElementMain};
OSStatus status = AudioObjectRemovePropertyListener(kAudioObjectSystemObject, &addr, DeviceListenerProc, nil);
if (status != noErr)
ERR("AudioObjectRemovePropertyListener fail: %d", status);
}
- static OSStatus DeviceListenerProc(AudioObjectID /*inObjectID*/,
- UInt32 inNumberAddresses,
- const AudioObjectPropertyAddress *inAddresses,
- void* /*inClientData*/)
+ static OSStatus DeviceListenerProc(AudioObjectID /*inObjectID*/, UInt32 inNumberAddresses,
+ const AudioObjectPropertyAddress *inAddresses, void* /*inClientData*/)
{
- for (UInt32 i = 0; i < inNumberAddresses; ++i)
+ for(UInt32 i = 0; i < inNumberAddresses; ++i)
{
- switch (inAddresses[i].mSelector)
+ switch(inAddresses[i].mSelector)
{
case kAudioHardwarePropertyDefaultOutputDevice:
case kAudioHardwarePropertyDefaultSystemOutputDevice:
+ alc::Event(alc::EventType::DefaultDeviceChanged, alc::DeviceType::Playback,
+ "Default playback device changed: "+std::to_string(inAddresses[i].mSelector));
+ break;
case kAudioHardwarePropertyDefaultInputDevice:
- alc::Event(alc::EventType::DefaultDeviceChanged, "Default device changed: "+std::to_string(inAddresses[i].mSelector));
+ alc::Event(alc::EventType::DefaultDeviceChanged, alc::DeviceType::Capture,
+ "Default capture device changed: "+std::to_string(inAddresses[i].mSelector));
break;
}
}