Skip to content

Commit

Permalink
Merge branch 'master' into master
Browse files Browse the repository at this point in the history
  • Loading branch information
eladyn authored Oct 21, 2024
2 parents 591d2c7 + 690ab7e commit 4a81f52
Show file tree
Hide file tree
Showing 7 changed files with 134 additions and 16 deletions.
78 changes: 66 additions & 12 deletions Cargo.lock

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

4 changes: 4 additions & 0 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,7 @@ default = ["alsa_backend", "pipe_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 All @@ -68,3 +69,6 @@ assets = [
["README.md", "usr/share/doc/spotifyd/README", "644"],
["contrib/spotifyd.service", "etc/systemd/user/", "644"],
]

[profile.release]
lto = true
1 change: 1 addition & 0 deletions docs/src/SUMMARY.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
- [Installing on a Raspberry Pi](./installation/Raspberry-Pi.md)
- [Installing on Ubuntu (from source)](./installation/Ubuntu.md)
- [Cross Compiling on Ubuntu](./installation/Cross-Compiling-on-Ubuntu.md)
- [Cross Compilation using Docker](./installation/cross-compile-using-docker.md)
- [Installing with Homebrew on macOS](./installation/MacOS.md)
- [Installing on FreeBSD](./installation/FreeBSD.md)
- [Installing on OpenBSD](./installation/OpenBSD.md)
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.
41 changes: 41 additions & 0 deletions docs/src/installation/cross-compile-using-docker.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
# Cross Compilation using Docker

We can also use `docker` to cross compile on every platform and OS that runs `docker` and `qemu`:

1. Setup a docker [custom builder](https://docs.docker.com/build/building/multi-platform/#create-a-custom-builder)

```shell
docker buildx create \
--name container-builder \
--driver docker-container \
--use --bootstrap
```

If you are **not** using Docker-Desktop you might have to install [QEMU](https://docs.docker.com/build/building/multi-platform/#install-qemu-manually)

2. Create a docker `compose-file.yml`

Here we are building a `arm64` binary, so we set `platform: linux/arm64`

```yaml
services:
build-container:
image: rust:1.79-bookworm
platform: linux/arm64
command: bash -c "
apt-get update &&
apt-get install -y \
libasound2-dev \
libssl-dev \
pkg-config &&
curl -sSL https://api.github.com/repos/Spotifyd/spotifyd/tarball/v0.3.5 | tar xz -C /spotifyd --strip-components=1 &&
cargo build --release &&
cp /spotifyd/target/release/spotifyd /build/"
working_dir: /spotifyd
volumes:
- ./:/build
```

3. Run `docker compose up`

This will copy the build `spotifyd` binary in the current directory.
4 changes: 2 additions & 2 deletions src/alsa_mixer.rs
Original file line number Diff line number Diff line change
Expand Up @@ -25,9 +25,9 @@ impl AlsaMixer {

let volume_steps = (max - min) as f64;
let normalised_volume = if self.linear_scaling {
((f64::from(volume) / f64::from(u16::max_value())) * volume_steps) as i64 + min
((f64::from(volume) / f64::from(u16::MAX)) * volume_steps) as i64 + min
} else {
(f64::from(volume).log(f64::from(u16::max_value())) * volume_steps).floor() as i64 + min
(f64::from(volume).log(f64::from(u16::MAX)) * volume_steps).floor() as i64 + min
};

elem.set_playback_volume_all(normalised_volume)?;
Expand Down
8 changes: 7 additions & 1 deletion src/config.rs
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,8 @@ const CONFIG_FILE_NAME: &str = "spotifyd.conf";
feature = "portaudio_backend",
feature = "alsa_backend",
feature = "pipe_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 @@ -40,6 +41,8 @@ static BACKEND_VALUES: &[&str] = &[
"rodio",
#[cfg(feature = "pipe_backend")]
"pipe",
#[cfg(feature = "rodiojack_backend")]
"rodiojack",
];

/// The backend used by librespot
Expand All @@ -51,6 +54,7 @@ pub enum Backend {
PulseAudio,
Rodio,
Pipe,
RodioJack,
}

fn default_backend() -> Backend {
Expand All @@ -67,6 +71,7 @@ impl FromStr for Backend {
"pulseaudio" => Ok(Backend::PulseAudio),
"rodio" => Ok(Backend::Rodio),
"pipe" => Ok(Backend::Pipe),
"rodiojack" => Ok(Backend::RodioJack),
_ => unreachable!(),
}
}
Expand All @@ -80,6 +85,7 @@ impl fmt::Display for Backend {
Backend::PulseAudio => write!(f, "pulseaudio"),
Backend::Rodio => write!(f, "rodio"),
Backend::Pipe => write!(f, "pipe"),
Backend::RodioJack => write!(f, "rodiojack"),
}
}
}
Expand Down

0 comments on commit 4a81f52

Please sign in to comment.