Make noises on Ubuntu 18.04 with Pulseaudio #2
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
WIP, don't merge, contains ugly workarounds to #1. :-)
On Ubuntu 18.04 with Pulseaudio, the
with_max_sample_rate
method returnsFormat { channels: 1, sample_rate: SampleRate(192_000), data_type: I16 }
but the code assumes:
Format { channels: 2, sample_rate: SampleRate(44_100), data_type: F32 }
so we hard-wire it.
Then cpal returns a buffer of length 8820, which is not a multiple of 64: the code tries to fill the too short tail and we get an
index out of bounds
panic. The workaround shown here is to not use the buffer tail. I also tried skipping the tail of the last worker chunk, but in both cases the resulting audio is scratchy, because the waveform gets cut off or has additional pauses.I could not find a way to tell
cpal
to use a given buffer size, nor to tell the workers to use a different chunk size.