summaryrefslogtreecommitdiff
path: root/cmp3.c
diff options
context:
space:
mode:
authorGravatar waker <wakeroid@gmail.com>2009-08-09 14:47:47 +0200
committerGravatar waker <wakeroid@gmail.com>2009-08-09 14:47:47 +0200
commit2d520c4c86d0cc67450a7a24a3f2ffba7447cf7e (patch)
tree3f13976c608324942930d3ad918ae6e9a146b75c /cmp3.c
parent62f994737141113a0ee5ccaa1c8e0ef39768d714 (diff)
mp3 duration now beeing calculated on play
Diffstat (limited to 'cmp3.c')
-rw-r--r--cmp3.c28
1 files changed, 15 insertions, 13 deletions
diff --git a/cmp3.c b/cmp3.c
index dde40d4c..df7c6892 100644
--- a/cmp3.c
+++ b/cmp3.c
@@ -57,9 +57,12 @@ cmp3_decode (void);
static int
cmp3_scan_stream (float position);
+static int
+cmp3_scan_stream2 (float position);
+
int
-cmp3_init (const char *fname, int track, float start, float end) {
- buffer.file = fopen (fname, "rb");
+cmp3_init (struct playItem_s *it) {
+ buffer.file = fopen (it->fname, "rb");
if (!buffer.file) {
return -1;
}
@@ -68,17 +71,15 @@ cmp3_init (const char *fname, int track, float start, float end) {
buffer.readsize = 0;
buffer.cachefill = 0;
cmp3.info.position = 0;
- mad_stream_init(&stream);
- mad_frame_init(&frame);
- mad_synth_init(&synth);
mad_timer_reset(&timer);
-#if 0
- if (cmp3_scan_stream (-1) < 0) {
- return -1;
+ if (it->duration <= 0) {
+ it->duration = cmp3_scan_stream (-1);
+ rewind (buffer.file);
}
- rewind (buffer.file);
-#endif
+ mad_stream_init(&stream);
+ mad_frame_init(&frame);
+ mad_synth_init(&synth);
return 0;
}
@@ -281,7 +282,6 @@ cmp3_scan_stream (float position) {
//printf ("file doesn't looks like mpeg stream\n");
return -1;
}
- printf ("mp3 scan stats: %d reads, %d seeks\n", nreads, nseeks);
return duration;
}
@@ -448,7 +448,6 @@ cmp3_scan_stream2 (float position) {
//printf ("file doesn't looks like mpeg stream\n");
duration = -1;
}
- printf ("mp3 scan stats: %d reads, %d seeks\n", nreads, nseeks);
munmap (map, len);
return duration;
}
@@ -1229,7 +1228,7 @@ cmp3_insert (playItem_t *after, const char *fname) {
}
rewind (fp);
-
+#if 0
// calculate duration
buffer.file = fp;
buffer.remaining = 0;
@@ -1249,6 +1248,9 @@ cmp3_insert (playItem_t *after, const char *fname) {
ps_item_free (it);
}
memset (&buffer, 0, sizeof (buffer));
+#endif
+ after = ps_insert_item (after, it);
+ it->duration = -1;
fclose (fp);
return after;
}