I think this is cleaner than having an upper layer allocate the results
set manually. This also lets me return NULL in the case that there were
no results.
Signed-off-by: Anna Schumaker <Anna@OcarinaProject.net>
I was storing database indexes, but this assumes that database indexes
are constant. I intend to change this with database defragmentation.
Implements #46: Filter stores a track pointer
Signed-off-by: Anna Schumaker <Anna@OcarinaProject.net>
This is used to remove tracks from the filtering index. We'll need this
once we switch over to storing pointers to keep the same track from
getting added multiple times.
Signed-off-by: Anna Schumaker <Anna@OcarinaProject.net>
This is more straightforward than using my custom index code without
adding too much work.
Implements #43: Filter code can use a GHashTable directly
Signed-off-by: Anna Schumaker <Anna@OcarinaProject.net>
The thread pool is used to fetch album art in the background, but this
can slow down most tests that aren't interested in album art. Adding a
(testing-only) function for running without the thread pool speeds
things up a bit.
Signed-off-by: Anna Schumaker <Anna@NoWheyCreamery.com>
I intend to use this for creating playlists with different properties,
such as using the playlist interface to add library paths.
Signed-off-by: Anna Schumaker <Anna@OcarinaProject.net>
I want to manage this container on my own, rather than relying on the
generic index code. This will eventually make it easier to store a
playlist as a queue, instead of a set.
Signed-off-by: Anna Schumaker <Anna@OcarinaProject.net>
This flag is used for bulk inserts to cut down on the number of gui
operations during startup. Let's just make it standard that unsetting
the flag causes the queue to resort itself.
Signed-off-by: Anna Schumaker <Anna@OcarinaProject.net>
- Allocate CaaCoverArt as needed, rather than sharing one object
- Use MusicBrainz fuzzy search to match more albums
- Escape most special characters in filenames
Signed-off-by: Anna Schumaker <Anna@OcarinaProject.net>
Reusing the Mb5Query can have undesireable side effects, such as the
error code not getting reset between queries. Fix this by allocating a
new Mb5Query before evey request.
Signed-off-by: Anna Schumaker <Anna@OcarinaProject.net>
This is needed so the user can manually set album artwork in the cases
where either we don't fetch the right image or no image is found.
Signed-off-by: Anna Schumaker <Anna@OcarinaProject.net>
I think this results in a slightly better search, although there are
still a few wrong images fetched.
Signed-off-by: Anna Schumaker <Anna@OcarinaProject.net>
If searching for artist and album fails, then fall back on album and
year or even just album name.
Signed-off-by: Anna Schumaker <Anna@OcarinaProject.net>
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>
This replaces the is_playing() function of the AudioDriver class. I can
also make the GUIs GstDriver static.
Signed-off-by: Anna Schumaker <Anna@OcarinaProject.net>
Dividing queue size by 3 seems to give a better distribution of tracks,
but only for a large set of tracks (such as the entire collection).
let's skip the division if the queue only has a small number of tracks.
Signed-off-by: Anna Schumaker <Anna@OcarinaProject.net>
I was assuming that my disk returns -EIO when it enters its failed
state, but it really seems to be return -ENOENT. Let's have this code
check for any error, rather than one specific one.
Signed-off-by: Anna Schumaker <Anna@OcarinaProject.net>
One of my disks frequently returns this error, and has wiped out my
track database on more than one occasion. Let's handle this error by
disabling the library until the user tells us it is safe to use again.
Fixes#33: Handle music directories disappearing better
Signed-off-by: Anna Schumaker <Anna@OcarinaProject.net>
We were returning right away if the file version check fails, without
closing the file. This could cause future reads or writes to fail to
open.
Fixes#25: File version checking doesn't look quite right
Signed-off-by: Anna Schumaker <Anna@OcarinaProject.net>
I also take this opportunity to drop support for upgrading from file
format 0. I've had several releases since this format was supported, so
this should be safe to do.
Signed-off-by: Anna Schumaker <Anna@OcarinaProject.net>
I decided that having a uniqueue history queue doesn't really get me
anything, so I dropped that portion of the behavior.
Signed-off-by: Anna Schumaker <Anna@OcarinaProject.net>
This function is used to cancel all idle tasks and free the memory
allocated for them. This needs to be called when Ocarina is shutting
down to prevent a possible hang with the gtk idle callback continuing to
process tasks.
Fixes#30: Closing Ocarina should cancel idle tasks
Signed-off-by: Anna Schumaker <Anna@OcarinaProject.net>
"Banning" a track is a bit harsh. Let's talking about hiding tracks
instead, so that it sounds friendlier.
Signed-off-by: Anna Schumaker <Anna@OcarinaProject.net>
I think it makes more sense to have the collection manage if banned
tracks are displayed or not, rather than doing this from the playlist
layer.
Signed-off-by: Anna Schumaker <Anna@OcarinaProject.net>
There is at least one place in the gui where it needs to know if a track
was actually added to a playlist. Adding a return value is the best way
to know what happened.
Signed-off-by: Anna Schumaker <Anna@OcarinaProject.net>
This is much more convenient to users, since they don't need to update
the collection manually.
Signed-off-by: Anna Schumaker <Anna@OcarinaProject.net>
This patch breaks later tests, since I needed to remove the old ogg
files. This will be fixed in a few more patches.
Signed-off-by: Anna Schumaker <Anna@OcarinaProject.net>
I needed to bump the track comparison fields by one so I can use signed
values to indicate sort order. I updated core/library.cpp to add and
subtract one as needed.
Signed-off-by: Anna Schumaker <Anna@OcarinaProject.net>
These functions are only used by temporary queues, and the collection
queue has its own save function.
Signed-off-by: Anna Schumaker <Anna@OcarinaProject.net>
And a function to help with saving queues. This patch also adds the
Q_SAVE_FLAGS and Q_SAVE_SORT queue flags to control if the queue should
be saved when flags are changed or when the queue is sorted.
Signed-off-by: Anna Schumaker <Anna@OcarinaProject.net>