feat(pipe): add audio_output_pipe_passthrough to write the raw encoded stream#316
Open
JRpersonal wants to merge 1 commit into
Open
feat(pipe): add audio_output_pipe_passthrough to write the raw encoded stream#316JRpersonal wants to merge 1 commit into
JRpersonal wants to merge 1 commit into
Conversation
…d stream Add a passthrough mode to the pipe backend: with audio_output_pipe_passthrough the decoder is bypassed and the raw Ogg/Vorbis bitstream is written to the pipe untouched, so a downstream consumer (e.g. a hardware decoder) does the decoding. Motivation: on a weak ARM target that can decode Vorbis natively, decoding to float32 PCM in go-librespot and re-streaming PCM wastes CPU and bandwidth. Handing the original Ogg/Vorbis straight through roughly halves CPU there. What it changes: - New config option audio_output_pipe_passthrough (cli + daemon Config), and a Passthrough flag on the pipe output, validated as pipe-backend only. - New AudioSourcePassthrough interface (ReadBytes) in output.go. - passthroughSource (player): hands out a track's raw Ogg bytes; position is approximated from bytes consumed and SetPositionMs only supports a restart (a mid-page byte seek would corrupt the Ogg stream). - SwitchingAudioSource.ReadBytes concatenates consecutive tracks' raw streams into a chained Ogg bitstream the downstream decoder plays continuously. - player NewStream: for OGG_VORBIS, when passthrough is on, skip vorbis.New and feed the raw audio stream through passthroughSource. - pipeOutput.passthroughLoop writes the raw bytes (no decode, no volume, no format transform). Caveats: volume scaling and normalisation/replay-gain are not applied in passthrough (the stream is untouched); seeking is limited to a restart; pipe backend only; FLAC passthrough is not included.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Adds a passthrough mode to the pipe backend: with
audio_output_pipe_passthroughthe decoder is bypassed and the raw Ogg/Vorbis bitstream is written to the pipe untouched, so a downstream consumer (e.g. a hardware decoder) does the decoding.Motivation: on a weak ARM target that can decode Vorbis natively, decoding to float32 PCM in go-librespot and re-streaming PCM wastes CPU and bandwidth. Handing the original Ogg/Vorbis straight through roughly halves CPU there.
What it changes:
audio_output_pipe_passthrough(cli + daemon Config), and aPassthroughflag on the pipe output, validated as pipe-backend only.AudioSourcePassthroughinterface (ReadBytes) inoutput.go.passthroughSource(player): hands out a track's raw Ogg bytes; position is approximated from bytes consumed andSetPositionMsonly supports a restart (a mid-page byte seek would corrupt the Ogg stream).SwitchingAudioSource.ReadBytesconcatenates consecutive tracks' raw streams into a chained Ogg bitstream the downstream decoder plays continuously.NewStream: forOGG_VORBIS, when passthrough is on, skipvorbis.Newand feed the raw audio stream throughpassthroughSource.pipeOutput.passthroughLoopwrites the raw bytes (no decode, no volume, no format transform).Caveats: volume scaling and normalisation/replay-gain are not applied in passthrough (the stream is untouched); seeking is limited to a restart; pipe backend only; FLAC passthrough is not included.
Builds clean on current
master. Happy to adjust naming or split the change if you'd prefer.