aboutsummaryrefslogtreecommitdiff
path: root/src/decoder_api.c
diff options
context:
space:
mode:
authorMax Kellermann <max@duempel.org>2009-12-25 23:12:10 +0100
committerMax Kellermann <max@duempel.org>2009-12-27 16:08:53 +0100
commit5787f737044e90b74e22d2179cd0d1b47fd17c76 (patch)
tree0455e67ab93ba5ba0bb221a1833f0aab50ff4db0 /src/decoder_api.c
parent201316cd67d374357c1aabc8a4aa2210fe20f1e8 (diff)
decoder, player: support song ranges
Seek the decoder to the start of the range before beginning with playback. Stop the decoder when the end of the range has been reached. Add the start position to the seek position. Expose the duration of the range, not the full song file.
Diffstat (limited to 'src/decoder_api.c')
-rw-r--r--src/decoder_api.c11
1 files changed, 9 insertions, 2 deletions
diff --git a/src/decoder_api.c b/src/decoder_api.c
index dde27727..704f6dbf 100644
--- a/src/decoder_api.c
+++ b/src/decoder_api.c
@@ -328,8 +328,9 @@ decoder_data(struct decoder *decoder,
}
dest = music_chunk_write(chunk, &dc->out_audio_format,
- decoder->timestamp, kbit_rate,
- &nbytes);
+ decoder->timestamp -
+ dc->song->start_ms / 1000.0,
+ kbit_rate, &nbytes);
if (dest == NULL) {
/* the chunk is full, flush it */
decoder_flush_chunk(decoder);
@@ -366,6 +367,12 @@ decoder_data(struct decoder *decoder,
decoder->timestamp += (double)nbytes /
audio_format_time_to_size(&dc->in_audio_format);
+
+ if (dc->song->end_ms > 0 &&
+ decoder->timestamp >= dc->song->end_ms / 1000.0)
+ /* the end of this range has been reached:
+ stop decoding */
+ return DECODE_COMMAND_STOP;
}
return DECODE_COMMAND_NONE;