Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: change device spec separator from colon to pipe #35

Merged
merged 1 commit into from
Nov 25, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ and [Conventional Commits](https://www.conventionalcommits.org/en/v1.0.0/).

### Fixed
- [config] Hexademical base does not correlate to key length
- [player] Use pipe separator in device specs for ALSA compatibility
- [repo] Fix pull request template format

### Security
Expand Down
14 changes: 7 additions & 7 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -115,21 +115,21 @@ Your music will start playing on the selected device.
pleezer -d "?"

# Use a specific device, formatted as:
# "[<host>][:<device>][:<sample rate>][:<sample format>]" (case-insensitive)
# "[<host>][|<device>][|<sample rate>][|<sample format>]" (case-insensitive)
#
# All fields are optional:
# - If you don't specify a host, it will use the system default host.
# - If you don't specify a device, it will use the host default device.
# - If you don't specify a sample rate, it will use the device default sample rate.
# - If you don't specify a sample format, it will use the device default sample format.
pleezer -d "CoreAudio"
pleezer -d "CoreAudio:Yggdrasil+"
pleezer -d "CoreAudio:Yggdrasil+:44100"
pleezer -d "CoreAudio:Yggdrasil+:44100:f32"
pleezer -d "CoreAudio|Yggdrasil+"
pleezer -d "CoreAudio|Yggdrasil+|44100"
pleezer -d "CoreAudio|Yggdrasil+|44100|f32"

# Some more advanced examples, showing you can omit fields as long as you include the colons:
pleezer -d ":yggdrasil+" # The Yggdrasil+ device (case-insensitive)
pleezer -d "::44100" # The first device to support 44100 Hz
# Some more advanced examples, showing you can omit fields as long as you include the pipes:
pleezer -d "|yggdrasil+" # The Yggdrasil+ device (case-insensitive)
pleezer -d "||44100" # The first device to support 44100 Hz
```

Deezer streams audio at 44100 Hz exclusively. Sampling rates other than
Expand Down
2 changes: 1 addition & 1 deletion src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ struct Args {

/// Select the audio output device
///
/// Format: [<host>][:<device>][:<sample rate>][:<sample format>]
/// Format: [<host>][|<device>][|<sample rate>][|<sample format>]
/// Use "?" to list available devices.
/// If omitted, uses the system default output device.
#[arg(short, long, default_value = None, env = "PLEEZER_DEVICE")]
Expand Down
6 changes: 3 additions & 3 deletions src/player.rs
Original file line number Diff line number Diff line change
Expand Up @@ -145,10 +145,10 @@ impl Player {
fn open_sink(device: &str) -> Result<(rodio::Sink, rodio::OutputStream)> {
let (stream, handle) = {
// The device string has the following format:
// [<host>][:<device>][:<sample rate>:<sample format>]
// "[<host>][|<device>][|<sample rate>][|<sample format>]" (case-insensitive)
// From left to right, the fields are optional, but each field
// depends on the preceding fields being specified.
let mut components = device.split(':');
let mut components = device.split('|');

// The host is the first field.
let host = match components.next() {
Expand Down Expand Up @@ -267,7 +267,7 @@ impl Player {
if let Ok(device_name) = device.name() {
let max_sample_rate = config.with_max_sample_rate();
let mut line = format!(
"{}:{}:{}:{}",
"{}|{}|{}|{}",
host.id().name(),
device_name,
max_sample_rate.sample_rate().0,
Expand Down