diff options
author | Chris Robinson <[email protected]> | 2021-03-09 07:09:27 -0800 |
---|---|---|
committer | Chris Robinson <[email protected]> | 2021-03-09 07:09:27 -0800 |
commit | d750983a58dfc3ea95976dcc5e8d9b8ed19a1a6a (patch) | |
tree | 025aeb88c44603b8c22ab0a64890b9c843d34f3a | |
parent | 5e481e7654c680aa45fd8ec8a22331a9366d7f57 (diff) |
Prevent querying the capture device name from a playback device
And vice-versa.
-rw-r--r-- | alc/alc.cpp | 19 |
1 files changed, 16 insertions, 3 deletions
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<std::mutex> _{dev->StateLock}; - value = dev->DeviceName.c_str(); + if(dev->Type != DeviceType::Playback) + alcSetError(dev.get(), ALC_INVALID_ENUM); + else + { + std::lock_guard<std::mutex> _{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<std::mutex> _{dev->StateLock}; + value = dev->DeviceName.c_str(); + } + } else { ProbeCaptureDeviceList(); |