Closed philburk closed 4 years ago
Thanks for detecting the issue !
"and then request that same sample rate for input so they match" => does this mean the input will then do resampling ? Or is there a way to setup native sampling rate ?
Good question. If you request a sample rate that does not match the native sample rate then you will not get a low latency stream UNLESS you use the new Oboe resampler. This was added in Oboe 1.3.0.
If the native rate matches then it will skip the resampler so no overhead.
I tried to swap the two blocks, so that opening the output stream is done first. Then opening the input stream works (openManagedStream(fInputStream) != oboe::Result::OK
is fine) but reading it in the callback fails here oboe::ResultWithValue<int32_t> res = fInputStream->read(inbuffer, framesWrite, 0);
Any idea?
New version https://github.com/grame-cncm/faust/blob/master-dev/architecture/faust/audio/oboe-dsp.h, can you possibly check ?
I do not see any obvious errors in the way the streams are setup.
What is the error returned from the read()? Maybe print it at Line 125.
convertToText(res.error())
It is possible that the Input stream may not be ready for some reason the first time you call it. Does the error happen at the beginning, at the end or always?
Another issue is in the stop(). You close the input stream but it is still being used by the output stream callback. There is a race condition. Better to close the output stream before closing the input stream.
Thanks.
"Better to close the output stream before closing the input stream." => is it documented somewhere ?
Not specifically. We are planning to add a Tech Note on full duplex operation.
If I interpret this code correctly:
https://github.com/grame-cncm/faust/blob/master-dev/architecture/faust/audio/oboe-dsp.h
if the sample rate is not specified then it will use the default rate for INPUT and OUTPUT. Surprisingly, on Android, those may not be the same! When visiting China, I was surprised to learn that there are some devices that use 44100 for input and 48000 for output! You may want to open the output first and then request that same sample rate for input so they match.