| OLD | NEW |
| 1 // Copyright (c) 2010 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2010 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #include "chrome/renderer/media/audio_renderer_impl.h" | 5 #include "chrome/renderer/media/audio_renderer_impl.h" |
| 6 | 6 |
| 7 #include <math.h> | 7 #include <math.h> |
| 8 | 8 |
| 9 #include "chrome/common/render_messages.h" | 9 #include "chrome/common/render_messages.h" |
| 10 #include "chrome/renderer/audio_message_filter.h" | 10 #include "chrome/renderer/audio_message_filter.h" |
| (...skipping 147 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 158 NewRunnableMethod(this, &AudioRendererImpl::SeekTask)); | 158 NewRunnableMethod(this, &AudioRendererImpl::SeekTask)); |
| 159 } | 159 } |
| 160 | 160 |
| 161 | 161 |
| 162 void AudioRendererImpl::Play(media::FilterCallback* callback) { | 162 void AudioRendererImpl::Play(media::FilterCallback* callback) { |
| 163 AudioRendererBase::Play(callback); | 163 AudioRendererBase::Play(callback); |
| 164 AutoLock auto_lock(lock_); | 164 AutoLock auto_lock(lock_); |
| 165 if (stopped_) | 165 if (stopped_) |
| 166 return; | 166 return; |
| 167 | 167 |
| 168 io_loop_->PostTask(FROM_HERE, | 168 if (GetPlaybackRate() != 0.0f) { |
| 169 NewRunnableMethod(this, &AudioRendererImpl::PlayTask)); | 169 io_loop_->PostTask(FROM_HERE, |
| 170 NewRunnableMethod(this, &AudioRendererImpl::PlayTask)); |
| 171 } else { |
| 172 io_loop_->PostTask(FROM_HERE, |
| 173 NewRunnableMethod(this, &AudioRendererImpl::PauseTask)); |
| 174 } |
| 170 } | 175 } |
| 171 | 176 |
| 172 void AudioRendererImpl::SetVolume(float volume) { | 177 void AudioRendererImpl::SetVolume(float volume) { |
| 173 AutoLock auto_lock(lock_); | 178 AutoLock auto_lock(lock_); |
| 174 if (stopped_) | 179 if (stopped_) |
| 175 return; | 180 return; |
| 176 io_loop_->PostTask(FROM_HERE, | 181 io_loop_->PostTask(FROM_HERE, |
| 177 NewRunnableMethod( | 182 NewRunnableMethod( |
| 178 this, &AudioRendererImpl::SetVolumeTask, volume)); | 183 this, &AudioRendererImpl::SetVolumeTask, volume)); |
| 179 } | 184 } |
| (...skipping 181 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 361 DCHECK(MessageLoop::current() == io_loop_); | 366 DCHECK(MessageLoop::current() == io_loop_); |
| 362 | 367 |
| 363 // We treat the IO loop going away the same as stopping. | 368 // We treat the IO loop going away the same as stopping. |
| 364 AutoLock auto_lock(lock_); | 369 AutoLock auto_lock(lock_); |
| 365 if (stopped_) | 370 if (stopped_) |
| 366 return; | 371 return; |
| 367 | 372 |
| 368 stopped_ = true; | 373 stopped_ = true; |
| 369 DestroyTask(); | 374 DestroyTask(); |
| 370 } | 375 } |
| OLD | NEW |