Commit graph

1517 commits

Author SHA1 Message Date
Hugo Osvaldo Barrera
c4af90f5fe Avoid crashing when Avahi is not available
When librespot is built with Avahi turned on, it will crash if Avahi is
later not available at runtime.

This change avoids it crashing hard when Avahi is not available;
librespot will merely warn of the issue.

This affects some distribution packages too, where the maintainer might
prefer leaving Avahi support enabled, but many setups don't (or can't)
run Avahi.

Co-authored-by: Nick Steel <nick@nsteel.co.uk>
2022-05-20 08:39:20 +02:00
Jason Gray
7efc62b9ca
Remove the volume sample iteration (#986)
Move volume calculations out of their own separate samples iteration and into the normalisation iteration
2022-05-19 22:23:14 +02:00
Roderick van Domburg
70de5752dc
Merge pull request #1000 from Gnarflord/dev
Bump libmdns to 0.7
2022-05-19 22:03:48 +02:00
Gnarflord
10c9a0f8ea
Use libmdns 0.7 to avoid packet 47 error 2022-05-19 18:37:21 +02:00
Roderick van Domburg
650d41b020
Merge pull request #976 from JasonLG1979/pulseaudio-name
Set the PulseAudio name to match librespot's device name
2022-03-19 22:49:26 +01:00
JasonLG1979
e0e23c9167 Use the librespot name arg for the app name in the PulseAudio backend
This sets the name displayed by PulseAudio to Librespot - Instance Name if a name is given otherwise Librespot (the default name).

This also sets the correct "role" as per the docs:

https://www.freedesktop.org/wiki/Software/PulseAudio/Documentation/Developer/Clients/ApplicationProperties/

PA_PROP_MEDIA_ROLE

"This is a property of the actual streamed data, not so much the application"

Roles are used for policies, things like automatically muting a music player when a call comes in and whatnot.

For bonus points this also sets PULSE_PROP_application.icon_name to audio-x-generic so that we get a nice icon in the PulseAudio settings by our name instead of a missing icon placeholder.
2022-03-19 15:09:26 -05:00
Jason Gray
616809b64c
Quantum-realm level normalisation optimization (#965)
This saves up to 1-2% CPU useage on a PI 4 depending on how much normalisation is actually being done.

* We don't need to test against EPSILON. The factor will never be over 1.0 in basic normalisation mode.
* Don't check the normalisation mode EVERY sample.
* Do as little math as possible by simplfiying all equations as much as possible (while still retaining the textbook equations in comments).
* Misc cleanup
2022-02-13 22:50:32 +01:00
Roderick van Domburg
cb194cfd3b
Merge pull request #966 from michaelherger/fix-params-printout
Only log runtime argument if it starts with a dash "-"
2022-02-13 20:48:36 +01:00
Michael Herger
6f6d330bce Only log runtime argument if it starts with a dash "-"
When there's a value that corresponds to an argument name used in the same command line, the logging of the arguments gets confused and logs the matching argument, but without the leading dash:

```
% target/debug/librespot -n c --verbose -c /path/to/my/cache
[2022-02-07T22:32:25Z INFO  librespot] librespot 0.3.1 55ced49 (Built on 2022-02-07, Build ID: qaEB8kEW, Profile: debug)
[2022-02-07T22:32:25Z TRACE librespot] Command line argument(s):
[2022-02-07T22:32:25Z TRACE librespot] 		-n "c"
[2022-02-07T22:32:25Z TRACE librespot] 		c "/path/to/my/cache"
[2022-02-07T22:32:25Z TRACE librespot] 		--verbose
[2022-02-07T22:32:25Z TRACE librespot] 		-c "/path/to/my/cache"
```

Here we're using the literal `c` as the device name, and the `-c` argument. Thus the `c /path/to/my/cache` is logged in addition to `-c /path...`.

After checking whether the key has a leading dash, this issue is gone:

```
% target/debug/librespot -n c --verbose -c /path/to/my/cache
[2022-02-07T22:32:41Z INFO  librespot] librespot 0.3.1 55ced49 (Built on 2022-02-07, Build ID: qaEB8kEW, Profile: debug)
[2022-02-07T22:32:41Z TRACE librespot] Command line argument(s):
[2022-02-07T22:32:41Z TRACE librespot] 		-n "c"
[2022-02-07T22:32:41Z TRACE librespot] 		--verbose
[2022-02-07T22:32:41Z TRACE librespot] 		-c "/path/to/my/cache"
```
2022-02-07 23:37:29 +01:00
Roderick van Domburg
c49415c3fb
Merge pull request #960 from JasonLG1979/fix-shuffle
Prevent shuffle crash
2022-02-03 09:36:09 +01:00
JasonLG1979
d54f3982a0 update changelog 2022-02-01 17:48:13 -06:00
JasonLG1979
edb98d5c1d Prevent shuffle crash
fixes https://github.com/librespot-org/librespot/issues/959
2022-01-31 18:31:09 -06:00
Roderick van Domburg
f4be9bb85d
Merge pull request #954 from JasonLG1979/remove-dep-warning
Remove basic normalisation deprecation warning
2022-01-28 08:45:18 +01:00
JasonLG1979
3c749a8f0e Remove basic normalisation deprecation warning 2022-01-27 17:03:21 -06:00
Roderick van Domburg
c8971dce63
Fix Alsa softvol linear mapping (#950)
Use `--volume-range` overrides
2022-01-27 18:39:28 +01:00
Jason Gray
03e71f6e0a
simplify get_factor (#942)
Simplify `get_factor`
2022-01-27 07:40:59 +01:00
Roderick van Domburg
55ced49c2d
Merge pull request #929 from jforberg/playlist_tracks
Add error message for bad ID
2022-01-24 13:47:09 +01:00
Jason Gray
ceebb374f0
Remove unsafe code (#940)
Remove unsafe code
2022-01-23 19:02:04 +01:00
Jason Gray
c6e97a7f8a
Save some more CPU cycles in the limiter (#939)
Optimise limiter CPU usage
2022-01-17 22:57:30 +01:00
Roderick van Domburg
72af0d2014
New dynamic limiter for very wide dynamic ranges (#935)
New dynamic limiter for very wide dynamic ranges
2022-01-14 23:31:29 +01:00
Roderick van Domburg
1e54913523
Fix --device argument to various backends (#938)
Fix `--device` argument to various backends
2022-01-14 08:20:29 +01:00
Johan Förberg
5e8e2ba8c5 examples/playlist_tracks: Use normal URI parser 2022-01-11 19:29:38 +01:00
Roderick van Domburg
a605444d18
Merge pull request #926 from JasonLG1979/clippy-lints-portaudio
Fix clippy lint warning
2022-01-06 09:49:18 +01:00
JasonLG1979
cfde70f6f9 Fix clippy lint warning 2022-01-05 16:55:16 -06:00
Roderick van Domburg
92b8476645
Merge pull request #922 from JasonLG1979/cleanup_list_compatible_devices
Clean up `list_compatible_devices`
2022-01-03 22:32:22 +01:00
JasonLG1979
8dfa00d66f Clean up list_compatible_devices
Fix a typo and be a little more forgiving.
2022-01-01 17:19:12 -06:00
Roderick van Domburg
9202ec01d4
Merge pull request #920 from gdesmott/write-own
Sink: pass ownership of the packet on write()
2022-01-01 17:00:03 +01:00
Guillaume Desmottes
f09be4850e Sink: pass ownership of the packet on write()
Prevent a copy if the implementation needs to keep the data around.
2021-12-31 13:46:35 +01:00
Roderick van Domburg
b1bdf1d7f2
Merge pull request #916 from JasonLG1979/remove-last-unwraps-from-main
Remove `unwrap`s from main
2021-12-27 11:36:03 +01:00
JasonLG1979
1f43e9e389 Remove that last couple unwraps from main
Also:

* Don't just hang if Spirc shuts down too often.

* Replace the while loop with Vec retain.

* Be more explicit with the rate limit.
2021-12-26 17:45:06 -06:00
Roderick van Domburg
4370aa1cbe
Merge pull request #910 from JasonLG1979/fix-alsa-mixer-device
Fix auto fallback for --alsa-mixer-device and --alsa-mixer-index
2021-12-22 08:47:27 +01:00
JasonLG1979
305f80bdfd Fix auto fallback for --alsa-mixer-device and --alsa-mixer-index
As mentioned in https://github.com/librespot-org/librespot/issues/898#issuecomment-986528998
2021-12-21 19:29:35 -06:00
Roderick van Domburg
e5fd7d6506
Merge pull request #899 from JasonLG1979/arg_parse_fixup
Fix incorrect verbose logging of command line options
2021-12-16 22:49:54 +01:00
Jason Gray
306096ee2a
Merge branch 'librespot-org:dev' into arg_parse_fixup 2021-12-15 12:28:09 -06:00
Roderick van Domburg
24e2c6da25
Merge pull request #907 from tomodachi/arm64
Add arm64 target example
2021-12-15 19:02:14 +01:00
Roderick van Domburg
1736e7c52b
Merge pull request #905 from roderickvd/fix-exit-on-decoder-error
Skip track on decoding error
2021-12-15 19:01:15 +01:00
Roderick van Domburg
1cd5f9e571
Merge pull request #896 from JasonLG1979/dynamic-alsa-buffer
Dynamic failable buffer sizing alsa-backend
2021-12-15 18:52:27 +01:00
JasonLG1979
d5efb8a620 Dynamic failable buffer sizing alsa-backend
Dynamically set the alsa buffer and period based on the device's reported min/max buffer and period sizes. In the event of failure use the device's defaults.

This should have no effect on devices that allow for reasonable buffer and period sizes but would allow us to be more forgiving with less reasonable devices or configurations.

Closes: https://github.com/librespot-org/librespot/issues/895
2021-12-14 16:49:09 -06:00
Mateusz Mojsiejuk
67836b5b02 Added arm64 target to docker run examples. Also removed
feature quotes as they're not nessesary and don't match
the non-quoted examples of targets in the WIKI
2021-12-14 21:23:13 +01:00
JasonLG1979
368bee1088 condense some option parsings 2021-12-13 18:43:28 -06:00
JasonLG1979
d29337c62d Dry up error messages. 2021-12-12 23:25:19 -06:00
Roderick van Domburg
8f23c3498f
Clean up warnings 2021-12-12 20:01:05 +01:00
Roderick van Domburg
79c4040a53
Skip track on decoding error 2021-12-12 12:56:02 +01:00
JasonLG1979
8c480b7e39 Fix Command line arguments incorrectly echoed in TRACE
Fix up for #886
Closes: #898

And...

* Don't silently ignore non-Unicode while parsing env vars.

* Iterating over `std::env::args` will panic! on invalid unicode. Let's not do that. `getopts` will catch missing args and exit if those args are required after our error message about the arg not being valid unicode.

* Gaurd against empty strings. There are a few places while parsing options strings that we don't immediately evaluate their validity let's at least makes sure that they are not empty if present.

* `args` is only used in `get_setup` it doesn't need to be in main.

* Nicer help header.

* Get rid of `use std::io::{stderr, Write};` and just use `rpassword::prompt_password_stderr`.

* Get rid of `get_credentials` it was clunky, ugly and only used once. There is no need for it to be a separate function.

* Handle an empty password prompt and password prompt parsing errors.

* + Other random misc clean ups.
2021-12-11 16:24:09 -06:00
Roderick van Domburg
7160dc1017
Merge pull request #897 from JasonLG1979/clippy-lints
Address clippy lint warnings from Rust 1.57
2021-12-03 20:07:56 +01:00
JasonLG1979
4370258716 Address clippy lint warnings for rust 1.57 2021-12-03 12:51:41 -06:00
Jason Gray
e66cc5508c
parse environment variables (#886)
Make librespot able to parse environment variables for options and flags.

To avoid name collisions environment variables must be prepended with `LIBRESPOT_` so option/flag `foo-bar` becomes `LIBRESPOT_FOO_BAR`.

Verbose logging mode (`-v`, `--verbose`) logs all parsed environment variables and command line arguments (credentials are redacted).
2021-12-01 21:29:58 +01:00
Tom Vincent
bbd575ed23
Harden systemd service, update restart policy (#888) 2021-11-26 19:49:50 +01:00
Roderick van Domburg
97399e2c0a
Merge pull request #883 from JasonLG1979/improve_device_list_outputs
Improve `--device ?` functionality for the alsa backend
2021-11-25 09:45:36 +01:00
JasonLG1979
c006a23644 Improve --device ? functionality for the alsa backend
This makes `--device ?` only show compatible devices (ones that support 2 ch 44.1 Interleaved) and it shows what `librespot` format(s) they support.

This should be more useful to users as the info maps directly to `librespot`'s `--device` and `--format` options.
2021-11-20 13:51:24 -06:00