Add reference counter for Filter

Filters should start demux reading thread for IPTV when start()
is called and they should PAUSE the thread when stop() is called.
They should only be paused when all associated filters of the
demux are closed. This CL adds reference counters for filters to
track that.

Bug: 288170590
Test: manual
Change-Id: I087175a685a4559918ceaa511971b79e7fcb0a51
This commit is contained in:
sadiqsada
2023-10-31 15:39:46 -07:00
committed by Sadiq Sada
parent 52b7f34ad7
commit 08cae81678
2 changed files with 5 additions and 0 deletions

View File

@@ -326,6 +326,8 @@ Filter::~Filter() {
ALOGV("%s", __FUNCTION__);
mFilterThreadRunning = true;
std::vector<DemuxFilterEvent> events;
mFilterCount += 1;
// All the filter event callbacks in start are for testing purpose.
switch (mType.mainType) {
case DemuxFilterMainType::TS:
@@ -362,6 +364,8 @@ Filter::~Filter() {
::ndk::ScopedAStatus Filter::stop() {
ALOGV("%s", __FUNCTION__);
mFilterCount -= 1;
mFilterThreadRunning = false;
if (mFilterThread.joinable()) {
mFilterThread.join();

View File

@@ -289,6 +289,7 @@ class Filter : public BnFilter {
uint8_t mIpCidMonitored = 0;
PlaybackStatus mIptvDvrPlaybackStatus;
std::atomic<int> mFilterCount = 0;
};
} // namespace tuner