aboutsummaryrefslogtreecommitdiffstats
path: root/alc/alc.cpp
diff options
context:
space:
mode:
authorChris Robinson <[email protected]>2021-04-26 20:25:24 -0700
committerChris Robinson <[email protected]>2021-04-26 20:25:24 -0700
commit26c8c50c2605e377f74d7a73bae3bbbf4f7bad61 (patch)
tree1d66be8cc28a32e965de87e5b51012c26b6b2b95 /alc/alc.cpp
parent22a8ebff8094785ec53aadef8489dc60f6939d55 (diff)
Partially implement an extension to hold sources on disconnect
Rather than stopping voices/sources when the device becomes disconnected, the context can be set to leave them alone. As a consequence, their state will remain as playing and they'll keep their last known sample offset indefinately. For applications mindful of this behavior, it will allow resetting or reopening the device to reconnect and automatically resume where it left off.
Diffstat (limited to 'alc/alc.cpp')
-rw-r--r--alc/alc.cpp5
1 files changed, 5 insertions, 0 deletions
diff --git a/alc/alc.cpp b/alc/alc.cpp
index d06ca067..47b77758 100644
--- a/alc/alc.cpp
+++ b/alc/alc.cpp
@@ -834,6 +834,8 @@ constexpr struct {
DECL(AL_FORMAT_UHJ4CHN8_SOFT),
DECL(AL_FORMAT_UHJ4CHN16_SOFT),
DECL(AL_FORMAT_UHJ4CHN_FLOAT32_SOFT),
+
+ DECL(AL_STOP_SOURCES_ON_DISCONNECT_SOFT),
};
#undef DECL
@@ -889,6 +891,7 @@ constexpr ALchar alExtList[] =
"AL_SOFT_events "
"AL_SOFTX_filter_gain_ex "
"AL_SOFT_gain_clamp_ex "
+ "AL_SOFTX_hold_on_disconnect "
"AL_SOFT_loop_points "
"AL_SOFTX_map_buffer "
"AL_SOFT_MSADPCM "
@@ -2269,6 +2272,8 @@ static bool ResetDeviceParams(ALCdevice *device, const int *attrList)
for(ContextBase *ctxbase : *device->mContexts.load(std::memory_order_acquire))
{
auto *ctx = static_cast<ALCcontext*>(ctxbase);
+ if(!ctx->mStopVoicesOnDisconnect.load(std::memory_order_acquire))
+ continue;
/* Clear any pending voice changes and reallocate voices to get a
* clean restart.