Refine tuner aidl hal threads.
Bug: 197763854
Test: VtsHalTvTunerTargetTest
Test: atest android.media.tv.tuner.cts
Test: sampletunertvinput
Change-Id: Id707438178ed93731919f0155cab805436147f86
diff --git a/tv/tuner/aidl/default/Demux.h b/tv/tuner/aidl/default/Demux.h
index 4d9b7fe..1b789bd 100644
--- a/tv/tuner/aidl/default/Demux.h
+++ b/tv/tuner/aidl/default/Demux.h
@@ -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"
@@ -155,12 +158,14 @@
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.
*/
@@ -169,10 +174,6 @@
* 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