diff options
author | Max Kellermann <max@duempel.org> | 2015-12-31 13:44:19 +0100 |
---|---|---|
committer | Max Kellermann <max@duempel.org> | 2015-12-31 13:44:19 +0100 |
commit | ef260377c37b55514af25491f66e9e61f0e93c43 (patch) | |
tree | 2b22bb40e4eb53da3d89b75b0c850b1ecb1cfbed | |
parent | b9213df64ba15c1d078903fa471879e20c86c213 (diff) |
decoder/Internal: use ScopeLock
-rw-r--r-- | src/decoder/DecoderInternal.cxx | 14 |
1 files changed, 9 insertions, 5 deletions
diff --git a/src/decoder/DecoderInternal.cxx b/src/decoder/DecoderInternal.cxx index f0bb04125..ee14f4c4d 100644 --- a/src/decoder/DecoderInternal.cxx +++ b/src/decoder/DecoderInternal.cxx @@ -56,6 +56,13 @@ need_chunks(DecoderControl &dc) return dc.command; } +static DecoderCommand +LockNeedChunks(DecoderControl &dc) +{ + const ScopeLock protect(dc.mutex); + return need_chunks(dc); +} + MusicChunk * Decoder::GetChunk() { @@ -74,9 +81,7 @@ Decoder::GetChunk() return chunk; } - dc.Lock(); - cmd = need_chunks(dc); - dc.Unlock(); + cmd = LockNeedChunks(dc); } while (cmd == DecoderCommand::NONE); return nullptr; @@ -97,8 +102,7 @@ Decoder::FlushChunk() chunk = nullptr; - dc.Lock(); + const ScopeLock protect(dc.mutex); if (dc.client_is_waiting) dc.client_cond.signal(); - dc.Unlock(); } |