Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(779)

Unified Diff: content/browser/renderer_host/media/audio_input_device_manager.cc

Issue 260073013: Added automatic mode to FakeInputAudioStream to generate automatic beeps (Closed) Base URL: http://git.chromium.org/chromium/src.git@master
Patch Set: addressed the comments. Created 6 years, 8 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | media/audio/fake_audio_input_stream.h » ('j') | media/audio/fake_audio_input_stream.cc » ('J')
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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
« no previous file with comments | « no previous file | media/audio/fake_audio_input_stream.h » ('j') | media/audio/fake_audio_input_stream.cc » ('J')

Powered by Google App Engine
This is Rietveld 408576698