Commit Graph

123 Commits

Author SHA1 Message Date
Anna Schumaker 1b34a9a8a0 index: Update the index design
I updated the design and rewrote the unit tests.  This creates something
more consistent with how I ended up using the index.

Signed-off-by: Anna Schumaker <schumaker.anna@gmail.com>
2014-04-06 19:57:05 -04:00
Anna Schumaker fc8dc9d55e database: Design and test updates
I add:
- Autosaving option
- Real iterators
- Better accessor functions

The new design and unit test also allows me to remove the 300,000+ line
"database.good" file that the old tests were based on.

Signed-off-by: Anna Schumaker <schumaker.anna@gmail.com>
2014-04-06 19:57:05 -04:00
Anna Schumaker b251f27bb5 file: Don't use throw / catch to report errors
Needing to use throw / catch was getting in the way.  Instead, check for
a boolean return value.

Signed-off-by: Anna Schumaker <schumaker.anna@gmail.com>
2014-04-06 19:57:05 -04:00
Anna Schumaker 959cac0fe1 Database: Update design for database entries
I changed primary_key() into a function since it is only called once,
and there is no point in using more mmemory than I need to.  I also
created a basic unit test for everything that database entries are
supposed to do.

Signed-off-by: Anna Schumaker <schumaker.anna@gmail.com>
2014-04-06 19:57:05 -04:00
Anna Schumaker 336024bae9 file: Update design and create a new unit test
Signed-off-by: Anna Schumaker <schumaker.anna@gmail.com>
2014-04-06 19:57:05 -04:00
Anna Schumaker 239c03b1ac playlist: playqueue should not remove tracks
I was double clicking tracks in the gui, and they were removed from the
playqueue!  This patch fixes that.

Signed-off-by: Anna Schumaker <schumaker.anna@gmail.com>
2014-04-06 19:57:04 -04:00
Anna Schumaker 871914ea90 Clean up the build system
I'm taking a break from gui code to clean up the build system and update
my unit tests.  This patch updates how code is built, and reworks my
"print" test to test version number instead.

Signed-off-by: Anna Schumaker <schumaker.anna@gmail.com>
2014-04-06 19:57:03 -04:00
Anna Schumaker 7d7c83c222 deck: Check if a playqueue is empty before calling next
I need this in case the user deletes all tracks from a playqueue without
adding anything by the time next() is called.

Signed-off-by: Anna Schumaker <schumaker.anna@gmail.com>
2014-04-06 19:57:02 -04:00
Anna Schumaker 240ae7e21a audio: Remove duplicates from the recent playqueue
Signed-off-by: Anna Schumaker <schumaker.anna@gmail.com>
2014-04-06 19:57:02 -04:00
Anna Schumaker 5f582e639b playqueue: Add a path_selected function
This is called by the GUI to tell the playqueue that a track has been
selected.  This gives the PQ a chance to (possibly) remove it.

Signed-off-by: Anna Schumaker <schumaker.anna@gmail.com>
2014-04-06 19:57:02 -04:00
Anna Schumaker 21c80ea1f9 lib: Import ban status from Ocarina 5.x
Now that I have a banned playlist working I can remember the ban status
easier.

Signed-off-by: Anna Schumaker <schumaker.anna@gmail.com>
2014-04-06 19:57:02 -04:00
Anna Schumaker a474712a22 lib: Remove track from library pq if banned
Put it back when unbanned.

Signed-off-by: Anna Schumaker <schumaker.ann@gmail.com>
2014-04-06 19:57:02 -04:00
Anna Schumaker 3894c4ac97 playlist: Create a playqueue to store the current playlist
Signed-off-by: Anna Schumaker <schumaker.anna@gmail.com>
2014-04-06 19:57:02 -04:00
Anna Schumaker 72accfd26d library: Add tracks to the filter for searching
Signed-off-by: Anna Schumaker <schumaker.anna@gmail.com>
2014-04-06 19:57:02 -04:00
Anna Schumaker 0e4c05350a gui: Implement tab reordering
And prevent tabs from being moved into the perma-tab area.

Signed-off-by: Anna Schumaker <schumaker.anna@gmail.com>
2014-04-06 19:57:02 -04:00
Anna Schumaker 7dc57572aa deck: Pass a random-enabled flag when creating playqueues
Signed-off-by: Anna Schumaker <schumaker.anna@gmail.com>
2014-04-06 19:57:02 -04:00
Anna Schumaker 37a776ef24 playqueue test fixes
Signed-off-by: Anna Schumaker <schumaker.anna@gmail.com>
2014-04-06 19:57:02 -04:00
Anna Schumaker 32841901db deck: Add callbacks for new playqueue creation
Used by the gui to set the playqueue on the correct page.

Signed-off-by: Anna Schumaker <schumaker.anna@gmail.com>
2014-04-06 19:57:01 -04:00
Anna Schumaker e8d63a15cf audio: Add a function to toggle playing
This will be used by the gui when the spacebar is pressed by the user.

Signed-off-by: Anna Schumaker <schumaker.anna@gmail.com>
2014-04-06 19:57:01 -04:00
Anna Schumaker e752e0f826 audio: Don't escape filepaths
This will actually be done automatically by the gstreamer code.

Signed-off-by: Anna Schumaker <schumaker.anna@gmail.com>
2014-04-06 19:57:01 -04:00
Anna Schumaker dfbb98b2c6 audio: Escape filepaths before loading
This is for filepaths containing special characters.

Signed-off-by: Anna Schumaker <schumaker.anna@gmail.com>
2014-04-06 19:57:01 -04:00
Anna Schumaker 03b44b9e16 Update play count
When a track finishes, I tell the library to update playcount.  Then,
the library triggers a callback to the playqueue deck telling it to
update.

This patch also finds and prints the track that causes a gstreamer
error.

Signed-off-by: Anna Schumaker <schumaker.anna@gmail.com>
2014-04-06 19:57:01 -04:00
Anna Schumaker d240ff44bc playqueue: Change cur when tracks are directly selected
Signed-off-by: Anna Schumaker <schumaker.anna@gmail.com>
2014-04-06 19:57:01 -04:00
Anna Schumaker e9416e6ace library: Properly set the track primary_key from file
First this was missing, then I set it to the short path, now it's
correct.

Signed-off-by: Anna Schumaker <schumaker.anna@gmail.com>
2014-04-06 19:57:01 -04:00
Anna Schumaker 7a78e649a0 library: Separate error messages with line breaks
This condition is only hit when trying to tag files that aren't
recognized as audio files.

Signed-off-by: Anna Schumaker <schumaker.anna@gmail.com>
2014-04-06 19:57:01 -04:00
Anna Schumaker c9f1c07fa3 playqueue: Add a function to clear the playqueue sort order
I do this when reading in a saved library sort order to make sure the
correct values are set.

Signed-off-by: Anna Schumaker <schumaker.anna@gmail.com>
2014-04-06 19:57:01 -04:00
Anna Schumaker 8dbb4684c7 deck: Update test after sorting changes
Signed-off-by: Anna Schumaker <schumaker.anna@gmail.com>
2014-04-06 19:57:01 -04:00
Anna Schumaker 63df51a847 library: Set primary key in the Library class
To prevent duplicates from being added to the library.

Signed-off-by: Anna Schumaker <schumaker.anna@gmail.com>
2014-04-06 19:57:01 -04:00
Anna Schumaker 362acf163b playqueue: More sorting improvements
- Reimplement binary search for neater code
- Flip sort order when resetting sort if the first field is the one we
  are sorting by.

Signed-off-by: Anna Schumaker <schumaker.anna@gmail.com>
2014-04-06 19:57:01 -04:00
Anna Schumaker 77e7101f85 playqueue: Binary seach edge cases
Because some things were still out of order.

Signed-off-by: Anna Schumaker <schumaker.anna@gmail.com>
2014-04-06 19:57:01 -04:00
Anna Schumaker 23a518cf5a playqueue: Sorting improvements
- Put empty tags last
- Correct and edge case in my binary search

Signed-off-by: Anna Schumaker <schumaker.anna@gmail.com>
2014-04-06 19:57:01 -04:00
Anna Schumaker 2962d792d7 playqueue: Add flags to disable sorting
The history playqueue should never change sort order, so use this flag
to prevent user changes.

Signed-off-by: Anna Schumaker <schumaker.anna@gmail.com>
2014-04-06 19:57:00 -04:00
Anna Schumaker 6a227df41b playqueue: Write library sort order to disk
Signed-off-by: Anna Schumaker <schumaker.anna@gmail.com>
2014-04-06 19:57:00 -04:00
Anna Schumaker d430e09a59 playqueue: Generic sorting
I don't save the sort order yet.

Signed-off-by: Anna Schumaker <schumaker.anna@gmail.com>
2014-04-06 19:57:00 -04:00
Anna Schumaker 6659f18de3 audio: Load tracks by trackid
Used to select specific tracks to play.

Signed-off-by: Anna Schumaker <schumaker.anna@gmail.com>
2014-04-06 19:57:00 -04:00
Anna Schumaker d434b7ebbb playqueue: Sort by a generic list of fields
Eventually I'll be able to click on column headers to change the sort
value.

Signed-off-by: Anna Schumaker <schumaker.anna@gmail.com>
2014-04-06 19:57:00 -04:00
Anna Schumaker ddbbf0ea49 playqueue: Improve insertion sort with a binary search
My test was done with a library size of 8040.

Before this patch, I make 21919628 calls to my "less_than" function.
With this patch, I now make 101205 calls to my "less than" function.

This comes out to a 216-X improvement.  I should have done this sooner.

Signed-off-by: Anna Schumaker <schumaker.anna@gmail.com>
2014-04-06 19:57:00 -04:00
Anna Schumaker e256c24b20 playqueue: Sort playqueues if PQ_SORTED is enabled
I don't have user-configurable sorting (yet), but for now I'm sorting by
Artist -> Year -> Track #.

I also fix a bug where the library wasn't lowercasing artist, album,
genere, and track fields when reading from file.

Signed-off-by: Anna Schumaker <schumaker.anna@gmail.com>
2014-04-06 19:57:00 -04:00
Anna Schumaker 00706cc33f playqueue: Add a flag to disable unnecessary callbacks
The history and collection playqueues are never saved to disk, so I only
care about saving when a flag is changed.

Signed-off-by: Anna Schumaker <schumaker.anna@gmail.com>
2014-04-06 19:57:00 -04:00
Anna Schumaker b490322f55 library: Don't send notifications if the library is disabled
In other words, don't add tracks to the collection playqueue if they are
disabled.

Signed-off-by: Anna Schumaker <schumaker.anna@gmail.com>
2014-04-06 19:57:00 -04:00
Anna Schumaker 018c4747a2 gui: Watch for clicks on the random button
Signed-off-by: Anna Schumaker <schumaker.anna@gmail.com>
2014-04-06 19:57:00 -04:00
Anna Schumaker a98443872c deck: Save the deck whenever a queue changes
I read in the saved file when init() is called.

Signed-off-by: Anna Schumaker <schumaker.anna@gmail.com>
2014-04-06 19:57:00 -04:00
Anna Schumaker 6446b7e5ad audio: Access function for recent playqueue
The recent playqueue is needed for the history tab.

Signed-off-by: Anna Schumaker <schumaker.anna@gmail.com>
2014-04-06 19:57:00 -04:00
Anna Schumaker 2b57be8c66 audio: Send on_pause() callback when autopausing
Also seek to 0 when choosing the next track.

Signed-off-by: Anna Schumaker <schumaker.anna@gmail.com>
2014-04-06 19:56:59 -04:00
Anna Schumaker e1dbdb3ffb playqueue: Fix generated status string
- Correct spelling of "minutes"
- Don't pluralize if duration is only 1

Signed-off-by: Anna Schumaker <schumaker.anna@gmail.com>
2014-04-06 19:56:59 -04:00
Anna Schumaker 1c99042efd audio: Add callbacks for changing pause status
When the count is changed or pausing finishes, I trigger this callback
to notify the UI.  I also added in a line to enable pausing any time the
count is incremented.

Signed-off-by: Anna Schumaker <schumaker.anna@gmail.com>
2014-04-06 19:56:59 -04:00
Anna Schumaker c346a5860a gui: Implement control buttons
Play, pause, stop and so on.  I also update labels and progress bars
during playback.

Signed-off-by: Anna Schumaker <schumaker.anna@gmail.com>
2014-04-06 19:56:59 -04:00
Anna Schumaker bc3220ae85 playqueue: Generate a string representing current runtime.
I almost did this on the gui side, but then I remembered that this isn't
a trivial job.  I chose to stick with my rule: "if something can be done
in the backend then it should be done in the backend"

Signed-off-by: Anna Schumaker <schumaker.anna@gmail.com>
2014-04-06 19:56:59 -04:00
Anna Schumaker 0e2cc50e7b library: Fix some bugs
- Check for path existing in the library already before adding again.
- Iterate over track database using <= for comparison, and not just <

Signed-off-by: Anna Schumaker <schumaker.anna@gmail.com>
2014-04-06 19:56:59 -04:00
Anna Schumaker 1cf268c6bf playqueue: Implement a reset() function
Only available when CONFIG_TESTING is enabled.  Used to test clearing
the library and library playqueue for testing.

Signed-off-by: Anna Schumaker <schumaker.anna@gmail.com>
2014-04-06 19:56:59 -04:00