decoder/Thread: use ScopeLock for exception-safety
This commit is contained in:
parent
ac1eaff6ec
commit
b62f5e079e
@ -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)
|
|||||||
}
|
}
|
||||||
|
|
||||||
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)
|
|||||||
|
|
||||||
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)
|
|||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
} while (dc.command != DecoderCommand::NONE || !dc.quit);
|
} while (dc.command != DecoderCommand::NONE || !dc.quit);
|
||||||
|
|
||||||
dc.Unlock();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
|
Loading…
Reference in New Issue
Block a user