Commit graph

402 commits

Author SHA1 Message Date
JasonLG1979
33e2ce65d3 Anti-alias Linear Interpolation also. 2023-07-03 14:10:21 -05:00
JasonLG1979
cb8f6c954d Duh, just use resample_factor_reciprocal
The resample_factor_reciprocal also happens to be our
anti-alias cutoff. In this case it represents the minimum
output bandwidth needed to fully represent the input.
2023-07-02 22:16:14 -05:00
JasonLG1979
87bbd539b7 Add anti-alias filtering just in case
Cap the output bandwidth to 92%.
Even at 48kHz it still translates to 100% source bandwidth.
This just provides a little bit of anti-alias filtering.
There is more then likely nothing there to filter,
but it doesn't hurt or cost us anything to make sure.
2023-07-02 17:59:11 -05:00
JasonLG1979
74e3f938da Make sure that decoder picks up where it left of going from paused to play
Since we are including the pipeline latency in the position we need to seek to the correct position when going from paused to play.

We can also drop the ALSA and PulseAudio buffers instead of draining them since their latency's are factored in.
2023-07-02 04:31:04 -05:00
JasonLG1979
c4dc7347c7 Change Interpolation Quality to default to High 2023-06-30 13:55:34 -05:00
JasonLG1979
25425dab5c Put CommonSampleRates to some use and clean up backend imports 2023-06-30 12:36:12 -05:00
JasonLG1979
15e2b441aa Fully implement CommonSampleRates 2023-06-29 16:35:54 -05:00
JasonLG1979
1ab5bac786 Address review comments 2023-06-28 22:16:33 -05:00
JasonLG1979
cea92a9c3a Avoid unnecessary Vec -> Slice -> Vec
In the case of a resampler bypass
2023-06-27 19:21:02 -05:00
JasonLG1979
20414e44b8 More warnings 2023-06-27 17:05:52 -05:00
JasonLG1979
841f923549 Remove unnecessary step
Our interpolation_coefficients are already normalized.
2023-06-27 16:13:31 -05:00
JasonLG1979
4b081b1365 Warn that trying to resample 44.1kHz to 44.1kHz is a stupid thing to do. 2023-06-26 18:00:39 -05:00
JasonLG1979
c29ec3f473 Add warning about Normalisation Attack or Release being to small 2023-06-26 17:45:28 -05:00
JasonLG1979
98f1fe84dd Reduce allocations 2023-06-26 05:11:30 -05:00
JasonLG1979
d3ae1cdc55 Update all deps 2023-06-25 21:09:43 -05:00
JasonLG1979
528a8a431e Don't pad the alsa buffer anymore on stop.
It's no longer necessary with the SymphoniaDecoder, in fact it causes the problem it used to prevent. Namely pops when you pause.
2023-06-24 22:50:32 -05:00
JasonLG1979
ac2c05a0f8 Reset the resampler's latency when stopped 2023-06-24 20:16:21 -05:00
JasonLG1979
f7c56dff44 Remove AudioPacketPosition
We don't need it since we now tell if we've skipped packets by calculating a max delta.
2023-06-24 18:59:01 -05:00
JasonLG1979
5e02b6643d Simplify time calculations in SymphoniaDecoder
Time impl's from f64 (as secs) so there's no need to manually calculate it beyond converting ms to sec.

If we grab the TimeBase in new we don't need to continually call decoder.codec_params().time_base everytime we want to convert ts to ms.
2023-06-24 18:10:35 -05:00
JasonLG1979
0bdfa726ca Remove round from pulse get_latency_pcm, floor math is fine 2023-06-24 15:26:29 -05:00
JasonLG1979
74b52e83fa Improve resampler performance
Do less calls into the worker.
2023-06-24 15:06:28 -05:00
JasonLG1979
46b8f84d6a Make sure there is only ever one allocation when converting
Collect is probably fine but for code that's this hot it's worth the couple extra lines to make certain there's only ever one allocation when it comes to the returned Vec.
2023-06-23 12:00:42 -05:00
JasonLG1979
5da8ddf5e2 Rename set_factor to update_normalisation_data to better indicate what it does 2023-06-23 11:24:10 -05:00
JasonLG1979
bfb0366c90 Make sure the ResampleWorker task_receiver is also drained on drop 2023-06-23 10:10:14 -05:00
JasonLG1979
0e3ffe5394 Harmonize thread names and debug messages 2023-06-23 03:08:22 -05:00
JasonLG1979
8d35b4b860 Update notify_about_position logic
It would be so much easier to use elapsed but elapsed could potentially panic is rare cases.

See: https://doc.rust-lang.org/std/time/struct.Instant.html#monotonicity

Otherwise this is pretty straight forward.
If anything fails getting expected_position_ms it will return 0 which will trigger a notify if either stream_position_ms or decoder_position_ms is > 1000.

If all goes well it's simply a matter of calculating the max delta of expected_position_ms and stream_position_ms and expected_position_ms and decoder_position_ms.
So if the decoder or the sample pipeline are off by more than 1 sec we notify.
2023-06-23 00:38:15 -05:00
JasonLG1979
09bd1bd324 Fix up notify 2023-06-22 04:43:56 -05:00
JasonLG1979
586e9f1929 Fix clippy lint round 1000 + a small bug fix 2023-06-22 01:40:50 -05:00
JasonLG1979
2a8da828c4 Fix clippy lint 2023-06-22 01:26:15 -05:00
JasonLG1979
efec96b9cc Put it all together 2023-06-21 23:32:03 -05:00
JasonLG1979
e1ea400220 Change the backends so that they support the diffrent sample rates 2023-06-21 22:17:41 -05:00
JasonLG1979
3bcf5498d2 Convert get_latency_pcm to get_latency_ms in sample_pipeline 2023-06-21 21:11:37 -05:00
JasonLG1979
9861a582a6 Add sample_pipeline 2023-06-21 20:55:00 -05:00
JasonLG1979
375f83797a Add normaliser 2023-06-21 20:48:02 -05:00
JasonLG1979
3b64f25286 Add resampler 2023-06-21 20:29:22 -05:00
JasonLG1979
71660a2351 Add InterpolationQuality and SampleRate enums 2023-06-21 19:51:14 -05:00
JasonLG1979
7dae33c4f0 Use default macro 2023-06-21 19:24:40 -05:00
JasonLG1979
35b94bdc94 Add the ability to get backend latency 2023-06-21 19:17:23 -05:00
JasonLG1979
0cefd0ea66 Better thread handling in player 2023-06-21 19:09:21 -05: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