From b62f5e079e8a5b0ff0f2ea732e6e86cd75a19f37 Mon Sep 17 00:00:00 2001 From: Max Kellermann Date: Thu, 31 Dec 2015 12:11:14 +0100 Subject: [PATCH] decoder/Thread: use ScopeLock for exception-safety --- src/decoder/DecoderThread.cxx | 10 ++-------- 1 file changed, 2 insertions(+), 8 deletions(-) diff --git a/src/decoder/DecoderThread.cxx b/src/decoder/DecoderThread.cxx index 2a7275a68..34696edb0 100644 --- a/src/decoder/DecoderThread.cxx +++ b/src/decoder/DecoderThread.cxx @@ -86,7 +86,7 @@ decoder_input_stream_open(DecoderControl &dc, const char *uri) /* wait for the input stream to become ready; its metadata will be available then */ - dc.Lock(); + const ScopeLock protect(dc.mutex); is->Update(); while (!is->IsReady() && @@ -97,14 +97,10 @@ decoder_input_stream_open(DecoderControl &dc, const char *uri) } if (!is->Check(error)) { - dc.Unlock(); - LogError(error); return nullptr; } - dc.Unlock(); - return is; } @@ -457,7 +453,7 @@ decoder_task(void *arg) SetThreadName("decoder"); - dc.Lock(); + const ScopeLock protect(dc.mutex); do { assert(dc.state == DecoderState::STOP || @@ -493,8 +489,6 @@ decoder_task(void *arg) break; } } while (dc.command != DecoderCommand::NONE || !dc.quit); - - dc.Unlock(); } void