Loading tv/tuner/aidl/default/Demux.cpp +7 −14 Original line number Diff line number Diff line Loading @@ -37,8 +37,7 @@ Demux::Demux(int32_t demuxId, std::shared_ptr<Tuner> tuner) { } Demux::~Demux() { mFrontendInputThreadRunning = false; std::lock_guard<std::mutex> lock(mFrontendInputThreadLock); close(); } ::ndk::ScopedAStatus Demux::setFrontendDataSource(int32_t in_frontendId) { Loading Loading @@ -171,6 +170,8 @@ Demux::~Demux() { ::ndk::ScopedAStatus Demux::close() { ALOGV("%s", __FUNCTION__); stopFrontendInput(); set<int64_t>::iterator it; for (it = mPlaybackFilterIds.begin(); it != mPlaybackFilterIds.end(); it++) { mDvrPlayback->removePlaybackFilter(*it); Loading @@ -180,8 +181,6 @@ Demux::~Demux() { mFilters.clear(); mLastUsedFilterId = -1; mTuner->removeDemux(mDemuxId); mFrontendInputThreadRunning = false; std::lock_guard<std::mutex> lock(mFrontendInputThreadLock); return ::ndk::ScopedAStatus::ok(); } Loading Loading @@ -345,14 +344,7 @@ uint16_t Demux::getFilterTpid(int64_t filterId) { void Demux::startFrontendInputLoop() { mFrontendInputThreadRunning = true; pthread_create(&mFrontendInputThread, NULL, __threadLoopFrontend, this); pthread_setname_np(mFrontendInputThread, "frontend_input_thread"); } void* Demux::__threadLoopFrontend(void* user) { Demux* const self = static_cast<Demux*>(user); self->frontendInputThreadLoop(); return 0; mFrontendInputThread = std::thread(&Demux::frontendInputThreadLoop, this); } void Demux::frontendInputThreadLoop() { Loading @@ -360,7 +352,6 @@ void Demux::frontendInputThreadLoop() { return; } std::lock_guard<std::mutex> lock(mFrontendInputThreadLock); if (!mDvrPlayback) { ALOGW("[Demux] No software Frontend input configured. Ending Frontend thread loop."); mFrontendInputThreadRunning = false; Loading Loading @@ -402,7 +393,9 @@ void Demux::stopFrontendInput() { ALOGD("[Demux] stop frontend on demux"); mKeepFetchingDataFromFrontend = false; mFrontendInputThreadRunning = false; std::lock_guard<std::mutex> lock(mFrontendInputThreadLock); if (mFrontendInputThread.joinable()) { mFrontendInputThread.join(); } } void Demux::setIsRecording(bool isRecording) { Loading tv/tuner/aidl/default/Demux.h +8 −7 Original line number Diff line number Diff line Loading @@ -20,7 +20,10 @@ #include <fmq/AidlMessageQueue.h> #include <math.h> #include <atomic> #include <set> #include <thread> #include "Dvr.h" #include "Filter.h" #include "Frontend.h" Loading Loading @@ -155,12 +158,14 @@ class Demux : public BnDemux { std::shared_ptr<Dvr> mDvrRecord; // Thread handlers pthread_t mFrontendInputThread; std::thread mFrontendInputThread; /** * If a specific filter's writing loop is still running */ bool mFrontendInputThreadRunning; bool mKeepFetchingDataFromFrontend; std::atomic<bool> mFrontendInputThreadRunning; std::atomic<bool> mKeepFetchingDataFromFrontend; /** * If the dvr recording is running. */ Loading @@ -169,10 +174,6 @@ class Demux : public BnDemux { * Lock to protect writes to the FMQs */ std::mutex mWriteLock; /** * Lock to protect writes to the input status */ std::mutex mFrontendInputThreadLock; // temp handle single PES filter // TODO handle mulptiple Pes filters Loading tv/tuner/aidl/default/Dvr.h +1 −1 Original line number Diff line number Diff line Loading @@ -129,7 +129,7 @@ class Dvr : public BnDvr { * If a specific filter's writing loop is still running */ std::atomic<bool> mDvrThreadRunning; bool mKeepFetchingDataFromFrontend; /** * Lock to protect writes to the FMQs */ Loading tv/tuner/aidl/default/Filter.cpp +10 −14 Original line number Diff line number Diff line Loading @@ -85,8 +85,7 @@ Filter::Filter(DemuxFilterType type, int64_t filterId, uint32_t bufferSize, } Filter::~Filter() { mFilterThreadRunning = false; std::lock_guard<std::mutex> lock(mFilterThreadLock); close(); } ::ndk::ScopedAStatus Filter::getId64Bit(int64_t* _aidl_return) { Loading Loading @@ -187,8 +186,12 @@ Filter::~Filter() { ::ndk::ScopedAStatus Filter::stop() { ALOGV("%s", __FUNCTION__); mFilterThreadRunning = false; std::lock_guard<std::mutex> lock(mFilterThreadLock); if (mFilterThread.joinable()) { mFilterThread.join(); } return ::ndk::ScopedAStatus::ok(); } Loading Loading @@ -226,8 +229,8 @@ Filter::~Filter() { ::ndk::ScopedAStatus Filter::close() { ALOGV("%s", __FUNCTION__); mFilterThreadRunning = false; std::lock_guard<std::mutex> lock(mFilterThreadLock); stop(); return mDemux->removeFilter(mFilterId); } Loading Loading @@ -376,22 +379,15 @@ bool Filter::createFilterMQ() { } ::ndk::ScopedAStatus Filter::startFilterLoop() { pthread_create(&mFilterThread, NULL, __threadLoopFilter, this); pthread_setname_np(mFilterThread, "filter_waiting_loop"); mFilterThread = std::thread(&Filter::filterThreadLoop, this); return ::ndk::ScopedAStatus::ok(); } void* Filter::__threadLoopFilter(void* user) { Filter* const self = static_cast<Filter*>(user); self->filterThreadLoop(); return 0; } void Filter::filterThreadLoop() { if (!mFilterThreadRunning) { return; } std::lock_guard<std::mutex> lock(mFilterThreadLock); ALOGD("[Filter] filter %" PRIu64 " threadLoop start.", mFilterId); // For the first time of filter output, implementation needs to send the filter Loading tv/tuner/aidl/default/Filter.h +5 −4 Original line number Diff line number Diff line Loading @@ -24,7 +24,10 @@ #include <ion/ion.h> #include <math.h> #include <sys/stat.h> #include <atomic> #include <set> #include <thread> #include "Demux.h" #include "Dvr.h" #include "Frontend.h" Loading Loading @@ -126,15 +129,14 @@ class Filter : public BnFilter { vector<DemuxFilterEvent> mFilterEvents; // Thread handlers pthread_t mFilterThread; std::thread mFilterThread; // FMQ status local records DemuxFilterStatus mFilterStatus; /** * If a specific filter's writing loop is still running */ bool mFilterThreadRunning; bool mKeepFetchingDataFromFrontend; std::atomic<bool> mFilterThreadRunning; /** * How many times a filter should write Loading Loading @@ -204,7 +206,6 @@ class Filter : public BnFilter { * Lock to protect writes to the input status */ std::mutex mFilterStatusLock; std::mutex mFilterThreadLock; std::mutex mFilterOutputLock; std::mutex mRecordFilterOutputLock; Loading Loading
tv/tuner/aidl/default/Demux.cpp +7 −14 Original line number Diff line number Diff line Loading @@ -37,8 +37,7 @@ Demux::Demux(int32_t demuxId, std::shared_ptr<Tuner> tuner) { } Demux::~Demux() { mFrontendInputThreadRunning = false; std::lock_guard<std::mutex> lock(mFrontendInputThreadLock); close(); } ::ndk::ScopedAStatus Demux::setFrontendDataSource(int32_t in_frontendId) { Loading Loading @@ -171,6 +170,8 @@ Demux::~Demux() { ::ndk::ScopedAStatus Demux::close() { ALOGV("%s", __FUNCTION__); stopFrontendInput(); set<int64_t>::iterator it; for (it = mPlaybackFilterIds.begin(); it != mPlaybackFilterIds.end(); it++) { mDvrPlayback->removePlaybackFilter(*it); Loading @@ -180,8 +181,6 @@ Demux::~Demux() { mFilters.clear(); mLastUsedFilterId = -1; mTuner->removeDemux(mDemuxId); mFrontendInputThreadRunning = false; std::lock_guard<std::mutex> lock(mFrontendInputThreadLock); return ::ndk::ScopedAStatus::ok(); } Loading Loading @@ -345,14 +344,7 @@ uint16_t Demux::getFilterTpid(int64_t filterId) { void Demux::startFrontendInputLoop() { mFrontendInputThreadRunning = true; pthread_create(&mFrontendInputThread, NULL, __threadLoopFrontend, this); pthread_setname_np(mFrontendInputThread, "frontend_input_thread"); } void* Demux::__threadLoopFrontend(void* user) { Demux* const self = static_cast<Demux*>(user); self->frontendInputThreadLoop(); return 0; mFrontendInputThread = std::thread(&Demux::frontendInputThreadLoop, this); } void Demux::frontendInputThreadLoop() { Loading @@ -360,7 +352,6 @@ void Demux::frontendInputThreadLoop() { return; } std::lock_guard<std::mutex> lock(mFrontendInputThreadLock); if (!mDvrPlayback) { ALOGW("[Demux] No software Frontend input configured. Ending Frontend thread loop."); mFrontendInputThreadRunning = false; Loading Loading @@ -402,7 +393,9 @@ void Demux::stopFrontendInput() { ALOGD("[Demux] stop frontend on demux"); mKeepFetchingDataFromFrontend = false; mFrontendInputThreadRunning = false; std::lock_guard<std::mutex> lock(mFrontendInputThreadLock); if (mFrontendInputThread.joinable()) { mFrontendInputThread.join(); } } void Demux::setIsRecording(bool isRecording) { Loading
tv/tuner/aidl/default/Demux.h +8 −7 Original line number Diff line number Diff line Loading @@ -20,7 +20,10 @@ #include <fmq/AidlMessageQueue.h> #include <math.h> #include <atomic> #include <set> #include <thread> #include "Dvr.h" #include "Filter.h" #include "Frontend.h" Loading Loading @@ -155,12 +158,14 @@ class Demux : public BnDemux { std::shared_ptr<Dvr> mDvrRecord; // Thread handlers pthread_t mFrontendInputThread; std::thread mFrontendInputThread; /** * If a specific filter's writing loop is still running */ bool mFrontendInputThreadRunning; bool mKeepFetchingDataFromFrontend; std::atomic<bool> mFrontendInputThreadRunning; std::atomic<bool> mKeepFetchingDataFromFrontend; /** * If the dvr recording is running. */ Loading @@ -169,10 +174,6 @@ class Demux : public BnDemux { * Lock to protect writes to the FMQs */ std::mutex mWriteLock; /** * Lock to protect writes to the input status */ std::mutex mFrontendInputThreadLock; // temp handle single PES filter // TODO handle mulptiple Pes filters Loading
tv/tuner/aidl/default/Dvr.h +1 −1 Original line number Diff line number Diff line Loading @@ -129,7 +129,7 @@ class Dvr : public BnDvr { * If a specific filter's writing loop is still running */ std::atomic<bool> mDvrThreadRunning; bool mKeepFetchingDataFromFrontend; /** * Lock to protect writes to the FMQs */ Loading
tv/tuner/aidl/default/Filter.cpp +10 −14 Original line number Diff line number Diff line Loading @@ -85,8 +85,7 @@ Filter::Filter(DemuxFilterType type, int64_t filterId, uint32_t bufferSize, } Filter::~Filter() { mFilterThreadRunning = false; std::lock_guard<std::mutex> lock(mFilterThreadLock); close(); } ::ndk::ScopedAStatus Filter::getId64Bit(int64_t* _aidl_return) { Loading Loading @@ -187,8 +186,12 @@ Filter::~Filter() { ::ndk::ScopedAStatus Filter::stop() { ALOGV("%s", __FUNCTION__); mFilterThreadRunning = false; std::lock_guard<std::mutex> lock(mFilterThreadLock); if (mFilterThread.joinable()) { mFilterThread.join(); } return ::ndk::ScopedAStatus::ok(); } Loading Loading @@ -226,8 +229,8 @@ Filter::~Filter() { ::ndk::ScopedAStatus Filter::close() { ALOGV("%s", __FUNCTION__); mFilterThreadRunning = false; std::lock_guard<std::mutex> lock(mFilterThreadLock); stop(); return mDemux->removeFilter(mFilterId); } Loading Loading @@ -376,22 +379,15 @@ bool Filter::createFilterMQ() { } ::ndk::ScopedAStatus Filter::startFilterLoop() { pthread_create(&mFilterThread, NULL, __threadLoopFilter, this); pthread_setname_np(mFilterThread, "filter_waiting_loop"); mFilterThread = std::thread(&Filter::filterThreadLoop, this); return ::ndk::ScopedAStatus::ok(); } void* Filter::__threadLoopFilter(void* user) { Filter* const self = static_cast<Filter*>(user); self->filterThreadLoop(); return 0; } void Filter::filterThreadLoop() { if (!mFilterThreadRunning) { return; } std::lock_guard<std::mutex> lock(mFilterThreadLock); ALOGD("[Filter] filter %" PRIu64 " threadLoop start.", mFilterId); // For the first time of filter output, implementation needs to send the filter Loading
tv/tuner/aidl/default/Filter.h +5 −4 Original line number Diff line number Diff line Loading @@ -24,7 +24,10 @@ #include <ion/ion.h> #include <math.h> #include <sys/stat.h> #include <atomic> #include <set> #include <thread> #include "Demux.h" #include "Dvr.h" #include "Frontend.h" Loading Loading @@ -126,15 +129,14 @@ class Filter : public BnFilter { vector<DemuxFilterEvent> mFilterEvents; // Thread handlers pthread_t mFilterThread; std::thread mFilterThread; // FMQ status local records DemuxFilterStatus mFilterStatus; /** * If a specific filter's writing loop is still running */ bool mFilterThreadRunning; bool mKeepFetchingDataFromFrontend; std::atomic<bool> mFilterThreadRunning; /** * How many times a filter should write Loading Loading @@ -204,7 +206,6 @@ class Filter : public BnFilter { * Lock to protect writes to the input status */ std::mutex mFilterStatusLock; std::mutex mFilterThreadLock; std::mutex mFilterOutputLock; std::mutex mRecordFilterOutputLock; Loading