Fix a race condition in WidevineEncryptionKeySource

The race condition could cause incorrect progress in current crypto
period index.

Change-Id: I76a1a3be16e2266fd07b5bbf73cb9470eafaac4b
This commit is contained in:
KongQun Yang 2014-06-23 15:22:11 -07:00
parent 0f49af6cc1
commit 4519dda07c
1 changed files with 4 additions and 1 deletions

View File

@ -154,12 +154,15 @@ WidevineEncryptionKeySource::~WidevineEncryptionKeySource() {
}
Status WidevineEncryptionKeySource::Initialize() {
// |first_crypto_period_index| might be updated after starting production.
// Make a local copy for prime later.
const uint32 first_crypto_period_index = first_crypto_period_index_;
DCHECK(!key_production_thread_.HasBeenStarted());
key_production_thread_.Start();
// Perform a GetKey request to find out common encryption request status.
// It also primes the key_pool if successful.
return key_rotation_enabled_ ? GetCryptoPeriodKey(first_crypto_period_index_,
return key_rotation_enabled_ ? GetCryptoPeriodKey(first_crypto_period_index,
TRACK_TYPE_SD, NULL)
: GetKey(TRACK_TYPE_SD, NULL);
}