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

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

Issue 300143005: Revert 272884 "reland 260073013: Added automatic mode to FakeInp..." (Closed) Base URL: svn://svn.chromium.org/chrome/
Patch Set: 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: trunk/src/content/browser/renderer_host/media/audio_input_device_manager.cc
===================================================================
--- trunk/src/content/browser/renderer_host/media/audio_input_device_manager.cc (revision 272929)
+++ trunk/src/content/browser/renderer_host/media/audio_input_device_manager.cc (working copy)
@@ -8,6 +8,7 @@
#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"
@@ -29,6 +30,14 @@
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() {
@@ -114,18 +123,19 @@
SCOPED_UMA_HISTOGRAM_TIMER(
"Media.AudioInputDeviceManager.EnumerateOnDeviceThreadTime");
DCHECK(IsOnDeviceThread());
- DCHECK_EQ(MEDIA_DEVICE_AUDIO_CAPTURE, stream_type);
media::AudioDeviceNames device_names;
- 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);
+
+ 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;
}
scoped_ptr<StreamDeviceInfoArray> devices(new StreamDeviceInfoArray());
@@ -136,6 +146,14 @@
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(
@@ -237,18 +255,4 @@
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