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