Make the library compatible with java 1.7

This commit is contained in:
Andre Natal 2018-10-16 15:34:40 -07:00 коммит произвёл Andre Natal
Родитель 896d10058c
Коммит e5690e7eb9
3 изменённых файлов: 21 добавлений и 18 удалений

Просмотреть файл

@ -13,8 +13,8 @@ org.gradle.jvmargs=-Xmx1536m
# org.gradle.parallel=true
VERSION_NAME=1.0.4
VERSION_CODE=10004
VERSION_NAME=1.0.6
VERSION_CODE=10006
GROUP=com.github.mozilla
POM_DESCRIPTION=This is an Android library containing an API to Mozilla's speech recognition services

Просмотреть файл

@ -28,8 +28,8 @@ android {
}
}
compileOptions {
sourceCompatibility JavaVersion.VERSION_1_8
targetCompatibility JavaVersion.VERSION_1_8
sourceCompatibility = 1.7
targetCompatibility = 1.7
}
}

Просмотреть файл

@ -72,7 +72,7 @@ public class HotwordRecorder {
.build();
mRecorder.startRecording();
mRecording = true;
mThread = new Thread(() -> readAudio());
mThread = new Thread(readAudio);
mThread.start();
}
@ -89,23 +89,26 @@ public class HotwordRecorder {
/**
* Read audio from the audio recorder stream.
*/
private void readAudio() {
int readBytes;
short[] buffer = new short[BUFFER_SIZE];
private Runnable readAudio =
new Runnable(){
public void run(){
int readBytes;
short[] buffer = new short[BUFFER_SIZE];
while (mRecording) {
readBytes = mRecorder.read(buffer, 0, BUFFER_SIZE);
while (mRecording) {
readBytes = mRecorder.read(buffer, 0, BUFFER_SIZE);
if (readBytes != AudioRecord.ERROR_INVALID_OPERATION) {
for (short s : buffer) {
writeShort(mPcmStream, s);
if (readBytes != AudioRecord.ERROR_INVALID_OPERATION) {
for (short s : buffer) {
writeShort(mPcmStream, s);
}
}
}
}
}
mRecorder.release();
mRecorder = null;
}
mRecorder.release();
mRecorder = null;
}
};
/**
* Convert raw PCM data to a wav file.