aboutsummaryrefslogtreecommitdiffstats
path: root/alc/backends/alsa.cpp
diff options
context:
space:
mode:
authorChris Robinson <[email protected]>2019-10-07 23:22:06 -0700
committerChris Robinson <[email protected]>2019-10-07 23:22:06 -0700
commit52a003e9bb7c870f26436b38e62edc96385805dc (patch)
tree7625ddfd05dc06c62f8870c2f24cd22bdf5ddd68 /alc/backends/alsa.cpp
parentf0fa6c6baf673a35337d2f2cb5548dd1e33c11e7 (diff)
Avoid raw lock/unlock calls
Diffstat (limited to 'alc/backends/alsa.cpp')
-rw-r--r--alc/backends/alsa.cpp12
1 files changed, 4 insertions, 8 deletions
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<AlsaPlayback> _{*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<AlsaPlayback> _{*this};
al::byte *WritePtr{mBuffer.data()};
avail = snd_pcm_bytes_to_frames(mPcmHandle, static_cast<ssize_t>(mBuffer.size()));
aluMixData(mDevice, WritePtr, static_cast<ALuint>(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<AlsaPlayback> _{*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<snd_pcm_sframes_t>(0, delay)};
ret.Latency /= mDevice->Frequency;
- unlock();
return ret;
}
@@ -1188,7 +1185,7 @@ ClockLatency AlsaCapture::getClockLatency()
{
ClockLatency ret;
- lock();
+ std::lock_guard<AlsaCapture> _{*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<snd_pcm_sframes_t>(0, delay)};
ret.Latency /= mDevice->Frequency;
- unlock();
return ret;
}