Recycle sonic buffer
This commit is contained in:
parent
dfd1a193ed
commit
a8197c93e1
|
@ -66,6 +66,7 @@ public class AudioPlayer implements MethodCallHandler {
|
||||||
private float volume = 1.0f;
|
private float volume = 1.0f;
|
||||||
private float speed = 1.0f;
|
private float speed = 1.0f;
|
||||||
private Thread mainThread;
|
private Thread mainThread;
|
||||||
|
private byte[] chunk;
|
||||||
|
|
||||||
public AudioPlayer(final Registrar registrar, final String id) {
|
public AudioPlayer(final Registrar registrar, final String id) {
|
||||||
mainThread = Thread.currentThread();
|
mainThread = Thread.currentThread();
|
||||||
|
@ -365,6 +366,7 @@ public class AudioPlayer implements MethodCallHandler {
|
||||||
codec.stop();
|
codec.stop();
|
||||||
codec.release();
|
codec.release();
|
||||||
codec = null;
|
codec = null;
|
||||||
|
chunk = null;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -495,8 +497,10 @@ public class AudioPlayer implements MethodCallHandler {
|
||||||
if (info.size > 0) {
|
if (info.size > 0) {
|
||||||
decoderIdleCount = 0;
|
decoderIdleCount = 0;
|
||||||
|
|
||||||
final byte[] chunk = new byte[info.size];
|
if (chunk == null || chunk.length < info.size) {
|
||||||
buf.get(chunk);
|
chunk = new byte[info.size];
|
||||||
|
}
|
||||||
|
buf.get(chunk, 0, info.size);
|
||||||
buf.clear();
|
buf.clear();
|
||||||
|
|
||||||
// put decoded data into sonic
|
// put decoded data into sonic
|
||||||
|
|
Loading…
Reference in New Issue