Commit Graph

548 Commits

Author SHA1 Message Date
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
Bryan Schumaker c75d832934 libsaria: Give the audio separate position() and duration() functions
The UI can use these functions to set up an accurate progress bar based
on the number of nanoseconds each returns.
2011-11-01 22:47:04 -04:00
Bryan Schumaker 8987dddade libsaria: Added a get_progress() function to the audio namespace
This function is used to access how far into the song the current audio
position is.  The value is returned as a percentage of the total length
for easy use by the UI.
2011-10-29 17:23:25 -04:00
Bryan Schumaker 0da84e8151 libsaria: Find tags for songs not in the library
I always want to find tags if it's possible.  Since I already have a way
to find the tags, it's fairly simple to tag a random file and pass the
result back to the UI.
2011-10-29 16:26:26 -04:00
Bryan Schumaker 049f91e514 libsaria: Return default track values in error case
If we can't find the inode, I return some default values to the UI to
keep it happy (and clear out the information from the previous song).
2011-10-29 16:18:15 -04:00
Bryan Schumaker 136f12bc7c libsaria: Created a SourceModel class
The source model class is used to more tightly control how songs are
inserted into the UI.  I provide an insert() function that the library's
for_each() function can take advantage of.  This allows me to directly
insert songs into the UI rather than having to use a static function as
the "middle man"
2011-10-29 15:19:45 -04:00
Bryan Schumaker 39f74eb6b4 libsaria: Various cleanups
- Pass inodes by reference
- Change some namespace code formatting to match later code
2011-10-28 17:02:46 -04:00
Bryan Schumaker a975fcc2cc libsaria: Added a current_track() function
This function will generate a Track object based on the current file
stored by the audio.  I then pass this object to to provided function so
the UI can be updated.
2011-10-28 15:33:17 -04:00
Bryan Schumaker 9997e6ffa6 libsaria: Added TRACK_LOADED callback
This is triggered whenever a new track is loaded.
2011-10-28 14:37:18 -04:00
Bryan Schumaker 707e7b3427 libsaria: Create an idle namespace
This cleans up the idle task code a lot, and reduces the size of
ocarina.bin to less than 1MB (with full debugging).  It probably won't
stay there long...
2011-10-27 15:18:03 -04:00
Bryan Schumaker c8dc6e1ee8 libsaria: Queue idle tasks from the task class
This is cleaner than calling an outside function since the task can
easily queue itself up.
2011-10-27 14:43:18 -04:00
Bryan Schumaker 90ac1ecfed libsaria: Massive audio cleanup
I removed libsaria/audio.cpp and did some namespace shuffling.  The new
code should be easier to follow and work with.
2011-10-27 14:31:30 -04:00
Bryan Schumaker 4f26d9ee2d libsaria: Update single paths
Updating a single LibraryPath may sometimes be faster than updating the
entire library.
2011-10-20 20:31:09 -04:00
Bryan Schumaker 245157c6b4 libsaria: Remove paths from library
If the user no longer wishes to track a certain path, they can remove it
from the library.  Note: it is unsafe to remove a path from the library
while that path is being scanned.  This could potentially lead to a
segmentation fault.
2011-10-20 20:18:35 -04:00
Bryan Schumaker c4cdfbe4b3 libsaria: Added library::update()
This will rescan every library path and add new files to the library.
Eventually it should probably remove files that no longer exist...
2011-10-20 13:24:11 -04:00
Bryan Schumaker 2a6d05ebee libsaria: Fill out a struct PathInfo
This struct is used by the gui to show how large a library path is
and eventually to remove it from the library.
2011-10-20 13:24:08 -04:00
Bryan Schumaker 8cf3caeb27 libsaria: Added function for getting the library size
I like to show this on the library tab so I know how many songs are
currently in the library.
2011-10-19 09:58:30 -04:00
Bryan Schumaker a508b7ff72 libsaria: Rip out old library
The code was a bit messy and didn't make use of namespaces very well.
By converting to a set of functions (instead of a class) I can use
each function as a function pointer if I want to.  I am also able to
remove libsaria/library.cpp since this was just a set of wrapper
functions to the old static class functions.
2011-10-18 10:02:55 -04:00
Bryan Schumaker c8daf92af4 libsaria: Save to XDG_CONFIG_HOME
I plan on storing all my preferences there rather than creating my own
save directory.  This will keep things consistent with other
applications the user may have.
2011-10-02 10:52:23 -04:00
Bryan Schumaker cea236a757 libsaria: Introduce libsaria namespace
Now I don't need to define everything as libsaria_some_func(), instead
these functions will exist in the libsaria namespace.
2011-10-01 13:27:31 -04:00
Bryan Schumaker 1a7b8a5ae9 libsaria: Load a saved library
No point in saving a library if I can't make use of the save file later.
2011-09-30 08:12:26 -04:00
Bryan Schumaker 1d1ecc8d8c libsaria: Save the library scan results
I write each track to a file that will be read in on startup (once those
changes are committed)
2011-09-27 08:23:49 -04:00