diff options
author | waker <wakeroid@gmail.com> | 2009-07-04 03:06:34 +0200 |
---|---|---|
committer | waker <wakeroid@gmail.com> | 2009-07-04 03:06:34 +0200 |
commit | 56ccf563e1de7068e414df1d05f0dd015cd44f7a (patch) | |
tree | 16c86ec05830b245f0e05bbfb12c2842ea3ca927 /playlist.c | |
parent | 4f836e3de6c0a40f7bb29650ae9ae3230bad31b4 (diff) |
thrown in some gui
Diffstat (limited to 'playlist.c')
-rw-r--r-- | playlist.c | 38 |
1 files changed, 37 insertions, 1 deletions
@@ -2,6 +2,7 @@ #include <string.h> #include <dirent.h> #include <fnmatch.h> +#include <stdio.h> #include "playlist.h" #include "codec.h" #include "cwav.h" @@ -11,6 +12,14 @@ playItem_t *playlist_head; playItem_t *playlist_tail; playItem_t *playlist_current; +static int ps_count = 0; + +void +ps_free (void) { + while (playlist_head) { + ps_remove (playlist_head); + } +} int ps_add_file (const char *fname) { @@ -37,9 +46,19 @@ ps_add_file (const char *fname) { else { return -1; } + printf ("added %s to playlist\n", fname); + ps_count++; // copy string it->fname = strdup (fname); - it->displayname = strdup (fname); + // find 1st slash from end + while (eol > fname && *eol != '/') { + eol--; + } + if (*eol=='/') { + eol++; + } + + it->displayname = strdup (eol); it->timestart = -1; it->timeend = -1; @@ -85,6 +104,7 @@ int ps_remove (playItem_t *it) { if (!it) return -1; + ps_count--; if (it->fname) { free (it->fname); } @@ -107,3 +127,19 @@ ps_remove (playItem_t *it) { return 0; } +int +ps_getcount (void) { + return ps_count; +} + +playItem_t * +ps_get_for_idx (int idx) { + playItem_t *it = playlist_head; + while (idx--) { + if (!it) + return NULL; + it = it->next; + } + return it; +} + |