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:
parent
1e23389b51
commit
a6fa805a53
|
@ -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 */
|
|
@ -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;
|
||||
|
|
Loading…
Reference in New Issue