Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(837)

Unified Diff: media/filters/vpx_video_decoder.cc

Issue 2668813002: Remove LazyInstance usage from media/ (Closed)
Patch Set: Fix presubmit comments. Created 3 years, 10 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « media/filters/ffmpeg_glue.cc ('k') | media/gpu/android_video_decode_accelerator.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: media/filters/vpx_video_decoder.cc
diff --git a/media/filters/vpx_video_decoder.cc b/media/filters/vpx_video_decoder.cc
index 9f8d786ce2d99b00faab09c8d6cec4aa334e002b..07b1bed0b5cb0ae9807b3cfb54061200cf95195b 100644
--- a/media/filters/vpx_video_decoder.cc
+++ b/media/filters/vpx_video_decoder.cc
@@ -15,7 +15,6 @@
#include "base/bind.h"
#include "base/callback_helpers.h"
#include "base/command_line.h"
-#include "base/lazy_instance.h"
#include "base/location.h"
#include "base/logging.h"
#include "base/macros.h"
@@ -111,8 +110,10 @@ class VpxOffloadThread {
DISALLOW_COPY_AND_ASSIGN(VpxOffloadThread);
};
-static base::LazyInstance<VpxOffloadThread>::Leaky g_vpx_offload_thread =
- LAZY_INSTANCE_INITIALIZER;
+static VpxOffloadThread* GetOffloadThread() {
+ static VpxOffloadThread* thread = new VpxOffloadThread();
+ return thread;
+}
// Always try to use three threads for video decoding. There is little reason
// not to since current day CPUs tend to be multi-core and we measured
@@ -442,7 +443,7 @@ void VpxVideoDecoder::Decode(const scoped_refptr<DecoderBuffer>& buffer,
void VpxVideoDecoder::Reset(const base::Closure& closure) {
DCHECK(thread_checker_.CalledOnValidThread());
if (offload_task_runner_)
- g_vpx_offload_thread.Pointer()->WaitForOutstandingTasks();
+ GetOffloadThread()->WaitForOutstandingTasks();
state_ = kNormal;
// PostTask() to avoid calling |closure| inmediately.
@@ -484,8 +485,7 @@ bool VpxVideoDecoder::ConfigureDecoder(const VideoDecoderConfig& config) {
// Move high resolution vp9 decodes off of the main media thread (otherwise
// decode may block audio decoding, demuxing, and other control activities).
if (config.coded_size().width() >= 1024) {
- offload_task_runner_ =
- g_vpx_offload_thread.Pointer()->RequestOffloadThread();
+ offload_task_runner_ = GetOffloadThread()->RequestOffloadThread();
}
DCHECK(!memory_pool_);
@@ -513,8 +513,7 @@ bool VpxVideoDecoder::ConfigureDecoder(const VideoDecoderConfig& config) {
void VpxVideoDecoder::CloseDecoder() {
if (offload_task_runner_) {
- g_vpx_offload_thread.Pointer()
- ->WaitForOutstandingTasksAndReleaseOffloadThread();
+ GetOffloadThread()->WaitForOutstandingTasksAndReleaseOffloadThread();
offload_task_runner_ = nullptr;
}
« no previous file with comments | « media/filters/ffmpeg_glue.cc ('k') | media/gpu/android_video_decode_accelerator.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698