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

Side by Side Diff: media/audio/mac/audio_manager_mac.h

Issue 1806313003: Pass task runners to AudioManager constructor. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: DCHECK -> CHECK Created 4 years, 8 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
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_MAC_AUDIO_MANAGER_MAC_H_ 5 #ifndef MEDIA_AUDIO_MAC_AUDIO_MANAGER_MAC_H_
6 #define MEDIA_AUDIO_MAC_AUDIO_MANAGER_MAC_H_ 6 #define MEDIA_AUDIO_MAC_AUDIO_MANAGER_MAC_H_
7 7
8 #include <AudioUnit/AudioUnit.h> 8 #include <AudioUnit/AudioUnit.h>
9 #include <CoreAudio/AudioHardware.h> 9 #include <CoreAudio/AudioHardware.h>
10 #include <stddef.h> 10 #include <stddef.h>
11 #include <list> 11 #include <list>
12 #include <string> 12 #include <string>
13 13
14 #include "base/compiler_specific.h" 14 #include "base/compiler_specific.h"
15 #include "base/macros.h" 15 #include "base/macros.h"
16 #include "media/audio/audio_manager_base.h" 16 #include "media/audio/audio_manager_base.h"
17 #include "media/audio/mac/audio_device_listener_mac.h" 17 #include "media/audio/mac/audio_device_listener_mac.h"
18 18
19 namespace media { 19 namespace media {
20 20
21 class AUAudioInputStream; 21 class AUAudioInputStream;
22 class AUHALStream; 22 class AUHALStream;
23 23
24 // Mac OS X implementation of the AudioManager singleton. This class is internal 24 // Mac OS X implementation of the AudioManager singleton. This class is internal
25 // to the audio output and only internal users can call methods not exposed by 25 // to the audio output and only internal users can call methods not exposed by
26 // the AudioManager class. 26 // the AudioManager class.
27 class MEDIA_EXPORT AudioManagerMac : public AudioManagerBase { 27 class MEDIA_EXPORT AudioManagerMac : public AudioManagerBase {
28 public: 28 public:
29 AudioManagerMac(AudioLogFactory* audio_log_factory); 29 AudioManagerMac(
30 scoped_refptr<base::SingleThreadTaskRunner> task_runner,
31 scoped_refptr<base::SingleThreadTaskRunner> worker_task_runner,
32 AudioLogFactory* audio_log_factory);
30 33
31 // Implementation of AudioManager. 34 // Implementation of AudioManager.
32 scoped_refptr<base::SingleThreadTaskRunner> GetTaskRunner() override;
33 scoped_refptr<base::SingleThreadTaskRunner> GetWorkerTaskRunner() override;
34 bool HasAudioOutputDevices() override; 35 bool HasAudioOutputDevices() override;
35 bool HasAudioInputDevices() override; 36 bool HasAudioInputDevices() override;
36 void GetAudioInputDeviceNames(AudioDeviceNames* device_names) override; 37 void GetAudioInputDeviceNames(AudioDeviceNames* device_names) override;
37 void GetAudioOutputDeviceNames(AudioDeviceNames* device_names) override; 38 void GetAudioOutputDeviceNames(AudioDeviceNames* device_names) override;
38 AudioParameters GetInputStreamParameters( 39 AudioParameters GetInputStreamParameters(
39 const std::string& device_id) override; 40 const std::string& device_id) override;
40 std::string GetAssociatedOutputDeviceID( 41 std::string GetAssociatedOutputDeviceID(
41 const std::string& input_device_id) override; 42 const std::string& input_device_id) override;
42 43
43 // Implementation of AudioManagerBase. 44 // Implementation of AudioManagerBase.
(...skipping 66 matching lines...) Expand 10 before | Expand all | Expand 10 after
110 111
111 protected: 112 protected:
112 ~AudioManagerMac() override; 113 ~AudioManagerMac() override;
113 114
114 AudioParameters GetPreferredOutputStreamParameters( 115 AudioParameters GetPreferredOutputStreamParameters(
115 const std::string& output_device_id, 116 const std::string& output_device_id,
116 const AudioParameters& input_params) override; 117 const AudioParameters& input_params) override;
117 118
118 private: 119 private:
119 void InitializeOnAudioThread(); 120 void InitializeOnAudioThread();
120 void ShutdownOnAudioThread();
121 121
122 int ChooseBufferSize(bool is_input, int sample_rate); 122 int ChooseBufferSize(bool is_input, int sample_rate);
123 123
124 // Notify streams of a device change if the default output device or its 124 // Notify streams of a device change if the default output device or its
125 // sample rate has changed, otherwise does nothing. 125 // sample rate has changed, otherwise does nothing.
126 void HandleDeviceChanges(); 126 void HandleDeviceChanges();
127 127
128 scoped_ptr<AudioDeviceListenerMac> output_device_listener_; 128 scoped_ptr<AudioDeviceListenerMac> output_device_listener_;
129 129
130 scoped_refptr<base::SingleThreadTaskRunner> task_runner_;
131 scoped_ptr<base::Thread> worker_thread_;
132
133 // Track the output sample-rate and the default output device 130 // Track the output sample-rate and the default output device
134 // so we can intelligently handle device notifications only when necessary. 131 // so we can intelligently handle device notifications only when necessary.
135 int current_sample_rate_; 132 int current_sample_rate_;
136 AudioDeviceID current_output_device_; 133 AudioDeviceID current_output_device_;
137 134
138 // Helper class which monitors power events to determine if output streams 135 // Helper class which monitors power events to determine if output streams
139 // should defer Start() calls. Required to workaround an OSX bug. See 136 // should defer Start() calls. Required to workaround an OSX bug. See
140 // http://crbug.com/160920 for more details. 137 // http://crbug.com/160920 for more details.
141 class AudioPowerObserver; 138 class AudioPowerObserver;
142 scoped_ptr<AudioPowerObserver> power_observer_; 139 scoped_ptr<AudioPowerObserver> power_observer_;
143 140
144 // Tracks all constructed input and output streams so they can be stopped at 141 // Tracks all constructed input and output streams.
145 // shutdown. See ShutdownOnAudioThread() for more details. 142 // TODO(alokp): We used to track these streams to close before destruction.
DaleCurtis 2016/04/14 00:00:35 Delete these? You already removed the stop streams
alokp 2016/04/14 13:30:03 Sorry I do not understand your comment. Remove the
143 // We no longer close the streams, so we may be able to get rid of these
144 // member variables. They are currently used by MaybeChangeBufferSize().
145 // Investigate if we can remove these.
146 std::list<AudioInputStream*> basic_input_streams_; 146 std::list<AudioInputStream*> basic_input_streams_;
147 std::list<AUAudioInputStream*> low_latency_input_streams_; 147 std::list<AUAudioInputStream*> low_latency_input_streams_;
148 std::list<AUHALStream*> output_streams_; 148 std::list<AUHALStream*> output_streams_;
149 149
150 DISALLOW_COPY_AND_ASSIGN(AudioManagerMac); 150 DISALLOW_COPY_AND_ASSIGN(AudioManagerMac);
151 }; 151 };
152 152
153 } // namespace media 153 } // namespace media
154 154
155 #endif // MEDIA_AUDIO_MAC_AUDIO_MANAGER_MAC_H_ 155 #endif // MEDIA_AUDIO_MAC_AUDIO_MANAGER_MAC_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698