decoder/flac: check "seekable" in libFLAC callbacks

Return FLAC__STREAM_DECODER_SEEK_STATUS_UNSUPPORTED if this input
stream does not support seeking.
This commit is contained in:
Max Kellermann 2009-11-11 21:02:52 +01:00
parent 37181c9181
commit 0fb877740b
1 changed files with 6 additions and 0 deletions

View File

@ -69,6 +69,9 @@ flac_seek_cb(G_GNUC_UNUSED const FLAC__StreamDecoder *fd,
{
struct flac_data *data = (struct flac_data *) fdata;
if (!data->input_stream->seekable)
return FLAC__STREAM_DECODER_SEEK_STATUS_UNSUPPORTED;
if (!input_stream_seek(data->input_stream, offset, SEEK_SET))
return FLAC__STREAM_DECODER_SEEK_STATUS_ERROR;
@ -81,6 +84,9 @@ flac_tell_cb(G_GNUC_UNUSED const FLAC__StreamDecoder *fd,
{
struct flac_data *data = (struct flac_data *) fdata;
if (!data->input_stream->seekable)
return FLAC__STREAM_DECODER_SEEK_STATUS_UNSUPPORTED;
*offset = (long)(data->input_stream->offset);
return FLAC__STREAM_DECODER_TELL_STATUS_OK;