| OLD | NEW |
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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 "media/audio/null_audio_sink.h" | 5 #include "media/audio/null_audio_sink.h" |
| 6 | 6 |
| 7 #include "base/bind.h" | 7 #include "base/bind.h" |
| 8 #include "base/location.h" |
| 8 #include "base/single_thread_task_runner.h" | 9 #include "base/single_thread_task_runner.h" |
| 9 #include "media/audio/fake_audio_worker.h" | 10 #include "media/audio/fake_audio_worker.h" |
| 10 #include "media/base/audio_hash.h" | 11 #include "media/base/audio_hash.h" |
| 11 | 12 |
| 12 namespace media { | 13 namespace media { |
| 13 | 14 |
| 14 NullAudioSink::NullAudioSink( | 15 NullAudioSink::NullAudioSink( |
| 15 const scoped_refptr<base::SingleThreadTaskRunner>& task_runner) | 16 const scoped_refptr<base::SingleThreadTaskRunner>& task_runner) |
| 16 : initialized_(false), | 17 : initialized_(false), |
| 17 playing_(false), | 18 playing_(false), |
| (...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 63 | 64 |
| 64 fake_worker_->Stop(); | 65 fake_worker_->Stop(); |
| 65 playing_ = false; | 66 playing_ = false; |
| 66 } | 67 } |
| 67 | 68 |
| 68 bool NullAudioSink::SetVolume(double volume) { | 69 bool NullAudioSink::SetVolume(double volume) { |
| 69 // Audio is always muted. | 70 // Audio is always muted. |
| 70 return volume == 0.0; | 71 return volume == 0.0; |
| 71 } | 72 } |
| 72 | 73 |
| 74 void NullAudioSink::SwitchOutputDevice(const std::string& device_id, |
| 75 const GURL& security_origin, |
| 76 const SwitchOutputDeviceCB& callback) { |
| 77 DCHECK(task_runner_->BelongsToCurrentThread()); |
| 78 callback.Run(SWITCH_OUTPUT_DEVICE_RESULT_ERROR_NOT_SUPPORTED); |
| 79 } |
| 80 |
| 73 void NullAudioSink::CallRender() { | 81 void NullAudioSink::CallRender() { |
| 74 DCHECK(task_runner_->BelongsToCurrentThread()); | 82 DCHECK(task_runner_->BelongsToCurrentThread()); |
| 75 | 83 |
| 76 int frames_received = callback_->Render(audio_bus_.get(), 0); | 84 int frames_received = callback_->Render(audio_bus_.get(), 0); |
| 77 if (!audio_hash_ || frames_received <= 0) | 85 if (!audio_hash_ || frames_received <= 0) |
| 78 return; | 86 return; |
| 79 | 87 |
| 80 audio_hash_->Update(audio_bus_.get(), frames_received); | 88 audio_hash_->Update(audio_bus_.get(), frames_received); |
| 81 } | 89 } |
| 82 | 90 |
| 83 void NullAudioSink::StartAudioHashForTesting() { | 91 void NullAudioSink::StartAudioHashForTesting() { |
| 84 DCHECK(!initialized_); | 92 DCHECK(!initialized_); |
| 85 audio_hash_.reset(new AudioHash()); | 93 audio_hash_.reset(new AudioHash()); |
| 86 } | 94 } |
| 87 | 95 |
| 88 std::string NullAudioSink::GetAudioHashForTesting() { | 96 std::string NullAudioSink::GetAudioHashForTesting() { |
| 89 return audio_hash_ ? audio_hash_->ToString() : std::string(); | 97 return audio_hash_ ? audio_hash_->ToString() : std::string(); |
| 90 } | 98 } |
| 91 | 99 |
| 92 } // namespace media | 100 } // namespace media |
| OLD | NEW |