AudioFlinger: fix unique ID generation after crash
The uniqued ID generator will generate the same audio session IDs
after a native audioserver restarts as it always resumes genrating from 1.
This can be a problem as the session ID of existing clients is
preserved on client side and reused when the client reconnects after a
native audioserver process crash.
This is particularly likely to happen with system sounds (touch sounds)
for which an audio track is created early in the init phase and stays
around forever.
To mitigate this risk, offset the allocation range by the
elapsed system time (monotonic) to push risk of overlap until after
first wrap around. Accounting for an average of one new ID per second
seems a good compromise between limiting the risk of overlap and leaving
room before the first wrap around.
Bug: 183582878
Test: make
Change-Id: I21b30c144cc3daab425757d7441af9bb62f793e5
1 file changed