mirror of
https://github.com/androidx/media.git
synced 2025-05-10 09:12:16 +08:00
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
This commit is contained in:
parent
1850a918f1
commit
201d120e38
@ -28,6 +28,7 @@ import android.os.Handler;
|
|||||||
import android.os.SystemClock;
|
import android.os.SystemClock;
|
||||||
import android.util.Pair;
|
import android.util.Pair;
|
||||||
import androidx.annotation.IntDef;
|
import androidx.annotation.IntDef;
|
||||||
|
import androidx.annotation.NonNull;
|
||||||
import androidx.annotation.Nullable;
|
import androidx.annotation.Nullable;
|
||||||
import androidx.annotation.RequiresApi;
|
import androidx.annotation.RequiresApi;
|
||||||
import com.google.android.exoplayer2.C;
|
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) {
|
public void register(AudioTrack audioTrack) {
|
||||||
audioTrack.registerStreamEventCallback(handler::post, this);
|
audioTrack.registerStreamEventCallback(handler::post, this);
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user