summaryrefslogtreecommitdiffstats
path: root/lib/rbcodec/codecs/libm4a/m4a.c
diff options
context:
space:
mode:
Diffstat (limited to 'lib/rbcodec/codecs/libm4a/m4a.c')
-rw-r--r--lib/rbcodec/codecs/libm4a/m4a.c19
1 files changed, 14 insertions, 5 deletions
diff --git a/lib/rbcodec/codecs/libm4a/m4a.c b/lib/rbcodec/codecs/libm4a/m4a.c
index 295c39c5ff..b63b8bad2c 100644
--- a/lib/rbcodec/codecs/libm4a/m4a.c
+++ b/lib/rbcodec/codecs/libm4a/m4a.c
@@ -211,11 +211,13 @@ unsigned int m4a_seek(demux_res_t* demux_res, stream_t* stream,
sound_sample_i += time_cnt * time_dur;
}
- DEBUGF("seek chunk=%lu, sample=%lu, soundsample=%lu, offset=%lu\n",
- (unsigned long)chunk, (unsigned long)chunk_first_sample,
- sound_sample_i, (unsigned long)offset);
+ if (demux_res->sample_byte_sizes_offset)
+ {
+ stream->ci->seek_buffer(demux_res->sample_byte_sizes_offset + chunk_first_sample * 4);
+ }
- if (tsz_tab) {
+ if (tsz_tab || demux_res->sample_byte_sizes_offset)
+ {
/* We have a sample-to-bytes table available so we can do accurate
* seeking. Move one sample at a time and update the file offset and
* PCM sample offset as we go. */
@@ -229,7 +231,7 @@ unsigned int m4a_seek(demux_res_t* demux_res, stream_t* stream,
time_dur = tts_tab[time].sample_duration;
}
- offset += tsz_tab[i];
+ offset += tsz_tab ? tsz_tab[i] : stream_read_uint32(stream);
sound_sample_i += time_dur;
time_cnt--;
}
@@ -239,6 +241,13 @@ unsigned int m4a_seek(demux_res_t* demux_res, stream_t* stream,
sample_i = chunk_first_sample;
}
+ DEBUGF("seek chunk=%lu, chunk_first_sample=%lu, sample_i=%u, soundsample=%lu, offset=%lu\n",
+ (unsigned long)chunk,
+ (unsigned long)chunk_first_sample,
+ sample_i,
+ (unsigned long)sound_sample_i,
+ (unsigned long)offset);
+
if (stream->ci->seek_buffer(offset))
{
*sound_samples_done = sound_sample_i;