diff --git a/library/core/src/main/java/com/google/android/exoplayer2/audio/DefaultAudioSink.java b/library/core/src/main/java/com/google/android/exoplayer2/audio/DefaultAudioSink.java index 1e04b1e8d7..41e76440c1 100644 --- a/library/core/src/main/java/com/google/android/exoplayer2/audio/DefaultAudioSink.java +++ b/library/core/src/main/java/com/google/android/exoplayer2/audio/DefaultAudioSink.java @@ -28,6 +28,7 @@ import android.os.Handler; import android.os.SystemClock; import android.util.Pair; import androidx.annotation.IntDef; +import androidx.annotation.NonNull; import androidx.annotation.Nullable; import androidx.annotation.RequiresApi; import com.google.android.exoplayer2.C; @@ -1694,6 +1695,16 @@ public final class DefaultAudioSink implements AudioSink { } } + @Override + public void onTearDown(@NonNull AudioTrack track) { + if (listener != null && playing) { + // A new Audio Track needs to be created and it's buffer filled, which will be done on the + // next handleBuffer call. + // Request this call explicitly in case ExoPlayer is sleeping waiting for a data request. + listener.onOffloadBufferEmptying(); + } + } + public void register(AudioTrack audioTrack) { audioTrack.registerStreamEventCallback(handler::post, this); }