From 52a003e9bb7c870f26436b38e62edc96385805dc Mon Sep 17 00:00:00 2001 From: Chris Robinson Date: Mon, 7 Oct 2019 23:22:06 -0700 Subject: Avoid raw lock/unlock calls --- alc/backends/alsa.cpp | 12 ++++-------- 1 file changed, 4 insertions(+), 8 deletions(-) (limited to 'alc/backends/alsa.cpp') diff --git a/alc/backends/alsa.cpp b/alc/backends/alsa.cpp index 2e157602..a9eb6d5f 100644 --- a/alc/backends/alsa.cpp +++ b/alc/backends/alsa.cpp @@ -471,7 +471,7 @@ int AlsaPlayback::mixerProc() avail -= avail%update_size; // it is possible that contiguous areas are smaller, thus we use a loop - lock(); + std::lock_guard _{*this}; while(avail > 0) { snd_pcm_uframes_t frames{avail}; @@ -498,7 +498,6 @@ int AlsaPlayback::mixerProc() avail -= frames; } - unlock(); } return 0; @@ -551,7 +550,7 @@ int AlsaPlayback::mixerNoMMapProc() continue; } - lock(); + std::lock_guard _{*this}; al::byte *WritePtr{mBuffer.data()}; avail = snd_pcm_bytes_to_frames(mPcmHandle, static_cast(mBuffer.size())); aluMixData(mDevice, WritePtr, static_cast(avail)); @@ -586,7 +585,6 @@ int AlsaPlayback::mixerNoMMapProc() if(ret < 0) break; } } - unlock(); } return 0; @@ -847,7 +845,7 @@ ClockLatency AlsaPlayback::getClockLatency() { ClockLatency ret; - lock(); + std::lock_guard _{*this}; ret.ClockTime = GetDeviceClockTime(mDevice); snd_pcm_sframes_t delay{}; int err{snd_pcm_delay(mPcmHandle, &delay)}; @@ -858,7 +856,6 @@ ClockLatency AlsaPlayback::getClockLatency() } ret.Latency = std::chrono::seconds{std::max(0, delay)}; ret.Latency /= mDevice->Frequency; - unlock(); return ret; } @@ -1188,7 +1185,7 @@ ClockLatency AlsaCapture::getClockLatency() { ClockLatency ret; - lock(); + std::lock_guard _{*this}; ret.ClockTime = GetDeviceClockTime(mDevice); snd_pcm_sframes_t delay{}; int err{snd_pcm_delay(mPcmHandle, &delay)}; @@ -1199,7 +1196,6 @@ ClockLatency AlsaCapture::getClockLatency() } ret.Latency = std::chrono::seconds{std::max(0, delay)}; ret.Latency /= mDevice->Frequency; - unlock(); return ret; } -- cgit v1.2.3