From d1e5c90c3b817084642f189e74fea71cfd5a855a Mon Sep 17 00:00:00 2001 From: Max Kellermann <max.kellermann@gmail.com> Date: Thu, 30 Jan 2025 16:44:26 +0100 Subject: [PATCH] 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. --- src/decoder/plugins/FlacInput.cxx | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/src/decoder/plugins/FlacInput.cxx b/src/decoder/plugins/FlacInput.cxx index 258e977c3..1d167a1fa 100644 --- a/src/decoder/plugins/FlacInput.cxx +++ b/src/decoder/plugins/FlacInput.cxx @@ -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;