Commit Graph

533 Commits

Author SHA1 Message Date
Anna Schumaker 1633946981 core/file: Check if a file is too new to be opened
I'm hitting this problem while developing 6.5, since file formats are
going to change.  Let's handle this situation gracefully rather than
segfaulting.

This patch changes versioning problems into fatal errors to prevent us
from overwriting data already on disk.

Signed-off-by: Anna Schumaker <Anna@NoWheyCreamery.com>
2016-08-28 10:07:27 -04:00
Anna Schumaker a430c5b117 core/playlists/artist: Add artist playlists as artists are added
Scanning new library paths should also add artist playlists, otherwise
they won't show up until Ocarina is restarted.

Fixes #79: Artist playlists not updated when tracks are added
Signed-off-by: Anna Schumaker <Anna@NoWheyCreamery.com>
2016-08-28 09:46:16 -04:00
Anna Schumaker 5964c508ce core/playlists/artists: Load each playlist with a different idle task
This seems less efficient overall, since we now need to take several
passes over the track database.  What I've noticed is that the
single-pass option creates a lot of UI notifications that makes the gui
unresponsive for a large amount of time.  Breaking this into smaller
chunks gives us a chance to handle any user actions between loading each
playlist.

Fixes #71: Initalize artist playlists with more idle tasks
Signed-off-by: Anna Schumaker <Anna@NoWheyCreamery.com>
2016-08-13 09:50:24 -04:00
Anna Schumaker 9733b82ae8 core/collection: Remove file
I have replaced everything in this file with the code in
core/playlists/library.c

Signed-off-by: Anna Schumaker <Anna@OcarinaProject.net>
2016-08-13 08:31:30 -04:00
Anna Schumaker f70b2b940f core/playlists/artist: Add basic artist operations
For now, hidden tracks are shown in artist queues.

Signed-off-by: Anna Schumaker <Anna@OcarinaProject.net>
2016-08-13 08:31:30 -04:00
Anna Schumaker 24448aefec core/playlists/artist: Add tracks to the artist playlists
I use a single idle task to scan the track database and add to the
appropriate playlist.

Signed-off-by: Anna Schumaker <Anna@OcarinaProject.net>
2016-08-13 08:31:30 -04:00
Anna Schumaker 12ae7cfee6 core/playlists/artist: Add pl_artist_{init, deinit}() functions
The pl_artist_init() function is used to allocate a playlist for each
artist already in the database, and pl_artist_deinit() is then used to
free up this memory during cleanup.

Signed-off-by: Anna Schumaker <Anna@OcarinaProject.net>
2016-08-13 08:31:30 -04:00
Anna Schumaker 11430f89cf core/playlists/library: Add pl_library_update() function
This is called to find and add new tracks to the library.

Signed-off-by: Anna Schumaker <Anna@OcarinaProject.net>
2016-08-13 08:31:30 -04:00
Anna Schumaker e1a722d04b core/playlists/library: Adding a library starts a directory scan
Signed-off-by: Anna Schumaker <Anna@OcarinaProject.net>
2016-08-13 08:31:30 -04:00
Anna Schumaker c448db2665 core/playlists: Add playlist_{new, delete}() functions
System playlists cannot be created or deleted, so these functions simply
return false in this case.  Library playlists will use this to add new
library paths to Ocarina.

Signed-off-by: Anna Schumaker <Anna@OcarinaProject.net>
2016-08-13 08:31:30 -04:00
Anna Schumaker 78aa0f9ff6 core/playlists/library: Add pl_library_sort() function
Used to sort library playlists.

Signed-off-by: Anna Schumaker <Anna@OcarinaProject.net>
2016-08-13 08:31:30 -04:00
Anna Schumaker 7f867199cb core/playlists/library: Add pl_library_set_flag() function
I also take the opportunity to add in a generic lookup function to
convert a library path into a playlist.

Signed-off-by: Anna Schumaker <Anna@OcarinaProject.net>
2016-08-13 08:31:30 -04:00
Anna Schumaker 1599897fbf core/playlists/library: Add pl_library_add_rm() function
This function is for both adding and removing tracks, and only returns
false.  Tracks will only be added and removed through the update
function.

Signed-off-by: Anna Schumaker <Anna@OcarinaProject.net>
2016-08-13 08:31:30 -04:00
Anna Schumaker c5a0a3470e core/playlists/library: Add pl_library_get_queue() function
Called to access the track queue associated with the given playlist.

Signed-off-by: Anna Schumaker <Anna@OcarinaProject.net>
2016-08-13 08:31:30 -04:00
Anna Schumaker 4d5569ef7a core/playlists/library: Add tracks to library playlists
This needs to happen in an idle task since the track database is loaded
when idle.

Signed-off-by: Anna Schumaker <Anna@OcarinaProject.net>
2016-08-13 08:31:30 -04:00
Anna Schumaker 261f6d91d7 core/playlists/library: Add pl_library_{init, deinit}() functions
The pl_library_init() function is used to allocate a playlist for each
library path already in the database, and pl_library_deinit() is then
used to free this memory during cleanup.

Signed-off-by: Anna Schumaker <Anna@OcarinaProject.net>
2016-08-13 08:31:30 -04:00
Anna Schumaker e4930704a2 core/playlists/system: Add pl_system_delete_track()
Called to remove a track from all system playlists.

Signed-off-by: Anna Schumaker <Anna@OcarinaProject.net>
2016-08-13 08:31:30 -04:00
Anna Schumaker 03ed7c4b84 core/playlists/system: Add pl_system_new_track()
Called to tell system playlists that a new track has been added to the
database.

Signed-off-by: Anna Schumaker <Anna@OcarinaProject.net>
2016-08-13 08:31:30 -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
Anna Schumaker e41f554b2e core/tags/artist: Add a pointer to store a playlist
Similar to the library tag, this is a void pointer that should only be
used by the playlist layer.

Signed-off-by: Anna Schumaker <Anna@OcarinaProject.net>
2016-08-13 08:31:30 -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 cfeca9ae4b core/playlist: Add playlist_type enum
I'm going to use this to distinguish between various playlist types that
are about to be added.  Let's update the playlist functions first, and
then add more types in a future patch.

Signed-off-by: Anna Schumaker <Anna@OcarinaProject.net>
2016-08-13 08:31:30 -04:00
Anna Schumaker 34447007f9 core/history: Remove unused queue
Signed-off-by: Anna Schumaker <Anna@OcarinaProject.net>
2016-07-29 17:09:38 -04:00
Anna Schumaker 5a54fb69b6 core/collection: Remove unused queue
And remove collection_ops from the core initdata

Signed-off-by: Anna Schumaker <Anna@OcarinaProject.net>
2016-07-29 17:09:33 -04:00
Anna Schumaker 8eaf6506e8 core/playlist: Add playlist_{next, prev}() functions
Signed-off-by: Anna Schumaker <Anna@OcarinaProject.net>
2016-07-29 17:06:06 -04:00
Anna Schumaker efae58c356 core/playlists/system: Add history playlist
Implements #8: Convert history queue into a playlist
Signed-off-by: Anna Schumaker <Anna@OcarinaProject.net>
2016-07-29 17:06:04 -04:00
Anna Schumaker 6265b937c7 core/playlists/system: Add collection playlist
Implements #7: Convert collection queue into a playlist
Signed-off-by: Anna Schumaker <Anna@OcarinaProject.net>
2016-07-29 17:06:03 -04:00
Anna Schumaker 5d4de9c5b0 core/playlist: Add playlist_sort() function
Signed-off-by: Anna Schumaker <Anna@OcarinaProject.net>
2016-07-29 17:06:03 -04:00
Anna Schumaker c7bc2062d2 core/playlist: Add playlist_{get,set}_random()
I'll need this to toggle the random flag for the Collection playlist to
avoid cycling through the GUI in order to save.

Signed-off-by: Anna Schumaker <Anna@OcarinaProject.net>
2016-07-29 17:06:03 -04:00
Anna Schumaker 62123eb025 core/playlists: Add struct playlist
Containing the playlist name and queue.  I pass this to the gui through
the queue_init() function.

Signed-off-by: Anna Schumaker <Anna@OcarinaProject.net>
2016-07-29 17:06:03 -04:00
Anna Schumaker 44a57ed863 core/queue: Add extra paramater to queue_init()
This is used to pass through a value to the GUI during queue
initialization.

Signed-off-by: Anna Schumaker <Anna@OcarinaProject.net>
2016-07-29 17:06:03 -04:00
Anna Schumaker 7f0e1ecc99 core/queue: Add queue_{save, load}_flags() function
Signed-off-by: Anna Schumaker <Anna@OcarinaProject.net>
2016-07-29 17:06:03 -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 fa0dee5921 core/containers: Remove unused set class
Implements #48: Remove set code
Signed-off-by: Anna Schumaker <Anna@OcarinaProject.net>
2016-07-29 17:06:00 -04:00
Anna Schumaker 98fe6d3bbb core/containers: Remove unused index class
Implements #44: Remove Index code
Signed-off-by: Anna Schumaker <Anna@OcarinaProject.net>
2016-07-29 17:05:59 -04:00
Anna Schumaker 93fb40360d core/filter: filter_search() returns a new GHashTable
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>
2016-07-29 17:05:59 -04:00
Anna Schumaker fda3f761a0 core/filter: Call GHashTable functions directly
Implements #43: Filter code can use a GHashTable directly
Signed-off-by: Anna Schumaker <Anna@OcarinaProject.net>
2016-07-29 17:05:54 -04:00
Anna Schumaker 63b46b6161 core/filter: Implement copy and intersect directly
I intend to remove the set class, so we still need a way to handle
filter results.

Signed-off-by: Anna Schumaker <Anna@OcarinaProject.net>
2016-07-29 17:05:54 -04:00
Anna Schumaker 29b2b6f6f4 core/filter: Store track pointers directly
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>
2016-07-29 17:05:47 -04:00
Anna Schumaker 415bd9731a core/filter: Add filter_remove()
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>
2016-07-29 15:46:11 -04:00
Anna Schumaker 04a175d3e3 core/filter: Switch from using Index to a GHashTable
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>
2016-07-29 15:46:11 -04:00
Anna Schumaker 951624c82f core/audio: Update Most and Least Played playlists
We need to do this when tracks are played to keep playlist counts
accurate.

Signed-off-by: Anna Schumaker <Anna@NoWheyCreamery.com>
2016-07-29 10:14:35 -04:00
Anna Schumaker 779969f28b core/idle: Let tests run without the thread pool
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>
2016-07-28 16:17:43 -04:00
Anna Schumaker 1d1e41916a core/playlists/system: Check that we read a valid playlist name
Otherwise we could crash when we try to access an out of bounds area of
the playlist array.

Signed-off-by: Anna Schumaker <Anna@NoWheyCreamery.com>
2016-07-28 08:55:53 -04:00
Anna Schumaker 2c18f9e715 core/playlist: Add playlist_size() function
Signed-off-by: Anna Schumaker <Anna@OcarinaProject.net>
2016-07-19 16:03:11 -04:00
Anna Schumaker 5e9b6bc975 core/playlist: Access playlists through a string
Signed-off-by: Anna Schumaker <Anna@OcarinaProject.net>
2016-07-19 16:03:11 -04:00
Anna Schumaker 90e0b3ed78 core/playlist: Remove remaining dynamic playlist code
Signed-off-by: Anna Schumaker <Anna@OcarinaProject.net>
2016-07-19 16:03:11 -04:00
Anna Schumaker 2ff7113668 core/playlists/system: Move the least played playlist into system.c
Signed-off-by: Anna Schumaker <Anna@OcarinaProject.net>
2016-07-19 16:03:10 -04:00