Chromium Code Reviews| OLD | NEW |
|---|---|
| 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 Loading... | |
| 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 lazy_instance = | |
|
DaleCurtis
2014/10/31 18:20:09
g_ffmpeg_initializer ?
| |
| 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(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 Loading... | |
| 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 |
| OLD | NEW |