libsaria: Move next() into playlist.cpp

I don't want to keep one function in a file by itself.  Instead, let's
just move it into the main playlist file.

Signed-off-by: Bryan Schumaker <bjschuma@gmail.com>
This commit is contained in:
Bryan Schumaker 2012-11-03 21:48:29 -04:00
parent 1e23389b51
commit a6fa805a53
2 changed files with 26 additions and 36 deletions

View File

@ -1,36 +0,0 @@
// Copyright (c) 2012 Bryan Schumaker.
#include <playlist.h>
#include <index.h>
#include <prefs.h>
#include <print.h>
#include <stdlib.h>
namespace libsaria
{
Track *Playlist::next()
{
Track *track;
if (get_size() == 0)
return NULL;
if (get_random())
cur += rand() % get_size();
else if (flags & PL_NO_DRAIN)
cur++;
if (cur >= plist.size())
cur -= plist.size();
track = plist[cur];
if (!(flags & PL_NO_DRAIN))
remove_index(cur);
if (get_size() != 0)
notify_ui(PLAYLIST_GOTO, track, cur);
return track;
}
}; /* Namespace: libsaria */

View File

@ -4,6 +4,8 @@
#include <library.h>
#include <playlist.h>
#include <stdlib.h>
namespace libsaria
{
@ -137,6 +139,30 @@ namespace libsaria
return plist.size();
}
Track *Playlist::next()
{
Track *track;
if (get_size() == 0)
return NULL;
if (get_random())
cur += rand() % get_size();
else if (flags & PL_NO_DRAIN)
cur++;
if (cur >= plist.size())
cur -= plist.size();
track = plist[cur];
if (!(flags & PL_NO_DRAIN))
remove_index(cur);
if (get_size() != 0)
notify_ui(PLAYLIST_GOTO, track, cur);
return track;
}
void Playlist::notify_ui(notify_t type, Track *track, unsigned int index)
{
struct PlaylistNotification data;