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
diff --git a/tv/tuner/aidl/default/Filter.cpp b/tv/tuner/aidl/default/Filter.cpp
index 5b6debb..5f61c8d 100644
--- a/tv/tuner/aidl/default/Filter.cpp
+++ b/tv/tuner/aidl/default/Filter.cpp
@@ -60,6 +60,12 @@
}
}
+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 @@
mFilterThread.join();
}
+ mCallbackScheduler.flushEvents();
+
return ::ndk::ScopedAStatus::ok();
}
diff --git a/tv/tuner/aidl/default/Filter.h b/tv/tuner/aidl/default/Filter.h
index a5adf4c..7298561 100644
--- a/tv/tuner/aidl/default/Filter.h
+++ b/tv/tuner/aidl/default/Filter.h
@@ -68,6 +68,8 @@
bool hasCallbackRegistered() const;
+ void flushEvents();
+
private:
void start();
void stop();