diff options
author | Andy Hung <hunga@google.com> | 2021-07-05 07:41:36 +0000 |
---|---|---|
committer | Automerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com> | 2021-07-05 07:41:36 +0000 |
commit | 8c6e35a9d8ef76e8e02f818dbc053ff80d114c88 (patch) | |
tree | 2a2323e7454e21d90c6f228e3e3bd7e70744f6f4 /modules | |
parent | 80cf50d3d4312bd3806d62afc9e08d1979b22c1b (diff) | |
parent | 07c80fdaa0340d60e5be2ceff31037712859412b (diff) | |
download | libhardware-8c6e35a9d8ef76e8e02f818dbc053ff80d114c88.tar.gz |
USB Audio Hal: Fix CTS timestamp handling am: 61583424ff am: 07c80fdaa0
Original change: https://googleplex-android-review.googlesource.com/c/platform/hardware/libhardware/+/15190378
Change-Id: I03d7042c652c6494ad4a8dd085a3895eba9b3c46
Diffstat (limited to 'modules')
-rw-r--r-- | modules/usbaudio/audio_hal.c | 16 |
1 files changed, 16 insertions, 0 deletions
diff --git a/modules/usbaudio/audio_hal.c b/modules/usbaudio/audio_hal.c index 24524965..fe921d69 100644 --- a/modules/usbaudio/audio_hal.c +++ b/modules/usbaudio/audio_hal.c @@ -1695,6 +1695,15 @@ static int adev_create_audio_patch(struct audio_hw_device *dev, stream_standby_l(alsa_devices, out == NULL ? &in->standby : &out->standby); device_unlock(adev); + // Timestamps: + // Audio timestamps assume continuous PCM frame counts which are maintained + // with the device proxy.transferred variable. Technically it would be better + // associated with in or out stream, not the device; here we save and restore + // using the first alsa device as a simplification. + uint64_t saved_transferred_frames = 0; + struct alsa_device_info *device_info = stream_get_first_alsa_device(alsa_devices); + if (device_info != NULL) saved_transferred_frames = device_info->proxy.transferred; + int ret = stream_set_new_devices(config, alsa_devices, num_configs, cards, devices, direction); if (ret != 0) { @@ -1704,6 +1713,13 @@ static int adev_create_audio_patch(struct audio_hw_device *dev, } else { *patch_handle = *handle; } + + // Timestamps: Restore transferred frames. + if (saved_transferred_frames != 0) { + device_info = stream_get_first_alsa_device(alsa_devices); + if (device_info != NULL) device_info->proxy.transferred = saved_transferred_frames; + } + if (!wasStandby) { device_lock(adev); if (in != NULL) { |