summaryrefslogtreecommitdiffstats
path: root/media
diff options
context:
space:
mode:
authorscherkus@chromium.org <scherkus@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2009-06-05 02:15:05 +0000
committerscherkus@chromium.org <scherkus@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2009-06-05 02:15:05 +0000
commitb571b647170a0a4711f588c665ad2d582f10018c (patch)
tree5aa36883a50893e407b51372cb1837b223e0b5bc /media
parent4c62d8c3a0ad1c141976135d7622516eb02e46c5 (diff)
downloadchromium_src-b571b647170a0a4711f588c665ad2d582f10018c.zip
chromium_src-b571b647170a0a4711f588c665ad2d582f10018c.tar.gz
chromium_src-b571b647170a0a4711f588c665ad2d582f10018c.tar.bz2
Serialized av_find_stream_info() with a Singleton Lock.
Review URL: http://codereview.chromium.org/118294 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@17704 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'media')
-rw-r--r--media/filters/ffmpeg_demuxer.cc35
1 files changed, 30 insertions, 5 deletions
diff --git a/media/filters/ffmpeg_demuxer.cc b/media/filters/ffmpeg_demuxer.cc
index dd37a3a..41b3314 100644
--- a/media/filters/ffmpeg_demuxer.cc
+++ b/media/filters/ffmpeg_demuxer.cc
@@ -12,6 +12,26 @@
namespace media {
+// FFmpegLock is used to serialize calls to av_find_stream_info() for an entire
+// process because for whatever reason it does Very Bad Things to other demuxers
+// also calling av_find_stream_info().
+//
+// TODO(scherkus): track down and upstream a fix to FFmpeg.
+class FFmpegLock : public Singleton<FFmpegLock> {
+ public:
+ Lock& lock() { return lock_; }
+
+ private:
+ // Only allow Singleton to create and delete FFmpegLock.
+ friend struct DefaultSingletonTraits<FFmpegLock>;
+ FFmpegLock() {}
+ virtual ~FFmpegLock() {}
+
+ Lock lock_;
+ DISALLOW_COPY_AND_ASSIGN(FFmpegLock);
+};
+
+
//
// AVPacketBuffer
//
@@ -254,11 +274,16 @@ void FFmpegDemuxer::InititalizeTask(DataSource* data_source) {
DCHECK(context);
format_context_.reset(context);
- // Fully initialize AVFormatContext by parsing the stream a little.
- result = av_find_stream_info(format_context_.get());
- if (result < 0) {
- host_->Error(DEMUXER_ERROR_COULD_NOT_PARSE);
- return;
+ // Serialize calls to av_find_stream_info().
+ {
+ AutoLock auto_lock(FFmpegLock::get()->lock());
+
+ // Fully initialize AVFormatContext by parsing the stream a little.
+ result = av_find_stream_info(format_context_.get());
+ if (result < 0) {
+ host_->Error(DEMUXER_ERROR_COULD_NOT_PARSE);
+ return;
+ }
}
// Create demuxer streams for all supported streams.