summaryrefslogtreecommitdiff
path: root/playlist.c
diff options
context:
space:
mode:
authorGravatar waker <wakeroid@gmail.com>2009-07-04 03:06:34 +0200
committerGravatar waker <wakeroid@gmail.com>2009-07-04 03:06:34 +0200
commit56ccf563e1de7068e414df1d05f0dd015cd44f7a (patch)
tree16c86ec05830b245f0e05bbfb12c2842ea3ca927 /playlist.c
parent4f836e3de6c0a40f7bb29650ae9ae3230bad31b4 (diff)
thrown in some gui
Diffstat (limited to 'playlist.c')
-rw-r--r--playlist.c38
1 files changed, 37 insertions, 1 deletions
diff --git a/playlist.c b/playlist.c
index 33ef9996..2f25db67 100644
--- a/playlist.c
+++ b/playlist.c
@@ -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;
+}
+