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 42728f7f42079b2f1341ed34b3457f1f000909c1..cb82723fa02e65fef1a3332fd89474b567f33dc8 100644 |
--- a/content/browser/renderer_host/media/audio_input_device_manager.cc |
+++ b/content/browser/renderer_host/media/audio_input_device_manager.cc |
@@ -8,6 +8,8 @@ |
#include "base/memory/scoped_ptr.h" |
#include "content/browser/renderer_host/media/audio_input_device_manager_event_handler.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" |
@@ -93,9 +95,10 @@ void AudioInputDeviceManager::EnumerateOnDeviceThread() { |
for (media::AudioDeviceNames::iterator it = device_names.begin(); |
it != device_names.end(); |
++it) { |
- devices->push_back(StreamDeviceInfo( |
- content::MEDIA_STREAM_DEVICE_TYPE_AUDIO_CAPTURE, it->device_name, |
- it->unique_id, false)); |
+ // NOTE: Only support enumeration of the MEDIA_DEVICE_AUDIO_CAPTURE type. |
+ devices->push_back(StreamDeviceInfo( |
+ content::MEDIA_DEVICE_AUDIO_CAPTURE, it->device_name, |
+ it->unique_id, false)); |
} |
// Returns the device list through the listener by posting a task on |
@@ -113,9 +116,8 @@ void AudioInputDeviceManager::OpenOnDeviceThread( |
DCHECK(IsOnDeviceThread()); |
DCHECK(devices_.find(session_id) == devices_.end()); |
- // Adds the session_id and device to the list. |
- media::AudioDeviceName target_device(device.name, device.device_id); |
- devices_[session_id] = target_device; |
+ // Adds the session_id and device to the map. |
+ devices_[session_id] = device; |
// Returns the |session_id| through the listener by posting a task on |
// IO thread since MediaStreamManager handles the callback asynchronously. |
@@ -123,14 +125,18 @@ void AudioInputDeviceManager::OpenOnDeviceThread( |
FROM_HERE, |
base::Bind(&AudioInputDeviceManager::OpenedOnIOThread, |
this, |
- session_id)); |
+ device.stream_type, session_id)); |
} |
void AudioInputDeviceManager::CloseOnDeviceThread(int session_id) { |
DCHECK(IsOnDeviceThread()); |
- if (devices_.find(session_id) != devices_.end()) |
- devices_.erase(session_id); |
+ StreamDeviceMap::iterator it = devices_.find(session_id); |
+ if (it == devices_.end()) { |
tommi (sloooow) - chröme
2012/09/10 09:17:25
no {} for cases like this. See how this is done e
miu
2012/09/10 21:24:38
Done.
|
+ return; |
+ } |
+ const content::MediaStreamDeviceType stream_type = it->second.stream_type; |
+ devices_.erase(it); |
// Posts a callback through the listener on IO thread since |
// MediaStreamManager handles the callback asynchronously. |
@@ -138,7 +144,7 @@ void AudioInputDeviceManager::CloseOnDeviceThread(int session_id) { |
FROM_HERE, |
base::Bind(&AudioInputDeviceManager::ClosedOnIOThread, |
this, |
- session_id)); |
+ stream_type, session_id)); |
} |
void AudioInputDeviceManager::Start( |
@@ -164,7 +170,7 @@ void AudioInputDeviceManager::Start( |
if (event_handlers_.find(session_id) == event_handlers_.end()) { |
event_handlers_.insert(std::make_pair(session_id, event_handler)); |
if (devices_.find(session_id) != devices_.end()) |
- device_id = devices_[session_id].unique_id; |
+ device_id = devices_[session_id].device_id; |
} |
// Posts a callback through the AudioInputRendererHost to notify the renderer |
@@ -185,24 +191,24 @@ void AudioInputDeviceManager::DevicesEnumeratedOnIOThread( |
// Ensures that |devices| gets deleted on exit. |
scoped_ptr<StreamDeviceInfoArray> devices_array(devices); |
if (listener_) { |
- listener_->DevicesEnumerated( |
- content::MEDIA_STREAM_DEVICE_TYPE_AUDIO_CAPTURE, |
- *devices_array); |
+ // NOTE: Only support enumeration of the MEDIA_DEVICE_AUDIO_CAPTURE type. |
+ listener_->DevicesEnumerated(content::MEDIA_DEVICE_AUDIO_CAPTURE, |
+ *devices_array); |
} |
} |
-void AudioInputDeviceManager::OpenedOnIOThread(int session_id) { |
+void AudioInputDeviceManager::OpenedOnIOThread( |
+ content::MediaStreamDeviceType stream_type, int session_id) { |
DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO)); |
if (listener_) |
- listener_->Opened(content::MEDIA_STREAM_DEVICE_TYPE_AUDIO_CAPTURE, |
- session_id); |
+ listener_->Opened(stream_type, session_id); |
} |
-void AudioInputDeviceManager::ClosedOnIOThread(int session_id) { |
+void AudioInputDeviceManager::ClosedOnIOThread( |
+ content::MediaStreamDeviceType stream_type, int session_id) { |
DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO)); |
if (listener_) |
- listener_->Closed(content::MEDIA_STREAM_DEVICE_TYPE_AUDIO_CAPTURE, |
- session_id); |
+ listener_->Closed(stream_type, session_id); |
} |
bool AudioInputDeviceManager::IsOnDeviceThread() const { |