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

Side by Side Diff: media/filters/ffmpeg_glue.cc

Issue 684763005: FFmpeg: Only use LazyInstance at global scope (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Use g_ for global variable name Created 6 years, 1 month 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 unified diff | Download patch
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "media/filters/ffmpeg_glue.h" 5 #include "media/filters/ffmpeg_glue.h"
6 6
7 #include "base/lazy_instance.h" 7 #include "base/lazy_instance.h"
8 #include "base/logging.h" 8 #include "base/logging.h"
9 #include "base/metrics/sparse_histogram.h" 9 #include "base/metrics/sparse_histogram.h"
10 #include "base/synchronization/lock.h" 10 #include "base/synchronization/lock.h"
(...skipping 100 matching lines...) Expand 10 before | Expand all | Expand 10 after
111 111
112 ~FFmpegInitializer() { 112 ~FFmpegInitializer() {
113 NOTREACHED() << "FFmpegInitializer should be leaky!"; 113 NOTREACHED() << "FFmpegInitializer should be leaky!";
114 } 114 }
115 115
116 bool initialized_; 116 bool initialized_;
117 117
118 DISALLOW_COPY_AND_ASSIGN(FFmpegInitializer); 118 DISALLOW_COPY_AND_ASSIGN(FFmpegInitializer);
119 }; 119 };
120 120
121 static base::LazyInstance<FFmpegInitializer>::Leaky g_lazy_instance =
122 LAZY_INSTANCE_INITIALIZER;
121 void FFmpegGlue::InitializeFFmpeg() { 123 void FFmpegGlue::InitializeFFmpeg() {
122 static base::LazyInstance<FFmpegInitializer>::Leaky li = 124 // Get() will invoke the FFmpegInitializer constructor once.
123 LAZY_INSTANCE_INITIALIZER; 125 CHECK(g_lazy_instance.Get().initialized());
124 CHECK(li.Get().initialized());
125 } 126 }
126 127
127 FFmpegGlue::FFmpegGlue(FFmpegURLProtocol* protocol) 128 FFmpegGlue::FFmpegGlue(FFmpegURLProtocol* protocol)
128 : open_called_(false) { 129 : open_called_(false) {
129 InitializeFFmpeg(); 130 InitializeFFmpeg();
130 131
131 // Initialize an AVIOContext using our custom read and seek operations. Don't 132 // Initialize an AVIOContext using our custom read and seek operations. Don't
132 // keep pointers to the buffer since FFmpeg may reallocate it on the fly. It 133 // keep pointers to the buffer since FFmpeg may reallocate it on the fly. It
133 // will be cleaned up 134 // will be cleaned up
134 format_context_ = avformat_alloc_context(); 135 format_context_ = avformat_alloc_context();
(...skipping 78 matching lines...) Expand 10 before | Expand all | Expand 10 after
213 avcodec_close(stream->codec); 214 avcodec_close(stream->codec);
214 } 215 }
215 } 216 }
216 } 217 }
217 218
218 avformat_close_input(&format_context_); 219 avformat_close_input(&format_context_);
219 av_free(avio_context_->buffer); 220 av_free(avio_context_->buffer);
220 } 221 }
221 222
222 } // namespace media 223 } // namespace media
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698