aboutsummaryrefslogtreecommitdiffstats
path: root/alc
diff options
context:
space:
mode:
authorChris Robinson <[email protected]>2021-03-09 06:01:27 -0800
committerChris Robinson <[email protected]>2021-03-09 06:01:27 -0800
commit5e481e7654c680aa45fd8ec8a22331a9366d7f57 (patch)
tree673d223580634fcbae502e614f18820c22b0ad11 /alc
parente824c808a0662361c9acdd9f97390d2412f21981 (diff)
Don't verify and hold a device reference in alcRenderSamplesSOFT
NULL devices are still checked, but invalid non-NULL device handles will invoke undefined behavior, as will attempting to close the device while the function is being executed (modifying the device state while the function is being called was inadvertently already UB, and will now remain so). This change is solely so alcRenderSamplesSOFT can be used in a buffer callback, and other places that need functions to be real-time safe. The verification requires locking to access the device list, which isn't allowed in a real-time callback.
Diffstat (limited to 'alc')
-rw-r--r--alc/alc.cpp9
1 files changed, 4 insertions, 5 deletions
diff --git a/alc/alc.cpp b/alc/alc.cpp
index a41aa944..f18864ea 100644
--- a/alc/alc.cpp
+++ b/alc/alc.cpp
@@ -4051,13 +4051,12 @@ END_API_FUNC
FORCE_ALIGN ALC_API void ALC_APIENTRY alcRenderSamplesSOFT(ALCdevice *device, ALCvoid *buffer, ALCsizei samples)
START_API_FUNC
{
- DeviceRef dev{VerifyDevice(device)};
- if(!dev || dev->Type != DeviceType::Loopback)
- alcSetError(dev.get(), ALC_INVALID_DEVICE);
+ if(!device || device->Type != DeviceType::Loopback)
+ alcSetError(device, ALC_INVALID_DEVICE);
else if(samples < 0 || (samples > 0 && buffer == nullptr))
- alcSetError(dev.get(), ALC_INVALID_VALUE);
+ alcSetError(device, ALC_INVALID_VALUE);
else
- dev->renderSamples(buffer, static_cast<uint>(samples), dev->channelsFromFmt());
+ device->renderSamples(buffer, static_cast<uint>(samples), device->channelsFromFmt());
}
END_API_FUNC