Eliminate delay in MediaDrm.closeSession for widevine CDM
automerge: 16abc11
* commit '16abc110bbb1e44ecbf605ea5eb96cbb1229c5e7':
Eliminate delay in MediaDrm.closeSession for widevine CDM
This commit is contained in:
@@ -8,6 +8,7 @@
|
||||
#include "utils/RefBase.h"
|
||||
#include "utils/StrongPointer.h"
|
||||
#include "utils/Thread.h"
|
||||
#include "utils/Mutex.h"
|
||||
|
||||
namespace wvcdm {
|
||||
|
||||
@@ -15,27 +16,35 @@ class Timer::Impl : virtual public android::RefBase {
|
||||
private:
|
||||
class ImplThread : public android::Thread {
|
||||
public:
|
||||
ImplThread() : Thread(false), handler_(NULL), period_(0) {}
|
||||
ImplThread() : Thread(false), handler_(NULL), period_ns_(0) {}
|
||||
virtual ~ImplThread() {};
|
||||
|
||||
bool Start(TimerHandler *handler, uint32_t time_in_secs) {
|
||||
handler_ = handler;
|
||||
period_ = time_in_secs;
|
||||
period_ns_ = time_in_secs * 1000000000ll;
|
||||
return run() == android::NO_ERROR;
|
||||
}
|
||||
|
||||
void Stop() {
|
||||
{
|
||||
android::Mutex::Autolock autoLock(lock_);
|
||||
stop_condition_.signal();
|
||||
}
|
||||
requestExitAndWait();
|
||||
}
|
||||
|
||||
private:
|
||||
virtual bool threadLoop() {
|
||||
struct timeval timeout;
|
||||
timeout.tv_sec = period_;
|
||||
timeout.tv_usec = 0;
|
||||
TEMP_FAILURE_RETRY(select(0, NULL, NULL, NULL, &timeout));
|
||||
android::Mutex::Autolock autoLock(lock_);
|
||||
stop_condition_.waitRelative(lock_, period_ns_);
|
||||
handler_->OnTimerEvent();
|
||||
return true;
|
||||
}
|
||||
|
||||
TimerHandler *handler_;
|
||||
uint32_t period_;
|
||||
uint64_t period_ns_;
|
||||
android::Mutex lock_;
|
||||
android::Condition stop_condition_;
|
||||
|
||||
CORE_DISALLOW_COPY_AND_ASSIGN(ImplThread);
|
||||
};
|
||||
@@ -52,7 +61,7 @@ class Timer::Impl : virtual public android::RefBase {
|
||||
}
|
||||
|
||||
void Stop() {
|
||||
impl_thread_->requestExitAndWait();
|
||||
impl_thread_->Stop();
|
||||
impl_thread_.clear();
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user