aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorMax Kellermann <max@duempel.org>2009-11-11 15:09:24 +0100
committerMax Kellermann <max@duempel.org>2009-11-11 15:31:17 +0100
commit80b220a3a68b4f9c4d21fa416ff220e4262cde82 (patch)
tree060fa951317fb59154a8d2dde442ec41b5168be3 /src
parent5cc3c4f5039cc57b414de3b94bb3ab0e54f28556 (diff)
downloadmpd-80b220a3a68b4f9c4d21fa416ff220e4262cde82.tar.gz
mpd-80b220a3a68b4f9c4d21fa416ff220e4262cde82.tar.xz
mpd-80b220a3a68b4f9c4d21fa416ff220e4262cde82.zip
decoder/flac: keep track of current frame number
We need this for more exact end-of-subsong detection for CUE files.
Diffstat (limited to '')
-rw-r--r--src/decoder/_flac_common.c3
-rw-r--r--src/decoder/_flac_common.h5
-rw-r--r--src/decoder/flac_plugin.c3
-rw-r--r--src/decoder/oggflac_plugin.c1
4 files changed, 12 insertions, 0 deletions
diff --git a/src/decoder/_flac_common.c b/src/decoder/_flac_common.c
index 2ccd2e536..812ca6dae 100644
--- a/src/decoder/_flac_common.c
+++ b/src/decoder/_flac_common.c
@@ -35,6 +35,8 @@ flac_data_init(struct flac_data *data, struct decoder * decoder,
{
pcm_buffer_init(&data->buffer);
+ data->next_frame = 0;
+
data->time = 0;
data->position = 0;
data->bit_rate = 0;
@@ -122,6 +124,7 @@ flac_common_write(struct flac_data *data, const FLAC__Frame * frame,
buffer, buffer_size,
data->time, data->bit_rate,
data->replay_gain_info);
+ data->next_frame += frame->header.blocksize;
switch (cmd) {
case DECODE_COMMAND_NONE:
case DECODE_COMMAND_START:
diff --git a/src/decoder/_flac_common.h b/src/decoder/_flac_common.h
index e0ddc6027..f4cf6e184 100644
--- a/src/decoder/_flac_common.h
+++ b/src/decoder/_flac_common.h
@@ -148,6 +148,11 @@ typedef size_t flac_read_status_size_t;
struct flac_data {
struct pcm_buffer buffer;
+ /**
+ * The number of the next frame which is going to be decoded.
+ */
+ FLAC__uint64 next_frame;
+
float time;
unsigned int bit_rate;
struct audio_format audio_format;
diff --git a/src/decoder/flac_plugin.c b/src/decoder/flac_plugin.c
index 17d0e8519..f7b8cdb96 100644
--- a/src/decoder/flac_plugin.c
+++ b/src/decoder/flac_plugin.c
@@ -460,6 +460,7 @@ flac_decode_internal(struct decoder * decoder,
FLAC__uint64 seek_sample = decoder_seek_where(decoder) *
data.audio_format.sample_rate + 0.5;
if (flac_seek_absolute(flac_dec, seek_sample)) {
+ data.next_frame = seek_sample;
data.time = ((float)seek_sample) /
data.audio_format.sample_rate;
data.position = 0;
@@ -634,6 +635,7 @@ flac_container_decode(struct decoder* decoder,
if (seek_sample >= t_start && seek_sample <= t_end &&
flac_seek_absolute(flac_dec, (FLAC__uint64)seek_sample)) {
+ data.next_frame = seek_sample;
data.time = (float)(seek_sample - t_start) /
data.audio_format.sample_rate;
data.position = 0;
@@ -756,6 +758,7 @@ flac_filedecode_internal(struct decoder* decoder,
data.audio_format.sample_rate + 0.5;
if (flac_seek_absolute(flac_dec, seek_sample))
{
+ data.next_frame = seek_sample;
data.time = ((float)seek_sample) /
data.audio_format.sample_rate;
data.position = 0;
diff --git a/src/decoder/oggflac_plugin.c b/src/decoder/oggflac_plugin.c
index d4ba7b213..018875ae8 100644
--- a/src/decoder/oggflac_plugin.c
+++ b/src/decoder/oggflac_plugin.c
@@ -328,6 +328,7 @@ oggflac_decode(struct decoder * mpd_decoder, struct input_stream *input_stream)
data.audio_format.sample_rate + 0.5;
if (OggFLAC__seekable_stream_decoder_seek_absolute
(decoder, seek_sample)) {
+ data.next_frame = seek_sample;
data.time = ((float)seek_sample) /
data.audio_format.sample_rate;
data.position = 0;