.class public final Lz5/fe;
.super Landroid/os/HandlerThread;
.source ""

# interfaces
.implements Landroid/graphics/SurfaceTexture$OnFrameAvailableListener;
.implements Landroid/os/Handler$Callback;


# instance fields
.field public final r:[I

.field public s:Landroid/os/Handler;

.field public t:Landroid/graphics/SurfaceTexture;

.field public u:Ljava/lang/Error;

.field public v:Ljava/lang/RuntimeException;

.field public w:Lz5/ge;


# direct methods
.method public constructor <init>()V
    .registers 2

    const-string v0, "dummySurface"

    invoke-direct {p0, v0}, Landroid/os/HandlerThread;-><init>(Ljava/lang/String;)V

    const/4 v0, 0x1

    new-array v0, v0, [I

    iput-object v0, p0, Lz5/fe;->r:[I

    return-void
.end method


# virtual methods
.method public final handleMessage(Landroid/os/Message;)Z
    .registers 24

    move-object/from16 v1, p0

    move-object/from16 v0, p1

    iget v2, v0, Landroid/os/Message;->what:I

    const/4 v3, 0x3

    const/4 v4, 0x2

    const/4 v5, 0x0

    const/4 v6, 0x1

    if-eq v2, v6, :cond_44

    if-eq v2, v4, :cond_3e

    if-eq v2, v3, :cond_11

    return v6

    :cond_11
    const/4 v2, 0x0

    :try_start_12
    iget-object v0, v1, Lz5/fe;->t:Landroid/graphics/SurfaceTexture;

    invoke-virtual {v0}, Landroid/graphics/SurfaceTexture;->release()V
    :try_end_17
    .catchall {:try_start_12 .. :try_end_17} :catchall_24

    :try_start_17
    iput-object v2, v1, Lz5/fe;->w:Lz5/ge;

    iput-object v2, v1, Lz5/fe;->t:Landroid/graphics/SurfaceTexture;

    iget-object v0, v1, Lz5/fe;->r:[I

    invoke-static {v6, v0, v5}, Landroid/opengl/GLES20;->glDeleteTextures(I[II)V
    :try_end_20
    .catchall {:try_start_17 .. :try_end_20} :catchall_2f

    :goto_20
    invoke-virtual/range {p0 .. p0}, Landroid/os/HandlerThread;->quit()Z

    goto :goto_38

    :catchall_24
    move-exception v0

    :try_start_25
    iput-object v2, v1, Lz5/fe;->w:Lz5/ge;

    iput-object v2, v1, Lz5/fe;->t:Landroid/graphics/SurfaceTexture;

    iget-object v2, v1, Lz5/fe;->r:[I

    invoke-static {v6, v2, v5}, Landroid/opengl/GLES20;->glDeleteTextures(I[II)V

    throw v0
    :try_end_2f
    .catchall {:try_start_25 .. :try_end_2f} :catchall_2f

    :catchall_2f
    move-exception v0

    :try_start_30
    const-string v2, "DummySurface"

    const-string v3, "Failed to release dummy surface"

    invoke-static {v2, v3, v0}, Landroid/util/Log;->e(Ljava/lang/String;Ljava/lang/String;Ljava/lang/Throwable;)I
    :try_end_37
    .catchall {:try_start_30 .. :try_end_37} :catchall_39

    goto :goto_20

    :goto_38
    return v6

    :catchall_39
    move-exception v0

    invoke-virtual/range {p0 .. p0}, Landroid/os/HandlerThread;->quit()Z

    throw v0

    :cond_3e
    iget-object v0, v1, Lz5/fe;->t:Landroid/graphics/SurfaceTexture;

    invoke-virtual {v0}, Landroid/graphics/SurfaceTexture;->updateTexImage()V

    return v6

    :cond_44
    :try_start_44
    iget v0, v0, Landroid/os/Message;->arg1:I

    if-eqz v0, :cond_4a

    move v0, v6

    goto :goto_4b

    :cond_4a
    move v0, v5

    :goto_4b
    invoke-static {v5}, Landroid/opengl/EGL14;->eglGetDisplay(I)Landroid/opengl/EGLDisplay;

    move-result-object v2

    if-eqz v2, :cond_53

    move v7, v6

    goto :goto_54

    :cond_53
    move v7, v5

    :goto_54
    const-string v8, "eglGetDisplay failed"

    invoke-static {v7, v8}, Lcom/google/android/gms/internal/ads/r;->s(ZLjava/lang/Object;)V

    new-array v7, v4, [I

    invoke-static {v2, v7, v5, v7, v6}, Landroid/opengl/EGL14;->eglInitialize(Landroid/opengl/EGLDisplay;[II[II)Z

    move-result v7

    const-string v8, "eglInitialize failed"

    invoke-static {v7, v8}, Lcom/google/android/gms/internal/ads/r;->s(ZLjava/lang/Object;)V

    const/16 v7, 0x11

    new-array v8, v7, [I

    const/16 v7, 0x3040

    aput v7, v8, v5

    const/4 v15, 0x4

    aput v15, v8, v6

    const/16 v7, 0x3024

    aput v7, v8, v4

    const/16 v7, 0x8

    aput v7, v8, v3

    const/16 v9, 0x3023

    aput v9, v8, v15

    const/4 v14, 0x5

    aput v7, v8, v14

    const/16 v9, 0x3022

    const/16 v16, 0x6

    aput v9, v8, v16

    const/4 v13, 0x7

    aput v7, v8, v13

    const/16 v9, 0x3021

    aput v9, v8, v7

    const/16 v9, 0x9

    aput v7, v8, v9

    const/16 v7, 0xa

    const/16 v9, 0x3025

    aput v9, v8, v7

    const/16 v7, 0xb

    aput v5, v8, v7

    const/16 v7, 0xc

    const/16 v9, 0x3027

    aput v9, v8, v7

    const/16 v7, 0xd

    const/16 v17, 0x3038

    aput v17, v8, v7

    const/16 v7, 0xe

    const/16 v9, 0x3033

    aput v9, v8, v7

    const/16 v7, 0xf

    aput v15, v8, v7

    const/16 v7, 0x10

    aput v17, v8, v7

    new-array v12, v6, [Landroid/opengl/EGLConfig;

    new-array v11, v6, [I

    const/4 v9, 0x0

    const/16 v18, 0x0

    const/16 v19, 0x1

    const/16 v20, 0x0

    move-object v7, v2

    move-object v10, v12

    move-object/from16 v21, v11

    move/from16 v11, v18

    move-object/from16 v18, v12

    move/from16 v12, v19

    move-object/from16 v13, v21

    move v15, v14

    move/from16 v14, v20

    invoke-static/range {v7 .. v14}, Landroid/opengl/EGL14;->eglChooseConfig(Landroid/opengl/EGLDisplay;[II[Landroid/opengl/EGLConfig;II[II)Z

    move-result v7

    if-eqz v7, :cond_dd

    aget v7, v21, v5

    if-lez v7, :cond_dd

    aget-object v7, v18, v5

    if-eqz v7, :cond_dd

    move v7, v6

    goto :goto_de

    :cond_dd
    move v7, v5

    :goto_de
    const-string v8, "eglChooseConfig failed"

    invoke-static {v7, v8}, Lcom/google/android/gms/internal/ads/r;->s(ZLjava/lang/Object;)V

    aget-object v7, v18, v5

    const/16 v8, 0x32c0

    const/16 v9, 0x3098

    if-eqz v0, :cond_f9

    new-array v10, v15, [I

    aput v9, v10, v5

    aput v4, v10, v6

    aput v8, v10, v4

    aput v6, v10, v3

    const/4 v9, 0x4

    aput v17, v10, v9

    goto :goto_101

    :cond_f9
    new-array v10, v3, [I

    aput v9, v10, v5

    aput v4, v10, v6

    aput v17, v10, v4

    :goto_101
    sget-object v9, Landroid/opengl/EGL14;->EGL_NO_CONTEXT:Landroid/opengl/EGLContext;

    invoke-static {v2, v7, v9, v10, v5}, Landroid/opengl/EGL14;->eglCreateContext(Landroid/opengl/EGLDisplay;Landroid/opengl/EGLConfig;Landroid/opengl/EGLContext;[II)Landroid/opengl/EGLContext;

    move-result-object v9

    if-eqz v9, :cond_10b

    move v10, v6

    goto :goto_10c

    :cond_10b
    move v10, v5

    :goto_10c
    const-string v11, "eglCreateContext failed"

    invoke-static {v10, v11}, Lcom/google/android/gms/internal/ads/r;->s(ZLjava/lang/Object;)V

    const/16 v10, 0x3056

    const/16 v11, 0x3057

    if-eqz v0, :cond_12a

    const/4 v0, 0x7

    new-array v0, v0, [I

    aput v11, v0, v5

    aput v6, v0, v6

    aput v10, v0, v4

    aput v6, v0, v3

    const/4 v3, 0x4

    aput v8, v0, v3

    aput v6, v0, v15

    aput v17, v0, v16

    goto :goto_137

    :cond_12a
    new-array v0, v15, [I

    aput v11, v0, v5

    aput v6, v0, v6

    aput v10, v0, v4

    aput v6, v0, v3

    const/4 v3, 0x4

    aput v17, v0, v3

    :goto_137
    invoke-static {v2, v7, v0, v5}, Landroid/opengl/EGL14;->eglCreatePbufferSurface(Landroid/opengl/EGLDisplay;Landroid/opengl/EGLConfig;[II)Landroid/opengl/EGLSurface;

    move-result-object v0

    if-eqz v0, :cond_13f

    move v3, v6

    goto :goto_140

    :cond_13f
    move v3, v5

    :goto_140
    const-string v4, "eglCreatePbufferSurface failed"

    invoke-static {v3, v4}, Lcom/google/android/gms/internal/ads/r;->s(ZLjava/lang/Object;)V

    invoke-static {v2, v0, v0, v9}, Landroid/opengl/EGL14;->eglMakeCurrent(Landroid/opengl/EGLDisplay;Landroid/opengl/EGLSurface;Landroid/opengl/EGLSurface;Landroid/opengl/EGLContext;)Z

    move-result v0

    const-string v2, "eglMakeCurrent failed"

    invoke-static {v0, v2}, Lcom/google/android/gms/internal/ads/r;->s(ZLjava/lang/Object;)V

    iget-object v0, v1, Lz5/fe;->r:[I

    invoke-static {v6, v0, v5}, Landroid/opengl/GLES20;->glGenTextures(I[II)V

    new-instance v0, Landroid/graphics/SurfaceTexture;

    iget-object v2, v1, Lz5/fe;->r:[I

    aget v2, v2, v5

    invoke-direct {v0, v2}, Landroid/graphics/SurfaceTexture;-><init>(I)V

    iput-object v0, v1, Lz5/fe;->t:Landroid/graphics/SurfaceTexture;

    invoke-virtual {v0, v1}, Landroid/graphics/SurfaceTexture;->setOnFrameAvailableListener(Landroid/graphics/SurfaceTexture$OnFrameAvailableListener;)V

    new-instance v0, Lz5/ge;

    iget-object v2, v1, Lz5/fe;->t:Landroid/graphics/SurfaceTexture;

    invoke-direct {v0, v1, v2}, Lz5/ge;-><init>(Lz5/fe;Landroid/graphics/SurfaceTexture;)V

    iput-object v0, v1, Lz5/fe;->w:Lz5/ge;
    :try_end_16a
    .catch Ljava/lang/RuntimeException; {:try_start_44 .. :try_end_16a} :catch_188
    .catch Ljava/lang/Error; {:try_start_44 .. :try_end_16a} :catch_175
    .catchall {:try_start_44 .. :try_end_16a} :catchall_173

    monitor-enter p0

    :try_start_16b
    invoke-virtual/range {p0 .. p0}, Ljava/lang/Object;->notify()V

    monitor-exit p0

    goto :goto_197

    :catchall_170
    move-exception v0

    monitor-exit p0
    :try_end_172
    .catchall {:try_start_16b .. :try_end_172} :catchall_170

    throw v0

    :catchall_173
    move-exception v0

    goto :goto_19b

    :catch_175
    move-exception v0

    :try_start_176
    const-string v2, "DummySurface"

    const-string v3, "Failed to initialize dummy surface"

    invoke-static {v2, v3, v0}, Landroid/util/Log;->e(Ljava/lang/String;Ljava/lang/String;Ljava/lang/Throwable;)I

    iput-object v0, v1, Lz5/fe;->u:Ljava/lang/Error;
    :try_end_17f
    .catchall {:try_start_176 .. :try_end_17f} :catchall_173

    monitor-enter p0

    :try_start_180
    invoke-virtual/range {p0 .. p0}, Ljava/lang/Object;->notify()V

    monitor-exit p0

    goto :goto_197

    :catchall_185
    move-exception v0

    monitor-exit p0
    :try_end_187
    .catchall {:try_start_180 .. :try_end_187} :catchall_185

    throw v0

    :catch_188
    move-exception v0

    :try_start_189
    const-string v2, "DummySurface"

    const-string v3, "Failed to initialize dummy surface"

    invoke-static {v2, v3, v0}, Landroid/util/Log;->e(Ljava/lang/String;Ljava/lang/String;Ljava/lang/Throwable;)I

    iput-object v0, v1, Lz5/fe;->v:Ljava/lang/RuntimeException;
    :try_end_192
    .catchall {:try_start_189 .. :try_end_192} :catchall_173

    monitor-enter p0

    :try_start_193
    invoke-virtual/range {p0 .. p0}, Ljava/lang/Object;->notify()V

    monitor-exit p0

    :goto_197
    return v6

    :catchall_198
    move-exception v0

    monitor-exit p0
    :try_end_19a
    .catchall {:try_start_193 .. :try_end_19a} :catchall_198

    throw v0

    :goto_19b
    monitor-enter p0

    :try_start_19c
    invoke-virtual/range {p0 .. p0}, Ljava/lang/Object;->notify()V

    monitor-exit p0
    :try_end_1a0
    .catchall {:try_start_19c .. :try_end_1a0} :catchall_1a1

    throw v0

    :catchall_1a1
    move-exception v0

    :try_start_1a2
    monitor-exit p0
    :try_end_1a3
    .catchall {:try_start_1a2 .. :try_end_1a3} :catchall_1a1

    throw v0
.end method

.method public final onFrameAvailable(Landroid/graphics/SurfaceTexture;)V
    .registers 3

    iget-object p1, p0, Lz5/fe;->s:Landroid/os/Handler;

    const/4 v0, 0x2

    invoke-virtual {p1, v0}, Landroid/os/Handler;->sendEmptyMessage(I)Z

    return-void
.end method
