Commit 734676fc authored by Max Kellermann's avatar Max Kellermann

decoder_thread: unlock the decoder while checking the stream

This is only a slight change to the previous locking behaviour: keep the decoder unlocked during the loop, and lock it only while checking decoder_control.command.
parent acb265d0
...@@ -121,12 +121,11 @@ decoder_run_song(struct decoder_control *dc, ...@@ -121,12 +121,11 @@ decoder_run_song(struct decoder_control *dc,
return; return;
} }
decoder_lock(dc);
/* 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 */
while (!input_stream.ready) { while (!input_stream.ready) {
decoder_lock(dc);
if (dc->command == DECODE_COMMAND_STOP) { if (dc->command == DECODE_COMMAND_STOP) {
decoder_unlock(dc); decoder_unlock(dc);
input_stream_close(&input_stream); input_stream_close(&input_stream);
...@@ -136,6 +135,7 @@ decoder_run_song(struct decoder_control *dc, ...@@ -136,6 +135,7 @@ decoder_run_song(struct decoder_control *dc,
} }
decoder_unlock(dc); decoder_unlock(dc);
ret = input_stream_buffer(&input_stream); ret = input_stream_buffer(&input_stream);
if (ret < 0) { if (ret < 0) {
input_stream_close(&input_stream); input_stream_close(&input_stream);
...@@ -143,10 +143,10 @@ decoder_run_song(struct decoder_control *dc, ...@@ -143,10 +143,10 @@ decoder_run_song(struct decoder_control *dc,
dc->state = DECODE_STATE_ERROR; dc->state = DECODE_STATE_ERROR;
return; return;
} }
decoder_lock(dc);
} }
decoder_lock(dc);
if (dc->command == DECODE_COMMAND_STOP) { if (dc->command == DECODE_COMMAND_STOP) {
decoder_unlock(dc); decoder_unlock(dc);
input_stream_close(&input_stream); input_stream_close(&input_stream);
......
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