Merge branch 'audiorecorder-1.1.57'
This commit is contained in:
commit
1b5eca2cc1
6 changed files with 17 additions and 19 deletions
|
|
@ -8,8 +8,8 @@ android {
|
|||
applicationId "com.github.axet.audiorecorder"
|
||||
minSdkVersion 16
|
||||
targetSdkVersion 23
|
||||
versionCode 78
|
||||
versionName "1.1.56"
|
||||
versionCode 79
|
||||
versionName "1.1.57"
|
||||
}
|
||||
signingConfigs {
|
||||
release {
|
||||
|
|
|
|||
|
|
@ -1,7 +1,7 @@
|
|||
package com.github.axet.audiorecorder.encoders;
|
||||
|
||||
public interface Encoder {
|
||||
void encode(short[] buf);
|
||||
void encode(short[] buf, int len);
|
||||
|
||||
void flush();
|
||||
|
||||
|
|
|
|||
|
|
@ -39,19 +39,19 @@ public class FileEncoder {
|
|||
|
||||
samples = rs.getSamples();
|
||||
|
||||
short[] buf = new short[1000];
|
||||
short[] buf = new short[2048];
|
||||
|
||||
rs.open(buf.length);
|
||||
|
||||
try {
|
||||
while (!Thread.currentThread().isInterrupted()) {
|
||||
long len = rs.read(buf);
|
||||
int len = rs.read(buf);
|
||||
if (len <= 0) {
|
||||
encoder.flush();
|
||||
handler.post(done);
|
||||
return;
|
||||
} else {
|
||||
encoder.encode(buf);
|
||||
encoder.encode(buf, len);
|
||||
handler.post(progress);
|
||||
synchronized (thread) {
|
||||
cur += len;
|
||||
|
|
@ -62,7 +62,6 @@ public class FileEncoder {
|
|||
Log.e(TAG, "Exception", e);
|
||||
t = e;
|
||||
handler.post(error);
|
||||
throw e;
|
||||
} finally {
|
||||
encoder.close();
|
||||
if (rs != null) {
|
||||
|
|
|
|||
|
|
@ -11,7 +11,7 @@ import java.util.Map;
|
|||
public class FormatM4A extends MuxerMP4 {
|
||||
|
||||
public FormatM4A(EncoderInfo info, File out) {
|
||||
Map<String, MediaCodecInfo> map = findEncoder("audio/mp4");
|
||||
Map<String, MediaCodecInfo> map = MuxerMP4.findEncoder("audio/mp4");
|
||||
if (map.isEmpty())
|
||||
throw new RuntimeException("mp4 not supported");
|
||||
MediaFormat format = MuxerMP4.getDefault("audio/mp4a-latm", map);
|
||||
|
|
|
|||
|
|
@ -97,12 +97,12 @@ public class FormatWAV implements Encoder {
|
|||
}
|
||||
}
|
||||
|
||||
public void encode(short[] buf) {
|
||||
NumSamples += buf.length / info.channels;
|
||||
public void encode(short[] buf, int buflen) {
|
||||
NumSamples += buflen / info.channels;
|
||||
try {
|
||||
ByteBuffer bb = ByteBuffer.allocate(buf.length * (Short.SIZE / Byte.SIZE));
|
||||
ByteBuffer bb = ByteBuffer.allocate(buflen * (Short.SIZE / Byte.SIZE));
|
||||
bb.order(order);
|
||||
for (int i = 0; i < buf.length; i++)
|
||||
for (int i = 0; i < buflen; i++)
|
||||
bb.putShort(buf[i]);
|
||||
bb.flip();
|
||||
outFile.write(bb.array());
|
||||
|
|
|
|||
|
|
@ -84,9 +84,10 @@ public class MuxerMP4 implements Encoder {
|
|||
}
|
||||
}
|
||||
|
||||
public void encode(short[] buf) {
|
||||
for (int offset = 0; offset < buf.length; ) {
|
||||
int len = buf.length - offset;
|
||||
@Override
|
||||
public void encode(short[] buf, int buflen) {
|
||||
for (int offset = 0; offset < buflen; ) {
|
||||
int len = buflen - offset;
|
||||
|
||||
int inputIndex = encoder.dequeueInputBuffer(-1);
|
||||
if (inputIndex < 0)
|
||||
|
|
@ -98,12 +99,10 @@ public class MuxerMP4 implements Encoder {
|
|||
len = Math.min(len, input.limit() / 2);
|
||||
|
||||
for (int i = 0; i < len; i++)
|
||||
input.putShort(buf[i]);
|
||||
|
||||
int bytes = len * 2;
|
||||
input.putShort(buf[offset + i]);
|
||||
|
||||
long ts = getCurrentTimeStamp();
|
||||
encoder.queueInputBuffer(inputIndex, 0, bytes, ts, 0);
|
||||
encoder.queueInputBuffer(inputIndex, 0, input.position(), ts, 0);
|
||||
NumSamples += len / info.channels;
|
||||
offset += len;
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue