Commit b62f5e07 authored by Max Kellermann's avatar Max Kellermann

decoder/Thread: use ScopeLock for exception-safety

parent ac1eaff6
...@@ -86,7 +86,7 @@ decoder_input_stream_open(DecoderControl &dc, const char *uri) ...@@ -86,7 +86,7 @@ decoder_input_stream_open(DecoderControl &dc, const char *uri)
/* wait for the input stream to become ready; its metadata /* wait for the input stream to become ready; its metadata
will be available then */ will be available then */
dc.Lock(); const ScopeLock protect(dc.mutex);
is->Update(); is->Update();
while (!is->IsReady() && while (!is->IsReady() &&
...@@ -97,14 +97,10 @@ decoder_input_stream_open(DecoderControl &dc, const char *uri) ...@@ -97,14 +97,10 @@ decoder_input_stream_open(DecoderControl &dc, const char *uri)
} }
if (!is->Check(error)) { if (!is->Check(error)) {
dc.Unlock();
LogError(error); LogError(error);
return nullptr; return nullptr;
} }
dc.Unlock();
return is; return is;
} }
...@@ -457,7 +453,7 @@ decoder_task(void *arg) ...@@ -457,7 +453,7 @@ decoder_task(void *arg)
SetThreadName("decoder"); SetThreadName("decoder");
dc.Lock(); const ScopeLock protect(dc.mutex);
do { do {
assert(dc.state == DecoderState::STOP || assert(dc.state == DecoderState::STOP ||
...@@ -493,8 +489,6 @@ decoder_task(void *arg) ...@@ -493,8 +489,6 @@ decoder_task(void *arg)
break; break;
} }
} while (dc.command != DecoderCommand::NONE || !dc.quit); } while (dc.command != DecoderCommand::NONE || !dc.quit);
dc.Unlock();
} }
void void
......
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