Merge branch 'audiorecorder-1.1.50'

This commit is contained in:
Alexey Kuznetsov 2016-09-24 20:57:11 +03:00
commit e0a891f727
6 changed files with 37 additions and 10 deletions

View file

@ -8,8 +8,8 @@ android {
applicationId "com.github.axet.audiorecorder"
minSdkVersion 16
targetSdkVersion 23
versionCode 71
versionName "1.1.49"
versionCode 72
versionName "1.1.50"
}
signingConfigs {
release {

View file

@ -810,8 +810,23 @@ public class RecordingActivity extends AppCompatActivity {
}, new Runnable() {
@Override
public void run() {
Toast.makeText(RecordingActivity.this, encoder.getException().getMessage(), Toast.LENGTH_SHORT).show();
finish();
d.cancel();
AlertDialog.Builder builder = new AlertDialog.Builder(RecordingActivity.this);
builder.setTitle("Error");
builder.setMessage(encoder.getException().getMessage());
builder.setOnCancelListener(new DialogInterface.OnCancelListener() {
@Override
public void onCancel(DialogInterface dialog) {
finish();
}
});
builder.setPositiveButton("OK", new DialogInterface.OnClickListener() {
@Override
public void onClick(DialogInterface dialog, int which) {
finish();
}
});
builder.show();
}
});
}

View file

@ -1,7 +1,9 @@
package com.github.axet.audiorecorder.encoders;
public interface Encoder {
public void encode(short[] buf);
void encode(short[] buf);
public void close();
void flush();
void close();
}

View file

@ -47,6 +47,7 @@ public class FileEncoder {
while (!Thread.currentThread().isInterrupted()) {
long len = rs.read(buf);
if (len <= 0) {
encoder.flush();
handler.post(done);
return;
} else {

View file

@ -111,10 +111,17 @@ public class FormatWAV implements Encoder {
}
}
public void close() {
public void flush() {
try {
outFile.seek(0);
save();
} catch (IOException e) {
throw new RuntimeException(e);
}
}
public void close() {
try {
outFile.close();
} catch (IOException e) {
throw new RuntimeException(e);

View file

@ -87,14 +87,16 @@ public class MuxerMP4 implements Encoder {
return true;
}
public void close() {
public void flush() {
end();
encode();
encoder.stop();
encoder.release();
muxer.stop();
}
public void close() {
encoder.release();
muxer.release();
}