From d750983a58dfc3ea95976dcc5e8d9b8ed19a1a6a Mon Sep 17 00:00:00 2001 From: Chris Robinson Date: Tue, 9 Mar 2021 07:09:27 -0800 Subject: Prevent querying the capture device name from a playback device And vice-versa. --- alc/alc.cpp | 19 ++++++++++++++++--- 1 file changed, 16 insertions(+), 3 deletions(-) (limited to 'alc') diff --git a/alc/alc.cpp b/alc/alc.cpp index f18864ea..f3fcb00a 100644 --- a/alc/alc.cpp +++ b/alc/alc.cpp @@ -2697,8 +2697,13 @@ START_API_FUNC case ALC_ALL_DEVICES_SPECIFIER: if(DeviceRef dev{VerifyDevice(Device)}) { - std::lock_guard _{dev->StateLock}; - value = dev->DeviceName.c_str(); + if(dev->Type != DeviceType::Playback) + alcSetError(dev.get(), ALC_INVALID_ENUM); + else + { + std::lock_guard _{dev->StateLock}; + value = dev->DeviceName.c_str(); + } } else { @@ -2709,7 +2714,15 @@ START_API_FUNC case ALC_CAPTURE_DEVICE_SPECIFIER: if(DeviceRef dev{VerifyDevice(Device)}) - value = dev->DeviceName.c_str(); + { + if(dev->Type != DeviceType::Capture) + alcSetError(dev.get(), ALC_INVALID_ENUM); + else + { + std::lock_guard _{dev->StateLock}; + value = dev->DeviceName.c_str(); + } + } else { ProbeCaptureDeviceList(); -- cgit v1.2.3