recording: use scoped_lock

This commit is contained in:
Megamouse 2023-11-29 21:54:07 +01:00
parent bebac4773a
commit 4520f7646f
3 changed files with 6 additions and 13 deletions

View File

@ -176,8 +176,7 @@ public:
{
cellRec.notice("Stopping video sink. flush=%d", flush);
std::lock_guard lock_video(m_video_mtx);
std::lock_guard lock_audio(m_audio_mtx);
std::scoped_lock lock(m_video_mtx, m_audio_mtx);
m_flush = flush;
m_paused = false;
m_frames_to_encode.clear();
@ -189,8 +188,7 @@ public:
{
cellRec.notice("Pausing video sink. flush=%d", flush);
std::lock_guard lock_video(m_video_mtx);
std::lock_guard lock_audio(m_audio_mtx);
std::scoped_lock lock(m_video_mtx, m_audio_mtx);
m_flush = flush;
m_paused = true;
}
@ -199,8 +197,7 @@ public:
{
cellRec.notice("Resuming video sink");
std::lock_guard lock_video(m_video_mtx);
std::lock_guard lock_audio(m_audio_mtx);
std::scoped_lock lock(m_video_mtx, m_audio_mtx);
m_flush = false;
m_paused = false;
}

View File

@ -781,8 +781,7 @@ namespace utils
m_thread.reset();
}
std::lock_guard lock_video(m_video_mtx);
std::lock_guard lock_audio(m_audio_mtx);
std::scoped_lock lock(m_video_mtx, m_audio_mtx);
m_frames_to_encode.clear();
m_samples_to_encode.clear();
has_error = false;

View File

@ -45,8 +45,7 @@ namespace utils
return false;
}
std::lock_guard lock_video(m_video_mutex);
std::lock_guard lock_audio(m_audio_mutex);
std::scoped_lock lock(m_video_mutex, m_audio_mutex);
if (m_video_sink)
{
@ -80,9 +79,7 @@ namespace utils
void video_provider::set_pause_time_us(usz pause_time_us)
{
std::lock_guard lock_video(m_video_mutex);
std::lock_guard lock_audio(m_audio_mutex);
std::scoped_lock lock(m_video_mutex, m_audio_mutex);
m_pause_time_us = pause_time_us;
}