diff options
author | Max Kellermann <max@duempel.org> | 2009-02-18 18:40:40 +0100 |
---|---|---|
committer | Max Kellermann <max@duempel.org> | 2009-02-18 18:40:40 +0100 |
commit | 5900ea5299bf2b3de46e7c1a32c2ac747249da89 (patch) | |
tree | 5d9421aacab8869bd15c6d45a0ba4d78467091c7 /src/decoder | |
parent | 8aa3edb6afaf22b424a57e13fa97de0c01b206ed (diff) | |
download | mpd-5900ea5299bf2b3de46e7c1a32c2ac747249da89.tar.gz mpd-5900ea5299bf2b3de46e7c1a32c2ac747249da89.tar.xz mpd-5900ea5299bf2b3de46e7c1a32c2ac747249da89.zip |
mp4ff: don't allocate seek_table when input is not seekable
Don't waste any precious memory when the seek_table cannot be used.
Diffstat (limited to '')
-rw-r--r-- | src/decoder/mp4ff_plugin.c | 12 |
1 files changed, 10 insertions, 2 deletions
diff --git a/src/decoder/mp4ff_plugin.c b/src/decoder/mp4ff_plugin.c index ec60bc0bd..ddbb768e3 100644 --- a/src/decoder/mp4ff_plugin.c +++ b/src/decoder/mp4ff_plugin.c @@ -24,6 +24,7 @@ #include <mp4ff.h> #include <faad.h> +#include <assert.h> #include <stdlib.h> #include <unistd.h> @@ -217,7 +218,9 @@ mp4_decode(struct decoder *mpd_decoder, struct input_stream *input_stream) file_time = 0.0; - seek_table = g_malloc(sizeof(float) * num_samples); + seek_table = input_stream->seekable + ? g_malloc(sizeof(float) * num_samples) + : NULL; decoder_initialized(mpd_decoder, &audio_format, input_stream->seekable, @@ -227,6 +230,8 @@ mp4_decode(struct decoder *mpd_decoder, struct input_stream *input_stream) sample_id < num_samples && cmd != DECODE_COMMAND_STOP; sample_id++) { if (cmd == DECODE_COMMAND_SEEK) { + assert(seek_table != NULL); + seeking = true; seek_where = decoder_seek_where(mpd_decoder); } @@ -234,6 +239,9 @@ mp4_decode(struct decoder *mpd_decoder, struct input_stream *input_stream) if (seeking && seek_table_end > 1 && seek_table[seek_table_end] >= seek_where) { int i = 2; + + assert(seek_table != NULL); + while (seek_table[i] < seek_where) i++; sample_id = i - 1; @@ -243,7 +251,7 @@ mp4_decode(struct decoder *mpd_decoder, struct input_stream *input_stream) dur = mp4ff_get_sample_duration(mp4fh, track, sample_id); offset = mp4ff_get_sample_offset(mp4fh, track, sample_id); - if (sample_id > seek_table_end) { + if (seek_table != NULL && sample_id > seek_table_end) { seek_table[sample_id] = file_time; seek_table_end = sample_id; } |