diff options
author | Max Kellermann <max@duempel.org> | 2008-11-16 20:42:08 +0100 |
---|---|---|
committer | Max Kellermann <max@duempel.org> | 2008-11-16 20:42:08 +0100 |
commit | 7591403566971eb19ba7bb16002eaa2689a637c7 (patch) | |
tree | cc08c5542d7e52b3bb3457b1e62fd209ba125be5 /src | |
parent | 8882f062000ec6f86d932eee7c948d1369901c03 (diff) | |
download | mpd-7591403566971eb19ba7bb16002eaa2689a637c7.tar.gz mpd-7591403566971eb19ba7bb16002eaa2689a637c7.tar.xz mpd-7591403566971eb19ba7bb16002eaa2689a637c7.zip |
input_stream: size==-1 means unknown size
Define the special value "-1" as "unknown size". Previously, there
was no indicator for streams with unknown size, which might confuse
some decoders.
Diffstat (limited to 'src')
-rw-r--r-- | src/decoder/aac_plugin.c | 2 | ||||
-rw-r--r-- | src/decoder/flac_plugin.c | 3 | ||||
-rw-r--r-- | src/decoder/oggflac_plugin.c | 3 | ||||
-rw-r--r-- | src/decoder/wavpack_plugin.c | 3 | ||||
-rw-r--r-- | src/input_curl.c | 4 | ||||
-rw-r--r-- | src/input_stream.c | 2 |
6 files changed, 15 insertions, 2 deletions
diff --git a/src/decoder/aac_plugin.c b/src/decoder/aac_plugin.c index 95b19735a..d23d43b55 100644 --- a/src/decoder/aac_plugin.c +++ b/src/decoder/aac_plugin.c @@ -186,7 +186,7 @@ static void aac_parse_header(AacBuffer * b, float *length) if (length) *length = -1; - fileread = b->inStream->size; + fileread = b->inStream->size >= 0 ? b->inStream->size : 0; fillAacBuffer(b); diff --git a/src/decoder/flac_plugin.c b/src/decoder/flac_plugin.c index 9c93983a0..289fada0b 100644 --- a/src/decoder/flac_plugin.c +++ b/src/decoder/flac_plugin.c @@ -75,6 +75,9 @@ static flac_length_status flacLength(mpd_unused const flac_decoder * flacDec, { FlacData *data = (FlacData *) fdata; + if (data->inStream->size < 0) + return flac_length_status_unsupported; + *length = (size_t) (data->inStream->size); return flac_length_status_ok; diff --git a/src/decoder/oggflac_plugin.c b/src/decoder/oggflac_plugin.c index b9ef13722..7550005d9 100644 --- a/src/decoder/oggflac_plugin.c +++ b/src/decoder/oggflac_plugin.c @@ -92,6 +92,9 @@ static OggFLAC__SeekableStreamDecoderLengthStatus of_length_cb(mpd_unused const { FlacData *data = (FlacData *) fdata; + if (data->inStream->size < 0) + return OggFLAC__SEEKABLE_STREAM_DECODER_LENGTH_STATUS_ERROR; + *length = (size_t) (data->inStream->size); return OggFLAC__SEEKABLE_STREAM_DECODER_LENGTH_STATUS_OK; diff --git a/src/decoder/wavpack_plugin.c b/src/decoder/wavpack_plugin.c index 4262d55fa..224895f25 100644 --- a/src/decoder/wavpack_plugin.c +++ b/src/decoder/wavpack_plugin.c @@ -410,6 +410,9 @@ wavpack_input_push_back_byte(void *id, int c) static uint32_t wavpack_input_get_length(void *id) { + if (wpin(id)->is->size < 0) + return 0; + return wpin(id)->is->size; } diff --git a/src/input_curl.c b/src/input_curl.c index f908bf245..1d07674e9 100644 --- a/src/input_curl.c +++ b/src/input_curl.c @@ -581,6 +581,10 @@ input_curl_seek(struct input_stream *is, off_t offset, int whence) break; case SEEK_END: + if (is->size < 0) + /* stream size is not known */ + return false; + is->offset = is->size + offset; break; diff --git a/src/input_stream.c b/src/input_stream.c index be547912e..65b6a89b2 100644 --- a/src/input_stream.c +++ b/src/input_stream.c @@ -58,7 +58,7 @@ input_stream_open(struct input_stream *is, const char *url) is->seekable = false; is->ready = false; is->offset = 0; - is->size = 0; + is->size = -1; is->error = 0; is->mime = NULL; is->meta_name = NULL; |