From 661e5229fbc3f71714d70505396e0e04b28142e0 Mon Sep 17 00:00:00 2001 From: Xiaohan Wang Date: Tue, 15 Jan 2019 02:24:33 +0000 Subject: [PATCH] media: Misc cleanup in Decrypting{Audio,Video}Decoder No functionality change. Change-Id: I4c28ac1c1944cbb2cd8e274c578ff45ec6e715b8 Reviewed-on: https://chromium-review.googlesource.com/c/1409848 Reviewed-by: John Rummell Commit-Queue: Xiaohan Wang Cr-Commit-Position: refs/heads/master@{#622684} --- media/filters/decrypting_audio_decoder.cc | 8 +------- media/filters/decrypting_audio_decoder.h | 14 +++++++------- media/filters/decrypting_video_decoder.cc | 8 +------- media/filters/decrypting_video_decoder.h | 14 +++++++------- 4 files changed, 16 insertions(+), 28 deletions(-) diff --git a/media/filters/decrypting_audio_decoder.cc b/media/filters/decrypting_audio_decoder.cc index 2c8020d908d2a..ed41d539c67fb 100644 --- a/media/filters/decrypting_audio_decoder.cc +++ b/media/filters/decrypting_audio_decoder.cc @@ -37,13 +37,7 @@ static inline bool IsOutOfSync(const base::TimeDelta& timestamp_1, DecryptingAudioDecoder::DecryptingAudioDecoder( const scoped_refptr& task_runner, MediaLog* media_log) - : task_runner_(task_runner), - media_log_(media_log), - state_(kUninitialized), - decryptor_(NULL), - key_added_while_decode_pending_(false), - support_clear_content_(false), - weak_factory_(this) {} + : task_runner_(task_runner), media_log_(media_log), weak_factory_(this) {} std::string DecryptingAudioDecoder::GetDisplayName() const { return "DecryptingAudioDecoder"; diff --git a/media/filters/decrypting_audio_decoder.h b/media/filters/decrypting_audio_decoder.h index abc1d089b82e3..95f8d23429567 100644 --- a/media/filters/decrypting_audio_decoder.h +++ b/media/filters/decrypting_audio_decoder.h @@ -88,11 +88,11 @@ class MEDIA_EXPORT DecryptingAudioDecoder : public AudioDecoder { // Sets timestamps for |frames| and then passes them to |output_cb_|. void ProcessDecodedFrames(const Decryptor::AudioFrames& frames); - scoped_refptr task_runner_; + // Set in constructor. + scoped_refptr const task_runner_; + MediaLog* const media_log_; - MediaLog* media_log_; - - State state_; + State state_ = kUninitialized; InitCB init_cb_; OutputCB output_cb_; @@ -103,7 +103,7 @@ class MEDIA_EXPORT DecryptingAudioDecoder : public AudioDecoder { // The current decoder configuration. AudioDecoderConfig config_; - Decryptor* decryptor_; + Decryptor* decryptor_ = nullptr; // The buffer that needs decrypting/decoding. scoped_refptr pending_buffer_to_decode_; @@ -113,13 +113,13 @@ class MEDIA_EXPORT DecryptingAudioDecoder : public AudioDecoder { // If this variable is true and kNoKey is returned then we need to try // decrypting/decoding again in case the newly added key is the correct // decryption key. - bool key_added_while_decode_pending_; + bool key_added_while_decode_pending_ = false; std::unique_ptr timestamp_helper_; // Once Initialized() with encrypted content support, if the stream changes to // clear content, we want to ensure this decoder remains used. - bool support_clear_content_; + bool support_clear_content_ = false; base::WeakPtr weak_this_; base::WeakPtrFactory weak_factory_; diff --git a/media/filters/decrypting_video_decoder.cc b/media/filters/decrypting_video_decoder.cc index 32ed82c2eab83..1c0a3a975cf26 100644 --- a/media/filters/decrypting_video_decoder.cc +++ b/media/filters/decrypting_video_decoder.cc @@ -24,13 +24,7 @@ const char DecryptingVideoDecoder::kDecoderName[] = "DecryptingVideoDecoder"; DecryptingVideoDecoder::DecryptingVideoDecoder( const scoped_refptr& task_runner, MediaLog* media_log) - : task_runner_(task_runner), - media_log_(media_log), - state_(kUninitialized), - decryptor_(NULL), - key_added_while_decode_pending_(false), - support_clear_content_(false), - weak_factory_(this) {} + : task_runner_(task_runner), media_log_(media_log), weak_factory_(this) {} std::string DecryptingVideoDecoder::GetDisplayName() const { return kDecoderName; diff --git a/media/filters/decrypting_video_decoder.h b/media/filters/decrypting_video_decoder.h index a9229c97b6b87..03cec55319598 100644 --- a/media/filters/decrypting_video_decoder.h +++ b/media/filters/decrypting_video_decoder.h @@ -84,11 +84,11 @@ class MEDIA_EXPORT DecryptingVideoDecoder : public VideoDecoder { void CompletePendingDecode(Decryptor::Status status); void CompleteWaitingForDecryptionKey(); - scoped_refptr task_runner_; + // Set in constructor. + scoped_refptr const task_runner_; + MediaLog* const media_log_; - MediaLog* media_log_; - - State state_; + State state_ = kUninitialized; InitCB init_cb_; OutputCB output_cb_; @@ -98,7 +98,7 @@ class MEDIA_EXPORT DecryptingVideoDecoder : public VideoDecoder { VideoDecoderConfig config_; - Decryptor* decryptor_; + Decryptor* decryptor_ = nullptr; // The buffer that needs decrypting/decoding. scoped_refptr pending_buffer_to_decode_; @@ -108,11 +108,11 @@ class MEDIA_EXPORT DecryptingVideoDecoder : public VideoDecoder { // If this variable is true and kNoKey is returned then we need to try // decrypting/decoding again in case the newly added key is the correct // decryption key. - bool key_added_while_decode_pending_; + bool key_added_while_decode_pending_ = false; // Once Initialized() with encrypted content support, if the stream changes to // clear content, we want to ensure this decoder remains used. - bool support_clear_content_; + bool support_clear_content_ = false; base::WeakPtr weak_this_; base::WeakPtrFactory weak_factory_;