decoder/Thread: use ScopeLock for exception-safety

This commit is contained in:
Max Kellermann 2015-12-31 12:11:14 +01:00
parent ac1eaff6ec
commit b62f5e079e

View File

@ -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