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

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

Issue 66183002: Replace MessageLoopProxy with SingleThreadTaskRunner for the rest of media/. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 7 years, 1 month 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
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_H_ 5 #ifndef MEDIA_AUDIO_AUDIO_MANAGER_H_
6 #define MEDIA_AUDIO_AUDIO_MANAGER_H_ 6 #define MEDIA_AUDIO_AUDIO_MANAGER_H_
7 7
8 #include <string> 8 #include <string>
9 9
10 #include "base/basictypes.h" 10 #include "base/basictypes.h"
11 #include "base/memory/ref_counted.h" 11 #include "base/memory/ref_counted.h"
12 #include "base/strings/string16.h" 12 #include "base/strings/string16.h"
13 #include "media/audio/audio_device_name.h" 13 #include "media/audio/audio_device_name.h"
14 #include "media/audio/audio_parameters.h" 14 #include "media/audio/audio_parameters.h"
15 15
16 namespace base { 16 namespace base {
17 class MessageLoop; 17 class SingleThreadTaskRunner;
18 class MessageLoopProxy;
19 } 18 }
20 19
21 namespace media { 20 namespace media {
22 21
23 class AudioInputStream; 22 class AudioInputStream;
24 class AudioOutputStream; 23 class AudioOutputStream;
25 24
26 // Manages all audio resources. In particular it owns the AudioOutputStream 25 // Manages all audio resources. In particular it owns the AudioOutputStream
27 // objects. Provides some convenience functions that avoid the need to provide 26 // objects. Provides some convenience functions that avoid the need to provide
28 // iterators over the existing streams. 27 // iterators over the existing streams.
(...skipping 28 matching lines...) Expand all
57 // ideally must not be called from the UI thread or other time sensitive 56 // ideally must not be called from the UI thread or other time sensitive
58 // threads to avoid blocking the rest of the application. 57 // threads to avoid blocking the rest of the application.
59 virtual void ShowAudioInputSettings() = 0; 58 virtual void ShowAudioInputSettings() = 0;
60 59
61 // Appends a list of available input devices to |device_names|, 60 // Appends a list of available input devices to |device_names|,
62 // which must initially be empty. It is not guaranteed that all the 61 // which must initially be empty. It is not guaranteed that all the
63 // devices in the list support all formats and sample rates for 62 // devices in the list support all formats and sample rates for
64 // recording. 63 // recording.
65 // 64 //
66 // Not threadsafe; in production this should only be called from the 65 // Not threadsafe; in production this should only be called from the
67 // Audio IO thread (see GetMessageLoop). 66 // Audio IO thread (see GetTaskRunner()).
68 virtual void GetAudioInputDeviceNames(AudioDeviceNames* device_names) = 0; 67 virtual void GetAudioInputDeviceNames(AudioDeviceNames* device_names) = 0;
69 68
70 // Appends a list of available output devices to |device_names|, 69 // Appends a list of available output devices to |device_names|,
71 // which must initially be empty. 70 // which must initially be empty.
72 // 71 //
73 // Not threadsafe; in production this should only be called from the 72 // Not threadsafe; in production this should only be called from the
74 // Audio IO thread (see GetMessageLoop). 73 // Audio IO thread (see GetTaskRunner()).
75 virtual void GetAudioOutputDeviceNames(AudioDeviceNames* device_names) = 0; 74 virtual void GetAudioOutputDeviceNames(AudioDeviceNames* device_names) = 0;
76 75
77 // Factory for all the supported stream formats. |params| defines parameters 76 // Factory for all the supported stream formats. |params| defines parameters
78 // of the audio stream to be created. 77 // of the audio stream to be created.
79 // 78 //
80 // |params.sample_per_packet| is the requested buffer allocation which the 79 // |params.sample_per_packet| is the requested buffer allocation which the
81 // audio source thinks it can usually fill without blocking. Internally two 80 // audio source thinks it can usually fill without blocking. Internally two
82 // or three buffers are created, one will be locked for playback and one will 81 // or three buffers are created, one will be locked for playback and one will
83 // be ready to be filled in the call to AudioSourceCallback::OnMoreData(). 82 // be ready to be filled in the call to AudioSourceCallback::OnMoreData().
84 // 83 //
(...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after
122 // with 0 suggesting that the implementation use a default value for that 121 // with 0 suggesting that the implementation use a default value for that
123 // platform. 122 // platform.
124 // Returns NULL if the combination of the parameters is not supported, or if 123 // Returns NULL if the combination of the parameters is not supported, or if
125 // we have reached some other platform specific limit. 124 // we have reached some other platform specific limit.
126 // 125 //
127 // Do not free the returned AudioInputStream. It is owned by AudioManager. 126 // Do not free the returned AudioInputStream. It is owned by AudioManager.
128 // When you are done with it, call |Stop()| and |Close()| to release it. 127 // When you are done with it, call |Stop()| and |Close()| to release it.
129 virtual AudioInputStream* MakeAudioInputStream( 128 virtual AudioInputStream* MakeAudioInputStream(
130 const AudioParameters& params, const std::string& device_id) = 0; 129 const AudioParameters& params, const std::string& device_id) = 0;
131 130
132 // Returns message loop used for audio IO. 131 // Returns the task runner used for audio IO.
133 virtual scoped_refptr<base::MessageLoopProxy> GetMessageLoop() = 0; 132 virtual scoped_refptr<base::SingleThreadTaskRunner> GetTaskRunner() = 0;
134 133
135 // Heavyweight tasks should use GetWorkerLoop() instead of GetMessageLoop(). 134 // Heavyweight tasks should use GetWorkerTaskRunner() instead of
136 // On most platforms they are the same, but some share the UI loop with the 135 // GetTaskRunner(). On most platforms they are the same, but some share the
137 // audio IO loop. 136 // UI loop with the audio IO loop.
138 virtual scoped_refptr<base::MessageLoopProxy> GetWorkerLoop() = 0; 137 virtual scoped_refptr<base::SingleThreadTaskRunner> GetWorkerTaskRunner() = 0;
139 138
140 // Allows clients to listen for device state changes; e.g. preferred sample 139 // Allows clients to listen for device state changes; e.g. preferred sample
141 // rate or channel layout changes. The typical response to receiving this 140 // rate or channel layout changes. The typical response to receiving this
142 // callback is to recreate the stream. 141 // callback is to recreate the stream.
143 class AudioDeviceListener { 142 class AudioDeviceListener {
144 public: 143 public:
145 virtual void OnDeviceChange() = 0; 144 virtual void OnDeviceChange() = 0;
146 }; 145 };
147 146
148 virtual void AddOutputDeviceChangeListener(AudioDeviceListener* listener) = 0; 147 virtual void AddOutputDeviceChangeListener(AudioDeviceListener* listener) = 0;
(...skipping 29 matching lines...) Expand all
178 protected: 177 protected:
179 AudioManager(); 178 AudioManager();
180 179
181 private: 180 private:
182 DISALLOW_COPY_AND_ASSIGN(AudioManager); 181 DISALLOW_COPY_AND_ASSIGN(AudioManager);
183 }; 182 };
184 183
185 } // namespace media 184 } // namespace media
186 185
187 #endif // MEDIA_AUDIO_AUDIO_MANAGER_H_ 186 #endif // MEDIA_AUDIO_AUDIO_MANAGER_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698