summaryrefslogtreecommitdiffstats
path: root/media
diff options
context:
space:
mode:
authorscherkus@chromium.org <scherkus@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2013-01-02 17:47:57 +0000
committerscherkus@chromium.org <scherkus@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2013-01-02 17:47:57 +0000
commite82b2bd016395079f0f9c8080d3499dc9bccd347 (patch)
treeea29237902b246668fc1b82c632f25a646d3cb1a /media
parent693845e44965a358274812ff75aa23ca80625658 (diff)
downloadchromium_src-e82b2bd016395079f0f9c8080d3499dc9bccd347.zip
chromium_src-e82b2bd016395079f0f9c8080d3499dc9bccd347.tar.gz
chromium_src-e82b2bd016395079f0f9c8080d3499dc9bccd347.tar.bz2
Vanquish the remnants of media::MessageLoopFactory.
Now that media code runs on a single thread we no longer need to worry about creating additional threads at runtime. To make changes like this easier in the future, webkit_media::WebMediaPlayerParams is introduced to avoid plumbing parameters through Chrome's various abstraction layers. BUG=116873 Review URL: https://codereview.chromium.org/11468033 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@174808 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'media')
-rw-r--r--media/base/message_loop_factory.cc48
-rw-r--r--media/base/message_loop_factory.h62
-rw-r--r--media/filters/gpu_video_decoder.cc7
-rw-r--r--media/filters/gpu_video_decoder.h6
-rw-r--r--media/media.gyp2
-rw-r--r--media/tools/player_x11/player_x11.cc21
6 files changed, 14 insertions, 132 deletions
diff --git a/media/base/message_loop_factory.cc b/media/base/message_loop_factory.cc
deleted file mode 100644
index 597ff13..0000000
--- a/media/base/message_loop_factory.cc
+++ /dev/null
@@ -1,48 +0,0 @@
-// Copyright (c) 2012 The Chromium Authors. All rights reserved.
-// Use of this source code is governed by a BSD-style license that can be
-// found in the LICENSE file.
-
-#include "media/base/message_loop_factory.h"
-
-#include "base/threading/thread.h"
-
-namespace media {
-
-MessageLoopFactory::MessageLoopFactory() {}
-
-MessageLoopFactory::~MessageLoopFactory() {
- for (ThreadList::reverse_iterator it = threads_.rbegin();
- it != threads_.rend(); ++it) {
- base::Thread* thread = it->second;
- thread->Stop();
- delete thread;
- }
- threads_.clear();
-}
-
-scoped_refptr<base::MessageLoopProxy> MessageLoopFactory::GetMessageLoop(
- Type type) {
- return GetThread(type)->message_loop_proxy();
-}
-
-base::Thread* MessageLoopFactory::GetThread(Type type) {
- base::AutoLock auto_lock(lock_);
- for (ThreadList::iterator it = threads_.begin(); it != threads_.end(); ++it) {
- if (it->first == type)
- return it->second;
- }
-
- const char* name = NULL;
- switch (type) {
- case kPipeline:
- name = "MediaPipeline";
- break;
- }
-
- base::Thread* thread = new base::Thread(name);
- CHECK(thread->Start()) << "Failed to start thread: " << name;
- threads_.push_back(std::make_pair(type, thread));
- return thread;
-}
-
-} // namespace media
diff --git a/media/base/message_loop_factory.h b/media/base/message_loop_factory.h
deleted file mode 100644
index 0989174..0000000
--- a/media/base/message_loop_factory.h
+++ /dev/null
@@ -1,62 +0,0 @@
-// Copyright (c) 2012 The Chromium Authors. All rights reserved.
-// Use of this source code is governed by a BSD-style license that can be
-// found in the LICENSE file.
-
-#ifndef MEDIA_BASE_MESSAGE_LOOP_FACTORY_H_
-#define MEDIA_BASE_MESSAGE_LOOP_FACTORY_H_
-
-#include <list>
-#include <string>
-
-#include "base/memory/ref_counted.h"
-#include "base/memory/scoped_ptr.h"
-#include "base/message_loop_proxy.h"
-#include "base/synchronization/lock.h"
-#include "media/base/media_export.h"
-
-class MessageLoop;
-
-namespace base {
-class Thread;
-}
-
-namespace media {
-
-// Factory object that manages named MessageLoops.
-//
-// TODO(scherkus): replace this with something simpler http://crbug.com/116873
-class MEDIA_EXPORT MessageLoopFactory {
- public:
- enum Type {
- kPipeline
- };
-
- MessageLoopFactory();
-
- // Get the message loop proxy associated with |type|. A new MessageLoopProxy
- // is created if the factory doesn't have one associated with |type|.
- scoped_refptr<base::MessageLoopProxy> GetMessageLoop(Type type);
-
- private:
- // Restrict who can delete the factory to scoped_ptr<>. scoped_ptr<> uses
- // base::DefaultDeleter.
- friend struct base::DefaultDeleter<MessageLoopFactory>;
- ~MessageLoopFactory();
-
- // Returns the thread associated with |type| creating a new thread if needed.
- base::Thread* GetThread(Type type);
-
- // Lock used to serialize access for the following data members.
- base::Lock lock_;
-
- // List of pairs of created threads and their types. We use a list to ensure
- // threads are stopped & deleted in reverse order of creation.
- typedef std::list<std::pair<Type, base::Thread*> > ThreadList;
- ThreadList threads_;
-
- DISALLOW_COPY_AND_ASSIGN(MessageLoopFactory);
-};
-
-} // namespace media
-
-#endif // MEDIA_BASE_MESSAGE_LOOP_FACTORY_H_
diff --git a/media/filters/gpu_video_decoder.cc b/media/filters/gpu_video_decoder.cc
index b05698a..b2e5670 100644
--- a/media/filters/gpu_video_decoder.cc
+++ b/media/filters/gpu_video_decoder.cc
@@ -51,11 +51,10 @@ GpuVideoDecoder::BufferData::BufferData(
GpuVideoDecoder::BufferData::~BufferData() {}
GpuVideoDecoder::GpuVideoDecoder(
- const scoped_refptr<base::MessageLoopProxy>& gvd_loop_proxy,
- const scoped_refptr<base::MessageLoopProxy>& vda_loop_proxy,
+ const scoped_refptr<base::MessageLoopProxy>& message_loop,
const scoped_refptr<Factories>& factories)
- : gvd_loop_proxy_(gvd_loop_proxy),
- vda_loop_proxy_(vda_loop_proxy),
+ : gvd_loop_proxy_(message_loop),
+ vda_loop_proxy_(factories->GetMessageLoop()),
factories_(factories),
state_(kNormal),
demuxer_read_in_progress_(false),
diff --git a/media/filters/gpu_video_decoder.h b/media/filters/gpu_video_decoder.h
index 6c1fec3..ae51189 100644
--- a/media/filters/gpu_video_decoder.h
+++ b/media/filters/gpu_video_decoder.h
@@ -55,13 +55,15 @@ class MEDIA_EXPORT GpuVideoDecoder
// Close()ing the returned pointer.
virtual base::SharedMemory* CreateSharedMemory(size_t size) = 0;
+ // Returns the message loop the VideoDecodeAccelerator runs on.
+ virtual scoped_refptr<base::MessageLoopProxy> GetMessageLoop() = 0;
+
protected:
friend class base::RefCountedThreadSafe<Factories>;
virtual ~Factories();
};
- GpuVideoDecoder(const scoped_refptr<base::MessageLoopProxy>& gvd_loop_proxy,
- const scoped_refptr<base::MessageLoopProxy>& vda_loop_proxy,
+ GpuVideoDecoder(const scoped_refptr<base::MessageLoopProxy>& message_loop,
const scoped_refptr<Factories>& factories);
// VideoDecoder implementation.
diff --git a/media/media.gyp b/media/media.gyp
index 89b1ecb..05b35cc 100644
--- a/media/media.gyp
+++ b/media/media.gyp
@@ -227,8 +227,6 @@
'base/media_switches.cc',
'base/media_switches.h',
'base/media_win.cc',
- 'base/message_loop_factory.cc',
- 'base/message_loop_factory.h',
'base/multi_channel_resampler.cc',
'base/multi_channel_resampler.h',
'base/pipeline.cc',
diff --git a/media/tools/player_x11/player_x11.cc b/media/tools/player_x11/player_x11.cc
index 8c76e17..0a7477c 100644
--- a/media/tools/player_x11/player_x11.cc
+++ b/media/tools/player_x11/player_x11.cc
@@ -20,7 +20,6 @@
#include "media/base/media.h"
#include "media/base/media_log.h"
#include "media/base/media_switches.h"
-#include "media/base/message_loop_factory.h"
#include "media/base/pipeline.h"
#include "media/base/video_frame.h"
#include "media/filters/audio_renderer_impl.h"
@@ -106,8 +105,7 @@ bool InitPipeline(const scoped_refptr<base::MessageLoopProxy>& message_loop,
const PaintCB& paint_cb,
bool /* enable_audio */,
scoped_refptr<media::Pipeline>* pipeline,
- MessageLoop* paint_message_loop,
- media::MessageLoopFactory* message_loop_factory) {
+ MessageLoop* paint_message_loop) {
// Create our filter factories.
scoped_ptr<media::FilterCollection> collection(
new media::FilterCollection());
@@ -259,13 +257,10 @@ int main(int argc, char** argv) {
return 1;
// Initialize the pipeline thread and the pipeline.
- scoped_ptr<media::MessageLoopFactory> message_loop_factory(
- new media::MessageLoopFactory());
- scoped_ptr<base::Thread> thread;
- scoped_refptr<media::Pipeline> pipeline;
MessageLoop message_loop;
- thread.reset(new base::Thread("PipelineThread"));
- thread->Start();
+ base::Thread media_thread("MediaThread");
+ media_thread.Start();
+ scoped_refptr<media::Pipeline> pipeline;
PaintCB paint_cb;
if (command_line->HasSwitch("use-gl")) {
@@ -280,9 +275,9 @@ int main(int argc, char** argv) {
new DataSourceLogger(CreateFileDataSource(filename),
command_line->HasSwitch("streaming")));
- if (InitPipeline(thread->message_loop_proxy(), data_source,
+ if (InitPipeline(media_thread.message_loop_proxy(), data_source,
paint_cb, command_line->HasSwitch("audio"),
- &pipeline, &message_loop, message_loop_factory.get())) {
+ &pipeline, &message_loop)) {
// Main loop of the application.
g_running = true;
@@ -294,9 +289,7 @@ int main(int argc, char** argv) {
}
// Cleanup tasks.
- message_loop_factory.reset();
-
- thread->Stop();
+ media_thread.Stop();
// Release callback which releases video renderer. Do this before cleaning up
// X below since the video renderer has some X cleanup duties as well.