package com.tencent.mm.modelvoiceaddr;

import com.tencent.matrix.trace.core.AppMethodBeat;
import com.tencent.mm.audio.b.c;
import com.tencent.mm.audio.d.d;
import com.tencent.mm.compatible.e.q;
import com.tencent.mm.sdk.platformtools.ab;
import java.io.File;

public class f$a implements Runnable {
    final /* synthetic */ f gbb;

    public f$a(f fVar) {
        this.gbb = fVar;
    }

    public final void run() {
        AppMethodBeat.i(116695);
        synchronized (this.gbb) {
            ab.i("MicroMsg.SceneVoiceAddr", "initDeviceInLock");
            try {
                new File(f.d(this.gbb)).delete();
            } catch (Exception e) {
                ab.e("MicroMsg.SceneVoiceAddr", "delete file failed, " + f.d(this.gbb), new Object[]{e});
            } catch (Throwable th) {
                AppMethodBeat.o(116695);
            }
            this.gbb.coZ = new c(f.c(this.gbb) ? 8000 : 16000, 1, 3);
            this.gbb.coZ.cpB = -19;
            this.gbb.coZ.bq(false);
            if (!f.c(this.gbb)) {
                this.gbb.gaY = new d();
                if (!this.gbb.gaY.eo(f.d(this.gbb))) {
                    ab.e("MicroMsg.SceneVoiceAddr", "init speex writer failed");
                    this.gbb.gaY.Fe();
                    this.gbb.gaY = null;
                }
            }
            if (f.c(this.gbb) || q.etn.erW <= 0) {
                this.gbb.coZ.v(5, false);
            } else {
                this.gbb.coZ.v(q.etn.erW, true);
            }
            this.gbb.coZ.br(false);
            this.gbb.gaZ = new com.tencent.qqpinyin.voicerecoapi.c(f.f(this.gbb));
            int dPU = this.gbb.gaZ.dPU();
            if (dPU != 0) {
                ab.e("MicroMsg.SceneVoiceAddr", "init VoiceDetectAPI failed :".concat(String.valueOf(dPU)));
                f.g(this.gbb);
            } else {
                this.gbb.coZ.cpM = f.h(this.gbb);
                if (!this.gbb.coZ.EL()) {
                    ab.e("MicroMsg.SceneVoiceAddr", "start record failed");
                    f.g(this.gbb);
                }
            }
        }
        AppMethodBeat.o(116695);
    }
}
