The SetTrack event is sent when *decoding* finishes, not when
*playback* finishes so the decoder can start buffering the next
track in advance of its playback to ensure gapless playback.
Clearing StreamCues causes
Playback::react(const internal::StreamHeartbeat& ev)
to transit the Playback FSM to Standby, which sets the
IAudioOutput to stop reading from the output buffer. Thus,
clearing StreamCues in response to the SetTrack event paused
playback with the end of the track stuck waiting in the output
buffer. When a new queue was loaded and started playing, the
end of the previous track would be played before the new track
was played.
Fixes https://codeberg.org/cool-tech-zone/tangara-fw/issues/313
Queue now has a separate 'ready' property to indicate it's ready to be used, which is independent from whether it's still loading tracks in. This also improves the response time for shuffling all tracks (we will initially pick a random track in the first 100 tracks whilst the rest of the tracks are loading). This should also fix issues where one song will start playing and then repeat itself when the queue finishes loading, and hopefully solve #160 as well (though I couldn't actually repro this myself).
Co-authored-by: jacqueline <me@jacqueline.id.au>
Reviewed-on: https://codeberg.org/cool-tech-zone/tangara-fw/pulls/170
Reviewed-by: cooljqln <cooljqln@noreply.codeberg.org>
Co-authored-by: ailurux <ailuruxx@gmail.com>
Co-committed-by: ailurux <ailuruxx@gmail.com>
I think this is what most folks would expect to happen if BT is
disconnected/disabled and the headphones are removed.
Also, I think(?) this fixes one situation where the device doesn't idle/
sleep when folks would expect it to (not connected to headphones or bt).
It's currently quite limited (no stereo or sample rate conversion,
multiple messages clobber each other, only plays if music is playing),
but we're getting there!
This allows the audio pipeline to remain responsive even when the drain
buffer has completely filled. This in turn means that you now see the
track info in the 'now playing' screen change if the current track
changes whilst you are paused.
Since I was fucking around a lot in the audio processor anyway, I also
added mono->stereo expansion so that playing mono tracks on Bluetooth no
longer destroys your ears.