Commit 276d7cc1 authored by Xiaohan Wang's avatar Xiaohan Wang Committed by Commit Bot

media: Fix CdmAdapter member variable declaration order

Move |cdm_| to the bottom of the declaration list so that it is
destructed first when CdmAdapter is destructed. This would help prevent
|cdm_| from accessing other deleted member during destruction.

Also clean up the declaration of other members to map initialization
order.

BUG=510088

Change-Id: I7c8535c503226089db1d7fd3ce6afcd22bc38dce
Reviewed-on: https://chromium-review.googlesource.com/742327Reviewed-by: default avatarDaniel Cheng <dcheng@chromium.org>
Reviewed-by: default avatarDan Sanders <sandersd@chromium.org>
Commit-Queue: Xiaohan Wang <xhwang@chromium.org>
Cr-Commit-Position: refs/heads/master@{#512620}
parent a0e776e8
......@@ -447,8 +447,6 @@ CdmAdapter::CdmAdapter(
session_closed_cb_(session_closed_cb),
session_keys_change_cb_(session_keys_change_cb),
session_expiration_update_cb_(session_expiration_update_cb),
audio_samples_per_second_(0),
audio_channel_layout_(CHANNEL_LAYOUT_NONE),
helper_(std::move(helper)),
task_runner_(base::ThreadTaskRunnerHandle::Get()),
pool_(new AudioBufferMemoryPool()),
......
......@@ -204,12 +204,8 @@ class MEDIA_EXPORT CdmAdapter : public ContentDecryptionModule,
uint32_t link_mask,
uint32_t protection_mask);
// Used to keep track of promises while the CDM is processing the request.
CdmPromiseAdapter cdm_promise_adapter_;
std::unique_ptr<CdmWrapper> cdm_;
std::string key_system_;
CdmConfig cdm_config_;
const std::string key_system_;
const CdmConfig cdm_config_;
// Callbacks for firing session events.
SessionMessageCB session_message_cb_;
......@@ -217,6 +213,12 @@ class MEDIA_EXPORT CdmAdapter : public ContentDecryptionModule,
SessionKeysChangeCB session_keys_change_cb_;
SessionExpirationUpdateCB session_expiration_update_cb_;
// Helper that provides additional functionality for the CDM.
std::unique_ptr<CdmAuxiliaryHelper> helper_;
scoped_refptr<base::SingleThreadTaskRunner> task_runner_;
scoped_refptr<AudioBufferMemoryPool> pool_;
// Callbacks for deferred initialization.
DecoderInitCB audio_init_cb_;
DecoderInitCB video_init_cb_;
......@@ -225,20 +227,20 @@ class MEDIA_EXPORT CdmAdapter : public ContentDecryptionModule,
NewKeyCB new_audio_key_cb_;
NewKeyCB new_video_key_cb_;
// Keep track of audio parameters.
int audio_samples_per_second_ = 0;
ChannelLayout audio_channel_layout_ = CHANNEL_LAYOUT_NONE;
// Keep track of video frame natural size from the latest configuration
// as the CDM doesn't provide it.
gfx::Size natural_size_;
// Keep track of audio parameters.
int audio_samples_per_second_;
ChannelLayout audio_channel_layout_;
// Helper that provides additional functionality for the CDM.
std::unique_ptr<CdmAuxiliaryHelper> helper_;
scoped_refptr<base::SingleThreadTaskRunner> task_runner_;
// Used to keep track of promises while the CDM is processing the request.
CdmPromiseAdapter cdm_promise_adapter_;
scoped_refptr<AudioBufferMemoryPool> pool_;
// Declare |cdm_| after other member variables to avoid the CDM accessing
// deleted objects (e.g. |helper_|) during destruction.
std::unique_ptr<CdmWrapper> cdm_;
// NOTE: Weak pointers must be invalidated before all other member variables.
base::WeakPtrFactory<CdmAdapter> weak_factory_;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment