Commit Graph

226 Commits

Author SHA1 Message Date
Anna Schumaker cce8666140 core/tags/album: Check for empty artist names before fetching album art
Otherwise we might crash when we attempt to look at ar_tokens[0].

Reported-by: Josh Larson <themutatedshrimp@gmail.com>
Signed-off-by: Anna Schumaker <Anna@NoWheyCreamery.com>
2018-02-28 10:28:59 -05:00
Anna Schumaker 59506d45e7 core/file: Rename cache_file_import() -> file_import()
Signed-off-by: Anna Schumaker <Anna@NoWheyCreamery.com>
2018-02-27 08:25:40 -05:00
Anna Schumaker e1f13a7ef4 core/file: Create new functions for reading data from files
The readd(), readu(), and readhu() functions are all used to read
various forms of integers.  The readl() and readw() are for reading
either lines or individual whitespace-delimited words

Signed-off-by: Anna Schumaker <Anna@NoWheyCreamery.com>
2018-02-21 16:01:15 -05:00
Anna Schumaker 111fcd4e72 core/file: Rename data_file_writef() -> file_writef()
For writing to files with printf-style formatting.

Signed-off-by: Anna Schumaker <Anna@NoWheyCreamery.com>
2018-02-21 08:19:19 -05:00
Anna Schumaker c5494811f4 core/file: Rework binary file IO
I rename cache_file_write() to file_write(), and implement the
corresponding file_read() for binary data.

Signed-off-by: Anna Schumaker <Anna@NoWheyCreamery.com>
2018-02-20 16:59:42 -05:00
Anna Schumaker 07f832ad26 core/file: Rename data_file_version() -> file_version()
Now it can be used by cache files, too.

Signed-off-by: Anna Schumaker <Anna@NoWheyCreamery.com>
2018-02-20 16:18:50 -05:00
Anna Schumaker 35d53855f5 core/file: Add write support to file_open()
I also take this opportunity to add a OPEN_WRITE_BINARY mode to support
writing binary data to files.

Signed-off-by: Anna Schumaker <Anna@NoWheyCreamery.com>
2018-02-20 16:18:49 -05:00
Anna Schumaker 84a1022bdf core/file: Create a single file_close() function
Signed-off-by: Anna Schumaker <Anna@NoWheyCreamery.com>
2018-02-20 16:06:50 -05:00
Anna Schumaker 3736b6cf3b core/file: Create a single file_exists() function
We can use the single file_path() function to check if files exist, too.

Signed-off-by: Anna Schumaker <Anna@NoWheyCreamery.com>
2018-02-20 16:03:32 -05:00
Anna Schumaker 22854b2f25 core/file: Create a single file_path() function
I also introduce a "file_operations" struct that will be used in the
future to do slightly different things for cache and data files.

Signed-off-by: Anna Schumaker <Anna@NoWheyCreamery.com>
2018-02-20 16:01:14 -05:00
Anna Schumaker b6d45e666e core/file: Remove struct cache_file
And rework the init functions at the same time to reflect that data
files can now be placed under a subdirectory.

Signed-off-by: Anna Schumaker <Anna@NoWheyCreamery.com>
2018-02-20 15:39:33 -05:00
Anna Schumaker 198fbf7f9b core/file: Create a new, unified file structure
We'll spend the next several patches slowly switching over to the new
way of accessing files.

Signed-off-by: Anna Schumaker <Anna@NoWheyCreamery.com>
2018-02-20 15:39:33 -05:00
Anna Schumaker 82280edfa2 core/file: Rename struct file -> struct data_file
I'm going to create a unified struct file that should be able to share
code between data and cache files.  The first step is to push the old
structure to the side so it can still be used in other places.

Signed-off-by: Anna Schumaker <Anna@NoWheyCreamery.com>
2018-02-20 15:39:33 -05:00
Anna Schumaker d7d553b80f core/tags/album: Create a new structure to store name and subdir strings
I eventually want to make these fields const in the file code, so we
need a different way to manage and eventually free these strings.

Signed-off-by: Anna Schumaker <Anna@NoWheyCreamery.com>
2018-02-20 15:39:33 -05:00
Anna Schumaker cc464ed198 core/tags/track: Add support for allocating external tracks
There might be rare occasions where users want to play a track that
exists outside their music library.  This patch adds support for
allocating and freeing these external tracks without adding them to the
track database.

Signed-off-by: Anna Schumaker <Anna@NoWheyCreamery.com>
2017-09-05 14:59:43 -04:00
Anna Schumaker f9a573b6a3 core/tags/track: Add a function to look up tracks using only the path
I'm struggling to come up with a good way to combine code for this with
code for track_add(), since the lookup mechanism is basically the same.
I'll keep them separate for now and think on it some more.

Signed-off-by: Anna Schumaker <Anna@NoWheyCreamery.com>
2017-09-05 14:59:43 -04:00
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 58cd43c330 core/database: Pass database index when allocating dbes
This is useful for user playlists so they can store their playlist-id
directly, letting us remove the entire playlist_get_id() function.

Signed-off-by: Anna Schumaker <Anna@NoWheyCreamery.com>
2017-04-28 09:40:02 -04:00
Anna Schumaker 6120366da3 core/tags/album: __album_query_artist() needs to initialize "found"
Otherwise we could end up checking this variable uninitialized.

Signed-off-by: Anna Schumaker <Anna@NoWheyCreamery.com>
2016-09-29 12:44:17 -04:00
Anna Schumaker eb8a23f2ff core/tags/track: Add support for re-keying the track database
This lets up update track keys to prevent duplicates showing up during a
library path update.

Fixes #93: Library sometimes has duplicated tracks
Signed-off-by: Anna Schumaker <Anna@NoWheyCreamery.com>
2016-09-26 15:41:56 -04:00
Anna Schumaker 27436115c7 core/database: Remove dbe_setup()
This was added so tracks could bump the libary tag size.  Now that the
size field has been removed, we can remove this function.

Signed-off-by: Anna Schumaker <Anna@NoWheyCreamery.com>
2016-09-26 08:07:36 -04:00
Anna Schumaker 1b18177d0a core/database: Remove db_load_idle()
This was added to help show the window faster.  Recent changes have made
it unnecessary.

Signed-off-by: Anna Schumaker <Anna@NoWheyCreamery.com>
2016-09-26 08:07:35 -04:00
Anna Schumaker b39c4c9ba4 core/file: File version is OCARINA_MINOR_VERSION
This makes file versioning way easier, since every file will have the
same version.  I'll still need to manage minimum-supported versions, but
that shouldn't be too difficult going forward.

Signed-off-by: Anna Schumaker <Anna@NoWheyCreamery.com>
2016-09-26 08:07:35 -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 784cd3eb91 core/tags/track: Remove redundant artist and genre tags
The track tag doesn't need these tags now that they can be found in the
album tag.

Implements #64: Remove Artist and Genre pointers from Tracks
Signed-off-by: Anna Schumaker <Anna@NoWheyCreamery.com>
2016-09-26 08:07:35 -04:00
Anna Schumaker 71ee59ae22 core/tags/track: Reduce amount of saved data
Artist and genre information are already saved by the album tag.  In
addition, we can save a single date stamp instead of (year, day, month)
triplets.

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 ffd09d410c core/tags/album: Add Genre ID to album keys
This allows for representing albums with multiple genres.  I know this
doesn't happen too often, but it doesn't hurt to be covered.  At the
very least, now we have a genre id for constructing new albums!

Signed-off-by: Anna Schumaker <Anna@NoWheyCreamery.com>
2016-09-26 08:07:35 -04:00
Anna Schumaker a85a1df7de core/tags/album: Add Artist ID to album keys
I need a way to represent the same album with different artists to
account for multi-artist albums.

Signed-off-by: Anna Schumaker <Anna@NoWheyCreamery.com>
2016-09-26 08:07:35 -04:00
Anna Schumaker 8d9139aea5 core/database: Add file versioning to databases
I plan to change the file format of some tags, so add versioning so we
can change things at different times.

Signed-off-by: Anna Schumaker <Anna@NoWheyCreamery.com>
2016-09-26 08:07:35 -04:00
Anna Schumaker a8abbdfdcc Remove scons build files
Signed-off-by: Anna Schumaker <Anna@OcarinaProject.net>
2016-09-23 16:11:08 -04:00
Anna Schumaker 8327d77ddd tests: Build tags/track test with ctest
Signed-off-by: Anna Schumaker <Anna@OcarinaProject.net>
2016-09-23 16:11:02 -04:00
Anna Schumaker 8c875acec9 tests: Build tags/artist test with ctest
Signed-off-by: Anna Schumaker <Anna@OcarinaProject.net>
2016-09-23 16:11:02 -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 e82beb719f core/tags/track: Reduce the size of the track tag
Signed-off-by: Anna Schumaker <Anna@NoWheyCreamery.com>
2016-09-11 10:50:34 -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 aead4939c3 core/filter: Remove filter.c
It is unused now that I have a token matching system in place.

Signed-off-by: Anna Schumaker <Anna@OcarinaProject.net>
2016-08-29 07:33:00 -04:00
Anna Schumaker d16e06111d core/tags/track: Add track_match_token() function
This is used to check if a track has a token that begins with the
requested string.

Signed-off-by: Anna Schumaker <Anna@OcarinaProject.net>
2016-08-29 07:33:00 -04:00
Anna Schumaker 6ad4325f22 core/tags/track: Convert lowercased string into tokens
Signed-off-by: Anna Schumaker <Anna@OcarinaProject.net>
2016-08-29 07:33:00 -04:00
Anna Schumaker 2e1c27294b core/tags/genre: Add genre_match_token() function
This is called to check if any string in a genre's token list is
prefixed by the given string.

Signed-off-by: Anna Schumaker <Anna@OcarinaProject.net>
2016-08-29 07:33:00 -04:00
Anna Schumaker 1ca9bb36c1 core/tags/genre: Convert lowercased string into tokens
Signed-off-by: Anna Schumaker <Anna@OcarinaProject.net>
2016-08-29 07:33:00 -04:00
Anna Schumaker a70b27779f core/tags/artist: Add artist_match_token() function
This is called to check if any string in an artist's token list is
prefixed by the given string.

Signed-off-by: Anna Schumaker <Anna@OcarinaProject.net>
2016-08-29 07:33:00 -04:00
Anna Schumaker b643b532d7 core/tags/artist: Convert lowercased string into tokens
Signed-off-by: Anna Schumaker <Anna@OcarinaProject.net>
2016-08-29 07:32:59 -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 20e0a85a5d core/tags/artist: Add an artist_db_get() function
This will be called to scan the artist database when setting up
playlists.

Signed-off-by: Anna Schumaker <Anna@OcarinaProject.net>
2016-08-13 08:31:30 -04:00
Anna Schumaker b3922cc731 core/tags/artist: Add an artist_lookup() function
For looking up artist tags without allocating a new one.

Signed-off-by: Anna Schumaker <Anna@OcarinaProject.net>
2016-08-13 08:31:30 -04:00