package com.tencent.mm.plugin.shake.d.a;

import com.tencent.matrix.trace.core.AppMethodBeat;
import com.tencent.mm.audio.b.c.a;
import com.tencent.mm.compatible.util.g;
import com.tencent.mm.sdk.platformtools.ab;
import com.tencent.mm.sdk.platformtools.bo;
import com.tencent.qafpapi.QAFPNative;
import com.tencent.ttpic.cache.VideoMemoryManager;

class a$1 implements a {
    final /* synthetic */ a qtD;

    a$1(a aVar) {
        this.qtD = aVar;
    }

    public final void u(byte[] bArr, int i) {
        int QAFPProcessTV;
        AppMethodBeat.i(24589);
        g.a aVar = new g.a();
        synchronized (this.qtD.kbe) {
            try {
                if (this.qtD.qtr == 408) {
                    ab.v("MicroMsg.MusicFingerPrintRecorder", "shake tv branch, QAFPProcessTV");
                    QAFPProcessTV = QAFPNative.QAFPProcessTV(bArr, i);
                } else {
                    QAFPProcessTV = QAFPNative.QAFPProcess(bArr, i);
                }
            } catch (Throwable th) {
                AppMethodBeat.o(24589);
            }
        }
        long anU = bo.anU() - this.qtD.qtA;
        ab.d("MicroMsg.MusicFingerPrintRecorder", "QAFPProcess clientid:%d pcm:%d ret:%d dur:%d usetime:%d", new Object[]{Integer.valueOf(this.qtD.qtx), Integer.valueOf(i), Integer.valueOf(QAFPProcessTV), Long.valueOf(anU), Long.valueOf(aVar.Mr())});
        if (anU > ((long) ((this.qtD.qtB * 3000) + 4000))) {
            byte[] bArr2 = new byte[VideoMemoryManager.VIDEO_CACHE_MEM_CACHE_REMAIN_SIZE];
            g.a aVar2 = new g.a();
            if (this.qtD.qtr == 408) {
                ab.v("MicroMsg.MusicFingerPrintRecorder", "shake tv branch, QAFPGetAudioFingerPrintTV");
                QAFPProcessTV = QAFPNative.QAFPGetAudioFingerPrintTV(bArr2);
            } else {
                QAFPProcessTV = QAFPNative.QAFPGetAudioFingerPrint(bArr2);
            }
            ab.d("MicroMsg.MusicFingerPrintRecorder", "QAFPGetAudioFingerPrint clientid:%d outLen:%d time:%d", new Object[]{Integer.valueOf(this.qtD.qtx), Integer.valueOf(QAFPProcessTV), Long.valueOf(aVar2.Mr())});
            if (QAFPProcessTV >= VideoMemoryManager.VIDEO_CACHE_MEM_CACHE_REMAIN_SIZE || QAFPProcessTV <= 0) {
                ab.e("MicroMsg.MusicFingerPrintRecorder", "QAFPGetAudioFingerPrint clientid:%d  out ret:%d  !stop record now", new Object[]{Integer.valueOf(this.qtD.qtx), Integer.valueOf(QAFPProcessTV)});
                this.qtD.reset();
                AppMethodBeat.o(24589);
                return;
            }
            synchronized (this.qtD.qtn) {
                try {
                    boolean z;
                    System.arraycopy(bArr2, 0, this.qtD.qtn, 0, QAFPProcessTV);
                    this.qtD.qto = QAFPProcessTV;
                    a aVar3 = this.qtD;
                    if (this.qtD.qtB >= 3) {
                        z = true;
                    } else {
                        z = false;
                    }
                    aVar3.qtw = z;
                    this.qtD.qtp = (int) (anU / 1000);
                } catch (Throwable th2) {
                    while (true) {
                        AppMethodBeat.o(24589);
                    }
                }
            }
            this.qtD.agK();
            a aVar4 = this.qtD;
            aVar4.qtB++;
        }
        if (this.qtD.qtw) {
            ab.w("MicroMsg.MusicFingerPrintRecorder", "client:%d stop now! duration:%d  ", new Object[]{Integer.valueOf(this.qtD.qtx), Long.valueOf(anU)});
            this.qtD.reset();
        }
        AppMethodBeat.o(24589);
    }

    public final void bN(int i, int i2) {
    }
}
