Commit ef260377 authored by Max Kellermann's avatar Max Kellermann

decoder/Internal: use ScopeLock

parent b9213df6
...@@ -56,6 +56,13 @@ need_chunks(DecoderControl &dc) ...@@ -56,6 +56,13 @@ need_chunks(DecoderControl &dc)
return dc.command; return dc.command;
} }
static DecoderCommand
LockNeedChunks(DecoderControl &dc)
{
const ScopeLock protect(dc.mutex);
return need_chunks(dc);
}
MusicChunk * MusicChunk *
Decoder::GetChunk() Decoder::GetChunk()
{ {
...@@ -74,9 +81,7 @@ Decoder::GetChunk() ...@@ -74,9 +81,7 @@ Decoder::GetChunk()
return chunk; return chunk;
} }
dc.Lock(); cmd = LockNeedChunks(dc);
cmd = need_chunks(dc);
dc.Unlock();
} while (cmd == DecoderCommand::NONE); } while (cmd == DecoderCommand::NONE);
return nullptr; return nullptr;
...@@ -97,8 +102,7 @@ Decoder::FlushChunk() ...@@ -97,8 +102,7 @@ Decoder::FlushChunk()
chunk = nullptr; chunk = nullptr;
dc.Lock(); const ScopeLock protect(dc.mutex);
if (dc.client_is_waiting) if (dc.client_is_waiting)
dc.client_cond.signal(); dc.client_cond.signal();
dc.Unlock();
} }
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment