diff options
author | Max Kellermann <max@musicpd.org> | 2016-12-03 14:20:51 +0100 |
---|---|---|
committer | Max Kellermann <max@musicpd.org> | 2016-12-03 14:20:51 +0100 |
commit | b3723274f7624b19e0979ba4b22f8257f50da331 (patch) | |
tree | 7a5b84f2156668eb99a36fc5e42a2630affc1256 /src | |
parent | 9fb7cc796b34f9faf8fa50354102a875e73fa476 (diff) |
decoder/Bridge: move code to DecoderControl::SetReady()
Diffstat (limited to 'src')
-rw-r--r-- | src/decoder/Bridge.cxx | 23 | ||||
-rw-r--r-- | src/decoder/DecoderControl.cxx | 21 | ||||
-rw-r--r-- | src/decoder/DecoderControl.hxx | 9 |
3 files changed, 36 insertions, 17 deletions
diff --git a/src/decoder/Bridge.cxx b/src/decoder/Bridge.cxx index db606b9d2..593cee26a 100644 --- a/src/decoder/Bridge.cxx +++ b/src/decoder/Bridge.cxx @@ -248,27 +248,20 @@ DecoderBridge::Ready(const AudioFormat audio_format, { struct audio_format_string af_string; - assert(dc.state == DecoderState::START); - assert(dc.pipe != nullptr); - assert(dc.pipe->IsEmpty()); assert(convert == nullptr); assert(stream_tag == nullptr); assert(decoder_tag == nullptr); assert(!seeking); - assert(audio_format.IsDefined()); - assert(audio_format.IsValid()); - - dc.in_audio_format = audio_format; - dc.out_audio_format = audio_format; - dc.out_audio_format.ApplyMask(dc.configured_audio_format); - - dc.seekable = seekable; - dc.total_time = duration; FormatDebug(decoder_domain, "audio_format=%s, seekable=%s", - audio_format_to_string(dc.in_audio_format, &af_string), + audio_format_to_string(audio_format, &af_string), seekable ? "true" : "false"); + { + const ScopeLock protect(dc.mutex); + dc.SetReady(audio_format, seekable, duration); + } + if (dc.in_audio_format != dc.out_audio_format) { FormatDebug(decoder_domain, "converting to %s", audio_format_to_string(dc.out_audio_format, @@ -283,10 +276,6 @@ DecoderBridge::Ready(const AudioFormat audio_format, error = std::current_exception(); } } - - const ScopeLock protect(dc.mutex); - dc.state = DecoderState::DECODE; - dc.client_cond.signal(); } DecoderCommand diff --git a/src/decoder/DecoderControl.cxx b/src/decoder/DecoderControl.cxx index 6bb80c7da..f2915a3f7 100644 --- a/src/decoder/DecoderControl.cxx +++ b/src/decoder/DecoderControl.cxx @@ -53,6 +53,27 @@ DecoderControl::WaitForDecoder() client_is_waiting = false; } +void +DecoderControl::SetReady(const AudioFormat audio_format, + bool _seekable, SignedSongTime _duration) +{ + assert(state == DecoderState::START); + assert(pipe != nullptr); + assert(pipe->IsEmpty()); + assert(audio_format.IsDefined()); + assert(audio_format.IsValid()); + + in_audio_format = audio_format; + out_audio_format = audio_format; + out_audio_format.ApplyMask(configured_audio_format); + + seekable = _seekable; + total_time = _duration; + + state = DecoderState::DECODE; + client_cond.signal(); +} + bool DecoderControl::IsCurrentSong(const DetachedSong &_song) const { diff --git a/src/decoder/DecoderControl.hxx b/src/decoder/DecoderControl.hxx index 9edaa44a7..d21b0e2dc 100644 --- a/src/decoder/DecoderControl.hxx +++ b/src/decoder/DecoderControl.hxx @@ -255,6 +255,15 @@ struct DecoderControl { } /** + * Transition this obejct from DecoderState::START to + * DecoderState::DECODE. + * + * Caller must lock the object. + */ + void SetReady(const AudioFormat audio_format, + bool _seekable, SignedSongTime _duration); + + /** * Checks whether an error has occurred, and if so, rethrows * it. * |