aboutsummaryrefslogtreecommitdiffstats
path: root/alc/backends/coreaudio.cpp
diff options
context:
space:
mode:
authorChris Robinson <[email protected]>2023-04-24 11:05:21 -0700
committerChris Robinson <[email protected]>2023-04-24 11:05:21 -0700
commit75f3e34951f165a523825472dc22bfc557277a00 (patch)
treefb853093b5fa236ae48ca4fd6b09a14563d235db /alc/backends/coreaudio.cpp
parentd9fed51aa6391debc31dbbca550f055c980afe70 (diff)
Try to detect headphones with CoreAudio
Diffstat (limited to 'alc/backends/coreaudio.cpp')
-rw-r--r--alc/backends/coreaudio.cpp18
1 files changed, 18 insertions, 0 deletions
diff --git a/alc/backends/coreaudio.cpp b/alc/backends/coreaudio.cpp
index 8b0e75fd..86f58637 100644
--- a/alc/backends/coreaudio.cpp
+++ b/alc/backends/coreaudio.cpp
@@ -388,6 +388,24 @@ void CoreAudioPlayback::open(const char *name)
if(!devname.empty()) mDevice->DeviceName = std::move(devname);
else mDevice->DeviceName = "Unknown Device Name";
}
+
+ if(audioDevice != kAudioDeviceUnknown)
+ {
+ UInt32 type{};
+ err = GetDevProperty(audioDevice, kAudioDevicePropertyTransportType, false,
+ kAudioObjectPropertyElementMaster, sizeof(type), &type);
+ if(err != noErr)
+ ERR("Failed to get audio device type: %u\n", err);
+ else
+ {
+ static constexpr UInt32 HeadphoneType{('h'<<24u) | ('d'<<16u) | ('p'<<8u) | 'n'};
+ TRACE("Got device type '%c%c%c%c'\n", static_cast<char>((type>>24)&0xff),
+ static_cast<char>((type>>16)&0xff), static_cast<char>((type>>8)&0xff),
+ static_cast<char>(type&0xff));
+ mDevice->Flags.set(DirectEar, (type == HeadphoneType));
+ }
+ }
+
#else
mDevice->DeviceName = name;
#endif