mirror of
https://github.com/Evolution-X/hardware_interfaces
synced 2026-02-02 02:42:35 +00:00
Merge changes I388fc2b8,I639e8314
* changes: Remove Unused Function Declarations from DVR Default Implementation Clean Up Playback Thread in DVR Test Implementation
This commit is contained in:
@@ -37,7 +37,10 @@ Dvr::Dvr(DvrType type, uint32_t bufferSize, const sp<IDvrCallback>& cb, sp<Demux
|
||||
mDemux = demux;
|
||||
}
|
||||
|
||||
Dvr::~Dvr() {}
|
||||
Dvr::~Dvr() {
|
||||
// make sure thread has joined
|
||||
close();
|
||||
}
|
||||
|
||||
Return<void> Dvr::getQueueDesc(getQueueDesc_cb _hidl_cb) {
|
||||
ALOGV("%s", __FUNCTION__);
|
||||
@@ -112,8 +115,7 @@ Return<Result> Dvr::start() {
|
||||
}
|
||||
|
||||
if (mType == DvrType::PLAYBACK) {
|
||||
pthread_create(&mDvrThread, NULL, __threadLoopPlayback, this);
|
||||
pthread_setname_np(mDvrThread, "playback_waiting_loop");
|
||||
mDvrThread = std::thread(&Dvr::playbackThreadLoop, this);
|
||||
} else if (mType == DvrType::RECORD) {
|
||||
mRecordStatus = RecordStatus::DATA_READY;
|
||||
mDemux->setIsRecording(mType == DvrType::RECORD);
|
||||
@@ -128,9 +130,11 @@ Return<Result> Dvr::stop() {
|
||||
ALOGV("%s", __FUNCTION__);
|
||||
|
||||
mDvrThreadRunning = false;
|
||||
|
||||
lock_guard<mutex> lock(mDvrThreadLock);
|
||||
|
||||
if (mDvrThread.joinable()) {
|
||||
mDvrThread.join();
|
||||
}
|
||||
// thread should always be joinable if it is running,
|
||||
// so it should be safe to assume recording stopped.
|
||||
mDemux->setIsRecording(false);
|
||||
|
||||
return Result::SUCCESS;
|
||||
@@ -146,7 +150,7 @@ Return<Result> Dvr::flush() {
|
||||
|
||||
Return<Result> Dvr::close() {
|
||||
ALOGV("%s", __FUNCTION__);
|
||||
|
||||
stop();
|
||||
return Result::SUCCESS;
|
||||
}
|
||||
|
||||
@@ -173,15 +177,8 @@ EventFlag* Dvr::getDvrEventFlag() {
|
||||
return mDvrEventFlag;
|
||||
}
|
||||
|
||||
void* Dvr::__threadLoopPlayback(void* user) {
|
||||
Dvr* const self = static_cast<Dvr*>(user);
|
||||
self->playbackThreadLoop();
|
||||
return 0;
|
||||
}
|
||||
|
||||
void Dvr::playbackThreadLoop() {
|
||||
ALOGD("[Dvr] playback threadLoop start.");
|
||||
lock_guard<mutex> lock(mDvrThreadLock);
|
||||
mDvrThreadRunning = true;
|
||||
|
||||
while (mDvrThreadRunning) {
|
||||
|
||||
@@ -20,7 +20,9 @@
|
||||
#include <android/hardware/tv/tuner/1.0/IDvr.h>
|
||||
#include <fmq/MessageQueue.h>
|
||||
#include <math.h>
|
||||
#include <atomic>
|
||||
#include <set>
|
||||
#include <thread>
|
||||
#include "Demux.h"
|
||||
#include "Frontend.h"
|
||||
#include "Tuner.h"
|
||||
@@ -119,10 +121,7 @@ class Dvr : public IDvr {
|
||||
* Each filter handler handles the data filtering/output writing/filterEvent updating.
|
||||
*/
|
||||
void startTpidFilter(vector<uint8_t> data);
|
||||
static void* __threadLoopPlayback(void* user);
|
||||
static void* __threadLoopRecord(void* user);
|
||||
void playbackThreadLoop();
|
||||
void recordThreadLoop();
|
||||
|
||||
unique_ptr<DvrMQ> mDvrMQ;
|
||||
EventFlag* mDvrEventFlag;
|
||||
@@ -133,7 +132,7 @@ class Dvr : public IDvr {
|
||||
DvrSettings mDvrSettings;
|
||||
|
||||
// Thread handlers
|
||||
pthread_t mDvrThread;
|
||||
std::thread mDvrThread;
|
||||
|
||||
// FMQ status local records
|
||||
PlaybackStatus mPlaybackStatus;
|
||||
@@ -141,7 +140,7 @@ class Dvr : public IDvr {
|
||||
/**
|
||||
* If a specific filter's writing loop is still running
|
||||
*/
|
||||
bool mDvrThreadRunning;
|
||||
std::atomic<bool> mDvrThreadRunning;
|
||||
bool mKeepFetchingDataFromFrontend;
|
||||
/**
|
||||
* Lock to protect writes to the FMQs
|
||||
@@ -152,7 +151,6 @@ class Dvr : public IDvr {
|
||||
*/
|
||||
std::mutex mPlaybackStatusLock;
|
||||
std::mutex mRecordStatusLock;
|
||||
std::mutex mDvrThreadLock;
|
||||
|
||||
const bool DEBUG_DVR = false;
|
||||
};
|
||||
|
||||
@@ -38,8 +38,8 @@ Dvr::Dvr(DvrType type, uint32_t bufferSize, const sp<IDvrCallback>& cb, sp<Demux
|
||||
}
|
||||
|
||||
Dvr::~Dvr() {
|
||||
mDvrThreadRunning = false;
|
||||
lock_guard<mutex> lock(mDvrThreadLock);
|
||||
// make sure thread has joined
|
||||
close();
|
||||
}
|
||||
|
||||
Return<void> Dvr::getQueueDesc(getQueueDesc_cb _hidl_cb) {
|
||||
@@ -134,8 +134,7 @@ Return<Result> Dvr::start() {
|
||||
|
||||
if (mType == DvrType::PLAYBACK) {
|
||||
mDvrThreadRunning = true;
|
||||
pthread_create(&mDvrThread, NULL, __threadLoopPlayback, this);
|
||||
pthread_setname_np(mDvrThread, "playback_waiting_loop");
|
||||
mDvrThread = std::thread(&Dvr::playbackThreadLoop, this);
|
||||
} else if (mType == DvrType::RECORD) {
|
||||
mRecordStatus = RecordStatus::DATA_READY;
|
||||
mDemux->setIsRecording(mType == DvrType::RECORD);
|
||||
@@ -150,8 +149,11 @@ Return<Result> Dvr::stop() {
|
||||
ALOGV("%s", __FUNCTION__);
|
||||
|
||||
mDvrThreadRunning = false;
|
||||
lock_guard<mutex> lock(mDvrThreadLock);
|
||||
|
||||
if (mDvrThread.joinable()) {
|
||||
mDvrThread.join();
|
||||
}
|
||||
// thread should always be joinable if it is running,
|
||||
// so it should be safe to assume recording stopped.
|
||||
mDemux->setIsRecording(false);
|
||||
|
||||
return Result::SUCCESS;
|
||||
@@ -167,9 +169,7 @@ Return<Result> Dvr::flush() {
|
||||
|
||||
Return<Result> Dvr::close() {
|
||||
ALOGV("%s", __FUNCTION__);
|
||||
|
||||
mDvrThreadRunning = false;
|
||||
lock_guard<mutex> lock(mDvrThreadLock);
|
||||
stop();
|
||||
return Result::SUCCESS;
|
||||
}
|
||||
|
||||
@@ -196,15 +196,8 @@ EventFlag* Dvr::getDvrEventFlag() {
|
||||
return mDvrEventFlag;
|
||||
}
|
||||
|
||||
void* Dvr::__threadLoopPlayback(void* user) {
|
||||
Dvr* const self = static_cast<Dvr*>(user);
|
||||
self->playbackThreadLoop();
|
||||
return 0;
|
||||
}
|
||||
|
||||
void Dvr::playbackThreadLoop() {
|
||||
ALOGD("[Dvr] playback threadLoop start.");
|
||||
lock_guard<mutex> lock(mDvrThreadLock);
|
||||
|
||||
while (mDvrThreadRunning) {
|
||||
uint32_t efState = 0;
|
||||
|
||||
@@ -19,7 +19,9 @@
|
||||
|
||||
#include <fmq/MessageQueue.h>
|
||||
#include <math.h>
|
||||
#include <atomic>
|
||||
#include <set>
|
||||
#include <thread>
|
||||
#include "Demux.h"
|
||||
#include "Frontend.h"
|
||||
#include "Tuner.h"
|
||||
@@ -115,10 +117,7 @@ class Dvr : public IDvr {
|
||||
* Each filter handler handles the data filtering/output writing/filterEvent updating.
|
||||
*/
|
||||
void startTpidFilter(vector<uint8_t> data);
|
||||
static void* __threadLoopPlayback(void* user);
|
||||
static void* __threadLoopRecord(void* user);
|
||||
void playbackThreadLoop();
|
||||
void recordThreadLoop();
|
||||
|
||||
unique_ptr<DvrMQ> mDvrMQ;
|
||||
EventFlag* mDvrEventFlag;
|
||||
@@ -129,7 +128,7 @@ class Dvr : public IDvr {
|
||||
DvrSettings mDvrSettings;
|
||||
|
||||
// Thread handlers
|
||||
pthread_t mDvrThread;
|
||||
std::thread mDvrThread;
|
||||
|
||||
// FMQ status local records
|
||||
PlaybackStatus mPlaybackStatus;
|
||||
@@ -137,7 +136,7 @@ class Dvr : public IDvr {
|
||||
/**
|
||||
* If a specific filter's writing loop is still running
|
||||
*/
|
||||
bool mDvrThreadRunning;
|
||||
std::atomic<bool> mDvrThreadRunning;
|
||||
bool mKeepFetchingDataFromFrontend;
|
||||
/**
|
||||
* Lock to protect writes to the FMQs
|
||||
@@ -148,7 +147,6 @@ class Dvr : public IDvr {
|
||||
*/
|
||||
std::mutex mPlaybackStatusLock;
|
||||
std::mutex mRecordStatusLock;
|
||||
std::mutex mDvrThreadLock;
|
||||
|
||||
const bool DEBUG_DVR = false;
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user