summaryrefslogtreecommitdiff
path: root/plugins
diff options
context:
space:
mode:
authorGravatar Alexey Yakovenko <wakeroid@gmail.com>2009-09-22 22:57:55 +0200
committerGravatar Alexey Yakovenko <wakeroid@gmail.com>2009-09-22 22:57:55 +0200
commitd377cbbef40a2ea672d746c1c9e0a6643125c7e2 (patch)
tree5e909a8a234a079b681e024d1c2f93fdb9d50939 /plugins
parent3c0f4bd7f6e0eac196174dbcf7d9cc06562831b5 (diff)
removed start/end time from playItem_t
Diffstat (limited to 'plugins')
-rw-r--r--plugins/ffap/ffap.c39
-rw-r--r--plugins/flac/flac.c13
-rw-r--r--plugins/mpgmad/mpgmad.c28
-rw-r--r--plugins/vorbis/vorbis.c6
4 files changed, 19 insertions, 67 deletions
diff --git a/plugins/ffap/ffap.c b/plugins/ffap/ffap.c
index 2ecd61a1..68899578 100644
--- a/plugins/ffap/ffap.c
+++ b/plugins/ffap/ffap.c
@@ -44,8 +44,8 @@
static DB_decoder_t plugin;
static DB_functions_t *deadbeef;
-static float timestart;
-static float timeend;
+//static float timestart;
+//static float timeend;
static int startsample;
static int endsample;
@@ -702,17 +702,17 @@ ffap_init(DB_playItem_t *it)
plugin.info.samplerate = ape_ctx.samplerate;
plugin.info.channels = ape_ctx.channels;
plugin.info.readpos = 0;
- if (it->timeend > 0) {
+ if (it->endsample > 0) {
startsample = it->startsample;
endsample = it->endsample;
- timestart = it->timestart;
- timeend = it->timeend;
+// timestart = it->timestart;
+// timeend = it->timeend;
plugin.seek_sample (0);
- trace ("start: %d/%f, end: %d/%f\n", startsample, timestart, endsample, timeend);
+ //trace ("start: %d/%f, end: %d/%f\n", startsample, timestart, endsample, timeend);
}
else {
- timestart = 0;
- timeend = it->duration;
+ //timestart = 0;
+ //timeend = it->duration;
startsample = 0;
endsample = ape_ctx.totalsamples-1;
}
@@ -1717,7 +1717,7 @@ ffap_read_int16 (char *buffer, int size) {
ape_ctx.remaining -= sz;
}
ape_ctx.currentsample += (inits - size) / (2 * ape_ctx.channels);
- plugin.info.readpos = ape_ctx.currentsample / (float)plugin.info.samplerate - timestart;
+ plugin.info.readpos = (ape_ctx.currentsample-startsample) / (float)plugin.info.samplerate;
return inits - size;
}
@@ -1742,30 +1742,13 @@ ffap_seek_sample (int sample) {
ape_ctx.packet_remaining = 0;
ape_ctx.samples = 0;
ape_ctx.currentsample = newsample;
- plugin.info.readpos = (float)newsample/ape_ctx.samplerate-timestart;
+ plugin.info.readpos = (float)(newsample-startsample)/ape_ctx.samplerate;
return 0;
}
static int
ffap_seek (float seconds) {
- seconds += timestart;
- uint32_t newsample = seconds * plugin.info.samplerate;
- if (newsample > ape_ctx.totalsamples) {
- return -1;
- }
- int nframe = newsample / ape_ctx.blocksperframe;
- if (nframe >= ape_ctx.totalframes) {
- return -1;
- }
- ape_ctx.currentframe = nframe;
- ape_ctx.samplestoskip = newsample - nframe * ape_ctx.blocksperframe;
-
- // reset decoder
- ape_ctx.packet_remaining = 0;
- ape_ctx.samples = 0;
- ape_ctx.currentsample = newsample;
- plugin.info.readpos = (float)newsample / ape_ctx.samplerate - timestart;
- return 0;
+ return ffap_seek_sample (seconds * plugin.info.samplerate);
}
static const char *exts[] = { "ape", NULL };
diff --git a/plugins/flac/flac.c b/plugins/flac/flac.c
index 190bddb9..2e384e51 100644
--- a/plugins/flac/flac.c
+++ b/plugins/flac/flac.c
@@ -158,9 +158,7 @@ cflac_init (DB_playItem_t *it) {
cflac_free ();
return -1;
}
- if (it->timeend > 0) {
- timestart = it->timestart;
- timeend = it->timeend;
+ if (it->endsample > 0) {
startsample = it->startsample;
endsample = it->endsample;
if (plugin.seek_sample (0) < 0) {
@@ -169,8 +167,6 @@ cflac_init (DB_playItem_t *it) {
}
}
else {
- timestart = 0;
- timeend = it->duration;
startsample = 0;
endsample = cb.totalsamples-1;
currentsample = 0;
@@ -430,8 +426,8 @@ cflac_insert (DB_playItem_t *after, const char *fname) {
// try external cue
DB_playItem_t *cue_after = deadbeef->pl_insert_cue (after, fname, &plugin, "flac", cb.totalsamples, cb.samplerate);
if (cue_after) {
- cue_after->timeend = (float)cb.totalsamples/cb.samplerate;
- cue_after->duration = cue_after->timeend - cue_after->timestart;
+ cue_after->endsample = cb.totalsamples-1;
+ cue_after->duration = (cue_after->endsample - cue_after->startsample+1) * cb.samplerate;
return cue_after;
}
decoder = FLAC__stream_decoder_new();
@@ -445,9 +441,6 @@ cflac_insert (DB_playItem_t *after, const char *fname) {
it = deadbeef->pl_item_alloc ();
it->decoder = &plugin;
it->fname = strdup (fname);
- it->tracknum = 0;
- it->timestart = 0;
- it->timeend = 0;
status = FLAC__stream_decoder_init_file (decoder, fname, cflac_init_write_callback, cflac_init_metadata_callback, cflac_init_error_callback, it);
if (status != FLAC__STREAM_DECODER_INIT_STATUS_OK || cflac_init_stop_decoding) {
goto cflac_insert_fail;
diff --git a/plugins/mpgmad/mpgmad.c b/plugins/mpgmad/mpgmad.c
index 5946fa58..886c77c4 100644
--- a/plugins/mpgmad/mpgmad.c
+++ b/plugins/mpgmad/mpgmad.c
@@ -56,10 +56,6 @@ static DB_functions_t *deadbeef;
typedef struct {
FILE *file;
- // cuesheet info
- float timestart;
- float timeend;
-
// // input buffer, for MPEG data
// // FIXME: this should go away if reading happens per-frame
char input[READBUFFER];
@@ -494,9 +490,7 @@ cmp3_init (DB_playItem_t *it) {
plugin.info.readpos = 0;
cmp3_scan_stream (&buffer, -1); // scan entire stream, calc duration
- if (it->timeend > 0) {
- buffer.timestart = it->timestart;
- buffer.timeend = it->timeend;
+ if (it->endsample > 0) {
buffer.startsample = it->startsample;
buffer.endsample = it->endsample;
// that comes from cue, don't calc duration, just seek and play
@@ -504,8 +498,6 @@ cmp3_init (DB_playItem_t *it) {
}
else {
it->duration = buffer.duration;
- buffer.timestart = 0;
- buffer.timeend = it->duration;
buffer.startsample = 0;
buffer.endsample = buffer.totalsamples-1;
buffer.skipsamples = buffer.startdelay;
@@ -711,15 +703,12 @@ static int
cmp3_read (char *bytes, int size) {
int result;
int ret = 0;
- if (plugin.info.readpos >= (buffer.timeend - buffer.timestart)) {
- return 0;
- }
int nsamples = size / 2 / plugin.info.channels;
size *= 2; // convert to mad sample size
if (buffer.cachefill < size) {
buffer.readsize = (size - buffer.cachefill);
cmp3_decode ();
- plugin.info.readpos = (float)buffer.currentsample / buffer.samplerate - buffer.timestart;
+ plugin.info.readpos = (float)(buffer.currentsample-buffer.startsample) / buffer.samplerate;
}
if (buffer.cachefill > 0) {
int sz = min (size, buffer.cachefill);
@@ -749,9 +738,6 @@ cmp3_read (char *bytes, int size) {
buffer.cachepos = 0;
}
}
- if (plugin.info.readpos >= (buffer.timeend - buffer.timestart)) {
- return 0;
- }
return ret;
}
@@ -759,15 +745,12 @@ static int
cmp3_read_float32 (char *bytes, int size) {
int result;
int ret = 0;
- if (plugin.info.readpos >= (buffer.timeend - buffer.timestart)) {
- return 0;
- }
int nsamples = size / 4 / plugin.info.channels;
if (buffer.cachefill < size) {
buffer.readsize = (size - buffer.cachefill);
//printf ("decoding %d bytes using read_float32\n", buffer.readsize);
cmp3_decode ();
- plugin.info.readpos = (float)buffer.currentsample / buffer.samplerate - buffer.timestart;
+ plugin.info.readpos = (float)(buffer.currentsample - buffer.startsample) / buffer.samplerate;
}
if (buffer.cachefill > 0) {
int sz = min (size, buffer.cachefill);
@@ -796,9 +779,6 @@ cmp3_read_float32 (char *bytes, int size) {
buffer.cachefill = 0;
}
}
- if (plugin.info.readpos >= (buffer.timeend - buffer.timestart)) {
- return 0;
- }
return ret;
}
@@ -841,7 +821,7 @@ cmp3_seek_sample (int sample) {
mad_stream_init(&stream);
mad_frame_init(&frame);
mad_synth_init(&synth);
- plugin.info.readpos = (float)buffer.currentsample / buffer.samplerate - buffer.timestart;
+ plugin.info.readpos = (float)(buffer.currentsample - buffer.startsample) / buffer.samplerate;
return 0;
}
diff --git a/plugins/vorbis/vorbis.c b/plugins/vorbis/vorbis.c
index 612c9e1a..bb778304 100644
--- a/plugins/vorbis/vorbis.c
+++ b/plugins/vorbis/vorbis.c
@@ -71,16 +71,12 @@ cvorbis_init (DB_playItem_t *it) {
plugin.info.samplerate = vi->rate;
plugin.info.readpos = 0;
currentsample = 0;
- if (it->timeend > 0) {
- timestart = it->timestart;
- timeend = it->timeend;
+ if (it->endsample > 0) {
startsample = it->startsample;
endsample = it->endsample;
plugin.seek_sample (0);
}
else {
- timestart = 0;
- timeend = it->duration;
startsample = 0;
endsample = ov_pcm_total (&vorbis_file, -1)-1;
}