mozilla / cubeb-coreaudio-rs

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

Don't assert about input_frames / total_input_frames when input-only. #174

Closed padenot closed 2 years ago

padenot commented 2 years ago

This is possible if the first branch of:

if status == kAudioUnitErr_CannotDoInCurrentContext

is taken and there's been data before. In this case, it's possible to have input frames, but impossible to have them, probably. I can reproduce 100% of the time by installing BlackHole-16ch and running ./run_tests.sh on the M1 Max.

ChunMinChang commented 2 years ago

After testing BlackHole-16ch on my MBP M1 Max, I find the problem is in input frame calculation instead of that assertion itself. I've pushed some code in this PR so you can test it on your end to see if the problem solves or not.

padenot commented 2 years ago

I am not sure I understand why assert!(input_frames as i64 <= total_input_frames) will be hit without hitting assert!(!stm.core_stream_data.output_unit.is_null()) first:

I think it's related with Siri or concurrent device reconfiguration maybe? You have the input callback firing with a number of frames, but when you attempt to render, it says it's now unavailable. We've hit this before (hence this code path), and I'm pretty sure it was at least when doing the device had an input stream going, and siri was triggered.

Anyways, yeah the buffer_manager code was wrong, thanks for the fix, it works locally as well for me.

padenot commented 2 years ago

Cleaned up the branch and merging.