| OLD | NEW |
| 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 <memory> | 7 #include <memory> |
| 8 | 8 |
| 9 #include "base/bind.h" | 9 #include "base/bind.h" |
| 10 #include "base/command_line.h" | 10 #include "base/command_line.h" |
| (...skipping 15 matching lines...) Expand all Loading... |
| 26 | 26 |
| 27 const int AudioInputDeviceManager::kFakeOpenSessionId = 1; | 27 const int AudioInputDeviceManager::kFakeOpenSessionId = 1; |
| 28 | 28 |
| 29 namespace { | 29 namespace { |
| 30 // Starting id for the first capture session. | 30 // Starting id for the first capture session. |
| 31 const int kFirstSessionId = AudioInputDeviceManager::kFakeOpenSessionId + 1; | 31 const int kFirstSessionId = AudioInputDeviceManager::kFakeOpenSessionId + 1; |
| 32 } | 32 } |
| 33 | 33 |
| 34 AudioInputDeviceManager::AudioInputDeviceManager( | 34 AudioInputDeviceManager::AudioInputDeviceManager( |
| 35 media::AudioManager* audio_manager) | 35 media::AudioManager* audio_manager) |
| 36 : listener_(NULL), | 36 : listener_(nullptr), |
| 37 next_capture_session_id_(kFirstSessionId), | 37 next_capture_session_id_(kFirstSessionId), |
| 38 #if defined(OS_CHROMEOS) | 38 #if defined(OS_CHROMEOS) |
| 39 keyboard_mic_streams_count_(0), | 39 keyboard_mic_streams_count_(0), |
| 40 #endif | 40 #endif |
| 41 audio_manager_(audio_manager) { | 41 audio_manager_(audio_manager), |
| 42 device_task_runner_(audio_manager_->GetTaskRunner()) { |
| 42 } | 43 } |
| 43 | 44 |
| 44 AudioInputDeviceManager::~AudioInputDeviceManager() { | 45 AudioInputDeviceManager::~AudioInputDeviceManager() { |
| 45 } | 46 } |
| 46 | 47 |
| 47 const StreamDeviceInfo* AudioInputDeviceManager::GetOpenedDeviceInfoById( | 48 const StreamDeviceInfo* AudioInputDeviceManager::GetOpenedDeviceInfoById( |
| 48 int session_id) { | 49 int session_id) { |
| 49 DCHECK_CURRENTLY_ON(BrowserThread::IO); | 50 DCHECK_CURRENTLY_ON(BrowserThread::IO); |
| 50 StreamDeviceList::iterator device = GetDevice(session_id); | 51 StreamDeviceList::iterator device = GetDevice(session_id); |
| 51 if (device == devices_.end()) | 52 if (device == devices_.end()) |
| 52 return NULL; | 53 return nullptr; |
| 53 | 54 |
| 54 return &(*device); | 55 return &(*device); |
| 55 } | 56 } |
| 56 | 57 |
| 57 void AudioInputDeviceManager::Register( | 58 void AudioInputDeviceManager::RegisterListener( |
| 58 MediaStreamProviderListener* listener, | 59 MediaStreamProviderListener* listener) { |
| 59 const scoped_refptr<base::SingleThreadTaskRunner>& device_task_runner) { | |
| 60 DCHECK_CURRENTLY_ON(BrowserThread::IO); | 60 DCHECK_CURRENTLY_ON(BrowserThread::IO); |
| 61 DCHECK(!listener_); | 61 DCHECK(!listener_); |
| 62 DCHECK(!device_task_runner_.get()); | 62 DCHECK(device_task_runner_); |
| 63 listener_ = listener; | 63 listener_ = listener; |
| 64 device_task_runner_ = device_task_runner; | |
| 65 } | 64 } |
| 66 | 65 |
| 67 void AudioInputDeviceManager::Unregister() { | 66 void AudioInputDeviceManager::UnregisterListener() { |
| 67 DCHECK_CURRENTLY_ON(BrowserThread::IO); |
| 68 DCHECK(listener_); | 68 DCHECK(listener_); |
| 69 listener_ = NULL; | 69 listener_ = nullptr; |
| 70 } | 70 } |
| 71 | 71 |
| 72 int AudioInputDeviceManager::Open(const StreamDeviceInfo& device) { | 72 int AudioInputDeviceManager::Open(const StreamDeviceInfo& device) { |
| 73 DCHECK_CURRENTLY_ON(BrowserThread::IO); | 73 DCHECK_CURRENTLY_ON(BrowserThread::IO); |
| 74 // Generate a new id for this device. | 74 // Generate a new id for this device. |
| 75 int session_id = next_capture_session_id_++; | 75 int session_id = next_capture_session_id_++; |
| 76 device_task_runner_->PostTask( | 76 device_task_runner_->PostTask( |
| 77 FROM_HERE, | 77 FROM_HERE, |
| 78 base::Bind(&AudioInputDeviceManager::OpenOnDeviceThread, | 78 base::Bind(&AudioInputDeviceManager::OpenOnDeviceThread, |
| 79 this, session_id, device)); | 79 this, session_id, device)); |
| (...skipping 159 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 239 #if defined(OS_CHROMEOS) | 239 #if defined(OS_CHROMEOS) |
| 240 void AudioInputDeviceManager::SetKeyboardMicStreamActiveOnUIThread( | 240 void AudioInputDeviceManager::SetKeyboardMicStreamActiveOnUIThread( |
| 241 bool active) { | 241 bool active) { |
| 242 DCHECK_CURRENTLY_ON(BrowserThread::UI); | 242 DCHECK_CURRENTLY_ON(BrowserThread::UI); |
| 243 chromeos::CrasAudioHandler::Get()->SetKeyboardMicActive(active); | 243 chromeos::CrasAudioHandler::Get()->SetKeyboardMicActive(active); |
| 244 } | 244 } |
| 245 #endif | 245 #endif |
| 246 | 246 |
| 247 | 247 |
| 248 } // namespace content | 248 } // namespace content |
| OLD | NEW |