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

Commit 3d17d7d5 authored by Hongguang's avatar Hongguang
Browse files

Flush events before stopping filter.

All the filter events in scheduler should be cleaned before stopping.
Sending events after stopping may cause problems if frameworks has
release some references.

Bug: 205763272
Test: atest VtsHalTvTunerTargetTest
Test: atest android.media.tv.tuner.cts
Change-Id: I2d3875b348035e14314034ff90aa8c066108affe
parent e51ea5f4
Loading
Loading
Loading
Loading
+8 −0
Original line number Diff line number Diff line
@@ -60,6 +60,12 @@ void FilterCallbackScheduler::onFilterStatus(const DemuxFilterStatus& status) {
    }
}

void FilterCallbackScheduler::flushEvents() {
    std::unique_lock<std::mutex> lock(mLock);
    mCallbackBuffer.clear();
    mDataLength = 0;
}

void FilterCallbackScheduler::setTimeDelayHint(int timeDelay) {
    // updating the setTimeDelay does not go into effect until the condition
    // variable times out or is notified.
@@ -335,6 +341,8 @@ Filter::~Filter() {
        mFilterThread.join();
    }

    mCallbackScheduler.flushEvents();

    return ::ndk::ScopedAStatus::ok();
}

+2 −0
Original line number Diff line number Diff line
@@ -68,6 +68,8 @@ class FilterCallbackScheduler final {

    bool hasCallbackRegistered() const;

    void flushEvents();

  private:
    void start();
    void stop();