Commit Graph

680 Commits

Author SHA1 Message Date
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