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

Side by Side Diff: content/browser/renderer_host/media/audio_input_device_manager.cc

Issue 11783059: Ensures that WebRTC works for device selection using a different sample rate than default (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Fix after review from Chris Created 7 years, 11 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 unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « no previous file | content/browser/renderer_host/media/audio_input_device_manager_unittest.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "content/browser/renderer_host/media/audio_input_device_manager.h" 5 #include "content/browser/renderer_host/media/audio_input_device_manager.h"
6 6
7 #include "base/bind.h" 7 #include "base/bind.h"
8 #include "base/memory/scoped_ptr.h" 8 #include "base/memory/scoped_ptr.h"
9 #include "content/browser/renderer_host/media/audio_input_device_manager_event_h andler.h" 9 #include "content/browser/renderer_host/media/audio_input_device_manager_event_h andler.h"
10 #include "content/public/browser/browser_thread.h" 10 #include "content/public/browser/browser_thread.h"
11 #include "content/public/common/media_stream_request.h" 11 #include "content/public/common/media_stream_request.h"
12 #include "media/audio/audio_device_name.h" 12 #include "media/audio/audio_device_name.h"
13 #include "media/audio/audio_input_ipc.h" 13 #include "media/audio/audio_input_ipc.h"
14 #include "media/audio/audio_manager_base.h" 14 #include "media/audio/audio_manager_base.h"
15 #include "media/audio/audio_util.h"
16 #include "media/base/channel_layout.h"
15 17
16 namespace content { 18 namespace content {
17 19
18 const int AudioInputDeviceManager::kFakeOpenSessionId = 1; 20 const int AudioInputDeviceManager::kFakeOpenSessionId = 1;
19 21
20 namespace { 22 namespace {
21 // Starting id for the first capture session. 23 // Starting id for the first capture session.
22 const int kFirstSessionId = AudioInputDeviceManager::kFakeOpenSessionId + 1; 24 const int kFirstSessionId = AudioInputDeviceManager::kFakeOpenSessionId + 1;
23 } 25 }
24 26
(...skipping 122 matching lines...) Expand 10 before | Expand all | Expand 10 after
147 break; 149 break;
148 150
149 default: 151 default:
150 NOTREACHED(); 152 NOTREACHED();
151 break; 153 break;
152 } 154 }
153 155
154 scoped_ptr<StreamDeviceInfoArray> devices(new StreamDeviceInfoArray()); 156 scoped_ptr<StreamDeviceInfoArray> devices(new StreamDeviceInfoArray());
155 for (media::AudioDeviceNames::iterator it = device_names.begin(); 157 for (media::AudioDeviceNames::iterator it = device_names.begin();
156 it != device_names.end(); ++it) { 158 it != device_names.end(); ++it) {
159 // Get the preferred sample rate and channel configuration for the
160 // current audio device.
161 int sample_rate =
162 media::GetAudioInputHardwareSampleRate(it->unique_id);
163 media::ChannelLayout channel_layout =
164 media::GetAudioInputHardwareChannelLayout(it->unique_id);
165
166 // Add device information to device vector.
157 devices->push_back(StreamDeviceInfo( 167 devices->push_back(StreamDeviceInfo(
158 stream_type, it->device_name, it->unique_id, false)); 168 stream_type, it->device_name, it->unique_id, sample_rate,
169 channel_layout, false));
159 } 170 }
160 171
161 // Return the device list through the listener by posting a task on 172 // Return the device list through the listener by posting a task on
162 // IO thread since MediaStreamManager handles the callback asynchronously. 173 // IO thread since MediaStreamManager handles the callback asynchronously.
163 BrowserThread::PostTask( 174 BrowserThread::PostTask(
164 BrowserThread::IO, 175 BrowserThread::IO,
165 FROM_HERE, 176 FROM_HERE,
166 base::Bind(&AudioInputDeviceManager::DevicesEnumeratedOnIOThread, 177 base::Bind(&AudioInputDeviceManager::DevicesEnumeratedOnIOThread,
167 this, stream_type, base::Passed(&devices))); 178 this, stream_type, base::Passed(&devices)));
168 } 179 }
(...skipping 54 matching lines...) Expand 10 before | Expand all | Expand 10 after
223 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO)); 234 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO));
224 if (listener_) 235 if (listener_)
225 listener_->Closed(stream_type, session_id); 236 listener_->Closed(stream_type, session_id);
226 } 237 }
227 238
228 bool AudioInputDeviceManager::IsOnDeviceThread() const { 239 bool AudioInputDeviceManager::IsOnDeviceThread() const {
229 return device_loop_->BelongsToCurrentThread(); 240 return device_loop_->BelongsToCurrentThread();
230 } 241 }
231 242
232 } // namespace content 243 } // namespace content
OLDNEW
« no previous file with comments | « no previous file | content/browser/renderer_host/media/audio_input_device_manager_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698