decoder/Thread: move code to DecoderUnlockedRunUri()

This commit is contained in:
Max Kellermann
2016-05-13 13:00:40 +02:00
parent 9252432bc0
commit fe8a13f76f

View File

@@ -344,6 +344,19 @@ decoder_run_file(Decoder &decoder, const char *uri_utf8, Path path_fs)
}); });
} }
/**
* Decode a song.
*
* DecoderControl::mutex is not locked.
*/
static bool
DecoderUnlockedRunUri(Decoder &decoder, const char *real_uri, Path path_fs)
{
return !path_fs.IsNull()
? decoder_run_file(decoder, real_uri, path_fs)
: decoder_run_stream(decoder, real_uri);
}
/** /**
* Decode a song addressed by a #DetachedSong. * Decode a song addressed by a #DetachedSong.
* *
@@ -367,9 +380,7 @@ decoder_run_song(DecoderControl &dc,
{ {
const ScopeUnlock unlock(dc.mutex); const ScopeUnlock unlock(dc.mutex);
success = !path_fs.IsNull() success = DecoderUnlockedRunUri(decoder, uri, path_fs);
? decoder_run_file(decoder, uri, path_fs)
: decoder_run_stream(decoder, uri);
/* flush the last chunk */ /* flush the last chunk */