-
Notifications
You must be signed in to change notification settings - Fork 582
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
getSampleRate disagrees with getFramesRead for input streams when sample rate conversion is enabled #1256
Labels
Comments
Thank you for reporting this problem with mRateScaler. You are correct. We will fix that. The best way to REPRODUCE the problem is:
EXPECT: about 10*8000 = 80,000 frames ACTUAL: about 3,200,000 frames We should fix this and also add a unit test to detect it. |
Reopening for unit tests. |
flamme
added a commit
that referenced
this issue
May 17, 2021
Add unit tests that open input/output stream and process data for a while and then verify the returned value from getFramesWritten is correct. Fixes #1256.
flamme
added a commit
that referenced
this issue
May 18, 2021
Add unit tests to that open input/output stream and process data for a while and then verify the returned values from getFramesWritten and getFramesRead are correct. Fixes #1256.
flamme
added a commit
that referenced
this issue
May 19, 2021
* Add unit tests for testing frames processed. Add unit tests to that open input/output stream and process data for a while and then verify the returned values from getFramesWritten and getFramesRead are correct. Fixes #1256.
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
The calculation here:
oboe/src/common/FilterAudioStream.cpp
Line 51 in 8041b38
getSampleRate
will always report the requested (converted) sample rate, which is the input sample rate for an output stream, but the output sample rate for an input stream. This means calculations working withgetSampleRate
along withgetFramesRead
on input streams will yield incorrect values. Changing the value ofmRateScaler
to((double) getSampleRate()) / mChildStream->getSampleRate();
appears to resolve this issue, by setting up a ratio that will consistently convert from the child (native) sample rate to the software (converted) sample rate.To demonstrate the problem, if we make a function that calculates latency for a stream based on AudioStreamAAudio's calculateLatencyMillis, it will produce implausibly small or negative values for latency when calculating for an input stream that's converting from 48k to 44.1k.
The text was updated successfully, but these errors were encountered: