package com.google.android.gms.internal.ads; import android.os.Handler; import android.os.HandlerThread; import android.os.Message; import android.view.Choreographer; import com.mbridge.msdk.playercommon.exoplayer2.C; /* loaded from: classes3.dex */ final class zzaao implements Choreographer.FrameCallback, Handler.Callback { private static final zzaao zzb = new zzaao(); public volatile long zza = C.TIME_UNSET; private final Handler zzc; private final HandlerThread zzd; private Choreographer zze; private int zzf; private zzaao() { HandlerThread handlerThread = new HandlerThread("ExoPlayer:FrameReleaseChoreographer"); this.zzd = handlerThread; handlerThread.start(); Handler handler = new Handler(handlerThread.getLooper(), this); this.zzc = handler; handler.sendEmptyMessage(1); } public static zzaao zza() { return zzb; } @Override // android.os.Handler.Callback public final boolean handleMessage(Message message) { int i = message.what; if (i == 1) { try { this.zze = Choreographer.getInstance(); } catch (RuntimeException e) { zzdo.zzg("VideoFrameReleaseHelper", "Vsync sampling disabled due to platform error", e); } return true; } if (i == 2) { Choreographer choreographer = this.zze; if (choreographer != null) { int i2 = this.zzf + 1; this.zzf = i2; if (i2 == 1) { choreographer.postFrameCallback(this); } } return true; } if (i != 3) { return false; } Choreographer choreographer2 = this.zze; if (choreographer2 != null) { int i3 = this.zzf - 1; this.zzf = i3; if (i3 == 0) { choreographer2.removeFrameCallback(this); this.zza = C.TIME_UNSET; } } return true; } public final void zzb() { this.zzc.sendEmptyMessage(2); } public final void zzc() { this.zzc.sendEmptyMessage(3); } @Override // android.view.Choreographer.FrameCallback public final void doFrame(long j) { this.zza = j; Choreographer choreographer = this.zze; choreographer.getClass(); choreographer.postFrameCallbackDelayed(this, 500L); } }