thread/Mutex: remove ScopeLock, use std::lock_guard directly
This commit is contained in:
@@ -440,7 +440,7 @@ public:
|
||||
|
||||
gcc_pure
|
||||
bool LockIsChunkConsumed(const MusicChunk &chunk) {
|
||||
const ScopeLock protect(mutex);
|
||||
const std::lock_guard<Mutex> protect(mutex);
|
||||
return IsChunkConsumed(chunk);
|
||||
}
|
||||
|
||||
|
||||
@@ -109,12 +109,12 @@ MultipleOutputs::EnableDisable()
|
||||
/* parallel execution */
|
||||
|
||||
for (auto ao : outputs) {
|
||||
const ScopeLock lock(ao->mutex);
|
||||
const std::lock_guard<Mutex> lock(ao->mutex);
|
||||
ao->EnableDisableAsync();
|
||||
}
|
||||
|
||||
for (auto ao : outputs) {
|
||||
const ScopeLock lock(ao->mutex);
|
||||
const std::lock_guard<Mutex> lock(ao->mutex);
|
||||
ao->WaitForCommand();
|
||||
}
|
||||
}
|
||||
@@ -123,7 +123,7 @@ bool
|
||||
MultipleOutputs::AllFinished() const
|
||||
{
|
||||
for (auto ao : outputs) {
|
||||
const ScopeLock protect(ao->mutex);
|
||||
const std::lock_guard<Mutex> protect(ao->mutex);
|
||||
if (ao->IsOpen() && !ao->IsCommandFinished())
|
||||
return false;
|
||||
}
|
||||
@@ -215,7 +215,7 @@ MultipleOutputs::Open(const AudioFormat audio_format,
|
||||
std::exception_ptr first_error;
|
||||
|
||||
for (auto ao : outputs) {
|
||||
const ScopeLock lock(ao->mutex);
|
||||
const std::lock_guard<Mutex> lock(ao->mutex);
|
||||
|
||||
if (ao->IsEnabled())
|
||||
enabled = true;
|
||||
|
||||
@@ -65,7 +65,7 @@ AudioOutput::CommandWait(Command cmd)
|
||||
void
|
||||
AudioOutput::LockCommandWait(Command cmd)
|
||||
{
|
||||
const ScopeLock protect(mutex);
|
||||
const std::lock_guard<Mutex> protect(mutex);
|
||||
CommandWait(cmd);
|
||||
}
|
||||
|
||||
@@ -162,7 +162,7 @@ AudioOutput::LockUpdate(const AudioFormat audio_format,
|
||||
const MusicPipe &mp,
|
||||
bool force)
|
||||
{
|
||||
const ScopeLock protect(mutex);
|
||||
const std::lock_guard<Mutex> protect(mutex);
|
||||
|
||||
if (enabled && really_enabled) {
|
||||
if (force || !fail_timer.IsDefined() ||
|
||||
@@ -178,7 +178,7 @@ AudioOutput::LockUpdate(const AudioFormat audio_format,
|
||||
void
|
||||
AudioOutput::LockPlay()
|
||||
{
|
||||
const ScopeLock protect(mutex);
|
||||
const std::lock_guard<Mutex> protect(mutex);
|
||||
|
||||
assert(allow_play);
|
||||
|
||||
@@ -197,7 +197,7 @@ AudioOutput::LockPauseAsync()
|
||||
mixer_auto_close()) */
|
||||
mixer_auto_close(mixer);
|
||||
|
||||
const ScopeLock protect(mutex);
|
||||
const std::lock_guard<Mutex> protect(mutex);
|
||||
|
||||
assert(allow_play);
|
||||
if (IsOpen())
|
||||
@@ -207,7 +207,7 @@ AudioOutput::LockPauseAsync()
|
||||
void
|
||||
AudioOutput::LockDrainAsync()
|
||||
{
|
||||
const ScopeLock protect(mutex);
|
||||
const std::lock_guard<Mutex> protect(mutex);
|
||||
|
||||
assert(allow_play);
|
||||
if (IsOpen())
|
||||
@@ -217,7 +217,7 @@ AudioOutput::LockDrainAsync()
|
||||
void
|
||||
AudioOutput::LockCancelAsync()
|
||||
{
|
||||
const ScopeLock protect(mutex);
|
||||
const std::lock_guard<Mutex> protect(mutex);
|
||||
|
||||
if (IsOpen()) {
|
||||
allow_play = false;
|
||||
@@ -228,7 +228,7 @@ AudioOutput::LockCancelAsync()
|
||||
void
|
||||
AudioOutput::LockAllowPlay()
|
||||
{
|
||||
const ScopeLock protect(mutex);
|
||||
const std::lock_guard<Mutex> protect(mutex);
|
||||
|
||||
allow_play = true;
|
||||
if (IsOpen())
|
||||
@@ -249,7 +249,7 @@ AudioOutput::LockCloseWait()
|
||||
{
|
||||
assert(!open || !fail_timer.IsDefined());
|
||||
|
||||
const ScopeLock protect(mutex);
|
||||
const std::lock_guard<Mutex> protect(mutex);
|
||||
CloseWait();
|
||||
}
|
||||
|
||||
@@ -270,7 +270,7 @@ AudioOutput::BeginDestroy()
|
||||
mixer_auto_close(mixer);
|
||||
|
||||
if (thread.IsDefined()) {
|
||||
const ScopeLock protect(mutex);
|
||||
const std::lock_guard<Mutex> protect(mutex);
|
||||
CommandAsync(Command::KILL);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -43,7 +43,7 @@ audio_output_state_save(BufferedOutputStream &os,
|
||||
{
|
||||
for (unsigned i = 0, n = outputs.Size(); i != n; ++i) {
|
||||
const AudioOutput &ao = outputs.Get(i);
|
||||
const ScopeLock lock(ao.mutex);
|
||||
const std::lock_guard<Mutex> lock(ao.mutex);
|
||||
|
||||
os.Format(AUDIO_DEVICE_STATE "%d:%s\n",
|
||||
ao.IsEnabled(), ao.GetName());
|
||||
|
||||
@@ -397,7 +397,7 @@ AudioOutput::Task()
|
||||
|
||||
SetThreadTimerSlackUS(100);
|
||||
|
||||
const ScopeLock lock(mutex);
|
||||
const std::lock_guard<Mutex> lock(mutex);
|
||||
|
||||
while (true) {
|
||||
switch (command) {
|
||||
|
||||
@@ -92,7 +92,7 @@ RoarOutput::RoarOutput(const ConfigBlock &block)
|
||||
inline int
|
||||
RoarOutput::GetVolume() const
|
||||
{
|
||||
const ScopeLock protect(mutex);
|
||||
const std::lock_guard<Mutex> protect(mutex);
|
||||
|
||||
if (vss == nullptr || !alive)
|
||||
return -1;
|
||||
@@ -116,7 +116,7 @@ RoarOutput::SetVolume(unsigned volume)
|
||||
{
|
||||
assert(volume <= 100);
|
||||
|
||||
const ScopeLock protect(mutex);
|
||||
const std::lock_guard<Mutex> protect(mutex);
|
||||
if (vss == nullptr || !alive)
|
||||
throw std::runtime_error("closed");
|
||||
|
||||
@@ -177,7 +177,7 @@ roar_use_audio_format(struct roar_audio_info *info,
|
||||
inline void
|
||||
RoarOutput::Open(AudioFormat &audio_format)
|
||||
{
|
||||
const ScopeLock protect(mutex);
|
||||
const std::lock_guard<Mutex> protect(mutex);
|
||||
|
||||
if (roar_simple_connect(&con,
|
||||
host.empty() ? nullptr : host.c_str(),
|
||||
@@ -201,7 +201,7 @@ RoarOutput::Open(AudioFormat &audio_format)
|
||||
inline void
|
||||
RoarOutput::Close()
|
||||
{
|
||||
const ScopeLock protect(mutex);
|
||||
const std::lock_guard<Mutex> protect(mutex);
|
||||
|
||||
alive = false;
|
||||
|
||||
@@ -214,7 +214,7 @@ RoarOutput::Close()
|
||||
inline void
|
||||
RoarOutput::Cancel()
|
||||
{
|
||||
const ScopeLock protect(mutex);
|
||||
const std::lock_guard<Mutex> protect(mutex);
|
||||
|
||||
if (vss == nullptr)
|
||||
return;
|
||||
@@ -306,7 +306,7 @@ RoarOutput::SendTag(const Tag &tag)
|
||||
if (vss == nullptr)
|
||||
return;
|
||||
|
||||
const ScopeLock protect(mutex);
|
||||
const std::lock_guard<Mutex> protect(mutex);
|
||||
|
||||
size_t cnt = 0;
|
||||
struct roar_keyval vals[32];
|
||||
|
||||
@@ -56,7 +56,7 @@ HttpdClient::Close()
|
||||
void
|
||||
HttpdClient::LockClose()
|
||||
{
|
||||
const ScopeLock protect(httpd.mutex);
|
||||
const std::lock_guard<Mutex> protect(httpd.mutex);
|
||||
Close();
|
||||
}
|
||||
|
||||
@@ -272,7 +272,7 @@ HttpdClient::GetBytesTillMetaData() const
|
||||
inline bool
|
||||
HttpdClient::TryWrite()
|
||||
{
|
||||
const ScopeLock protect(httpd.mutex);
|
||||
const std::lock_guard<Mutex> protect(httpd.mutex);
|
||||
|
||||
assert(state == RESPONSE);
|
||||
|
||||
|
||||
@@ -200,7 +200,7 @@ public:
|
||||
*/
|
||||
gcc_pure
|
||||
bool LockHasClients() const {
|
||||
const ScopeLock protect(mutex);
|
||||
const std::lock_guard<Mutex> protect(mutex);
|
||||
return HasClients();
|
||||
}
|
||||
|
||||
|
||||
@@ -153,7 +153,7 @@ HttpdOutput::RunDeferred()
|
||||
/* this method runs in the IOThread; it broadcasts pages from
|
||||
our own queue to all clients */
|
||||
|
||||
const ScopeLock protect(mutex);
|
||||
const std::lock_guard<Mutex> protect(mutex);
|
||||
|
||||
while (!pages.empty()) {
|
||||
Page *page = pages.front();
|
||||
@@ -200,7 +200,7 @@ HttpdOutput::OnAccept(int fd, SocketAddress address, gcc_unused int uid)
|
||||
(void)address;
|
||||
#endif /* HAVE_WRAP */
|
||||
|
||||
const ScopeLock protect(mutex);
|
||||
const std::lock_guard<Mutex> protect(mutex);
|
||||
|
||||
if (fd >= 0) {
|
||||
/* can we allow additional client */
|
||||
@@ -296,7 +296,7 @@ httpd_output_open(AudioOutput *ao, AudioFormat &audio_format)
|
||||
{
|
||||
HttpdOutput *httpd = HttpdOutput::Cast(ao);
|
||||
|
||||
const ScopeLock protect(httpd->mutex);
|
||||
const std::lock_guard<Mutex> protect(httpd->mutex);
|
||||
httpd->Open(audio_format);
|
||||
}
|
||||
|
||||
@@ -324,7 +324,7 @@ httpd_output_close(AudioOutput *ao)
|
||||
{
|
||||
HttpdOutput *httpd = HttpdOutput::Cast(ao);
|
||||
|
||||
const ScopeLock protect(httpd->mutex);
|
||||
const std::lock_guard<Mutex> protect(httpd->mutex);
|
||||
httpd->Close();
|
||||
}
|
||||
|
||||
@@ -496,7 +496,7 @@ HttpdOutput::SendTag(const Tag &tag)
|
||||
|
||||
metadata = icy_server_metadata_page(tag, &types[0]);
|
||||
if (metadata != nullptr) {
|
||||
const ScopeLock protect(mutex);
|
||||
const std::lock_guard<Mutex> protect(mutex);
|
||||
for (auto &client : clients)
|
||||
client.PushMetaData(metadata);
|
||||
}
|
||||
@@ -514,7 +514,7 @@ httpd_output_tag(AudioOutput *ao, const Tag &tag)
|
||||
inline void
|
||||
HttpdOutput::CancelAllClients()
|
||||
{
|
||||
const ScopeLock protect(mutex);
|
||||
const std::lock_guard<Mutex> protect(mutex);
|
||||
|
||||
while (!pages.empty()) {
|
||||
Page *page = pages.front();
|
||||
|
||||
@@ -319,7 +319,7 @@ SlesOutput::Play(const void *chunk, size_t size)
|
||||
pause = false;
|
||||
}
|
||||
|
||||
const ScopeLock protect(mutex);
|
||||
const std::lock_guard<Mutex> protect(mutex);
|
||||
|
||||
assert(filled < BUFFER_SIZE);
|
||||
|
||||
@@ -348,7 +348,7 @@ SlesOutput::Play(const void *chunk, size_t size)
|
||||
inline void
|
||||
SlesOutput::Drain()
|
||||
{
|
||||
const ScopeLock protect(mutex);
|
||||
const std::lock_guard<Mutex> protect(mutex);
|
||||
|
||||
assert(filled < BUFFER_SIZE);
|
||||
|
||||
@@ -371,7 +371,7 @@ SlesOutput::Cancel()
|
||||
FormatWarning(sles_domain,
|
||||
"AndroidSimpleBufferQueue.Clear() failed");
|
||||
|
||||
const ScopeLock protect(mutex);
|
||||
const std::lock_guard<Mutex> protect(mutex);
|
||||
n_queued = 0;
|
||||
filled = 0;
|
||||
}
|
||||
@@ -398,7 +398,7 @@ SlesOutput::Pause()
|
||||
inline void
|
||||
SlesOutput::PlayedCallback()
|
||||
{
|
||||
const ScopeLock protect(mutex);
|
||||
const std::lock_guard<Mutex> protect(mutex);
|
||||
assert(n_queued > 0);
|
||||
--n_queued;
|
||||
cond.signal();
|
||||
|
||||
Reference in New Issue
Block a user