@@ -160,9 +160,22 @@ public void prepare(FilterContext context) {
160160 @ Override
161161 public void open (FilterContext context ) {
162162 // Set up SurfaceTexture internals
163- mSurfaceId = context .getGLEnvironment ().registerSurfaceTexture (mSurfaceTexture , mScreenWidth , mScreenHeight );
163+ mSurfaceId = context .getGLEnvironment ().registerSurfaceTexture (
164+ mSurfaceTexture , mScreenWidth , mScreenHeight );
165+ if (mSurfaceId <= 0 ) {
166+ throw new RuntimeException ("Could not register SurfaceTexture: " + mSurfaceTexture );
167+ }
164168 }
165169
170+
171+ @ Override
172+ public void close (FilterContext context ) {
173+ if (mSurfaceId > 0 ) {
174+ context .getGLEnvironment ().unregisterSurfaceId (mSurfaceId );
175+ }
176+ }
177+
178+
166179 @ Override
167180 public void process (FilterContext context ) {
168181 if (mLogVerbose ) Log .v (TAG , "Starting frame processing" );
@@ -173,9 +186,11 @@ public void process(FilterContext context) {
173186 Frame input = pullInput ("frame" );
174187 boolean createdFrame = false ;
175188
176- float currentAspectRatio = (float )input .getFormat ().getWidth () / input .getFormat ().getHeight ();
189+ float currentAspectRatio =
190+ (float )input .getFormat ().getWidth () / input .getFormat ().getHeight ();
177191 if (currentAspectRatio != mAspectRatio ) {
178- if (mLogVerbose ) Log .v (TAG , "New aspect ratio: " + currentAspectRatio +", previously: " + mAspectRatio );
192+ if (mLogVerbose ) Log .v (TAG , "New aspect ratio: " + currentAspectRatio +
193+ ", previously: " + mAspectRatio );
179194 mAspectRatio = currentAspectRatio ;
180195 updateTargetRect ();
181196 }
0 commit comments