mirror of
https://github.com/samsonjs/media.git
synced 2026-04-15 12:55:46 +00:00
Fix handling of timestamps before play()
If the AudioTimestamp was sampled before play() was called, it was incorrectly returned to the caller for sanity-checking. Fix this behavior by dropping the timestamp internally in the AudioTimestampPoller. ------------- Created by MOE: https://github.com/google/moe MOE_MIGRATED_REVID=190584412
This commit is contained in:
parent
eb34a2a102
commit
6cb07adcee
1 changed files with 9 additions and 5 deletions
|
|
@ -121,11 +121,15 @@ import java.lang.annotation.RetentionPolicy;
|
|||
boolean updatedTimestamp = audioTimestamp.maybeUpdateTimestamp();
|
||||
switch (state) {
|
||||
case STATE_INITIALIZING:
|
||||
if (updatedTimestamp
|
||||
&& audioTimestamp.getTimestampSystemTimeUs() >= initializeSystemTimeUs) {
|
||||
// We have an initial timestamp, but don't know if it's advancing yet.
|
||||
initialTimestampPositionFrames = audioTimestamp.getTimestampPositionFrames();
|
||||
updateState(STATE_TIMESTAMP);
|
||||
if (updatedTimestamp) {
|
||||
if (audioTimestamp.getTimestampSystemTimeUs() >= initializeSystemTimeUs) {
|
||||
// We have an initial timestamp, but don't know if it's advancing yet.
|
||||
initialTimestampPositionFrames = audioTimestamp.getTimestampPositionFrames();
|
||||
updateState(STATE_TIMESTAMP);
|
||||
} else {
|
||||
// Drop the timestamp, as it was sampled before the last reset.
|
||||
updatedTimestamp = false;
|
||||
}
|
||||
} else if (systemTimeUs - initializeSystemTimeUs > INITIALIZING_DURATION_US) {
|
||||
// We haven't received a timestamp for a while, so they probably aren't available for the
|
||||
// current audio route. Poll infrequently in case the route changes later.
|
||||
|
|
|
|||
Loading…
Reference in a new issue