Skip to content

feat(pipe): add audio_output_pipe_passthrough to write the raw encoded stream#316

Open
JRpersonal wants to merge 1 commit into
devgianlu:masterfrom
JRpersonal:pr/pipe-passthrough
Open

feat(pipe): add audio_output_pipe_passthrough to write the raw encoded stream#316
JRpersonal wants to merge 1 commit into
devgianlu:masterfrom
JRpersonal:pr/pipe-passthrough

Conversation

@JRpersonal

Copy link
Copy Markdown
Contributor

Adds 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.

Builds clean on current master. Happy to adjust naming or split the change if you'd prefer.

…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.
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