diff options
author | Chris Robinson <[email protected]> | 2021-03-08 22:29:40 -0800 |
---|---|---|
committer | Chris Robinson <[email protected]> | 2021-03-08 22:29:40 -0800 |
commit | 730c964029f7b649510490d8766aba801f576492 (patch) | |
tree | f9415b25e80d49ac40a02d6f94a96cfa355ca8b0 /alc/backends/wave.cpp | |
parent | 0f7ed495e199f7158295c6a61ea0e0080a5b4339 (diff) |
Allow calling BackendBase::open multiple times on playback devices
It will not be called while the device is running. If the first call succeeds,
a subsequent call that happens to fail must leave the existing device state as
it was so it can be resumed.
This is a rough first pass. It will fail when trying to re-open the same device
which can only be opened once (for instance, with direct hardware access, on
hardware that doesn't do its own mixing). Some backends won't guarantee the new
device is usable until the reset() or start() call.
Diffstat (limited to 'alc/backends/wave.cpp')
-rw-r--r-- | alc/backends/wave.cpp | 9 |
1 files changed, 6 insertions, 3 deletions
diff --git a/alc/backends/wave.cpp b/alc/backends/wave.cpp index 4f738230..e80fb3ae 100644 --- a/alc/backends/wave.cpp +++ b/alc/backends/wave.cpp @@ -132,8 +132,8 @@ int WaveBackend::mixerProc() int64_t done{0}; auto start = std::chrono::steady_clock::now(); - while(!mKillNow.load(std::memory_order_acquire) && - mDevice->Connected.load(std::memory_order_acquire)) + while(!mKillNow.load(std::memory_order_acquire) + && mDevice->Connected.load(std::memory_order_acquire)) { auto now = std::chrono::steady_clock::now(); @@ -214,9 +214,12 @@ void WaveBackend::open(const char *name) throw al::backend_exception{al::backend_error::NoDevice, "Device name \"%s\" not found", name}; + /* There's only one "device", so if it's already open, we're done. */ + if(mFile) return; + #ifdef _WIN32 { - std::wstring wname = utf8_to_wstr(fname); + std::wstring wname{utf8_to_wstr(fname)}; mFile = _wfopen(wname.c_str(), L"wb"); } #else |