sad

simple audio daemon
git clone git://git.2f30.org/sad
Log | Files | Refs | LICENSE

commit 74db6f041d3290d3a3da7eed79ed1b1700d741fc
parent f15e29bd1819101807fae10d7d14e258ff860991
Author: sin <sin@2f30.org>
Date:   Thu, 25 Dec 2014 22:43:54 +0000

Just use the current song as a reference when moving to next/prev

Diffstat:
Mcmd.c | 14++------------
Mplaylist.c | 10++++++----
Msad.h | 4++--
3 files changed, 10 insertions(+), 18 deletions(-)

diff --git a/cmd.c b/cmd.c @@ -49,12 +49,7 @@ cmdnext(int fd, int argc, char **argv) return; } - next = getnextsong(s); - if (!next) { - dprintf(fd, "ERR \"invalid song id\"\n"); - return; - } - + next = getnextsong(); decoder->close(); s->state = NONE; next->state = PREPARE; @@ -148,12 +143,7 @@ cmdprev(int fd, int argc, char **argv) return; } - prev = getprevsong(s); - if (!prev) { - dprintf(fd, "ERR \"invalid song id\"\n"); - return; - } - + prev = getprevsong(); decoder->close(); s->state = NONE; prev->state = PREPARE; diff --git a/playlist.c b/playlist.c @@ -58,11 +58,12 @@ findsongid(int id) } Song * -getnextsong(Song *cur) +getnextsong(void) { - Song *s; + Song *s, *cur; int i; + cur = playlist.cursong; for (i = 0; i < playlist.nsongs; i++) { s = &playlist.songs[i]; if (s->id == cur->id) @@ -78,11 +79,12 @@ getnextsong(Song *cur) } Song * -getprevsong(Song *cur) +getprevsong(void) { - Song *s; + Song *s, *cur; int i; + cur = playlist.cursong; for (i = 0; i < playlist.nsongs; i++) { s = &playlist.songs[i]; if (s->id == cur->id) diff --git a/sad.h b/sad.h @@ -57,8 +57,8 @@ int initplaylist(void); Song *addplaylist(const char *); Song *findsong(const char *); Song *findsongid(int); -Song *getnextsong(Song *); -Song *getprevsong(Song *); +Song *getnextsong(void); +Song *getprevsong(void); Song *getcursong(void); void putcursong(Song *); void dumpplaylist(int);