Commit graph

1873 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
3dafb5904e Fix up for #1178
sys.uptime() returns sec not mins so it should be 60 not 1.
2023-07-01 22:25:48 -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
242e68a98c Revert remaining spirc changes
It's best to deal with this after discovery is fixed.
2023-06-30 10:56:44 -05:00
Jason Gray
b15b48b626 Merge branch 'dev' into resampling 2023-06-30 10:30:26 -05:00
Jason Gray
4d6de15a97
Discovery retry (#1178)
When started at boot as a service discovery may fail due to it
trying to bind to interfaces before the network is actually up.
This could be prevented in systemd by starting the service after
network-online.target but it requires that a wait-online.service is
also enabled which is not always the case since a wait-online.service
can potentially hang the boot process until it times out in certain situations.
This allows for discovery to retry every 10 secs in the 1st 60 secs of uptime
before giving up thus papering over the issue and not holding up the boot process.
2023-06-30 09:30:14 +02:00
Jason Gray
00ee65b006
Merge branch 'librespot-org:dev' into resampling 2023-06-29 20:31:46 -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
Roderick van Domburg
e5d364b07a
Merge pull request #1181 from yubiuser/xml
Update quick-xml to 0.29
2023-06-28 22:18:26 +02:00
Roderick van Domburg
2242a24d7e
Merge pull request #1175 from librespot-org/dependabot/github_actions/dev/actions/checkout-3.5.3
Bump actions/checkout from 3.5.2 to 3.5.3
2023-06-28 22:03:29 +02: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
d1e4b4464a Break message recursion. 2023-06-26 21:31:03 -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
2fa2bf86cb Don't handle messages that are not intended for us in spirc.
This prevents 2 active instances of librespot from effectively arguing over who the current active instance actually is. Without it events recurse.
2023-06-26 17:12:32 -05:00
JasonLG1979
98f1fe84dd Reduce allocations 2023-06-26 05:11:30 -05:00
JasonLG1979
8e6d452765 Don't use Instant elapsed
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
2023-06-26 02:32:39 -05:00
JasonLG1979
d3ae1cdc55 Update all deps 2023-06-25 21:09:43 -05:00
Christian König
9c30532fd4
Update quick-xml to 0.29
Signed-off-by: Christian König <ckoenig@posteo.de>
2023-06-25 23:32:09 +02: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
ad4763005d Add release-dist-optimized profile
release-dist-optimized inherits from `release`. Useful if you're distributing librespot at part of a project. The diffrences are:

panic = "abort", Makes librespot abort instead of unwind and hang on a panic.
Extremely useful when running librespot unattended as a system service for example to allow for auto-restarts.

codegen-units = 1 and lto = true, Take slighly longer to compile but produce more optimized binaries.
2023-06-23 18:51:17 -05:00
JasonLG1979
340bac5eb0 Warn the user if the try to set interpolation-quality with 44.1kHz 2023-06-23 14:33:01 -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
b5e0ea2bd3 Fix examples and update change log 2023-06-22 02:06:24 -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