Improve android MediaDrm property latency
[ Merge of http://go/wvgerrit/89848 ] Apps query a number of properties at initialization. The mediaDrm API getProperty allows the query of a single property at a time. This causes a series of requests. If no crypto sessions are concurrently open, a series of expensive OEMCrypto Initialization and Termination calls will occur. In this change OEMCrypto termination is delayed. If an OEMCrypto Terminate is followed in close succession by an Initialize, neither will occur avoiding the overhead. A timer enables a countdown process. If no session activity occurs, the timer will eventually terminate OEMCrypto and exit. Bug: 136282358 Test: Android unit/integration tests Change-Id: I442b7919b4e7835c52583516c8bc64d0c150241d
This commit is contained in:
@@ -28,12 +28,13 @@ class Timer::Impl : virtual public android::RefBase {
|
||||
return run("wvcdm::Timer::Impl") == android::NO_ERROR;
|
||||
}
|
||||
|
||||
void Stop() {
|
||||
{
|
||||
android::Mutex::Autolock autoLock(lock_);
|
||||
stop_condition_.signal();
|
||||
void Stop(bool wait_for_exit) {
|
||||
stop_condition_.signal();
|
||||
if (wait_for_exit) {
|
||||
requestExitAndWait();
|
||||
} else {
|
||||
requestExit();
|
||||
}
|
||||
requestExitAndWait();
|
||||
}
|
||||
|
||||
private:
|
||||
@@ -63,8 +64,8 @@ class Timer::Impl : virtual public android::RefBase {
|
||||
return impl_thread_->Start(handler, time_in_secs);
|
||||
}
|
||||
|
||||
void Stop() {
|
||||
impl_thread_->Stop();
|
||||
void Stop(bool wait_for_exit) {
|
||||
impl_thread_->Stop(wait_for_exit);
|
||||
impl_thread_.clear();
|
||||
}
|
||||
|
||||
@@ -78,7 +79,7 @@ class Timer::Impl : virtual public android::RefBase {
|
||||
Timer::Timer() : impl_(new Timer::Impl()) {}
|
||||
|
||||
Timer::~Timer() {
|
||||
if (IsRunning()) Stop();
|
||||
if (IsRunning()) Stop(false);
|
||||
}
|
||||
|
||||
bool Timer::Start(TimerHandler* handler, uint32_t time_in_secs) {
|
||||
@@ -87,7 +88,7 @@ bool Timer::Start(TimerHandler* handler, uint32_t time_in_secs) {
|
||||
return impl_->Start(handler, time_in_secs);
|
||||
}
|
||||
|
||||
void Timer::Stop() { impl_->Stop(); }
|
||||
void Timer::Stop(bool wait_for_exit) { impl_->Stop(wait_for_exit); }
|
||||
|
||||
bool Timer::IsRunning() { return impl_->IsRunning(); }
|
||||
|
||||
|
||||
Reference in New Issue
Block a user