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

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

Loading…
Cancel
Save