Skip to content

Commit

Permalink
Merge pull request #1281 from agdphd/jack
Browse files Browse the repository at this point in the history
Add support for `rodiojack` backend.
  • Loading branch information
eladyn committed Jul 10, 2024
2 parents 357e147 + 3cac01e commit 8fb0b9a
Show file tree
Hide file tree
Showing 4 changed files with 58 additions and 3 deletions.
38 changes: 37 additions & 1 deletion Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,7 @@ default = ["alsa_backend"]
portaudio_backend = ["librespot-playback/portaudio-backend"]
pulseaudio_backend = ["librespot-playback/pulseaudio-backend"]
rodio_backend = ["librespot-playback/rodio-backend"]
rodiojack_backend = ["librespot-playback/rodiojack-backend"]

[package.metadata.deb]
depends = "$auto, systemd, pulseaudio"
Expand Down
14 changes: 13 additions & 1 deletion docs/src/installation/Feature-flags.md
Original file line number Diff line number Diff line change
Expand Up @@ -59,4 +59,16 @@ cargo build --release --no-default-features --features="rodio_backend"

On Linux you will need the development package for alsa and make/gcc. (`libasound2-dev`,`build-essential` on debian, `alsa-lib-devel`,`make`,`gcc` on fedora)

[mpris-specification]: https://specifications.freedesktop.org/mpris-spec/latest/
[mpris-specification]: https://specifications.freedesktop.org/mpris-spec/latest/

### JACK Audio Connection Kit

To use the [JACK](http://jackaudio.org) backend on Linux, compile with the `--features` flag to enable it:

```bash
cargo build --release --no-default-features --features="rodiojack_backend"
```

You will need the development packages for alsa, make/gcc, and JACK. (`libasound2-dev`, `build-essential`, and `libjack-dev` on Debian; `alsa-lib-devel`, `make`, `gcc`, and `jack-audio-connection-kit-devel` on Fedora.)

> __Note__: when Spotifyd starts with this backend, it will create a JACK output device named `cpal_client_out` with two ports: `out_0` for the left channel and `out_1` for the right.
8 changes: 7 additions & 1 deletion src/config.rs
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,8 @@ const CONFIG_FILE_NAME: &str = "spotifyd.conf";
feature = "pulseaudio_backend",
feature = "portaudio_backend",
feature = "alsa_backend",
feature = "rodio_backend"
feature = "rodio_backend",
feature = "rodiojack_backend",
)))]
compile_error!("At least one of the backend features is required!");
static BACKEND_VALUES: &[&str] = &[
Expand All @@ -37,6 +38,8 @@ static BACKEND_VALUES: &[&str] = &[
"portaudio",
#[cfg(feature = "rodio_backend")]
"rodio",
#[cfg(feature = "rodiojack_backend")]
"rodiojack",
];

/// The backend used by librespot
Expand All @@ -47,6 +50,7 @@ pub enum Backend {
PortAudio,
PulseAudio,
Rodio,
RodioJack,
}

fn default_backend() -> Backend {
Expand All @@ -62,6 +66,7 @@ impl FromStr for Backend {
"portaudio" => Ok(Backend::PortAudio),
"pulseaudio" => Ok(Backend::PulseAudio),
"rodio" => Ok(Backend::Rodio),
"rodiojack" => Ok(Backend::RodioJack),
_ => unreachable!(),
}
}
Expand All @@ -74,6 +79,7 @@ impl fmt::Display for Backend {
Backend::PortAudio => write!(f, "portaudio"),
Backend::PulseAudio => write!(f, "pulseaudio"),
Backend::Rodio => write!(f, "rodio"),
Backend::RodioJack => write!(f, "rodiojack"),
}
}
}
Expand Down

0 comments on commit 8fb0b9a

Please sign in to comment.