summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMax Kellermann <max@musicpd.org>2017-01-03 07:11:57 +0100
committerMax Kellermann <max@musicpd.org>2017-01-03 07:11:57 +0100
commit2e182e84c35c73f8d5b4f135ffa3550b7e70f66f (patch)
tree806ec01525f834132c46e6392714900ec75eada2
parenta42021655c3218c64272b648438197247ec7f6a9 (diff)
thread/Mutex: remove ScopeLock, use std::lock_guard directly
-rw-r--r--src/IOThread.cxx2
-rw-r--r--src/MusicBuffer.cxx4
-rw-r--r--src/MusicPipe.cxx6
-rw-r--r--src/db/update/Remove.cxx4
-rw-r--r--src/decoder/Bridge.cxx14
-rw-r--r--src/decoder/DecoderControl.cxx2
-rw-r--r--src/decoder/DecoderControl.hxx14
-rw-r--r--src/decoder/DecoderThread.cxx14
-rw-r--r--src/event/Loop.cxx2
-rw-r--r--src/input/AsyncInputStream.cxx4
-rw-r--r--src/input/InputStream.cxx14
-rw-r--r--src/input/Open.cxx2
-rw-r--r--src/input/ThreadInputStream.cxx4
-rw-r--r--src/input/plugins/AlsaInputPlugin.cxx2
-rw-r--r--src/input/plugins/CurlInputPlugin.cxx4
-rw-r--r--src/input/plugins/NfsInputPlugin.cxx6
-rw-r--r--src/input/plugins/SmbclientInputPlugin.cxx2
-rw-r--r--src/lib/icu/Converter.cxx4
-rw-r--r--src/lib/nfs/Blocking.hxx4
-rw-r--r--src/lib/smbclient/Init.cxx2
-rw-r--r--src/lib/upnp/ClientInit.cxx4
-rw-r--r--src/lib/upnp/Discovery.cxx8
-rw-r--r--src/lib/upnp/Init.cxx4
-rw-r--r--src/lib/upnp/WorkQueue.hxx10
-rw-r--r--src/mixer/MixerControl.cxx8
-rw-r--r--src/neighbor/plugins/SmbclientNeighborPlugin.cxx4
-rw-r--r--src/notify.cxx6
-rw-r--r--src/output/Internal.hxx2
-rw-r--r--src/output/MultipleOutputs.cxx8
-rw-r--r--src/output/OutputControl.cxx18
-rw-r--r--src/output/OutputState.cxx2
-rw-r--r--src/output/OutputThread.cxx2
-rw-r--r--src/output/plugins/RoarOutputPlugin.cxx12
-rw-r--r--src/output/plugins/httpd/HttpdClient.cxx4
-rw-r--r--src/output/plugins/httpd/HttpdInternal.hxx2
-rw-r--r--src/output/plugins/httpd/HttpdOutputPlugin.cxx12
-rw-r--r--src/output/plugins/sles/SlesOutputPlugin.cxx8
-rw-r--r--src/player/Control.cxx18
-rw-r--r--src/player/Control.hxx18
-rw-r--r--src/player/Thread.cxx12
-rw-r--r--src/playlist/plugins/SoundCloudPlaylistPlugin.cxx2
-rw-r--r--src/storage/CompositeStorage.cxx16
-rw-r--r--src/storage/CompositeStorage.hxx2
-rw-r--r--src/storage/plugins/NfsStorage.cxx6
-rw-r--r--src/storage/plugins/SmbclientStorage.cxx8
-rw-r--r--src/tag/ApeLoader.cxx2
-rw-r--r--src/tag/Id3Load.cxx2
-rw-r--r--src/thread/Mutex.hxx2
-rw-r--r--test/dump_text_file.cxx2
-rw-r--r--test/run_input.cxx2
-rw-r--r--test/test_rewind.cxx2
51 files changed, 158 insertions, 160 deletions
diff --git a/src/IOThread.cxx b/src/IOThread.cxx
index 4fbe837f7..00784276d 100644
--- a/src/IOThread.cxx
+++ b/src/IOThread.cxx
@@ -72,7 +72,7 @@ io_thread_start()
assert(io.loop != nullptr);
assert(!io.thread.IsDefined());
- const ScopeLock protect(io.mutex);
+ const std::lock_guard<Mutex> protect(io.mutex);
io.thread.Start(io_thread_func, nullptr);
}
diff --git a/src/MusicBuffer.cxx b/src/MusicBuffer.cxx
index f7e786428..0b4783b95 100644
--- a/src/MusicBuffer.cxx
+++ b/src/MusicBuffer.cxx
@@ -30,7 +30,7 @@ MusicBuffer::MusicBuffer(unsigned num_chunks)
MusicChunk *
MusicBuffer::Allocate()
{
- const ScopeLock protect(mutex);
+ const std::lock_guard<Mutex> protect(mutex);
return buffer.Allocate();
}
@@ -39,7 +39,7 @@ MusicBuffer::Return(MusicChunk *chunk)
{
assert(chunk != nullptr);
- const ScopeLock protect(mutex);
+ const std::lock_guard<Mutex> protect(mutex);
if (chunk->other != nullptr) {
assert(chunk->other->other == nullptr);
diff --git a/src/MusicPipe.cxx b/src/MusicPipe.cxx
index 9f62c40f7..cac9bb26b 100644
--- a/src/MusicPipe.cxx
+++ b/src/MusicPipe.cxx
@@ -27,7 +27,7 @@
bool
MusicPipe::Contains(const MusicChunk *chunk) const
{
- const ScopeLock protect(mutex);
+ const std::lock_guard<Mutex> protect(mutex);
for (const MusicChunk *i = head; i != nullptr; i = i->next)
if (i == chunk)
@@ -41,7 +41,7 @@ MusicPipe::Contains(const MusicChunk *chunk) const
MusicChunk *
MusicPipe::Shift()
{
- const ScopeLock protect(mutex);
+ const std::lock_guard<Mutex> protect(mutex);
MusicChunk *chunk = head;
if (chunk != nullptr) {
@@ -87,7 +87,7 @@ MusicPipe::Push(MusicChunk *chunk)
assert(!chunk->IsEmpty());
assert(chunk->length == 0 || chunk->audio_format.IsValid());
- const ScopeLock protect(mutex);
+ const std::lock_guard<Mutex> protect(mutex);
assert(size > 0 || !audio_format.IsDefined());
assert(!audio_format.IsDefined() ||
diff --git a/src/db/update/Remove.cxx b/src/db/update/Remove.cxx
index c566092a9..4878011ac 100644
--- a/src/db/update/Remove.cxx
+++ b/src/db/update/Remove.cxx
@@ -37,7 +37,7 @@ UpdateRemoveService::RunDeferred()
std::forward_list<std::string> copy;
{
- const ScopeLock protect(mutex);
+ const std::lock_guard<Mutex> protect(mutex);
std::swap(uris, copy);
}
@@ -56,7 +56,7 @@ UpdateRemoveService::Remove(std::string &&uri)
bool was_empty;
{
- const ScopeLock protect(mutex);
+ const std::lock_guard<Mutex> protect(mutex);
was_empty = uris.empty();
uris.emplace_front(std::move(uri));
}
diff --git a/src/decoder/Bridge.cxx b/src/decoder/Bridge.cxx
index 593cee26a..3d006edd1 100644
--- a/src/decoder/Bridge.cxx
+++ b/src/decoder/Bridge.cxx
@@ -88,7 +88,7 @@ need_chunks(DecoderControl &dc)
static DecoderCommand
LockNeedChunks(DecoderControl &dc)
{
- const ScopeLock protect(dc.mutex);
+ const std::lock_guard<Mutex> protect(dc.mutex);
return need_chunks(dc);
}
@@ -130,7 +130,7 @@ DecoderBridge::FlushChunk()
else
dc.pipe->Push(chunk);
- const ScopeLock protect(dc.mutex);
+ const std::lock_guard<Mutex> protect(dc.mutex);
if (dc.client_is_waiting)
dc.client_cond.signal();
}
@@ -193,7 +193,7 @@ DecoderBridge::GetVirtualCommand()
DecoderCommand
DecoderBridge::LockGetVirtualCommand()
{
- const ScopeLock protect(dc.mutex);
+ const std::lock_guard<Mutex> protect(dc.mutex);
return GetVirtualCommand();
}
@@ -258,7 +258,7 @@ DecoderBridge::Ready(const AudioFormat audio_format,
seekable ? "true" : "false");
{
- const ScopeLock protect(dc.mutex);
+ const std::lock_guard<Mutex> protect(dc.mutex);
dc.SetReady(audio_format, seekable, duration);
}
@@ -287,7 +287,7 @@ DecoderBridge::GetCommand()
void
DecoderBridge::CommandFinished()
{
- const ScopeLock protect(dc.mutex);
+ const std::lock_guard<Mutex> protect(dc.mutex);
assert(dc.command != DecoderCommand::NONE || initial_seek_running);
assert(dc.command != DecoderCommand::SEEK ||
@@ -376,7 +376,7 @@ DecoderBridge::OpenUri(const char *uri)
auto is = InputStream::Open(uri, mutex, cond);
- const ScopeLock lock(mutex);
+ const std::lock_guard<Mutex> lock(mutex);
while (true) {
is->Update();
if (is->IsReady())
@@ -399,7 +399,7 @@ try {
if (length == 0)
return 0;
- ScopeLock lock(is.mutex);
+ std::lock_guard<Mutex> lock(is.mutex);
while (true) {
if (CheckCancelRead())
diff --git a/src/decoder/DecoderControl.cxx b/src/decoder/DecoderControl.cxx
index 259d51a1f..6bf9054ab 100644
--- a/src/decoder/DecoderControl.cxx
+++ b/src/decoder/DecoderControl.cxx
@@ -111,7 +111,7 @@ DecoderControl::Start(DetachedSong *_song,
void
DecoderControl::Stop()
{
- const ScopeLock protect(mutex);
+ const std::lock_guard<Mutex> protect(mutex);
if (command != DecoderCommand::NONE)
/* Attempt to cancel the current command. If it's too
diff --git a/src/decoder/DecoderControl.hxx b/src/decoder/DecoderControl.hxx
index d21b0e2dc..c59c67f41 100644
--- a/src/decoder/DecoderControl.hxx
+++ b/src/decoder/DecoderControl.hxx
@@ -228,7 +228,7 @@ struct DecoderControl {
gcc_pure
bool LockIsIdle() const {
- const ScopeLock protect(mutex);
+ const std::lock_guard<Mutex> protect(mutex);
return IsIdle();
}
@@ -238,7 +238,7 @@ struct DecoderControl {
gcc_pure
bool LockIsStarting() const {
- const ScopeLock protect(mutex);
+ const std::lock_guard<Mutex> protect(mutex);
return IsStarting();
}
@@ -250,7 +250,7 @@ struct DecoderControl {
gcc_pure
bool LockHasFailed() const {
- const ScopeLock protect(mutex);
+ const std::lock_guard<Mutex> protect(mutex);
return HasFailed();
}
@@ -281,7 +281,7 @@ struct DecoderControl {
* Like CheckRethrowError(), but locks and unlocks the object.
*/
void LockCheckRethrowError() const {
- const ScopeLock protect(mutex);
+ const std::lock_guard<Mutex> protect(mutex);
CheckRethrowError();
}
@@ -309,7 +309,7 @@ struct DecoderControl {
gcc_pure
bool LockIsCurrentSong(const DetachedSong &_song) const {
- const ScopeLock protect(mutex);
+ const std::lock_guard<Mutex> protect(mutex);
return IsCurrentSong(_song);
}
@@ -346,13 +346,13 @@ private:
* object.
*/
void LockSynchronousCommand(DecoderCommand cmd) {
- const ScopeLock protect(mutex);
+ const std::lock_guard<Mutex> protect(mutex);
ClearError();
SynchronousCommandLocked(cmd);
}
void LockAsynchronousCommand(DecoderCommand cmd) {
- const ScopeLock protect(mutex);
+ const std::lock_guard<Mutex> protect(mutex);
command = cmd;
Signal();
}
diff --git a/src/decoder/DecoderThread.cxx b/src/decoder/DecoderThread.cxx
index cd8eb7538..5e3eed365 100644
--- a/src/decoder/DecoderThread.cxx
+++ b/src/decoder/DecoderThread.cxx
@@ -61,7 +61,7 @@ decoder_input_stream_open(DecoderControl &dc, const char *uri)
/* wait for the input stream to become ready; its metadata
will be available then */
- const ScopeLock protect(dc.mutex);
+ const std::lock_guard<Mutex> protect(dc.mutex);
is->Update();
while (!is->IsReady()) {
@@ -264,7 +264,7 @@ static void
MaybeLoadReplayGain(DecoderBridge &bridge, InputStream &is)
{
{
- const ScopeLock protect(bridge.dc.mutex);
+ const std::lock_guard<Mutex> protect(bridge.dc.mutex);
if (bridge.dc.replay_gain_mode == ReplayGainMode::OFF)
/* ReplayGain is disabled */
return;
@@ -288,7 +288,7 @@ decoder_run_stream(DecoderBridge &bridge, const char *uri)
MaybeLoadReplayGain(bridge, *input_stream);
- const ScopeLock protect(dc.mutex);
+ const std::lock_guard<Mutex> protect(dc.mutex);
bool tried = false;
return dc.command == DecoderCommand::STOP ||
@@ -318,10 +318,10 @@ TryDecoderFile(DecoderBridge &bridge, Path path_fs, const char *suffix,
DecoderControl &dc = bridge.dc;
if (plugin.file_decode != nullptr) {
- const ScopeLock protect(dc.mutex);
+ const std::lock_guard<Mutex> protect(dc.mutex);
return decoder_file_decode(plugin, bridge, path_fs);
} else if (plugin.stream_decode != nullptr) {
- const ScopeLock protect(dc.mutex);
+ const std::lock_guard<Mutex> protect(dc.mutex);
return decoder_stream_decode(plugin, bridge, input_stream);
} else
return false;
@@ -344,7 +344,7 @@ TryContainerDecoder(DecoderBridge &bridge, Path path_fs, const char *suffix,
bridge.error = nullptr;
DecoderControl &dc = bridge.dc;
- const ScopeLock protect(dc.mutex);
+ const std::lock_guard<Mutex> protect(dc.mutex);
return decoder_file_decode(plugin, bridge, path_fs);
}
@@ -517,7 +517,7 @@ decoder_task(void *arg)
SetThreadName("decoder");
- const ScopeLock protect(dc.mutex);
+ const std::lock_guard<Mutex> protect(dc.mutex);
do {
assert(dc.state == DecoderState::STOP ||
diff --git a/src/event/Loop.cxx b/src/event/Loop.cxx
index 56e12b756..aab161278 100644
--- a/src/event/Loop.cxx
+++ b/src/event/Loop.cxx
@@ -254,7 +254,7 @@ EventLoop::AddDeferred(DeferredMonitor &d)
void
EventLoop::RemoveDeferred(DeferredMonitor &d)
{
- const ScopeLock protect(mutex);
+ const std::lock_guard<Mutex> protect(mutex);
if (!d.pending) {
assert(std::find(deferred.begin(),
diff --git a/src/input/AsyncInputStream.cxx b/src/input/AsyncInputStream.cxx
index 19b14b180..201e37656 100644
--- a/src/input/AsyncInputStream.cxx
+++ b/src/input/AsyncInputStream.cxx
@@ -240,7 +240,7 @@ AsyncInputStream::AppendToBuffer(const void *data, size_t append_size)
void
AsyncInputStream::DeferredResume()
{
- const ScopeLock protect(mutex);
+ const std::lock_guard<Mutex> protect(mutex);
try {
Resume();
@@ -253,7 +253,7 @@ AsyncInputStream::DeferredResume()
void
AsyncInputStream::DeferredSeek()
{
- const ScopeLock protect(mutex);
+ const std::lock_guard<Mutex> protect(mutex);
if (seek_state != SeekState::SCHEDULED)
return;
diff --git a/src/input/InputStream.cxx b/src/input/InputStream.cxx
index f9b25b60c..e48e59684 100644
--- a/src/input/InputStream.cxx
+++ b/src/input/InputStream.cxx
@@ -64,7 +64,7 @@ InputStream::WaitReady()
void
InputStream::LockWaitReady()
{
- const ScopeLock protect(mutex);
+ const std::lock_guard<Mutex> protect(mutex);
WaitReady();
}
@@ -96,14 +96,14 @@ InputStream::Seek(gcc_unused offset_type new_offset)
void
InputStream::LockSeek(offset_type _offset)
{
- const ScopeLock protect(mutex);
+ const std::lock_guard<Mutex> protect(mutex);
Seek(_offset);
}
void
InputStream::LockSkip(offset_type _offset)
{
- const ScopeLock protect(mutex);
+ const std::lock_guard<Mutex> protect(mutex);
Skip(_offset);
}
@@ -116,7 +116,7 @@ InputStream::ReadTag()
Tag *
InputStream::LockReadTag()
{
- const ScopeLock protect(mutex);
+ const std::lock_guard<Mutex> protect(mutex);
return ReadTag();
}
@@ -135,7 +135,7 @@ InputStream::LockRead(void *ptr, size_t _size)
#endif
assert(_size > 0);
- const ScopeLock protect(mutex);
+ const std::lock_guard<Mutex> protect(mutex);
return Read(ptr, _size);
}
@@ -164,13 +164,13 @@ InputStream::LockReadFull(void *ptr, size_t _size)
#endif
assert(_size > 0);
- const ScopeLock protect(mutex);
+ const std::lock_guard<Mutex> protect(mutex);
ReadFull(ptr, _size);
}
bool
InputStream::LockIsEOF()
{
- const ScopeLock protect(mutex);
+ const std::lock_guard<Mutex> protect(mutex);
return IsEOF();
}
diff --git a/src/input/Open.cxx b/src/input/Open.cxx
index 10e156898..ae7422da2 100644
--- a/src/input/Open.cxx
+++ b/src/input/Open.cxx
@@ -59,7 +59,7 @@ InputStream::OpenReady(const char *uri,
auto is = Open(uri, mutex, cond);
{
- const ScopeLock protect(mutex);
+ const std::lock_guard<Mutex> protect(mutex);
is->WaitReady();
is->Check();
}
diff --git a/src/input/ThreadInputStream.cxx b/src/input/ThreadInputStream.cxx
index 56054e15b..f18c1e632 100644
--- a/src/input/ThreadInputStream.cxx
+++ b/src/input/ThreadInputStream.cxx
@@ -29,7 +29,7 @@
ThreadInputStream::~ThreadInputStream()
{
{
- const ScopeLock lock(mutex);
+ const std::lock_guard<Mutex> lock(mutex);
close = true;
wake_cond.signal();
}
@@ -62,7 +62,7 @@ ThreadInputStream::ThreadFunc()
{
FormatThreadName("input:%s", plugin);
- const ScopeLock lock(mutex);
+ const std::lock_guard<Mutex> lock(mutex);
try {
Open();
diff --git a/src/input/plugins/AlsaInputPlugin.cxx b/src/input/plugins/AlsaInputPlugin.cxx
index f87483c4e..4b8eabda3 100644
--- a/src/input/plugins/AlsaInputPlugin.cxx
+++ b/src/input/plugins/AlsaInputPlugin.cxx
@@ -192,7 +192,7 @@ AlsaInputStream::PrepareSockets()
void
AlsaInputStream::DispatchSockets()
{
- const ScopeLock protect(mutex);
+ const std::lock_guard<Mutex> protect(mutex);
auto w = PrepareWriteBuffer();
const snd_pcm_uframes_t w_frames = w.size / frame_size;
diff --git a/src/input/plugins/CurlInputPlugin.cxx b/src/input/plugins/CurlInputPlugin.cxx
index 7f5f3991c..3034f0794 100644
--- a/src/input/plugins/CurlInputPlugin.cxx
+++ b/src/input/plugins/CurlInputPlugin.cxx
@@ -429,7 +429,7 @@ CurlInputStream::RequestDone(CURLcode result, long status)
FreeEasy();
AsyncInputStream::SetClosed();
- const ScopeLock protect(mutex);
+ const std::lock_guard<Mutex> protect(mutex);
if (result != CURLE_OK) {
postponed_exception = std::make_exception_ptr(FormatRuntimeError("curl failed: %s",
@@ -693,7 +693,7 @@ CurlInputStream::DataReceived(const void *ptr, size_t received_size)
{
assert(received_size > 0);
- const ScopeLock protect(mutex);
+ const std::lock_guard<Mutex> protect(mutex);
if (IsSeekPending())
SeekDone();
diff --git a/src/input/plugins/NfsInputPlugin.cxx b/src/input/plugins/NfsInputPlugin.cxx
index 7df6ded60..ccfb7816e 100644
--- a/src/input/plugins/NfsInputPlugin.cxx
+++ b/src/input/plugins/NfsInputPlugin.cxx
@@ -142,7 +142,7 @@ NfsInputStream::DoSeek(offset_type new_offset)
void
NfsInputStream::OnNfsFileOpen(uint64_t _size)
{
- const ScopeLock protect(mutex);
+ const std::lock_guard<Mutex> protect(mutex);
if (reconnecting) {
/* reconnect has succeeded */
@@ -162,7 +162,7 @@ NfsInputStream::OnNfsFileOpen(uint64_t _size)
void
NfsInputStream::OnNfsFileRead(const void *data, size_t data_size)
{
- const ScopeLock protect(mutex);
+ const std::lock_guard<Mutex> protect(mutex);
assert(!IsBufferFull());
assert(IsBufferFull() == (GetBufferSpace() == 0));
AppendToBuffer(data, data_size);
@@ -175,7 +175,7 @@ NfsInputStream::OnNfsFileRead(const void *data, size_t data_size)
void
NfsInputStream::OnNfsFileError(std::exception_ptr &&e)
{
- const ScopeLock protect(mutex);
+ const std::lock_guard<Mutex> protect(mutex);
if (IsPaused()) {
/* while we're paused, don't report this error to the
diff --git a/src/input/plugins/SmbclientInputPlugin.cxx b/src/input/plugins/SmbclientInputPlugin.cxx
index 641a15c8f..30d4d5887 100644
--- a/src/input/plugins/SmbclientInputPlugin.cxx
+++ b/src/input/plugins/SmbclientInputPlugin.cxx
@@ -90,7 +90,7 @@ input_smbclient_open(const char *uri,
if (!StringStartsWith(uri, "smb://"))
return nullptr;
- const ScopeLock protect(smbclient_mutex);
+ const std::lock_guard<Mutex> protect(smbclient_mutex);
SMBCCTX *ctx = smbc_new_context();
if (ctx == nullptr)
diff --git a/src/lib/icu/Converter.cxx b/src/lib/icu/Converter.cxx
index 1b638bbfd..6ea116fa0 100644
--- a/src/lib/icu/Converter.cxx
+++ b/src/lib/icu/Converter.cxx
@@ -105,7 +105,7 @@ AllocatedString<char>
IcuConverter::ToUTF8(const char *s) const
{
#ifdef HAVE_ICU
- const ScopeLock protect(mutex);
+ const std::lock_guard<Mutex> protect(mutex);
ucnv_resetToUnicode(converter);
@@ -133,7 +133,7 @@ AllocatedString<char>
IcuConverter::FromUTF8(const char *s) const
{
#ifdef HAVE_ICU
- const ScopeLock protect(mutex);
+ const std::lock_guard<Mutex> protect(mutex);
const auto u = UCharFromUTF8(s);
diff --git a/src/lib/nfs/Blocking.hxx b/src/lib/nfs/Blocking.hxx
index ab9d07e2a..690d76939 100644
--- a/src/lib/nfs/Blocking.hxx
+++ b/src/lib/nfs/Blocking.hxx
@@ -60,7 +60,7 @@ public:
private:
bool LockWaitFinished() {
- const ScopeLock protect(mutex);
+ const std::lock_guard<Mutex> protect(mutex);
while (!finished)
if (!cond.timed_wait(mutex, timeout))
return false;
@@ -73,7 +73,7 @@ private:
* thread.
*/
void LockSetFinished() {
- const ScopeLock protect(mutex);
+ const std::lock_guard<Mutex> protect(mutex);
finished = true;
cond.signal();
}
diff --git a/src/lib/smbclient/Init.cxx b/src/lib/smbclient/Init.cxx
index b8b7d8391..69f520eb0 100644
--- a/src/lib/smbclient/Init.cxx
+++ b/src/lib/smbclient/Init.cxx
@@ -43,7 +43,7 @@ mpd_smbc_get_auth_data(gcc_unused const char *srv,
void
SmbclientInit()
{
- const ScopeLock protect(smbclient_mutex);
+ const std::lock_guard<Mutex> protect(smbclient_mutex);
constexpr int debug = 0;
if (smbc_init(mpd_smbc_get_auth_data, debug) < 0)
diff --git a/src/lib/upnp/ClientInit.cxx b/src/lib/upnp/ClientInit.cxx
index 19046f397..ca592f440 100644
--- a/src/lib/upnp/ClientInit.cxx
+++ b/src/lib/upnp/ClientInit.cxx
@@ -61,7 +61,7 @@ UpnpClientGlobalInit(UpnpClient_Handle &handle)
UpnpGlobalInit();
try {
- const ScopeLock protect(upnp_client_init_mutex);
+ const std::lock_guard<Mutex> protect(upnp_client_init_mutex);
if (upnp_client_ref == 0)
DoInit();
} catch (...) {
@@ -77,7 +77,7 @@ void
UpnpClientGlobalFinish()
{
{
- const ScopeLock protect(upnp_client_init_mutex);
+ const std::lock_guard<Mutex> protect(upnp_client_init_mutex);
assert(upnp_client_ref > 0);
if (--upnp_client_ref == 0)
diff --git a/src/lib/upnp/Discovery.cxx b/src/lib/upnp/Discovery.cxx
index 52d5b21e1..43a2dc7e2 100644
--- a/src/lib/upnp/Discovery.cxx
+++ b/src/lib/upnp/Discovery.cxx
@@ -74,7 +74,7 @@ AnnounceLostUPnP(UPnPDiscoveryListener &listener, const UPnPDevice &device)
inline void
UPnPDeviceDirectory::LockAdd(ContentDirectoryDescriptor &&d)
{
- const ScopeLock protect(mutex);
+ const std::lock_guard<Mutex> protect(mutex);
for (auto &i : directories) {
if (i.id == d.id) {
@@ -92,7 +92,7 @@ UPnPDeviceDirectory::LockAdd(ContentDirectoryDescriptor &&d)
inline void
UPnPDeviceDirectory::LockRemove(const std::string &id)
{
- const ScopeLock protect(mutex);
+ const std::lock_guard<Mutex> protect(mutex);
for (auto i = directories.begin(), end = directories.end();
i != end; ++i) {
@@ -273,7 +273,7 @@ UPnPDeviceDirectory::Search()
std::vector<ContentDirectoryService>
UPnPDeviceDirectory::GetDirectories()
{
- const ScopeLock protect(mutex);
+ const std::lock_guard<Mutex> protect(mutex);
ExpireDevices();
@@ -293,7 +293,7 @@ UPnPDeviceDirectory::GetDirectories()
ContentDirectoryService
UPnPDeviceDirectory::GetServer(const char *friendly_name)
{
- const ScopeLock protect(mutex);
+ const std::lock_guard<Mutex> protect(mutex);
ExpireDevices();
diff --git a/src/lib/upnp/Init.cxx b/src/lib/upnp/Init.cxx
index c4bd1b9b0..19b32ea7d 100644
--- a/src/lib/upnp/Init.cxx
+++ b/src/lib/upnp/Init.cxx
@@ -48,7 +48,7 @@ DoInit()
void
UpnpGlobalInit()
{
- const ScopeLock protect(upnp_init_mutex);
+ const std::lock_guard<Mutex> protect(upnp_init_mutex);
if (upnp_ref == 0)
DoInit();
@@ -59,7 +59,7 @@ UpnpGlobalInit()
void
UpnpGlobalFinish()
{
- const ScopeLock protect(upnp_init_mutex);
+ const std::lock_guard<Mutex> protect(upnp_init_mutex);
assert(upnp_ref > 0);
diff --git a/src/lib/upnp/WorkQueue.hxx b/src/lib/upnp/WorkQueue.hxx
index 3b30e9db5..6cf48d0c2 100644
--- a/src/lib/upnp/WorkQueue.hxx
+++ b/src/lib/upnp/WorkQueue.hxx
@@ -90,7 +90,7 @@ public:
*/
bool start(unsigned nworkers, void *(*workproc)(void *), void *arg)
{
- const ScopeLock protect(mutex);
+ const std::lock_guard<Mutex> protect(mutex);
assert(nworkers > 0);
assert(!ok);
@@ -120,7 +120,7 @@ public:
template<typename U>
bool put(U &&u)
{
- const ScopeLock protect(mutex);
+ const std::lock_guard<Mutex> protect(mutex);
queue.emplace(std::forward<U>(u));
@@ -135,7 +135,7 @@ public:
*/
void setTerminateAndWait()
{
- const ScopeLock protect(mutex);
+ const std::lock_guard<Mutex> protect(mutex);
// Wait for all worker threads to have called workerExit()
ok = false;
@@ -166,7 +166,7 @@ public:
*/
bool take(T &tp)
{
- const ScopeLock protect(mutex);
+ const std::lock_guard<Mutex> protect(mutex);
if (!ok)
return false;
@@ -192,7 +192,7 @@ public:
*/
void workerExit()
{
- const ScopeLock protect(mutex);
+ const std::lock_guard<Mutex> protect(mutex);
n_workers_exited++;
ok = false;
diff --git a/src/mixer/MixerControl.cxx b/src/mixer/MixerControl.cxx
index 33f26ccc9..df7b384dc 100644
--- a/src/mixer/MixerControl.cxx
+++ b/src/mixer/MixerControl.cxx
@@ -53,7 +53,7 @@ mixer_open(Mixer *mixer)
{
assert(mixer != nullptr);
- const ScopeLock protect(mixer->mutex);
+ const std::lock_guard<Mutex> protect(mixer->mutex);
if (mixer->open)
return;
@@ -83,7 +83,7 @@ mixer_close(Mixer *mixer)
{
assert(mixer != nullptr);
- const ScopeLock protect(mixer->mutex);
+ const std::lock_guard<Mutex> protect(mixer->mutex);
if (mixer->open)
mixer_close_internal(mixer);
@@ -120,7 +120,7 @@ mixer_get_volume(Mixer *mixer)
if (mixer->plugin.global && !mixer->failed)
mixer_open(mixer);
- const ScopeLock protect(mixer->mutex);
+ const std::lock_guard<Mutex> protect(mixer->mutex);
if (mixer->open) {
try {
@@ -144,7 +144,7 @@ mixer_set_volume(Mixer *mixer, unsigned volume)
if (mixer->plugin.global && !mixer->failed)
mixer_open(mixer);
- const ScopeLock protect(mixer->mutex);
+ const std::lock_guard<Mutex> protect(mixer->mutex);
if (mixer->open)
mixer->SetVolume(volume);
diff --git a/src/neighbor/plugins/SmbclientNeighborPlugin.cxx b/src/neighbor/plugins/SmbclientNeighborPlugin.cxx
index 95e4dd3fc..ac5731a46 100644
--- a/src/neighbor/plugins/SmbclientNeighborPlugin.cxx
+++ b/src/neighbor/plugins/SmbclientNeighborPlugin.cxx
@@ -103,7 +103,7 @@ SmbclientNeighborExplorer::Close()
NeighborExplorer::List
SmbclientNeighborExplorer::GetList() const
{
- const ScopeLock protect(mutex);
+ const std::lock_guard<Mutex> protect(mutex);
/*
List list;
for (const auto &i : servers)
@@ -172,7 +172,7 @@ static NeighborExplorer::List
DetectServers()
{
NeighborExplorer::List list;
- const ScopeLock protect(smbclient_mutex);
+ const std::lock_guard<Mutex> protect(smbclient_mutex);
ReadServers(list, "smb://");
return list;
}
diff --git a/src/notify.cxx b/src/notify.cxx
index 347ce55a0..3d75d4249 100644
--- a/src/notify.cxx
+++ b/src/notify.cxx
@@ -23,7 +23,7 @@
void
notify::Wait()
{
- const ScopeLock protect(mutex);
+ const std::lock_guard<Mutex> protect(mutex);
while (!pending)
cond.wait(mutex);
pending = false;
@@ -32,7 +32,7 @@ notify::Wait()
void
notify::Signal()
{
- const ScopeLock protect(mutex);
+ const std::lock_guard<Mutex> protect(mutex);
pending = true;
cond.signal();
}
@@ -40,6 +40,6 @@ notify::Signal()
void
notify::Clear()
{
- const ScopeLock protect(mutex);
+ const std::lock_guard<Mutex> protect(mutex);
pending = false;
}
diff --git a/src/output/Internal.hxx b/src/output/Internal.hxx
index ae030bc8f..0fd156803 100644
--- a/src/output/Internal.hxx
+++ b/src/output/Internal.hxx
@@ -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);
}
diff --git a/src/output/MultipleOutputs.cxx b/src/output/MultipleOutputs.cxx
index e56fe2f2a..74c299be0 100644
--- a/src/output/MultipleOutputs.cxx
+++ b/src/output/MultipleOutputs.cxx
@@ -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;
diff --git a/src/output/OutputControl.cxx b/src/output/OutputControl.cxx
index fd20a6dd2..8b22042df 100644
--- a/src/output/OutputControl.cxx
+++ b/src/output/OutputControl.cxx
@@ -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);
}
}
diff --git a/src/output/OutputState.cxx b/src/output/OutputState.cxx
index 981bb024a..a2dfc84e2 100644
--- a/src/output/OutputState.cxx
+++ b/src/output/OutputState.cxx
@@ -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());
diff --git a/src/output/OutputThread.cxx b/src/output/OutputThread.cxx
index f0b2ab085..a6242704a 100644
--- a/src/output/OutputThread.cxx
+++ b/src/output/OutputThread.cxx
@@ -397,7 +397,7 @@ AudioOutput::Task()
SetThreadTimerSlackUS(100);
- const ScopeLock lock(mutex);
+ const std::lock_guard<Mutex> lock(mutex);
while (true) {
switch (command) {
diff --git a/src/output/plugins/RoarOutputPlugin.cxx b/src/output/plugins/RoarOutputPlugin.cxx
index cbfc9ffce..b3e71854b 100644
--- a/src/output/plugins/RoarOutputPlugin.cxx
+++ b/src/output/plugins/RoarOutputPlugin.cxx
@@ -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];
diff --git a/src/output/plugins/httpd/HttpdClient.cxx b/src/output/plugins/httpd/HttpdClient.cxx
index e9cda85f0..02960932d 100644
--- a/src/output/plugins/httpd/HttpdClient.cxx
+++ b/src/output/plugins/httpd/HttpdClient.cxx
@@ -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);
diff --git a/src/output/plugins/httpd/HttpdInternal.hxx b/src/output/plugins/httpd/HttpdInternal.hxx
index 74363110d..a1fb9669a 100644
--- a/src/output/plugins/httpd/HttpdInternal.hxx
+++ b/src/output/plugins/httpd/HttpdInternal.hxx
@@ -200,7 +200,7 @@ public:
*/
gcc_pure
bool LockHasClients() const {
- const ScopeLock protect(mutex);
+ const std::lock_guard<Mutex> protect(mutex);
return HasClients();
}
diff --git a/src/output/plugins/httpd/HttpdOutputPlugin.cxx b/src/output/plugins/httpd/HttpdOutputPlugin.cxx
index 0d0433e32..4dbd17e7c 100644
--- a/src/output/plugins/httpd/HttpdOutputPlugin.cxx
+++ b/src/output/plugins/httpd/HttpdOutputPlugin.cxx
@@ -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();
diff --git a/src/output/plugins/sles/SlesOutputPlugin.cxx b/src/output/plugins/sles/SlesOutputPlugin.cxx
index 274af1864..a5eb24a41 100644
--- a/src/output/plugins/sles/SlesOutputPlugin.cxx
+++ b/src/output/plugins/sles/SlesOutputPlugin.cxx
@@ -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();
diff --git a/src/player/Control.cxx b/src/player/Control.cxx
index 87620fc90..4d426266a 100644
--- a/src/player/Control.cxx
+++ b/src/player/Control.cxx
@@ -64,7 +64,7 @@ PlayerControl::Play(DetachedSong *song)
{
assert(song != nullptr);
- const ScopeLock protect(mutex);
+ const std::lock_guard<Mutex> protect(mutex);
SeekLocked(song, SongTime::zero());
if (state == PlayerState::PAUSE)
@@ -118,14 +118,14 @@ PlayerControl::PauseLocked()
void
PlayerControl::LockPause()
{
- const ScopeLock protect(mutex);
+ const std::lock_guard<Mutex> protect(mutex);
PauseLocked();
}
void
PlayerControl::LockSetPause(bool pause_flag)
{
- const ScopeLock protect(mutex);
+ const std::lock_guard<Mutex> protect(mutex);
switch (state) {
case PlayerState::STOP:
@@ -146,7 +146,7 @@ PlayerControl::LockSetPause(bool pause_flag)
void
PlayerControl::LockSetBorderPause(bool _border_pause)
{
- const ScopeLock protect(mutex);
+ const std::lock_guard<Mutex> protect(mutex);
border_pause = _border_pause;
}
@@ -155,7 +155,7 @@ PlayerControl::LockGetStatus()
{
player_status status;
- const ScopeLock protect(mutex);
+ const std::lock_guard<Mutex> protect(mutex);
SynchronousCommand(PlayerCommand::REFRESH);
status.state = state;
@@ -183,14 +183,14 @@ PlayerControl::SetError(PlayerError type, std::exception_ptr &&_error)
void
PlayerControl::LockClearError()
{
- const ScopeLock protect(mutex);
+ const std::lock_guard<Mutex> protect(mutex);
ClearError();
}
void
PlayerControl::LockSetTaggedSong(const DetachedSong &song)
{
- const ScopeLock protect(mutex);
+ const std::lock_guard<Mutex> protect(mutex);
delete tagged_song;
tagged_song = new DetachedSong(song);
}
@@ -207,7 +207,7 @@ PlayerControl::LockEnqueueSong(DetachedSong *song)
{
assert(song != nullptr);
- const ScopeLock protect(mutex);
+ const std::lock_guard<Mutex> protect(mutex);
EnqueueSongLocked(song);
}
@@ -246,7 +246,7 @@ PlayerControl::LockSeek(DetachedSong *song, SongTime t)
assert(song != nullptr);
{
- const ScopeLock protect(mutex);
+ const std::lock_guard<Mutex> protect(mutex);
SeekLocked(song, t);
}
diff --git a/src/player/Control.hxx b/src/player/Control.hxx
index 6d3e70647..608351306 100644
--- a/src/player/Control.hxx
+++ b/src/player/Control.hxx
@@ -224,7 +224,7 @@ struct PlayerControl final : AudioOutputClient {
* this function.
*/
void LockSignal() {
- const ScopeLock protect(mutex);
+ const std::lock_guard<Mutex> protect(mutex);
Signal();
}
@@ -277,7 +277,7 @@ struct PlayerControl final : AudioOutputClient {
}
void LockCommandFinished() {
- const ScopeLock protect(mutex);
+ const std::lock_guard<Mutex> protect(mutex);
CommandFinished();
}
@@ -294,7 +294,7 @@ struct PlayerControl final : AudioOutputClient {
bool WaitOutputConsumed(unsigned threshold);
bool LockWaitOutputConsumed(unsigned threshold) {
- const ScopeLock protect(mutex);
+ const std::lock_guard<Mutex> protect(mutex);
return WaitOutputConsumed(threshold);
}
@@ -333,7 +333,7 @@ private:
* object.
*/
void LockSynchronousCommand(PlayerCommand cmd) {
- const ScopeLock protect(mutex);
+ const std::lock_guard<Mutex> protect(mutex);
SynchronousCommand(cmd);
}
@@ -376,7 +376,7 @@ public:
}
bool LockApplyBorderPause() {
- const ScopeLock lock(mutex);
+ const std::lock_guard<Mutex> lock(mutex);
return ApplyBorderPause();
}
@@ -410,7 +410,7 @@ public:
}
void LockSetOutputError(std::exception_ptr &&_error) {
- const ScopeLock lock(mutex);
+ const std::lock_guard<Mutex> lock(mutex);
SetOutputError(std::move(_error));
}
@@ -429,7 +429,7 @@ public:
* Like CheckRethrowError(), but locks and unlocks the object.
*/
void LockCheckRethrowError() const {
- const ScopeLock protect(mutex);
+ const std::lock_guard<Mutex> protect(mutex);
CheckRethrowError();
}
@@ -462,7 +462,7 @@ public:
* Like ReadTaggedSong(), but locks and unlocks the object.
*/
DetachedSong *LockReadTaggedSong() {
- const ScopeLock protect(mutex);
+ const std::lock_guard<Mutex> protect(mutex);
return ReadTaggedSong();
}
@@ -521,7 +521,7 @@ public:
}
void LockSetReplayGainMode(ReplayGainMode _mode) {
- const ScopeLock protect(mutex);
+ const std::lock_guard<Mutex> protect(mutex);
replay_gain_mode = _mode;
}
diff --git a/src/player/Thread.cxx b/src/player/Thread.cxx
index 6d927df41..1426c98f4 100644
--- a/src/player/Thread.cxx
+++ b/src/player/Thread.cxx
@@ -213,7 +213,7 @@ private:
* allowed to be used while a command is being handled.
*/
bool WaitDecoderStartup() {
- const ScopeLock lock(pc.mutex);
+ const std::lock_guard<Mutex> lock(pc.mutex);
while (decoder_starting) {
if (!CheckDecoderStartup()) {
@@ -351,7 +351,7 @@ Player::StartDecoder(MusicPipe &_pipe)
{
/* copy ReplayGain parameters to the decoder */
- const ScopeLock protect(pc.mutex);
+ const std::lock_guard<Mutex> protect(pc.mutex);
dc.replay_gain_mode = pc.replay_gain_mode;
}
@@ -406,7 +406,7 @@ Player::ActivateDecoder()
queued = false;
{
- const ScopeLock lock(pc.mutex);
+ const std::lock_guard<Mutex> lock(pc.mutex);
pc.ClearTaggedSong();
@@ -787,7 +787,7 @@ play_chunk(PlayerControl &pc,
}
{
- const ScopeLock lock(pc.mutex);
+ const std::lock_guard<Mutex> lock(pc.mutex);
pc.bit_rate = chunk->bit_rate;
}
@@ -863,7 +863,7 @@ Player::PlayNextChunk()
} else {
/* there are not enough decoded chunks yet */
- const ScopeLock lock(pc.mutex);
+ const std::lock_guard<Mutex> lock(pc.mutex);
if (dc.IsIdle()) {
/* the decoder isn't running, abort
@@ -911,7 +911,7 @@ Player::PlayNextChunk()
return false;
}
- const ScopeLock lock(pc.mutex);
+ const std::lock_guard<Mutex> lock(pc.mutex);
/* this formula should prevent that the decoder gets woken up
with each chunk; it is more efficient to make it decode a
diff --git a/src/playlist/plugins/SoundCloudPlaylistPlugin.cxx b/src/playlist/plugins/SoundCloudPlaylistPlugin.cxx
index fceb13ec5..1ad7717eb 100644
--- a/src/playlist/plugins/SoundCloudPlaylistPlugin.cxx
+++ b/src/playlist/plugins/SoundCloudPlaylistPlugin.cxx
@@ -232,7 +232,7 @@ soundcloud_parse_json(const char *url, yajl_handle hand,
try {
auto input_stream = InputStream::OpenReady(url, mutex, cond);
- const ScopeLock protect(mutex);
+ const std::lock_guard<Mutex> protect(mutex);
yajl_status stat;
bool done = false;
diff --git a/src/storage/CompositeStorage.cxx b/src/storage/CompositeStorage.cxx
index e46d10f81..640b3b640 100644
--- a/src/storage/CompositeStorage.cxx
+++ b/src/storage/CompositeStorage.cxx
@@ -213,7 +213,7 @@ CompositeStorage::~CompositeStorage()
Storage *
CompositeStorage::GetMount(const char *uri)
{
- const ScopeLock protect(mutex);
+ const std::lock_guard<Mutex> protect(mutex);
auto result = FindStorage(uri);
if (*result.uri != 0)
@@ -226,7 +226,7 @@ CompositeStorage::GetMount(const char *uri)
void
CompositeStorage::Mount(const char *uri, Storage *storage)
{
- const ScopeLock protect(mutex);
+ const std::lock_guard<Mutex> protect(mutex);
Directory &directory = root.Make(uri);
if (directory.storage != nullptr)
@@ -237,7 +237,7 @@ CompositeStorage::Mount(const char *uri, Storage *storage)
bool
CompositeStorage::Unmount(const char *uri)
{
- const ScopeLock protect(mutex);
+ const std::lock_guard<Mutex> protect(mutex);
return root.Unmount(uri);
}
@@ -266,7 +266,7 @@ CompositeStorage::FindStorage(const char *uri) const
StorageFileInfo
CompositeStorage::GetInfo(const char *uri, bool follow)
{
- const ScopeLock protect(mutex);
+ const std::lock_guard<Mutex> protect(mutex);
std::exception_ptr error;
@@ -298,7 +298,7 @@ CompositeStorage::GetInfo(const char *uri, bool follow)
StorageDirectoryReader *
CompositeStorage::OpenDirectory(const char *uri)
{
- const ScopeLock protect(mutex);
+ const std::lock_guard<Mutex> protect(mutex);
auto f = FindStorage(uri);
const Directory *directory = f.directory->Find(f.uri);
@@ -324,7 +324,7 @@ CompositeStorage::OpenDirectory(const char *uri)
std::string
CompositeStorage::MapUTF8(const char *uri) const
{
- const ScopeLock protect(mutex);
+ const std::lock_guard<Mutex> protect(mutex);
auto f = FindStorage(uri);
if (f.directory->storage == nullptr)
@@ -336,7 +336,7 @@ CompositeStorage::MapUTF8(const char *uri) const
AllocatedPath
CompositeStorage::MapFS(const char *uri) const
{
- const ScopeLock protect(mutex);
+ const std::lock_guard<Mutex> protect(mutex);
auto f = FindStorage(uri);
if (f.directory->storage == nullptr)
@@ -348,7 +348,7 @@ CompositeStorage::MapFS(const char *uri) const
const char *
CompositeStorage::MapToRelativeUTF8(const char *uri) const
{
- const ScopeLock protect(mutex);
+ const std::lock_guard<Mutex> protect(mutex);
if (root.storage != nullptr) {
const char *result = root.storage->MapToRelativeUTF8(uri);
diff --git a/src/storage/CompositeStorage.hxx b/src/storage/CompositeStorage.hxx
index 65d96b354..75f4bd744 100644
--- a/src/storage/CompositeStorage.hxx
+++ b/src/storage/CompositeStorage.hxx
@@ -110,7 +110,7 @@ public:
*/
template<typename T>
void VisitMounts(T t) const {
- const ScopeLock protect(mutex);
+ const std::lock_guard<Mutex> protect(mutex);
std::string uri;
VisitMounts(uri, root, t);
}
diff --git a/src/storage/plugins/NfsStorage.cxx b/src/storage/plugins/NfsStorage.cxx
index f4f16edbc..edf9b1b92 100644
--- a/src/storage/plugins/NfsStorage.cxx
+++ b/src/storage/plugins/NfsStorage.cxx
@@ -133,7 +133,7 @@ private:
void SetState(State _state) {
assert(GetEventLoop().IsInside());
- const ScopeLock protect(mutex);
+ const std::lock_guard<Mutex> protect(mutex);
state = _state;
cond.broadcast();
}
@@ -141,7 +141,7 @@ private:
void SetState(State _state, std::exception_ptr &&e) {
assert(GetEventLoop().IsInside());
- const ScopeLock protect(mutex);
+ const std::lock_guard<Mutex> protect(mutex);
state = _state;
last_exception = std::move(e);
cond.broadcast();
@@ -164,7 +164,7 @@ private:
}
void WaitConnected() {
- const ScopeLock protect(mutex);
+ const std::lock_guard<Mutex> protect(mutex);
while (true) {
switch (state) {
diff --git a/src/storage/plugins/SmbclientStorage.cxx b/src/storage/plugins/SmbclientStorage.cxx
index 0fe5b128b..0b4de5683 100644
--- a/src/storage/plugins/SmbclientStorage.cxx
+++ b/src/storage/plugins/SmbclientStorage.cxx
@@ -97,7 +97,7 @@ GetInfo(const char *path)
struct stat st;
{
- const ScopeLock protect(smbclient_mutex);
+ const std::lock_guard<Mutex> protect(smbclient_mutex);
if (smbc_stat(path, &st) != 0)
throw MakeErrno("Failed to access file");
}
@@ -132,7 +132,7 @@ SmbclientStorage::OpenDirectory(const char *uri_utf8)
int handle;
{
- const ScopeLock protect(smbclient_mutex);
+ const std::lock_guard<Mutex> protect(smbclient_mutex);
handle = smbc_opendir(mapped.c_str());
if (handle < 0)
throw MakeErrno("Failed to open directory");
@@ -160,7 +160,7 @@ SmbclientDirectoryReader::~SmbclientDirectoryReader()
const char *
SmbclientDirectoryReader::Read()
{
- const ScopeLock protect(smbclient_mutex);
+ const std::lock_guard<Mutex> protect(smbclient_mutex);
struct smbc_dirent *e;
while ((e = smbc_readdir(handle)) != nullptr) {
@@ -187,7 +187,7 @@ CreateSmbclientStorageURI(gcc_unused EventLoop &event_loop, const char *base)
SmbclientInit();
- const ScopeLock protect(smbclient_mutex);
+ const std::lock_guard<Mutex> protect(smbclient_mutex);
SMBCCTX *ctx = smbc_new_context();
if (ctx == nullptr)
throw MakeErrno("smbc_new_context() failed");
diff --git a/src/tag/ApeLoader.cxx b/src/tag/ApeLoader.cxx
index 2350af9b4..9324c1577 100644
--- a/src/tag/ApeLoader.cxx
+++ b/src/tag/ApeLoader.cxx
@@ -42,7 +42,7 @@ struct ApeFooter {
bool
tag_ape_scan(InputStream &is, ApeTagCallback callback)
try {
- const ScopeLock protect(is.mutex);
+ const std::lock_guard<Mutex> protect(is.mutex);
if (!is.KnownSize() || !is.CheapSeeking())
return false;
diff --git a/src/tag/Id3Load.cxx b/src/tag/Id3Load.cxx
index f443e4207..a0ff42c02 100644
--- a/src/tag/Id3Load.cxx
+++ b/src/tag/Id3Load.cxx
@@ -210,7 +210,7 @@ try {
UniqueId3Tag
tag_id3_load(InputStream &is)
try {
- const ScopeLock protect(is.mutex);
+ const std::lock_guard<Mutex> protect(is.mutex);
auto tag = tag_id3_find_from_beginning(is);
if (tag == nullptr && is.CheapSeeking()) {
diff --git a/src/thread/Mutex.hxx b/src/thread/Mutex.hxx
index 35e0125d8..627c66103 100644
--- a/src/thread/Mutex.hxx
+++ b/src/thread/Mutex.hxx
@@ -44,8 +44,6 @@ class Mutex : public PosixMutex {};
#endif
-using ScopeLock = std::lock_guard<Mutex>;
-
/**
* Within the scope of an instance, this class will keep a #Mutex
* unlocked.
diff --git a/test/dump_text_file.cxx b/test/dump_text_file.cxx
index 918d0a721..b25761dd3 100644
--- a/test/dump_text_file.cxx
+++ b/test/dump_text_file.cxx
@@ -52,7 +52,7 @@ dump_input_stream(InputStreamPtr &&is)
dump_text_file(tis);
}
- const ScopeLock protect(is->mutex);
+ const std::lock_guard<Mutex> protect(is->mutex);
is->Check();
return 0;
diff --git a/test/run_input.cxx b/test/run_input.cxx
index b7212b94c..0e519cd0e 100644
--- a/test/run_input.cxx
+++ b/test/run_input.cxx
@@ -50,7 +50,7 @@ tag_save(FILE *file, const Tag &tag)
static int
dump_input_stream(InputStream *is)
{
- const ScopeLock protect(is->mutex);
+ const std::lock_guard<Mutex> protect(is->mutex);
/* print meta data */
diff --git a/test/test_rewind.cxx b/test/test_rewind.cxx
index d7ae7c8c9..ef417de34 100644
--- a/test/test_rewind.cxx
+++ b/test/test_rewind.cxx
@@ -65,7 +65,7 @@ public:
CPPUNIT_ASSERT(ris != sis);
CPPUNIT_ASSERT(ris != nullptr);
- const ScopeLock protect(mutex);
+ const std::lock_guard<Mutex> protect(mutex);
ris->Update();
CPPUNIT_ASSERT(ris->IsReady());