Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
M
mpd
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Registry
Registry
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Иван Мажукин
mpd
Commits
2e182e84
Commit
2e182e84
authored
Jan 03, 2017
by
Max Kellermann
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
thread/Mutex: remove ScopeLock, use std::lock_guard directly
parent
a4202165
Hide whitespace changes
Inline
Side-by-side
Showing
51 changed files
with
158 additions
and
160 deletions
+158
-160
IOThread.cxx
src/IOThread.cxx
+1
-1
MusicBuffer.cxx
src/MusicBuffer.cxx
+2
-2
MusicPipe.cxx
src/MusicPipe.cxx
+3
-3
Remove.cxx
src/db/update/Remove.cxx
+2
-2
Bridge.cxx
src/decoder/Bridge.cxx
+7
-7
DecoderControl.cxx
src/decoder/DecoderControl.cxx
+1
-1
DecoderControl.hxx
src/decoder/DecoderControl.hxx
+7
-7
DecoderThread.cxx
src/decoder/DecoderThread.cxx
+7
-7
Loop.cxx
src/event/Loop.cxx
+1
-1
AsyncInputStream.cxx
src/input/AsyncInputStream.cxx
+2
-2
InputStream.cxx
src/input/InputStream.cxx
+7
-7
Open.cxx
src/input/Open.cxx
+1
-1
ThreadInputStream.cxx
src/input/ThreadInputStream.cxx
+2
-2
AlsaInputPlugin.cxx
src/input/plugins/AlsaInputPlugin.cxx
+1
-1
CurlInputPlugin.cxx
src/input/plugins/CurlInputPlugin.cxx
+2
-2
NfsInputPlugin.cxx
src/input/plugins/NfsInputPlugin.cxx
+3
-3
SmbclientInputPlugin.cxx
src/input/plugins/SmbclientInputPlugin.cxx
+1
-1
Converter.cxx
src/lib/icu/Converter.cxx
+2
-2
Blocking.hxx
src/lib/nfs/Blocking.hxx
+2
-2
Init.cxx
src/lib/smbclient/Init.cxx
+1
-1
ClientInit.cxx
src/lib/upnp/ClientInit.cxx
+2
-2
Discovery.cxx
src/lib/upnp/Discovery.cxx
+4
-4
Init.cxx
src/lib/upnp/Init.cxx
+2
-2
WorkQueue.hxx
src/lib/upnp/WorkQueue.hxx
+5
-5
MixerControl.cxx
src/mixer/MixerControl.cxx
+4
-4
SmbclientNeighborPlugin.cxx
src/neighbor/plugins/SmbclientNeighborPlugin.cxx
+2
-2
notify.cxx
src/notify.cxx
+3
-3
Internal.hxx
src/output/Internal.hxx
+1
-1
MultipleOutputs.cxx
src/output/MultipleOutputs.cxx
+4
-4
OutputControl.cxx
src/output/OutputControl.cxx
+9
-9
OutputState.cxx
src/output/OutputState.cxx
+1
-1
OutputThread.cxx
src/output/OutputThread.cxx
+1
-1
RoarOutputPlugin.cxx
src/output/plugins/RoarOutputPlugin.cxx
+6
-6
HttpdClient.cxx
src/output/plugins/httpd/HttpdClient.cxx
+2
-2
HttpdInternal.hxx
src/output/plugins/httpd/HttpdInternal.hxx
+1
-1
HttpdOutputPlugin.cxx
src/output/plugins/httpd/HttpdOutputPlugin.cxx
+6
-6
SlesOutputPlugin.cxx
src/output/plugins/sles/SlesOutputPlugin.cxx
+4
-4
Control.cxx
src/player/Control.cxx
+9
-9
Control.hxx
src/player/Control.hxx
+9
-9
Thread.cxx
src/player/Thread.cxx
+6
-6
SoundCloudPlaylistPlugin.cxx
src/playlist/plugins/SoundCloudPlaylistPlugin.cxx
+1
-1
CompositeStorage.cxx
src/storage/CompositeStorage.cxx
+8
-8
CompositeStorage.hxx
src/storage/CompositeStorage.hxx
+1
-1
NfsStorage.cxx
src/storage/plugins/NfsStorage.cxx
+3
-3
SmbclientStorage.cxx
src/storage/plugins/SmbclientStorage.cxx
+4
-4
ApeLoader.cxx
src/tag/ApeLoader.cxx
+1
-1
Id3Load.cxx
src/tag/Id3Load.cxx
+1
-1
Mutex.hxx
src/thread/Mutex.hxx
+0
-2
dump_text_file.cxx
test/dump_text_file.cxx
+1
-1
run_input.cxx
test/run_input.cxx
+1
-1
test_rewind.cxx
test/test_rewind.cxx
+1
-1
No files found.
src/IOThread.cxx
View file @
2e182e84
...
...
@@ -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
);
}
...
...
src/MusicBuffer.cxx
View file @
2e182e84
...
...
@@ -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
);
...
...
src/MusicPipe.cxx
View file @
2e182e84
...
...
@@ -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
()
||
...
...
src/db/update/Remove.cxx
View file @
2e182e84
...
...
@@ -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
));
}
...
...
src/decoder/Bridge.cxx
View file @
2e182e84
...
...
@@ -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
())
...
...
src/decoder/DecoderControl.cxx
View file @
2e182e84
...
...
@@ -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
...
...
src/decoder/DecoderControl.hxx
View file @
2e182e84
...
...
@@ -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
();
}
...
...
src/decoder/DecoderThread.cxx
View file @
2e182e84
...
...
@@ -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
||
...
...
src/event/Loop.cxx
View file @
2e182e84
...
...
@@ -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
(),
...
...
src/input/AsyncInputStream.cxx
View file @
2e182e84
...
...
@@ -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
;
...
...
src/input/InputStream.cxx
View file @
2e182e84
...
...
@@ -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
();
}
src/input/Open.cxx
View file @
2e182e84
...
...
@@ -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
();
}
...
...
src/input/ThreadInputStream.cxx
View file @
2e182e84
...
...
@@ -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
();
...
...
src/input/plugins/AlsaInputPlugin.cxx
View file @
2e182e84
...
...
@@ -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
;
...
...
src/input/plugins/CurlInputPlugin.cxx
View file @
2e182e84
...
...
@@ -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
();
...
...
src/input/plugins/NfsInputPlugin.cxx
View file @
2e182e84
...
...
@@ -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
...
...
src/input/plugins/SmbclientInputPlugin.cxx
View file @
2e182e84
...
...
@@ -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
)
...
...
src/lib/icu/Converter.cxx
View file @
2e182e84
...
...
@@ -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
);
...
...
src/lib/nfs/Blocking.hxx
View file @
2e182e84
...
...
@@ -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
();
}
...
...
src/lib/smbclient/Init.cxx
View file @
2e182e84
...
...
@@ -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
)
...
...
src/lib/upnp/ClientInit.cxx
View file @
2e182e84
...
...
@@ -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
)
...
...
src/lib/upnp/Discovery.cxx
View file @
2e182e84
...
...
@@ -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
();
...
...
src/lib/upnp/Init.cxx
View file @
2e182e84
...
...
@@ -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
);
...
...
src/lib/upnp/WorkQueue.hxx
View file @
2e182e84
...
...
@@ -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
;
...
...
src/mixer/MixerControl.cxx
View file @
2e182e84
...
...
@@ -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
);
...
...
src/neighbor/plugins/SmbclientNeighborPlugin.cxx
View file @
2e182e84
...
...
@@ -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
;
}
...
...
src/notify.cxx
View file @
2e182e84
...
...
@@ -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
;
}
src/output/Internal.hxx
View file @
2e182e84
...
...
@@ -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
);
}
...
...
src/output/MultipleOutputs.cxx
View file @
2e182e84
...
...
@@ -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
;
...
...
src/output/OutputControl.cxx
View file @
2e182e84
...
...
@@ -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
);
}
}
...
...
src/output/OutputState.cxx
View file @
2e182e84
...
...
@@ -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
());
...
...
src/output/OutputThread.cxx
View file @
2e182e84
...
...
@@ -397,7 +397,7 @@ AudioOutput::Task()
SetThreadTimerSlackUS
(
100
);
const
ScopeLock
lock
(
mutex
);
const
std
::
lock_guard
<
Mutex
>
lock
(
mutex
);
while
(
true
)
{
switch
(
command
)
{
...
...
src/output/plugins/RoarOutputPlugin.cxx
View file @
2e182e84
...
...
@@ -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
];
...
...
src/output/plugins/httpd/HttpdClient.cxx
View file @
2e182e84
...
...
@@ -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
);
...
...
src/output/plugins/httpd/HttpdInternal.hxx
View file @
2e182e84
...
...
@@ -200,7 +200,7 @@ public:
*/
gcc_pure
bool
LockHasClients
()
const
{
const
ScopeLock
protect
(
mutex
);
const
std
::
lock_guard
<
Mutex
>
protect
(
mutex
);
return
HasClients
();
}
...
...
src/output/plugins/httpd/HttpdOutputPlugin.cxx
View file @
2e182e84
...
...
@@ -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
();
...
...
src/output/plugins/sles/SlesOutputPlugin.cxx
View file @
2e182e84
...
...
@@ -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
();
...
...
src/player/Control.cxx
View file @
2e182e84
...
...
@@ -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
);
}
...
...
src/player/Control.hxx
View file @
2e182e84
...
...
@@ -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
;
}
...
...
src/player/Thread.cxx
View file @
2e182e84
...
...
@@ -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
...
...
src/playlist/plugins/SoundCloudPlaylistPlugin.cxx
View file @
2e182e84
...
...
@@ -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
;
...
...
src/storage/CompositeStorage.cxx
View file @
2e182e84
...
...
@@ -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
);
...
...
src/storage/CompositeStorage.hxx
View file @
2e182e84
...
...
@@ -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
);
}
...
...
src/storage/plugins/NfsStorage.cxx
View file @
2e182e84
...
...
@@ -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
)
{
...
...
src/storage/plugins/SmbclientStorage.cxx
View file @
2e182e84
...
...
@@ -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"
);
...
...
src/tag/ApeLoader.cxx
View file @
2e182e84
...
...
@@ -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
;
...
...
src/tag/Id3Load.cxx
View file @
2e182e84
...
...
@@ -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
())
{
...
...
src/thread/Mutex.hxx
View file @
2e182e84
...
...
@@ -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.
...
...
test/dump_text_file.cxx
View file @
2e182e84
...
...
@@ -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
;
...
...
test/run_input.cxx
View file @
2e182e84
...
...
@@ -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 */
...
...
test/test_rewind.cxx
View file @
2e182e84
...
...
@@ -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
());
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment