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/base/mock_audio_renderer_sink.h" | 5 #include "media/base/mock_audio_renderer_sink.h" |
6 #include "media/base/fake_output_device.h" | 6 #include "media/base/fake_output_device.h" |
7 | 7 |
8 namespace media { | 8 namespace media { |
9 MockAudioRendererSink::MockAudioRendererSink() | 9 MockAudioRendererSink::MockAudioRendererSink() |
10 : MockAudioRendererSink(OUTPUT_DEVICE_STATUS_OK) {} | 10 : MockAudioRendererSink(OUTPUT_DEVICE_STATUS_OK) {} |
11 | 11 |
12 MockAudioRendererSink::MockAudioRendererSink(OutputDeviceStatus device_status) | 12 MockAudioRendererSink::MockAudioRendererSink(OutputDeviceStatus device_status) |
13 : output_device_(new FakeOutputDevice(device_status)) {} | 13 : device_factory_(nullptr), |
| 14 output_device_(new FakeOutputDevice(std::string(), device_status)) {} |
| 15 |
| 16 MockAudioRendererSink::MockAudioRendererSink(const std::string& device_id, |
| 17 OutputDeviceStatus device_status) |
| 18 : device_factory_(nullptr), |
| 19 output_device_(new FakeOutputDevice(device_id, device_status)) {} |
| 20 |
| 21 MockAudioRendererSink::MockAudioRendererSink( |
| 22 const std::string& device_id, |
| 23 OutputDeviceStatus device_status, |
| 24 const AudioParameters& device_output_params) |
| 25 : device_factory_(nullptr), |
| 26 output_device_(new FakeOutputDevice(device_id, |
| 27 device_status, |
| 28 device_output_params)) {} |
| 29 |
| 30 MockAudioRendererSink::MockAudioRendererSink( |
| 31 FakeOutputDeviceFactory* device_factory, |
| 32 const std::string& device_id) |
| 33 : device_factory_(device_factory), |
| 34 output_device_(device_factory_->NewFakeOutputDevice(device_id)) {} |
14 | 35 |
15 MockAudioRendererSink::~MockAudioRendererSink() {} | 36 MockAudioRendererSink::~MockAudioRendererSink() {} |
16 | 37 |
| 38 void MockAudioRendererSink::SwitchOutputDevice( |
| 39 const std::string& device_id, |
| 40 const url::Origin& security_origin, |
| 41 const SwitchOutputDeviceCB& callback) { |
| 42 // NB: output device won't be changed if no factory is provided at |
| 43 // construction time. |
| 44 if (device_factory_) |
| 45 output_device_.reset(device_factory_->NewFakeOutputDevice(device_id)); |
| 46 callback.Run(output_device_->GetDeviceStatus()); |
| 47 } |
| 48 |
17 void MockAudioRendererSink::Initialize(const AudioParameters& params, | 49 void MockAudioRendererSink::Initialize(const AudioParameters& params, |
18 RenderCallback* renderer) { | 50 RenderCallback* renderer) { |
19 callback_ = renderer; | 51 callback_ = renderer; |
20 } | 52 } |
21 | 53 |
22 OutputDevice* MockAudioRendererSink::GetOutputDevice() { | 54 OutputDevice* MockAudioRendererSink::GetOutputDevice() { |
23 return output_device_.get(); | 55 return output_device_.get(); |
24 } | 56 } |
25 | 57 |
26 } // namespace media | 58 } // namespace media |
OLD | NEW |