Skip to main content

Module persistence

Module persistence 

Source
Expand description

This module contains the implementation of the daemon’s queue persistence mechanism.

On shutdown, the daemon will save the current audio state (StateAudio) to disk. This includes:

  • The current position in the queue (usize)
  • The queues repeat mode (RepeatMode)
  • The current seek position in the current song (Duration)
  • The songs in the queue
  • etc.

On startup, the daemon will load that data from disk and use it to restore the queue by:

  1. restoring the repeat mode
  2. setting the volume and mute
  3. loading the songs into the queue
  4. pausing playback
  5. skipping to the correct position in the queue
  6. skipping to the correct position in the current song

we always restore the queue as paused, even if the last state was playing.

Both of these tasks should be atomic, that it, if any step fails the process should be aborted.

  • on startup, this means just logging the error and not restoring the queue
  • on shutdown, this means logging the error and exiting as normal

Structs§

QueueState