Skip to content

Fix hang in the OneShotDecoder on undecodable FLAC data - #33

Open
mikicaivosevic wants to merge 1 commit into
sonos:developfrom
mikicaivosevic:develop
Open

mikicaivosevic wants to merge 1 commit into
sonos:developfrom
mikicaivosevic:develop

Conversation

@mikicaivosevic

Copy link
Copy Markdown

Fix hang in the OneShotDecoder on undecodable FLAC data. The decode loop in OneShotDecoder is driven by how much data is left in the buffer:

while len(self._buffer) > 0:
    _lib.FLAC__stream_decoder_process_single(self._decoder)

Whether that condition ever becomes False depends on libFLAC continuing to consume the buffer. When it stops, the loop never ends, and because this runs in the constructor, the caller never gets an object back to cancel or inspect.

Drive the loop off the decoder state and stop as soon as libFLAC reports it can make no further progress. Let the read callback report end-of-stream when the buffer runs dry instead of waiting for data that can't arrive, keeping the wait for StreamDecoder, which is fed from another thread and does need it. Raise DecoderProcessException when the stream was aborted, matching what FileDecoder.process and StreamDecoder.finish already do, so a failed decode is reported rather than silently returning nothing.

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant