Report the skipped silence more deterministically

Issue: androidx/media#1035
#minor-release
PiperOrigin-RevId: 605361126
This commit is contained in:
tianyifeng 2024-02-08 10:37:26 -08:00 committed by Copybara-Service
parent e56e27e725
commit 9b0cdde7d2
2 changed files with 4 additions and 4 deletions

View file

@ -22,6 +22,8 @@
* Improve silence skipping algorithm with smooth volume ramp, retained
minimal silence and more natural silence durations
([#7423](https://github.com/google/ExoPlayer/issues/7423)).
* Report the skipped silence more deterministically
([#1035](https://github.com/androidx/media/issues/1035)).
* Video:
* Text:
* Metadata:

View file

@ -99,7 +99,7 @@ public final class DefaultAudioSink implements AudioSink {
private static final int AUDIO_TRACK_SMALLER_BUFFER_RETRY_SIZE = 1_000_000;
/** The minimum duration of the skipped silence to be reported as discontinuity. */
private static final int MINIMUM_REPORT_SKIPPED_SILENCE_DURATION_US = 1_000_000;
private static final int MINIMUM_REPORT_SKIPPED_SILENCE_DURATION_US = 300_000;
/**
* The delay of reporting the skipped silence, during which the default audio sink checks if there
@ -2340,10 +2340,8 @@ public final class DefaultAudioSink implements AudioSink {
if (accumulatedSkippedSilenceDurationUs >= MINIMUM_REPORT_SKIPPED_SILENCE_DURATION_US) {
// If the existing silence is already long enough, report the silence
listener.onSilenceSkipped();
accumulatedSkippedSilenceDurationUs = 0;
}
// Reset the accumulated silence anyway as the later silences are far from the current one
// and should be treated separately.
accumulatedSkippedSilenceDurationUs = 0;
}
@RequiresApi(23)