SpeechEvaluatorImpl.smali

.class public Lcom/iflytek/cloud/speech/impl/SpeechEvaluatorImpl;
.super Lcom/iflytek/thirdparty/w;
.source "SourceFile"


# annotations
.annotation system Ldalvik/annotation/MemberClasses;
    value = {
        Lcom/iflytek/cloud/speech/impl/SpeechEvaluatorImpl$InternalEvaluatorListener;
    }
.end annotation


# instance fields
.field private mRequestFocus:Z


# direct methods
.method public constructor <init>(Landroid/content/Context;)V
    .registers 3

    .prologue
    .line 35
    invoke-direct {p0, p1}, Lcom/iflytek/thirdparty/w;-><init>(Landroid/content/Context;)V

    .line 32
    const/4 v0, 0x0

    iput-boolean v0, p0, Lcom/iflytek/cloud/speech/impl/SpeechEvaluatorImpl;->mRequestFocus:Z

    .line 36
    return-void
.end method


# virtual methods
.method public cancel(Z)V
    .registers 4

    .prologue
    .line 146
    iget-object v1, p0, Lcom/iflytek/cloud/speech/impl/SpeechEvaluatorImpl;->mSynObj:Ljava/lang/Object;

    monitor-enter v1

    .line 147
    :try_start_3
    invoke-virtual {p0}, Lcom/iflytek/cloud/speech/impl/SpeechEvaluatorImpl;->sessionEnd()V

    .line 148
    monitor-exit v1
    :try_end_7
    .catchall {:try_start_3 .. :try_end_7} :catchall_b

    .line 150
    invoke-super {p0, p1}, Lcom/iflytek/thirdparty/w;->cancel(Z)V

    .line 151
    return-void

    .line 148
    :catchall_b
    move-exception v0

    :try_start_c
    monitor-exit v1
    :try_end_d
    .catchall {:try_start_c .. :try_end_d} :catchall_b

    throw v0
.end method

.method public getLastBuffer()Ljava/util/concurrent/ConcurrentLinkedQueue;
    .registers 3
    .annotation system Ldalvik/annotation/Signature;
        value = {
            "()",
            "Ljava/util/concurrent/ConcurrentLinkedQueue",
            "<[B>;"
        }
    .end annotation

    .prologue
    .line 157
    iget-object v1, p0, Lcom/iflytek/cloud/speech/impl/SpeechEvaluatorImpl;->mSynObj:Ljava/lang/Object;

    monitor-enter v1

    .line 158
    :try_start_3
    iget-object v0, p0, Lcom/iflytek/cloud/speech/impl/SpeechEvaluatorImpl;->mscer:Lcom/iflytek/thirdparty/s;

    if-eqz v0, :cond_11

    .line 159
    iget-object v0, p0, Lcom/iflytek/cloud/speech/impl/SpeechEvaluatorImpl;->mscer:Lcom/iflytek/thirdparty/s;

    check-cast v0, Lcom/iflytek/thirdparty/b;

    invoke-virtual {v0}, Lcom/iflytek/thirdparty/b;->c()Ljava/util/concurrent/ConcurrentLinkedQueue;

    move-result-object v0

    monitor-exit v1

    .line 161
    :goto_10
    return-object v0

    :cond_11
    const/4 v0, 0x0

    monitor-exit v1

    goto :goto_10

    .line 163
    :catchall_14
    move-exception v0

    monitor-exit v1
    :try_end_16
    .catchall {:try_start_3 .. :try_end_16} :catchall_14

    throw v0
.end method

.method public isEvaluating()Z
    .registers 2

    .prologue
    .line 299
    invoke-virtual {p0}, Lcom/iflytek/cloud/speech/impl/SpeechEvaluatorImpl;->isRunning()Z

    move-result v0

    return v0
.end method

.method protected onFini()Z
    .registers 2

    .prologue
    .line 168
    invoke-super {p0}, Lcom/iflytek/thirdparty/w;->onFini()Z

    move-result v0

    return v0
.end method

.method protected sessionEnd()V
    .registers 7

    .prologue
    const/4 v5, 0x0

    .line 172
    iget-object v0, p0, Lcom/iflytek/cloud/speech/impl/SpeechEvaluatorImpl;->mscer:Lcom/iflytek/thirdparty/s;

    if-eqz v0, :cond_44

    .line 173
    iget-object v0, p0, Lcom/iflytek/cloud/speech/impl/SpeechEvaluatorImpl;->mscer:Lcom/iflytek/thirdparty/s;

    invoke-virtual {v0}, Lcom/iflytek/thirdparty/s;->getParam()Lcom/iflytek/thirdparty/ad;

    move-result-object v0

    const-string v1, "ise_audio_path"

    invoke-virtual {v0, v1}, Lcom/iflytek/thirdparty/ad;->e(Ljava/lang/String;)Ljava/lang/String;

    move-result-object v1

    .line 175
    invoke-static {v1}, Landroid/text/TextUtils;->isEmpty(Ljava/lang/CharSequence;)Z

    move-result v0

    if-nez v0, :cond_44

    .line 176
    iget-object v0, p0, Lcom/iflytek/cloud/speech/impl/SpeechEvaluatorImpl;->mscer:Lcom/iflytek/thirdparty/s;

    check-cast v0, Lcom/iflytek/thirdparty/b;

    invoke-virtual {v0}, Lcom/iflytek/thirdparty/b;->c()Ljava/util/concurrent/ConcurrentLinkedQueue;

    move-result-object v0

    invoke-static {v0, v1}, Lcom/iflytek/cloud/msc/util/FileUtil;->saveFile(Ljava/util/concurrent/ConcurrentLinkedQueue;Ljava/lang/String;)Z

    move-result v0

    if-eqz v0, :cond_44

    .line 177
    iget-object v0, p0, Lcom/iflytek/cloud/speech/impl/SpeechEvaluatorImpl;->mscer:Lcom/iflytek/thirdparty/s;

    invoke-virtual {v0}, Lcom/iflytek/thirdparty/s;->getParam()Lcom/iflytek/thirdparty/ad;

    move-result-object v0

    const-string v2, "audio_format"

    invoke-virtual {v0, v2, v5}, Lcom/iflytek/thirdparty/ad;->b(Ljava/lang/String;Ljava/lang/String;)Ljava/lang/String;

    move-result-object v0

    .line 178
    iget-object v2, p0, Lcom/iflytek/cloud/speech/impl/SpeechEvaluatorImpl;->mscer:Lcom/iflytek/thirdparty/s;

    invoke-virtual {v2}, Lcom/iflytek/thirdparty/s;->getParam()Lcom/iflytek/thirdparty/ad;

    move-result-object v2

    const-string v3, "sample_rate"

    iget-object v4, p0, Lcom/iflytek/cloud/speech/impl/SpeechEvaluatorImpl;->mscer:Lcom/iflytek/thirdparty/s;

    iget v4, v4, Lcom/iflytek/thirdparty/s;->mSampleRate:I

    invoke-virtual {v2, v3, v4}, Lcom/iflytek/thirdparty/ad;->a(Ljava/lang/String;I)I

    move-result v2

    .line 179
    invoke-static {v0, v1, v2}, Lcom/iflytek/cloud/msc/util/FileUtil;->formatPcm(Ljava/lang/String;Ljava/lang/String;I)Z

    .line 185
    :cond_44
    iget-object v0, p0, Lcom/iflytek/cloud/speech/impl/SpeechEvaluatorImpl;->mContext:Landroid/content/Context;

    iget-boolean v1, p0, Lcom/iflytek/cloud/speech/impl/SpeechEvaluatorImpl;->mRequestFocus:Z

    invoke-static {v1}, Ljava/lang/Boolean;->valueOf(Z)Ljava/lang/Boolean;

    move-result-object v1

    invoke-static {v0, v1, v5}, Lcom/iflytek/cloud/msc/util/FuncAdapter;->UnLock(Landroid/content/Context;Ljava/lang/Boolean;Landroid/media/AudioManager$OnAudioFocusChangeListener;)Z

    .line 186
    return-void
.end method

.method public startEvaluating(Ljava/lang/String;Ljava/lang/String;Lcom/iflytek/cloud/EvaluatorListener;)I
    .registers 10

    .prologue
    const/4 v1, 0x0

    .line 46
    .line 48
    iget-object v2, p0, Lcom/iflytek/cloud/speech/impl/SpeechEvaluatorImpl;->mSynObj:Ljava/lang/Object;

    monitor-enter v2

    .line 50
    :try_start_4
    iget-object v0, p0, Lcom/iflytek/cloud/speech/impl/SpeechEvaluatorImpl;->mSessionParams:Lcom/iflytek/thirdparty/ad;

    const-string v3, "request_audio_focus"

    const/4 v4, 0x1

    invoke-virtual {v0, v3, v4}, Lcom/iflytek/thirdparty/ad;->a(Ljava/lang/String;Z)Z

    move-result v0

    iput-boolean v0, p0, Lcom/iflytek/cloud/speech/impl/SpeechEvaluatorImpl;->mRequestFocus:Z

    .line 51
    iget-object v0, p0, Lcom/iflytek/cloud/speech/impl/SpeechEvaluatorImpl;->mscer:Lcom/iflytek/thirdparty/s;

    if-eqz v0, :cond_29

    iget-object v0, p0, Lcom/iflytek/cloud/speech/impl/SpeechEvaluatorImpl;->mscer:Lcom/iflytek/thirdparty/s;

    invoke-virtual {v0}, Lcom/iflytek/thirdparty/s;->isRunning()Z

    move-result v0

    if-eqz v0, :cond_29

    .line 52
    iget-object v0, p0, Lcom/iflytek/cloud/speech/impl/SpeechEvaluatorImpl;->mscer:Lcom/iflytek/thirdparty/s;

    iget-object v3, p0, Lcom/iflytek/cloud/speech/impl/SpeechEvaluatorImpl;->mSessionParams:Lcom/iflytek/thirdparty/ad;

    const-string v4, "ise_interrupt_error"

    const/4 v5, 0x0

    invoke-virtual {v3, v4, v5}, Lcom/iflytek/thirdparty/ad;->a(Ljava/lang/String;Z)Z

    move-result v3

    invoke-virtual {v0, v3}, Lcom/iflytek/thirdparty/s;->cancel(Z)V

    .line 55
    :cond_29
    new-instance v0, Lcom/iflytek/thirdparty/b;

    iget-object v3, p0, Lcom/iflytek/cloud/speech/impl/SpeechEvaluatorImpl;->mContext:Landroid/content/Context;

    iget-object v4, p0, Lcom/iflytek/cloud/speech/impl/SpeechEvaluatorImpl;->mSessionParams:Lcom/iflytek/thirdparty/ad;

    const-string v5, "eva"

    invoke-virtual {p0, v5}, Lcom/iflytek/cloud/speech/impl/SpeechEvaluatorImpl;->getHandlerThread(Ljava/lang/String;)Landroid/os/HandlerThread;

    move-result-object v5

    invoke-direct {v0, v3, v4, v5}, Lcom/iflytek/thirdparty/b;-><init>(Landroid/content/Context;Lcom/iflytek/thirdparty/ad;Landroid/os/HandlerThread;)V

    iput-object v0, p0, Lcom/iflytek/cloud/speech/impl/SpeechEvaluatorImpl;->mscer:Lcom/iflytek/thirdparty/s;

    .line 57
    iget-object v0, p0, Lcom/iflytek/cloud/speech/impl/SpeechEvaluatorImpl;->mContext:Landroid/content/Context;

    iget-boolean v3, p0, Lcom/iflytek/cloud/speech/impl/SpeechEvaluatorImpl;->mRequestFocus:Z

    invoke-static {v3}, Ljava/lang/Boolean;->valueOf(Z)Ljava/lang/Boolean;

    move-result-object v3

    const/4 v4, 0x0

    invoke-static {v0, v3, v4}, Lcom/iflytek/cloud/msc/util/FuncAdapter;->Lock(Landroid/content/Context;Ljava/lang/Boolean;Landroid/media/AudioManager$OnAudioFocusChangeListener;)Z

    .line 58
    iget-object v0, p0, Lcom/iflytek/cloud/speech/impl/SpeechEvaluatorImpl;->mscer:Lcom/iflytek/thirdparty/s;

    check-cast v0, Lcom/iflytek/thirdparty/b;

    new-instance v3, Lcom/iflytek/cloud/speech/impl/SpeechEvaluatorImpl$InternalEvaluatorListener;

    invoke-direct {v3, p0, p3}, Lcom/iflytek/cloud/speech/impl/SpeechEvaluatorImpl$InternalEvaluatorListener;-><init>(Lcom/iflytek/cloud/speech/impl/SpeechEvaluatorImpl;Lcom/iflytek/cloud/EvaluatorListener;)V

    invoke-virtual {v0, p1, p2, v3}, Lcom/iflytek/thirdparty/b;->a(Ljava/lang/String;Ljava/lang/String;Lcom/iflytek/cloud/EvaluatorListener;)V
    :try_end_52
    .catch Lcom/iflytek/cloud/SpeechError; {:try_start_4 .. :try_end_52} :catch_55
    .catch Ljava/lang/Throwable; {:try_start_4 .. :try_end_52} :catch_5f
    .catchall {:try_start_4 .. :try_end_52} :catchall_67

    move v0, v1

    .line 67
    :goto_53
    :try_start_53
    monitor-exit v2

    .line 69
    return v0

    .line 60
    :catch_55
    move-exception v0

    .line 61
    invoke-virtual {v0}, Lcom/iflytek/cloud/SpeechError;->getErrorCode()I

    move-result v1

    .line 62
    invoke-static {v0}, Lcom/iflytek/cloud/msc/util/log/DebugLog;->LogE(Ljava/lang/Throwable;)V

    move v0, v1

    .line 66
    goto :goto_53

    .line 63
    :catch_5f
    move-exception v0

    .line 64
    const/16 v1, 0x5207

    .line 65
    invoke-static {v0}, Lcom/iflytek/cloud/msc/util/log/DebugLog;->LogE(Ljava/lang/Throwable;)V

    move v0, v1

    goto :goto_53

    .line 67
    :catchall_67
    move-exception v0

    monitor-exit v2
    :try_end_69
    .catchall {:try_start_53 .. :try_end_69} :catchall_67

    throw v0
.end method

.method public startEvaluating([BLjava/lang/String;Lcom/iflytek/cloud/EvaluatorListener;)I
    .registers 10

    .prologue
    const/4 v1, 0x0

    .line 80
    .line 82
    iget-object v2, p0, Lcom/iflytek/cloud/speech/impl/SpeechEvaluatorImpl;->mSynObj:Ljava/lang/Object;

    monitor-enter v2

    .line 84
    :try_start_4
    iget-object v0, p0, Lcom/iflytek/cloud/speech/impl/SpeechEvaluatorImpl;->mSessionParams:Lcom/iflytek/thirdparty/ad;

    const-string v3, "request_audio_focus"

    const/4 v4, 0x1

    invoke-virtual {v0, v3, v4}, Lcom/iflytek/thirdparty/ad;->a(Ljava/lang/String;Z)Z

    move-result v0

    iput-boolean v0, p0, Lcom/iflytek/cloud/speech/impl/SpeechEvaluatorImpl;->mRequestFocus:Z

    .line 85
    iget-object v0, p0, Lcom/iflytek/cloud/speech/impl/SpeechEvaluatorImpl;->mscer:Lcom/iflytek/thirdparty/s;

    if-eqz v0, :cond_29

    iget-object v0, p0, Lcom/iflytek/cloud/speech/impl/SpeechEvaluatorImpl;->mscer:Lcom/iflytek/thirdparty/s;

    invoke-virtual {v0}, Lcom/iflytek/thirdparty/s;->isRunning()Z

    move-result v0

    if-eqz v0, :cond_29

    .line 86
    iget-object v0, p0, Lcom/iflytek/cloud/speech/impl/SpeechEvaluatorImpl;->mscer:Lcom/iflytek/thirdparty/s;

    iget-object v3, p0, Lcom/iflytek/cloud/speech/impl/SpeechEvaluatorImpl;->mSessionParams:Lcom/iflytek/thirdparty/ad;

    const-string v4, "ise_interrupt_error"

    const/4 v5, 0x0

    invoke-virtual {v3, v4, v5}, Lcom/iflytek/thirdparty/ad;->a(Ljava/lang/String;Z)Z

    move-result v3

    invoke-virtual {v0, v3}, Lcom/iflytek/thirdparty/s;->cancel(Z)V

    .line 89
    :cond_29
    new-instance v0, Lcom/iflytek/thirdparty/b;

    iget-object v3, p0, Lcom/iflytek/cloud/speech/impl/SpeechEvaluatorImpl;->mContext:Landroid/content/Context;

    iget-object v4, p0, Lcom/iflytek/cloud/speech/impl/SpeechEvaluatorImpl;->mSessionParams:Lcom/iflytek/thirdparty/ad;

    const-string v5, "eva"

    invoke-virtual {p0, v5}, Lcom/iflytek/cloud/speech/impl/SpeechEvaluatorImpl;->getHandlerThread(Ljava/lang/String;)Landroid/os/HandlerThread;

    move-result-object v5

    invoke-direct {v0, v3, v4, v5}, Lcom/iflytek/thirdparty/b;-><init>(Landroid/content/Context;Lcom/iflytek/thirdparty/ad;Landroid/os/HandlerThread;)V

    iput-object v0, p0, Lcom/iflytek/cloud/speech/impl/SpeechEvaluatorImpl;->mscer:Lcom/iflytek/thirdparty/s;

    .line 91
    iget-object v0, p0, Lcom/iflytek/cloud/speech/impl/SpeechEvaluatorImpl;->mContext:Landroid/content/Context;

    iget-boolean v3, p0, Lcom/iflytek/cloud/speech/impl/SpeechEvaluatorImpl;->mRequestFocus:Z

    invoke-static {v3}, Ljava/lang/Boolean;->valueOf(Z)Ljava/lang/Boolean;

    move-result-object v3

    const/4 v4, 0x0

    invoke-static {v0, v3, v4}, Lcom/iflytek/cloud/msc/util/FuncAdapter;->Lock(Landroid/content/Context;Ljava/lang/Boolean;Landroid/media/AudioManager$OnAudioFocusChangeListener;)Z

    .line 92
    iget-object v0, p0, Lcom/iflytek/cloud/speech/impl/SpeechEvaluatorImpl;->mscer:Lcom/iflytek/thirdparty/s;

    check-cast v0, Lcom/iflytek/thirdparty/b;

    new-instance v3, Lcom/iflytek/cloud/speech/impl/SpeechEvaluatorImpl$InternalEvaluatorListener;

    invoke-direct {v3, p0, p3}, Lcom/iflytek/cloud/speech/impl/SpeechEvaluatorImpl$InternalEvaluatorListener;-><init>(Lcom/iflytek/cloud/speech/impl/SpeechEvaluatorImpl;Lcom/iflytek/cloud/EvaluatorListener;)V

    invoke-virtual {v0, p1, p2, v3}, Lcom/iflytek/thirdparty/b;->a([BLjava/lang/String;Lcom/iflytek/cloud/EvaluatorListener;)V
    :try_end_52
    .catch Lcom/iflytek/cloud/SpeechError; {:try_start_4 .. :try_end_52} :catch_55
    .catch Ljava/lang/Throwable; {:try_start_4 .. :try_end_52} :catch_5f
    .catchall {:try_start_4 .. :try_end_52} :catchall_67

    move v0, v1

    .line 101
    :goto_53
    :try_start_53
    monitor-exit v2

    .line 103
    return v0

    .line 94
    :catch_55
    move-exception v0

    .line 95
    invoke-virtual {v0}, Lcom/iflytek/cloud/SpeechError;->getErrorCode()I

    move-result v1

    .line 96
    invoke-static {v0}, Lcom/iflytek/cloud/msc/util/log/DebugLog;->LogE(Ljava/lang/Throwable;)V

    move v0, v1

    .line 100
    goto :goto_53

    .line 97
    :catch_5f
    move-exception v0

    .line 98
    const/16 v1, 0x5207

    .line 99
    invoke-static {v0}, Lcom/iflytek/cloud/msc/util/log/DebugLog;->LogE(Ljava/lang/Throwable;)V

    move v0, v1

    goto :goto_53

    .line 101
    :catchall_67
    move-exception v0

    monitor-exit v2
    :try_end_69
    .catchall {:try_start_53 .. :try_end_69} :catchall_67

    throw v0
.end method

.method public stopEvaluating()V
    .registers 4

    .prologue
    .line 134
    iget-object v1, p0, Lcom/iflytek/cloud/speech/impl/SpeechEvaluatorImpl;->mSynObj:Ljava/lang/Object;

    monitor-enter v1

    .line 135
    :try_start_3
    iget-object v0, p0, Lcom/iflytek/cloud/speech/impl/SpeechEvaluatorImpl;->mscer:Lcom/iflytek/thirdparty/s;

    if-eqz v0, :cond_f

    .line 136
    iget-object v0, p0, Lcom/iflytek/cloud/speech/impl/SpeechEvaluatorImpl;->mscer:Lcom/iflytek/thirdparty/s;

    check-cast v0, Lcom/iflytek/thirdparty/b;

    const/4 v2, 0x1

    invoke-virtual {v0, v2}, Lcom/iflytek/thirdparty/b;->a(Z)Z

    .line 138
    :cond_f
    monitor-exit v1

    .line 139
    return-void

    .line 138
    :catchall_11
    move-exception v0

    monitor-exit v1
    :try_end_13
    .catchall {:try_start_3 .. :try_end_13} :catchall_11

    throw v0
.end method

.method public writeAudio([BII)Z
    .registers 8

    .prologue
    const/4 v0, 0x0

    .line 112
    iget-object v1, p0, Lcom/iflytek/cloud/speech/impl/SpeechEvaluatorImpl;->mSynObj:Ljava/lang/Object;

    monitor-enter v1

    .line 113
    :try_start_4
    iget-object v2, p0, Lcom/iflytek/cloud/speech/impl/SpeechEvaluatorImpl;->mscer:Lcom/iflytek/thirdparty/s;

    if-nez v2, :cond_f

    .line 114
    const-string v2, "writeAudio error, no active session."

    invoke-static {v2}, Lcom/iflytek/cloud/msc/util/log/DebugLog;->LogD(Ljava/lang/String;)V

    .line 115
    monitor-exit v1

    .line 126
    :goto_e
    return v0

    .line 117
    :cond_f
    if-eqz p1, :cond_14

    array-length v2, p1

    if-gtz v2, :cond_1e

    .line 118
    :cond_14
    const-string v2, "writeAudio error,buffer is null."

    invoke-static {v2}, Lcom/iflytek/cloud/msc/util/log/DebugLog;->LogD(Ljava/lang/String;)V

    .line 119
    monitor-exit v1

    goto :goto_e

    .line 127
    :catchall_1b
    move-exception v0

    monitor-exit v1
    :try_end_1d
    .catchall {:try_start_4 .. :try_end_1d} :catchall_1b

    throw v0

    .line 121
    :cond_1e
    :try_start_1e
    array-length v2, p1

    add-int v3, p3, p2

    if-ge v2, v3, :cond_2a

    .line 122
    const-string v2, "writeAudio error,buffer length < length."

    invoke-static {v2}, Lcom/iflytek/cloud/msc/util/log/DebugLog;->LogD(Ljava/lang/String;)V

    .line 123
    monitor-exit v1

    goto :goto_e

    .line 125
    :cond_2a
    iget-object v0, p0, Lcom/iflytek/cloud/speech/impl/SpeechEvaluatorImpl;->mscer:Lcom/iflytek/thirdparty/s;

    check-cast v0, Lcom/iflytek/thirdparty/b;

    invoke-virtual {v0, p1, p2, p3}, Lcom/iflytek/thirdparty/b;->onRecordBuffer([BII)V

    .line 126
    const/4 v0, 0x1

    monitor-exit v1
    :try_end_33
    .catchall {:try_start_1e .. :try_end_33} :catchall_1b

    goto :goto_e
.end method