From 08cae8167815ca7f144b734cbc0bde042b67769a Mon Sep 17 00:00:00 2001 From: sadiqsada Date: Tue, 31 Oct 2023 15:39:46 -0700 Subject: [PATCH] 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 --- tv/tuner/aidl/default/Filter.cpp | 4 ++++ tv/tuner/aidl/default/Filter.h | 1 + 2 files changed, 5 insertions(+) diff --git a/tv/tuner/aidl/default/Filter.cpp b/tv/tuner/aidl/default/Filter.cpp index 7b62c3e21e..d8f5dd5f28 100644 --- a/tv/tuner/aidl/default/Filter.cpp +++ b/tv/tuner/aidl/default/Filter.cpp @@ -326,6 +326,8 @@ Filter::~Filter() { ALOGV("%s", __FUNCTION__); mFilterThreadRunning = true; std::vector 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(); diff --git a/tv/tuner/aidl/default/Filter.h b/tv/tuner/aidl/default/Filter.h index 1cf6b3abc4..e2a0c7abfa 100644 --- a/tv/tuner/aidl/default/Filter.h +++ b/tv/tuner/aidl/default/Filter.h @@ -289,6 +289,7 @@ class Filter : public BnFilter { uint8_t mIpCidMonitored = 0; PlaybackStatus mIptvDvrPlaybackStatus; + std::atomic mFilterCount = 0; }; } // namespace tuner