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

Unified Diff: media/audio/audio_output_device.cc

Issue 66183002: Replace MessageLoopProxy with SingleThreadTaskRunner for the rest of media/. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: fix win and audio tests Created 6 years, 11 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « media/audio/audio_output_device.h ('k') | media/audio/audio_output_dispatcher.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: media/audio/audio_output_device.cc
diff --git a/media/audio/audio_output_device.cc b/media/audio/audio_output_device.cc
index 1f9efc185bdba7c1347906bf6914c1daed8bd27c..734251a80baf97a5b5731a7a0b82a6c1e30f6ed7 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();
}
« no previous file with comments | « media/audio/audio_output_device.h ('k') | media/audio/audio_output_dispatcher.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698