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

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

Issue 599443003: Activate and inactivate keyboard mic on ChromeOS. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@check_kmic_set_effect
Patch Set: Code review fix. Created 6 years, 3 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
« no previous file with comments | « no previous file | content/browser/renderer_host/media/audio_input_device_manager.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 // AudioInputDeviceManager manages the audio input devices. In particular it 5 // AudioInputDeviceManager manages the audio input devices. In particular it
6 // communicates with MediaStreamManager and AudioInputRendererHost on the 6 // communicates with MediaStreamManager and AudioInputRendererHost on the
7 // browser IO thread, handles queries like 7 // browser IO thread, handles queries like
8 // enumerate/open/close/GetOpenedDeviceInfoById from MediaStreamManager and 8 // enumerate/open/close/GetOpenedDeviceInfoById from MediaStreamManager and
9 // GetOpenedDeviceInfoById from AudioInputRendererHost. 9 // GetOpenedDeviceInfoById from AudioInputRendererHost.
10 // The work for enumerate/open/close is handled asynchronously on Media Stream 10 // The work for enumerate/open/close is handled asynchronously on Media Stream
(...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after
49 const scoped_refptr<base::SingleThreadTaskRunner>& 49 const scoped_refptr<base::SingleThreadTaskRunner>&
50 device_task_runner) OVERRIDE; 50 device_task_runner) OVERRIDE;
51 virtual void Unregister() OVERRIDE; 51 virtual void Unregister() OVERRIDE;
52 virtual void EnumerateDevices(MediaStreamType stream_type) OVERRIDE; 52 virtual void EnumerateDevices(MediaStreamType stream_type) OVERRIDE;
53 virtual int Open(const StreamDeviceInfo& device) OVERRIDE; 53 virtual int Open(const StreamDeviceInfo& device) OVERRIDE;
54 virtual void Close(int session_id) OVERRIDE; 54 virtual void Close(int session_id) OVERRIDE;
55 55
56 void UseFakeDevice(); 56 void UseFakeDevice();
57 bool ShouldUseFakeDevice() const; 57 bool ShouldUseFakeDevice() const;
58 58
59 #if defined(OS_CHROMEOS)
60 // Registers and unregisters that a stream using keyboard mic has been opened
61 // or closed. Keeps count of how many such streams are open and activates and
62 // inactivates the keyboard mic accordingly. The (in)activation is done on the
63 // UI thread and for the register case a callback must therefor be provided
64 // which is called when activated.
65 // Called on the IO thread.
66 void RegisterKeyboardMicStream(const base::Closure& callback);
67 void UnregisterKeyboardMicStream();
68 #endif
69
59 private: 70 private:
60 // Used by the unittests to get a list of fake devices. 71 // Used by the unittests to get a list of fake devices.
61 friend class MediaStreamDispatcherHostTest; 72 friend class MediaStreamDispatcherHostTest;
62 void GetFakeDeviceNames(media::AudioDeviceNames* device_names); 73 void GetFakeDeviceNames(media::AudioDeviceNames* device_names);
63 74
64 typedef std::vector<StreamDeviceInfo> StreamDeviceList; 75 typedef std::vector<StreamDeviceInfo> StreamDeviceList;
65 virtual ~AudioInputDeviceManager(); 76 virtual ~AudioInputDeviceManager();
66 77
67 // Enumerates audio input devices on media stream device thread. 78 // Enumerates audio input devices on media stream device thread.
68 void EnumerateOnDeviceThread(MediaStreamType stream_type); 79 void EnumerateOnDeviceThread(MediaStreamType stream_type);
(...skipping 11 matching lines...) Expand all
80 // referencing the closed device on IO thread. 91 // referencing the closed device on IO thread.
81 void ClosedOnIOThread(MediaStreamType type, int session_id); 92 void ClosedOnIOThread(MediaStreamType type, int session_id);
82 93
83 // Verifies that the calling thread is media stream device thread. 94 // Verifies that the calling thread is media stream device thread.
84 bool IsOnDeviceThread() const; 95 bool IsOnDeviceThread() const;
85 96
86 // Helper to return iterator to the device referenced by |session_id|. If no 97 // Helper to return iterator to the device referenced by |session_id|. If no
87 // device is found, it will return devices_.end(). 98 // device is found, it will return devices_.end().
88 StreamDeviceList::iterator GetDevice(int session_id); 99 StreamDeviceList::iterator GetDevice(int session_id);
89 100
101 #if defined(OS_CHROMEOS)
102 // Calls Cras audio handler and sets keyboard mic active status.
103 void SetKeyboardMicStreamActiveOnUIThread(bool active);
104 #endif
105
90 // Only accessed on Browser::IO thread. 106 // Only accessed on Browser::IO thread.
91 MediaStreamProviderListener* listener_; 107 MediaStreamProviderListener* listener_;
92 int next_capture_session_id_; 108 int next_capture_session_id_;
93 bool use_fake_device_; 109 bool use_fake_device_;
94 StreamDeviceList devices_; 110 StreamDeviceList devices_;
95 111
112 #if defined(OS_CHROMEOS)
113 // Keeps count of how many streams are using keyboard mic.
114 int keyboard_mic_streams_count_;
115 #endif
116
96 media::AudioManager* const audio_manager_; // Weak. 117 media::AudioManager* const audio_manager_; // Weak.
97 118
98 // The message loop of media stream device thread that this object runs on. 119 // The message loop of media stream device thread that this object runs on.
99 scoped_refptr<base::SingleThreadTaskRunner> device_task_runner_; 120 scoped_refptr<base::SingleThreadTaskRunner> device_task_runner_;
100 121
101 DISALLOW_COPY_AND_ASSIGN(AudioInputDeviceManager); 122 DISALLOW_COPY_AND_ASSIGN(AudioInputDeviceManager);
102 }; 123 };
103 124
104 } // namespace content 125 } // namespace content
105 126
106 #endif // CONTENT_BROWSER_RENDERER_HOST_MEDIA_AUDIO_INPUT_DEVICE_MANAGER_H_ 127 #endif // CONTENT_BROWSER_RENDERER_HOST_MEDIA_AUDIO_INPUT_DEVICE_MANAGER_H_
OLDNEW
« no previous file with comments | « no previous file | content/browser/renderer_host/media/audio_input_device_manager.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698