summaryrefslogtreecommitdiff
path: root/src/output
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 /src/output
parenta42021655c3218c64272b648438197247ec7f6a9 (diff)
thread/Mutex: remove ScopeLock, use std::lock_guard directly
Diffstat (limited to 'src/output')
-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
10 files changed, 35 insertions, 35 deletions
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();