Commit graph

365 commits

Author SHA1 Message Date
Jarkko Lehtoranta
46195f18d6
Handle play_request_id as an event 2023-07-19 14:49:05 +03:00
Wang Guan
d6257c41ca make clippy happy: clippy::default-constructed-unit-structs 2023-07-14 00:21:37 +09:00
JasonLG1979
f89c622e30 Read Normalisation Data in one go
Read all the Normalisation Data in one shot to avoid 4 seperate reads.
2023-05-13 13:00:50 -05:00
AeRo
31d18f7e30
Respect disabled normalisation with maximum volume (#1159) 2023-05-06 09:47:08 +02:00
yubiuser
e14dac3ff3
Remove and update dependencies (#1140) 2023-04-11 20:33:45 +02:00
Roderick van Domburg
d569d37966
Merge pull request #1136 from eladyn/jack_update
update jack to match alsa requirement
2023-03-22 13:38:52 +01:00
eladyn
9836db2c2c
update jack to match alsa requirement 2023-03-22 13:35:15 +01:00
Federico
a50d0d4510
Update rodio to 0.17.1 and cpal to 0.15.1 #1191
Inherit upstream fix https://github.com/RustAudio/cpal/pull/648
2023-03-17 14:57:40 +01:00
Petr Tesarik
c600297f52 Fix newly reported clippy errors
- Use variables directly in format strings.
  As reported by clippy, variables can be used directly in the
  `format!` string.
- Use rewind() instead of seeking to 0.
- Remove superfluous & and ref.

Signed-off-by: Petr Tesarik <petr@tesarici.cz>
2023-01-27 23:15:51 +01:00
Guillaume Desmottes
7f2cb684c9 fix clippy warnings 2023-01-03 00:36:35 +01:00
Roderick van Domburg
eb1472c713
Various loading improvements
- Improve responsiveness by downloading the smallest possible chunk
  size when seeking or first loading.

- Improve download time and decrease CPU usage by downloading the
  largest possible chunk size as throughput allows, still allowing
  for reasonable seek responsiveness (~1 second).

- As a result, take refactoring opportunities: simplify prefetching
  logic, download threading, command sending, and some ergonomics.

- Fix disappearing controls in the Spotify mobile UI while loading.

- Fix handling of seek, pause, and play commands while loading.

- Fix download rate calculation (don't use the Mercury rate).

- Fix ping time calculation under lock contention.
2022-09-28 21:25:56 +02:00
JasonLG1979
8545f361c4 Major Events Overhaul
Special thanks to @eladyn for all of their help and suggestions.

* Add all player events to `player_event_handler.rs`

* Move event handler code to `player_event_handler.rs`

* Add session events

* Clean up and de-noise events and event firing

* Added metadata support via a TrackChanged event

* Add `event_handler_example.py`

* Handle invalid track start positions by just starting the track from the beginning

* Add repeat support to `spirc.rs`

* Add `disconnect`, `set_position_ms` and `set_volume` to `spirc.rs`

* Set `PlayStatus` to the correct value when Player is loading to avoid blanking out the controls when `self.play_status` is `LoadingPlay` or `LoadingPause` in `spirc.rs`

* Handle attempts to play local files better by basically ignoring attempts to load them in `handle_remote_update` in `spirc.rs`

* Add an event worker thread that runs async to the main thread(s) but sync to itself to prevent potential data races for event consumers.

* Get rid of (probably harmless) `.unwrap()` in `main.rs`

* Ensure that events are emited in a logical order and at logical times

* Handle invalid and disappearing devices better

* Ignore SpircCommands unless we're active with the exception of ShutDown
2022-09-17 16:21:10 -05:00
Roderick van Domburg
9d80521e09
Fix warning and clippy lints 2022-08-22 22:38:19 +02:00
Roderick van Domburg
2a79af1f0a
Migrate to Rust 2021 2022-08-02 21:42:38 +02:00
sqozz
d09ee4206c Add minimum rust version 2022-08-01 15:14:17 +02:00
Roderick van Domburg
786f8832d1
Update version numbers to 0.5.0-dev 2022-07-30 22:28:12 +02:00
Roderick van Domburg
37794c5b78
Merge branch 'new-api' into dev 2022-07-29 23:39:06 +02:00
Roderick van Domburg
6537c441c3
Update Cargo.lock 2022-07-29 22:05:10 +02:00
Roderick van Domburg
05b9b13cf8
Merge branch 'dev' into new-api and update crates 2022-07-27 23:31:11 +02:00
Roderick van Domburg
9385dc840f
Merge pull request #1014 from JasonLG1979/improve-subprocess-backend
Improve the subprocess backend
2022-07-18 22:21:12 +02:00
JasonLG1979
2532687cc6 Improve pipe backend
* Implement stop
* Better error handling
2022-06-30 21:57:23 -05:00
Jason Gray
9b2490e4e1
Merge branch 'librespot-org:dev' into improve-subprocess-backend 2022-06-30 21:33:47 -05:00
JasonLG1979
0d4367fca2 Improve the subprocess backend
Better error handling.

Move the checking of the shell command to start so a proper error can be thrown if it's None.

Use write instead of write_all for finer grained error handling and the ability to attempt a restart on write errors.

Use try_wait to skip flushing and killing the process if it's already dead.

Stop the player on shutdown to *mostly* prevent write errors from spamming the logs during shutdown. Previously Ctrl+c always resulted in a write error.
2022-06-20 17:19:31 -05:00
JasonLG1979
5a10a963ff Minor alsa backend tweaks
Silence a clippy warning and we don't need `std::cmp::min` when `usize` already has `min`.
2022-06-18 09:08:04 -05:00
JasonLG1979
e4deb5ddcd Fix fixed volume with hardware mixer.
fixes https://github.com/librespot-org/librespot/issues/1008
2022-06-09 16:34:42 -05:00
Roderick van Domburg
88e64bd884
Update Cargo.lock 2022-05-23 21:43:16 +02:00
JasonLG1979
0b7508a2bf Update deps round 2 2022-05-23 13:17:18 -05:00
JasonLG1979
c03d3ad102 Bump deps
This bumps deps that don't need major code refactoring or MSRV bumps.
2022-05-23 10:19:54 -05:00
Roderick van Domburg
dff19377fa
Update version numbers to 0.4.0 2022-05-21 22:31:15 +02:00
Roderick van Domburg
b08502c801
Update crates 2022-05-21 21:51:37 +02:00
Roderick van Domburg
2a3e248bba
Fix clippy lints 2022-05-21 21:36:56 +02:00
Sean McNamara
3d298768b3
Backport #964 GStreamer backend cleanup (#979) 2022-05-21 20:55:55 +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
JasonLG1979
3be6990a13 Update dependencies 2022-04-19 17:29:37 -05:00
Roderick van Domburg
a7a260be16
Fix SDL deprecations 2022-04-07 23:20:49 +02:00
Roderick van Domburg
1290ee9925
Fix clippy warnings 2022-04-07 22:32:43 +02:00
JasonLG1979
d887d58251 Fix clippy warnings 2022-03-20 10:52:08 -05:00
JasonLG1979
dc9f822c80 Port #976 2022-03-19 21:15:46 -05: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
JasonLG1979
85d6c0c714 symphonia_decoder tweak
* Remove unwrap

* Refactor normalisation_data.
2022-02-20 01:27:12 -06:00
Jason Gray
47f1362453
Port remove unsafe code and catch up with dev (#956) 2022-02-14 12:15:19 +01: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
Sebastian Dröge
ab562cc8d8
Update GStreamer to 0.18 and clean up (#964)
* Update GStreamer backend to 0.18
* Don't manually go through all intermediate states when shutting down the GStreamer backend; that happens automatically
* Don't initialize GStreamer twice
* Use less stringly-typed API for configuring the appsrc
* Create our own main context instead of stealing the default one; if the application somewhere else uses the default main context this would otherwise fail in interesting ways
* Create GStreamer pipeline more explicitly instead of going via strings for everything
* Add an audioresample element before the sink in case the sink doesn't support the sample rate
* Remove unnecessary `as_bytes()` call
* Use a GStreamer bus sync handler instead of spawning a new thread with a mainloop; it's only used for printing errors or when the end of the stream is reached, which can also be done as well when synchronously handling messages.
* Change `expect()` calls to proper error returns wherever possible in GStreamer backend
* Store asynchronously reported error in GStreamer backend and return them on next write
* Update MSRV to 1.56
2022-02-13 21:52:02 +01:00
Philip Deljanov
e64f09fd77 Upgrade to Symphonia v0.5. 2022-02-01 19:02:14 -05: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
9b25669a08
Fix clippy lints 2022-01-26 23:05:40 +01:00
Roderick van Domburg
827b815da9
Update Rodio and neatly call play/pause 2022-01-26 22:54:04 +01:00
Roderick van Domburg
552d9145f4
Feature-gate passthrough decoder 2022-01-25 20:46:10 +01:00
Jason Gray
ceebb374f0
Remove unsafe code (#940)
Remove unsafe code
2022-01-23 19:02:04 +01:00