I don't think it makes sense that callers of file_open() are expected to
check the file version after opening. This should be something handled
by the file code so we can print a consistent error message.
Implements issue #5: Better file versioning
Signed-off-by: Anna Schumaker <Anna@OcarinaProject.net>
I want to be able to print any message as an error message without
relying on errno. Let's handle this by introducing REPORT_ERRNO() to
look up the right error message for a given errno.
Signed-off-by: Anna Schumaker <Anna@OcarinaProject.net>
And then rename the temporary file when closed. This protects users
data in case Ocarina gets killed.
Implements issue #31: Make file writes seem atomic
Signed-off-by: Anna Schumaker <Anna@OcarinaProject.net>
There are enough differences in the read and write paths that
__file_open_common() was still trying to account for. Let's make a
simpler wrapper around g_fopen() and move differing code into
__file_open_read() and __file_open_write().
Signed-off-by: Anna Schumaker <Anna@OcarinaProject.net>
I'm only setting this to a static string, so it doesn't make sense to
store this as a char array. Let's use a string pointer instead.
Signed-off-by: Anna Schumaker <Anna@OcarinaProject.net>
I'm going to use this for saving album art to the right place. I moved
it into an include file to avoid duplicating code.
Signed-off-by: Anna Schumaker <Anna@OcarinaProject.net>
The track database now tallys total play count and unplayed track count,
so we can use this information for calculating averages. I also changed
the least played tracks playlist to allow tracks with play count equal
to the average.
Signed-off-by: Anna Schumaker <Anna@OcarinaProject.net>
This function returns the average count of tracks that have been played,
and not the average count of all tracks.
Implements #29: Efficiently calculate average play count of tracks
Signed-off-by: Anna Schumaker <Anna@OcarinaProject.net>
I no longer need these now that the queue is using the glib
g_random_int_range() function.
Implements #32: Remove custom RNG code
Signed-off-by: Anna Schumaker <Anna@OcarinaProject.net>
Using somebody else's library is probably better than relying on my own
random number function.
Implements #32: Remove custom RNG code
Signed-off-by: Anna Schumaker <Anna@OcarinaProject.net>
Load all tag databases with the new load function.
Implements #15: Load track database through an idle task
Implements #16: Load library database through an idle task
Implements #17: Load genre database through an idle task
Implements #18: Load artist database through an idle task
Implements #19: Load album database through an idle task
Signed-off-by: Anna Schumaker <Anna@OcarinaProject.net>
Scan over all tracks in the database first, and then schedule a
collection update.
Implements #13: Load collection queue through an idle task
Signed-off-by: Anna Schumaker <Anna@OcarinaProject.net>
This will help reduce disk accesses during thet main startup sequence.
Implements #12: Load temporary queues through an idle task
Signed-off-by: Anna Schumaker <Anna@OcarinaProject.net>
Let's save this disk access for when we're idle.
Implements #11: Load initial track through an idle task
Signed-off-by: Anna Schumaker <Anna@OcarinaProject.net>
I need to do this for temporary queues in addition to the collection for
bolding to work properly.
Signed-off-by: Anna Schumaker <Anna@OcarinaProject.net>
This function is similar to queue_remove(), except the remove can be
prevented if qop_erase() returns false.
Signed-off-by: Anna Schumaker <Anna@OcarinaProject.net>
We don't need different operations for each queue. If we store this
then a higher layer doesn't need to keep passing the same structure over
and over again.
Signed-off-by: Anna Schumaker <Anna@OcarinaProject.net>
Enabling all queues by default, even ones read from disk, is incorrect
as it leads to all queues getting reenabled when restarting Ocarina.
Fixes#56: Enabled status of temporary queues not saving
Signed-off-by: Anna Schumaker <Anna@OcarinaProject.net>
This function is used to notify a higher layer that a queue is being
deinitialized. The higher layer should then clean up any state
associated with that queue.
Signed-off-by: Anna Schumaker <Anna@OcarinaProject.net>
This function is used to notify a higher layer that a queue has been
initialized. That higher layer can return a pointer to be attached to
the "private data" field of the queue.
Signed-off-by: Anna Schumaker <Anna@OcarinaProject.net>
It's better to have a single function loading tracks and adding them to
the history queue.
Fixes#2: Initial track not added to history
Signed-off-by: Anna Schumaker <Anna@OcarinaProject.net>
6.4.8 changed how random tracks are selected, but never updated the unit
test. This patch fixes the unit test, and makes a few changes to make
sure the right tracks are getting selected.
Signed-off-by: Anna Schumaker <Anna@OcarinaProject.net>
The GUI needed an extra function to do this manually, which means it's
something that core should do instead.
Signed-off-by: Anna Schumaker <Anna@OcarinaProject.net>