Chromium Code Reviews| 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" | |
| 7 | 6 |
| 8 namespace media { | 7 namespace media { |
| 9 MockAudioRendererSink::MockAudioRendererSink() | 8 MockAudioRendererSink::MockAudioRendererSink() |
| 10 : MockAudioRendererSink(OUTPUT_DEVICE_STATUS_OK) {} | 9 : MockAudioRendererSink(OUTPUT_DEVICE_STATUS_OK) {} |
| 11 | 10 |
| 12 MockAudioRendererSink::MockAudioRendererSink(OutputDeviceStatus device_status) | 11 MockAudioRendererSink::MockAudioRendererSink(OutputDeviceStatus device_status) |
| 13 : output_device_(new FakeOutputDevice(device_status)) {} | 12 : MockAudioRendererSink(std::string(), device_status) {} |
| 13 | |
| 14 MockAudioRendererSink::MockAudioRendererSink(const std::string& device_id, | |
| 15 OutputDeviceStatus device_status) | |
| 16 : MockAudioRendererSink( | |
| 17 device_id, | |
| 18 device_status, | |
| 19 media::AudioParameters(media::AudioParameters::AUDIO_FAKE, | |
| 20 media::CHANNEL_LAYOUT_STEREO, | |
| 21 media::AudioParameters::kTelephoneSampleRate, | |
| 22 16, | |
| 23 1)) {} | |
| 24 | |
| 25 MockAudioRendererSink::MockAudioRendererSink( | |
| 26 const std::string& device_id, | |
| 27 OutputDeviceStatus device_status, | |
| 28 const AudioParameters& device_output_params) | |
| 29 : device_info_factory_(nullptr), | |
| 30 output_device_info_(new OutputDeviceInfo(device_id, | |
| 31 device_status, | |
| 32 device_output_params)) {} | |
| 33 | |
| 34 MockAudioRendererSink::MockAudioRendererSink( | |
| 35 OutputDeviceInfoFactory* device_info_factory, | |
| 36 const std::string& device_id) | |
| 37 : device_info_factory_(device_info_factory), | |
| 38 output_device_info_( | |
| 39 device_info_factory_->NewOutputDeviceInfo(device_id)) {} | |
| 14 | 40 |
| 15 MockAudioRendererSink::~MockAudioRendererSink() {} | 41 MockAudioRendererSink::~MockAudioRendererSink() {} |
| 16 | 42 |
| 43 void MockAudioRendererSink::SwitchOutputDevice( | |
| 44 const std::string& device_id, | |
| 45 const url::Origin& security_origin, | |
| 46 const OutputDeviceStatusCB& callback) { | |
| 47 // NB: output device won't be changed if no factory is provided at | |
|
Guido Urdaneta
2016/03/22 15:30:18
Isn't it a lot simpler to just store the device_id
o1ka
2016/03/22 16:13:56
It looks cool! :) But I removed it, since it's not
| |
| 48 // construction time. | |
| 49 if (device_info_factory_) { | |
| 50 output_device_info_.reset( | |
| 51 device_info_factory_->NewOutputDeviceInfo(device_id)); | |
| 52 } | |
| 53 callback.Run(output_device_info_->device_status()); | |
| 54 } | |
| 55 | |
| 17 void MockAudioRendererSink::Initialize(const AudioParameters& params, | 56 void MockAudioRendererSink::Initialize(const AudioParameters& params, |
| 18 RenderCallback* renderer) { | 57 RenderCallback* renderer) { |
| 19 callback_ = renderer; | 58 callback_ = renderer; |
| 20 } | 59 } |
| 21 | 60 |
| 22 OutputDevice* MockAudioRendererSink::GetOutputDevice() { | 61 OutputDeviceInfo MockAudioRendererSink::GetOutputDeviceInfo() { |
| 23 return output_device_.get(); | 62 return *output_device_info_; |
| 24 } | 63 } |
| 25 | 64 |
| 26 } // namespace media | 65 } // namespace media |
| OLD | NEW |