Fix crackling audio when using Sink#320
Conversation
est31
left a comment
There was a problem hiding this comment.
There should still be an upper bound to the length. It influences buffer sizes for example. If THRESHOLD is too small and that causes issues, one can define another larger constant by which to clamp the returned value, e.g. 4096.
|
Is this method really the right place to clamp it though? If a method further down the pipeline needs to break things up into chunks for more efficient buffering it should be free to do that anyway, right? The frame_len is only supposed to be an upper bound on the allowed buffer if I understand it correctly. |
|
In a test I changed it to always return Some(4096) and that does get rid of the crackling as well. |
|
Hmm yeah I think I misread |
|
Hmmm, actually UniformSourceIterator::bootstrap does use the frame size without any limits. Might want to have some limit there. |
|
@HalfVoxel PRs welcome! |
|
I would gladly open one, but I'm not sure what the best limit value is? I haven't got enough insight into the library to have a feel for the possible consequences. |
|
buffered.rs uses 32768. I guess that value is okay. |

Fixes #318.
Fixes #319.
Fixes #266.
Combined, these two fixes also fix crackling audio on my computer. The reason for the crackling audio was that Done did not implement size_hint so it would always fall back to a frame size of 512. Somewhere down the pipeline this causing crackling every 512 samples I suspect (which might be worth fixing too).
The current_frame_length fix is necessary because in my case I was playing from a sound file and it returns a size hint on the format
(very_large_number, Some(very_large_number))and the current_frame_length method would just ignore that and fall back to a frame length of 512 samples anyway.This might also fix #225 (I am running on linux, so I cannot test that).