diff options
author | Android Build Coastguard Worker <android-build-coastguard-worker@google.com> | 2021-08-27 06:20:24 +0000 |
---|---|---|
committer | Android Build Coastguard Worker <android-build-coastguard-worker@google.com> | 2021-08-27 06:20:24 +0000 |
commit | 5d21b9d6de8f54203e306c7e7224a899c46c0f15 (patch) | |
tree | b69723eebf023f54d0e71be94f0d74a98cbcf77e | |
parent | f66876dc1a1581f0eb4bc7249aef9be9d960f3ec (diff) | |
parent | 07c80fdaa0340d60e5be2ceff31037712859412b (diff) | |
download | libhardware-android-mainline-12.0.0_r44.tar.gz |
Snap for 7679530 from 07c80fdaa0340d60e5be2ceff31037712859412b to mainline-extservices-releaseandroid-mainline-12.0.0_r9android-mainline-12.0.0_r87android-mainline-12.0.0_r72android-mainline-12.0.0_r44android-mainline-12.0.0_r27android-mainline-12.0.0_r117android-mainline-12.0.0_r102android12-mainline-extservices-release
Change-Id: If5efd79d5ebda9bec3ca9bca8e83a6d166c08e61
-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 cc9e4f7c..39c0fb5c 100644 --- a/modules/usbaudio/audio_hal.c +++ b/modules/usbaudio/audio_hal.c @@ -1652,6 +1652,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) { @@ -1661,6 +1670,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) { |