Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 76fd0a16 authored by Oscar Rydhé's avatar Oscar Rydhé Committed by Steve Kondik
Browse files

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
parent e0ea7fe5
Loading
Loading
Loading
Loading
+1 −0
Original line number Diff line number Diff line
@@ -95,6 +95,7 @@ public:
    // install a callback to receive periodic captures. The capture rate is specified in milliHertz
    // 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);
    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]
+8 −0
Original line number Diff line number Diff line
@@ -97,6 +97,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)
{