Commit 201d120e by krocard Committed by Oliver Woodman

Recover from audio server crash while sleeping for offload

Without this patch, playback would be frozen indefinitely
until the user manually pauses and unpauses it.

This has the side effect of disabling offload until
the next stop due to the workaround of
disabling offload when it encounters a failure.

As an audio server crash is considered very
infrequent, especially in stable conditions like
an audio only playback, it is unlikely that disabling
offload is an issue.

PiperOrigin-RevId: 332857094
parent 1850a918
......@@ -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);
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or sign in to comment