package defpackage;
import android.os.Build;
import android.os.Build.VERSION;
import android.os.Process;
import android.os.SystemClock;
import com.tencent.mobileqq.ptt.processor.IPttProcessor;
import com.tencent.mobileqq.ptt.processor.IPttProcessor.ProcessData;
import com.tencent.mobileqq.ptt.processor.IPttProcessorListener;
import com.tencent.mobileqq.transfile.PttInfoCollector;
import com.tencent.mobileqq.utils.AudioHelper;
import com.tencent.mobileqq.utils.AudioUtil;
import com.tencent.mobileqq.utils.QQRecorder;
import com.tencent.mobileqq.utils.QQRecorder.RecordNoPermissonException;
import com.tencent.mobileqq.utils.WechatNsWrapper;
import com.tencent.qphone.base.util.QLog;
import java.util.HashMap;
/* compiled from: ProGuard */
public class ammg extends Thread implements IPttProcessorListener {
int a = 0;
long f0a = 0;
final /* synthetic */ QQRecorder f1a;
public String f2a;
public volatile boolean f3a = true;
public volatile boolean b = true;
private boolean c;
public ammg(QQRecorder qQRecorder) {
this.f1a = qQRecorder;
}
public void run() {
while (this.b) {
if (QLog.isColorLevel()) {
QLog.d("QQRecorder", 2, "RecordThread : begin run");
}
this.f3a = true;
this.c = false;
a(this.f2a);
if (this.b) {
long uptimeMillis = SystemClock.uptimeMillis();
synchronized (this.f1a) {
this.f1a.wait((long) QQRecorder.a);
}
if (SystemClock.uptimeMillis() - uptimeMillis < ((long) QQRecorder.a)) {
continue;
} else {
if (QLog.isColorLevel()) {
QLog.d("QQRecorder", 2, "RecordThread more than maxtime release");
}
synchronized (this) {
this.b = false;
}
try {
a();
} catch (InterruptedException e) {
e.printStackTrace();
}
}
}
}
a();
}
private void a(String str) {
long j;
int read;
Throwable th;
Object obj;
HashMap hashMap;
int i;
StringBuilder stringBuilder;
if (QLog.isColorLevel()) {
QLog.d("QQRecorder", 2, "RecordThread doRecord: " + this);
}
long j2 = 0;
long j3 = 0;
int i2 = 0;
double d = 0.0d;
long currentTimeMillis = System.currentTimeMillis();
long j4 = 0;
long j5 = 0;
int i3 = 0;
long j6 = 0;
int i4 = 250;
Process.setThreadPriority(-19);
AudioUtil.a(QQRecorder.a(this.f1a), true);
HashMap hashMap2;
int i5;
StringBuilder stringBuilder2;
try {
int a;
if (QQRecorder.a(this.f1a) != null) {
QQRecorder.a(this.f1a).a(str, this.f1a.a);
}
byte[] bArr = new byte[QQRecorder.b(this.f1a)];
QQRecorder.a(this.f1a);
if (QQRecorder.a(this.f1a) != null) {
i4 = QQRecorder.a(this.f1a).a();
if (i4 <= 0) {
i4 = 250;
}
i4 = QQRecorder.a(i4);
}
if (QLog.isDevelopLevel()) {
QLog.d("QQRecorder", 4, "PTT onRecordReady cost : " + (SystemClock.uptimeMillis() - PttInfoCollector.a));
}
QQRecorder.b(this.f1a);
QQRecorder.a(this.f1a).a(this);
Thread.sleep(200);
int b = (QQRecorder.b(this.f1a.a.a) / 1000) * i4;
int i6 = 0;
while (i6 < b) {
i4 = QQRecorder.b(this.f1a);
if (QQRecorder.b(this.f1a) > b - i6) {
i4 = b - i6;
}
QQRecorder.a(this.f1a).read(bArr, 0, i4);
i6 = i4 + i6;
}
if (QLog.isColorLevel()) {
QLog.d("QQRecorder", 2, "MyThread abandonBuf, abandonSize:" + i6 + " abandonBufLen:" + b);
}
if (QQRecorder.a(this.f1a) != null) {
a = QQRecorder.a(this.f1a).a(this.f2a, this.f1a.a);
} else {
a = -1;
}
if (QLog.isDevelopLevel()) {
QLog.d("QQRecorder", 4, "PTT onBeginReceiveData cost : " + (SystemClock.uptimeMillis() - PttInfoCollector.a));
}
long currentTimeMillis2 = System.currentTimeMillis();
int i7 = 0;
i6 = 0;
long j7 = 0;
Object obj2 = null;
long j8 = 0;
j2 = 0;
double d2 = 0.0d;
while (this.f3a && !this.c) {
try {
if (System.currentTimeMillis() - currentTimeMillis2 > 1000 && r16 == null) {
obj2 = 1;
if (j7 == 0 || i3 == 0) {
if (QLog.isColorLevel()) {
QLog.d("QQRecorder", 2, "record abnormal: data size = " + j7 + ", max volume = " + i3);
}
throw new RecordNoPermissonException("no permission");
}
}
Object obj3 = obj2;
if (System.currentTimeMillis() - currentTimeMillis2 > 1000 && r4 == 0) {
if (QLog.isColorLevel()) {
QLog.d("QQRecorder", 2, "check 1000ms max volume, volume: " + this.a);
}
if (this.a <= 0 || this.a >= 500) {
i7 = 2;
} else {
i7 = 1;
}
if (QQRecorder.a(this.f1a) != null) {
QQRecorder.a(this.f1a).a(i7);
}
}
j = j8 + 1;
try {
read = QQRecorder.a(this.f1a).read(bArr, 0, QQRecorder.b(this.f1a));
if (read <= 0) {
try {
Thread.sleep(10);
obj2 = obj3;
i6 = read;
j8 = j;
} catch (Throwable th2) {
th = th2;
j3 = j7;
i2 = read;
d = d2;
obj = null;
}
} else {
j3 = 1 + j5;
long j9 = j7 + ((long) read);
try {
int a2 = (int) AudioHelper.a(QQRecorder.a(this.f1a), bArr, read, 1.0f);
int max = Math.max(i3, a2);
j7 = j6 + ((long) a2);
try {
ProcessData a3 = QQRecorder.a(this.f1a).a(bArr, 0, read);
PttInfoCollector.b();
d2 += QQRecorder.a((long) read, this.f1a.a.a);
if (!(QQRecorder.a(this.f1a) == null || a3 == null)) {
QQRecorder.a(this.f1a).a(str, a3.a, a3.a, QQRecorder.c(this.f1a), d2, this.f1a.a);
}
if (a3 != null) {
j6 = ((long) a3.a) + j2;
} else {
j6 = j2;
}
if (i7 == 1) {
try {
if (this.a > 500) {
i7 = 2;
if (QQRecorder.a(this.f1a) != null) {
QQRecorder.a(this.f1a).a(2);
}
if (QLog.isColorLevel()) {
QLog.d("QQRecorder", 2, "volume state changed, normal volume: " + this.a);
}
}
} catch (Throwable th3) {
th = th3;
i3 = max;
j5 = j3;
j2 = j6;
j6 = j7;
d = d2;
j3 = j9;
i2 = i6;
obj = null;
}
}
if (a != -1 && d2 >= ((double) a)) {
this.c = true;
}
i3 = max;
j5 = j3;
j2 = j6;
j6 = j7;
obj2 = obj3;
j8 = j;
j7 = j9;
} catch (Throwable th4) {
th = th4;
j6 = j7;
i3 = max;
j5 = j3;
d = d2;
i2 = i6;
j3 = j9;
obj = null;
}
} catch (Throwable th5) {
th = th5;
j5 = j3;
d = d2;
i2 = i6;
obj = null;
j3 = j9;
}
}
} catch (Throwable th6) {
th = th6;
d = d2;
j3 = j7;
i2 = i6;
obj = null;
}
} catch (Throwable th7) {
th = th7;
j3 = j7;
j = j8;
i2 = i6;
d = d2;
obj = null;
}
}
if (QQRecorder.a(this.f1a) != null) {
QQRecorder.a(this.f1a).a(str, this.f1a.a, d2);
if (!(this.f1a.a == null || QQRecorder.d(this.f1a) == -1)) {
this.f1a.a.setMode(0);
}
}
if (QQRecorder.a(this.f1a) != null && QQRecorder.a(this.f1a).getState() == 1) {
QQRecorder.a(this.f1a).stop();
}
try {
QQRecorder.c(this.f1a);
} catch (Throwable th8) {
th8.printStackTrace();
}
if (QLog.isColorLevel()) {
QLog.d("QQRecorder", 2, "MyThread end: " + this);
QLog.d("QQRecorder", 2, "read times = " + j8 + " orginal data size = " + j7 + "arm data size = " + j2 + " error code = " + i6);
}
AudioUtil.a(QQRecorder.a(this.f1a), false);
if ((j2 < 512 || d2 < 1000.0d) && System.currentTimeMillis() - currentTimeMillis > 1000) {//如果arm大小小于512 ,或者读取时间小于1000但是总时长间隔超过了1000.那么就研究你触摸了多久。
try {
hashMap2 = new HashMap();
hashMap2.put("exceptionType", "1");
hashMap2.put("osVersion", VERSION.SDK_INT + "");
hashMap2.put("deviceName", Build.MANUFACTURER + "_" + Build.MODEL);
hashMap2.put("dataSize", j7 + "");
hashMap2.put("maxVolume", i3 + "");
hashMap2.put("readTime", d2 + "");
hashMap2.put("touchTime", (System.currentTimeMillis() - currentTimeMillis) + "");
QQRecorder.a("actPttRecordException", false, hashMap2);
if (QLog.isColorLevel()) {
QLog.d("QQRecorder", 2, "report exception(short record) | exception type = 1 | dataSize = " + j7 + " | amrSize = " + j2 + " | readTime = " + d2 + " | toucTime = " + (System.currentTimeMillis() - currentTimeMillis));
}
} catch (Throwable th82) {
if (QLog.isColorLevel()) {
QLog.d("QQRecorder", 2, "Report exception error.", th82);
}
}
}
try {
hashMap2 = new HashMap();
hashMap2.put("osVersion", VERSION.SDK_INT + "");
hashMap2.put("deviceName", Build.MANUFACTURER + "_" + Build.MODEL);
hashMap2.put("dataSize", j7 + "");
hashMap2.put("pttDuration", d2 + "");
hashMap2.put("touchTime", (System.currentTimeMillis() - currentTimeMillis) + "");
hashMap2.put("maxVolume", i3 + "");
hashMap2.put("amrMaxVolume", this.a + "");
read = (int) (j5 == 0 ? -1 : j6 / j5);
if (j5 == 0) {
j6 = -1;
} else {
j6 = this.f0a / j5;
}
i5 = (int) j6;
hashMap2.put("averageVolume", read + "");
hashMap2.put("amrAverageVolume", i5 + "");
QQRecorder.a("actPttRecordVolume", true, hashMap2);
if (QLog.isColorLevel()) {
stringBuilder2 = new StringBuilder();
stringBuilder2.append("report record detail | maxVolume = ").append(i3);
stringBuilder2.append(" | averageVolume = ").append(read);
stringBuilder2.append(" | amrMaxVolume = ").append(i5);
stringBuilder2.append(" | amrAverage = ").append(i5);
stringBuilder2.append(" | dataSize = ").append(j7);
stringBuilder2.append(" | amrSize = ").append(j2);
stringBuilder2.append(" | pttDuration = ").append(d2);
stringBuilder2.append(" | touchTime = ").append(System.currentTimeMillis() - currentTimeMillis);
QLog.d("QQRecorder", 2, stringBuilder2.toString());
}
} catch (Throwable th822) {
if (QLog.isColorLevel()) {
QLog.d("QQRecorder", 2, "Report record error.", th822);
}
}
} catch (Throwable th9) {
th822 = th9;
j = 0;
j2 = 0;
obj = null;
if (QQRecorder.a(this.f1a) != null && QQRecorder.a(this.f1a).getState() == 1) {
QQRecorder.a(this.f1a).stop();
}
QQRecorder.c(this.f1a);
if (QLog.isColorLevel()) {
QLog.d("QQRecorder", 2, "MyThread end: " + this);
QLog.d("QQRecorder", 2, "read times = " + j + " orginal data size = " + j3 + "arm data size = " + j2 + " error code = " + i2);
}
AudioUtil.a(QQRecorder.a(this.f1a), false);
if ((j2 < 512 || d < 1000.0d) && r10 == null && System.currentTimeMillis() - currentTimeMillis > 1000) {
hashMap = new HashMap();
hashMap.put("exceptionType", "1");
hashMap.put("osVersion", VERSION.SDK_INT + "");
hashMap.put("deviceName", Build.MANUFACTURER + "_" + Build.MODEL);
hashMap.put("dataSize", j3 + "");
hashMap.put("maxVolume", i3 + "");
hashMap.put("readTime", d + "");
hashMap.put("touchTime", (System.currentTimeMillis() - currentTimeMillis) + "");
QQRecorder.a("actPttRecordException", false, hashMap);
if (QLog.isColorLevel()) {
QLog.d("QQRecorder", 2, "report exception(short record) | exception type = 1 | dataSize = " + j3 + " | amrSize = " + j2 + " | readTime = " + d + " | toucTime = " + (System.currentTimeMillis() - currentTimeMillis));
}
}
hashMap = new HashMap();
hashMap.put("osVersion", VERSION.SDK_INT + "");
hashMap.put("deviceName", Build.MANUFACTURER + "_" + Build.MODEL);
hashMap.put("dataSize", j3 + "");
hashMap.put("pttDuration", d + "");
hashMap.put("touchTime", (System.currentTimeMillis() - currentTimeMillis) + "");
hashMap.put("maxVolume", i3 + "");
hashMap.put("amrMaxVolume", this.a + "");
if (j5 != 0) {
}
i = (int) (j5 != 0 ? j6 / j5 : -1);
if (j5 != 0) {
j6 = -1;
} else {
j6 = this.f0a / j5;
}
i5 = (int) j6;
hashMap.put("averageVolume", i + "");
hashMap.put("amrAverageVolume", i5 + "");
QQRecorder.a("actPttRecordVolume", true, hashMap);
if (QLog.isColorLevel()) {
stringBuilder = new StringBuilder();
stringBuilder.append("report record detail | maxVolume = ").append(i3);
stringBuilder.append(" | averageVolume = ").append(i);
stringBuilder.append(" | amrMaxVolume = ").append(i5);
stringBuilder.append(" | amrAverage = ").append(i5);
stringBuilder.append(" | dataSize = ").append(j3);
stringBuilder.append(" | amrSize = ").append(j2);
stringBuilder.append(" | pttDuration = ").append(d);
stringBuilder.append(" | touchTime = ").append(System.currentTimeMillis() - currentTimeMillis);
QLog.d("QQRecorder", 2, stringBuilder.toString());
}
throw th822;
}
}
public void a(IPttProcessor iPttProcessor, ProcessData processData) {
if ((iPttProcessor instanceof WechatNsWrapper) && QQRecorder.a(this.f1a) != null) {
QQRecorder.a(this.f1a).b(iPttProcessor, processData);
}
}
public void b(IPttProcessor iPttProcessor, ProcessData processData) {
if (iPttProcessor instanceof WechatNsWrapper) {
QQRecorder.b(this.f1a, (int) AudioHelper.a(QQRecorder.a(this.f1a), processData.a, processData.a, 1.0f));
this.a = Math.max(this.a, QQRecorder.c(this.f1a));
this.f0a += (long) QQRecorder.c(this.f1a);
if (QQRecorder.a(this.f1a) != null) {
QQRecorder.a(this.f1a).a(iPttProcessor, processData);
}
}
}
public boolean m0a() {
return this.b || QQRecorder.a(this.f1a) != null;
}
public void a() {
if (QQRecorder.a(this.f1a) != null) {
if (QLog.isColorLevel()) {
QLog.d("QQRecorder", 2, "releaseRecorder");
}
QQRecorder.a(this.f1a).release();
QQRecorder.a(this.f1a, null);
}
}
}
QQ语音 7.8.2的语音红包触发run方法逻辑
©著作权归作者所有,转载或内容合作请联系作者
- 文/潘晓璐 我一进店门,熙熙楼的掌柜王于贵愁眉苦脸地迎上来,“玉大人,你说我怎么就摊上这事。” “怎么了?”我有些...
- 文/花漫 我一把揭开白布。 她就那样静静地躺着,像睡着了一般。 火红的嫁衣衬着肌肤如雪。 梳的纹丝不乱的头发上,一...
- 文/苍兰香墨 我猛地睁开眼,长吁一口气:“原来是场噩梦啊……” “哼!你这毒妇竟也来了?” 一声冷哼从身侧响起,我...
推荐阅读更多精彩内容
- 2018.2.3 目标:身心健康,财富丰盛 好种子: 1早起健康早餐,种下健康的种子,回向群里姐妹及家人身心健康 ...