mozilla / cubeb-coreaudio-rs

The audio backend of Firefox on Mac OS X.
ISC License
25 stars 10 forks source link

Fix two bugs and add logs #57

Closed padenot closed 4 years ago

padenot commented 4 years ago

This is about duplex stream that have to use non-aggregate devices.

Bug #1 (https://github.com/ChunMinChang/cubeb-coreaudio-rs/commit/89147a72e90716d3e4cd37230d4d8f166c15c506) was that we're not draining the linear_input_buffer. If the output is super long to start compared to the output, a lot of input audio has been buffered. We need to remove most of the input frames when we have the first output callback. The opposite case was covered, not having audio input data when the first output callback was early.

Bug #2 (https://github.com/ChunMinChang/cubeb-coreaudio-rs/commit/5499668a61454dc7f51bd78ad13ab94b8c1d3f0e) was that the code was completely wrong, the function is to be able to feed the right amount of data into the resampler, to have continuous audio, and to detect when we're under-running, to try to correct it. This is the right code. The C++ has the same bug so it's not cause by rewrite I guess.

Then I'm adding some logs that I found useful to debug (https://github.com/ChunMinChang/cubeb-coreaudio-rs/commit/5499668a61454dc7f51bd78ad13ab94b8c1d3f0e).

ChunMinChang commented 4 years ago

I am ok to merge this first and import it to Firefox ASAP and fix the comments later. Unfortunately, I don't have level-3 to push the commit. I'll see if I can find one to vouch for me. If I can find one today, I'll merge this first.

ChunMinChang commented 4 years ago

Merge the update first so users can test if this fix their issues. We should file another PR as a follow up.

ChunMinChang commented 4 years ago

I think it's better to fix #61 before importing this to Firefox.