Chromium Code Reviews| Index: content/browser/renderer_host/media/audio_input_device_manager.cc |
| diff --git a/content/browser/renderer_host/media/audio_input_device_manager.cc b/content/browser/renderer_host/media/audio_input_device_manager.cc |
| index 8d0377d859d63edd85d6da7fb5eae98370c143be..c47d50a86ef3978c65c3326d0038fce52cfe3f54 100644 |
| --- a/content/browser/renderer_host/media/audio_input_device_manager.cc |
| +++ b/content/browser/renderer_host/media/audio_input_device_manager.cc |
| @@ -19,6 +19,9 @@ namespace content { |
| const int AudioInputDeviceManager::kFakeOpenSessionId = 1; |
| +const char kFakeDeviceName[] = "Fake Audio"; |
| +const char kFakeDeviceId[] = "fake_audio"; |
| + |
| namespace { |
| // Starting id for the first capture session. |
| const int kFirstSessionId = AudioInputDeviceManager::kFakeOpenSessionId + 1; |
| @@ -32,8 +35,8 @@ AudioInputDeviceManager::AudioInputDeviceManager( |
| audio_manager_(audio_manager) { |
| // TODO(xians): Remove this fake_device after the unittests do not need it. |
| StreamDeviceInfo fake_device(MEDIA_DEVICE_AUDIO_CAPTURE, |
| - media::AudioManagerBase::kDefaultDeviceName, |
| - media::AudioManagerBase::kDefaultDeviceId, |
| + kFakeDeviceName, |
| + kFakeDeviceId, |
| 44100, media::CHANNEL_LAYOUT_STEREO, |
| 0); |
| fake_device.session_id = kFakeOpenSessionId; |
| @@ -123,20 +126,13 @@ void AudioInputDeviceManager::EnumerateOnDeviceThread( |
| SCOPED_UMA_HISTOGRAM_TIMER( |
| "Media.AudioInputDeviceManager.EnumerateOnDeviceThreadTime"); |
| DCHECK(IsOnDeviceThread()); |
| + DCHECK_EQ(MEDIA_DEVICE_AUDIO_CAPTURE, stream_type); |
| + // Enumerate the devices on the OS. |
| + // AudioManager is guaranteed to outlive MediaStreamManager in |
| + // BrowserMainloop. |
| media::AudioDeviceNames device_names; |
| - |
| - switch (stream_type) { |
| - case MEDIA_DEVICE_AUDIO_CAPTURE: |
| - // AudioManager is guaranteed to outlive MediaStreamManager in |
| - // BrowserMainloop. |
| - audio_manager_->GetAudioInputDeviceNames(&device_names); |
| - break; |
| - |
| - default: |
| - NOTREACHED(); |
| - break; |
| - } |
| + audio_manager_->GetAudioInputDeviceNames(&device_names); |
| scoped_ptr<StreamDeviceInfoArray> devices(new StreamDeviceInfoArray()); |
| for (media::AudioDeviceNames::iterator it = device_names.begin(); |
| @@ -146,12 +142,12 @@ void AudioInputDeviceManager::EnumerateOnDeviceThread( |
| stream_type, it->device_name, it->unique_id)); |
| } |
| - // If the |use_fake_device_| flag is on, inject the fake device if there is |
| - // no available device on the OS. |
| if (use_fake_device_ && devices->empty()) { |
| - devices->push_back(StreamDeviceInfo( |
| - stream_type, media::AudioManagerBase::kDefaultDeviceName, |
| - media::AudioManagerBase::kDefaultDeviceId)); |
| + // Some unittests can mock the AudioManager enumeration APIs to inject |
| + // their own fake devices, so we only inject the fake device if |
| + // |use_fake_device_| flag is on and there is no enumerated device. |
| + devices->push_back(StreamDeviceInfo(stream_type, kFakeDeviceName, |
|
DaleCurtis
2014/05/02 20:20:09
Won't this now put the fake device at the back of
no longer working on chromium
2014/05/06 14:10:56
That has been the change before this CL, and the w
|
| + kFakeDeviceId)); |
| } |
| // Return the device list through the listener by posting a task on |