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

Side by Side Diff: media/audio/audio_manager_base.h

Issue 11175066: Replace AudioManager::Init() with InitializeOnAudioThread(). (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Comments. Created 8 years, 2 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 | « media/audio/audio_manager.cc ('k') | media/audio/audio_manager_base.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 #ifndef MEDIA_AUDIO_AUDIO_MANAGER_BASE_H_ 5 #ifndef MEDIA_AUDIO_AUDIO_MANAGER_BASE_H_
6 #define MEDIA_AUDIO_AUDIO_MANAGER_BASE_H_ 6 #define MEDIA_AUDIO_AUDIO_MANAGER_BASE_H_
7 7
8 #include <map> 8 #include <map>
9 #include <string> 9 #include <string>
10 10
(...skipping 19 matching lines...) Expand all
30 // AudioManagerBase provides AudioManager functions common for all platforms. 30 // AudioManagerBase provides AudioManager functions common for all platforms.
31 class MEDIA_EXPORT AudioManagerBase : public AudioManager { 31 class MEDIA_EXPORT AudioManagerBase : public AudioManager {
32 public: 32 public:
33 // Name of the generic "default" device. 33 // Name of the generic "default" device.
34 static const char kDefaultDeviceName[]; 34 static const char kDefaultDeviceName[];
35 // Unique Id of the generic "default" device. 35 // Unique Id of the generic "default" device.
36 static const char kDefaultDeviceId[]; 36 static const char kDefaultDeviceId[];
37 37
38 virtual ~AudioManagerBase(); 38 virtual ~AudioManagerBase();
39 39
40 virtual void Init() OVERRIDE;
41
42 virtual scoped_refptr<base::MessageLoopProxy> GetMessageLoop() OVERRIDE; 40 virtual scoped_refptr<base::MessageLoopProxy> GetMessageLoop() OVERRIDE;
43 41
44 virtual string16 GetAudioInputDeviceModel() OVERRIDE; 42 virtual string16 GetAudioInputDeviceModel() OVERRIDE;
45 43
46 virtual bool CanShowAudioInputSettings() OVERRIDE; 44 virtual bool CanShowAudioInputSettings() OVERRIDE;
47 virtual void ShowAudioInputSettings() OVERRIDE; 45 virtual void ShowAudioInputSettings() OVERRIDE;
48 46
49 virtual void GetAudioInputDeviceNames( 47 virtual void GetAudioInputDeviceNames(
50 media::AudioDeviceNames* device_names) OVERRIDE; 48 media::AudioDeviceNames* device_names) OVERRIDE;
51 49
(...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after
104 AudioManagerBase(); 102 AudioManagerBase();
105 103
106 // TODO(dalecurtis): This must change to map both input and output parameters 104 // TODO(dalecurtis): This must change to map both input and output parameters
107 // to a single dispatcher, otherwise on a device state change we'll just get 105 // to a single dispatcher, otherwise on a device state change we'll just get
108 // the exact same invalid dispatcher. 106 // the exact same invalid dispatcher.
109 typedef std::map<AudioParameters, scoped_refptr<AudioOutputDispatcher>, 107 typedef std::map<AudioParameters, scoped_refptr<AudioOutputDispatcher>,
110 AudioParameters::Compare> 108 AudioParameters::Compare>
111 AudioOutputDispatchersMap; 109 AudioOutputDispatchersMap;
112 110
113 // Shuts down the audio thread and releases all the audio output dispatchers 111 // Shuts down the audio thread and releases all the audio output dispatchers
114 // on the audio thread. All audio streams should be freed before 112 // on the audio thread. All audio streams should be freed before Shutdown()
115 // Shutdown is called. 113 // is called. This must be called in the destructor of every AudioManagerBase
116 // This must be called in the destructor of the AudioManager<Platform>. 114 // implementation.
117 void Shutdown(); 115 void Shutdown();
118 116
119 void ShutdownOnAudioThread();
120
121 void SetMaxOutputStreamsAllowed(int max) { max_num_output_streams_ = max; } 117 void SetMaxOutputStreamsAllowed(int max) { max_num_output_streams_ = max; }
122 118
123 // Called by each platform specific AudioManager to notify output state change 119 // Called by each platform specific AudioManager to notify output state change
124 // listeners that a state change has occurred. Must be called from the audio 120 // listeners that a state change has occurred. Must be called from the audio
125 // thread. 121 // thread.
126 void NotifyAllOutputDeviceChangeListeners(); 122 void NotifyAllOutputDeviceChangeListeners();
127 123
124 // Called on |audio_thread_|'s message loop immediately after construction.
125 virtual void InitializeOnAudioThread();
126
128 // Map of cached AudioOutputDispatcher instances. Must only be touched 127 // Map of cached AudioOutputDispatcher instances. Must only be touched
129 // from the audio thread (no locking). 128 // from the audio thread (no locking).
130 AudioOutputDispatchersMap output_dispatchers_; 129 AudioOutputDispatchersMap output_dispatchers_;
131 130
132 private: 131 private:
132 // Called by Shutdown().
133 void ShutdownOnAudioThread();
134
133 // Counts the number of active input streams to find out if something else 135 // Counts the number of active input streams to find out if something else
134 // is currently recording in Chrome. 136 // is currently recording in Chrome.
135 base::AtomicRefCount num_active_input_streams_; 137 base::AtomicRefCount num_active_input_streams_;
136 138
137 // Max number of open output streams, modified by 139 // Max number of open output streams, modified by
138 // SetMaxOutputStreamsAllowed(). 140 // SetMaxOutputStreamsAllowed().
139 int max_num_output_streams_; 141 int max_num_output_streams_;
140 142
141 // Max number of open input streams. 143 // Max number of open input streams.
142 int max_num_input_streams_; 144 int max_num_input_streams_;
143 145
144 // Number of currently open output streams. 146 // Number of currently open output streams.
145 int num_output_streams_; 147 int num_output_streams_;
146 148
147 // Number of currently open input streams. 149 // Number of currently open input streams.
148 int num_input_streams_; 150 int num_input_streams_;
149 151
150 // Track output state change listeners. 152 // Track output state change listeners.
151 ObserverList<AudioDeviceListener> output_listeners_; 153 ObserverList<AudioDeviceListener> output_listeners_;
152 154
153 // Thread used to interact with audio streams created by this audio manager. 155 // Thread used to interact with audio streams created by this audio manager.
154 scoped_ptr<base::Thread> audio_thread_; 156 scoped_ptr<base::Thread> audio_thread_;
155 mutable base::Lock audio_thread_lock_; 157 mutable base::Lock audio_thread_lock_;
156 158
157 // The message loop of the audio thread this object runs on. Set on Init(). 159 // The message loop of the audio thread this object runs on. Used for internal
158 // Used for internal tasks which run on the audio thread even after Shutdown() 160 // tasks which run on the audio thread even after Shutdown() has been started
159 // has been started and GetMessageLoop() starts returning NULL. 161 // and GetMessageLoop() starts returning NULL.
160 scoped_refptr<base::MessageLoopProxy> message_loop_; 162 scoped_refptr<base::MessageLoopProxy> message_loop_;
161 163
162 DISALLOW_COPY_AND_ASSIGN(AudioManagerBase); 164 DISALLOW_COPY_AND_ASSIGN(AudioManagerBase);
163 }; 165 };
164 166
165 } // namespace media 167 } // namespace media
166 168
167 #endif // MEDIA_AUDIO_AUDIO_MANAGER_BASE_H_ 169 #endif // MEDIA_AUDIO_AUDIO_MANAGER_BASE_H_
OLDNEW
« no previous file with comments | « media/audio/audio_manager.cc ('k') | media/audio/audio_manager_base.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698