Commit Graph

40 Commits

Author SHA1 Message Date
Anna Schumaker e7ceed9b5d core/library: Improve subdirectory handling for lookup and find
It's possible that the user may pass us a subdirectory of a path that
has already been added to the library.  We can use this to prevent
double-adding tracks if the user does this.  Additionally, this function
can be used to help look up tracks using only a filepath.

Signed-off-by: Anna Schumaker <Anna@NoWheyCreamery.com>
2017-09-05 14:59:43 -04:00
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 85bfe717dd core/tags/library: Remove unused li_size variable
This was used to display the number of tracks in each library path.  We
can use playlist functions to get this information now.

Signed-off-by: Anna Schumaker <Anna@NoWheyCreamery.com>
2016-09-26 08:07:35 -04:00
Anna Schumaker 30cebb4a45 core/tags/library: Remove unused "enabled" field
This was used to enable and disable library paths in previous Ocarina
versions.  This isn't used anymore now that we have library-based
playlists.

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 938bbc92f2 core/tags/library: Add a library_lookup() function
I want a way to lookup library paths without allocating new ones, so
let's add this now.

Signed-off-by: Anna Schumaker <Anna@OcarinaProject.net>
2016-08-13 08:31:30 -04:00
Anna Schumaker 6e02f75262 core/tags/library: Add a pointer to store a playlist
I decided to set this as a void pointer to keep other layers from using
the playlist without our knowledge.  The only user of this variable
should be the playlist code.

Signed-off-by: Anna Schumaker <Anna@OcarinaProject.net>
2016-08-13 08:31:30 -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 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 1b4eb470a7 core/tags/library: Convert file to C
Signed-off-by: Anna Schumaker <Anna@OcarinaProject.net>
2016-01-11 09:35:59 -05:00
Anna Schumaker 62fd782710 core/tags/library: Replace std::string with gchar *
Signed-off-by: Anna Schumaker <Anna@OcarinaProject.net>
2016-01-11 09:35:59 -05:00
Anna Schumaker 5cc4efb6ac core/tags/library: 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 1c0235c8c7 core/tags/generic: Remove Generic tag
Nothing uses it anymore, so it can be safely removed :)

Signed-off-by: Anna Schumaker <Anna@OcarinaProject.net>
2015-12-10 16:48:18 -05:00
Anna Schumaker 446f1228cf core/tags/library: Add library_file() function
To help with finding the full path of files that are located in the
library's directory.

Signed-off-by: Anna Schumaker <Anna@OcarinaProject.net>
2015-12-10 16:41:33 -05:00
Anna Schumaker 24504c7de8 core/tags/library: Remove library size() and {inc|dec}_size() functions
We can just access this variable directly instead.

Signed-off-by: Anna Schumaker <Anna@OcarinaProject.net>
2015-12-10 16:41:33 -05:00
Anna Schumaker ac2b4ad52c core/tags/library: Remove library enabled() function
Signed-off-by: Anna Schumaker <Anna@OcarinaProject.net>
2015-12-10 16:41:33 -05:00
Anna Schumaker 47ab4c4b17 core/tags/library: Move library_set_enabled() out of the library struct
Signed-off-by: Anna Schumaker <Anna@OcarinaProject.net>
2015-12-10 16:41:33 -05:00
Anna Schumaker f41235e5b2 core/tags/library: Replace tags :: library_size() with library_db_get()
It's easier to just pass off the library database rather than forcing
higher layers to iterate over the entire thing (including possible
invalid entries).

Signed-off-by: Anna Schumaker <Anna@OcarinaProject.net>
2015-12-10 16:41:33 -05:00
Anna Schumaker 768f86e802 core/tags/library: Move library_db_init() out of the tags namespace
And add the function library_db_deinit().

Signed-off-by: Anna Schumaker <Anna@OcarinaProject.net>
2015-12-10 16:41:33 -05:00
Anna Schumaker d7cff5faf4 core/tags/library: Move library_remove() out of tags namespace
Signed-off-by: Anna Schumaker <Anna@OcarinaProject.net>
2015-12-10 16:41:33 -05:00
Anna Schumaker a288922b65 core/tags/library: Move library_find() out of the tags namespace
Signed-off-by: Anna Schumaker <Anna@OcarinaProject.net>
2015-12-10 16:41:33 -05:00
Anna Schumaker e1093f7eab core/tags/library: Move library_get() out of the tags namespace
Signed-off-by: Anna Schumaker <Anna@OcarinaProject.net>
2015-12-10 16:41:33 -05:00
Anna Schumaker ffa5e65ba7 core/tags/library: Convert Library class to a struct
I also have to replace the "library" namespace with the "collection"
namespace to avoid naming collisions.

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 f433ced9cb Library: Add functions for looking up or creating Library tags
This patch moves the library_db into tags/library.cpp, where it can be
effectively managed by the Library tag.  For this to work, I need to add
some extra functions to the tags namespace to:

	- Create new Library tags,
	- Find tags by index,
	- Remove the Library at a specific index, and
	- Find the actual size of the library_db.

Signed-off-by: Anna Schumaker <Anna@OcarinaProject.net>
2014-12-04 08:31:51 -05:00
Anna Schumaker d88f008728 Library: Update documentation for the Library tag
I also take the chance to remove the corresponding section of the DESIGN
file.

Signed-off-by: Anna Schumaker <Anna@OcarinaProject.net>
2014-12-04 08:31:51 -05:00
Anna Schumaker ce8b3ada03 Library: Rename count -> _size
Also make it private and provide accessor functions.

Signed-off-by: Anna Schumaker <Anna@OcarinaProject.net>
2014-12-04 08:31:51 -05:00
Anna Schumaker 754d45efd0 Library: Make _enabled private
I added in accessor functions to get and set this value.

Signed-off-by: Anna Schumaker <Anna@OcarinaProject.net>
2014-12-04 08:31:51 -05:00
Anna Schumaker 01e514736e Library Tag: Make root_path private
And just change the name of the variable to "_path".

Signed-off-by: Anna Schumaker <Anna@OcarinaProject.net>
2014-12-04 08:31:51 -05:00
Anna Schumaker 4d6cb81f77 Library: Move the Library tag into a new file
No code or documentation changes yet, just split things out for now.

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