Closed ChunMinChang closed 4 years ago
Won't this reintroduce the problems of https://github.com/ChunMinChang/cubeb-coreaudio-rs/pull/79 ?
Won't this reintroduce the problems of #79 ?
I am unable to reproduce the glitch that #79 tried to fix. It's better to create a regression test to prevent that glitch otherwise that problem might popup again.
However, from the code we used to have in #79, the silent frames would be appended to the buffer_manager
in the following case:
https://github.com/ChunMinChang/cubeb-coreaudio-rs/blob/27cf89ef920d1968c06e45f2a7903725d6b635cd/src/backend/mod.rs#L609-L615
and then the corrected buffer (with newly added silent frames) would be fed to the resampler:
https://github.com/ChunMinChang/cubeb-coreaudio-rs/blob/27cf89ef920d1968c06e45f2a7903725d6b635cd/src/backend/mod.rs#L631-L635
This is same as what the current change does here. The difference is that this patch would append the silent frames by get_linear_data
implicitly instead of calling push_silent_data
and then using get_linear_data
(push_silent_data
is removed). Thus, if the fix in #79 doesn't cause the glitch, the change here won't cause the glitch as well (however I am not able to test the glitch).
https://github.com/ChunMinChang/cubeb-coreaudio-rs/issues/91#issuecomment-625489253: Another approach is allowing push 0
frames to the resampler once it's initialized.
The change here fixes #91 and complete what we want to do in #86.
The
assert(destination && source)
in [1] will be hit in the following scenario:audiounit_output_callback
comes beforeaudiounit_input_callback
audiounit_input_callback
is never called before 1input_buffer_manager.available_samples()
is0
since no buffered input datainput_frame_count
of the firstffi::cubeb_resampler_fill
would be0
The silent frames needs to be fed as the input buffer to the resampler.
[1] https://github.com/kinetiknz/cubeb/blob/35190a8da650be297edb91d2db778bed622d8691/src/cubeb_utils.h#L31