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

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: consolidated how we inject fake audio devices. Created 6 years, 7 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
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..5fd5f88a440c06f1878a60a0bd85a2cc7389ed0d 100644
--- a/content/browser/renderer_host/media/audio_input_device_manager.cc
+++ b/content/browser/renderer_host/media/audio_input_device_manager.cc
@@ -8,7 +8,6 @@
#include "base/memory/scoped_ptr.h"
#include "content/public/browser/browser_thread.h"
#include "content/public/common/media_stream_request.h"
-#include "media/audio/audio_device_name.h"
#include "media/audio/audio_input_ipc.h"
#include "media/audio/audio_manager_base.h"
#include "media/audio/audio_parameters.h"
@@ -30,14 +29,6 @@ AudioInputDeviceManager::AudioInputDeviceManager(
next_capture_session_id_(kFirstSessionId),
use_fake_device_(false),
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,
- 44100, media::CHANNEL_LAYOUT_STEREO,
- 0);
- fake_device.session_id = kFakeOpenSessionId;
- devices_.push_back(fake_device);
}
AudioInputDeviceManager::~AudioInputDeviceManager() {
@@ -123,19 +114,18 @@ void AudioInputDeviceManager::EnumerateOnDeviceThread(
SCOPED_UMA_HISTOGRAM_TIMER(
"Media.AudioInputDeviceManager.EnumerateOnDeviceThreadTime");
DCHECK(IsOnDeviceThread());
+ DCHECK_EQ(MEDIA_DEVICE_AUDIO_CAPTURE, stream_type);
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;
+ if (use_fake_device_) {
+ // Use the fake devices.
+ GetFakeDeviceNames(&device_names);
+ } else {
+ // Enumerate the devices on the OS.
+ // AudioManager is guaranteed to outlive MediaStreamManager in
+ // BrowserMainloop.
+ media::AudioDeviceNames device_names;
+ audio_manager_->GetAudioInputDeviceNames(&device_names);
}
scoped_ptr<StreamDeviceInfoArray> devices(new StreamDeviceInfoArray());
@@ -146,14 +136,6 @@ 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));
- }
-
// Return the device list through the listener by posting a task on
// IO thread since MediaStreamManager handles the callback asynchronously.
BrowserThread::PostTask(
@@ -255,4 +237,18 @@ AudioInputDeviceManager::GetDevice(int session_id) {
return devices_.end();
}
+void AudioInputDeviceManager::GetFakeDeviceNames(
+ media::AudioDeviceNames* device_names) {
+ static const char kFakeDeviceName1[] = "Fake Audio 1";
+ static const char kFakeDeviceId1[] = "fake_audio_1";
+ static const char kFakeDeviceName2[] = "Fake Audio 2";
+ static const char kFakeDeviceId2[] = "fake_audio_2";
+ DCHECK(device_names->empty());
+ DCHECK(use_fake_device_);
+ device_names->push_back(media::AudioDeviceName(kFakeDeviceName1,
+ kFakeDeviceId1));
+ device_names->push_back(media::AudioDeviceName(kFakeDeviceName2,
+ kFakeDeviceId2));
+}
+
} // namespace content

Powered by Google App Engine
This is Rietveld 408576698