Commit Graph

969 Commits

Author SHA1 Message Date
Bryan Schumaker
fad3019d83 libsaria: Reload a saved library
And add tracks to the library playlist.

Signed-off-by: Bryan Schumaker <bjschuma@gmail.com>
2012-04-07 10:01:17 -04:00
Bryan Schumaker
d0a1b9fdf8 libsaria: Save library
- Change WriteTask() to take an extra void pointer argument
- Pass library path pointer through WriteTask
- Store tracks to file named after library id.
- Remove newline from tags

Signed-off-by: Bryan Schumaker <bjschuma@gmail.com>
2012-04-07 10:01:17 -04:00
Bryan Schumaker
ab687a49bc libsaria: Create library and track counters
I plan on using (library, track) ids as a way of storing playlists.  I
made both counters unsigned ints, since I'm willing to bet that people
won't have 4,294,967,295 songs or library paths...

Signed-off-by: Bryan Schumaker <bjschuma@gmail.com>
2012-04-07 10:01:17 -04:00
Bryan Schumaker
41dac97711 libsaria: Remove old library files
I was keeping them for reference, but I don't need them anymore.

Signed-off-by: Bryan Schumaker <bjschuma@gmail.com>
2012-04-07 10:01:17 -04:00
Bryan Schumaker
ac3964de01 libsaria: Randomly pick next song from library
I'll eventually allow more playlists to be stacked, but for now picking
from the library is easy.  I may eventually add in a way to pick
sequentially from a set.

Signed-off-by: Bryan Schumaker <bjschuma@gmail.com>
2012-04-07 10:01:17 -04:00
Bryan Schumaker
07c365fcc0 libsaria: Add library playlist to to stack
I do this during library::init()

Signed-off-by: Bryan Schumaker <bjschuma@gmail.com>
2012-04-07 10:01:17 -04:00
Bryan Schumaker
3d7082e6f9 libsaria: Remove some old audio code
Not needed anymore with recent changes.

Signed-off-by: Bryan Schumaker <bjschuma@gmail.com>
2012-04-07 10:01:17 -04:00
Bryan Schumaker
6bae34e487 libsaria: Added stopping
pause() and seek_to(0).  I also added a button in Ocarina.

Signed-off-by: Bryan Schumaker <bjschuma@gmail.com>
2012-04-07 10:01:17 -04:00
Bryan Schumaker
595806ec0f libsaria: Reenabled seeking
Signed-off-by: Bryan Schumaker <bjschuma@gmail.com>
2012-04-07 10:01:17 -04:00
Bryan Schumaker
70ef389aab libsaria: Find audio position and duration
Used for update a slider in the UI.

Signed-off-by: Bryan Schumaker <bjschuma@gmail.com>
2012-04-07 10:01:17 -04:00
Bryan Schumaker
53425485d6 libsaria: Preserve the current playback state when changing tracks
This makes something new play when we want it to...

Signed-off-by: Bryan Schumaker <bjschuma@gmail.com>
2012-04-07 10:01:17 -04:00
Bryan Schumaker
fe76a8d30a libsaria: Add play(), pause() and get_state() functions
Signed-off-by: Bryan Schumaker <bjschuma@gmail.com>
2012-04-07 10:01:17 -04:00
Bryan Schumaker
e3c44146ff ocarina: Show information on the currently playing track
I update it using the main timeout loop, but only if the current track
pointer has changed.

Signed-off-by: Bryan Schumaker <bjschuma@gmail.com>
2012-04-07 10:01:17 -04:00
Bryan Schumaker
f1bbbbcc5c libsaria: Play a track using Track::play_now()
It loads and begins playback.

Signed-off-by: Bryan Schumaker <bjschuma@gmail.com>
2012-04-07 10:01:17 -04:00
Bryan Schumaker
5163447638 libsaria: Remove most audio code
It'll be re-added as I review it all.

Signed-off-by: Bryan Schumaker <bjschuma@gmail.com>
2012-04-07 10:01:16 -04:00
Bryan Schumaker
a0d509cdff ocarina: Look for double clicking treeview rows
I now have direct access to the track that was selected, so I created a
dummy function to play it (to be filled in soon).

Signed-off-by: Bryan Schumaker <bjschuma@gmail.com>
2012-04-07 10:01:16 -04:00
Bryan Schumaker
6bb3cd38a4 libsaria: Notify playlist renderers when new tracks are added
For sets, I keep a sorted list and merge-sort the new songs.  I also
created insert_prepare() and insert_done() functions to tell the UI that
we are about to insert (this gives me a chance to call the
freeze_child_notify() and thaw_child_notify() in GTK).

Signed-off-by: Bryan Schumaker <bjschuma@gmail.com>
2012-04-07 10:01:16 -04:00
Bryan Schumaker
abac8883c3 libsaria: Give playlists a name
Right now this must be set when a new playlist is constructed.  I can
eventually change this to use a default name based on what type of
playlist has been created.

Signed-off-by: Bryan Schumaker <bjschuma@gmail.com>
2012-04-07 10:01:16 -04:00
Bryan Schumaker
cdd2fe1af5 Add a playlist renderer
The renderer doesn't actually render anything yet, but it is statically
defined in ocarina/playlist.cpp and it will eventually display the
library.

Signed-off-by: Bryan Schumaker <bjschuma@gmail.com>
2012-04-07 10:01:16 -04:00
Bryan Schumaker
b1eb47006d libsaria: Move the renderer into the playlist namespace
This makes more sense to me conceptually than having a class called
PlaylistRenderer.  I also commented out a lot of code, so the renderer
doesn't do anything right now.

Signed-off-by: Bryan Schumaker <bjschuma@gmail.com>
2012-04-07 10:01:16 -04:00
Bryan Schumaker
6d709e3a18 libsaria: Add sorted songs to the Set playlist
I sort the subset of tracks to be added, and then use insertion sort to
add them to the playlist object.

Signed-off-by: Bryan Schumaker <bjschuma@gmail.com>
2012-04-07 10:01:16 -04:00
Bryan Schumaker
cfc50cf745 libsaria: Added Set playlist type
I think inheritance is easier than passing a bunch of flags and then
deciding what to do.

Signed-off-by: Bryan Schumaker <bjschuma@gmail.com>
2012-04-07 10:01:16 -04:00
Bryan Schumaker
29cb7f7a47 libsaria: Create a static playlist for the library
Signed-off-by: Bryan Schumaker <bjschuma@gmail.com>
2012-04-07 10:01:16 -04:00
Bryan Schumaker
dfb5c09260 libsaria: Remove most of the playlist class
I'm going to clean it up too, so I've removed everything for now to
slowly re-add later.

Signed-off-by: Bryan Schumaker <bjschuma@gmail.com>
2012-04-07 10:01:16 -04:00
Bryan Schumaker
01d4819d15 libsaria: Add fields for play count and last played date
Signed-off-by: Bryan Schumaker <bjschuma@gmail.com>
2012-04-07 10:01:16 -04:00
Bryan Schumaker
c38eaccf3a libsaria: Find audio information, too
Length, bitrate and various other fields.

Signed-off-by: Bryan Schumaker <bjschuma@gmail.com>
2012-04-07 10:01:16 -04:00
Bryan Schumaker
97a0bb7260 libsaria: Find song file tags
I don't pull out the audio properties yet, but I do find artist, album,
title and everything else that I can.

Signed-off-by: Bryan Schumaker <bjschuma@gmail.com>
2012-04-07 10:01:16 -04:00
Bryan Schumaker
011db26d92 libsaria: Pass library path to Track()
This will eventually be used to determine if the track is visible based
on library path visibility.

Signed-off-by: Bryan Schumaker <bjschuma@gmail.com>
2012-04-07 10:01:16 -04:00
Bryan Schumaker
b0c76f4b11 Notify when library paths have been updated
This gives the UI a chance to set the new path or new size.  I also
updated Ocarina to show the library path size in its liststore row.

Signed-off-by: Bryan Schumaker <bjschuma@gmail.com>
2012-04-07 10:01:16 -04:00
Bryan Schumaker
8f666fe10c libsaria: Add new tracks to library paths during update
Right now the Track added is empty, but I'll fill it in soon enough.

Signed-off-by: Bryan Schumaker <bjschuma@gmail.com>
2012-04-07 10:01:16 -04:00
Bryan Schumaker
a944869093 libsaria: Clean out the Track class for re-implementation
This also removed the other `typedef sid_t` left in the header file.
I'll re-add in functions and variables as I need them, and hopefully
keep things working more efficiently.

Signed-off-by: Bryan Schumaker <bjschuma@gmail.com>
2012-04-07 10:01:16 -04:00
Bryan Schumaker
d77b06f267 libsaria: Remove sid_t type
I was using the sid_t to lookups for tracks and library paths.  I think
I can simplify things by storing pointers in the UI rather than using
id numbers.  This will give me direct access to whatever it is I want to
manipulate.

Signed-off-by: Bryan Schumaker <bjschuma@gmail.com>
2012-04-07 10:01:16 -04:00
Bryan Schumaker
230a31a5a7 libsaria: Divide scan file list into smaller chunks
Each chunk is given to a new ScanTask to process.

Signed-off-by: Bryan Schumaker <bjschuma@gmail.com>
2012-04-07 10:01:16 -04:00
Bryan Schumaker
f5462da461 Find files to add to the library
I created a new "list_dir()" function to recursively list directory
contents.  I plan on using this to find songs to add to the library, but
it could also be modified to read playlists and library paths in the
appdir.

Signed-off-by: Bryan Schumaker <bjschuma@gmail.com>
2012-04-07 10:01:16 -04:00
Bryan Schumaker
2c830af7fa Create a progress bar for idle tasks
Whenever a task is queued, I increment a counter.  When it is run, I
increment a different counter.  This allows me to track the idle queue
completion percentage.  I also created a progress bar for Ocarina to
display in the toes of the footer.

Signed-off-by: Bryan Schumaker <bjschuma@gmail.com>
2012-04-07 10:01:15 -04:00
Bryan Schumaker
03d35fee77 libsaria: Only use the library::Driver for notifications
This allows other tools to be written to modify the library of a
currently running program without having to create a library driver
instance.

Signed-off-by: Bryan Schumaker <bjschuma@gmail.com>
2012-04-07 10:01:15 -04:00
Bryan Schumaker
e1b410845d ocarina: Set child propertys for GtkNotebook
The set_tab_packing() function is deprecated, so I might as well just
use the real way to do this...

Signed-off-by: Bryan Schumaker <bjschuma@gmail.com>
2012-04-07 10:01:15 -04:00
Bryan Schumaker
032caad800 ocarina: Poll for idle queue tasks
I'm going to need a polling loop for the progress bar.  I might as well
only create one poll() function that is used to do everything...

Signed-off-by: Bryan Schumaker <bjschuma@gmail.com>
2012-04-07 10:01:15 -04:00
Bryan Schumaker
30e2003a27 libsaria: Find library id from inode number
I want to eventually use this to create a library file for each library
path.  The "visible" field will be used to enable and disable different
paths during run time.

Signed-off-by: Bryan Schumaker <bjschuma@gmail.com>
2012-04-07 10:01:15 -04:00
Bryan Schumaker
4448ba7ce1 libsaria: Turn the library::Renderer into a library::Driver
This will provide a 2-way notification system, rather than just going
from libsaria to the UI.

Signed-off-by: Bryan Schumaker <bjschuma@gmail.com>
2012-04-07 10:01:15 -04:00
Bryan Schumaker
111e8f2c3b libsaria: Created a library::Renderer class
The UI should inherit from this class to create a driver used to control
the library.

Signed-off-by: Bryan Schumaker <bjschuma@gmail.com>
2012-04-07 10:01:15 -04:00
Bryan Schumaker
ae9074103a libsaria: Create new LibraryPaths
The UI calls the library::add_path() function to create a new
LibraryPath structure to be managed by the library.

Signed-off-by: Bryan Schumaker <bjschuma@gmail.com>
2012-04-07 10:01:15 -04:00
Bryan Schumaker
7c8ef5508e libsaria: Comment out most of the library
I want to gradually re-add everything and clean it up as I go along.  To
help with this, I comment out the old code so I can use it as a
reference while writing new code.

Signed-off-by: Bryan Schumaker <bjschuma@gmail.com>
2012-04-07 10:01:15 -04:00
Bryan Schumaker
c0df8f2e2b libsaria: Take idle callback func during libsaria init
This allows me to enable the idle queue if the function pointer is not
NULL.

Signed-off-by: Bryan Schumaker <bjschuma@gmail.com>
2012-04-07 10:01:15 -04:00
Bryan Schumaker
292d237561 libsaria: Idle queue cleanups
To make the code easier to follow and maintain.

Signed-off-by: Bryan Schumaker <bjschuma@gmail.com>
2012-04-07 10:01:15 -04:00
Bryan Schumaker
84582ae9d8 libsaria: load preferences from disk during startup
This is one of the first things that happens when initializing libsaria.
This also allows me to remove the remaining commented out code from the
preferences file.

Signed-off-by: Bryan Schumaker <bjschuma@gmail.com>
2012-04-07 10:01:15 -04:00
Bryan Schumaker
06412afeed libsaria: Save preferences in idle task after they change
I made a WriteTask class to use for saving files.  This allows me to
create a file in the appdir and write out the new preferences if they've
changed.

Signed-off-by: Bryan Schumaker <bjschuma@gmail.com>
2012-04-07 10:01:14 -04:00
Bryan Schumaker
a0da654fc6 ocarina: Resize window to match preference
I initialize the window size preferences to (800, 600) and then resize
the window to match.

Signed-off-by: Bryan Schumaker <bjschuma@gmail.com>
2012-04-07 10:01:14 -04:00
Bryan Schumaker
95cc9d272f libsaria: Begin appdir code
I'm going to replace my old path lookup code with something designed
around accessing files in a pre-set directory.  I'm also moving back to
putting files in the home diretory, rather than the XDG_CONFIG directory.

Signed-off-by: Bryan Schumaker <bjschuma@gmail.com>
2012-04-07 10:01:14 -04:00
Bryan Schumaker
02740d1feb libsaria: Remove initflags and comment out init() functions
Instead, I pass a string with the name of the application being run.
This will be used to have separate applications using libsaria.

This commit also comments out most of the libsaria and ocarina init
functions until I can revise and clean up everything.

Signed-off-by: Bryan Schumaker <bjschuma@gmail.com>
2012-04-07 10:01:14 -04:00
Bryan Schumaker
d764489e89 libsaria: Create init flags
I eventually plan on creating more cpp binaries that link with libsaria
for pipe actions and other things.  It's helpful to only initialize the
parts of libsaria that I intend to use.

Signed-off-by: Bryan Schumaker <bjschuma@gmail.com>
2012-04-07 10:01:14 -04:00
Bryan Schumaker
db00eb0908 libsaria: Include missing header file
This was needed for unlink()

Signed-off-by: Bryan Schumaker <bjschuma@gmail.com>
2012-04-07 10:00:05 -04:00
Bryan Schumaker
37bcb47de2 libsaria: Check the top of the stack through a function
The UI shortcuts may remove songs from the queue with no way of
notifying the stack layer.  The UI should call the stack_top_pop()
function to check if the top playlist is empty and ready for removal.

Signed-off-by: Bryan Schumaker <bjschuma@gmail.com>
2012-03-05 08:23:00 -05:00
Bryan Schumaker
ed3254813c libsaria: Playlist tells renderer where to insert tracks
Now renderers don't need to track this on their own, and renderers will
update as tracks are added.

Signed-off-by: Bryan Schumaker <bjschuma@gmail.com>
2012-03-05 07:47:55 -05:00
Bryan Schumaker
3c423e986a libsaria: Load playlists on startup
I removed this in a previous patch by accident, but I fixed it now.

Signed-off-by: Bryan Schumaker <bjschuma@gmail.com>
2012-03-04 10:29:39 -05:00
Bryan Schumaker
981b64a635 libsaira: Pass a flag if renderers should be deleted
Not all renderers are created dynamically, so I made a way of telling
the playlist system if renderers should be deleted.

Signed-off-by: Bryan Schumaker <bjschuma@gmail.com>
2012-03-04 10:13:44 -05:00
Bryan Schumaker
dd5e73a2ba libsaria: Delete playlists and renderers when popped
This allows dynamic memory to be freed when we are done using it.

Signed-off-by: Bryan Schumaker <bjschuma@gmail.com>
2012-03-04 10:02:03 -05:00
Bryan Schumaker
83897633ce Dynamically allocate queue playlists
I only allow one queue instance right now, but this allows me to remove
the queue directory since it is no longer needed.  I also removed the
QUEUE_REFRESH callback since all this is handled through the libsaria
playlist code.  All that's left is reloading saved playlists on startup.

Signed-off-by: Bryan Schumaker <bjschuma@gmail.com>
2012-03-03 14:19:33 -05:00
Bryan Schumaker
ef62f5d2b0 libsaria: Alert the PlaylistRenderer when the playlist becomes empty
This allows for bookkeeping and other cleanup (schedule playlist
removal, remove from UI, and so on).

Signed-off-by: Bryan Schumaker <bjschuma@gmail.com>
2012-02-28 08:16:23 -05:00
Bryan Schumaker
b7e1c2c631 libsaria: Create a Playlist stack
My goal is to eventually pick songs from whatever is on top of the
playlist stack.  Right now, only the library is added and no songs are
picked.

Signed-off-by: Bryan Schumaker <bjschuma@gmail.com>
2012-02-25 17:21:19 -05:00
Bryan Schumaker
8d50e63df2 libsaria: Remove refresh() after picking next queued song
Unfortunately, this doesn't hide the queue when empty anymore.  I
probably won't see this behavior again until I create the stack.

Signed-off-by: Bryan Schumaker <bjschuma@gmail.com>
2012-02-25 14:04:31 -05:00
Bryan Schumaker
e03dfb33b8 libsaria: Remove indices from the queue
This replaces the "remove id" ability and replaces it with a "remove
index" ability.  Removing an index will remove the correct song in the
case that the same song has been added multiple times.  I also modified
the UI to remove rows at a specific index.

Signed-off-by: Bryan Schumaker <bjschuma@gmail.com>
2012-02-25 13:50:56 -05:00
Bryan Schumaker
6637a82573 ocarina: Remove the SongListFuncs struct
I can get everything I need using playlists and renderers, so I can
safely remove this bit of code (I never really liked it anyway...).  I
have to keep around the queue::size() function for a little bit longer,
since choosing the next song still uses it.

Signed-off-by: Bryan Schumaker <bjschuma@gmail.com>
2012-02-25 10:52:35 -05:00
Bryan Schumaker
f7d7589882 libsaria: Remove library and queue iterator functions
I don't need these now that I have playlist renderers, so I might as
well rip out the code while I'm thinking about it.

Signed-off-by: Bryan Schumaker <bjschuma@gmail.com>
2012-02-25 10:11:26 -05:00
Bryan Schumaker
4ebfd8a33b libsaria: Use a tighter loop to fill in the playlist
Rather than exposing iterator functions, I now have a function to walk
the playlist and call the renderer insert() function for each track.

Signed-off-by: Bryan Schumaker <bjschuma@gmail.com>
2012-02-25 10:04:19 -05:00
Bryan Schumaker
055f349cd1 libsaria: Playlist knows about the renderer
I plan on using this to fill in each playlist instead of using my
current iterator system.

Signed-off-by: Bryan Schumaker <bjschuma@gmail.com>
2012-02-25 09:50:35 -05:00
Bryan Schumaker
f795af5d6c libsaria: Created a playlist renderer
This class will be given a Playlist and will be in charge of calling
Playlist functions.  I eventually plan on expanding this to allow the
playlist to call renderer functions instead of using my current callback
system.

Signed-off-by: Bryan Schumaker <bjschuma@gmail.com>
2012-02-25 09:45:27 -05:00
Bryan Schumaker
d8b6f5b0a0 libsaria: Queue size uses apparent_size()
I don't have filtering enabled right now, but I may change my mind in
the future.  Might as well prepare now...

Signed-off-by: Bryan Schumaker <bjschuma@gmail.com>
2012-02-24 09:44:37 -05:00
Bryan Schumaker
4ee79d8385 libsaria: Always load the library first
Other playlists need this, so it makes sense to queue this up first.

Signed-off-by: Bryan Schumaker <bjschuma@gmail.com>
2012-02-24 09:36:14 -05:00
Bryan Schumaker
3472aec5bf libsaria: Save idl_task to filename
This was hardcoded to "queue.q"

Signed-off-by: Bryan Schumaker <bjschuma@gmail.com>
2012-02-24 09:35:44 -05:00
Bryan Schumaker
98573bf3a9 libsaria: Create a function for reloading a playlist
I don't think I'll need this once I implement dynamic, stackable
playlists, but for now I need a way of scheduling the idle task.

Signed-off-by: Bryan Schumaker <bjschuma@gmail.com>
2012-02-24 09:34:18 -05:00
Bryan Schumaker
f3abd0cbc6 libsaria: Fix sequential_next()
the while(true) created a state where the loop never ended.

Signed-off-by: Bryan Schumaker <bjschuma@gmail.com>
2012-02-24 09:26:25 -05:00
Bryan Schumaker
aaeb4d8fba libsaria: Replace SaveTask and LoadTask
I put in a generic IOTask function.  I'm sure this could eventually be
expanded to open and pass the appropriate stream to functions using this
task.

Signed-off-by: Bryan Schumaker <bjschuma@gmail.com>
2012-02-23 09:57:52 -05:00
Bryan Schumaker
a9abe28d84 libsaria: Don't choose a random song if none are visible
This lead to a floating point exception and crashed Ocarina.  Oops...

Signed-off-by: Bryan Schumaker <bjschuma@gmail.com>
2012-02-23 09:31:10 -05:00
Bryan Schumaker
b5339f8688 libsaria: Remove the library/list subdirectory
I moved all the functions into a single file and bumped that file up one
directory.

Signed-off-by: Bryan Schumaker <bjschuma@gmail.com>
2012-02-23 09:26:02 -05:00
Bryan Schumaker
8a52471c95 libsaria: Remove the old library track list
I've completely replaced it with a Playlist now.

Signed-off-by: Bryan Schumaker <bjschuma@gmail.com>
2012-02-23 09:17:54 -05:00
Bryan Schumaker
b46a4e38ac libsaria: Check random preference in some cases
If both PL_RANDOM and PL_SEQUENTIAL are enabled, then I want to check
the random preference to determine what to do.

Signed-off-by: Bryan Schumaker <bjschuma@gmail.com>
2012-02-23 09:15:04 -05:00
Bryan Schumaker
d902de95cc libsaria: Pick a random song from the playlist
I do this if PL_RANDOM is set before checking PL_SEQUENTIAL.  I still
need to respond to the case that both flags are set...

Signed-off-by: Bryan Schumaker <bjschuma@gmail.com>
2012-02-22 10:10:17 -05:00
Bryan Schumaker
d075773682 libsaria: Give playlists an apparent_size() function
This will return the number of visible songs, instead of the number of
songs in the playlist.

Signed-off-by: Bryan Schumaker <bjschuma@gmail.com>
2012-02-22 10:03:40 -05:00
Bryan Schumaker
9980f53f63 libsaria: Iterate past invisible songs when choosing next
If the PL_FILTER flag is enabled, then we skip songs that aren't
currenly visible.
2012-02-21 10:05:45 -05:00
Bryan Schumaker
c8ad4371d6 libsaria: Added playlist flags and improved next()
The improved next() function will increment the current iterator to the
next visible song.  If no songs are visible, then it moves to the next
song on the list.  The PL_DRAIN flags is then checked, and if draining
is enabled then the current track is removed from the list before
returning.

This patch also switches over the library sequential next function to
use the lib_playlist version.

Signed-off-by: Bryan Schumaker <bjschuma@gmail.com>
2012-02-21 09:47:23 -05:00
Bryan Schumaker
8b9457a8d0 libsaria: Remove library::find_filepath()
I can do this easier with library::lookup() since this avoids having to
loop on the entire track_list.

Signed-off-by: Bryan Schumaker <bjschuma@gmail.com>
2012-02-20 10:02:56 -05:00
Bryan Schumaker
cc224376fa libsaria: Replace library::get_info()
get_info() performed a loop over all library paths and over each track
in each path to find the requested sid_t.  I now keep a map sid_t ->
Track * to make finding the track easier and faster.

Signed-off-by: Bryan Schumaker <bjschuma@gmail.com>
2012-02-20 09:44:57 -05:00
Bryan Schumaker
8069144e87 libsaria: Get library size from the library playlist
Signed-off-by: Bryan Schumaker <bjschuma@gmail.com>
2012-02-20 09:22:47 -05:00
Bryan Schumaker
8af182fac9 libsaria: Change playlists to a list of Track pointers
This allows more direct access to each item in the list.  It also speeds
up sorting, since I don't need to keep looking up the same tracks over
and over again in the library.

Siged-off-by: Bryan Schumaker <bjschuma@gmail.com>
2012-02-19 17:58:23 -05:00
Bryan Schumaker
7b6ecfdd99 libsaria: Sort the Playlist
I do this whenever the sort() function is called.  I eventually want a
more automatic way of doing this, so I expect the function won't exist
for long.
2012-02-19 17:47:29 -05:00
Bryan Schumaker
f352952924 libsaria: Add and remove individual tracks to a playlist
I can easily get the sid_t out of the Track pointer, so I might as well
allow this for now...

Signed-off-by: Bryan Schumaker <bjschuma@gmail.com>
2012-02-19 17:37:04 -05:00
Bryan Schumaker
e52e6ae3b0 libsaria: Don't require filename when creating a Playlist
A Playlist created without a filename will sever be loaded or saved.

Signed-off-by: Bryan Schumaker <bjschuma@gmail.com>
2012-02-19 17:28:13 -05:00
Bryan Schumaker
7a272e35f5 libsaria: Create load and save functions in the Playlist
These create and schedule idle tasks that perform the actual loading or
saving.

Signed-off-by: Bryan Schumaker <bjschuma@gmail.com>
2012-02-19 17:17:26 -05:00
Bryan Schumaker
2813481dff libsaria: Remove old queue code
With Playlists this code is no longer needed.  I'll remove more of this
code once I've updated the UI.

Signed-off-by: Bryan Schumaker <bjschuma@gmail.com>
2012-02-19 17:17:26 -05:00
Bryan Schumaker
57c8fcf030 libsaria: Save a playlist whenever it changes
With this change, my old queue code no longer saves itself.  Instead, it
only sends out QUEUE_REFRESH notifications.

Signed-off-by: Bryan Schumaker <bjschuma@gmail.com>
2012-02-19 17:17:25 -05:00
Bryan Schumaker
00274a836f libsaria: SaveTasks take an extra argument
I want to pass a Playlist through to save a changing playlist.

Signed-off-by: Bryan Schumaker <bjschuma@gmail.com>
2012-02-19 17:17:25 -05:00
Bryan Schumaker
83e3fa4b24 libsaria: Pick next song from the Playlist
Signed-off-by: Bryan Schumaker <bjschuma@gmail.com>
2012-02-19 17:17:25 -05:00
Bryan Schumaker
95aa5802cd libsaria: Remove ids from a playlist
Note that this follows the broken implementation used by the queue.  It
will remove all ids with the given values rather than the ones at a
specifix index.  This will be fixed later when I update the UI to make
it Playlist-aware.

Signed-off-by: Bryan Schumaker <bjschuma@gmail.com>
2012-02-19 17:17:25 -05:00
Bryan Schumaker
7aca058254 libsaria: Give Playlists a size() function
Signed-off-by: Bryan Schumaker <bjschuma@gmail.com>
2012-02-19 17:17:25 -05:00
Bryan Schumaker
6866200e42 libsaria: Implement playlist iterators
I replace the old queue iterator functions with calls to the queue
playlist object that way I don't need to modify the UI.  This creates a
common iterator that can be used by all playlists.

Signed-off-by: Bryan Schumaker <bjschuma@gmail.com>
2012-02-19 17:17:25 -05:00
Bryan Schumaker
356f6c0465 libsaria: Add ids to the queue playlist
I could read the queue file, but that doesn't help me add new songs...

Signed-off-by: Bryan Schumaker <bjschuma@gmail.com>
2012-02-19 17:17:25 -05:00
Bryan Schumaker
2fa54e76ac libsaria: Create a parallel queue as a Playlist
My goal is to slowly phase in use of a Playlist class.  This patch
begins this effort by creating the Playlist class and changing the queue
code to load queue.q as a playlist in addition to the queue's hardcoded
list.

Signed-off-by: Bryan Schumake <bjschuma@gmail.com>
2012-02-19 17:17:25 -05:00
Bryan Schumaker
c452af1ce7 libsaria: LoadTasks take an extra argument
I want to pass a playlist argument through during playlist construction,
so I changed the LoadTask to handle it.

Signed-off-by: Bryan Schumaker <bjschuma@gmail.com>
2012-02-19 17:17:25 -05:00
Bryan Schumaker
7a355d1434 libsaria: Remove the SourceModel class
Nothing has used it in a few months, so it can safely be removed.

Signed-off-by: Bryan Schumaker <bjschuma@gmail.com>
2012-02-19 17:17:25 -05:00
Bryan Schumaker
1470b908c2 libsaria: Remove dir.cpp.orig
Where did this file ever come from?

Signed-off-by: Bryan Schumaker <bjschuma@gmail.com>
2012-02-19 17:17:25 -05:00
Bryan Schumaker
1933689d4f Added copyright lines to everything
I probably should have done this earlier... oh well

Signed-off-by: Bryan Schumaker <bjschuma@gmail.com>
2012-02-19 17:17:24 -05:00
Bryan Schumaker
c3ed28250c libsaria: Return the correct saria directory
My environment variables were set in a way that the path
/home/bjschuma/~/.config/saria-debug was being returned as the working
directory.  Obviously this is wrong, so I changed the function to make
better use of default values when finding the directory.

Signed-off-by: Bryan Schumaker <bjschuma@gmail.com>
2012-02-19 17:14:44 -05:00
Bryan Schumaker
98a2dc316a libsaria: Free alsa value array
I don't want to be leaking memory...

Signed-off-by: Bryan Schumaker <bjschuma@gmail.com>
2012-02-11 12:57:22 -05:00
Bryan Schumaker
01bd48d6cc libsaria: Call add_alsa() during startup
Rather than resetting the preference, it's easier to call the add_alsa()
function if the preference is set.  This also cuts down on startup
warnings!

Signed-off-by: Bryan Schumaker <bjschuma@gmail.com>
2012-02-11 12:57:22 -05:00
Bryan Schumaker
bec76743da libsaria: Call gst_quit()
This gives gstreamer a chance to free anything it's created.

Signed-off-by: Bryan Schumaker <bjschuma@gmail.com>
2012-02-11 12:57:22 -05:00
Bryan Schumaker
9e322433d5 libsaria: Set about-to-finish from ALSA
I've found that without ALSA enabled, the about-to-finish will hang.  To
solve this, I only enable it when ALSA is enabled.

Signed-off-by: Bryan Schumaker <bjschuma@gmail.com>
2012-02-09 08:04:52 -05:00
Bryan Schumaker
280baa7572 libsaria: Allow different UIs to use a different pipe
The UI now passes in a string to use as the filename.  In addition, I
store the filename and remove it when the application is closed.  If the
pipe already exists, then I return the path without creating a new one.

Pipes will only be removed by the application that creates them.

Signed-off-by: Bryan Schumaker <bjschuma@gmail.com>
2012-02-08 08:11:13 -05:00
Bryan Schumaker
8623779210 libsaria: Reduce library refreshes during update
The library only needs to refresh if new tracks were found, so don't do
anything if nothing new has been added.

Signed-off-by: Bryan Schumaker <bjschuma@gmail.com>
2012-02-08 08:11:13 -05:00
Bryan Schumaker
01288e1a86 Libsaria: Make alsa controls its own thing
I created a new preference for "Using ALSA" that people can set if they
want to use extra alsa features.  This should allow the UI to provide a
dropdown list of outputs that users can select.  Once a UI is in place,
users can play music either on their computer speakers or pipe it out to
their blu ray players (or other device).

Signed-off-by: Bryan Schumaker <bjschuma@netapp.com>
2012-02-08 08:11:13 -05:00
Bryan Schumaker
82b9974448 libsaria: Get the path to the pipe file
This will either return the full path to the file or an empty string if
no pipe has been created.
2012-02-08 08:11:13 -05:00
Bryan Schumaker
b2f72df146 libsaria: Don't notify_audio_changed() in main loop
I have a hard time remembering how this works, so instead I leave it up
to the UI to determine how to handle this event running from multiple
threads.

Signed-off-by: Bryan Schumaker <bjschuma@gmail.com>
2012-02-08 08:11:13 -05:00
Bryan Schumaker
747ba85fbb libsaria: Never return negative duration
A negative duration doesn't make sense, so return 0 instead.

Signed-off-by: Bryan Schumaker <bjschuma@gmail.com>
2012-02-08 08:11:13 -05:00
Bryan Schumaker
e7e1bb352a libsaria: Remove OutFile print statement
It was triggering too often during a library update, so I removed it.

Signed-off-by: Bryan Schumaker <bjschuma@gmail.com>
2012-02-08 08:11:13 -05:00
Bryan Schumaker
c7abfb6496 libsaria: Save queue in a background task
We can easily do this a little bit later to improve performance.

Signed-off-by: Bryan Schumaker <bjschuma@gmail.com>
2012-02-08 08:11:13 -05:00
Bryan Schumaker
808927da45 libsaria: Export size of a library path to the UI
Signed-off-by: Bryan Schumaker <bjschuma@gmail.com>
2012-02-08 08:11:13 -05:00
Bryan Schumaker
1daa12ee81 libsaria: Create a library path iterator
This makes it easier to loop over all the library paths without needing
to know anything about implementation.  I modified the update functions
to use the new way, so it should be ready for use by the UI.

Signed-off-by: Bryan Schumaker <bjschuma@gmail.com>
2012-02-08 08:11:13 -05:00
Bryan Schumaker
12b193cc80 libsaria: Move LibraryPath to a global header
I am going to expose this class to the UI so it can directly access
information (size, path, ...).

Signed-off-by: Bryan Schumaker <bjschuma@gmail.com>
2012-02-08 08:11:12 -05:00
Bryan Schumaker
d6c48ca177 libsaria: Add the library path to the libsaria namespace
I want to move it to a global header file, so it needs to be added to
the libsaria namespace.

Signed-off-by: Bryan Schumaker <bjschuma@gmail.com>
2012-02-08 08:11:12 -05:00
Bryan Schumaker
3d511a1f19 libsaria: Remove old callback framework
I moved ocarina over to the new system, so the old one can go away now
since it isn't thread safe and nothing uses it anymore.

Signed-off-by: Bryan Schumaker <bjschuma@gmail.com>
2012-02-08 08:11:12 -05:00
Bryan Schumaker
7150e8bdee libsaria: Prepare for a single callback handler function
Rather than keeping a map of function pointers, I want the UI to
register a single function that takes a callback_t as an argument.  From
there, the UI can decide the best way to handle callback lookups (such
as grabbing a lock before changing anything).  At the very least, a
switch statement or array lookup should be faster than searching a map.

Signed-off-by: Bryan Schumaker <bjschuma@gmail.com>
2012-02-08 08:11:12 -05:00
0d63656df8 Fixed bug with unset environment variable.
When either HOME or XDG_CONFIG_HOME are unset getenv() can return NULL.
C++ strings don't like being set to NULL, so we need to check for this
case.

Bryan: Edited Sconstruct and commit message.

Signed-off-by: Josh Larson <theMutatedShrimp@gmail.com>
Signed-off-by: Bryan Schumaker <bjschuma@gmail.com>
2012-02-08 08:10:19 -05:00
Bryan Schumaker
fe7bf9e445 libsaria: Check if a song exists before loading it
This could lead to a segmentation fault if we don't do it...

Signed-off-by: Bryan Schumaker <bjschuma@gmail.com>
2012-02-07 22:25:13 -05:00
Bryan Schumaker
51e5887971 libsaria: Rename the index rand() function
I found it was calling itself over and over again, rather than calling
the stdlib rand().  This wasn't the desired behavior...

Signed-off-by: Bryan Schumaker <bjschuma@gmail.com>
2012-02-07 08:47:24 -05:00
Bryan Schumaker
3e458e2d9f libsaria: Validate library before adding new songs
If a file has been moved to another location in the same library root
the new location won't be added since it'll have the same inode number.
The track would then be removed during the library validation step.  I
switch the order for correctness.
2012-01-04 08:22:21 -05:00
Bryan Schumaker
b503536d57 libsaria: Fix iterator initializer bug
It was being initialized with '==' instead of '=', so the for loop was
always causing a segmentation fault.  This was caused by commit
180707a6c2

Author: Bryan Schumaker <bjschuma@gmail.com>
Date:   Thu Dec 29 22:08:53 2011 -0500

	libsaria: Remove redundant code

	Nothing needs to call this function anymore.  I also cleaned
	up the header file a bit.
2011-12-31 11:19:31 -05:00
Bryan Schumaker
e21f0e251c libsaria: LibraryPath()s load their own directory
It makes more sense to set this variable directly from the save file
rather than read it in and pass it as an argument.
2011-12-31 11:13:36 -05:00
Bryan Schumaker
41ec0b68e0 libsaria: Validate library tracks after updating
I check two things during this step:

1) Does the file still exist?
2) Does the file have the same inode number?

If the answer to either of these is "no", then the track is removed from
the library.
2011-12-31 10:48:05 -05:00
Bryan Schumaker
3fa1331303 libsaria: Remove ids from the queue
In case the user changes their mind...
2011-12-30 23:27:15 -05:00
Bryan Schumaker
425c7421ed libsaria: Switch to using a list for the queue
A deque won't allow me to remove elements from anywhere in the queue, so
using a linked list is a better choice.
2011-12-30 23:15:07 -05:00
Bryan Schumaker
d655739b77 libsaria: Save queue to disk
This will restore the queue the next time ocarina is started up.
2011-12-30 20:26:36 -05:00
Bryan Schumaker
8a0922c4a1 libsaria: Generic LoadFile() task
This was specific to the library namespace, but I think it makes more
sense to exist as a global class definition that can be reused by
others.
2011-12-30 20:22:47 -05:00
Bryan Schumaker
11e82cccf1 libsaria: Save queue to disk
I save when IDs are added and when a next track is chosen.
2011-12-30 20:02:24 -05:00
Bryan Schumaker
4dac0fe096 libsaria: New current_track() function
Instead of taking a callback function,  I instead find a pointer to the
current track and return this to the caller.
2011-12-30 19:47:13 -05:00
Bryan Schumaker
0ef8e44207 libsaria: Remove unused variable from Track() 2011-12-30 19:46:54 -05:00
Bryan Schumaker
a44ecbb795 libsaria: Remove old readdir() function
It's not used anymore...
2011-12-30 19:15:03 -05:00
Bryan Schumaker
ab0e459298 libsaria: Change track cleanup process
Tracks only need to be unlisted from the library list when they are
manually removed by the user.  Trying to do this during shutdown lead do
a segfault because the library's file_list had already been removed when
I tried to access it.
2011-12-30 16:42:04 -05:00
Bryan Schumaker
2a9900c1e5 libsaria: Tracks remove themselves from the list
This is mostly for when a library path is removed from the list.  Tracks
all remove themselves when destroyed, and then the library can be
refreshed.
2011-12-30 16:05:35 -05:00
Bryan Schumaker
26979eb6a9 libsaria: Track()s add themselves to the index and library
When one is created, it adds itself to the library and index.  Up next:
removing themselves when they are destroyed.
2011-12-30 15:57:14 -05:00
Bryan Schumaker
6b7c3f3d50 libsaria: Use dynamic memory for library tracks
This allows me to create only one Track() instance for each song in the
library.  Before this, a Track() was being created and then copied when
adding new songs to the library.  I thought this was wasteful, so now
each song is only created once.
2011-12-30 15:50:21 -05:00
Bryan Schumaker
ff4fcbf809 libsaria: Clean up path scanning code
I have an easier time figuring out what's going on now.
2011-12-30 15:03:45 -05:00
Bryan Schumaker
180707a6c2 libsaria: Remove redundant code
Nothing needs to call this function anymore.  I also cleaned up the
header file a bit.
2011-12-29 22:08:53 -05:00
Bryan Schumaker
bdf359e008 libsaria: Remove path.cpp file
I moved these functions into the main library.cpp file
2011-12-29 21:54:51 -05:00
Bryan Schumaker
8e8eec3556 libsaria: Move update_path() function
Now it's in the library.cpp file.
2011-12-29 21:42:07 -05:00
Bryan Schumaker
dbeb2981d4 libsaria: Move update code to path subdir
This keeps it all together and makes editing the library less confusing.
2011-12-29 21:12:27 -05:00
Bryan Schumaker
ad989fdcd7 libsaria: Move more LibraryPath() code to the subdirectory 2011-12-29 21:02:24 -05:00
Bryan Schumaker
df7e677bf2 libsaria: Remove unused LibraryPath function
I don't need to get the list of tracks anymore, now that my for_each
function has been removed.
2011-12-29 20:46:01 -05:00
Bryan Schumaker
d74efc6022 libsaria: Remove barely used size function from LibraryPath
It was used internally once and externally once (to print out the
current size).  It can easily be removed to clean things up.
2011-12-29 20:43:46 -05:00
Bryan Schumaker
995a372a6e libsaria: Library code can access the path_list directly
This makes more sense than using an accessor function.  Nothing outside
the library can use this variable, so there shouldn't be other problems.
2011-12-29 20:37:05 -05:00
Bryan Schumaker
fe8a293377 libsaria: Move library's LoadTask() to file.cpp
This is the only place it's used, so it makes sense to define it there.
2011-12-29 20:31:54 -05:00
Bryan Schumaker
9da577daa0 libsaria: Begin moving LibraryPath class to subdirectory
I think it'll be easier to work with if it is self-contained in a
subdirectory.  Otherwise it's too mixed in with the library code to be
maintainable.
2011-12-29 20:27:04 -05:00
Bryan Schumaker
63140fb6a0 libsaria: Remove queue for_each
It's been replaced with iterator functions.
2011-12-29 16:25:34 -05:00
Bryan Schumaker
fe8c1cd580 libsaria: Create iterator functions for the queue 2011-12-29 16:24:33 -05:00
Bryan Schumaker
3749b56bfd libsaria: Remove old list file
I've completely replaced it with my new list now.
2011-12-29 15:47:11 -05:00
Bryan Schumaker
ec2aadbc2d libsaria: Move get_info() function to new list 2011-12-29 15:43:17 -05:00
Bryan Schumaker
fb0084c275 libsaria: Remove old play_id() function
Nothing uses it anymore
2011-12-29 15:35:06 -05:00
Bryan Schumaker
8049a7a9fd libsaria: Select songid using libsaria controls.cpp
I do this in the upper level namespace, rather than doing it in the
library, to make use of the play_filepath() function that I already have
written.
2011-12-29 15:32:15 -05:00
Bryan Schumaker
c1cc33877c libsaria: Find filepath from songid using new list 2011-12-29 15:30:30 -05:00
Bryan Schumaker
7b78f18e52 libsaria: Remove next() from the queue
I don't need it anymore.
2011-12-29 15:10:00 -05:00
Bryan Schumaker
bcc34ef4b0 libsaria: Choose next song from the new list
I removed the old list functions while I was at it.  I also changed the
next() function in the controls.cpp file to work with filepaths so the
library and queue won't have to load the chosen file themselves.
2011-12-29 15:06:12 -05:00
Bryan Schumaker
942c518394 libsaria: Remove for_each() from library
I don't need it anymore.
2011-12-29 14:20:53 -05:00
Bryan Schumaker
fea84b90ac libsaria: Move list size function
It now exists with my new playlist code, since I'm phasing out the old
code.
2011-12-29 12:28:00 -05:00
Bryan Schumaker
2fd41ff4d7 libsaria: Create iterator functions for the library
I use these to fill in the UI list for the library.  I think this will
be easier to use (and cleaner) than passing a function pointer to a
for_each loop.
2011-12-29 12:08:32 -05:00
Bryan Schumaker
0fa608c90f libsaria: Sort the new playlist after reading
Otherwise it won't be useful...
2011-12-28 23:04:41 -05:00
Bryan Schumaker
2effa26b32 libsaria: Began new playlist namespace
It'll exist in parallel to the current list for now.  I'll remove the
old one once the new one has all the same features.
2011-12-28 22:25:55 -05:00
Bryan Schumaker
336f188686 libsaria: Sort list using comparison operator
It makes sense to define a function for sorting tracks as part of the
track class, rather than having to implement it externally.
2011-12-28 22:03:43 -05:00
Bryan Schumaker
1e5628d059 libsaria: Find lowercase tags when creating a track
This avoids several lookups during list sorting, so initial startup
should be a little bit faster now.
2011-12-28 17:40:11 -05:00
Bryan Schumaker
a3130a7da5 libsaria: Cache lowercase strings, too
This is useful for sorting the library when filling in the list, since I
do many comparisons with the same artists and albums.  This beats having
to lowercase them every time!
2011-12-28 11:00:08 -05:00
Bryan Schumaker
8e4b3dfbfe libsaria: Don't track cache misses
Each cache miss will add a new word to either the format cache or the
substring cache.  I can look at the size of the caches to determine the
number of misses rather than keep track of this with a new variable.
2011-12-28 10:23:17 -05:00
Bryan Schumaker
147a212809 libsaria: Format to a set of words
I don't care about the order of words for indexing, and I don't need
duplicates either.  Formatting to a unique set of words should make
things a little faster.
2011-12-28 10:15:08 -05:00
Bryan Schumaker
abfd67cc84 libsaria: Refresh index while scanning
This keeps the index up-to-date with the library.  Tracks are indexed as
they are scanned, then the current filter string is run through the
index again to update it.
2011-12-27 23:02:09 -05:00
Bryan Schumaker
26a18f331e libsaria: Remove old index code
It has been replaced with my new index.
2011-12-27 22:42:50 -05:00
Bryan Schumaker
1d3baa79d5 libsaria: Implement index::rand()
Needed to get a random song from the index when filtered.
2011-12-27 22:41:54 -05:00
Bryan Schumaker
83488dfa06 libsaria: Add filtering to the new index
Otherwise it's useless.  I search all three indexes and use the union of
those results to determine what is visible.
2011-12-27 22:30:38 -05:00
Bryan Schumaker
9c749e4ade libsaria: Began new index
Right now I just add songs to it and cache substrings for each word.  I
also print out stats during libsaria shutdown.
2011-12-27 19:42:46 -05:00
Bryan Schumaker
52a3e73023 libsaria: Print format_cache stats
I wanted to know how often there were cache hits and misses, so I print
out these stats on shutdown.
2011-12-27 19:42:27 -05:00
Bryan Schumaker
664ad0dad2 libsaria: Cache words generated from strings
I now look up a list of words from a map (if it exists), rather than
having to iterate over the same string potentially many times.
2011-12-27 18:48:57 -05:00
Bryan Schumaker
a74cea2e71 libsaria: Remove old TrackTag() class
It was basically a layer of misdirection that made it harder to use
Tracks.  The Track() class now does everything that the TrackTag() one
did.
2011-12-26 12:14:25 -05:00
Bryan Schumaker
5f20899b14 libsaria: Remove references to ino_t
I want to use sid_t instead.  It's more obvious what it's used for.
2011-12-25 23:29:35 -05:00
Bryan Schumaker
e4f7fde197 Create a typedef for song ids
Passing around an inode number doesn't tell people what the inode is
used for.  Typedefing it to a song id is more helpful.
2011-12-25 23:07:58 -05:00
Bryan Schumaker
da118b2281 libsaria: Switch to the new OutFile() class
The new class is more convenient to work with since it's the output
stream with my save protocol built in.  I should have done this earlier!
2011-12-25 22:34:12 -05:00
Bryan Schumaker
5877d3ac4a libsaria: Created a new OutFile() class
Similar to how I created a new InFile() class.  The new one can be used
directly as a stream, only it has my save file protocol stuff built in.
2011-12-25 22:21:11 -05:00
Bryan Schumaker
6794ce15e5 libsaria: Return ifstream reference from operator>>
This allows me to chain calls to the same stream, cleaning up the code.
2011-12-25 22:20:04 -05:00
Bryan Schumaker
d39536d7d0 libsaria: Completely replace old InFile() class
My InFile2() class is clearer and simpler, so I've replaced InFile()
with it.
2011-12-25 21:24:02 -05:00
Bryan Schumaker
5e308202a0 libsaria: Create a new way to save files
I inherit from the ifstream class, so I can override the insertion
operator for string handling.  I can then use templates to save
everything else.
2011-12-25 21:16:09 -05:00
Bryan Schumaker
603a76964b libsaria: Store current audio volume
This allows me to restore the volume on startup.
2011-12-23 22:04:24 -05:00
Bryan Schumaker
f7d7d5e038 libsaria: Add floats as preferenc type
Now I can store floating point numbers in addition to booleans.
2011-12-23 22:03:31 -05:00
Bryan Schumaker
8dfbb8915b libsaria: Check for current file before attempting state change
Without this, pressing "play" on an empty library will cause an error.
The recovery code will then try to pick a new song, and fail (since
there are no tracks to choose from).  It will then try to play, cause an
error and repeat forever.
2011-12-23 21:18:45 -05:00
Bryan Schumaker
1dc9df80e1 libsaria: Cleanup audio progress code 2011-12-23 21:14:14 -05:00
Bryan Schumaker
0e983e4043 libsaria: Implement gapless playback
I need to get the next file out of the library or queue without changing
it immediately.  I then queue it up in the gstreamer pipeline so it will
play automatically when the current track finishes.
2011-12-23 20:48:37 -05:00
Bryan Schumaker
2783b8d995 libsaria: Improved audio file loading
I look for an audio-changed signal and push this to the message bus.  I
then use the message to send out the TRACK_LOADED callback to the UI.
This should be even more useful for gapless playback.
2011-12-23 20:46:02 -05:00
Bryan Schumaker
7711b354cb libsaria: Create a durstr() function
Call this to get a string representation of the pipeline's current
duration.
2011-12-23 20:31:07 -05:00
Bryan Schumaker
e509d4e723 libsaria: Added comments
I'll be able to figure out these functions easier the next time I see
them.
2011-12-23 16:04:28 -05:00
Bryan Schumaker
04a64ca015 libsaria: Use a load_file() function
All this function does is load a file.  Nothing else.  I think this will
be useful for using about-to-finish.
2011-12-23 16:03:10 -05:00
Bryan Schumaker
f8f5f87e54 libsaria: Remove the get_player() function
I declared the variables in the local header file for use by the audio
layer.  I think this will make things a bit more efficient.
2011-12-23 15:49:56 -05:00
Bryan Schumaker
3944e691a5 libsaria: New controls
I added functions for rewinding, fast forwarding, and toggling play /
pause.  This should make it easier on the UI.
2011-12-23 15:48:08 -05:00
Bryan Schumaker
df1e1a0a9a libsaria: Replace the old print() function
I now use a wrapper around printf() that can be disabled when debugging
is off.
2011-12-18 15:07:01 -05:00
Bryan Schumaker
81e7662c7e libsaria: Track current gstreamer state
I use this to tell the GUI if music is currently playing or not.
2011-12-17 09:44:24 -05:00
Bryan Schumaker
a10fd2f5a0 libsaria: Print size of queue
I needed this for debugging, so I'll leave it there.
2011-12-17 09:44:11 -05:00
Bryan Schumaker
5c6d7903a8 libsaria: Pause after current song
What if you want to leave and a good song starts playing?  This solves
the problem by loading the next song, but not playing it so the user can
go away and listen to it when they come back.
2011-12-11 21:03:09 -05:00
Bryan Schumaker
304b581274 libsaria: Check if $HOME is part of $XDG_CONFIG_HOME
On one machine it is, on another it isn't.  This should be a solution
that works for everybody.
2011-12-11 20:26:39 -05:00
Bryan Schumaker
83867dba2c libsaria: Reindex on library refresh
This should allow me to filter while the library is scanning.
2011-12-11 20:25:53 -05:00
Bryan Schumaker
e983d69322 libsaria: Chose next songs from the queue
If there are songs in the queue, I pick from there.  Otherwise, I pick
from the library.
2011-12-11 16:25:24 -05:00
Bryan Schumaker
6ef54e07c5 libsaria: Add songs to the queue
It takes a list of song ids and adds them to a deque.  The UI can then
iterate over each ID and query the size.
2011-12-11 16:16:02 -05:00
Bryan Schumaker
9739bdc76a libsaria: Library get_info() returns TrackTag
I simplify the function by removing the function pointer call and
letting callers deal with the TrackTag pointer it now returns.
2011-12-11 16:14:53 -05:00
Bryan Schumaker
56eee0ae22 libsaria: Added queue
I do this as a double-ended queue so I can remove songs anywhere I want
(and hopefully re-order them later, too).
2011-12-11 15:46:58 -05:00
Bryan Schumaker
57bf72c4e5 libsaria: Get utf8 encoded strings from taglib
This should cut down on the number of pango errors that I see when
filing in lists.
2011-12-11 15:46:44 -05:00
Bryan Schumaker
0b4d9c25eb libsaria: Use absolute paths for saria dirs
I noticed that new save files weren't being created.  I now use the HOME
environment variable to construct an absolute path to write files to.
2011-12-11 15:46:40 -05:00
Bryan Schumaker
a14cedc942 libsaria: Choose songs after filtering
Songs are only picked from the set of visible songs after filtering.
2011-12-11 15:46:35 -05:00
Bryan Schumaker
f0decd07d6 libsaria: Load library through an idle task
This allows me to draw the UI first and load the library once that has
finished.  This should make Ocarina feel more responsive.
2011-11-13 13:44:45 -05:00
Bryan Schumaker
ffbaff27ec libsaria: Change the number of tracks indexed at once
I was doing 50, but I think I can handle 100.  I also defined a constant
at the top of the file to make it easier to change this value again in
the future.
2011-11-13 12:43:02 -05:00
Bryan Schumaker
6e033513c0 libsaria: Refilter during indexing
I trigger a REFILTER callback after each IndexTask is processed to keep
the UI up to date with the current index.
2011-11-13 12:40:42 -05:00
Bryan Schumaker
b36def4c08 libsaria: Change library size when filtered
I return the number of visible songs, so if the user has entered a
filter string then I return the size of the results set.  If we're not
filtered then I return the size of the playlist.
2011-11-13 12:21:00 -05:00
Bryan Schumaker
fa498f379c libsaria: Added an is_visible() function
This will return true if the given inode is visible.
2011-11-13 12:05:03 -05:00
Bryan Schumaker
75cb804756 libsaria: Added a REFILTER callback
This will be called to inform the UI that the filter text has changed.
2011-11-13 11:33:12 -05:00
Bryan Schumaker
824f589ff2 libsaria: Perform filtering
I use an in-place set intersection to find a set of songs that match the
search terms.
2011-11-13 11:29:41 -05:00
Bryan Schumaker
1c0084b2e9 libsaria: Created a generic format_text() function
This is used by the track tags for creating word lists.  I also use the
function to format filter search text.
2011-11-13 10:47:55 -05:00
Bryan Schumaker
d5df6e134b libsaria: Build the substring index
This is an index of every substring in the (artist, album, title) tags
of the library.  This should be easier to work with than regular
expression based filtering since I don't need to compare every key with
every search term.
2011-11-13 09:48:50 -05:00
Bryan Schumaker
7fc4e22795 libsaria: Call a dummy index function for each TrackTag
This function takes an inode and word list.  Soon it will add each
substring to an index.
2011-11-12 19:31:42 -05:00
Bryan Schumaker
fc50ceb34f libsaria: Format each tag as it is read in
I lowercase everything, strip out some characters, and create a linked
list of each word for each tag.
2011-11-12 19:21:41 -05:00
Bryan Schumaker
ef36c58e96 libsaria: Create an IdleTask for indexing the library
Right now this will only be triggered when the library is loaded from
disk.  Once I get farther I can easily create a function to index a
track as it is added to the library (so I won't need to reindex
everything during this case)
2011-11-12 14:25:32 -05:00
Bryan Schumaker
958020f270 libsaria: Check stream status before reading
If we are unable to open the preferences file we shouldn't try to read
from it.  This led to a segmentation fault when compiled in release
mode, but for some reason it worked when compiled in debug mode?
2011-11-09 17:28:19 -05:00
Bryan Schumaker
026bf0c010 libsaria: Only load song if string is not empty
It's stupid to try loading an empty string.
2011-11-09 08:33:40 -05:00
Bryan Schumaker
11d92eef89 libsaria: Add a debugging message
Helpful for knowing what path the audio subsystem is attempting to load.
2011-11-08 08:19:47 -05:00
Bryan Schumaker
258ebbc081 libsaria: Choose the next song based on the random setting
If random is enabled, I choose a random song from the list.  If random
is disabled I choose the next song sequentially.
2011-11-07 18:33:15 -05:00
Bryan Schumaker
b6f21d5705 libsaria: Added preferences
Right now I only store boolean values, but I think I've coded this in a
way to make adding new values easy.
2011-11-07 08:30:53 -05:00
Bryan Schumaker
c1332133a9 libsaria: Change meaning of audio::seek_to()
It used to seek to a percentage of the pipeline, but now is seeks to an
absolute position in nanoseconds.
2011-11-06 20:25:13 -05:00
Bryan Schumaker
6b58311e9e libsaria: Call next() at the end of the stream
It's nice to pick another song after the end of the current one.
2011-11-06 19:44:16 -05:00
Bryan Schumaker
e908f46c21 libsaria: Implement a next() function
This will pick the next song from the library to play.
2011-11-06 19:17:15 -05:00
Bryan Schumaker
9379a2cf33 libsaria: Better track comparision function
I sort by artist / album / track, so I need to check each of these
fields in order.  It would be nice if I could expand numbers into words
for some tags (3 Doors Down, Matchbox 20 and so on), but I'm happy with
what I have right now.
2011-11-06 15:44:45 -05:00
Bryan Schumaker
858fa1821f libsaria: Turn the play_list into a list of pointers
Pointers to a TrackTag structure are easier to pass around than the
TrackTag structure, so this should speed up sorting.  Also it removes
duplicated memory between the LibraryPaths and the play_list.
2011-11-06 13:57:09 -05:00
Bryan Schumaker
095ade27ad libsaria: Sort play_list by artist
Right now I do a basic string comparison.  I should eventually format
the strings to remove punctuation and use the same case.
2011-11-06 13:49:20 -05:00
Bryan Schumaker
4f2c75499f libsaria: Clean up LibraryPath class
I moved around some code and removed undefined functions
2011-11-06 13:39:14 -05:00
Bryan Schumaker
922c9e86ef libsaria: Get info from play_list
It's easier with everything in one single list.
2011-11-06 13:36:11 -05:00
Bryan Schumaker
5ae5a349de libsaria: Play tracks from the play_list
Rather than finding the id in the LibraryPath lists, I instead find it
in the play_list list and store an iterator to this track.
2011-11-06 13:15:48 -05:00
Bryan Schumaker
b3cb20dd5d libsaria: Properly set the inode for each track tag
I was setting local variables rather than the TrackTag variable.  No
wonder things didn't work
2011-11-06 13:09:59 -05:00
Bryan Schumaker
5b2e0c7b82 libsaria: Fill a SourceModel from the play_list
Looping over a single list is really easy and straightforward!
2011-11-06 12:44:14 -05:00
Bryan Schumaker
cdcaaeb8c8 libsaria: Report the library size as the play_list size
This is simpler than looping over all library paths and adding up their
individual sizes.
2011-11-06 12:39:13 -05:00
Bryan Schumaker
637ea47a60 libsaria: Insert all tracks into one giant list
This puts everything in one place for easy use (I hope)
2011-11-06 12:34:41 -05:00
Bryan Schumaker
b55ac22866 libsaria: Introduce a rebuild_list() function
I am going to create a play list in memory based on the state of the
library.  To do this, I first need a way to trigger construction of a
list.
2011-11-06 12:16:54 -05:00
Bryan Schumaker
7507955018 libsaria: Fix bug in updating library
I was readding all tracks to the new linked list, rather than checking
if the track existed first.  This has been fixed.
2011-11-06 12:11:31 -05:00
Bryan Schumaker
b5c8efc6d5 libsaria: Move LibraryPath functions to path.cpp
This is really what path.cpp is all about.
2011-11-06 11:50:16 -05:00
Bryan Schumaker
d23c1c72f0 libsaria: Move library update code to new file
Putting it all in path.cpp along with other LibraryPath functions was
getting confusing.  I'd rather just have it all in a new file for
simplicity.
2011-11-06 11:47:26 -05:00
Bryan Schumaker
297c0637ea libsaria: Rename path list accessor functions
I added these functions into the library namespace so I can remove the
"_library_" part of the function names.
2011-11-06 11:36:12 -05:00
Bryan Schumaker
d678a5c170 libsaria: Move library path constructor
This constructor creates a library path from a file, so it makes sense
to store it in file.cpp instead of path.cpp.
2011-11-06 11:29:38 -05:00
Bryan Schumaker
6d7828b946 libsaria: Store library path as a linked list of track tags
Lookup by id will be slighly slower, but now I will have one list for
each path that can be merged together and sorted to represent the
library.  This sounds like a good tradeoff to me, especially since I can
store an iterator to the current track when deciding what to play next.
This will give me much faster access to song for the current track.
2011-11-06 11:16:46 -05:00
Bryan Schumaker
9c0e61b42d libsaria: Create track tags with an inode
I need to store the inode somewhere if I want to use a linked list to
store LibraryPath data.  I currently have a map <ino_t, TrackTag>, so
the obvious choice is to store the inode in the TrackTag structure.
2011-11-06 10:54:45 -05:00
Bryan Schumaker
8609b9a6a7 libsaria: Use a linked list of library paths
I was using a map, but the map required duplicating the library path
everywhere.  Except for removing a path, I don't ever need to look up a
specific path by name, so why bother optimizing this case?  Iterating
over a linked list should be more efficient (and easier to comprehend)
2011-11-06 10:43:35 -05:00
Bryan Schumaker
9f6320ce18 libsaria: Return empty string when no song loaded
I was returning "0:00", but I think an empty string looks better.
2011-11-02 08:25:17 -04:00
Bryan Schumaker
0a216c38ce libsaria: Return the current audio position as a string
This returns it in mm:ss format for easy use by the UI
2011-11-02 08:20:26 -04:00