| Index: media/audio/audio_device_thread.cc
|
| diff --git a/media/audio/audio_device_thread.cc b/media/audio/audio_device_thread.cc
|
| index 9447293979415cccca39977c937f55c0d9f4f576..1c33396356f23e315615e3e57e9ccfc45682f9a2 100644
|
| --- a/media/audio/audio_device_thread.cc
|
| +++ b/media/audio/audio_device_thread.cc
|
| @@ -30,7 +30,8 @@ class AudioDeviceThread::Thread
|
| Thread(AudioDeviceThread::Callback* callback,
|
| base::SyncSocket::Handle socket,
|
| const char* thread_name,
|
| - bool synchronized_buffers);
|
| + bool synchronized_buffers,
|
| + bool input);
|
|
|
| void Start();
|
|
|
| @@ -57,6 +58,7 @@ class AudioDeviceThread::Thread
|
| base::Lock callback_lock_;
|
| const char* thread_name_;
|
| const bool synchronized_buffers_;
|
| + const bool input_;
|
|
|
| DISALLOW_COPY_AND_ASSIGN(Thread);
|
| };
|
| @@ -71,11 +73,12 @@ AudioDeviceThread::~AudioDeviceThread() { DCHECK(!thread_.get()); }
|
| void AudioDeviceThread::Start(AudioDeviceThread::Callback* callback,
|
| base::SyncSocket::Handle socket,
|
| const char* thread_name,
|
| - bool synchronized_buffers) {
|
| + bool synchronized_buffers,
|
| + bool input) {
|
| base::AutoLock auto_lock(thread_lock_);
|
| CHECK(!thread_.get());
|
| - thread_ = new AudioDeviceThread::Thread(
|
| - callback, socket, thread_name, synchronized_buffers);
|
| + thread_ = new AudioDeviceThread::Thread(callback, socket, thread_name,
|
| + synchronized_buffers, input);
|
| thread_->Start();
|
| }
|
|
|
| @@ -96,13 +99,14 @@ bool AudioDeviceThread::IsStopped() {
|
| AudioDeviceThread::Thread::Thread(AudioDeviceThread::Callback* callback,
|
| base::SyncSocket::Handle socket,
|
| const char* thread_name,
|
| - bool synchronized_buffers)
|
| + bool synchronized_buffers,
|
| + bool input)
|
| : thread_(),
|
| callback_(callback),
|
| socket_(socket),
|
| thread_name_(thread_name),
|
| - synchronized_buffers_(synchronized_buffers) {
|
| -}
|
| + synchronized_buffers_(synchronized_buffers),
|
| + input_(input) {}
|
|
|
| AudioDeviceThread::Thread::~Thread() {
|
| DCHECK(thread_.is_null());
|
| @@ -165,22 +169,31 @@ void AudioDeviceThread::Thread::ThreadMain() {
|
| void AudioDeviceThread::Thread::Run() {
|
| uint32 buffer_index = 0;
|
| while (true) {
|
| - uint32 pending_data = 0;
|
| - size_t bytes_read = socket_.Receive(&pending_data, sizeof(pending_data));
|
| - if (bytes_read != sizeof(pending_data))
|
| - break;
|
| -
|
| - // kuint32max is a special signal which is returned after the browser
|
| - // stops the output device in response to a renderer side request.
|
| - //
|
| - // Avoid running Process() for the paused signal, we still need to update
|
| - // the buffer index if |synchronized_buffers_| is true though.
|
| - //
|
| - // See comments in AudioOutputController::DoPause() for details on why.
|
| - if (pending_data != kuint32max) {
|
| + if (input_) {
|
| + uint32_t pending_data = 0;
|
| + size_t bytes_read = socket_.Receive(&pending_data, sizeof(pending_data));
|
| + if (bytes_read != sizeof(pending_data))
|
| + break;
|
| +
|
| base::AutoLock auto_lock(callback_lock_);
|
| if (callback_)
|
| - callback_->Process(pending_data);
|
| + callback_->Process(pending_data, 0);
|
| + } else {
|
| + uint32_t data[2] = {0}; // {pending_data, frames_skipped}
|
| + size_t bytes_read = socket_.Receive(&data, sizeof(data));
|
| + if (bytes_read != sizeof(data))
|
| + break;
|
| +
|
| + base::AutoLock auto_lock(callback_lock_);
|
| + // kuint32max is a special signal which is returned after the browser
|
| + // stops the output device in response to a renderer side request.
|
| + //
|
| + // Avoid running Process() for the paused signal, we still need to
|
| + // update the buffer index if |synchronized_buffers_| is true though.
|
| + //
|
| + // See comments in AudioOutputController::DoPause() for details on why.
|
| + if (callback_ && data[0] != kuint32max)
|
| + callback_->Process(data[0], data[1]);
|
| }
|
|
|
| // The usage of |synchronized_buffers_| differs between input and output
|
|
|