decoder/flac: do not seek when DecoderCommand::STOP is received

libFLAC tries to keep on seeking a stream even after a (fatal) read
error has occurred.  Let the DecoderClient decide whether proceeding
is possible.

This fixes a crash bug when playing a file over NFS and the NFS
connection fails.
This commit is contained in:
Max Kellermann 2025-01-30 16:44:26 +01:00
parent 715ef846b6
commit d1e5c90c3b

@ -31,6 +31,11 @@ FlacInput::Read(FLAC__byte buffer[], size_t *bytes) noexcept
inline FLAC__StreamDecoderSeekStatus
FlacInput::Seek(FLAC__uint64 absolute_byte_offset) noexcept
{
if (client != nullptr && client->GetCommand() == DecoderCommand::STOP)
/* do not seek if we're supposed to stop playback (or
if an error has occurred) */
return FLAC__STREAM_DECODER_SEEK_STATUS_ERROR;
if (!input_stream.IsSeekable())
return FLAC__STREAM_DECODER_SEEK_STATUS_UNSUPPORTED;