oboe
oboe copied to clipboard
Weird ErrorInvalidState for gettimestamp() in Android 11
Android version(s): 11 Android device(s): Pixel 5a Oboe version: 1.6.1 App name used for testing: use mediarecorder to record video and Oboe to record audio
Short description It only happens in Android 11. It works well in Android 10 It can record the audio but cannot get timestamps. Check the getstate() before call gettimestamp(). It is StreamState::Started. The error comes from https://github.com/google/oboe/blob/a0731d6041561da9a15efdfd4ed49718b57bf5b4/src/aaudio/AudioStreamAAudio.cpp#L661-L662
It may be the error from aaudio.
Steps to reproduce call mInputStream->getTimestamp(CLOCK_MONOTONIC) Expected behavior Get the timestamp Actual behavior return the error result Device Pixel 5a with Android 11 does not work. Pixel 3 XL with Android 10 and Redmi Note 9s with Android 10 work well
Please see: https://developer.android.com/ndk/reference/group/audio#aaudiostream_gettimestamp
Note that because requestStart() is asynchronous, timestamps will not be valid until a short time after calling requestStart(). So AAUDIO_ERROR_INVALID_STATE should not be considered a fatal error. Just try calling again later.
If you keep calling then do you eventually get timestamps? How long does it take?
Please see: https://developer.android.com/ndk/reference/group/audio#aaudiostream_gettimestamp
Note that because requestStart() is asynchronous, timestamps will not be valid until a short time after calling requestStart(). So AAUDIO_ERROR_INVALID_STATE should not be considered a fatal error. Just try calling again later.
If you keep calling then do you eventually get timestamps? How long does it take?
It always keeps returning the error.
Note that there is no timestamp error when only using audio stream on Android 11. The error happens when I use MediaRecorder to record the video at the same time. Everything works well on Android 10.
Update: I upgrade the Android OS. It works well on Pixel 5a with Android 12. I believe the key cause is Android 11.