summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--Jamfile4
-rw-r--r--cmp3.c28
-rw-r--r--codec.h2
-rw-r--r--csid.cpp6
-rw-r--r--cvorbis.c4
-rw-r--r--gtkplaylist.c11
-rw-r--r--playlist.c4
-rw-r--r--streamer.c1
8 files changed, 34 insertions, 26 deletions
diff --git a/Jamfile b/Jamfile
index 93169ee3..a8f6b784 100644
--- a/Jamfile
+++ b/Jamfile
@@ -8,8 +8,8 @@ CCFLAGS += -D_GNU_SOURCE ;
CCFLAGS += -std=c99 ;
#CCFLAGS += -DUSE_SDL ;
# CCFLAGS += -D_REENTRANT ;
-OPTIM += -O2 ;
-#OPTIM += -g ;
+OPTIM += -O0 ;
+OPTIM += -g ;
HDRS += /usr/include/gtk-2.0 ;
HDRS += /usr/lib/gtk-2.0/include ;
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;
}
diff --git a/codec.h b/codec.h
index 60eac955..f01b614c 100644
--- a/codec.h
+++ b/codec.h
@@ -31,7 +31,7 @@ typedef struct {
struct playItem_s;
typedef struct codec_s {
- int (*init) (const char *fname, int track, float start, float end);
+ int (*init) (struct playItem_s *it);
void (*free) (void);
// player is responsible for starting next song if -1 is returned
int (*read) (char *bytes, int size);
diff --git a/csid.cpp b/csid.cpp
index bcc32e27..78bb28ac 100644
--- a/csid.cpp
+++ b/csid.cpp
@@ -230,14 +230,14 @@ sldb_find (const uint8_t *digest) {
}
extern "C" int
-csid_init (const char *fname, int track, float start, float end) {
+csid_init (struct playItem_s *it) {
sidplay = new sidplay2;
resid = new ReSIDBuilder ("wtf");
resid->create (sidplay->info ().maxsids);
// resid->create (1);
resid->filter (true);
resid->sampling (p_get_rate ());
- tune = new SidTune (fname);
+ tune = new SidTune (it->fname);
#if 0
// calc md5
uint8_t sig[16];
@@ -263,7 +263,7 @@ csid_init (const char *fname, int track, float start, float end) {
md5_finish (&md5, sig);
#endif
- tune->selectSong (track+1);
+ tune->selectSong (it->tracknum+1);
csid.info.channels = tune->isStereo () ? 2 : 1;
sid2_config_t conf;
conf = sidplay->config ();
diff --git a/cvorbis.c b/cvorbis.c
index 7428934a..8506c41b 100644
--- a/cvorbis.c
+++ b/cvorbis.c
@@ -33,12 +33,12 @@ void
cvorbis_free (void);
int
-cvorbis_init (const char *fname, int track, float start, float end) {
+cvorbis_init (struct playItem_s *it) {
file = NULL;
vi = NULL;
cur_bit_stream = -1;
- file = fopen (fname, "rb");
+ file = fopen (it->fname, "rb");
if (!file) {
return -1;
}
diff --git a/gtkplaylist.c b/gtkplaylist.c
index 4ba5d427..5ff05929 100644
--- a/gtkplaylist.c
+++ b/gtkplaylist.c
@@ -242,9 +242,14 @@ gtkps_draw_ps_row (gtkplaylist_t *ps, cairo_t *cr, int row, playItem_t *it) {
cairo_set_font_size (cr, rowheight-4);
// draw as columns
char dur[10];
- int min = (int)it->duration/60;
- int sec = (int)(it->duration-min*60);
- snprintf (dur, 10, "%d:%02d", min, sec);
+ if (it->duration < 0) { // means not initialized yet
+ strcpy (dur, "-:--");
+ }
+ else {
+ int min = (int)it->duration/60;
+ int sec = (int)(it->duration-min*60);
+ snprintf (dur, 10, "%d:%02d", min, sec);
+ }
const char *columns[ps_ncolumns] = {
"",
ps_find_meta (it, "artist"),
diff --git a/playlist.c b/playlist.c
index 57858ae1..a2bbaab8 100644
--- a/playlist.c
+++ b/playlist.c
@@ -618,7 +618,7 @@ ps_set_current (playItem_t *it) {
playlist_current_ptr = it;
if (it && it->codec) {
// don't do anything on fail, streamer will take care
- ret = it->codec->init (it->fname, it->tracknum, it->timestart, it->timeend);
+ ret = it->codec->init (it);
if (ret < 0) {
it->codec->info.samplesPerSecond = -1;
}
@@ -768,7 +768,7 @@ ps_start_current (void) {
if (it && it->codec) {
// don't do anything on fail, streamer will take care
it->codec->free ();
- it->codec->init (it->fname, it->tracknum, it->timestart, it->timeend);
+ it->codec->init (it);
}
codec_unlock ();
}
diff --git a/streamer.c b/streamer.c
index 56b4e8a1..e98d5ed4 100644
--- a/streamer.c
+++ b/streamer.c
@@ -58,6 +58,7 @@ streamer_thread (uintptr_t ctx) {
while (!streaming_terminate) {
if (nextsong >= 0) {
+ printf ("starting next song: %d\n", nextsong);
int sng = nextsong;
int pstate = nextsong_pstate;
nextsong = -1;