diff options
author | Haamed Gheibi <haamed@google.com> | 2021-07-12 20:47:30 +0000 |
---|---|---|
committer | Haamed Gheibi <haamed@google.com> | 2021-07-12 20:47:30 +0000 |
commit | 9bec19a4772b4c8d1edf7f7cca4a0b05cfc8ce33 (patch) | |
tree | cddb25b008cdeac8c747ae27cbd352d94967dc2d | |
parent | 10ed0c75d7c0d64a82c138389533bea6b6f33f4d (diff) | |
parent | a8568d0d3478cf8b75b36f9c7bd584cce5cfbd5c (diff) |
Merge SP1A.210709.002
Change-Id: I09fb49c5d935aaaffedc4e01dc08d309a30a8b1d
-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) { |