Skip to content

Commit f22a859

Browse files
committed
Comply with the lifecycle methods
Signed-off-by: Umair Khan <[email protected]>
1 parent 7d39c4b commit f22a859

File tree

1 file changed

+20
-16
lines changed

1 file changed

+20
-16
lines changed

src/in/omerjerk/processing/video/android/Capture.java

Lines changed: 20 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -89,22 +89,6 @@ public void run() {
8989
mCameraHandler = new CameraHandler(Capture.this);
9090
}
9191
});
92-
93-
glView.queueEvent(new Runnable() {
94-
@Override
95-
public void run() {
96-
mFullScreen = new FullFrameRect(
97-
new Texture2dProgram(Texture2dProgram.ProgramType.TEXTURE_EXT));
98-
mTextureId = mFullScreen.createTextureObject();
99-
100-
mSurfaceTexture = new SurfaceTexture(mTextureId);
101-
mSurfaceTexture.setOnFrameAvailableListener(Capture.this);
102-
// mCameraHandler.sendMessage(mCameraHandler.obtainMessage(CameraHandler.MSG_START_CAMERA, null));
103-
startCameraImpl(0);
104-
System.out.println("sent starting message to UI thread");
105-
prepareFrameBuffers();
106-
}
107-
});
10892
}
10993

11094
public void setCamera(String camera) {
@@ -137,13 +121,33 @@ public void pause() {
137121
mFullScreen.release(false); // assume the GLSurfaceView EGL context is about
138122
mFullScreen = null; // to be destroyed
139123
}
124+
if (mSurfaceTexture != null) {
125+
mSurfaceTexture.release();
126+
mSurfaceTexture = null;
127+
}
140128
}
141129

142130
public void resume() {
143131
log("resume called");
144132
if (selectedCamera != -1) {
145133
startCameraImpl(selectedCamera);
146134
}
135+
136+
glView.queueEvent(new Runnable() {
137+
@Override
138+
public void run() {
139+
mFullScreen = new FullFrameRect(
140+
new Texture2dProgram(Texture2dProgram.ProgramType.TEXTURE_EXT));
141+
mTextureId = mFullScreen.createTextureObject();
142+
143+
mSurfaceTexture = new SurfaceTexture(mTextureId);
144+
mSurfaceTexture.setOnFrameAvailableListener(Capture.this);
145+
// mCameraHandler.sendMessage(mCameraHandler.obtainMessage(CameraHandler.MSG_START_CAMERA, null));
146+
startCameraImpl(0);
147+
System.out.println("sent starting message to UI thread");
148+
prepareFrameBuffers();
149+
}
150+
});
147151
}
148152

149153
@Override

0 commit comments

Comments
 (0)