Skip to content

Rework of the audio player implementation

Alexander Stippich requested to merge astippich/elisa:audioPlayerRework into master

On the basis of !29 (closed), this completely overhauls the audio player implementation. I had the feeling that !29 (closed) was received only as an opportunity to swap the audio backends, which was never the motivation. So I started to implemented the changes I had in mind, which I think are absolutely necessary for certain features, resulting in this large refactoring. This is still not complete and some subsequent cleanup and features will implemented, but the major changes are included. I try to explain the changes and their motivation in more detail.

The major architectural difference is that now the audio player itself is responsible for which track is being played, instead of the playlist that previously set the current track. The audio player is now receiving the previous, current and next tracks from the playlist and is responsible for actually starting the playback and advancing to next tracks. The intermediate class manageaudioplayer is completely removed.

  • Besides the actual playback state of a track, a player state is introduced that indicates the desired state, e.g. if the player wants to play a track or if it is paused or stopped. This has advantages when advancing to the next track: Between the playback of two tracks, there will not be a short blink of the playing button anymore going from pause to play to pause. It will just continue playing. Additionally, power management/inhibition will now only be triggered when audio is truly stopped and not stopped and enabled again between each track.
  • Prepared for gapless playback: since the player knows about the next track, it can be set for audio backends which support gapless playback. Currently, neither QtMultimedia nor libVLC support it :) However, the latency of advancing to a next track is already cut since the next track is known beforehand and some signals are skipped compared to the previous implementation.
  • The player can now be set to the start of the track when pressing the skip-to-previous button depending on the position, since it knows the current position now (Note that there is currently still a bug when no previous track is available, the button is always disabled, which I plan to fix later)
  • As much code as possible is shared between the QtMultimedia and libVLC implementation
  • The player persistent state (position, volume, muted etc.) are now handled in one place.
  • A fake testaudioplayer implementation provides basic testing of all functionality of the base class

BUG: 408295

CCBUG: 414771

CCBUG: 380441

Edited by Alexander Stippich

Merge request reports