Commit Graph

50 Commits

Author SHA1 Message Date
Bryan Schumaker 5bc357be18 libsaria: Remove operator[] for strings
Public member variables is easier.

Signed-off-by: Bryan Schumaker <bjschuma@gmail.com>
2014-04-06 19:56:50 -04:00
Bryan Schumaker 05bbad5444 libsaria: Resizing a vector invalidates pointers
I was keeping a vector of objects, and then pass pointers to these
objects around everywhere.  HOWEVER, when vectors are resized they
allocate new memory and copy things over invalidating iterators and
pointers to the original objects.  This can cause memory corruption
issues when I try to use a pointer to an object that no longer exists.

The simple solution?  Allocate tracks dynamically and then store the
pointer in the library path.

Signed-off-by: Bryan Schumaker <bjschuma@gmail.com>
2014-04-06 19:56:50 -04:00
Bryan Schumaker 9043183807 libsaria: Remove old idle task stuff
I handle the idle task stuff inside the idle layer, hiding it from
everything else.

Signed-off-by: Bryan Schumaker <bjschuma@gmail.com>
2014-04-06 19:56:50 -04:00
Bryan Schumaker b6e0d6dd58 libsaria: Remove my custom linked list class
Now that I'm using vectors for everything I don't need to maintain my
own class.  Nothing uses it now, so it can be safely removed.

Signed-off-by: Bryan Schumaker <bjschuma@gmail.com>
2014-04-06 19:56:50 -04:00
Bryan Schumaker 36e9995bb9 libsaria: Use vectors to store the track list
For each library path, I replace the linked list with a vector allowing
me to easily index into the list to find tracks.

Signed-off-by: Bryan Schumaker <bjschuma@gmail.com>
2014-04-06 19:56:50 -04:00
Bryan Schumaker 8f7a610d6d libsaria: Remove DataState optimization
It made sense at the time, but I'm not convinced the added complexity is
actually worth it.

Signed-off-by: Bryan Schumaker <bjschuma@gmail.com>
2014-04-06 19:56:50 -04:00
Bryan Schumaker 0a4e4d9085 libsaria: Use [] to access track string properties
This finishes the job I started in the last commit.  Once again, I use
an enum of string properties to determine the right field to return.

Signed-off-by: Bryan Schumaker <bjschuma@gmail.com>
2012-10-31 17:42:57 -04:00
Bryan Schumaker 0600556ca4 libsaria: Replace add_track() and friends
I created simpler functions using the push_front() / push_back() names
that stl uses.  If we're a set-type playlist, then call the
insert_sorted function instead.  I also remove unnecessary bulk-inserts
of a single track.  Packing and unpacking a list each time seems stupid.

Signed-off-by: Bryan Schumaker <bjschuma@gmail.com>
2012-09-14 16:22:50 -04:00
Bryan Schumaker 258875bdb8 libsaria: Move header files out of include/libsaria/
Ocarina no longer has a header file subdirectory so there is no reason
to have a libsaria subdirectory anymore.  Putting header files directly
in the include/ directory is a bit simpler.

Signed-off-by: Bryan Schumaker <bjschuma@gmail.com>
2012-09-12 08:15:31 -04:00
Bryan Schumaker 83e3763083 libsaria: Remove songs from the library playlist when they are reaped
It's useful to keep the UI in sync with the backend...

Signed-off-by: Bryan Schumaker <bjschuma@gmail.com>
2012-09-09 12:58:41 -04:00
Bryan Schumaker 4d764eeb00 libsaria: Add tracks to the lib_playlist when scanning
I was trying to add an empty list, rather than track items.  This caused
the library count to increase (on the library path tab), but the library
playlist was never given track pointers so you had to restart ocarina to
see songs.

Signed-off-by: Bryan Schumaker <bjschuma@gmail.com>
2012-09-09 12:48:12 -04:00
Bryan Schumaker 9f7d861b77 libsaria: Remove library::Driver
I initially made this class so that multiple front ends could be used at
once and all receive the same notifications.  I see now that this was a
stupid idea, since I only need to keep one list of the library.  My
notify() function does the same stuff without the need for a driver
list.

Signed-off-by: Bryan Schumaker <bjschuma@gmail.com>
2012-08-21 17:55:27 -04:00
Bryan Schumaker aed5a023b3 libsaria: Remove second library path list
I kept around the old list while I was converting everything over to the
new list.  Now that I support all the needed features, I can remove the
old variable.

Signed-off-by: Bryan Schumaker <bjschuma@gmail.com>
2012-07-01 11:24:02 -04:00
Bryan Schumaker a7d1f57403 libsaria: Switch the update code to use the new list
Signed-off-by: Bryan Schumaker <bjschuma@gmail.com>
2012-07-01 09:59:48 -04:00
Bryan Schumaker 743caa85e6 libsaria: Add tracks to new library lists too
Signed-off-by: Bryan Schumaker <bjschuma@gmail.com>
2012-06-16 14:59:59 -04:00
Bryan Schumaker 28eaba41e0 libsaria: Use find_item() for updating library paths
I need to check if the file is already in the library.  I also made a
note for how this check could be done faster using a tree.

Signed-off-by: Bryan Schumaker <bjschuma@gmail.com>
2012-06-16 14:51:47 -04:00
Bryan Schumaker 3772bf78fa libsaria: Re-order code in update.cpp
Keep class functions with the class that uses them.

Signed-off-by: Bryan Schumaker <bjschuma@gmail.com>
2012-04-07 10:01:19 -04:00
Bryan Schumaker 659a2208b8 libsaria: Remove files that no longer exist
I scan a library path, do an lstat() and remove the files that can't be
found.

Signed-off-by: Bryan Schumaker <bjschuma@gmail.com>
2012-04-07 10:01:19 -04:00
Bryan Schumaker a1819dd5f9 libsaria: Only add new files during a library scan
I simply check if the file is already in the library before tagging it.

Signed-off-by: Bryan Schumaker <bjschuma@gmail.com>
2012-04-07 10:01:19 -04:00
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 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 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 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 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 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 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 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 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 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 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 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 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
Bryan Schumaker 69beb10d6b libsaria: Added LIBRARY_REFRESH callback
This callback is triggered during a library update to tell the UI that a
new version of the library is available.
2011-09-18 17:25:57 -04:00
Bryan Schumaker 7aff13f382 libsaria: Add tags to the library
I add each scanned track to the library for use later.
2011-09-18 12:20:59 -04:00
Bryan Schumaker 333a3a4b04 libsaria: Tag files to add to the library
I collect the artist / album / title / ... tags and add them to a class.
2011-09-17 14:16:06 -04:00
Bryan Schumaker 2c2e058b49 libsaria: Use new print functions
This mostly involved switching each print() to a println() to end the
line.
2011-09-17 13:50:13 -04:00
Bryan Schumaker 1abdd945ae libsaria: Create scan tasks for each subdirectory
I want to recursively scan each directory for music files.
2011-09-17 12:56:39 -04:00
Bryan Schumaker 5167c6f012 libsaria: Read a directory into two vectors
I separate out directories and files so they can be processed
differenty.
2011-09-17 12:27:20 -04:00
Bryan Schumaker e94ca6b9d6 libsaria: Rename UpdateTask to ScanTask
I feel that ScanTask is a better name
2011-09-13 08:04:59 -04:00
Bryan Schumaker b43fcc4b05 libsaria: Queue an idle task to update the library
I don't actually perform a library update at this point, but I do create
a new task and add it to the update queue.  When the run_task() function
is called, the task is removed from the queue and deleted.
2011-09-12 14:18:23 -04:00