Clear frame cache before close consumer thread

Signed-off-by: Leo Ma <begeekmyfriend@gmail.com>
camera2
Leo Ma 9 years ago
parent 3b5892e869
commit a50396c567

@ -37,6 +37,7 @@ public class SrsCameraView extends GLSurfaceView implements GLSurfaceView.Render
private int mSurfaceHeight;
private int mPreviewWidth;
private int mPreviewHeight;
private boolean mIsEncoding;
private float mInputAspectRatio;
private float mOutputAspectRatio;
private float[] mProjectionMatrix = new float[16];
@ -122,7 +123,7 @@ public class SrsCameraView extends GLSurfaceView implements GLSurfaceView.Render
magicFilter.setTextureTransformMatrix(mTransformMatrix);
magicFilter.onDrawFrame(mOESTextureId);
if (worker != null) {
if (mIsEncoding) {
mGLIntBufferCache.add(magicFilter.getGLFboBuffer());
synchronized (writeLock) {
writeLock.notifyAll();
@ -240,9 +241,13 @@ public class SrsCameraView extends GLSurfaceView implements GLSurfaceView.Render
}
});
worker.start();
mIsEncoding = true;
}
public void disableEncoding() {
mIsEncoding = false;
mGLIntBufferCache.clear();
if (worker != null) {
worker.interrupt();
try {
@ -251,7 +256,6 @@ public class SrsCameraView extends GLSurfaceView implements GLSurfaceView.Render
e.printStackTrace();
worker.interrupt();
}
mGLIntBufferCache.clear();
worker = null;
}
}

@ -200,6 +200,7 @@ public class SrsFlvMuxer {
* stop the muxer, disconnect RTMP connection.
*/
public void stop() {
mFlvTagCache.clear();
if (worker != null) {
worker.interrupt();
try {
@ -208,7 +209,6 @@ public class SrsFlvMuxer {
e.printStackTrace();
worker.interrupt();
}
mFlvTagCache.clear();
worker = null;
}
flv.reset();

Loading…
Cancel
Save