diff --git a/RELEASENOTES.md b/RELEASENOTES.md index 7bdfadc96f1..5f7ca930029 100644 --- a/RELEASENOTES.md +++ b/RELEASENOTES.md @@ -19,6 +19,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: diff --git a/libraries/exoplayer/src/main/java/androidx/media3/exoplayer/audio/DefaultAudioSink.java b/libraries/exoplayer/src/main/java/androidx/media3/exoplayer/audio/DefaultAudioSink.java index 7ba42ca8706..e2238fca0be 100644 --- a/libraries/exoplayer/src/main/java/androidx/media3/exoplayer/audio/DefaultAudioSink.java +++ b/libraries/exoplayer/src/main/java/androidx/media3/exoplayer/audio/DefaultAudioSink.java @@ -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 @@ private void maybeReportSkippedSilence() { 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)