Commit Graph

38 Commits

Author SHA1 Message Date
Anna Schumaker d6e5e6c773 core: Defragment databases on startup
Databases can change either as part of an upgrade or through adding and
removing entries.  We can save a bit of memory by removing unallocated
entries during startup.

Implements #47: Automatic database defragment
Signed-off-by: Anna Schumaker <Anna@NoWheyCreamery.com>
2016-09-26 08:07:35 -04:00
Anna Schumaker 0cefd158d9 core/tags/album: Add artist and genre information to saved data
And perform an upgrade when reading back in.  After track tags are read,
we can save the database in the new format and remove the old tags.

Signed-off-by: Anna Schumaker <Anna@NoWheyCreamery.com>
2016-09-26 08:07:35 -04:00
Anna Schumaker 0ea75ccb29 core/tags/album: Add artist and genre arguments to album_find()
And propegate these through the alloc steps to create an album with the
correct artist and genre tags set.

Signed-off-by: Anna Schumaker <Anna@NoWheyCreamery.com>
2016-09-26 08:07:35 -04:00
Anna Schumaker c2178bc265 core: Cut back on hardcoded dbe_index uses
The dbe_index of a given database item might change in the future, so we
can't rely on it everywhere.  Let's just use it for saving and loading
files, with the expectation that changes will happen sometime after
startup.

Implements #69: Reduce use of dbe_index in Ocarina code
Signed-off-by: Anna Schumaker <Anna@NoWheyCreamery.com>
2016-09-11 10:50:45 -04:00
Anna Schumaker 65b547f60b core/tags/album: Add pointer to genre tag
Albums tend to have a single genre for all tracks, so it makes more
sense for an album to point to genre information.

Signed-off-by: Anna Schumaker <Anna@NoWheyCreamery.com>
2016-09-11 10:25:43 -04:00
Anna Schumaker be29f53eaa core/tags/album: Add album_match_token() function
This is called to check if any string in an album's token list is
prefixed by the given string.

Signed-off-by: Anna Schumaker <Anna@OcarinaProject.net>
2016-08-29 07:32:59 -04:00
Anna Schumaker c3bc8e9c02 core/tags/album: Convert lowercased string into tokens
Signed-off-by: Anna Schumaker <Anna@OcarinaProject.net>
2016-08-29 07:32:59 -04:00
Anna Schumaker 92a53d90b4 core/database: Move database out of containers/ subdirectory
It doesn't make sense to have a subdirectory with a single file.  Let's
move it back to core/

Implements #45: Move database into core/
Signed-off-by: Anna Schumaker <Anna@OcarinaProject.net>
2016-07-29 17:06:01 -04:00
Anna Schumaker e30f7f8115 core/tags/album: Add support for importing album artwork
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>
2016-07-12 14:36:40 -04:00
Anna Schumaker d0dddeacdb core/tags/album: Add album_artwork_path() function
Signed-off-by: Anna Schumaker <Anna@OcarinaProject.net>
2016-06-24 10:50:37 -04:00
Anna Schumaker d79eb2c9b8 core/tags/album: Add album_artwork_exists() function
Signed-off-by: Anna Schumaker <Anna@OcarinaProject.net>
2016-06-24 10:50:37 -04:00
Anna Schumaker 0d9b7baff6 core/tags/album: Add a pointer to the struct artist
This is needed for album art fetching to get more accurate results for
our MusicBrainz query.

Signed-off-by: Anna Schumaker <Anna@OcarinaProject.net>
2016-06-24 10:50:37 -04:00
Anna Schumaker 9a16a18b9f core/tags/album: Add an album_compare_year() function
With special handling for albums with the same year but different names.

Signed-off-by: Anna Schumaker <Anna@OcarinaProject.net>
2016-01-15 15:10:44 -05:00
Anna Schumaker c34f0c160d core/containers: Move database into the containers/ directory
Signed-off-by: Anna Schumaker <Anna@OcarinaProject.net>
2016-01-15 15:10:44 -05:00
Anna Schumaker 5309ea5931 core/tags/album: Convert file to C
Signed-off-by: Anna Schumaker <Anna@OcarinaProject.net>
2016-01-11 09:35:59 -05:00
Anna Schumaker ad48d24533 core/tags/album: Replace std::string with gchar *
Signed-off-by: Anna Schumaker <Anna@OcarinaProject.net>
2016-01-11 09:35:59 -05:00
Anna Schumaker 7c3bba11b5 core/tags/album: Replace constructor with a backwards pointer
Signed-off-by: Anna Schumaker <Anna@OcarinaProject.net>
2016-01-11 09:35:59 -05:00
Anna Schumaker 877d9ac1d7 core/database: Convert file to C
Signed-off-by: Anna Schumaker <Anna@OcarinaProject.net>
2015-12-10 16:48:19 -05:00
Anna Schumaker 4a4529b158 core/database: Replace std::map with a glib hash table
Signed-off-by: Anna Schumaker <Anna@OcarinaProject.net>
2015-12-10 16:48:19 -05:00
Anna Schumaker 1c22ecfda4 core/database: De-templatize the database
We now have an interface for controlling everything through struct
db_entry, so let's just have the database store a db_entry directly.

Signed-off-by: Anna Schumaker <Anna@OcarinaProject.net>
2015-12-10 16:48:18 -05:00
Anna Schumaker 1bef380ba7 core/database: Introduce the dbe_key() database operation
And store the result in the db_entry struct for use later.

Signed-off-by: Anna Schumaker <Anna@OcarinaProject.net>
2015-12-10 16:48:18 -05:00
Anna Schumaker f51852f62e core/database: Introduce the dbe_write() database operation
For writing database entries to disk.

Signed-off-by: Anna Schumaker <Anna@OcarinaProject.net>
2015-12-10 16:48:18 -05:00
Anna Schumaker 2da33f1c75 core/database: Introduce the dbe_read() database operation
This function allocates and returns a new database entry using
information read from a file.

Signed-off-by: Anna Schumaker <Anna@OcarinaProject.net>
2015-12-10 16:48:18 -05:00
Anna Schumaker 049156a523 core/database: Introduce the dbe_alloc() database operation
For allocating new database items from a given key.  Tracks do not need
this function since we have special handling for creation and insertion.

Signed-off-by: Anna Schumaker <Anna@OcarinaProject.net>
2015-12-10 16:48:18 -05:00
Anna Schumaker ab1572ed34 core/database: Add operations vector
I intend to replace C++ inheritance with this struct of function
pointers.

Signed-off-by: Anna Schumaker <Anna@OcarinaProject.net>
2015-12-10 16:48:18 -05:00
Anna Schumaker 3eb27debfb core/database: Convert DatabaseEntry class into a struct
Signed-off-by: Anna Schumaker <Anna@OcarinaProject.net>
2015-12-10 16:48:18 -05:00
Anna Schumaker 928c215494 core/tags/album: Clean up constructors
Remove an unused constructor and share code between everything left.

Signed-off-by: Anna Schumaker <Anna@OcarinaProject.net>
2015-12-10 16:41:33 -05:00
Anna Schumaker e5b0047812 core/tags/album: Directly inherit from DatabaseEntry
Signed-off-by: Anna Schumaker <Anna@OcarinaProject.net>
2015-12-10 16:41:33 -05:00
Anna Schumaker a7746cf901 core/tags/album: Remove album::year() function
Signed-off-by: Anna Schumaker <Anna@OcarinaProject.net>
2015-12-10 16:41:33 -05:00
Anna Schumaker abe12bac64 core/tags/album: Move album_db_init() out of the tags namespace
And add the function album_db_deinit().

Signed-off-by: Anna Schumaker <Anna@OcarinaProject.net>
2015-12-10 16:41:33 -05:00
Anna Schumaker 0fa2d8acc2 core/tags/album: Move album_find() out of the tags namespace
Signed-off-by: Anna Schumaker <Anna@OcarinaProject.net>
2015-12-10 16:41:33 -05:00
Anna Schumaker 1f5668bd72 core/tags/album: Move album_get() out of the tags namespace
Signed-off-by: Anna Schumaker <Anna@OcarinaProject.net>
2015-12-10 16:41:33 -05:00
Anna Schumaker e6bdf65606 core/tags/album: Convert Album class to a struct
Signed-off-by: Anna Schumaker <Anna@OcarinaProject.net>
2015-12-10 16:41:33 -05:00
Anna Schumaker ffd38bd28b core/database: Move db_find() out of the database struct
I also take the chance to modify this function slightly.  Now, if a
matching item could not be found a new item will be allocated.

I added the new function db_get() if callers just want to get an item
without allocating.

Signed-off-by: Anna Schumaker <Anna@OcarinaProject.net>
2015-12-10 16:41:33 -05:00
Anna Schumaker 1dcc56c87e core/file: Convert class to a struct
In addition, we lowercase variable names and add an f_ prefix to all
struct mebers.

Signed-off-by: Anna Schumaker <Anna@OcarinaProject.net>
2015-10-07 10:39:51 -04:00
Anna Schumaker ead1397b31 Remove Doxygen tags
I wasn't actually using Doxygen for anything, so it's probably best just
to remove it.

Signed-off-by: Anna Schumaker <Anna@OcarinaProject.net>
2015-09-02 14:24:42 -04:00
Anna Schumaker 7d3e9a3d28 Album: Add functions for looking up or creating Album tags
The album_db should really be controlled from within the Album tag, so
this patch adds functions to find or create Album tags to the tags
namespace.

Signed-off-by: Anna Schumaker <Anna@OcarinaProject.net>
2014-12-04 08:31:51 -05:00
Anna Schumaker 2d9d87afc9 Album: Move Album tag into a new file
Also make it inherit from the GenericTag base class.  Also also, add a
unit test specific to Album tags.  Finally, I remove the corresponding
section of the DESIGN file since it is no longer needed.

Signed-off-by: Anna Schumaker <Anna@OcarinaProject.net>
2014-12-04 08:31:49 -05:00