google / oboe

Oboe is a C++ library that makes it easy to build high-performance audio apps on Android.
Apache License 2.0
3.71k stars 569 forks source link

CLOCK_BOOTTIME does not work for gettimestamp #1476

Open sunwell1994 opened 2 years ago

sunwell1994 commented 2 years ago

Android version(s): 10 Android device(s): Pixel 3 XL Oboe version: 1.6.1 App name used for testing: (Please try to reproduce the issue using the OboeTester or an Oboe sample.) LiveEffect Short description (Please only report one bug per Issue. Do not combine multiple bugs.) Steps to reproduce Try stream->getTimestamp(CLOCK_MONOTONIC) and stream->getTimestamp(CLOCK_BOOTTIME) in LiveEffect. Expected behavior They should output different timestamps for the same frame position. Actual behavior They output the same timestamps whose clock source is the same as System.nanotime(). Device

Any additional context

If applicable, please attach a few seconds of an uncompressed recording of the sound in a WAV or AIFF file.

philburk commented 2 years ago

How much time difference are you seeing between CLOCK_MONOTONIC and CLOCK_BOOTTIME?

It appears the clockId is ignored for MMAP streams in AAudio: https://cs.android.com/android/platform/superproject/+/master:frameworks/av/media/libaaudio/src/client/AudioStreamInternal.cpp;l=514;drc=master

We will track this as an AAudio issue. I think Oboe is passing the clockId correctly to AAudio.

sunwell1994 commented 2 years ago

The difference of returned timestamps is 0. between CLOCK_MONOTONIC and CLOCK_BOOTTIME. The correct difference of my device should be 330738680632263 nanoseconds based on Java System clock APIs. It is the AAudio issue. I also verified it through AAudio directly.