Lock session list in CdmEngine OnTimerEvent (master)
Cherry pick of https://widevine-internal-review.googlesource.com/#/c/12935/ Change-Id: I029d36b2b6d092ae938fca2a7f6d893814c25a8a
This commit is contained in:
@@ -138,9 +138,16 @@ class CdmEngine {
|
||||
virtual bool IsKeyLoaded(const KeyId& key_id);
|
||||
virtual bool FindSessionForKey(const KeyId& key_id, CdmSessionId* sessionId);
|
||||
|
||||
// Event listener related methods
|
||||
// Event listener related methods.
|
||||
|
||||
// We assume that the WvCdmEventListener is asynchronous -- i.e. an event
|
||||
// should be dispatched to another thread which actually does the work. In
|
||||
// particular, if a syncrhonous listener calls OpenSession or CloseSession,
|
||||
// the thread will dead lock.
|
||||
// Returns false if listener already attached.
|
||||
virtual bool AttachEventListener(const CdmSessionId& session_id,
|
||||
WvCdmEventListener* listener);
|
||||
// Returns true if listener was detached.
|
||||
virtual bool DetachEventListener(const CdmSessionId& session_id,
|
||||
WvCdmEventListener* listener);
|
||||
|
||||
@@ -148,7 +155,8 @@ class CdmEngine {
|
||||
virtual void NotifyResolution(const CdmSessionId& session_id, uint32_t width,
|
||||
uint32_t height);
|
||||
|
||||
// Timer expiration method
|
||||
// Timer expiration method. This method is not re-entrant -- there can be
|
||||
// only one timer.
|
||||
virtual void OnTimerEvent();
|
||||
|
||||
private:
|
||||
@@ -175,11 +183,13 @@ class CdmEngine {
|
||||
scoped_ptr<UsagePropertySet> usage_property_set_;
|
||||
int64_t last_usage_information_update_time_;
|
||||
|
||||
// Locks the list of sessions, |sessions_|, for the event timer. It will be
|
||||
// locked in OpenSession, CloseSession. It is also locked in OnTimerEvent and
|
||||
// OnKeyReleaseEvent while the list of event listeners is being generated.
|
||||
// The layer above the CDM implementation is expected to handle thread
|
||||
// synchronization to make sure other functions that access sessions do not
|
||||
// occur simultaneously with OpenSession or CloseSession.
|
||||
Lock session_list_lock_;
|
||||
// If the timer is currently active -- do not delete any sessions.
|
||||
bool timer_event_active_;
|
||||
// Sessions to be deleted after the timer has finished.
|
||||
std::vector<CdmSession*> dead_sessions_;
|
||||
|
||||
CORE_DISALLOW_COPY_AND_ASSIGN(CdmEngine);
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user