We can just pass 0 to the sorted function to indicate that the playlist
shouldn't be sorted by default. Let's also take this chance to rename
playlist_generic_init_sorted() -> playlist_generic_init()
Signed-off-by: Anna Schumaker <Anna@NoWheyCreamery.com>
If we have two albums by the same artist in the same year (such as a CD1
or CD2 postfix), then we'll end up mixing them together when sorting.
Fix this by changing the default sort order to
Artist -> Year -> Album -> Track Number
Signed-off-by: Anna Schumaker <Anna@NoWheyCreamery.com>
This will be needed by the gui to find the current count at any time,
without waiting for a callback.
Signed-off-by: Anna Schumaker <Anna@NoWheyCreamery.com>
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>
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>
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>
This function currently only supports opening files for reading, but it
will soon be expanded to supporting writes as well. To support binary
reads, I add a new OPEN_READ_BINARY open mode.
Signed-off-by: Anna Schumaker <Anna@NoWheyCreamery.com>
I'll eventually want to support text and binary files in both locations,
so cache files might need access to this too.
Signed-off-by: Anna Schumaker <Anna@NoWheyCreamery.com>
This change means removing cache files is now supported. As a bonus,
we try to remove empty subdirectories to keep down the clutter.
Signed-off-by: Anna Schumaker <Anna@NoWheyCreamery.com>
This might also be useful for cache files to track their current state.
To help with accurate tracking, I take this opportunity to add a CLOSED
state that files default to.
Signed-off-by: Anna Schumaker <Anna@NoWheyCreamery.com>
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>
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>
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>
If a matching track isn't found in the track database, then use the new
track_alloc_external() function to allocate an external track with the
correct tags.
Signed-off-by: Anna Schumaker <Anna@NoWheyCreamery.com>
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>
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>
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>
I want to use this to prevent users from adding a subdirectory of a path
that has already been added to the library.
Signed-off-by: Anna Schumaker <Anna@NoWheyCreamery.com>
Let's just do everything inline and cut out the extra function calls to
make the code simpler. I also created functions to help tests send EOS
or error messages.
Signed-off-by: Anna Schumaker <Anna@NoWheyCreamery.com>
And use these to trigger the state changed callback. Additionally, this
callback can now be used by tests to determine when we're done seeking.
Signed-off-by: Anna Schumaker <Anna@NoWheyCreamery.com>
We only play local music, so we know that we're using a file and we
don't need a uridecodebin to figure it out for us.
Signed-off-by: Anna Schumaker <Anna@NoWheyCreamery.com>
Add some whitespace to make it easier to follow what everything is. I
also rename audio_bus to audio_old_id to make it easier to add in a new
audio bus. Additionally, I changed test_audio_player() to
test_old_player() to make room for the new pipeline.
Signed-off-by: Anna Schumaker <Anna@NoWheyCreamery.com>
Users may make typos in naming playlists, or they might think up better
names for playlists later. Let's be friendly and give users a way to
change playlist names if desired.
Signed-off-by: Anna Schumaker <Anna@NoWheyCreamery.com>
This way we don't need to keep including the same core libraries in
almost every file.
Implements #83: Include useful headers in core/core.h
Signed-off-by: Anna Schumaker <Anna@NoWheyCreamery.com>
The core_init_data only held three items, most of which don't get set
during testing. Removing this struct means several tests no longer need
to define a "dummy" initdata object to pass around during init.
Implements #92: Remove core_init_data
Signed-off-by: Anna Schumaker <Anna@NoWheyCreamery.com>
And make them optional, that way tests don't need to keep creating fake
callbacks if they don't need anything from the audio layer.
Signed-off-by: Anna Schumaker <Anna@NoWheyCreamery.com>
Rather than offering two init functions for testing. This lets the UI
select if they want async idle tasks (like Album Art fetching).
Implements #90: Give idle_init an async flag
Signed-off-by: Anna Schumaker <Anna@NoWheyCreamery.com>
Users might not remember any sorting or random settings from the last
time they queued tracks, so saving these values could result in
selecting tracks in an unexpected order. Fix this by resetting the
queued tracks options whenever the playlist is emptied.
Fixes#108: Unset random and sorting when finishing queued tracks
Signed-off-by: Anna Schumaker <Anna@NoWheyCreamery.com>
These fields were working fine for statically initialized playlists, but
they get set to garbage values when g_malloc()-ing a playlist. Let's
make sure they get initialized properly with the rest of the playlist.
Fixes#107: Initialize all values in playlist_generic_init()
Signed-off-by: Anna Schumaker <Anna@NoWheyCreamery.com>
Everything has been merged into the playlist layer to better match how
playlists are actually used. This means we can remove the queue files.
Signed-off-by: Anna Schumaker <Anna@NoWheyCreamery.com>
Artist and library playlists are allocated manually, so there should be
generic functions that both can use to get a playlist pointer and free
it when we're done.
I also add a callback for telling the UI when new playlists have been
allocated. This isn't needed for Library playlists, but this is the
only way the UI can know about new Artists.
Signed-off-by: Anna Schumaker <Anna@NoWheyCreamery.com>
Sometimes we want to initialize the playlist with sort data, other times
we don't. This gives us functions we can call for both!
Signed-off-by: Anna Schumaker <Anna@NoWheyCreamery.com>
And change its type to gchar **. This lets the playlist code manage
setting and freeing search strings. The UI is still responsible for
how this string is used.
This patch also lets me remove the now-unused queue_deinit() function
and associated callback.
Signed-off-by: Anna Schumaker <Anna@NoWheyCreamery.com>
The iterator only needs to point to the current position on the GQueue,
so we can do away with manual position tracking. This lets us use a
GList pointer as an iterator instead of something more complicated.
Signed-off-by: Anna Schumaker <Anna@NoWheyCreamery.com>
I keep using the queue_iter struct for now to reduce code churn in this
patch. I'll be replacing it in the next patch.
Signed-off-by: Anna Schumaker <Anna@NoWheyCreamery.com>