[PR #153] [MERGED] Add support for Audio Toolbox output (MacOS) #234

Closed
opened 2026-02-28 14:26:20 +03:00 by kerem · 0 comments
Owner

📋 Pull Request Information

Original PR: https://github.com/devgianlu/go-librespot/pull/153
Author: @stronk-dev
Created: 12/10/2024
Status: Merged
Merged: 7/12/2025
Merged by: @devgianlu

Base: masterHead: feature/AudioToolbox


📝 Commits (10+)

📊 Changes

5 files changed (+283 additions, -1 deletions)

View changed files

📝 README.md (+1 -1)
output/driver-alsa-stub.go (+11 -0)
output/driver-audio-toolbox-stub.go (+11 -0)
output/driver-audio-toolbox.go (+254 -0)
📝 output/output.go (+6 -0)

📄 Description

Adapted from https://github.com/devgianlu/go-librespot/pull/59

Notable changes:

  • Instead of overwriting newOutput, make it a separate toolboxOutput which can be activated by setting the backend to audio-toolbox.
  • Stubs added for outputs with go:build constraint printing a generic 'unsupported' message
    NOTE: we could enhance the stubs so that the output knows which outputs are supported and then automatically choose a platform-specific output like audio-toolbox.
  • Use a C struct to give the audio callback (which asks for samples when required) access to the reader directly.
    NOTE: depending on how the float32 reader is implemented, maybe having a FIFO buffer in the output could be useful? Ideally these kinds of callbacks have instant access to data without blockage (and fill remaining samples with silence if there's no data in the buffer).
    Removing the local buffer in the output and having the CB read directly does not seem to cause any issues so far...
  • Major simplification of buffer initialization and buffering logic for easier maintainability
  • Generic code cleanup: added some comments, checks, error cases, etc...

The PR is pronbably ready for review as-is, but there might be some minor issues like making sure that out.err gets set where necessary, more comments and testing to see how it handles error cases.


🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.

## 📋 Pull Request Information **Original PR:** https://github.com/devgianlu/go-librespot/pull/153 **Author:** [@stronk-dev](https://github.com/stronk-dev) **Created:** 12/10/2024 **Status:** ✅ Merged **Merged:** 7/12/2025 **Merged by:** [@devgianlu](https://github.com/devgianlu) **Base:** `master` ← **Head:** `feature/AudioToolbox` --- ### 📝 Commits (10+) - [`6684e3e`](https://github.com/devgianlu/go-librespot/commit/6684e3e1d64916b277f7e18573ee0ef2919c6f61) macos - [`fbff003`](https://github.com/devgianlu/go-librespot/commit/fbff0031b2a537dd9fa8d9816133e4f25195b9c2) initial proof of concept - [`d8b96f4`](https://github.com/devgianlu/go-librespot/commit/d8b96f4ebf6c2b6aa3fe495298aacb56222a1bc1) rename to reflect technology used - [`bdeb4e0`](https://github.com/devgianlu/go-librespot/commit/bdeb4e0d0638fa76a5c3a637f6ba08e11e7573d9) volume control and delay - [`f334cec`](https://github.com/devgianlu/go-librespot/commit/f334cec92cd8e602623d94c3095ab886ecab3358) implement coreaudio latency - [`df88de2`](https://github.com/devgianlu/go-librespot/commit/df88de2fd98090b76756942c174d8bd314a408dc) close some memory leaks - [`4dab982`](https://github.com/devgianlu/go-librespot/commit/4dab9825aed5b4e7c37543e6bc94d6e200d1680a) Rename audio toolbox output - [`ebfe7c7`](https://github.com/devgianlu/go-librespot/commit/ebfe7c769eb6c57d4f0eae55da7032461cc83463) Refactor & fixes for Mac support - [`30b7a20`](https://github.com/devgianlu/go-librespot/commit/30b7a20b1cee97ae2a2d155e14237f4c5e393694) Remove ring buffer alltogether - [`70cc116`](https://github.com/devgianlu/go-librespot/commit/70cc11638a7952353ba154c3e97c9f6ef7fc2aa2) Set `out.err` ### 📊 Changes **5 files changed** (+283 additions, -1 deletions) <details> <summary>View changed files</summary> 📝 `README.md` (+1 -1) ➕ `output/driver-alsa-stub.go` (+11 -0) ➕ `output/driver-audio-toolbox-stub.go` (+11 -0) ➕ `output/driver-audio-toolbox.go` (+254 -0) 📝 `output/output.go` (+6 -0) </details> ### 📄 Description Adapted from https://github.com/devgianlu/go-librespot/pull/59 Notable changes: - Instead of overwriting `newOutput`, make it a separate `toolboxOutput` which can be activated by setting the backend to `audio-toolbox`. - Stubs added for outputs with `go:build` constraint printing a generic 'unsupported' message NOTE: we could enhance the stubs so that the output knows which outputs are supported and then automatically choose a platform-specific output like `audio-toolbox`. - Use a C struct to give the audio callback (which asks for samples when required) access to the reader directly. NOTE: depending on how the float32 reader is implemented, maybe having a FIFO buffer in the output could be useful? Ideally these kinds of callbacks have instant access to data without blockage (and fill remaining samples with silence if there's no data in the buffer). Removing the local buffer in the output and having the CB read directly does not seem to cause any issues so far... - Major simplification of buffer initialization and buffering logic for easier maintainability - Generic code cleanup: added some comments, checks, error cases, etc... The PR is pronbably ready for review as-is, but there might be some minor issues like making sure that `out.err` gets set where necessary, more comments and testing to see how it handles error cases. --- <sub>🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.</sub>
kerem 2026-02-28 14:26:20 +03:00
Sign in to join this conversation.
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
starred/go-librespot#234
No description provided.