audio: hal: Fix CTS test failure with no hardware output
last_write_time_us is an approximation of when the (simulated) alsa
buffer is believed completely full. The usleep above waits for more space
in the buffer, but by the end of the sleep the buffer is considered
topped-off.
On the subsequent out_write(), we measure the elapsed time spent in
the mixer. This is subtracted from the sleep estimate based on frames,
thereby accounting for drain in the alsa buffer during mixing.
This is a crude approximation; we don't handle underruns precisely.
Note that this is copied from the stub hal.
Bug: 33764682
Change-Id: I3f3b825ede8f98b92b09ac76be3835c54bd7188f
2 files changed