aboutsummaryrefslogtreecommitdiffstats
path: root/alc/backends
diff options
context:
space:
mode:
authorChris Robinson <[email protected]>2020-03-29 23:57:37 -0700
committerChris Robinson <[email protected]>2020-03-29 23:57:37 -0700
commit9b237790b274a9191e0835e84c28de6cefbc2d34 (patch)
tree83c696bb61d947e5c4ab3c79adf2308d918ef29c /alc/backends
parentd70912c0345e402e8aed9835ce450330cd6a7d36 (diff)
Remove the mutex from the backend base
Diffstat (limited to 'alc/backends')
-rw-r--r--alc/backends/alsa.cpp9
-rw-r--r--alc/backends/base.h2
-rw-r--r--alc/backends/jack.cpp6
-rw-r--r--alc/backends/opensl.cpp6
-rw-r--r--alc/backends/wasapi.cpp6
5 files changed, 17 insertions, 12 deletions
diff --git a/alc/backends/alsa.cpp b/alc/backends/alsa.cpp
index 3298f157..bfeec1b8 100644
--- a/alc/backends/alsa.cpp
+++ b/alc/backends/alsa.cpp
@@ -425,6 +425,8 @@ struct AlsaPlayback final : public BackendBase {
snd_pcm_t *mPcmHandle{nullptr};
+ std::mutex mMutex;
+
al::vector<al::byte> mBuffer;
std::atomic<bool> mKillNow{true};
@@ -493,7 +495,7 @@ int AlsaPlayback::mixerProc()
avail -= avail%update_size;
// it is possible that contiguous areas are smaller, thus we use a loop
- std::lock_guard<std::recursive_mutex> _{mMutex};
+ std::lock_guard<std::mutex> _{mMutex};
while(avail > 0)
{
snd_pcm_uframes_t frames{avail};
@@ -575,7 +577,7 @@ int AlsaPlayback::mixerNoMMapProc()
al::byte *WritePtr{mBuffer.data()};
avail = snd_pcm_bytes_to_frames(mPcmHandle, static_cast<ssize_t>(mBuffer.size()));
- std::lock_guard<std::recursive_mutex> _{mMutex};
+ std::lock_guard<std::mutex> _{mMutex};
aluMixData(mDevice, WritePtr, static_cast<ALuint>(avail), frame_step);
while(avail > 0)
{
@@ -848,7 +850,7 @@ ClockLatency AlsaPlayback::getClockLatency()
{
ClockLatency ret;
- std::lock_guard<std::recursive_mutex> _{mMutex};
+ std::lock_guard<std::mutex> _{mMutex};
ret.ClockTime = GetDeviceClockTime(mDevice);
snd_pcm_sframes_t delay{};
int err{snd_pcm_delay(mPcmHandle, &delay)};
@@ -1168,7 +1170,6 @@ ClockLatency AlsaCapture::getClockLatency()
{
ClockLatency ret;
- std::lock_guard<std::recursive_mutex> _{mMutex};
ret.ClockTime = GetDeviceClockTime(mDevice);
snd_pcm_sframes_t delay{};
int err{snd_pcm_delay(mPcmHandle, &delay)};
diff --git a/alc/backends/base.h b/alc/backends/base.h
index 6887a813..310191b1 100644
--- a/alc/backends/base.h
+++ b/alc/backends/base.h
@@ -45,8 +45,6 @@ struct BackendBase {
ALCdevice *mDevice;
- std::recursive_mutex mMutex;
-
BackendBase(ALCdevice *device) noexcept;
virtual ~BackendBase();
};
diff --git a/alc/backends/jack.cpp b/alc/backends/jack.cpp
index 7e91f28c..0cad064d 100644
--- a/alc/backends/jack.cpp
+++ b/alc/backends/jack.cpp
@@ -169,6 +169,8 @@ struct JackPlayback final : public BackendBase {
jack_client_t *mClient{nullptr};
jack_port_t *mPort[MAX_OUTPUT_CHANNELS]{};
+ std::mutex mMutex;
+
std::atomic<bool> mPlaying{false};
RingBufferPtr mRing;
al::semaphore mSem;
@@ -282,7 +284,7 @@ int JackPlayback::mixerProc()
ALuint len1{minu(static_cast<ALuint>(data.first.len), todo)};
ALuint len2{minu(static_cast<ALuint>(data.second.len), todo-len1)};
- std::lock_guard<std::recursive_mutex> _{mMutex};
+ std::lock_guard<std::mutex> _{mMutex};
aluMixData(mDevice, data.first.buf, len1, frame_step);
if(len2 > 0)
aluMixData(mDevice, data.second.buf, len2, frame_step);
@@ -458,7 +460,7 @@ ClockLatency JackPlayback::getClockLatency()
{
ClockLatency ret;
- std::lock_guard<std::recursive_mutex> _{mMutex};
+ std::lock_guard<std::mutex> _{mMutex};
ret.ClockTime = GetDeviceClockTime(mDevice);
ret.Latency = std::chrono::seconds{mRing->readSpace()};
ret.Latency /= mDevice->Frequency;
diff --git a/alc/backends/opensl.cpp b/alc/backends/opensl.cpp
index 635d6c0d..b1355061 100644
--- a/alc/backends/opensl.cpp
+++ b/alc/backends/opensl.cpp
@@ -171,6 +171,8 @@ struct OpenSLPlayback final : public BackendBase {
RingBufferPtr mRing{nullptr};
al::semaphore mSem;
+ std::mutex mMutex;
+
ALuint mFrameSize{0};
std::atomic<bool> mKillNow{true};
@@ -260,7 +262,7 @@ int OpenSLPlayback::mixerProc()
}
}
- std::unique_lock<std::recursive_mutex> dlock{mMutex};
+ std::unique_lock<std::mutex> dlock{mMutex};
auto data = mRing->getWriteVector();
aluMixData(mDevice, data.first.buf,
static_cast<ALuint>(data.first.len*mDevice->UpdateSize), frame_step);
@@ -610,7 +612,7 @@ ClockLatency OpenSLPlayback::getClockLatency()
{
ClockLatency ret;
- std::lock_guard<std::recursive_mutex> _{mMutex};
+ std::lock_guard<std::mutex> _{mMutex};
ret.ClockTime = GetDeviceClockTime(mDevice);
ret.Latency = std::chrono::seconds{mRing->readSpace() * mDevice->UpdateSize};
ret.Latency /= mDevice->Frequency;
diff --git a/alc/backends/wasapi.cpp b/alc/backends/wasapi.cpp
index 0f58d426..fc48d492 100644
--- a/alc/backends/wasapi.cpp
+++ b/alc/backends/wasapi.cpp
@@ -658,6 +658,8 @@ struct WasapiPlayback final : public BackendBase, WasapiProxy {
UINT32 mFrameStep{0u};
std::atomic<UINT32> mPadding{0u};
+ std::mutex mMutex;
+
std::atomic<bool> mKillNow{true};
std::thread mThread;
@@ -717,7 +719,7 @@ FORCE_ALIGN int WasapiPlayback::mixerProc()
if(SUCCEEDED(hr))
{
{
- std::lock_guard<std::recursive_mutex> _{mMutex};
+ std::lock_guard<std::mutex> _{mMutex};
aluMixData(mDevice, buffer, len, mFrameStep);
mPadding.store(written + len, std::memory_order_relaxed);
}
@@ -1167,7 +1169,7 @@ ClockLatency WasapiPlayback::getClockLatency()
{
ClockLatency ret;
- std::lock_guard<std::recursive_mutex> _{mMutex};
+ std::lock_guard<std::mutex> _{mMutex};
ret.ClockTime = GetDeviceClockTime(mDevice);
ret.Latency = std::chrono::seconds{mPadding.load(std::memory_order_relaxed)};
ret.Latency /= mDevice->Frequency;