From 4519dda07c2147a237d1951cfade3edfa92e091d Mon Sep 17 00:00:00 2001 From: KongQun Yang Date: Mon, 23 Jun 2014 15:22:11 -0700 Subject: [PATCH] Fix a race condition in WidevineEncryptionKeySource The race condition could cause incorrect progress in current crypto period index. Change-Id: I76a1a3be16e2266fd07b5bbf73cb9470eafaac4b --- media/base/widevine_encryption_key_source.cc | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/media/base/widevine_encryption_key_source.cc b/media/base/widevine_encryption_key_source.cc index 0b318b2f76..0e1c4efb13 100644 --- a/media/base/widevine_encryption_key_source.cc +++ b/media/base/widevine_encryption_key_source.cc @@ -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); }