Fixed leaks in SurfaceMediaSource_test
mEglSurface was being reused which resulted in
EGLSurfaces being lost.
Change-Id: Ica07cd24b0e4f3d4b2156f55b7de8e83d5466136
diff --git a/media/libstagefright/tests/SurfaceMediaSource_test.cpp b/media/libstagefright/tests/SurfaceMediaSource_test.cpp
index 10713fe..466f521 100644
--- a/media/libstagefright/tests/SurfaceMediaSource_test.cpp
+++ b/media/libstagefright/tests/SurfaceMediaSource_test.cpp
@@ -486,6 +486,10 @@
mSTC = new SurfaceTextureClient(iST);
mANW = mSTC;
+ if (mEglSurface != EGL_NO_SURFACE) {
+ EXPECT_TRUE(eglDestroySurface(mEglDisplay, mEglSurface));
+ mEglSurface = EGL_NO_SURFACE;
+ }
mEglSurface = eglCreateWindowSurface(mEglDisplay, mGlConfig,
mANW.get(), NULL);
ASSERT_EQ(EGL_SUCCESS, eglGetError());
@@ -783,6 +787,11 @@
DummyRecorder writer(mSMS);
writer.start();
+ if (mEglSurface != EGL_NO_SURFACE) {
+ EXPECT_TRUE(eglDestroySurface(mEglDisplay, mEglSurface));
+ mEglSurface = EGL_NO_SURFACE;
+ }
+
mEglSurface = eglCreateWindowSurface(mEglDisplay, mGlConfig,
mANW.get(), NULL);
ASSERT_EQ(EGL_SUCCESS, eglGetError());