summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorscherkus@chromium.org <scherkus@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2014-01-07 21:40:50 +0000
committerscherkus@chromium.org <scherkus@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2014-01-07 21:40:50 +0000
commita0e7e86682f9804b06d59d9163f8118484e30c91 (patch)
tree2d85734289e5b6dfdf54c24c5de5d8e3f8e0eb39
parentb2a34d53b43b5c81b36d9c40caeed8353bb3c433 (diff)
downloadchromium_src-a0e7e86682f9804b06d59d9163f8118484e30c91.zip
chromium_src-a0e7e86682f9804b06d59d9163f8118484e30c91.tar.gz
chromium_src-a0e7e86682f9804b06d59d9163f8118484e30c91.tar.bz2
Replace MessageLoopProxy with SingleThreadTaskRunner for the rest of media/.
BUG=315922 R=dalecurtis@chromium.org TBR=jam Review URL: https://codereview.chromium.org/66183002 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@243390 0039d316-1c4b-4281-b951-d872f2087c98
-rw-r--r--chrome/browser/extensions/api/webrtc_audio_private/webrtc_audio_private_api.cc17
-rw-r--r--chrome/browser/extensions/api/webrtc_audio_private/webrtc_audio_private_api.h6
-rw-r--r--chrome/browser/extensions/api/webrtc_audio_private/webrtc_audio_private_browsertest.cc5
-rw-r--r--content/browser/renderer_host/media/audio_input_renderer_host.cc11
-rw-r--r--content/browser/renderer_host/media/audio_renderer_host_unittest.cc2
-rw-r--r--content/browser/renderer_host/media/web_contents_audio_input_stream.cc4
-rw-r--r--content/browser/renderer_host/media/web_contents_audio_input_stream.h10
-rw-r--r--content/browser/renderer_host/render_message_filter.cc2
-rw-r--r--content/test/webrtc_audio_device_test.cc16
-rw-r--r--content/test/webrtc_audio_device_test.h4
-rw-r--r--media/audio/alsa/alsa_output.cc3
-rw-r--r--media/audio/alsa/alsa_output_unittest.cc5
-rw-r--r--media/audio/android/audio_manager_android.cc2
-rw-r--r--media/audio/audio_input_controller.cc48
-rw-r--r--media/audio/audio_input_controller.h10
-rw-r--r--media/audio/audio_input_device.cc27
-rw-r--r--media/audio/audio_input_device.h9
-rw-r--r--media/audio/audio_low_latency_input_output_unittest.cc3
-rw-r--r--media/audio/audio_manager.h19
-rw-r--r--media/audio/audio_manager_base.cc32
-rw-r--r--media/audio/audio_manager_base.h13
-rw-r--r--media/audio/audio_output_controller.cc3
-rw-r--r--media/audio/audio_output_controller.h2
-rw-r--r--media/audio/audio_output_controller_unittest.cc2
-rw-r--r--media/audio/audio_output_device.cc31
-rw-r--r--media/audio/audio_output_device.h10
-rw-r--r--media/audio/audio_output_dispatcher.cc10
-rw-r--r--media/audio/audio_output_dispatcher.h4
-rw-r--r--media/audio/audio_output_dispatcher_impl.cc24
-rw-r--r--media/audio/audio_output_proxy_unittest.cc10
-rw-r--r--media/audio/audio_output_resampler.cc18
-rw-r--r--media/audio/clockless_audio_sink.h2
-rw-r--r--media/audio/fake_audio_consumer.cc29
-rw-r--r--media/audio/fake_audio_consumer.h13
-rw-r--r--media/audio/fake_audio_output_stream.cc14
-rw-r--r--media/audio/mac/audio_manager_mac.cc14
-rw-r--r--media/audio/mac/audio_manager_mac.h1
-rw-r--r--media/audio/mock_audio_manager.cc17
-rw-r--r--media/audio/mock_audio_manager.h10
-rw-r--r--media/audio/null_audio_sink.cc18
-rw-r--r--media/audio/null_audio_sink.h6
-rw-r--r--media/audio/pulse/pulse_output.cc16
-rw-r--r--media/audio/pulse/pulse_unified.cc16
-rw-r--r--media/audio/scoped_loop_observer.h50
-rw-r--r--media/audio/scoped_task_runner_observer.cc (renamed from media/audio/scoped_loop_observer.cc)21
-rw-r--r--media/audio/scoped_task_runner_observer.h52
-rw-r--r--media/audio/sounds/audio_stream_handler.cc18
-rw-r--r--media/audio/sounds/sounds_manager.cc7
-rw-r--r--media/audio/test_audio_input_controller_factory.cc4
-rw-r--r--media/audio/virtual_audio_input_stream.cc13
-rw-r--r--media/audio/virtual_audio_input_stream.h12
-rw-r--r--media/audio/virtual_audio_input_stream_unittest.cc25
-rw-r--r--media/audio/virtual_audio_output_stream_unittest.cc30
-rw-r--r--media/audio/win/audio_manager_win.cc6
-rw-r--r--media/base/bind_to_loop_unittest.cc2
-rw-r--r--media/media.gyp4
-rw-r--r--media/tools/player_x11/player_x11.cc23
-rw-r--r--media/video/capture/mac/video_capture_device_mac.h7
-rw-r--r--media/video/capture/mac/video_capture_device_mac.mm15
-rw-r--r--media/video/capture/video_capture_device_unittest.cc4
-rw-r--r--media/video/capture/video_capture_proxy.cc18
-rw-r--r--media/video/capture/video_capture_proxy.h6
62 files changed, 418 insertions, 417 deletions
diff --git a/chrome/browser/extensions/api/webrtc_audio_private/webrtc_audio_private_api.cc b/chrome/browser/extensions/api/webrtc_audio_private/webrtc_audio_private_api.cc
index 4725c5d..5cc59fc 100644
--- a/chrome/browser/extensions/api/webrtc_audio_private/webrtc_audio_private_api.cc
+++ b/chrome/browser/extensions/api/webrtc_audio_private/webrtc_audio_private_api.cc
@@ -5,7 +5,6 @@
#include "chrome/browser/extensions/api/webrtc_audio_private/webrtc_audio_private_api.h"
#include "base/lazy_instance.h"
-#include "base/message_loop/message_loop_proxy.h"
#include "base/strings/string_number_conversions.h"
#include "base/task_runner_util.h"
#include "chrome/browser/extensions/api/tabs/tabs_constants.h"
@@ -99,7 +98,7 @@ void WebrtcAudioPrivateEventService::SignalEvent() {
bool WebrtcAudioPrivateGetSinksFunction::RunImpl() {
DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));
- AudioManager::Get()->GetMessageLoop()->PostTaskAndReply(
+ AudioManager::Get()->GetTaskRunner()->PostTaskAndReply(
FROM_HERE,
base::Bind(&WebrtcAudioPrivateGetSinksFunction::DoQuery, this),
base::Bind(&WebrtcAudioPrivateGetSinksFunction::DoneOnUIThread, this));
@@ -107,7 +106,7 @@ bool WebrtcAudioPrivateGetSinksFunction::RunImpl() {
}
void WebrtcAudioPrivateGetSinksFunction::DoQuery() {
- DCHECK(AudioManager::Get()->GetMessageLoop()->BelongsToCurrentThread());
+ DCHECK(AudioManager::Get()->GetTaskRunner()->BelongsToCurrentThread());
AudioDeviceNames device_names;
AudioManager::Get()->GetAudioOutputDeviceNames(&device_names);
@@ -198,7 +197,7 @@ void WebrtcAudioPrivateGetActiveSinkFunction::OnSinkId(const std::string& id) {
WebrtcAudioPrivateSetActiveSinkFunction::
WebrtcAudioPrivateSetActiveSinkFunction()
- : message_loop_(base::MessageLoopProxy::current()),
+ : task_runner_(base::MessageLoopProxy::current()),
tab_id_(0),
num_remaining_sink_ids_(0) {
}
@@ -244,7 +243,7 @@ void WebrtcAudioPrivateSetActiveSinkFunction::OnControllerList(
void WebrtcAudioPrivateSetActiveSinkFunction::SwitchDone() {
if (--num_remaining_sink_ids_ == 0) {
- message_loop_->PostTask(
+ task_runner_->PostTask(
FROM_HERE,
base::Bind(&WebrtcAudioPrivateSetActiveSinkFunction::DoneOnUIThread,
this));
@@ -268,7 +267,7 @@ bool WebrtcAudioPrivateGetAssociatedSinkFunction::RunImpl() {
DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));
EXTENSION_FUNCTION_VALIDATE(params_.get());
- AudioManager::Get()->GetMessageLoop()->PostTaskAndReply(
+ AudioManager::Get()->GetTaskRunner()->PostTaskAndReply(
FROM_HERE,
base::Bind(&WebrtcAudioPrivateGetAssociatedSinkFunction::
GetDevicesOnDeviceThread, this),
@@ -280,7 +279,7 @@ bool WebrtcAudioPrivateGetAssociatedSinkFunction::RunImpl() {
}
void WebrtcAudioPrivateGetAssociatedSinkFunction::GetDevicesOnDeviceThread() {
- DCHECK(AudioManager::Get()->GetMessageLoop()->BelongsToCurrentThread());
+ DCHECK(AudioManager::Get()->GetTaskRunner()->BelongsToCurrentThread());
AudioManager::Get()->GetAudioInputDeviceNames(&source_devices_);
}
@@ -332,7 +331,7 @@ void WebrtcAudioPrivateGetAssociatedSinkFunction::OnGetRawSourceIDDone(
const std::string& raw_source_id) {
DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));
base::PostTaskAndReplyWithResult(
- AudioManager::Get()->GetMessageLoop(),
+ AudioManager::Get()->GetTaskRunner(),
FROM_HERE,
base::Bind(&WebrtcAudioPrivateGetAssociatedSinkFunction::
GetAssociatedSinkOnDeviceThread,
@@ -346,7 +345,7 @@ void WebrtcAudioPrivateGetAssociatedSinkFunction::OnGetRawSourceIDDone(
std::string
WebrtcAudioPrivateGetAssociatedSinkFunction::GetAssociatedSinkOnDeviceThread(
const std::string& raw_source_id) {
- DCHECK(AudioManager::Get()->GetMessageLoop()->BelongsToCurrentThread());
+ DCHECK(AudioManager::Get()->GetTaskRunner()->BelongsToCurrentThread());
// We return an empty string if there is no associated output device.
std::string result;
diff --git a/chrome/browser/extensions/api/webrtc_audio_private/webrtc_audio_private_api.h b/chrome/browser/extensions/api/webrtc_audio_private/webrtc_audio_private_api.h
index cf3a994..85f1922 100644
--- a/chrome/browser/extensions/api/webrtc_audio_private/webrtc_audio_private_api.h
+++ b/chrome/browser/extensions/api/webrtc_audio_private/webrtc_audio_private_api.h
@@ -16,7 +16,7 @@
#include "url/gurl.h"
namespace base {
-class MessageLoopProxy;
+class SingleThreadTaskRunner;
}
namespace extensions {
@@ -107,8 +107,8 @@ class WebrtcAudioPrivateSetActiveSinkFunction
void SwitchDone();
void DoneOnUIThread();
- // Message loop of the thread this class is constructed on.
- const scoped_refptr<base::MessageLoopProxy> message_loop_;
+ // Task runner of the thread this class is constructed on.
+ const scoped_refptr<base::SingleThreadTaskRunner> task_runner_;
int tab_id_;
std::string sink_id_;
diff --git a/chrome/browser/extensions/api/webrtc_audio_private/webrtc_audio_private_browsertest.cc b/chrome/browser/extensions/api/webrtc_audio_private/webrtc_audio_private_browsertest.cc
index abb18c1..57480f8 100644
--- a/chrome/browser/extensions/api/webrtc_audio_private/webrtc_audio_private_browsertest.cc
+++ b/chrome/browser/extensions/api/webrtc_audio_private/webrtc_audio_private_browsertest.cc
@@ -3,7 +3,6 @@
// found in the LICENSE file.
#include "base/json/json_writer.h"
-#include "base/message_loop/message_loop.h"
#include "base/strings/string_util.h"
#include "base/strings/stringprintf.h"
#include "base/strings/utf_string_conversions.h"
@@ -103,8 +102,8 @@ class WebrtcAudioPrivateTest : public AudioWaitingExtensionTest {
AudioDeviceNames* device_names) {
AudioManager* audio_manager = AudioManager::Get();
- if (!audio_manager->GetMessageLoop()->BelongsToCurrentThread()) {
- audio_manager->GetMessageLoop()->PostTask(
+ if (!audio_manager->GetTaskRunner()->BelongsToCurrentThread()) {
+ audio_manager->GetTaskRunner()->PostTask(
FROM_HERE,
base::Bind(&WebrtcAudioPrivateTest::GetAudioDeviceNames, this,
EnumerationFunc, device_names));
diff --git a/content/browser/renderer_host/media/audio_input_renderer_host.cc b/content/browser/renderer_host/media/audio_input_renderer_host.cc
index e3d88cc..ec61944 100644
--- a/content/browser/renderer_host/media/audio_input_renderer_host.cc
+++ b/content/browser/renderer_host/media/audio_input_renderer_host.cc
@@ -273,12 +273,13 @@ void AudioInputRendererHost::OnCreateStream(
entry->writer.reset(writer.release());
if (WebContentsCaptureUtil::IsWebContentsDeviceId(device_id)) {
entry->controller = media::AudioInputController::CreateForStream(
- audio_manager_->GetMessageLoop(),
+ audio_manager_->GetTaskRunner(),
this,
- WebContentsAudioInputStream::Create(device_id,
- audio_params,
- audio_manager_->GetWorkerLoop(),
- audio_mirroring_manager_),
+ WebContentsAudioInputStream::Create(
+ device_id,
+ audio_params,
+ audio_manager_->GetWorkerTaskRunner(),
+ audio_mirroring_manager_),
entry->writer.get(),
user_input_monitor_);
} else {
diff --git a/content/browser/renderer_host/media/audio_renderer_host_unittest.cc b/content/browser/renderer_host/media/audio_renderer_host_unittest.cc
index ff36a27..a2720ac 100644
--- a/content/browser/renderer_host/media/audio_renderer_host_unittest.cc
+++ b/content/browser/renderer_host/media/audio_renderer_host_unittest.cc
@@ -265,7 +265,7 @@ class AudioRendererHostTest : public testing::Test {
base::RunLoop().RunUntilIdle();
base::RunLoop run_loop;
- audio_manager_->GetMessageLoop()->PostTask(
+ audio_manager_->GetTaskRunner()->PostTask(
FROM_HERE, media::BindToCurrentLoop(run_loop.QuitClosure()));
run_loop.Run();
}
diff --git a/content/browser/renderer_host/media/web_contents_audio_input_stream.cc b/content/browser/renderer_host/media/web_contents_audio_input_stream.cc
index 8336eb2..e559be2 100644
--- a/content/browser/renderer_host/media/web_contents_audio_input_stream.cc
+++ b/content/browser/renderer_host/media/web_contents_audio_input_stream.cc
@@ -281,7 +281,7 @@ void WebContentsAudioInputStream::Impl::OnTargetChanged(int render_process_id,
WebContentsAudioInputStream* WebContentsAudioInputStream::Create(
const std::string& device_id,
const media::AudioParameters& params,
- const scoped_refptr<base::MessageLoopProxy>& worker_loop,
+ const scoped_refptr<base::SingleThreadTaskRunner>& worker_task_runner,
AudioMirroringManager* audio_mirroring_manager) {
int render_process_id;
int render_view_id;
@@ -295,7 +295,7 @@ WebContentsAudioInputStream* WebContentsAudioInputStream::Create(
audio_mirroring_manager,
new WebContentsTracker(),
new media::VirtualAudioInputStream(
- params, worker_loop,
+ params, worker_task_runner,
media::VirtualAudioInputStream::AfterCloseCallback()));
}
diff --git a/content/browser/renderer_host/media/web_contents_audio_input_stream.h b/content/browser/renderer_host/media/web_contents_audio_input_stream.h
index 486547e..cd50353 100644
--- a/content/browser/renderer_host/media/web_contents_audio_input_stream.h
+++ b/content/browser/renderer_host/media/web_contents_audio_input_stream.h
@@ -23,7 +23,7 @@
#include "media/audio/audio_io.h"
namespace base {
-class MessageLoopProxy;
+class SingleThreadTaskRunner;
}
namespace media {
@@ -55,13 +55,13 @@ class CONTENT_EXPORT WebContentsAudioInputStream
// WebContentsCaptureUtil::ExtractTabCaptureTarget(). The caller must
// guarantee Close() is called on the returned object so that it may
// self-destruct.
- // |worker_loop| is the loop on which AudioInputCallback methods are called
- // and may or may not be the single thread that invokes the AudioInputStream
- // methods.
+ // |worker_task_runner| is the task runner on which AudioInputCallback methods
+ // are called and may or may not be the single thread that invokes the
+ // AudioInputStream methods.
static WebContentsAudioInputStream* Create(
const std::string& device_id,
const media::AudioParameters& params,
- const scoped_refptr<base::MessageLoopProxy>& worker_loop,
+ const scoped_refptr<base::SingleThreadTaskRunner>& worker_task_runner,
AudioMirroringManager* audio_mirroring_manager);
private:
diff --git a/content/browser/renderer_host/render_message_filter.cc b/content/browser/renderer_host/render_message_filter.cc
index 429aef8..575a1c9 100644
--- a/content/browser/renderer_host/render_message_filter.cc
+++ b/content/browser/renderer_host/render_message_filter.cc
@@ -464,7 +464,7 @@ base::TaskRunner* RenderMessageFilter::OverrideTaskRunnerForMessage(
#if defined(OS_MACOSX)
// OSX CoreAudio calls must all happen on the main thread.
if (message.type() == ViewHostMsg_GetAudioHardwareConfig::ID)
- return audio_manager_->GetMessageLoop().get();
+ return audio_manager_->GetTaskRunner().get();
#endif
return NULL;
}
diff --git a/content/test/webrtc_audio_device_test.cc b/content/test/webrtc_audio_device_test.cc
index d56f7d0..3883443 100644
--- a/content/test/webrtc_audio_device_test.cc
+++ b/content/test/webrtc_audio_device_test.cc
@@ -8,7 +8,6 @@
#include "base/bind_helpers.h"
#include "base/compiler_specific.h"
#include "base/file_util.h"
-#include "base/message_loop/message_loop.h"
#include "base/run_loop.h"
#include "base/synchronization/waitable_event.h"
#include "base/test/test_timeouts.h"
@@ -399,20 +398,21 @@ bool MAYBE_WebRTCAudioDeviceTest::OnMessageReceived(
// Posts a final task to the IO message loop and waits for completion.
void MAYBE_WebRTCAudioDeviceTest::WaitForIOThreadCompletion() {
- WaitForMessageLoopCompletion(
- ChildProcess::current()->io_message_loop()->message_loop_proxy().get());
+ WaitForTaskRunnerCompletion(
+ ChildProcess::current()->io_message_loop()->message_loop_proxy());
}
void MAYBE_WebRTCAudioDeviceTest::WaitForAudioManagerCompletion() {
if (audio_manager_)
- WaitForMessageLoopCompletion(audio_manager_->GetMessageLoop().get());
+ WaitForTaskRunnerCompletion(audio_manager_->GetTaskRunner());
}
-void MAYBE_WebRTCAudioDeviceTest::WaitForMessageLoopCompletion(
- base::MessageLoopProxy* loop) {
+void MAYBE_WebRTCAudioDeviceTest::WaitForTaskRunnerCompletion(
+ const scoped_refptr<base::SingleThreadTaskRunner>& task_runner) {
base::WaitableEvent* event = new base::WaitableEvent(false, false);
- loop->PostTask(FROM_HERE, base::Bind(&base::WaitableEvent::Signal,
- base::Unretained(event)));
+ task_runner->PostTask(
+ FROM_HERE,
+ base::Bind(&base::WaitableEvent::Signal, base::Unretained(event)));
if (event->TimedWait(TestTimeouts::action_max_timeout())) {
delete event;
} else {
diff --git a/content/test/webrtc_audio_device_test.h b/content/test/webrtc_audio_device_test.h
index 9b8f57e..3a9a8b14 100644
--- a/content/test/webrtc_audio_device_test.h
+++ b/content/test/webrtc_audio_device_test.h
@@ -10,7 +10,6 @@
#include "base/files/file_path.h"
#include "base/memory/ref_counted.h"
#include "base/memory/scoped_ptr.h"
-#include "base/message_loop/message_loop.h"
#include "content/browser/renderer_host/media/mock_media_observer.h"
#include "content/public/renderer/content_renderer_client.h"
#include "ipc/ipc_listener.h"
@@ -151,7 +150,8 @@ class MAYBE_WebRTCAudioDeviceTest : public ::testing::Test,
// Posts a final task to the IO message loop and waits for completion.
void WaitForIOThreadCompletion();
void WaitForAudioManagerCompletion();
- void WaitForMessageLoopCompletion(base::MessageLoopProxy* loop);
+ void WaitForTaskRunnerCompletion(
+ const scoped_refptr<base::SingleThreadTaskRunner>& task_runner);
std::string GetTestDataPath(const base::FilePath::StringType& file_name);
diff --git a/media/audio/alsa/alsa_output.cc b/media/audio/alsa/alsa_output.cc
index eccf8ee..f28dfca 100644
--- a/media/audio/alsa/alsa_output.cc
+++ b/media/audio/alsa/alsa_output.cc
@@ -39,7 +39,6 @@
#include "base/bind.h"
#include "base/debug/trace_event.h"
#include "base/logging.h"
-#include "base/message_loop/message_loop.h"
#include "base/stl_util.h"
#include "base/time/time.h"
#include "media/audio/alsa/alsa_util.h"
@@ -159,7 +158,7 @@ AlsaPcmOutputStream::AlsaPcmOutputStream(const std::string& device_name,
volume_(1.0f),
source_callback_(NULL),
audio_bus_(AudioBus::Create(params)) {
- DCHECK(manager_->GetMessageLoop()->BelongsToCurrentThread());
+ DCHECK(manager_->GetTaskRunner()->BelongsToCurrentThread());
DCHECK_EQ(audio_bus_->frames() * bytes_per_frame_, packet_size_);
// Sanity check input values.
diff --git a/media/audio/alsa/alsa_output_unittest.cc b/media/audio/alsa/alsa_output_unittest.cc
index 99ae8b0..da7924f 100644
--- a/media/audio/alsa/alsa_output_unittest.cc
+++ b/media/audio/alsa/alsa_output_unittest.cc
@@ -2,7 +2,6 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
-#include "base/message_loop/message_loop.h"
#include "base/strings/stringprintf.h"
#include "media/audio/alsa/alsa_output.h"
#include "media/audio/alsa/alsa_wrapper.h"
@@ -102,8 +101,8 @@ class MockAudioManagerAlsa : public AudioManagerAlsa {
}
// We don't mock this method since all tests will do the same thing
- // and use the current message loop.
- virtual scoped_refptr<base::MessageLoopProxy> GetMessageLoop() OVERRIDE {
+ // and use the current task runner.
+ virtual scoped_refptr<base::SingleThreadTaskRunner> GetTaskRunner() OVERRIDE {
return base::MessageLoop::current()->message_loop_proxy();
}
diff --git a/media/audio/android/audio_manager_android.cc b/media/audio/android/audio_manager_android.cc
index e67700c..7601dcb 100644
--- a/media/audio/android/audio_manager_android.cc
+++ b/media/audio/android/audio_manager_android.cc
@@ -294,7 +294,7 @@ void AudioManagerAndroid::Close() {
}
void AudioManagerAndroid::SetMute(JNIEnv* env, jobject obj, jboolean muted) {
- GetMessageLoop()->PostTask(
+ GetTaskRunner()->PostTask(
FROM_HERE,
base::Bind(
&AudioManagerAndroid::DoSetMuteOnAudioThread,
diff --git a/media/audio/audio_input_controller.cc b/media/audio/audio_input_controller.cc
index 1f008b4..e6d8462 100644
--- a/media/audio/audio_input_controller.cc
+++ b/media/audio/audio_input_controller.cc
@@ -33,7 +33,7 @@ AudioInputController::Factory* AudioInputController::factory_ = NULL;
AudioInputController::AudioInputController(EventHandler* handler,
SyncWriter* sync_writer,
UserInputMonitor* user_input_monitor)
- : creator_loop_(base::MessageLoopProxy::current()),
+ : creator_task_runner_(base::MessageLoopProxy::current()),
handler_(handler),
stream_(NULL),
data_is_active_(false),
@@ -42,7 +42,7 @@ AudioInputController::AudioInputController(EventHandler* handler,
max_volume_(0.0),
user_input_monitor_(user_input_monitor),
prev_key_down_count_(0) {
- DCHECK(creator_loop_.get());
+ DCHECK(creator_task_runner_.get());
}
AudioInputController::~AudioInputController() {
@@ -68,11 +68,11 @@ scoped_refptr<AudioInputController> AudioInputController::Create(
scoped_refptr<AudioInputController> controller(
new AudioInputController(event_handler, NULL, user_input_monitor));
- controller->message_loop_ = audio_manager->GetMessageLoop();
+ controller->task_runner_ = audio_manager->GetTaskRunner();
// Create and open a new audio input stream from the existing
// audio-device thread.
- if (!controller->message_loop_->PostTask(FROM_HERE,
+ if (!controller->task_runner_->PostTask(FROM_HERE,
base::Bind(&AudioInputController::DoCreate, controller,
base::Unretained(audio_manager), params, device_id))) {
controller = NULL;
@@ -99,11 +99,11 @@ scoped_refptr<AudioInputController> AudioInputController::CreateLowLatency(
// the audio-manager thread.
scoped_refptr<AudioInputController> controller(
new AudioInputController(event_handler, sync_writer, user_input_monitor));
- controller->message_loop_ = audio_manager->GetMessageLoop();
+ controller->task_runner_ = audio_manager->GetTaskRunner();
// Create and open a new audio input stream from the existing
// audio-device thread. Use the provided audio-input device.
- if (!controller->message_loop_->PostTask(FROM_HERE,
+ if (!controller->task_runner_->PostTask(FROM_HERE,
base::Bind(&AudioInputController::DoCreate, controller,
base::Unretained(audio_manager), params, device_id))) {
controller = NULL;
@@ -114,7 +114,7 @@ scoped_refptr<AudioInputController> AudioInputController::CreateLowLatency(
// static
scoped_refptr<AudioInputController> AudioInputController::CreateForStream(
- const scoped_refptr<base::MessageLoopProxy>& message_loop,
+ const scoped_refptr<base::SingleThreadTaskRunner>& task_runner,
EventHandler* event_handler,
AudioInputStream* stream,
SyncWriter* sync_writer,
@@ -126,14 +126,14 @@ scoped_refptr<AudioInputController> AudioInputController::CreateForStream(
// the audio-manager thread.
scoped_refptr<AudioInputController> controller(
new AudioInputController(event_handler, sync_writer, user_input_monitor));
- controller->message_loop_ = message_loop;
+ controller->task_runner_ = task_runner;
// TODO(miu): See TODO at top of file. Until that's resolved, we need to
// disable the error auto-detection here (since the audio mirroring
// implementation will reliably report error and close events). Note, of
// course, that we're assuming CreateForStream() has been called for the audio
// mirroring use case only.
- if (!controller->message_loop_->PostTask(
+ if (!controller->task_runner_->PostTask(
FROM_HERE,
base::Bind(&AudioInputController::DoCreateForStream, controller,
stream, false))) {
@@ -144,32 +144,32 @@ scoped_refptr<AudioInputController> AudioInputController::CreateForStream(
}
void AudioInputController::Record() {
- message_loop_->PostTask(FROM_HERE, base::Bind(
+ task_runner_->PostTask(FROM_HERE, base::Bind(
&AudioInputController::DoRecord, this));
}
void AudioInputController::Close(const base::Closure& closed_task) {
DCHECK(!closed_task.is_null());
- DCHECK(creator_loop_->BelongsToCurrentThread());
+ DCHECK(creator_task_runner_->BelongsToCurrentThread());
- message_loop_->PostTaskAndReply(
+ task_runner_->PostTaskAndReply(
FROM_HERE, base::Bind(&AudioInputController::DoClose, this), closed_task);
}
void AudioInputController::SetVolume(double volume) {
- message_loop_->PostTask(FROM_HERE, base::Bind(
+ task_runner_->PostTask(FROM_HERE, base::Bind(
&AudioInputController::DoSetVolume, this, volume));
}
void AudioInputController::SetAutomaticGainControl(bool enabled) {
- message_loop_->PostTask(FROM_HERE, base::Bind(
+ task_runner_->PostTask(FROM_HERE, base::Bind(
&AudioInputController::DoSetAutomaticGainControl, this, enabled));
}
void AudioInputController::DoCreate(AudioManager* audio_manager,
const AudioParameters& params,
const std::string& device_id) {
- DCHECK(message_loop_->BelongsToCurrentThread());
+ DCHECK(task_runner_->BelongsToCurrentThread());
SCOPED_UMA_HISTOGRAM_TIMER("Media.AudioInputController.CreateTime");
// TODO(miu): See TODO at top of file. Until that's resolved, assume all
// platform audio input requires the |no_data_timer_| be used to auto-detect
@@ -181,7 +181,7 @@ void AudioInputController::DoCreate(AudioManager* audio_manager,
void AudioInputController::DoCreateForStream(
AudioInputStream* stream_to_control, bool enable_nodata_timer) {
- DCHECK(message_loop_->BelongsToCurrentThread());
+ DCHECK(task_runner_->BelongsToCurrentThread());
DCHECK(!stream_);
stream_ = stream_to_control;
@@ -221,7 +221,7 @@ void AudioInputController::DoCreateForStream(
}
void AudioInputController::DoRecord() {
- DCHECK(message_loop_->BelongsToCurrentThread());
+ DCHECK(task_runner_->BelongsToCurrentThread());
SCOPED_UMA_HISTOGRAM_TIMER("Media.AudioInputController.RecordTime");
if (state_ != kCreated)
@@ -243,7 +243,7 @@ void AudioInputController::DoRecord() {
}
void AudioInputController::DoClose() {
- DCHECK(message_loop_->BelongsToCurrentThread());
+ DCHECK(task_runner_->BelongsToCurrentThread());
SCOPED_UMA_HISTOGRAM_TIMER("Media.AudioInputController.CloseTime");
// Delete the timer on the same thread that created it.
@@ -265,12 +265,12 @@ void AudioInputController::DoClose() {
}
void AudioInputController::DoReportError() {
- DCHECK(message_loop_->BelongsToCurrentThread());
+ DCHECK(task_runner_->BelongsToCurrentThread());
handler_->OnError(this);
}
void AudioInputController::DoSetVolume(double volume) {
- DCHECK(message_loop_->BelongsToCurrentThread());
+ DCHECK(task_runner_->BelongsToCurrentThread());
DCHECK_GE(volume, 0);
DCHECK_LE(volume, 1.0);
@@ -293,7 +293,7 @@ void AudioInputController::DoSetVolume(double volume) {
}
void AudioInputController::DoSetAutomaticGainControl(bool enabled) {
- DCHECK(message_loop_->BelongsToCurrentThread());
+ DCHECK(task_runner_->BelongsToCurrentThread());
DCHECK_NE(state_, kRecording);
// Ensure that the AGC state only can be modified before streaming starts.
@@ -304,7 +304,7 @@ void AudioInputController::DoSetAutomaticGainControl(bool enabled) {
}
void AudioInputController::DoCheckForNoData() {
- DCHECK(message_loop_->BelongsToCurrentThread());
+ DCHECK(task_runner_->BelongsToCurrentThread());
if (!GetDataIsActive()) {
// The data-is-active marker will be false only if it has been more than
@@ -362,13 +362,13 @@ void AudioInputController::OnData(AudioInputStream* stream,
void AudioInputController::OnError(AudioInputStream* stream) {
// Handle error on the audio-manager thread.
- message_loop_->PostTask(FROM_HERE, base::Bind(
+ task_runner_->PostTask(FROM_HERE, base::Bind(
&AudioInputController::DoReportError, this));
}
void AudioInputController::DoStopCloseAndClearStream(
base::WaitableEvent* done) {
- DCHECK(message_loop_->BelongsToCurrentThread());
+ DCHECK(task_runner_->BelongsToCurrentThread());
// Allow calling unconditionally and bail if we don't have a stream to close.
if (stream_ != NULL) {
diff --git a/media/audio/audio_input_controller.h b/media/audio/audio_input_controller.h
index 3ca87c4..82fae7f 100644
--- a/media/audio/audio_input_controller.h
+++ b/media/audio/audio_input_controller.h
@@ -165,7 +165,7 @@ class MEDIA_EXPORT AudioInputController
// OnCreated() call from that same thread. |user_input_monitor| is used for
// typing detection and can be NULL.
static scoped_refptr<AudioInputController> CreateForStream(
- const scoped_refptr<base::MessageLoopProxy>& message_loop,
+ const scoped_refptr<base::SingleThreadTaskRunner>& task_runner,
EventHandler* event_handler,
AudioInputStream* stream,
// External synchronous writer for audio controller.
@@ -241,11 +241,11 @@ class MEDIA_EXPORT AudioInputController
void SetDataIsActive(bool enabled);
bool GetDataIsActive();
- // Gives access to the message loop of the creating thread.
- scoped_refptr<base::MessageLoopProxy> creator_loop_;
+ // Gives access to the task runner of the creating thread.
+ scoped_refptr<base::SingleThreadTaskRunner> creator_task_runner_;
- // The message loop of audio-manager thread that this object runs on.
- scoped_refptr<base::MessageLoopProxy> message_loop_;
+ // The task runner of audio-manager thread that this object runs on.
+ scoped_refptr<base::SingleThreadTaskRunner> task_runner_;
// Contains the AudioInputController::EventHandler which receives state
// notifications from this class.
diff --git a/media/audio/audio_input_device.cc b/media/audio/audio_input_device.cc
index d1a6ab8..f57284c 100644
--- a/media/audio/audio_input_device.cc
+++ b/media/audio/audio_input_device.cc
@@ -6,7 +6,6 @@
#include "base/basictypes.h"
#include "base/bind.h"
-#include "base/message_loop/message_loop.h"
#include "base/threading/thread_restrictions.h"
#include "base/time/time.h"
#include "media/audio/audio_manager_base.h"
@@ -47,8 +46,8 @@ class AudioInputDevice::AudioThreadCallback
AudioInputDevice::AudioInputDevice(
scoped_ptr<AudioInputIPC> ipc,
- const scoped_refptr<base::MessageLoopProxy>& io_loop)
- : ScopedLoopObserver(io_loop),
+ const scoped_refptr<base::SingleThreadTaskRunner>& io_task_runner)
+ : ScopedTaskRunnerObserver(io_task_runner),
callback_(NULL),
ipc_(ipc.Pass()),
state_(IDLE),
@@ -78,7 +77,7 @@ void AudioInputDevice::Initialize(const AudioParameters& params,
void AudioInputDevice::Start() {
DCHECK(callback_) << "Initialize hasn't been called";
DVLOG(1) << "Start()";
- message_loop()->PostTask(FROM_HERE,
+ task_runner()->PostTask(FROM_HERE,
base::Bind(&AudioInputDevice::StartUpOnIOThread, this));
}
@@ -91,7 +90,7 @@ void AudioInputDevice::Stop() {
stopping_hack_ = true;
}
- message_loop()->PostTask(FROM_HERE,
+ task_runner()->PostTask(FROM_HERE,
base::Bind(&AudioInputDevice::ShutDownOnIOThread, this));
}
@@ -101,13 +100,13 @@ void AudioInputDevice::SetVolume(double volume) {
return;
}
- message_loop()->PostTask(FROM_HERE,
+ task_runner()->PostTask(FROM_HERE,
base::Bind(&AudioInputDevice::SetVolumeOnIOThread, this, volume));
}
void AudioInputDevice::SetAutomaticGainControl(bool enabled) {
DVLOG(1) << "SetAutomaticGainControl(enabled=" << enabled << ")";
- message_loop()->PostTask(FROM_HERE,
+ task_runner()->PostTask(FROM_HERE,
base::Bind(&AudioInputDevice::SetAutomaticGainControlOnIOThread,
this, enabled));
}
@@ -117,7 +116,7 @@ void AudioInputDevice::OnStreamCreated(
base::SyncSocket::Handle socket_handle,
int length,
int total_segments) {
- DCHECK(message_loop()->BelongsToCurrentThread());
+ DCHECK(task_runner()->BelongsToCurrentThread());
#if defined(OS_WIN)
DCHECK(handle);
DCHECK(socket_handle);
@@ -153,7 +152,7 @@ void AudioInputDevice::OnVolume(double volume) {
void AudioInputDevice::OnStateChanged(
AudioInputIPCDelegate::State state) {
- DCHECK(message_loop()->BelongsToCurrentThread());
+ DCHECK(task_runner()->BelongsToCurrentThread());
// Do nothing if the stream has been closed.
if (state_ < CREATING_STREAM)
@@ -186,7 +185,7 @@ void AudioInputDevice::OnStateChanged(
}
void AudioInputDevice::OnIPCClosed() {
- DCHECK(message_loop()->BelongsToCurrentThread());
+ DCHECK(task_runner()->BelongsToCurrentThread());
state_ = IPC_CLOSED;
ipc_.reset();
}
@@ -198,7 +197,7 @@ AudioInputDevice::~AudioInputDevice() {
}
void AudioInputDevice::StartUpOnIOThread() {
- DCHECK(message_loop()->BelongsToCurrentThread());
+ DCHECK(task_runner()->BelongsToCurrentThread());
// Make sure we don't call Start() more than once.
if (state_ != IDLE)
@@ -215,7 +214,7 @@ void AudioInputDevice::StartUpOnIOThread() {
}
void AudioInputDevice::ShutDownOnIOThread() {
- DCHECK(message_loop()->BelongsToCurrentThread());
+ DCHECK(task_runner()->BelongsToCurrentThread());
// Close the stream, if we haven't already.
if (state_ >= CREATING_STREAM) {
@@ -240,13 +239,13 @@ void AudioInputDevice::ShutDownOnIOThread() {
}
void AudioInputDevice::SetVolumeOnIOThread(double volume) {
- DCHECK(message_loop()->BelongsToCurrentThread());
+ DCHECK(task_runner()->BelongsToCurrentThread());
if (state_ >= CREATING_STREAM)
ipc_->SetVolume(volume);
}
void AudioInputDevice::SetAutomaticGainControlOnIOThread(bool enabled) {
- DCHECK(message_loop()->BelongsToCurrentThread());
+ DCHECK(task_runner()->BelongsToCurrentThread());
if (state_ >= CREATING_STREAM) {
DLOG(WARNING) << "The AGC state can not be modified after starting.";
diff --git a/media/audio/audio_input_device.h b/media/audio/audio_input_device.h
index bb7d0ff..0c39002 100644
--- a/media/audio/audio_input_device.h
+++ b/media/audio/audio_input_device.h
@@ -62,7 +62,7 @@
#include "media/audio/audio_device_thread.h"
#include "media/audio/audio_input_ipc.h"
#include "media/audio/audio_parameters.h"
-#include "media/audio/scoped_loop_observer.h"
+#include "media/audio/scoped_task_runner_observer.h"
#include "media/base/audio_capturer_source.h"
#include "media/base/media_export.h"
@@ -77,11 +77,12 @@ namespace media {
class MEDIA_EXPORT AudioInputDevice
: NON_EXPORTED_BASE(public AudioCapturerSource),
NON_EXPORTED_BASE(public AudioInputIPCDelegate),
- NON_EXPORTED_BASE(public ScopedLoopObserver) {
+ NON_EXPORTED_BASE(public ScopedTaskRunnerObserver) {
public:
// NOTE: Clients must call Initialize() before using.
- AudioInputDevice(scoped_ptr<AudioInputIPC> ipc,
- const scoped_refptr<base::MessageLoopProxy>& io_loop);
+ AudioInputDevice(
+ scoped_ptr<AudioInputIPC> ipc,
+ const scoped_refptr<base::SingleThreadTaskRunner>& io_task_runner);
// AudioCapturerSource implementation.
virtual void Initialize(const AudioParameters& params,
diff --git a/media/audio/audio_low_latency_input_output_unittest.cc b/media/audio/audio_low_latency_input_output_unittest.cc
index 033988f..0fff86c 100644
--- a/media/audio/audio_low_latency_input_output_unittest.cc
+++ b/media/audio/audio_low_latency_input_output_unittest.cc
@@ -6,7 +6,6 @@
#include "base/environment.h"
#include "base/file_util.h"
#include "base/memory/scoped_ptr.h"
-#include "base/message_loop/message_loop.h"
#include "base/path_service.h"
#include "base/synchronization/lock.h"
#include "base/test/test_timeouts.h"
@@ -88,7 +87,7 @@ class MockAudioManager : public AudioManagerAnyPlatform {
MockAudioManager() : AudioManagerAnyPlatform(&fake_audio_log_factory_) {}
virtual ~MockAudioManager() {}
- virtual scoped_refptr<base::MessageLoopProxy> GetMessageLoop() OVERRIDE {
+ virtual scoped_refptr<base::SingleThreadTaskRunner> GetTaskRunner() OVERRIDE {
return base::MessageLoop::current()->message_loop_proxy();
}
diff --git a/media/audio/audio_manager.h b/media/audio/audio_manager.h
index 0ca468e..04e89a6 100644
--- a/media/audio/audio_manager.h
+++ b/media/audio/audio_manager.h
@@ -15,8 +15,7 @@
#include "media/audio/audio_parameters.h"
namespace base {
-class MessageLoop;
-class MessageLoopProxy;
+class SingleThreadTaskRunner;
}
namespace media {
@@ -68,14 +67,14 @@ class MEDIA_EXPORT AudioManager {
// recording.
//
// Not threadsafe; in production this should only be called from the
- // Audio IO thread (see GetMessageLoop).
+ // Audio IO thread (see GetTaskRunner()).
virtual void GetAudioInputDeviceNames(AudioDeviceNames* device_names) = 0;
// Appends a list of available output devices to |device_names|,
// which must initially be empty.
//
// Not threadsafe; in production this should only be called from the
- // Audio IO thread (see GetMessageLoop).
+ // Audio IO thread (see GetTaskRunner()).
virtual void GetAudioOutputDeviceNames(AudioDeviceNames* device_names) = 0;
// Factory for all the supported stream formats. |params| defines parameters
@@ -133,13 +132,13 @@ class MEDIA_EXPORT AudioManager {
virtual AudioInputStream* MakeAudioInputStream(
const AudioParameters& params, const std::string& device_id) = 0;
- // Returns message loop used for audio IO.
- virtual scoped_refptr<base::MessageLoopProxy> GetMessageLoop() = 0;
+ // Returns the task runner used for audio IO.
+ virtual scoped_refptr<base::SingleThreadTaskRunner> GetTaskRunner() = 0;
- // Heavyweight tasks should use GetWorkerLoop() instead of GetMessageLoop().
- // On most platforms they are the same, but some share the UI loop with the
- // audio IO loop.
- virtual scoped_refptr<base::MessageLoopProxy> GetWorkerLoop() = 0;
+ // Heavyweight tasks should use GetWorkerTaskRunner() instead of
+ // GetTaskRunner(). On most platforms they are the same, but some share the
+ // UI loop with the audio IO loop.
+ virtual scoped_refptr<base::SingleThreadTaskRunner> GetWorkerTaskRunner() = 0;
// Allows clients to listen for device state changes; e.g. preferred sample
// rate or channel layout changes. The typical response to receiving this
diff --git a/media/audio/audio_manager_base.cc b/media/audio/audio_manager_base.cc
index f7b590a..dae8135 100644
--- a/media/audio/audio_manager_base.cc
+++ b/media/audio/audio_manager_base.cc
@@ -7,7 +7,6 @@
#include "base/bind.h"
#include "base/bind_helpers.h"
#include "base/command_line.h"
-#include "base/message_loop/message_loop_proxy.h"
#include "base/strings/string_number_conversions.h"
#include "build/build_config.h"
#include "media/audio/audio_output_dispatcher_impl.h"
@@ -99,13 +98,13 @@ AudioManagerBase::AudioManagerBase(AudioLogFactory* audio_log_factory)
if (!cmd_line->HasSwitch(switches::kDisableMainThreadAudio) &&
base::MessageLoopProxy::current().get() &&
base::MessageLoop::current()->IsType(base::MessageLoop::TYPE_UI)) {
- message_loop_ = base::MessageLoopProxy::current();
+ task_runner_ = base::MessageLoopProxy::current();
return;
}
#endif
CHECK(audio_thread_.Start());
- message_loop_ = audio_thread_.message_loop_proxy();
+ task_runner_ = audio_thread_.message_loop_proxy();
}
AudioManagerBase::~AudioManagerBase() {
@@ -125,11 +124,12 @@ base::string16 AudioManagerBase::GetAudioInputDeviceModel() {
return base::string16();
}
-scoped_refptr<base::MessageLoopProxy> AudioManagerBase::GetMessageLoop() {
- return message_loop_;
+scoped_refptr<base::SingleThreadTaskRunner> AudioManagerBase::GetTaskRunner() {
+ return task_runner_;
}
-scoped_refptr<base::MessageLoopProxy> AudioManagerBase::GetWorkerLoop() {
+scoped_refptr<base::SingleThreadTaskRunner>
+AudioManagerBase::GetWorkerTaskRunner() {
// Lazily start the worker thread.
if (!audio_thread_.IsRunning())
CHECK(audio_thread_.Start());
@@ -143,7 +143,7 @@ AudioOutputStream* AudioManagerBase::MakeAudioOutputStream(
const std::string& input_device_id) {
// TODO(miu): Fix ~50 call points across several unit test modules to call
// this method on the audio thread, then uncomment the following:
- // DCHECK(message_loop_->BelongsToCurrentThread());
+ // DCHECK(task_runner_->BelongsToCurrentThread());
if (!params.IsValid()) {
DLOG(ERROR) << "Audio parameters are invalid";
@@ -192,7 +192,7 @@ AudioInputStream* AudioManagerBase::MakeAudioInputStream(
const std::string& device_id) {
// TODO(miu): Fix ~20 call points across several unit test modules to call
// this method on the audio thread, then uncomment the following:
- // DCHECK(message_loop_->BelongsToCurrentThread());
+ // DCHECK(task_runner_->BelongsToCurrentThread());
if (!params.IsValid() || (params.channels() > kMaxInputChannels) ||
device_id.empty()) {
@@ -234,7 +234,7 @@ AudioOutputStream* AudioManagerBase::MakeAudioOutputStreamProxy(
const AudioParameters& params,
const std::string& device_id,
const std::string& input_device_id) {
- DCHECK(message_loop_->BelongsToCurrentThread());
+ DCHECK(task_runner_->BelongsToCurrentThread());
// If the caller supplied an empty device id to select the default device,
// we fetch the actual device id of the default device so that the lookup
@@ -332,10 +332,10 @@ void AudioManagerBase::ReleaseInputStream(AudioInputStream* stream) {
void AudioManagerBase::Shutdown() {
// Only true when we're sharing the UI message loop with the browser. The UI
// loop is no longer running at this time and browser destruction is imminent.
- if (message_loop_->BelongsToCurrentThread()) {
+ if (task_runner_->BelongsToCurrentThread()) {
ShutdownOnAudioThread();
} else {
- message_loop_->PostTask(FROM_HERE, base::Bind(
+ task_runner_->PostTask(FROM_HERE, base::Bind(
&AudioManagerBase::ShutdownOnAudioThread, base::Unretained(this)));
}
@@ -344,7 +344,7 @@ void AudioManagerBase::Shutdown() {
}
void AudioManagerBase::ShutdownOnAudioThread() {
- DCHECK(message_loop_->BelongsToCurrentThread());
+ DCHECK(task_runner_->BelongsToCurrentThread());
AudioOutputDispatchers::iterator it = output_dispatchers_.begin();
for (; it != output_dispatchers_.end(); ++it) {
@@ -365,18 +365,18 @@ void AudioManagerBase::ShutdownOnAudioThread() {
void AudioManagerBase::AddOutputDeviceChangeListener(
AudioDeviceListener* listener) {
- DCHECK(message_loop_->BelongsToCurrentThread());
+ DCHECK(task_runner_->BelongsToCurrentThread());
output_listeners_.AddObserver(listener);
}
void AudioManagerBase::RemoveOutputDeviceChangeListener(
AudioDeviceListener* listener) {
- DCHECK(message_loop_->BelongsToCurrentThread());
+ DCHECK(task_runner_->BelongsToCurrentThread());
output_listeners_.RemoveObserver(listener);
}
void AudioManagerBase::NotifyAllOutputDeviceChangeListeners() {
- DCHECK(message_loop_->BelongsToCurrentThread());
+ DCHECK(task_runner_->BelongsToCurrentThread());
DVLOG(1) << "Firing OnDeviceChange() notifications.";
FOR_EACH_OBSERVER(AudioDeviceListener, output_listeners_, OnDeviceChange());
}
@@ -425,7 +425,7 @@ scoped_ptr<AudioLog> AudioManagerBase::CreateAudioLog(
}
void AudioManagerBase::FixWedgedAudio() {
- DCHECK(message_loop_->BelongsToCurrentThread());
+ DCHECK(task_runner_->BelongsToCurrentThread());
#if defined(OS_MACOSX)
// Through trial and error, we've found that one way to restore audio after a
// hang is to close all outstanding audio streams. Once all streams have been
diff --git a/media/audio/audio_manager_base.h b/media/audio/audio_manager_base.h
index 09b021a..e1ec49b 100644
--- a/media/audio/audio_manager_base.h
+++ b/media/audio/audio_manager_base.h
@@ -48,8 +48,9 @@ class MEDIA_EXPORT AudioManagerBase : public AudioManager {
virtual ~AudioManagerBase();
- virtual scoped_refptr<base::MessageLoopProxy> GetMessageLoop() OVERRIDE;
- virtual scoped_refptr<base::MessageLoopProxy> GetWorkerLoop() OVERRIDE;
+ virtual scoped_refptr<base::SingleThreadTaskRunner> GetTaskRunner() OVERRIDE;
+ virtual scoped_refptr<base::SingleThreadTaskRunner> GetWorkerTaskRunner()
+ OVERRIDE;
virtual base::string16 GetAudioInputDeviceModel() OVERRIDE;
@@ -99,7 +100,7 @@ class MEDIA_EXPORT AudioManagerBase : public AudioManager {
virtual AudioInputStream* MakeLowLatencyInputStream(
const AudioParameters& params, const std::string& device_id) = 0;
- // Listeners will be notified on the AudioManager::GetMessageLoop() loop.
+ // Listeners will be notified on the GetTaskRunner() task runner.
virtual void AddOutputDeviceChangeListener(
AudioDeviceListener* listener) OVERRIDE;
virtual void RemoveOutputDeviceChangeListener(
@@ -187,10 +188,10 @@ class MEDIA_EXPORT AudioManagerBase : public AudioManager {
// Thread used to interact with audio streams created by this audio manager.
base::Thread audio_thread_;
- // The message loop of the audio thread this object runs on. Used for internal
+ // The task runner of the audio thread this object runs on. Used for internal
// tasks which run on the audio thread even after Shutdown() has been started
- // and GetMessageLoop() starts returning NULL.
- scoped_refptr<base::MessageLoopProxy> message_loop_;
+ // and GetTaskRunner() starts returning NULL.
+ scoped_refptr<base::SingleThreadTaskRunner> task_runner_;
// Map of cached AudioOutputDispatcher instances. Must only be touched
// from the audio thread (no locking).
diff --git a/media/audio/audio_output_controller.cc b/media/audio/audio_output_controller.cc
index 92f9f25..97651dc 100644
--- a/media/audio/audio_output_controller.cc
+++ b/media/audio/audio_output_controller.cc
@@ -6,7 +6,6 @@
#include "base/bind.h"
#include "base/debug/trace_event.h"
-#include "base/message_loop/message_loop.h"
#include "base/metrics/histogram.h"
#include "base/task_runner_util.h"
#include "base/threading/platform_thread.h"
@@ -51,7 +50,7 @@ AudioOutputController::AudioOutputController(
state_(kEmpty),
num_allowed_io_(0),
sync_reader_(sync_reader),
- message_loop_(audio_manager->GetMessageLoop()),
+ message_loop_(audio_manager->GetTaskRunner()),
#if defined(AUDIO_POWER_MONITORING)
power_monitor_(
params.sample_rate(),
diff --git a/media/audio/audio_output_controller.h b/media/audio/audio_output_controller.h
index d16ce9e..121b446 100644
--- a/media/audio/audio_output_controller.h
+++ b/media/audio/audio_output_controller.h
@@ -261,7 +261,7 @@ class MEDIA_EXPORT AudioOutputController
SyncReader* const sync_reader_;
// The message loop of audio manager thread that this object runs on.
- const scoped_refptr<base::MessageLoopProxy> message_loop_;
+ const scoped_refptr<base::SingleThreadTaskRunner> message_loop_;
#if defined(AUDIO_POWER_MONITORING)
// Scans audio samples from OnMoreIOData() as input to compute power levels.
diff --git a/media/audio/audio_output_controller_unittest.cc b/media/audio/audio_output_controller_unittest.cc
index 457265e..288acd9 100644
--- a/media/audio/audio_output_controller_unittest.cc
+++ b/media/audio/audio_output_controller_unittest.cc
@@ -166,7 +166,7 @@ class AudioOutputControllerTest : public testing::Test {
// Simulate a device change event to AudioOutputController from the
// AudioManager.
- audio_manager_->GetMessageLoop()->PostTask(
+ audio_manager_->GetTaskRunner()->PostTask(
FROM_HERE,
base::Bind(&AudioOutputController::OnDeviceChange, controller_));
}
diff --git a/media/audio/audio_output_device.cc b/media/audio/audio_output_device.cc
index 1f9efc1..734251a 100644
--- a/media/audio/audio_output_device.cc
+++ b/media/audio/audio_output_device.cc
@@ -6,7 +6,6 @@
#include "base/basictypes.h"
#include "base/debug/trace_event.h"
-#include "base/message_loop/message_loop.h"
#include "base/threading/thread_restrictions.h"
#include "base/time/time.h"
#include "media/audio/audio_output_controller.h"
@@ -40,8 +39,8 @@ class AudioOutputDevice::AudioThreadCallback
AudioOutputDevice::AudioOutputDevice(
scoped_ptr<AudioOutputIPC> ipc,
- const scoped_refptr<base::MessageLoopProxy>& io_loop)
- : ScopedLoopObserver(io_loop),
+ const scoped_refptr<base::SingleThreadTaskRunner>& io_task_runner)
+ : ScopedTaskRunnerObserver(io_task_runner),
callback_(NULL),
ipc_(ipc.Pass()),
state_(IDLE),
@@ -81,7 +80,7 @@ AudioOutputDevice::~AudioOutputDevice() {
void AudioOutputDevice::Start() {
DCHECK(callback_) << "Initialize hasn't been called";
- message_loop()->PostTask(FROM_HERE,
+ task_runner()->PostTask(FROM_HERE,
base::Bind(&AudioOutputDevice::CreateStreamOnIOThread, this,
audio_parameters_));
}
@@ -93,17 +92,17 @@ void AudioOutputDevice::Stop() {
stopping_hack_ = true;
}
- message_loop()->PostTask(FROM_HERE,
+ task_runner()->PostTask(FROM_HERE,
base::Bind(&AudioOutputDevice::ShutDownOnIOThread, this));
}
void AudioOutputDevice::Play() {
- message_loop()->PostTask(FROM_HERE,
+ task_runner()->PostTask(FROM_HERE,
base::Bind(&AudioOutputDevice::PlayOnIOThread, this));
}
void AudioOutputDevice::Pause() {
- message_loop()->PostTask(FROM_HERE,
+ task_runner()->PostTask(FROM_HERE,
base::Bind(&AudioOutputDevice::PauseOnIOThread, this));
}
@@ -111,7 +110,7 @@ bool AudioOutputDevice::SetVolume(double volume) {
if (volume < 0 || volume > 1.0)
return false;
- if (!message_loop()->PostTask(FROM_HERE,
+ if (!task_runner()->PostTask(FROM_HERE,
base::Bind(&AudioOutputDevice::SetVolumeOnIOThread, this, volume))) {
return false;
}
@@ -120,7 +119,7 @@ bool AudioOutputDevice::SetVolume(double volume) {
}
void AudioOutputDevice::CreateStreamOnIOThread(const AudioParameters& params) {
- DCHECK(message_loop()->BelongsToCurrentThread());
+ DCHECK(task_runner()->BelongsToCurrentThread());
if (state_ == IDLE) {
state_ = CREATING_STREAM;
ipc_->CreateStream(this, params, session_id_);
@@ -128,7 +127,7 @@ void AudioOutputDevice::CreateStreamOnIOThread(const AudioParameters& params) {
}
void AudioOutputDevice::PlayOnIOThread() {
- DCHECK(message_loop()->BelongsToCurrentThread());
+ DCHECK(task_runner()->BelongsToCurrentThread());
if (state_ == PAUSED) {
ipc_->PlayStream();
state_ = PLAYING;
@@ -139,7 +138,7 @@ void AudioOutputDevice::PlayOnIOThread() {
}
void AudioOutputDevice::PauseOnIOThread() {
- DCHECK(message_loop()->BelongsToCurrentThread());
+ DCHECK(task_runner()->BelongsToCurrentThread());
if (state_ == PLAYING) {
ipc_->PauseStream();
state_ = PAUSED;
@@ -148,7 +147,7 @@ void AudioOutputDevice::PauseOnIOThread() {
}
void AudioOutputDevice::ShutDownOnIOThread() {
- DCHECK(message_loop()->BelongsToCurrentThread());
+ DCHECK(task_runner()->BelongsToCurrentThread());
// Close the stream, if we haven't already.
if (state_ >= CREATING_STREAM) {
@@ -172,13 +171,13 @@ void AudioOutputDevice::ShutDownOnIOThread() {
}
void AudioOutputDevice::SetVolumeOnIOThread(double volume) {
- DCHECK(message_loop()->BelongsToCurrentThread());
+ DCHECK(task_runner()->BelongsToCurrentThread());
if (state_ >= CREATING_STREAM)
ipc_->SetVolume(volume);
}
void AudioOutputDevice::OnStateChanged(AudioOutputIPCDelegate::State state) {
- DCHECK(message_loop()->BelongsToCurrentThread());
+ DCHECK(task_runner()->BelongsToCurrentThread());
// Do nothing if the stream has been closed.
if (state_ < CREATING_STREAM)
@@ -211,7 +210,7 @@ void AudioOutputDevice::OnStreamCreated(
base::SharedMemoryHandle handle,
base::SyncSocket::Handle socket_handle,
int length) {
- DCHECK(message_loop()->BelongsToCurrentThread());
+ DCHECK(task_runner()->BelongsToCurrentThread());
#if defined(OS_WIN)
DCHECK(handle);
DCHECK(socket_handle);
@@ -254,7 +253,7 @@ void AudioOutputDevice::OnStreamCreated(
}
void AudioOutputDevice::OnIPCClosed() {
- DCHECK(message_loop()->BelongsToCurrentThread());
+ DCHECK(task_runner()->BelongsToCurrentThread());
state_ = IPC_CLOSED;
ipc_.reset();
}
diff --git a/media/audio/audio_output_device.h b/media/audio/audio_output_device.h
index 66f7897..0b54b9a 100644
--- a/media/audio/audio_output_device.h
+++ b/media/audio/audio_output_device.h
@@ -62,11 +62,10 @@
#include "base/bind.h"
#include "base/memory/scoped_ptr.h"
#include "base/memory/shared_memory.h"
-#include "base/message_loop/message_loop.h"
#include "media/audio/audio_device_thread.h"
#include "media/audio/audio_output_ipc.h"
#include "media/audio/audio_parameters.h"
-#include "media/audio/scoped_loop_observer.h"
+#include "media/audio/scoped_task_runner_observer.h"
#include "media/base/audio_renderer_sink.h"
#include "media/base/media_export.h"
@@ -75,11 +74,12 @@ namespace media {
class MEDIA_EXPORT AudioOutputDevice
: NON_EXPORTED_BASE(public AudioRendererSink),
NON_EXPORTED_BASE(public AudioOutputIPCDelegate),
- NON_EXPORTED_BASE(public ScopedLoopObserver) {
+ NON_EXPORTED_BASE(public ScopedTaskRunnerObserver) {
public:
// NOTE: Clients must call Initialize() before using.
- AudioOutputDevice(scoped_ptr<AudioOutputIPC> ipc,
- const scoped_refptr<base::MessageLoopProxy>& io_loop);
+ AudioOutputDevice(
+ scoped_ptr<AudioOutputIPC> ipc,
+ const scoped_refptr<base::SingleThreadTaskRunner>& io_task_runner);
// Initialize function for clients wishing to have unified input and
// output, |params| may specify |input_channels| > 0, representing a
diff --git a/media/audio/audio_output_dispatcher.cc b/media/audio/audio_output_dispatcher.cc
index 89912c0..1e78c9d 100644
--- a/media/audio/audio_output_dispatcher.cc
+++ b/media/audio/audio_output_dispatcher.cc
@@ -4,7 +4,7 @@
#include "media/audio/audio_output_dispatcher.h"
-#include "base/message_loop/message_loop_proxy.h"
+#include "base/single_thread_task_runner.h"
namespace media {
@@ -14,17 +14,17 @@ AudioOutputDispatcher::AudioOutputDispatcher(
const std::string& output_device_id,
const std::string& input_device_id)
: audio_manager_(audio_manager),
- message_loop_(audio_manager->GetMessageLoop()),
+ task_runner_(audio_manager->GetTaskRunner()),
params_(params),
output_device_id_(output_device_id),
input_device_id_(input_device_id) {
// We expect to be instantiated on the audio thread. Otherwise the
- // message_loop_ member will point to the wrong message loop!
- DCHECK(audio_manager->GetMessageLoop()->BelongsToCurrentThread());
+ // |task_runner_| member will point to the wrong message loop!
+ DCHECK(audio_manager->GetTaskRunner()->BelongsToCurrentThread());
}
AudioOutputDispatcher::~AudioOutputDispatcher() {
- DCHECK(message_loop_->BelongsToCurrentThread());
+ DCHECK(task_runner_->BelongsToCurrentThread());
}
} // namespace media
diff --git a/media/audio/audio_output_dispatcher.h b/media/audio/audio_output_dispatcher.h
index d707aff..69c5f16 100644
--- a/media/audio/audio_output_dispatcher.h
+++ b/media/audio/audio_output_dispatcher.h
@@ -26,7 +26,7 @@
#include "media/audio/audio_parameters.h"
namespace base {
-class MessageLoopProxy;
+class SingleThreadTaskRunner;
}
namespace media {
@@ -83,7 +83,7 @@ class MEDIA_EXPORT AudioOutputDispatcher
// A no-reference-held pointer (we don't want circular references) back to the
// AudioManager that owns this object.
AudioManager* audio_manager_;
- const scoped_refptr<base::MessageLoopProxy> message_loop_;
+ const scoped_refptr<base::SingleThreadTaskRunner> task_runner_;
const AudioParameters params_;
std::string output_device_id_;
const std::string input_device_id_;
diff --git a/media/audio/audio_output_dispatcher_impl.cc b/media/audio/audio_output_dispatcher_impl.cc
index 5118bef..d2e1d1c 100644
--- a/media/audio/audio_output_dispatcher_impl.cc
+++ b/media/audio/audio_output_dispatcher_impl.cc
@@ -8,7 +8,7 @@
#include "base/bind.h"
#include "base/compiler_specific.h"
-#include "base/message_loop/message_loop.h"
+#include "base/single_thread_task_runner.h"
#include "base/time/time.h"
#include "media/audio/audio_io.h"
#include "media/audio/audio_output_proxy.h"
@@ -41,7 +41,7 @@ AudioOutputDispatcherImpl::~AudioOutputDispatcherImpl() {
}
bool AudioOutputDispatcherImpl::OpenStream() {
- DCHECK(message_loop_->BelongsToCurrentThread());
+ DCHECK(task_runner_->BelongsToCurrentThread());
// Ensure that there is at least one open stream.
if (idle_streams_.empty() && !CreateAndOpenStream())
@@ -55,7 +55,7 @@ bool AudioOutputDispatcherImpl::OpenStream() {
bool AudioOutputDispatcherImpl::StartStream(
AudioOutputStream::AudioSourceCallback* callback,
AudioOutputProxy* stream_proxy) {
- DCHECK(message_loop_->BelongsToCurrentThread());
+ DCHECK(task_runner_->BelongsToCurrentThread());
DCHECK(proxy_to_physical_map_.find(stream_proxy) ==
proxy_to_physical_map_.end());
@@ -82,7 +82,7 @@ bool AudioOutputDispatcherImpl::StartStream(
}
void AudioOutputDispatcherImpl::StopStream(AudioOutputProxy* stream_proxy) {
- DCHECK(message_loop_->BelongsToCurrentThread());
+ DCHECK(task_runner_->BelongsToCurrentThread());
AudioStreamMap::iterator it = proxy_to_physical_map_.find(stream_proxy);
DCHECK(it != proxy_to_physical_map_.end());
@@ -99,7 +99,7 @@ void AudioOutputDispatcherImpl::StopStream(AudioOutputProxy* stream_proxy) {
void AudioOutputDispatcherImpl::StreamVolumeSet(AudioOutputProxy* stream_proxy,
double volume) {
- DCHECK(message_loop_->BelongsToCurrentThread());
+ DCHECK(task_runner_->BelongsToCurrentThread());
AudioStreamMap::iterator it = proxy_to_physical_map_.find(stream_proxy);
if (it != proxy_to_physical_map_.end()) {
AudioOutputStream* physical_stream = it->second;
@@ -109,7 +109,7 @@ void AudioOutputDispatcherImpl::StreamVolumeSet(AudioOutputProxy* stream_proxy,
}
void AudioOutputDispatcherImpl::CloseStream(AudioOutputProxy* stream_proxy) {
- DCHECK(message_loop_->BelongsToCurrentThread());
+ DCHECK(task_runner_->BelongsToCurrentThread());
DCHECK_GT(idle_proxies_, 0u);
--idle_proxies_;
@@ -121,7 +121,7 @@ void AudioOutputDispatcherImpl::CloseStream(AudioOutputProxy* stream_proxy) {
}
void AudioOutputDispatcherImpl::Shutdown() {
- DCHECK(message_loop_->BelongsToCurrentThread());
+ DCHECK(task_runner_->BelongsToCurrentThread());
// Close all idle streams immediately. The |close_timer_| will handle
// invalidating any outstanding tasks upon its destruction.
@@ -129,7 +129,7 @@ void AudioOutputDispatcherImpl::Shutdown() {
}
bool AudioOutputDispatcherImpl::CreateAndOpenStream() {
- DCHECK(message_loop_->BelongsToCurrentThread());
+ DCHECK(task_runner_->BelongsToCurrentThread());
AudioOutputStream* stream = audio_manager_->MakeAudioOutputStream(
params_, output_device_id_, input_device_id_);
if (!stream)
@@ -150,12 +150,12 @@ bool AudioOutputDispatcherImpl::CreateAndOpenStream() {
}
void AudioOutputDispatcherImpl::CloseAllIdleStreams() {
- DCHECK(message_loop_->BelongsToCurrentThread());
+ DCHECK(task_runner_->BelongsToCurrentThread());
CloseIdleStreams(0);
}
void AudioOutputDispatcherImpl::CloseIdleStreams(size_t keep_alive) {
- DCHECK(message_loop_->BelongsToCurrentThread());
+ DCHECK(task_runner_->BelongsToCurrentThread());
if (idle_streams_.size() <= keep_alive)
return;
for (size_t i = keep_alive; i < idle_streams_.size(); ++i) {
@@ -171,12 +171,12 @@ void AudioOutputDispatcherImpl::CloseIdleStreams(size_t keep_alive) {
}
void AudioOutputDispatcherImpl::CloseStreamsForWedgeFix() {
- DCHECK(message_loop_->BelongsToCurrentThread());
+ DCHECK(task_runner_->BelongsToCurrentThread());
CloseAllIdleStreams();
}
void AudioOutputDispatcherImpl::RestartStreamsForWedgeFix() {
- DCHECK(message_loop_->BelongsToCurrentThread());
+ DCHECK(task_runner_->BelongsToCurrentThread());
// Should only be called when the dispatcher is used with fake streams which
// don't need to be shutdown or restarted.
diff --git a/media/audio/audio_output_proxy_unittest.cc b/media/audio/audio_output_proxy_unittest.cc
index cea0988..1c37dc5 100644
--- a/media/audio/audio_output_proxy_unittest.cc
+++ b/media/audio/audio_output_proxy_unittest.cc
@@ -5,7 +5,6 @@
#include <string>
#include "base/message_loop/message_loop.h"
-#include "base/message_loop/message_loop_proxy.h"
#include "base/run_loop.h"
#include "media/audio/audio_manager.h"
#include "media/audio/audio_manager_base.h"
@@ -105,8 +104,9 @@ class MockAudioManager : public AudioManagerBase {
MOCK_METHOD2(MakeAudioInputStream, AudioInputStream*(
const AudioParameters& params, const std::string& device_id));
MOCK_METHOD0(ShowAudioInputSettings, void());
- MOCK_METHOD0(GetMessageLoop, scoped_refptr<base::MessageLoopProxy>());
- MOCK_METHOD0(GetWorkerLoop, scoped_refptr<base::MessageLoopProxy>());
+ MOCK_METHOD0(GetTaskRunner, scoped_refptr<base::SingleThreadTaskRunner>());
+ MOCK_METHOD0(GetWorkerTaskRunner,
+ scoped_refptr<base::SingleThreadTaskRunner>());
MOCK_METHOD1(GetAudioInputDeviceNames, void(
media::AudioDeviceNames* device_name));
@@ -146,9 +146,9 @@ namespace media {
class AudioOutputProxyTest : public testing::Test {
protected:
virtual void SetUp() {
- EXPECT_CALL(manager_, GetMessageLoop())
+ EXPECT_CALL(manager_, GetTaskRunner())
.WillRepeatedly(Return(message_loop_.message_loop_proxy()));
- EXPECT_CALL(manager_, GetWorkerLoop())
+ EXPECT_CALL(manager_, GetWorkerTaskRunner())
.WillRepeatedly(Return(message_loop_.message_loop_proxy()));
// Use a low sample rate and large buffer size when testing otherwise the
// FakeAudioOutputStream will keep the message loop busy indefinitely; i.e.,
diff --git a/media/audio/audio_output_resampler.cc b/media/audio/audio_output_resampler.cc
index c53f3e0..e6fcc56 100644
--- a/media/audio/audio_output_resampler.cc
+++ b/media/audio/audio_output_resampler.cc
@@ -7,8 +7,8 @@
#include "base/bind.h"
#include "base/bind_helpers.h"
#include "base/compiler_specific.h"
-#include "base/message_loop/message_loop.h"
#include "base/metrics/histogram.h"
+#include "base/single_thread_task_runner.h"
#include "base/time/time.h"
#include "build/build_config.h"
#include "media/audio/audio_io.h"
@@ -174,7 +174,7 @@ void AudioOutputResampler::Initialize() {
}
bool AudioOutputResampler::OpenStream() {
- DCHECK(message_loop_->BelongsToCurrentThread());
+ DCHECK(task_runner_->BelongsToCurrentThread());
if (dispatcher_->OpenStream()) {
// Only record the UMA statistic if we didn't fallback during construction
@@ -233,7 +233,7 @@ bool AudioOutputResampler::OpenStream() {
bool AudioOutputResampler::StartStream(
AudioOutputStream::AudioSourceCallback* callback,
AudioOutputProxy* stream_proxy) {
- DCHECK(message_loop_->BelongsToCurrentThread());
+ DCHECK(task_runner_->BelongsToCurrentThread());
OnMoreDataConverter* resampler_callback = NULL;
CallbackMap::iterator it = callbacks_.find(stream_proxy);
@@ -253,12 +253,12 @@ bool AudioOutputResampler::StartStream(
void AudioOutputResampler::StreamVolumeSet(AudioOutputProxy* stream_proxy,
double volume) {
- DCHECK(message_loop_->BelongsToCurrentThread());
+ DCHECK(task_runner_->BelongsToCurrentThread());
dispatcher_->StreamVolumeSet(stream_proxy, volume);
}
void AudioOutputResampler::StopStream(AudioOutputProxy* stream_proxy) {
- DCHECK(message_loop_->BelongsToCurrentThread());
+ DCHECK(task_runner_->BelongsToCurrentThread());
dispatcher_->StopStream(stream_proxy);
// Now that StopStream() has completed the underlying physical stream should
@@ -270,7 +270,7 @@ void AudioOutputResampler::StopStream(AudioOutputProxy* stream_proxy) {
}
void AudioOutputResampler::CloseStream(AudioOutputProxy* stream_proxy) {
- DCHECK(message_loop_->BelongsToCurrentThread());
+ DCHECK(task_runner_->BelongsToCurrentThread());
dispatcher_->CloseStream(stream_proxy);
// We assume that StopStream() is always called prior to CloseStream(), so
@@ -283,7 +283,7 @@ void AudioOutputResampler::CloseStream(AudioOutputProxy* stream_proxy) {
}
void AudioOutputResampler::Shutdown() {
- DCHECK(message_loop_->BelongsToCurrentThread());
+ DCHECK(task_runner_->BelongsToCurrentThread());
// No AudioOutputProxy objects should hold a reference to us when we get
// to this stage.
@@ -294,7 +294,7 @@ void AudioOutputResampler::Shutdown() {
}
void AudioOutputResampler::CloseStreamsForWedgeFix() {
- DCHECK(message_loop_->BelongsToCurrentThread());
+ DCHECK(task_runner_->BelongsToCurrentThread());
// Stop and close all active streams. Once all streams across all dispatchers
// have been closed the AudioManager will call RestartStreamsForWedgeFix().
@@ -310,7 +310,7 @@ void AudioOutputResampler::CloseStreamsForWedgeFix() {
}
void AudioOutputResampler::RestartStreamsForWedgeFix() {
- DCHECK(message_loop_->BelongsToCurrentThread());
+ DCHECK(task_runner_->BelongsToCurrentThread());
// By opening all streams first and then starting them one by one we ensure
// the dispatcher only opens streams for those which will actually be used.
for (CallbackMap::iterator it = callbacks_.begin(); it != callbacks_.end();
diff --git a/media/audio/clockless_audio_sink.h b/media/audio/clockless_audio_sink.h
index 9e73b1a..bf68896 100644
--- a/media/audio/clockless_audio_sink.h
+++ b/media/audio/clockless_audio_sink.h
@@ -10,7 +10,7 @@
#include "media/base/audio_renderer_sink.h"
namespace base {
-class MessageLoopProxy;
+class SingleThreadTaskRunner;
}
namespace media {
diff --git a/media/audio/fake_audio_consumer.cc b/media/audio/fake_audio_consumer.cc
index 55c439a..ca99424 100644
--- a/media/audio/fake_audio_consumer.cc
+++ b/media/audio/fake_audio_consumer.cc
@@ -7,10 +7,10 @@
#include "base/bind.h"
#include "base/bind_helpers.h"
#include "base/cancelable_callback.h"
+#include "base/location.h"
#include "base/logging.h"
#include "base/memory/scoped_ptr.h"
-#include "base/message_loop/message_loop.h"
-#include "base/message_loop/message_loop_proxy.h"
+#include "base/single_thread_task_runner.h"
#include "base/synchronization/lock.h"
#include "base/threading/thread_checker.h"
#include "base/time/time.h"
@@ -22,7 +22,7 @@ namespace media {
class FakeAudioConsumer::Worker
: public base::RefCountedThreadSafe<FakeAudioConsumer::Worker> {
public:
- Worker(const scoped_refptr<base::MessageLoopProxy>& worker_loop,
+ Worker(const scoped_refptr<base::SingleThreadTaskRunner>& worker_task_runner,
const AudioParameters& params);
bool IsStopped();
@@ -44,7 +44,7 @@ class FakeAudioConsumer::Worker
// the worker loop.
void DoRead();
- const scoped_refptr<base::MessageLoopProxy> worker_loop_;
+ const scoped_refptr<base::SingleThreadTaskRunner> worker_task_runner_;
const scoped_ptr<AudioBus> audio_bus_;
const base::TimeDelta buffer_duration_;
@@ -61,9 +61,9 @@ class FakeAudioConsumer::Worker
};
FakeAudioConsumer::FakeAudioConsumer(
- const scoped_refptr<base::MessageLoopProxy>& worker_loop,
+ const scoped_refptr<base::SingleThreadTaskRunner>& worker_task_runner,
const AudioParameters& params)
- : worker_(new Worker(worker_loop, params)) {
+ : worker_(new Worker(worker_task_runner, params)) {
}
FakeAudioConsumer::~FakeAudioConsumer() {
@@ -80,9 +80,9 @@ void FakeAudioConsumer::Stop() {
}
FakeAudioConsumer::Worker::Worker(
- const scoped_refptr<base::MessageLoopProxy>& worker_loop,
+ const scoped_refptr<base::SingleThreadTaskRunner>& worker_task_runner,
const AudioParameters& params)
- : worker_loop_(worker_loop),
+ : worker_task_runner_(worker_task_runner),
audio_bus_(AudioBus::Create(params)),
buffer_duration_(base::TimeDelta::FromMicroseconds(
params.frames_per_buffer() * base::Time::kMicrosecondsPerSecond /
@@ -111,11 +111,11 @@ void FakeAudioConsumer::Worker::Start(const ReadCB& read_cb) {
DCHECK(read_cb_.is_null());
read_cb_ = read_cb;
}
- worker_loop_->PostTask(FROM_HERE, base::Bind(&Worker::DoStart, this));
+ worker_task_runner_->PostTask(FROM_HERE, base::Bind(&Worker::DoStart, this));
}
void FakeAudioConsumer::Worker::DoStart() {
- DCHECK(worker_loop_->BelongsToCurrentThread());
+ DCHECK(worker_task_runner_->BelongsToCurrentThread());
next_read_time_ = base::TimeTicks::Now();
read_task_cb_.Reset(base::Bind(&Worker::DoRead, this));
read_task_cb_.callback().Run();
@@ -129,16 +129,16 @@ void FakeAudioConsumer::Worker::Stop() {
return;
read_cb_.Reset();
}
- worker_loop_->PostTask(FROM_HERE, base::Bind(&Worker::DoCancel, this));
+ worker_task_runner_->PostTask(FROM_HERE, base::Bind(&Worker::DoCancel, this));
}
void FakeAudioConsumer::Worker::DoCancel() {
- DCHECK(worker_loop_->BelongsToCurrentThread());
+ DCHECK(worker_task_runner_->BelongsToCurrentThread());
read_task_cb_.Cancel();
}
void FakeAudioConsumer::Worker::DoRead() {
- DCHECK(worker_loop_->BelongsToCurrentThread());
+ DCHECK(worker_task_runner_->BelongsToCurrentThread());
{
base::AutoLock scoped_lock(read_cb_lock_);
@@ -156,7 +156,8 @@ void FakeAudioConsumer::Worker::DoRead() {
delay += buffer_duration_ * (-delay / buffer_duration_ + 1);
next_read_time_ = now + delay;
- worker_loop_->PostDelayedTask(FROM_HERE, read_task_cb_.callback(), delay);
+ worker_task_runner_->PostDelayedTask(
+ FROM_HERE, read_task_cb_.callback(), delay);
}
} // namespace media
diff --git a/media/audio/fake_audio_consumer.h b/media/audio/fake_audio_consumer.h
index 5037356..18c552a 100644
--- a/media/audio/fake_audio_consumer.h
+++ b/media/audio/fake_audio_consumer.h
@@ -10,7 +10,7 @@
#include "media/base/media_export.h"
namespace base {
-class MessageLoopProxy;
+class SingleThreadTaskRunner;
}
namespace media {
@@ -21,12 +21,13 @@ class AudioParameters;
// simulate a real time consumer of audio data.
class MEDIA_EXPORT FakeAudioConsumer {
public:
- // |worker_loop| is the loop on which the ReadCB provided to Start() will be
- // executed on. This may or may not be the be for the same thread that
- // invokes the Start/Stop methods.
+ // |worker_task_runner| is the task runner on which the ReadCB provided to
+ // Start() will be executed on. This may or may not be the be for the same
+ // thread that invokes the Start/Stop methods.
// |params| is used to determine the frequency of callbacks.
- FakeAudioConsumer(const scoped_refptr<base::MessageLoopProxy>& worker_loop,
- const AudioParameters& params);
+ FakeAudioConsumer(
+ const scoped_refptr<base::SingleThreadTaskRunner>& worker_task_runner,
+ const AudioParameters& params);
~FakeAudioConsumer();
// Start executing |read_cb| at a regular intervals. Stop() must be called by
diff --git a/media/audio/fake_audio_output_stream.cc b/media/audio/fake_audio_output_stream.cc
index fb460ab..0448c23 100644
--- a/media/audio/fake_audio_output_stream.cc
+++ b/media/audio/fake_audio_output_stream.cc
@@ -7,7 +7,7 @@
#include "base/bind.h"
#include "base/bind_helpers.h"
#include "base/logging.h"
-#include "base/message_loop/message_loop.h"
+#include "base/single_thread_task_runner.h"
#include "media/audio/audio_manager_base.h"
namespace media {
@@ -22,7 +22,7 @@ FakeAudioOutputStream::FakeAudioOutputStream(AudioManagerBase* manager,
const AudioParameters& params)
: audio_manager_(manager),
callback_(NULL),
- fake_consumer_(manager->GetWorkerLoop(), params) {
+ fake_consumer_(manager->GetWorkerTaskRunner(), params) {
}
FakeAudioOutputStream::~FakeAudioOutputStream() {
@@ -30,26 +30,26 @@ FakeAudioOutputStream::~FakeAudioOutputStream() {
}
bool FakeAudioOutputStream::Open() {
- DCHECK(audio_manager_->GetMessageLoop()->BelongsToCurrentThread());
+ DCHECK(audio_manager_->GetTaskRunner()->BelongsToCurrentThread());
return true;
}
void FakeAudioOutputStream::Start(AudioSourceCallback* callback) {
- DCHECK(audio_manager_->GetMessageLoop()->BelongsToCurrentThread());
+ DCHECK(audio_manager_->GetTaskRunner()->BelongsToCurrentThread());
callback_ = callback;
fake_consumer_.Start(base::Bind(
&FakeAudioOutputStream::CallOnMoreData, base::Unretained(this)));
}
void FakeAudioOutputStream::Stop() {
- DCHECK(audio_manager_->GetMessageLoop()->BelongsToCurrentThread());
+ DCHECK(audio_manager_->GetTaskRunner()->BelongsToCurrentThread());
fake_consumer_.Stop();
callback_ = NULL;
}
void FakeAudioOutputStream::Close() {
DCHECK(!callback_);
- DCHECK(audio_manager_->GetMessageLoop()->BelongsToCurrentThread());
+ DCHECK(audio_manager_->GetTaskRunner()->BelongsToCurrentThread());
audio_manager_->ReleaseOutputStream(this);
}
@@ -60,7 +60,7 @@ void FakeAudioOutputStream::GetVolume(double* volume) {
};
void FakeAudioOutputStream::CallOnMoreData(AudioBus* audio_bus) {
- DCHECK(audio_manager_->GetWorkerLoop()->BelongsToCurrentThread());
+ DCHECK(audio_manager_->GetWorkerTaskRunner()->BelongsToCurrentThread());
callback_->OnMoreData(audio_bus, AudioBuffersState());
}
diff --git a/media/audio/mac/audio_manager_mac.cc b/media/audio/mac/audio_manager_mac.cc
index be7dddd..1dca1c3 100644
--- a/media/audio/mac/audio_manager_mac.cc
+++ b/media/audio/mac/audio_manager_mac.cc
@@ -230,17 +230,17 @@ AudioManagerMac::AudioManagerMac(AudioLogFactory* audio_log_factory)
// Task must be posted last to avoid races from handing out "this" to the
// audio thread. Always PostTask even if we're on the right thread since
// AudioManager creation is on the startup path and this may be slow.
- GetMessageLoop()->PostTask(FROM_HERE, base::Bind(
+ GetTaskRunner()->PostTask(FROM_HERE, base::Bind(
&AudioManagerMac::CreateDeviceListener, base::Unretained(this)));
}
AudioManagerMac::~AudioManagerMac() {
- if (GetMessageLoop()->BelongsToCurrentThread()) {
+ if (GetTaskRunner()->BelongsToCurrentThread()) {
DestroyDeviceListener();
} else {
// It's safe to post a task here since Shutdown() will wait for all tasks to
// complete before returning.
- GetMessageLoop()->PostTask(FROM_HERE, base::Bind(
+ GetTaskRunner()->PostTask(FROM_HERE, base::Bind(
&AudioManagerMac::DestroyDeviceListener, base::Unretained(this)));
}
@@ -693,7 +693,7 @@ AudioParameters AudioManagerMac::GetPreferredOutputStreamParameters(
}
void AudioManagerMac::CreateDeviceListener() {
- DCHECK(GetMessageLoop()->BelongsToCurrentThread());
+ DCHECK(GetTaskRunner()->BelongsToCurrentThread());
// Get a baseline for the sample-rate and current device,
// so we can intelligently handle device notifications only when necessary.
@@ -706,13 +706,13 @@ void AudioManagerMac::CreateDeviceListener() {
}
void AudioManagerMac::DestroyDeviceListener() {
- DCHECK(GetMessageLoop()->BelongsToCurrentThread());
+ DCHECK(GetTaskRunner()->BelongsToCurrentThread());
output_device_listener_.reset();
}
void AudioManagerMac::HandleDeviceChanges() {
- if (!GetMessageLoop()->BelongsToCurrentThread()) {
- GetMessageLoop()->PostTask(FROM_HERE, base::Bind(
+ if (!GetTaskRunner()->BelongsToCurrentThread()) {
+ GetTaskRunner()->PostTask(FROM_HERE, base::Bind(
&AudioManagerMac::HandleDeviceChanges, base::Unretained(this)));
return;
}
diff --git a/media/audio/mac/audio_manager_mac.h b/media/audio/mac/audio_manager_mac.h
index fb521c9..898c7e9 100644
--- a/media/audio/mac/audio_manager_mac.h
+++ b/media/audio/mac/audio_manager_mac.h
@@ -10,7 +10,6 @@
#include "base/basictypes.h"
#include "base/compiler_specific.h"
-#include "base/message_loop/message_loop_proxy.h"
#include "media/audio/audio_manager_base.h"
#include "media/audio/mac/aggregate_device_manager.h"
#include "media/audio/mac/audio_device_listener_mac.h"
diff --git a/media/audio/mock_audio_manager.cc b/media/audio/mock_audio_manager.cc
index f2074d6..5984790 100644
--- a/media/audio/mock_audio_manager.cc
+++ b/media/audio/mock_audio_manager.cc
@@ -5,14 +5,14 @@
#include "media/audio/mock_audio_manager.h"
#include "base/logging.h"
-#include "base/message_loop/message_loop_proxy.h"
+#include "base/single_thread_task_runner.h"
#include "media/audio/audio_parameters.h"
namespace media {
-MockAudioManager::MockAudioManager(base::MessageLoopProxy* message_loop_proxy)
- : message_loop_proxy_(message_loop_proxy) {
-}
+MockAudioManager::MockAudioManager(
+ const scoped_refptr<base::SingleThreadTaskRunner>& task_runner)
+ : task_runner_(task_runner) {}
MockAudioManager::~MockAudioManager() {
}
@@ -68,12 +68,13 @@ media::AudioInputStream* MockAudioManager::MakeAudioInputStream(
return NULL;
}
-scoped_refptr<base::MessageLoopProxy> MockAudioManager::GetMessageLoop() {
- return message_loop_proxy_;
+scoped_refptr<base::SingleThreadTaskRunner> MockAudioManager::GetTaskRunner() {
+ return task_runner_;
}
-scoped_refptr<base::MessageLoopProxy> MockAudioManager::GetWorkerLoop() {
- return message_loop_proxy_;
+scoped_refptr<base::SingleThreadTaskRunner>
+MockAudioManager::GetWorkerTaskRunner() {
+ return task_runner_;
}
void MockAudioManager::AddOutputDeviceChangeListener(
diff --git a/media/audio/mock_audio_manager.h b/media/audio/mock_audio_manager.h
index 2d71fe8..0cd79e7 100644
--- a/media/audio/mock_audio_manager.h
+++ b/media/audio/mock_audio_manager.h
@@ -21,7 +21,8 @@ namespace media {
// synchronization purposes).
class MockAudioManager : public media::AudioManager {
public:
- explicit MockAudioManager(base::MessageLoopProxy* message_loop_proxy);
+ explicit MockAudioManager(
+ const scoped_refptr<base::SingleThreadTaskRunner>& task_runner);
virtual bool HasAudioOutputDevices() OVERRIDE;
@@ -51,8 +52,9 @@ class MockAudioManager : public media::AudioManager {
const media::AudioParameters& params,
const std::string& device_id) OVERRIDE;
- virtual scoped_refptr<base::MessageLoopProxy> GetMessageLoop() OVERRIDE;
- virtual scoped_refptr<base::MessageLoopProxy> GetWorkerLoop() OVERRIDE;
+ virtual scoped_refptr<base::SingleThreadTaskRunner> GetTaskRunner() OVERRIDE;
+ virtual scoped_refptr<base::SingleThreadTaskRunner> GetWorkerTaskRunner()
+ OVERRIDE;
virtual void AddOutputDeviceChangeListener(
AudioDeviceListener* listener) OVERRIDE;
@@ -76,7 +78,7 @@ class MockAudioManager : public media::AudioManager {
virtual ~MockAudioManager();
private:
- scoped_refptr<base::MessageLoopProxy> message_loop_proxy_;
+ scoped_refptr<base::SingleThreadTaskRunner> task_runner_;
DISALLOW_COPY_AND_ASSIGN(MockAudioManager);
};
diff --git a/media/audio/null_audio_sink.cc b/media/audio/null_audio_sink.cc
index 607d7d8..dfd07fc 100644
--- a/media/audio/null_audio_sink.cc
+++ b/media/audio/null_audio_sink.cc
@@ -5,18 +5,18 @@
#include "media/audio/null_audio_sink.h"
#include "base/bind.h"
-#include "base/message_loop/message_loop_proxy.h"
+#include "base/single_thread_task_runner.h"
#include "media/audio/fake_audio_consumer.h"
#include "media/base/audio_hash.h"
namespace media {
NullAudioSink::NullAudioSink(
- const scoped_refptr<base::MessageLoopProxy>& message_loop)
+ const scoped_refptr<base::SingleThreadTaskRunner>& task_runner)
: initialized_(false),
playing_(false),
callback_(NULL),
- message_loop_(message_loop) {
+ task_runner_(task_runner) {
}
NullAudioSink::~NullAudioSink() {}
@@ -24,18 +24,18 @@ NullAudioSink::~NullAudioSink() {}
void NullAudioSink::Initialize(const AudioParameters& params,
RenderCallback* callback) {
DCHECK(!initialized_);
- fake_consumer_.reset(new FakeAudioConsumer(message_loop_, params));
+ fake_consumer_.reset(new FakeAudioConsumer(task_runner_, params));
callback_ = callback;
initialized_ = true;
}
void NullAudioSink::Start() {
- DCHECK(message_loop_->BelongsToCurrentThread());
+ DCHECK(task_runner_->BelongsToCurrentThread());
DCHECK(!playing_);
}
void NullAudioSink::Stop() {
- DCHECK(message_loop_->BelongsToCurrentThread());
+ DCHECK(task_runner_->BelongsToCurrentThread());
// Stop may be called at any time, so we have to check before stopping.
if (fake_consumer_)
@@ -43,7 +43,7 @@ void NullAudioSink::Stop() {
}
void NullAudioSink::Play() {
- DCHECK(message_loop_->BelongsToCurrentThread());
+ DCHECK(task_runner_->BelongsToCurrentThread());
DCHECK(initialized_);
if (playing_)
@@ -55,7 +55,7 @@ void NullAudioSink::Play() {
}
void NullAudioSink::Pause() {
- DCHECK(message_loop_->BelongsToCurrentThread());
+ DCHECK(task_runner_->BelongsToCurrentThread());
if (!playing_)
return;
@@ -70,7 +70,7 @@ bool NullAudioSink::SetVolume(double volume) {
}
void NullAudioSink::CallRender(AudioBus* audio_bus) {
- DCHECK(message_loop_->BelongsToCurrentThread());
+ DCHECK(task_runner_->BelongsToCurrentThread());
int frames_received = callback_->Render(audio_bus, 0);
if (!audio_hash_ || frames_received <= 0)
diff --git a/media/audio/null_audio_sink.h b/media/audio/null_audio_sink.h
index 0724146..c28a2cf 100644
--- a/media/audio/null_audio_sink.h
+++ b/media/audio/null_audio_sink.h
@@ -11,7 +11,7 @@
#include "media/base/audio_renderer_sink.h"
namespace base {
-class MessageLoopProxy;
+class SingleThreadTaskRunner;
}
namespace media {
@@ -22,7 +22,7 @@ class FakeAudioConsumer;
class MEDIA_EXPORT NullAudioSink
: NON_EXPORTED_BASE(public AudioRendererSink) {
public:
- NullAudioSink(const scoped_refptr<base::MessageLoopProxy>& message_loop);
+ NullAudioSink(const scoped_refptr<base::SingleThreadTaskRunner>& task_runner);
// AudioRendererSink implementation.
virtual void Initialize(const AudioParameters& params,
@@ -53,7 +53,7 @@ class MEDIA_EXPORT NullAudioSink
// Controls whether or not a running hash is computed for audio frames.
scoped_ptr<AudioHash> audio_hash_;
- scoped_refptr<base::MessageLoopProxy> message_loop_;
+ scoped_refptr<base::SingleThreadTaskRunner> task_runner_;
scoped_ptr<FakeAudioConsumer> fake_consumer_;
DISALLOW_COPY_AND_ASSIGN(NullAudioSink);
diff --git a/media/audio/pulse/pulse_output.cc b/media/audio/pulse/pulse_output.cc
index c40d4f6..bfa963f 100644
--- a/media/audio/pulse/pulse_output.cc
+++ b/media/audio/pulse/pulse_output.cc
@@ -6,7 +6,7 @@
#include <pulse/pulseaudio.h>
-#include "base/message_loop/message_loop.h"
+#include "base/single_thread_task_runner.h"
#include "media/audio/audio_manager_base.h"
#include "media/audio/audio_parameters.h"
#include "media/audio/pulse/pulse_util.h"
@@ -47,7 +47,7 @@ PulseAudioOutputStream::PulseAudioOutputStream(const AudioParameters& params,
pa_stream_(NULL),
volume_(1.0f),
source_callback_(NULL) {
- DCHECK(manager_->GetMessageLoop()->BelongsToCurrentThread());
+ DCHECK(manager_->GetTaskRunner()->BelongsToCurrentThread());
CHECK(params_.IsValid());
audio_bus_ = AudioBus::Create(params_);
@@ -62,7 +62,7 @@ PulseAudioOutputStream::~PulseAudioOutputStream() {
}
bool PulseAudioOutputStream::Open() {
- DCHECK(manager_->GetMessageLoop()->BelongsToCurrentThread());
+ DCHECK(manager_->GetTaskRunner()->BelongsToCurrentThread());
return pulse::CreateOutputStream(&pa_mainloop_, &pa_context_, &pa_stream_,
params_, &StreamNotifyCallback,
&StreamRequestCallback, this);
@@ -107,7 +107,7 @@ void PulseAudioOutputStream::Reset() {
}
void PulseAudioOutputStream::Close() {
- DCHECK(manager_->GetMessageLoop()->BelongsToCurrentThread());
+ DCHECK(manager_->GetTaskRunner()->BelongsToCurrentThread());
Reset();
@@ -157,7 +157,7 @@ void PulseAudioOutputStream::FulfillWriteRequest(size_t requested_bytes) {
}
void PulseAudioOutputStream::Start(AudioSourceCallback* callback) {
- DCHECK(manager_->GetMessageLoop()->BelongsToCurrentThread());
+ DCHECK(manager_->GetTaskRunner()->BelongsToCurrentThread());
CHECK(callback);
CHECK(pa_stream_);
@@ -179,7 +179,7 @@ void PulseAudioOutputStream::Start(AudioSourceCallback* callback) {
}
void PulseAudioOutputStream::Stop() {
- DCHECK(manager_->GetMessageLoop()->BelongsToCurrentThread());
+ DCHECK(manager_->GetTaskRunner()->BelongsToCurrentThread());
// Cork (pause) the stream. Waiting for the main loop lock will ensure
// outstanding callbacks have completed.
@@ -202,13 +202,13 @@ void PulseAudioOutputStream::Stop() {
}
void PulseAudioOutputStream::SetVolume(double volume) {
- DCHECK(manager_->GetMessageLoop()->BelongsToCurrentThread());
+ DCHECK(manager_->GetTaskRunner()->BelongsToCurrentThread());
volume_ = static_cast<float>(volume);
}
void PulseAudioOutputStream::GetVolume(double* volume) {
- DCHECK(manager_->GetMessageLoop()->BelongsToCurrentThread());
+ DCHECK(manager_->GetTaskRunner()->BelongsToCurrentThread());
*volume = volume_;
}
diff --git a/media/audio/pulse/pulse_unified.cc b/media/audio/pulse/pulse_unified.cc
index c68a797..cd17b01 100644
--- a/media/audio/pulse/pulse_unified.cc
+++ b/media/audio/pulse/pulse_unified.cc
@@ -4,7 +4,7 @@
#include "media/audio/pulse/pulse_unified.h"
-#include "base/message_loop/message_loop.h"
+#include "base/single_thread_task_runner.h"
#include "base/time/time.h"
#include "media/audio/audio_manager_base.h"
#include "media/audio/audio_parameters.h"
@@ -54,7 +54,7 @@ PulseAudioUnifiedStream::PulseAudioUnifiedStream(
output_stream_(NULL),
volume_(1.0f),
source_callback_(NULL) {
- DCHECK(manager_->GetMessageLoop()->BelongsToCurrentThread());
+ DCHECK(manager_->GetTaskRunner()->BelongsToCurrentThread());
CHECK(params_.IsValid());
input_bus_ = AudioBus::Create(params_);
output_bus_ = AudioBus::Create(params_);
@@ -70,7 +70,7 @@ PulseAudioUnifiedStream::~PulseAudioUnifiedStream() {
}
bool PulseAudioUnifiedStream::Open() {
- DCHECK(manager_->GetMessageLoop()->BelongsToCurrentThread());
+ DCHECK(manager_->GetTaskRunner()->BelongsToCurrentThread());
// Prepare the recording buffers for the callbacks.
fifo_.reset(new media::SeekableBuffer(
0, kFifoSizeInPackets * params_.GetBytesPerBuffer()));
@@ -138,7 +138,7 @@ void PulseAudioUnifiedStream::Reset() {
}
void PulseAudioUnifiedStream::Close() {
- DCHECK(manager_->GetMessageLoop()->BelongsToCurrentThread());
+ DCHECK(manager_->GetTaskRunner()->BelongsToCurrentThread());
Reset();
// Signal to the manager that we're closed and can be removed.
@@ -211,7 +211,7 @@ void PulseAudioUnifiedStream::ReadData() {
}
void PulseAudioUnifiedStream::Start(AudioSourceCallback* callback) {
- DCHECK(manager_->GetMessageLoop()->BelongsToCurrentThread());
+ DCHECK(manager_->GetTaskRunner()->BelongsToCurrentThread());
CHECK(callback);
CHECK(input_stream_);
CHECK(output_stream_);
@@ -244,7 +244,7 @@ void PulseAudioUnifiedStream::Start(AudioSourceCallback* callback) {
}
void PulseAudioUnifiedStream::Stop() {
- DCHECK(manager_->GetMessageLoop()->BelongsToCurrentThread());
+ DCHECK(manager_->GetTaskRunner()->BelongsToCurrentThread());
// Cork (pause) the stream. Waiting for the main loop lock will ensure
// outstanding callbacks have completed.
@@ -278,13 +278,13 @@ void PulseAudioUnifiedStream::Stop() {
}
void PulseAudioUnifiedStream::SetVolume(double volume) {
- DCHECK(manager_->GetMessageLoop()->BelongsToCurrentThread());
+ DCHECK(manager_->GetTaskRunner()->BelongsToCurrentThread());
volume_ = static_cast<float>(volume);
}
void PulseAudioUnifiedStream::GetVolume(double* volume) {
- DCHECK(manager_->GetMessageLoop()->BelongsToCurrentThread());
+ DCHECK(manager_->GetTaskRunner()->BelongsToCurrentThread());
*volume = volume_;
}
diff --git a/media/audio/scoped_loop_observer.h b/media/audio/scoped_loop_observer.h
deleted file mode 100644
index 7aaab54..0000000
--- a/media/audio/scoped_loop_observer.h
+++ /dev/null
@@ -1,50 +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_AUDIO_SCOPED_LOOP_OBSERVER_H_
-#define MEDIA_AUDIO_SCOPED_LOOP_OBSERVER_H_
-
-#include "base/memory/ref_counted.h"
-#include "base/message_loop/message_loop.h"
-#include "base/message_loop/message_loop_proxy.h"
-
-namespace base {
-class WaitableEvent;
-}
-
-namespace media {
-
-// A common base class for AudioOutputDevice and AudioInputDevice that manages
-// a message loop pointer and monitors it for destruction. If the object goes
-// out of scope before the message loop, the object will automatically remove
-// itself from the message loop's list of destruction observers.
-// NOTE: The class that inherits from this class must implement the
-// WillDestroyCurrentMessageLoop virtual method from DestructionObserver.
-class ScopedLoopObserver
- : public base::MessageLoop::DestructionObserver {
- public:
- explicit ScopedLoopObserver(
- const scoped_refptr<base::MessageLoopProxy>& message_loop);
-
- protected:
- virtual ~ScopedLoopObserver();
-
- // Accessor to the loop that's used by the derived class.
- const scoped_refptr<base::MessageLoopProxy>& message_loop() { return loop_; }
-
- private:
- // Call to add or remove ourselves from the list of destruction observers for
- // the message loop.
- void ObserveLoopDestruction(bool enable, base::WaitableEvent* done);
-
- // A pointer to the message loop's proxy. In case the loop gets destroyed
- // before this object goes out of scope, PostTask etc will fail but not crash.
- scoped_refptr<base::MessageLoopProxy> loop_;
-
- DISALLOW_COPY_AND_ASSIGN(ScopedLoopObserver);
-};
-
-} // namespace media.
-
-#endif // MEDIA_AUDIO_SCOPED_LOOP_OBSERVER_H_
diff --git a/media/audio/scoped_loop_observer.cc b/media/audio/scoped_task_runner_observer.cc
index 01187ec..9f4eac2 100644
--- a/media/audio/scoped_loop_observer.cc
+++ b/media/audio/scoped_task_runner_observer.cc
@@ -2,27 +2,28 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
-#include "media/audio/scoped_loop_observer.h"
+#include "media/audio/scoped_task_runner_observer.h"
#include "base/bind.h"
#include "base/synchronization/waitable_event.h"
namespace media {
-ScopedLoopObserver::ScopedLoopObserver(
- const scoped_refptr<base::MessageLoopProxy>& loop)
- : loop_(loop) {
+ScopedTaskRunnerObserver::ScopedTaskRunnerObserver(
+ const scoped_refptr<base::SingleThreadTaskRunner>& task_runner)
+ : task_runner_(task_runner) {
ObserveLoopDestruction(true, NULL);
}
-ScopedLoopObserver::~ScopedLoopObserver() {
+ScopedTaskRunnerObserver::~ScopedTaskRunnerObserver() {
ObserveLoopDestruction(false, NULL);
}
-void ScopedLoopObserver::ObserveLoopDestruction(bool enable,
- base::WaitableEvent* done) {
+void ScopedTaskRunnerObserver::ObserveLoopDestruction(
+ bool enable,
+ base::WaitableEvent* done) {
// Note: |done| may be NULL.
- if (loop_->BelongsToCurrentThread()) {
+ if (task_runner_->BelongsToCurrentThread()) {
base::MessageLoop* loop = base::MessageLoop::current();
if (enable) {
loop->AddDestructionObserver(this);
@@ -31,8 +32,8 @@ void ScopedLoopObserver::ObserveLoopDestruction(bool enable,
}
} else {
base::WaitableEvent event(false, false);
- if (loop_->PostTask(FROM_HERE,
- base::Bind(&ScopedLoopObserver::ObserveLoopDestruction,
+ if (task_runner_->PostTask(FROM_HERE,
+ base::Bind(&ScopedTaskRunnerObserver::ObserveLoopDestruction,
base::Unretained(this), enable, &event))) {
event.Wait();
} else {
diff --git a/media/audio/scoped_task_runner_observer.h b/media/audio/scoped_task_runner_observer.h
new file mode 100644
index 0000000..ce9adf9
--- /dev/null
+++ b/media/audio/scoped_task_runner_observer.h
@@ -0,0 +1,52 @@
+// 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_AUDIO_SCOPED_TASK_RUNNER_OBSERVER_H_
+#define MEDIA_AUDIO_SCOPED_TASK_RUNNER_OBSERVER_H_
+
+#include "base/memory/ref_counted.h"
+#include "base/message_loop/message_loop.h"
+
+namespace base {
+class SingleThreadTaskRunner;
+class WaitableEvent;
+}
+
+namespace media {
+
+// A common base class for AudioOutputDevice and AudioInputDevice that manages
+// a task runner and monitors it for destruction. If the object goes out of
+// scope before the task runner, the object will automatically remove itself
+// from the task runner's list of destruction observers.
+// NOTE: The class that inherits from this class must implement the
+// WillDestroyCurrentMessageLoop virtual method from DestructionObserver.
+class ScopedTaskRunnerObserver
+ : public base::MessageLoop::DestructionObserver {
+ public:
+ explicit ScopedTaskRunnerObserver(
+ const scoped_refptr<base::SingleThreadTaskRunner>& task_runner);
+
+ protected:
+ virtual ~ScopedTaskRunnerObserver();
+
+ // Accessor to the loop that's used by the derived class.
+ const scoped_refptr<base::SingleThreadTaskRunner>& task_runner() {
+ return task_runner_;
+ }
+
+ private:
+ // Call to add or remove ourselves from the list of destruction observers for
+ // the message loop.
+ void ObserveLoopDestruction(bool enable, base::WaitableEvent* done);
+
+ // A pointer to the task runner. In case it gets destroyed before this object
+ // goes out of scope, PostTask() etc will fail but not crash.
+ scoped_refptr<base::SingleThreadTaskRunner> task_runner_;
+
+ DISALLOW_COPY_AND_ASSIGN(ScopedTaskRunnerObserver);
+};
+
+} // namespace media.
+
+#endif // MEDIA_AUDIO_SCOPED_TASK_RUNNER_OBSERVER_H_
diff --git a/media/audio/sounds/audio_stream_handler.cc b/media/audio/sounds/audio_stream_handler.cc
index 08608ac4..4970976 100644
--- a/media/audio/sounds/audio_stream_handler.cc
+++ b/media/audio/sounds/audio_stream_handler.cc
@@ -7,7 +7,7 @@
#include <string>
#include "base/logging.h"
-#include "base/message_loop/message_loop_proxy.h"
+#include "base/single_thread_task_runner.h"
#include "media/audio/audio_manager.h"
#include "media/audio/audio_manager_base.h"
#include "media/base/channel_layout.h"
@@ -39,11 +39,11 @@ class AudioStreamHandler::AudioStreamContainer
}
virtual ~AudioStreamContainer() {
- DCHECK(AudioManager::Get()->GetMessageLoop()->BelongsToCurrentThread());
+ DCHECK(AudioManager::Get()->GetTaskRunner()->BelongsToCurrentThread());
}
void Play() {
- DCHECK(AudioManager::Get()->GetMessageLoop()->BelongsToCurrentThread());
+ DCHECK(AudioManager::Get()->GetTaskRunner()->BelongsToCurrentThread());
if (!stream_) {
stream_ = AudioManager::Get()->MakeAudioOutputStreamProxy(params_,
@@ -70,7 +70,7 @@ class AudioStreamHandler::AudioStreamContainer
}
void Stop() {
- DCHECK(AudioManager::Get()->GetMessageLoop()->BelongsToCurrentThread());
+ DCHECK(AudioManager::Get()->GetTaskRunner()->BelongsToCurrentThread());
if (!stream_)
return;
stream_->Stop();
@@ -89,7 +89,7 @@ class AudioStreamHandler::AudioStreamContainer
size_t bytes_written = 0;
if (wav_audio_.AtEnd(cursor_) ||
!wav_audio_.CopyTo(dest, cursor_, &bytes_written)) {
- AudioManager::Get()->GetMessageLoop()->PostTask(
+ AudioManager::Get()->GetTaskRunner()->PostTask(
FROM_HERE,
base::Bind(&AudioStreamContainer::Stop, base::Unretained(this)));
return 0;
@@ -142,10 +142,10 @@ AudioStreamHandler::AudioStreamHandler(const base::StringPiece& wav_data)
AudioStreamHandler::~AudioStreamHandler() {
DCHECK(CalledOnValidThread());
- AudioManager::Get()->GetMessageLoop()->PostTask(
+ AudioManager::Get()->GetTaskRunner()->PostTask(
FROM_HERE,
base::Bind(&AudioStreamContainer::Stop, base::Unretained(stream_.get())));
- AudioManager::Get()->GetMessageLoop()->DeleteSoon(FROM_HERE,
+ AudioManager::Get()->GetTaskRunner()->DeleteSoon(FROM_HERE,
stream_.release());
}
@@ -160,7 +160,7 @@ bool AudioStreamHandler::Play() {
if (!IsInitialized())
return false;
- AudioManager::Get()->GetMessageLoop()->PostTask(
+ AudioManager::Get()->GetTaskRunner()->PostTask(
FROM_HERE,
base::Bind(base::IgnoreResult(&AudioStreamContainer::Play),
base::Unretained(stream_.get())));
@@ -169,7 +169,7 @@ bool AudioStreamHandler::Play() {
void AudioStreamHandler::Stop() {
DCHECK(CalledOnValidThread());
- AudioManager::Get()->GetMessageLoop()->PostTask(
+ AudioManager::Get()->GetTaskRunner()->PostTask(
FROM_HERE,
base::Bind(&AudioStreamContainer::Stop, base::Unretained(stream_.get())));
}
diff --git a/media/audio/sounds/sounds_manager.cc b/media/audio/sounds/sounds_manager.cc
index e93dc65..de6ff09 100644
--- a/media/audio/sounds/sounds_manager.cc
+++ b/media/audio/sounds/sounds_manager.cc
@@ -9,7 +9,7 @@
#include "base/logging.h"
#include "base/memory/linked_ptr.h"
#include "base/memory/ref_counted.h"
-#include "base/message_loop/message_loop_proxy.h"
+#include "base/single_thread_task_runner.h"
#include "media/audio/audio_manager.h"
#include "media/audio/sounds/audio_stream_handler.h"
#include "media/base/media_switches.h"
@@ -35,13 +35,14 @@ class SoundsManagerImpl : public SoundsManager {
private:
base::hash_map<SoundKey, linked_ptr<AudioStreamHandler> > handlers_;
- scoped_refptr<base::MessageLoopProxy> message_loop_;
+ scoped_refptr<base::SingleThreadTaskRunner> task_runner_;
DISALLOW_COPY_AND_ASSIGN(SoundsManagerImpl);
};
SoundsManagerImpl::SoundsManagerImpl()
- : message_loop_(AudioManager::Get()->GetMessageLoop()) {}
+ : task_runner_(AudioManager::Get()->GetTaskRunner()) {
+}
SoundsManagerImpl::~SoundsManagerImpl() { DCHECK(CalledOnValidThread()); }
diff --git a/media/audio/test_audio_input_controller_factory.cc b/media/audio/test_audio_input_controller_factory.cc
index 3aeb777..4490dc9 100644
--- a/media/audio/test_audio_input_controller_factory.cc
+++ b/media/audio/test_audio_input_controller_factory.cc
@@ -18,7 +18,7 @@ TestAudioInputController::TestAudioInputController(
audio_parameters_(audio_parameters),
factory_(factory),
event_handler_(event_handler) {
- message_loop_ = audio_manager->GetMessageLoop();
+ task_runner_ = audio_manager->GetTaskRunner();
}
TestAudioInputController::~TestAudioInputController() {
@@ -32,7 +32,7 @@ void TestAudioInputController::Record() {
}
void TestAudioInputController::Close(const base::Closure& closed_task) {
- message_loop_->PostTask(FROM_HERE, closed_task);
+ task_runner_->PostTask(FROM_HERE, closed_task);
if (factory_->delegate_)
factory_->delegate_->TestAudioControllerClosed(this);
}
diff --git a/media/audio/virtual_audio_input_stream.cc b/media/audio/virtual_audio_input_stream.cc
index 91b9f992..f632d3b 100644
--- a/media/audio/virtual_audio_input_stream.cc
+++ b/media/audio/virtual_audio_input_stream.cc
@@ -8,8 +8,7 @@
#include <utility>
#include "base/bind.h"
-#include "base/message_loop/message_loop.h"
-#include "base/message_loop/message_loop_proxy.h"
+#include "base/single_thread_task_runner.h"
#include "media/audio/virtual_audio_output_stream.h"
namespace media {
@@ -50,18 +49,18 @@ class LoopbackAudioConverter : public AudioConverter::InputCallback {
VirtualAudioInputStream::VirtualAudioInputStream(
const AudioParameters& params,
- const scoped_refptr<base::MessageLoopProxy>& worker_loop,
+ const scoped_refptr<base::SingleThreadTaskRunner>& worker_task_runner,
const AfterCloseCallback& after_close_cb)
- : worker_loop_(worker_loop),
+ : worker_task_runner_(worker_task_runner),
after_close_cb_(after_close_cb),
callback_(NULL),
buffer_(new uint8[params.GetBytesPerBuffer()]),
params_(params),
mixer_(params_, params_, false),
num_attached_output_streams_(0),
- fake_consumer_(worker_loop_, params_) {
+ fake_consumer_(worker_task_runner_, params_) {
DCHECK(params_.IsValid());
- DCHECK(worker_loop_.get());
+ DCHECK(worker_task_runner_.get());
// VAIS can be constructed on any thread, but will DCHECK that all
// AudioInputStream methods are called from the same thread.
@@ -134,7 +133,7 @@ void VirtualAudioInputStream::RemoveOutputStream(
}
void VirtualAudioInputStream::PumpAudio(AudioBus* audio_bus) {
- DCHECK(worker_loop_->BelongsToCurrentThread());
+ DCHECK(worker_task_runner_->BelongsToCurrentThread());
{
base::AutoLock scoped_lock(converter_network_lock_);
diff --git a/media/audio/virtual_audio_input_stream.h b/media/audio/virtual_audio_input_stream.h
index 53a1073..17e2730 100644
--- a/media/audio/virtual_audio_input_stream.h
+++ b/media/audio/virtual_audio_input_stream.h
@@ -18,7 +18,7 @@
#include "media/base/audio_converter.h"
namespace base {
-class MessageLoopProxy;
+class SingleThreadTaskRunner;
}
namespace media {
@@ -36,12 +36,12 @@ class MEDIA_EXPORT VirtualAudioInputStream : public AudioInputStream {
AfterCloseCallback;
// Construct a target for audio loopback which mixes multiple data streams
- // into a single stream having the given |params|. |worker_loop| is the loop
- // on which AudioInputCallback methods are called and may or may not be the
- // single thread that invokes the AudioInputStream methods.
+ // into a single stream having the given |params|. |worker_task_runner| is
+ // the task runner on which AudioInputCallback methods are called and may or
+ // may not be the single thread that invokes the AudioInputStream methods.
VirtualAudioInputStream(
const AudioParameters& params,
- const scoped_refptr<base::MessageLoopProxy>& worker_loop,
+ const scoped_refptr<base::SingleThreadTaskRunner>& worker_task_runner,
const AfterCloseCallback& after_close_cb);
virtual ~VirtualAudioInputStream();
@@ -78,7 +78,7 @@ class MEDIA_EXPORT VirtualAudioInputStream : public AudioInputStream {
// Invoked on the worker thread.
void PumpAudio(AudioBus* audio_bus);
- const scoped_refptr<base::MessageLoopProxy> worker_loop_;
+ const scoped_refptr<base::SingleThreadTaskRunner> worker_task_runner_;
AfterCloseCallback after_close_cb_;
diff --git a/media/audio/virtual_audio_input_stream_unittest.cc b/media/audio/virtual_audio_input_stream_unittest.cc
index 8c792d5..4937952 100644
--- a/media/audio/virtual_audio_input_stream_unittest.cc
+++ b/media/audio/virtual_audio_input_stream_unittest.cc
@@ -6,7 +6,6 @@
#include "base/bind.h"
#include "base/bind_helpers.h"
-#include "base/message_loop/message_loop.h"
#include "base/rand_util.h"
#include "base/synchronization/waitable_event.h"
#include "base/threading/thread.h"
@@ -104,7 +103,7 @@ class VirtualAudioInputStreamTest : public testing::TestWithParam<bool> {
stream_(NULL),
closed_stream_(false, false) {
audio_thread_->Start();
- audio_message_loop_ = audio_thread_->message_loop_proxy();
+ audio_task_runner_ = audio_thread_->message_loop_proxy();
}
virtual ~VirtualAudioInputStreamTest() {
@@ -117,7 +116,7 @@ class VirtualAudioInputStreamTest : public testing::TestWithParam<bool> {
void Create() {
const bool worker_is_separate_thread = GetParam();
stream_ = new VirtualAudioInputStream(
- kParams, GetWorkerLoop(worker_is_separate_thread),
+ kParams, GetWorkerTaskRunner(worker_is_separate_thread),
base::Bind(&base::DeletePointer<VirtualAudioInputStream>));
stream_->Open();
}
@@ -207,36 +206,36 @@ class VirtualAudioInputStreamTest : public testing::TestWithParam<bool> {
stopped_output_streams_.clear();
}
- const scoped_refptr<base::MessageLoopProxy>& audio_message_loop() const {
- return audio_message_loop_;
+ const scoped_refptr<base::SingleThreadTaskRunner>& audio_task_runner() const {
+ return audio_task_runner_;
}
- const scoped_refptr<base::MessageLoopProxy>& GetWorkerLoop(
+ const scoped_refptr<base::SingleThreadTaskRunner>& GetWorkerTaskRunner(
bool worker_is_separate_thread) {
if (worker_is_separate_thread) {
if (!worker_thread_->IsRunning()) {
worker_thread_->Start();
- worker_message_loop_ = worker_thread_->message_loop_proxy();
+ worker_task_runner_ = worker_thread_->message_loop_proxy();
}
- return worker_message_loop_;
+ return worker_task_runner_;
} else {
- return audio_message_loop_;
+ return audio_task_runner_;
}
}
private:
void SyncWithAudioThread() {
base::WaitableEvent done(false, false);
- audio_message_loop_->PostTask(
+ audio_task_runner_->PostTask(
FROM_HERE,
base::Bind(&base::WaitableEvent::Signal, base::Unretained(&done)));
done.Wait();
}
scoped_ptr<base::Thread> audio_thread_;
- scoped_refptr<base::MessageLoopProxy> audio_message_loop_;
+ scoped_refptr<base::SingleThreadTaskRunner> audio_task_runner_;
scoped_ptr<base::Thread> worker_thread_;
- scoped_refptr<base::MessageLoopProxy> worker_message_loop_;
+ scoped_refptr<base::SingleThreadTaskRunner> worker_task_runner_;
VirtualAudioInputStream* stream_;
MockInputCallback input_callback_;
@@ -250,7 +249,7 @@ class VirtualAudioInputStreamTest : public testing::TestWithParam<bool> {
};
#define RUN_ON_AUDIO_THREAD(method) \
- audio_message_loop()->PostTask( \
+ audio_task_runner()->PostTask( \
FROM_HERE, base::Bind(&VirtualAudioInputStreamTest::method, \
base::Unretained(this)))
diff --git a/media/audio/virtual_audio_output_stream_unittest.cc b/media/audio/virtual_audio_output_stream_unittest.cc
index 1e3abd1..72e794d 100644
--- a/media/audio/virtual_audio_output_stream_unittest.cc
+++ b/media/audio/virtual_audio_output_stream_unittest.cc
@@ -4,8 +4,6 @@
#include "base/bind.h"
#include "base/bind_helpers.h"
-#include "base/message_loop/message_loop.h"
-#include "base/message_loop/message_loop_proxy.h"
#include "base/synchronization/waitable_event.h"
#include "base/threading/thread.h"
#include "media/audio/audio_manager.h"
@@ -27,10 +25,10 @@ const AudioParameters kParams(
class MockVirtualAudioInputStream : public VirtualAudioInputStream {
public:
explicit MockVirtualAudioInputStream(
- const scoped_refptr<base::MessageLoopProxy>& worker_loop)
+ const scoped_refptr<base::SingleThreadTaskRunner>& worker_task_runner)
: VirtualAudioInputStream(
kParams,
- worker_loop,
+ worker_task_runner,
base::Bind(&base::DeletePointer<VirtualAudioInputStream>)) {}
~MockVirtualAudioInputStream() {}
@@ -53,16 +51,16 @@ class VirtualAudioOutputStreamTest : public testing::Test {
VirtualAudioOutputStreamTest()
: audio_thread_(new base::Thread("AudioThread")) {
audio_thread_->Start();
- audio_message_loop_ = audio_thread_->message_loop_proxy();
+ audio_task_runner_ = audio_thread_->message_loop_proxy();
}
- const scoped_refptr<base::MessageLoopProxy>& audio_message_loop() const {
- return audio_message_loop_;
+ const scoped_refptr<base::SingleThreadTaskRunner>& audio_task_runner() const {
+ return audio_task_runner_;
}
void SyncWithAudioThread() {
base::WaitableEvent done(false, false);
- audio_message_loop()->PostTask(
+ audio_task_runner()->PostTask(
FROM_HERE, base::Bind(&base::WaitableEvent::Signal,
base::Unretained(&done)));
done.Wait();
@@ -70,7 +68,7 @@ class VirtualAudioOutputStreamTest : public testing::Test {
private:
scoped_ptr<base::Thread> audio_thread_;
- scoped_refptr<base::MessageLoopProxy> audio_message_loop_;
+ scoped_refptr<base::SingleThreadTaskRunner> audio_task_runner_;
DISALLOW_COPY_AND_ASSIGN(VirtualAudioOutputStreamTest);
};
@@ -79,8 +77,8 @@ TEST_F(VirtualAudioOutputStreamTest, StartStopStartStop) {
static const int kCycles = 3;
MockVirtualAudioInputStream* const input_stream =
- new MockVirtualAudioInputStream(audio_message_loop());
- audio_message_loop()->PostTask(
+ new MockVirtualAudioInputStream(audio_task_runner());
+ audio_task_runner()->PostTask(
FROM_HERE, base::Bind(
base::IgnoreResult(&MockVirtualAudioInputStream::Open),
base::Unretained(input_stream)));
@@ -95,24 +93,24 @@ TEST_F(VirtualAudioOutputStreamTest, StartStopStartStop) {
EXPECT_CALL(*input_stream, RemoveOutputStream(output_stream, _))
.Times(kCycles);
- audio_message_loop()->PostTask(
+ audio_task_runner()->PostTask(
FROM_HERE, base::Bind(base::IgnoreResult(&VirtualAudioOutputStream::Open),
base::Unretained(output_stream)));
SineWaveAudioSource source(CHANNEL_LAYOUT_STEREO, 200.0, 128);
for (int i = 0; i < kCycles; ++i) {
- audio_message_loop()->PostTask(
+ audio_task_runner()->PostTask(
FROM_HERE, base::Bind(&VirtualAudioOutputStream::Start,
base::Unretained(output_stream),
&source));
- audio_message_loop()->PostTask(
+ audio_task_runner()->PostTask(
FROM_HERE, base::Bind(&VirtualAudioOutputStream::Stop,
base::Unretained(output_stream)));
}
- audio_message_loop()->PostTask(
+ audio_task_runner()->PostTask(
FROM_HERE, base::Bind(&VirtualAudioOutputStream::Close,
base::Unretained(output_stream)));
- audio_message_loop()->PostTask(
+ audio_task_runner()->PostTask(
FROM_HERE, base::Bind(&MockVirtualAudioInputStream::Close,
base::Unretained(input_stream)));
diff --git a/media/audio/win/audio_manager_win.cc b/media/audio/win/audio_manager_win.cc
index 242813a..5e105db 100644
--- a/media/audio/win/audio_manager_win.cc
+++ b/media/audio/win/audio_manager_win.cc
@@ -141,14 +141,14 @@ AudioManagerWin::AudioManagerWin(AudioLogFactory* audio_log_factory)
// Task must be posted last to avoid races from handing out "this" to the
// audio thread.
- GetMessageLoop()->PostTask(FROM_HERE, base::Bind(
+ GetTaskRunner()->PostTask(FROM_HERE, base::Bind(
&AudioManagerWin::CreateDeviceListener, base::Unretained(this)));
}
AudioManagerWin::~AudioManagerWin() {
// It's safe to post a task here since Shutdown() will wait for all tasks to
// complete before returning.
- GetMessageLoop()->PostTask(FROM_HERE, base::Bind(
+ GetTaskRunner()->PostTask(FROM_HERE, base::Bind(
&AudioManagerWin::DestroyDeviceListener, base::Unretained(this)));
Shutdown();
}
@@ -166,7 +166,7 @@ void AudioManagerWin::CreateDeviceListener() {
// be used if WASAPI / Core Audio is supported.
if (CoreAudioUtil::IsSupported()) {
output_device_listener_.reset(new AudioDeviceListenerWin(BindToLoop(
- GetMessageLoop(), base::Bind(
+ GetTaskRunner(), base::Bind(
&AudioManagerWin::NotifyAllOutputDeviceChangeListeners,
base::Unretained(this)))));
}
diff --git a/media/base/bind_to_loop_unittest.cc b/media/base/bind_to_loop_unittest.cc
index 0c7a3dd..6daf683 100644
--- a/media/base/bind_to_loop_unittest.cc
+++ b/media/base/bind_to_loop_unittest.cc
@@ -43,7 +43,7 @@ class BindToLoopTest : public ::testing::Test {
protected:
base::MessageLoop loop_;
- scoped_refptr<base::MessageLoopProxy> proxy_;
+ scoped_refptr<base::SingleThreadTaskRunner> proxy_;
};
TEST_F(BindToLoopTest, Closure) {
diff --git a/media/media.gyp b/media/media.gyp
index 017ffc6..ff83daa 100644
--- a/media/media.gyp
+++ b/media/media.gyp
@@ -169,8 +169,8 @@
'audio/pulse/pulse_util.h',
'audio/sample_rates.cc',
'audio/sample_rates.h',
- 'audio/scoped_loop_observer.cc',
- 'audio/scoped_loop_observer.h',
+ 'audio/scoped_task_runner_observer.cc',
+ 'audio/scoped_task_runner_observer.h',
'audio/simple_sources.cc',
'audio/simple_sources.h',
'audio/sounds/audio_stream_handler.cc',
diff --git a/media/tools/player_x11/player_x11.cc b/media/tools/player_x11/player_x11.cc
index fe3beec..32e5019 100644
--- a/media/tools/player_x11/player_x11.cc
+++ b/media/tools/player_x11/player_x11.cc
@@ -108,21 +108,22 @@ static void SaveStatusAndSignal(base::WaitableEvent* event,
}
// TODO(vrk): Re-enabled audio. (crbug.com/112159)
-void InitPipeline(media::Pipeline* pipeline,
- const scoped_refptr<base::MessageLoopProxy>& message_loop,
- media::Demuxer* demuxer,
- const PaintCB& paint_cb,
- bool /* enable_audio */,
- base::MessageLoop* paint_message_loop) {
+void InitPipeline(
+ media::Pipeline* pipeline,
+ const scoped_refptr<base::SingleThreadTaskRunner>& task_runner,
+ media::Demuxer* demuxer,
+ const PaintCB& paint_cb,
+ bool /* enable_audio */,
+ base::MessageLoop* paint_message_loop) {
// Create our filter factories.
scoped_ptr<media::FilterCollection> collection(
new media::FilterCollection());
collection->SetDemuxer(demuxer);
ScopedVector<media::VideoDecoder> video_decoders;
- video_decoders.push_back(new media::FFmpegVideoDecoder(message_loop));
+ video_decoders.push_back(new media::FFmpegVideoDecoder(task_runner));
scoped_ptr<media::VideoRenderer> video_renderer(new media::VideoRendererImpl(
- message_loop,
+ task_runner,
video_decoders.Pass(),
media::SetDecryptorReadyCB(),
base::Bind(&Paint, paint_message_loop, paint_cb),
@@ -131,10 +132,10 @@ void InitPipeline(media::Pipeline* pipeline,
collection->SetVideoRenderer(video_renderer.Pass());
ScopedVector<media::AudioDecoder> audio_decoders;
- audio_decoders.push_back(new media::FFmpegAudioDecoder(message_loop));
+ audio_decoders.push_back(new media::FFmpegAudioDecoder(task_runner));
scoped_ptr<media::AudioRenderer> audio_renderer(new media::AudioRendererImpl(
- message_loop,
- new media::NullAudioSink(message_loop),
+ task_runner,
+ new media::NullAudioSink(task_runner),
audio_decoders.Pass(),
media::SetDecryptorReadyCB()));
collection->SetAudioRenderer(audio_renderer.Pass());
diff --git a/media/video/capture/mac/video_capture_device_mac.h b/media/video/capture/mac/video_capture_device_mac.h
index 474e7e1..b672409 100644
--- a/media/video/capture/mac/video_capture_device_mac.h
+++ b/media/video/capture/mac/video_capture_device_mac.h
@@ -14,12 +14,15 @@
#include "base/compiler_specific.h"
#include "base/memory/ref_counted.h"
#include "base/memory/weak_ptr.h"
-#include "base/message_loop/message_loop_proxy.h"
#include "media/video/capture/video_capture_device.h"
#include "media/video/capture/video_capture_types.h"
@protocol PlatformVideoCapturingMac;
+namespace base {
+class SingleThreadTaskRunner;
+}
+
namespace media {
// Called by VideoCaptureManager to open, close and start, stop video capture
@@ -66,7 +69,7 @@ class VideoCaptureDeviceMac : public VideoCaptureDevice {
bool tried_to_square_pixels_;
// Only read and write state_ from inside this loop.
- const scoped_refptr<base::MessageLoopProxy> loop_proxy_;
+ const scoped_refptr<base::SingleThreadTaskRunner> task_runner_;
InternalState state_;
// Used with Bind and PostTask to ensure that methods aren't called
diff --git a/media/video/capture/mac/video_capture_device_mac.mm b/media/video/capture/mac/video_capture_device_mac.mm
index dba4fa1..0880667 100644
--- a/media/video/capture/mac/video_capture_device_mac.mm
+++ b/media/video/capture/mac/video_capture_device_mac.mm
@@ -7,6 +7,7 @@
#include "base/bind.h"
#include "base/location.h"
#include "base/logging.h"
+#include "base/message_loop/message_loop_proxy.h"
#include "base/time/time.h"
#import "media/video/capture/mac/avfoundation_glue.h"
#import "media/video/capture/mac/platform_video_capturing_mac.h"
@@ -117,7 +118,7 @@ VideoCaptureDeviceMac::VideoCaptureDeviceMac(const Name& device_name)
: device_name_(device_name),
sent_frame_info_(false),
tried_to_square_pixels_(false),
- loop_proxy_(base::MessageLoopProxy::current()),
+ task_runner_(base::MessageLoopProxy::current()),
state_(kNotInitialized),
weak_factory_(this),
weak_this_(weak_factory_.GetWeakPtr()),
@@ -125,14 +126,14 @@ VideoCaptureDeviceMac::VideoCaptureDeviceMac(const Name& device_name)
}
VideoCaptureDeviceMac::~VideoCaptureDeviceMac() {
- DCHECK_EQ(loop_proxy_, base::MessageLoopProxy::current());
+ DCHECK(task_runner_->BelongsToCurrentThread());
[capture_device_ release];
}
void VideoCaptureDeviceMac::AllocateAndStart(
const VideoCaptureParams& params,
scoped_ptr<VideoCaptureDevice::Client> client) {
- DCHECK_EQ(loop_proxy_, base::MessageLoopProxy::current());
+ DCHECK(task_runner_->BelongsToCurrentThread());
if (state_ != kIdle) {
return;
}
@@ -188,7 +189,7 @@ void VideoCaptureDeviceMac::AllocateAndStart(
}
void VideoCaptureDeviceMac::StopAndDeAllocate() {
- DCHECK_EQ(loop_proxy_, base::MessageLoopProxy::current());
+ DCHECK(task_runner_->BelongsToCurrentThread());
DCHECK(state_ == kCapturing || state_ == kError) << state_;
[capture_device_ stopCapture];
@@ -200,7 +201,7 @@ void VideoCaptureDeviceMac::StopAndDeAllocate() {
}
bool VideoCaptureDeviceMac::Init() {
- DCHECK_EQ(loop_proxy_, base::MessageLoopProxy::current());
+ DCHECK(task_runner_->BelongsToCurrentThread());
DCHECK_EQ(state_, kNotInitialized);
// TODO(mcasas): The following check might not be necessary; if the device has
@@ -312,13 +313,13 @@ void VideoCaptureDeviceMac::ReceiveFrame(
}
void VideoCaptureDeviceMac::ReceiveError(const std::string& reason) {
- loop_proxy_->PostTask(FROM_HERE,
+ task_runner_->PostTask(FROM_HERE,
base::Bind(&VideoCaptureDeviceMac::SetErrorState, weak_this_,
reason));
}
void VideoCaptureDeviceMac::SetErrorState(const std::string& reason) {
- DCHECK_EQ(loop_proxy_, base::MessageLoopProxy::current());
+ DCHECK(task_runner_->BelongsToCurrentThread());
DLOG(ERROR) << reason;
state_ = kError;
client_->OnError();
diff --git a/media/video/capture/video_capture_device_unittest.cc b/media/video/capture/video_capture_device_unittest.cc
index 88303dc..cfb0e96 100644
--- a/media/video/capture/video_capture_device_unittest.cc
+++ b/media/video/capture/video_capture_device_unittest.cc
@@ -5,8 +5,6 @@
#include "base/bind.h"
#include "base/bind_helpers.h"
#include "base/memory/scoped_ptr.h"
-#include "base/message_loop/message_loop.h"
-#include "base/message_loop/message_loop_proxy.h"
#include "base/run_loop.h"
#include "base/synchronization/waitable_event.h"
#include "base/test/test_timeouts.h"
@@ -93,7 +91,7 @@ class MockClient : public media::VideoCaptureDevice::Client {
}
private:
- scoped_refptr<base::MessageLoopProxy> main_thread_;
+ scoped_refptr<base::SingleThreadTaskRunner> main_thread_;
base::Callback<void(const VideoCaptureFormat&)> frame_cb_;
};
diff --git a/media/video/capture/video_capture_proxy.cc b/media/video/capture/video_capture_proxy.cc
index d488c50..c552819 100644
--- a/media/video/capture/video_capture_proxy.cc
+++ b/media/video/capture/video_capture_proxy.cc
@@ -6,7 +6,7 @@
#include "base/bind.h"
#include "base/location.h"
-#include "base/message_loop/message_loop_proxy.h"
+#include "base/single_thread_task_runner.h"
#include "media/base/video_frame.h"
namespace {
@@ -27,16 +27,16 @@ namespace media {
VideoCaptureHandlerProxy::VideoCaptureHandlerProxy(
VideoCapture::EventHandler* proxied,
- scoped_refptr<base::MessageLoopProxy> main_message_loop)
+ const scoped_refptr<base::SingleThreadTaskRunner>& main_task_runner)
: proxied_(proxied),
- main_message_loop_(main_message_loop) {
+ main_task_runner_(main_task_runner) {
}
VideoCaptureHandlerProxy::~VideoCaptureHandlerProxy() {
}
void VideoCaptureHandlerProxy::OnStarted(VideoCapture* capture) {
- main_message_loop_->PostTask(FROM_HERE, base::Bind(
+ main_task_runner_->PostTask(FROM_HERE, base::Bind(
&VideoCaptureHandlerProxy::OnStartedOnMainThread,
base::Unretained(this),
capture,
@@ -44,7 +44,7 @@ void VideoCaptureHandlerProxy::OnStarted(VideoCapture* capture) {
}
void VideoCaptureHandlerProxy::OnStopped(VideoCapture* capture) {
- main_message_loop_->PostTask(FROM_HERE, base::Bind(
+ main_task_runner_->PostTask(FROM_HERE, base::Bind(
&VideoCaptureHandlerProxy::OnStoppedOnMainThread,
base::Unretained(this),
capture,
@@ -52,7 +52,7 @@ void VideoCaptureHandlerProxy::OnStopped(VideoCapture* capture) {
}
void VideoCaptureHandlerProxy::OnPaused(VideoCapture* capture) {
- main_message_loop_->PostTask(FROM_HERE, base::Bind(
+ main_task_runner_->PostTask(FROM_HERE, base::Bind(
&VideoCaptureHandlerProxy::OnPausedOnMainThread,
base::Unretained(this),
capture,
@@ -60,7 +60,7 @@ void VideoCaptureHandlerProxy::OnPaused(VideoCapture* capture) {
}
void VideoCaptureHandlerProxy::OnError(VideoCapture* capture, int error_code) {
- main_message_loop_->PostTask(FROM_HERE, base::Bind(
+ main_task_runner_->PostTask(FROM_HERE, base::Bind(
&VideoCaptureHandlerProxy::OnErrorOnMainThread,
base::Unretained(this),
capture,
@@ -69,7 +69,7 @@ void VideoCaptureHandlerProxy::OnError(VideoCapture* capture, int error_code) {
}
void VideoCaptureHandlerProxy::OnRemoved(VideoCapture* capture) {
- main_message_loop_->PostTask(FROM_HERE, base::Bind(
+ main_task_runner_->PostTask(FROM_HERE, base::Bind(
&VideoCaptureHandlerProxy::OnRemovedOnMainThread,
base::Unretained(this),
capture,
@@ -79,7 +79,7 @@ void VideoCaptureHandlerProxy::OnRemoved(VideoCapture* capture) {
void VideoCaptureHandlerProxy::OnFrameReady(
VideoCapture* capture,
const scoped_refptr<VideoFrame>& frame) {
- main_message_loop_->PostTask(
+ main_task_runner_->PostTask(
FROM_HERE,
base::Bind(&VideoCaptureHandlerProxy::OnFrameReadyOnMainThread,
base::Unretained(this),
diff --git a/media/video/capture/video_capture_proxy.h b/media/video/capture/video_capture_proxy.h
index fca0a80..80f019d 100644
--- a/media/video/capture/video_capture_proxy.h
+++ b/media/video/capture/video_capture_proxy.h
@@ -10,7 +10,7 @@
#include "media/video/capture/video_capture.h"
namespace base {
-class MessageLoopProxy;
+class SingleThreadTaskRunner;
}
namespace media {
@@ -36,7 +36,7 @@ class MEDIA_EXPORT VideoCaptureHandlerProxy
// Called on main thread.
VideoCaptureHandlerProxy(
VideoCapture::EventHandler* proxied,
- scoped_refptr<base::MessageLoopProxy> main_message_loop);
+ const scoped_refptr<base::SingleThreadTaskRunner>& main_task_runner);
virtual ~VideoCaptureHandlerProxy();
// Retrieves the state of the VideoCapture. Must be called on main thread.
@@ -77,7 +77,7 @@ class MEDIA_EXPORT VideoCaptureHandlerProxy
VideoCapture::EventHandler* proxied_;
VideoCaptureState state_;
- scoped_refptr<base::MessageLoopProxy> main_message_loop_;
+ scoped_refptr<base::SingleThreadTaskRunner> main_task_runner_;
};
} // namespace media