| 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 "content/browser/renderer_host/media/audio_renderer_host.h" | 5 #include "content/browser/renderer_host/media/audio_renderer_host.h" |
| 6 | 6 |
| 7 #include <stdint.h> | 7 #include <stdint.h> |
| 8 | 8 |
| 9 #include <memory> | 9 #include <memory> |
| 10 | 10 |
| (...skipping 257 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 268 std::string GetNondefaultIdExpectedToPassPermissionsCheck() { | 268 std::string GetNondefaultIdExpectedToPassPermissionsCheck() { |
| 269 std::string nondefault_id; | 269 std::string nondefault_id; |
| 270 | 270 |
| 271 MediaDevicesManager::BoolDeviceTypes devices_to_enumerate; | 271 MediaDevicesManager::BoolDeviceTypes devices_to_enumerate; |
| 272 devices_to_enumerate[MEDIA_DEVICE_TYPE_AUDIO_OUTPUT] = true; | 272 devices_to_enumerate[MEDIA_DEVICE_TYPE_AUDIO_OUTPUT] = true; |
| 273 media_stream_manager_->media_devices_manager()->EnumerateDevices( | 273 media_stream_manager_->media_devices_manager()->EnumerateDevices( |
| 274 devices_to_enumerate, | 274 devices_to_enumerate, |
| 275 base::Bind( | 275 base::Bind( |
| 276 [](std::string* out, const MediaDeviceEnumeration& result) { | 276 [](std::string* out, const MediaDeviceEnumeration& result) { |
| 277 // Index 0 is default, so use 1. Always exists because we use | 277 // Index 0 is default, so use 1. Always exists because we use |
| 278 // fake devices. | 278 // fake devices. We expect to have a nondefault device. |
| 279 CHECK(result[MediaDeviceType::MEDIA_DEVICE_TYPE_AUDIO_OUTPUT] | 279 CHECK(result[MediaDeviceType::MEDIA_DEVICE_TYPE_AUDIO_OUTPUT] |
| 280 .size() > 1) | 280 .size() > 1); |
| 281 << "Expected to have a nondefault device."; | |
| 282 *out = result[MediaDeviceType::MEDIA_DEVICE_TYPE_AUDIO_OUTPUT][1] | 281 *out = result[MediaDeviceType::MEDIA_DEVICE_TYPE_AUDIO_OUTPUT][1] |
| 283 .device_id; | 282 .device_id; |
| 284 }, | 283 }, |
| 285 base::Unretained(&nondefault_id))); | 284 base::Unretained(&nondefault_id))); |
| 286 | 285 |
| 287 // Make sure nondefault_id is set before returning. | 286 // Make sure nondefault_id is set before returning. |
| 288 base::RunLoop().RunUntilIdle(); | 287 base::RunLoop().RunUntilIdle(); |
| 289 | 288 |
| 290 return nondefault_id; | 289 return nondefault_id; |
| 291 } | 290 } |
| 292 | 291 |
| 293 std::string GetNondefaultInputId() { | 292 std::string GetNondefaultInputId() { |
| 294 std::string nondefault_id; | 293 std::string nondefault_id; |
| 295 | 294 |
| 296 MediaDevicesManager::BoolDeviceTypes devices_to_enumerate; | 295 MediaDevicesManager::BoolDeviceTypes devices_to_enumerate; |
| 297 devices_to_enumerate[MEDIA_DEVICE_TYPE_AUDIO_INPUT] = true; | 296 devices_to_enumerate[MEDIA_DEVICE_TYPE_AUDIO_INPUT] = true; |
| 298 media_stream_manager_->media_devices_manager()->EnumerateDevices( | 297 media_stream_manager_->media_devices_manager()->EnumerateDevices( |
| 299 devices_to_enumerate, | 298 devices_to_enumerate, |
| 300 base::Bind( | 299 base::Bind( |
| 301 // Index 0 is default, so use 1. Always exists because we use | 300 // Index 0 is default, so use 1. Always exists because we use |
| 302 // fake devices. | 301 // fake devices. We expect to have a nondefault device. |
| 303 [](std::string* out, const MediaDeviceEnumeration& result) { | 302 [](std::string* out, const MediaDeviceEnumeration& result) { |
| 304 CHECK(result[MediaDeviceType::MEDIA_DEVICE_TYPE_AUDIO_INPUT] | 303 CHECK(result[MediaDeviceType::MEDIA_DEVICE_TYPE_AUDIO_INPUT] |
| 305 .size() > 1) | 304 .size() > 1); |
| 306 << "Expected to have a nondefault device."; | |
| 307 *out = result[MediaDeviceType::MEDIA_DEVICE_TYPE_AUDIO_INPUT][1] | 305 *out = result[MediaDeviceType::MEDIA_DEVICE_TYPE_AUDIO_INPUT][1] |
| 308 .device_id; | 306 .device_id; |
| 309 }, | 307 }, |
| 310 base::Unretained(&nondefault_id))); | 308 base::Unretained(&nondefault_id))); |
| 311 | 309 |
| 312 base::RunLoop().RunUntilIdle(); | 310 base::RunLoop().RunUntilIdle(); |
| 313 | 311 |
| 314 return nondefault_id; | 312 return nondefault_id; |
| 315 } | 313 } |
| 316 | 314 |
| (...skipping 298 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 615 } | 613 } |
| 616 | 614 |
| 617 TEST_F(AudioRendererHostTest, CreateFailsForInvalidRenderFrame) { | 615 TEST_F(AudioRendererHostTest, CreateFailsForInvalidRenderFrame) { |
| 618 CreateWithInvalidRenderFrameId(); | 616 CreateWithInvalidRenderFrameId(); |
| 619 Close(); | 617 Close(); |
| 620 } | 618 } |
| 621 | 619 |
| 622 // TODO(hclam): Add tests for data conversation in low latency mode. | 620 // TODO(hclam): Add tests for data conversation in low latency mode. |
| 623 | 621 |
| 624 } // namespace content | 622 } // namespace content |
| OLD | NEW |