decoder/Thread: mutex not locked for decoder_run_{file,stream}()

This commit is contained in:
Max Kellermann 2015-12-31 12:42:02 +01:00
parent 55e113c7a7
commit dc76eb6139

View File

@ -269,20 +269,16 @@ decoder_run_stream_fallback(Decoder &decoder, InputStream &is)
/** /**
* Try decoding a stream. * Try decoding a stream.
* *
* Caller holds DecoderControl::mutex. * DecoderControl::mutex is not locked by caller.
*/ */
static bool static bool
decoder_run_stream(Decoder &decoder, const char *uri) decoder_run_stream(Decoder &decoder, const char *uri)
{ {
DecoderControl &dc = decoder.dc; DecoderControl &dc = decoder.dc;
dc.Unlock();
InputStream *input_stream = decoder_input_stream_open(dc, uri); InputStream *input_stream = decoder_input_stream_open(dc, uri);
if (input_stream == nullptr) { if (input_stream == nullptr)
dc.Lock();
return false; return false;
}
dc.Lock(); dc.Lock();
@ -297,7 +293,6 @@ decoder_run_stream(Decoder &decoder, const char *uri)
dc.Unlock(); dc.Unlock();
delete input_stream; delete input_stream;
dc.Lock();
return success; return success;
} }
@ -363,7 +358,7 @@ TryDecoderFile(Decoder &decoder, Path path_fs, const char *suffix,
/** /**
* Try decoding a file. * Try decoding a file.
* *
* Caller holds DecoderControl::mutex. * DecoderControl::mutex is not locked by caller.
*/ */
static bool static bool
decoder_run_file(Decoder &decoder, const char *uri_utf8, Path path_fs) decoder_run_file(Decoder &decoder, const char *uri_utf8, Path path_fs)
@ -373,7 +368,6 @@ decoder_run_file(Decoder &decoder, const char *uri_utf8, Path path_fs)
return false; return false;
DecoderControl &dc = decoder.dc; DecoderControl &dc = decoder.dc;
dc.Unlock();
decoder_load_replay_gain(decoder, path_fs); decoder_load_replay_gain(decoder, path_fs);
@ -382,10 +376,11 @@ decoder_run_file(Decoder &decoder, const char *uri_utf8, Path path_fs)
return TryDecoderFile(decoder, return TryDecoderFile(decoder,
path_fs, suffix, path_fs, suffix,
plugin); plugin);
})) })) {
dc.Unlock();
return true; return true;
}
dc.Lock();
return false; return false;
} }
@ -409,12 +404,12 @@ decoder_run_song(DecoderControl &dc,
decoder_command_finished_locked(dc); decoder_command_finished_locked(dc);
dc.Unlock();
const int ret = !path_fs.IsNull() const int ret = !path_fs.IsNull()
? decoder_run_file(decoder, uri, path_fs) ? decoder_run_file(decoder, uri, path_fs)
: decoder_run_stream(decoder, uri); : decoder_run_stream(decoder, uri);
dc.Unlock();
/* flush the last chunk */ /* flush the last chunk */
if (decoder.chunk != nullptr) if (decoder.chunk != nullptr)