summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorOscar Rydhé <oscar.rydhe@sonyericsson.com>2011-12-29 13:57:04 +0100
committerSteve Kondik <steve@cyngn.com>2015-11-07 02:24:47 -0800
commit5d9ec7585ad39f73690fddbd864f3e3f5c1bde4d (patch)
tree88b5fd9ca4ba1bc1db3e2abe88bb276b50143af7
parent45c06ec4ffad8f5a602db37b28537267f687c3ef (diff)
downloadframeworks_av-5d9ec7585ad39f73690fddbd864f3e3f5c1bde4d.zip
frameworks_av-5d9ec7585ad39f73690fddbd864f3e3f5c1bde4d.tar.gz
frameworks_av-5d9ec7585ad39f73690fddbd864f3e3f5c1bde4d.tar.bz2
Stop thread before deleting object reference
If setPeriodicCapture is called Visualizer will start a thread and do periodic callbacks. When native_finalize is called the reference to the class is deleted. If a callback happens after this the reference is no longer valid and when used from the callback method the vm crashes. With this patch the thread will be terminated before deleting the reference. Change-Id: I30f331437ddad05f8d52c244cdbecb1859a0abd2
-rw-r--r--include/media/Visualizer.h1
-rw-r--r--media/libmedia/Visualizer.cpp8
2 files changed, 9 insertions, 0 deletions
diff --git a/include/media/Visualizer.h b/include/media/Visualizer.h
index 186e018..f14977b 100644
--- a/include/media/Visualizer.h
+++ b/include/media/Visualizer.h
@@ -97,6 +97,7 @@ public:
// and the capture format is according to flags (see callback_flags).
status_t setCaptureCallBack(capture_cbk_t cbk, void* user, uint32_t flags, uint32_t rate,
bool force = false);
+ void cancelCaptureCallBack();
// set the capture size capture size must be a power of two in the range
// [VISUALIZER_CAPTURE_SIZE_MAX. VISUALIZER_CAPTURE_SIZE_MIN]
diff --git a/media/libmedia/Visualizer.cpp b/media/libmedia/Visualizer.cpp
index f5c1b1f..8d83c1b 100644
--- a/media/libmedia/Visualizer.cpp
+++ b/media/libmedia/Visualizer.cpp
@@ -94,6 +94,14 @@ status_t Visualizer::setEnabled(bool enabled)
return status;
}
+void Visualizer::cancelCaptureCallBack()
+{
+ sp<CaptureThread> t = mCaptureThread;
+ if (t != 0) {
+ t->requestExitAndWait();
+ }
+}
+
status_t Visualizer::setCaptureCallBack(capture_cbk_t cbk, void* user, uint32_t flags,
uint32_t rate, bool force)
{