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

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

Issue 1936553002: Revert of Restores larger output buffer size when output stream requiring smaller size is closed (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 years, 7 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 | « media/audio/mac/audio_auhal_mac.cc ('k') | media/audio/mac/audio_manager_mac.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_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 11
12 #include <list> 12 #include <list>
13 #include <map>
14 #include <memory> 13 #include <memory>
15 #include <string> 14 #include <string>
16 15
17 #include "base/compiler_specific.h" 16 #include "base/compiler_specific.h"
18 #include "base/macros.h" 17 #include "base/macros.h"
19 #include "media/audio/audio_manager_base.h" 18 #include "media/audio/audio_manager_base.h"
20 #include "media/audio/mac/audio_device_listener_mac.h" 19 #include "media/audio/mac/audio_device_listener_mac.h"
21 20
22 namespace media { 21 namespace media {
23 22
(...skipping 97 matching lines...) Expand 10 before | Expand all | Expand 10 after
121 120
122 private: 121 private:
123 void InitializeOnAudioThread(); 122 void InitializeOnAudioThread();
124 123
125 int ChooseBufferSize(bool is_input, int sample_rate); 124 int ChooseBufferSize(bool is_input, int sample_rate);
126 125
127 // Notify streams of a device change if the default output device or its 126 // Notify streams of a device change if the default output device or its
128 // sample rate has changed, otherwise does nothing. 127 // sample rate has changed, otherwise does nothing.
129 void HandleDeviceChanges(); 128 void HandleDeviceChanges();
130 129
131 // Returns true if any active input stream is using the specified |device_id|.
132 bool AudioDeviceIsUsedForInput(AudioDeviceID device_id);
133
134 // This method is called when an output stream has been released and it takes
135 // the given |device_id| and scans all active output streams that are
136 // using this id. The goal is to find a new (larger) I/O buffer size which
137 // can be applied to all active output streams since doing so will save
138 // system resources.
139 // Note that, it is only called if no input stream is also using the device.
140 // Example: two active output streams where #1 wants 1024 as buffer size but
141 // is using 256 since stream #2 wants it. Now, if stream #2 is closed down,
142 // the native I/O buffer size will be increased to 1024 instead of 256.
143 // Returns true if it was possible to increase the I/O buffer size and
144 // false otherwise.
145 // TODO(henrika): possibly extend the scheme to also take input streams into
146 // account.
147 bool IncreaseIOBufferSizeIfPossible(AudioDeviceID device_id);
148
149 std::unique_ptr<AudioDeviceListenerMac> output_device_listener_; 130 std::unique_ptr<AudioDeviceListenerMac> output_device_listener_;
150 131
151 // Track the output sample-rate and the default output device 132 // Track the output sample-rate and the default output device
152 // so we can intelligently handle device notifications only when necessary. 133 // so we can intelligently handle device notifications only when necessary.
153 int current_sample_rate_; 134 int current_sample_rate_;
154 AudioDeviceID current_output_device_; 135 AudioDeviceID current_output_device_;
155 136
156 // Helper class which monitors power events to determine if output streams 137 // Helper class which monitors power events to determine if output streams
157 // should defer Start() calls. Required to workaround an OSX bug. See 138 // should defer Start() calls. Required to workaround an OSX bug. See
158 // http://crbug.com/160920 for more details. 139 // http://crbug.com/160920 for more details.
159 class AudioPowerObserver; 140 class AudioPowerObserver;
160 std::unique_ptr<AudioPowerObserver> power_observer_; 141 std::unique_ptr<AudioPowerObserver> power_observer_;
161 142
162 // Tracks all constructed input and output streams. 143 // Tracks all constructed input and output streams.
163 // TODO(alokp): We used to track these streams to close before destruction. 144 // TODO(alokp): We used to track these streams to close before destruction.
164 // We no longer close the streams, so we may be able to get rid of these 145 // We no longer close the streams, so we may be able to get rid of these
165 // member variables. They are currently used by MaybeChangeBufferSize(). 146 // member variables. They are currently used by MaybeChangeBufferSize().
166 // Investigate if we can remove these. 147 // Investigate if we can remove these.
167 std::list<AudioInputStream*> basic_input_streams_; 148 std::list<AudioInputStream*> basic_input_streams_;
168 std::list<AUAudioInputStream*> low_latency_input_streams_; 149 std::list<AUAudioInputStream*> low_latency_input_streams_;
169 std::list<AUHALStream*> output_streams_; 150 std::list<AUHALStream*> output_streams_;
170 151
171 // Maps device IDs and their corresponding actual (I/O) buffer sizes for
172 // all output streams using the specific device.
173 std::map<AudioDeviceID, size_t> output_io_buffer_size_map_;
174
175 DISALLOW_COPY_AND_ASSIGN(AudioManagerMac); 152 DISALLOW_COPY_AND_ASSIGN(AudioManagerMac);
176 }; 153 };
177 154
178 } // namespace media 155 } // namespace media
179 156
180 #endif // MEDIA_AUDIO_MAC_AUDIO_MANAGER_MAC_H_ 157 #endif // MEDIA_AUDIO_MAC_AUDIO_MANAGER_MAC_H_
OLDNEW
« no previous file with comments | « media/audio/mac/audio_auhal_mac.cc ('k') | media/audio/mac/audio_manager_mac.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698