Commit f931a13b authored by Sergey Ulanov's avatar Sergey Ulanov Committed by Commit Bot

[Fuchsia] Destroy audio decryptor on the right thread

Previously FuchsiaDecryptor was destroying FuchsiaClearStreamDecryptor
in the destructor which may run on a thread that's different than the
thread on which FuchsiaClearStreamDecryptor was created. Updated
FuchsiaDecryptor destructor to delete audio_decryptor_ asynchronously
on the right thread.

Bug: 1047783
Change-Id: I9c4dc5d7a292078eb632c0c44be6a68cc949b7e6
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2033813
Commit-Queue: Sergey Ulanov <sergeyu@chromium.org>
Reviewed-by: default avatarDavid Dorwin <ddorwin@chromium.org>
Auto-Submit: Sergey Ulanov <sergeyu@chromium.org>
Cr-Commit-Position: refs/heads/master@{#738277}
parent df0f4722
...@@ -5,7 +5,9 @@ ...@@ -5,7 +5,9 @@
#include "media/fuchsia/cdm/fuchsia_decryptor.h" #include "media/fuchsia/cdm/fuchsia_decryptor.h"
#include "base/fuchsia/fuchsia_logging.h" #include "base/fuchsia/fuchsia_logging.h"
#include "base/location.h"
#include "base/logging.h" #include "base/logging.h"
#include "base/threading/thread_task_runner_handle.h"
#include "media/base/decoder_buffer.h" #include "media/base/decoder_buffer.h"
#include "media/base/video_frame.h" #include "media/base/video_frame.h"
#include "media/fuchsia/cdm/fuchsia_stream_decryptor.h" #include "media/fuchsia/cdm/fuchsia_stream_decryptor.h"
...@@ -18,7 +20,12 @@ FuchsiaDecryptor::FuchsiaDecryptor( ...@@ -18,7 +20,12 @@ FuchsiaDecryptor::FuchsiaDecryptor(
DCHECK(cdm_); DCHECK(cdm_);
} }
FuchsiaDecryptor::~FuchsiaDecryptor() = default; FuchsiaDecryptor::~FuchsiaDecryptor() {
if (audio_decryptor_) {
audio_decryptor_task_runner_->DeleteSoon(FROM_HERE,
std::move(audio_decryptor_));
}
}
void FuchsiaDecryptor::RegisterNewKeyCB(StreamType stream_type, void FuchsiaDecryptor::RegisterNewKeyCB(StreamType stream_type,
const NewKeyCB& new_key_cb) { const NewKeyCB& new_key_cb) {
...@@ -37,8 +44,10 @@ void FuchsiaDecryptor::Decrypt(StreamType stream_type, ...@@ -37,8 +44,10 @@ void FuchsiaDecryptor::Decrypt(StreamType stream_type,
return; return;
} }
if (!audio_decryptor_) if (!audio_decryptor_) {
audio_decryptor_task_runner_ = base::ThreadTaskRunnerHandle::Get();
audio_decryptor_ = FuchsiaClearStreamDecryptor::Create(cdm_); audio_decryptor_ = FuchsiaClearStreamDecryptor::Create(cdm_);
}
audio_decryptor_->Decrypt(std::move(encrypted), decrypt_cb); audio_decryptor_->Decrypt(std::move(encrypted), decrypt_cb);
} }
......
...@@ -7,6 +7,8 @@ ...@@ -7,6 +7,8 @@
#include <memory> #include <memory>
#include "base/memory/ref_counted.h"
#include "base/single_thread_task_runner.h"
#include "base/synchronization/lock.h" #include "base/synchronization/lock.h"
#include "base/thread_annotations.h" #include "base/thread_annotations.h"
#include "media/base/decryptor.h" #include "media/base/decryptor.h"
...@@ -60,6 +62,9 @@ class FuchsiaDecryptor : public Decryptor { ...@@ -60,6 +62,9 @@ class FuchsiaDecryptor : public Decryptor {
std::unique_ptr<FuchsiaClearStreamDecryptor> audio_decryptor_; std::unique_ptr<FuchsiaClearStreamDecryptor> audio_decryptor_;
// TaskRunner for the thread on which |audio_decryptor_| was created.
scoped_refptr<base::SingleThreadTaskRunner> audio_decryptor_task_runner_;
DISALLOW_COPY_AND_ASSIGN(FuchsiaDecryptor); DISALLOW_COPY_AND_ASSIGN(FuchsiaDecryptor);
}; };
......
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