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

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

Issue 2582703003: Audio output debug recording. (Closed)
Patch Set: Changed to record in AudioOutputResampler. Created 3 years, 11 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_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 <memory> 8 #include <memory>
9 #include <string> 9 #include <string>
10 #include <unordered_set> 10 #include <unordered_set>
11 #include <utility> 11 #include <utility>
12 12
13 #include "base/compiler_specific.h" 13 #include "base/compiler_specific.h"
14 #include "base/files/file_path.h"
14 #include "base/macros.h" 15 #include "base/macros.h"
15 #include "base/memory/scoped_vector.h" 16 #include "base/memory/scoped_vector.h"
16 #include "base/observer_list.h" 17 #include "base/observer_list.h"
17 #include "base/threading/thread.h" 18 #include "base/threading/thread.h"
18 #include "build/build_config.h" 19 #include "build/build_config.h"
19 #include "media/audio/audio_device_name.h" 20 #include "media/audio/audio_device_name.h"
20 #include "media/audio/audio_manager.h" 21 #include "media/audio/audio_manager.h"
21 #include "media/audio/audio_output_dispatcher.h" 22 #include "media/audio/audio_output_dispatcher.h"
22 23
23 #if defined(OS_WIN) 24 #if defined(OS_WIN)
24 #include "base/win/scoped_com_initializer.h" 25 #include "base/win/scoped_com_initializer.h"
25 #endif 26 #endif
26 27
27 namespace media { 28 namespace media {
28 29
29 class AudioOutputDispatcher; 30 class AudioOutputDispatcher;
31 class AudioOutputResampler;
30 32
31 // AudioManagerBase provides AudioManager functions common for all platforms. 33 // AudioManagerBase provides AudioManager functions common for all platforms.
32 class MEDIA_EXPORT AudioManagerBase : public AudioManager { 34 class MEDIA_EXPORT AudioManagerBase : public AudioManager {
33 public: 35 public:
34 ~AudioManagerBase() override; 36 ~AudioManagerBase() override;
35 37
36 // AudioManager: 38 // AudioManager:
37 base::string16 GetAudioInputDeviceModel() override; 39 base::string16 GetAudioInputDeviceModel() override;
38 void ShowAudioInputSettings() override; 40 void ShowAudioInputSettings() override;
39 41
(...skipping 20 matching lines...) Expand all
60 62
61 AudioParameters GetDefaultOutputStreamParameters() override; 63 AudioParameters GetDefaultOutputStreamParameters() override;
62 AudioParameters GetOutputStreamParameters( 64 AudioParameters GetOutputStreamParameters(
63 const std::string& device_id) override; 65 const std::string& device_id) override;
64 AudioParameters GetInputStreamParameters( 66 AudioParameters GetInputStreamParameters(
65 const std::string& device_id) override; 67 const std::string& device_id) override;
66 std::string GetAssociatedOutputDeviceID( 68 std::string GetAssociatedOutputDeviceID(
67 const std::string& input_device_id) override; 69 const std::string& input_device_id) override;
68 std::unique_ptr<AudioLog> CreateAudioLog( 70 std::unique_ptr<AudioLog> CreateAudioLog(
69 AudioLogFactory::AudioComponent component) override; 71 AudioLogFactory::AudioComponent component) override;
72 std::unique_ptr<AudioFileWriter> CreateAudioFileWriter(
73 const AudioParameters& params) override;
74 void EnableOutputDebugRecording(
75 const base::FilePath& base_file_name) override;
76 void DisableOutputDebugRecording() override;
70 77
71 void SetMaxStreamCountForTesting(int max_input, int max_output) final; 78 void SetMaxStreamCountForTesting(int max_input, int max_output) final;
72 79
73 // AudioManagerBase: 80 // AudioManagerBase:
74 81
75 // Called internally by the audio stream when it has been closed. 82 // Called internally by the audio stream when it has been closed.
76 virtual void ReleaseOutputStream(AudioOutputStream* stream); 83 virtual void ReleaseOutputStream(AudioOutputStream* stream);
77 virtual void ReleaseInputStream(AudioInputStream* stream); 84 virtual void ReleaseInputStream(AudioInputStream* stream);
78 85
79 // Creates the output stream for the |AUDIO_PCM_LINEAR| format. The legacy 86 // Creates the output stream for the |AUDIO_PCM_LINEAR| format. The legacy
(...skipping 24 matching lines...) Expand all
104 // Get number of input or output streams. 111 // Get number of input or output streams.
105 int input_stream_count() const { 112 int input_stream_count() const {
106 return static_cast<int>(input_streams_.size()); 113 return static_cast<int>(input_streams_.size());
107 } 114 }
108 int output_stream_count() const { return num_output_streams_; } 115 int output_stream_count() const { return num_output_streams_; }
109 116
110 protected: 117 protected:
111 AudioManagerBase( 118 AudioManagerBase(
112 scoped_refptr<base::SingleThreadTaskRunner> task_runner, 119 scoped_refptr<base::SingleThreadTaskRunner> task_runner,
113 scoped_refptr<base::SingleThreadTaskRunner> worker_task_runner, 120 scoped_refptr<base::SingleThreadTaskRunner> worker_task_runner,
114 AudioLogFactory* audio_log_factory); 121 AudioLogFactory* audio_log_factory,
122 CreateAudioFileWriterCallback create_audio_file_writer_callback);
115 123
116 // Releases all the audio output dispatchers. 124 // Releases all the audio output dispatchers.
117 // All audio streams should be closed before Shutdown() is called. 125 // All audio streams should be closed before Shutdown() is called.
118 // This must be called in the destructor of every AudioManagerBase 126 // This must be called in the destructor of every AudioManagerBase
119 // implementation. 127 // implementation.
120 void Shutdown(); 128 void Shutdown();
121 129
122 void SetMaxOutputStreamsAllowed(int max) { max_num_output_streams_ = max; } 130 void SetMaxOutputStreamsAllowed(int max) { max_num_output_streams_ = max; }
123 131
124 // Called by each platform specific AudioManager to notify output state change 132 // Called by each platform specific AudioManager to notify output state change
(...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after
159 167
160 class CompareByParams; 168 class CompareByParams;
161 169
162 // These functions assign group ids to devices based on their device ids. 170 // These functions assign group ids to devices based on their device ids.
163 // The default implementation is an attempt to do this based on 171 // The default implementation is an attempt to do this based on
164 // GetAssociatedOutputDeviceID. Must be called on the audio worker thread 172 // GetAssociatedOutputDeviceID. Must be called on the audio worker thread
165 // (see GetTaskRunner()). 173 // (see GetTaskRunner()).
166 std::string GetGroupIDOutput(const std::string& output_device_id); 174 std::string GetGroupIDOutput(const std::string& output_device_id);
167 std::string GetGroupIDInput(const std::string& input_device_id); 175 std::string GetGroupIDInput(const std::string& input_device_id);
168 176
177 base::FilePath GetDebugRecordingFileNameWithExtension(
178 const base::FilePath& file_name);
179
169 // Max number of open output streams, modified by 180 // Max number of open output streams, modified by
170 // SetMaxOutputStreamsAllowed(). 181 // SetMaxOutputStreamsAllowed().
171 int max_num_output_streams_; 182 int max_num_output_streams_;
172 183
173 // Max number of open input streams. 184 // Max number of open input streams.
174 int max_num_input_streams_; 185 int max_num_input_streams_;
175 186
176 // Number of currently open output streams. 187 // Number of currently open output streams.
177 int num_output_streams_; 188 int num_output_streams_;
178 189
179 // Track output state change listeners. 190 // Track output state change listeners.
180 base::ObserverList<AudioDeviceListener> output_listeners_; 191 base::ObserverList<AudioDeviceListener> output_listeners_;
181 192
193 // Contains output resamplers. Used for controlling debug recording.
194 std::unordered_set<AudioOutputResampler*> output_resamplers_;
195
182 // Contains currently open input streams. 196 // Contains currently open input streams.
183 std::unordered_set<AudioInputStream*> input_streams_; 197 std::unordered_set<AudioInputStream*> input_streams_;
184 198
185 // Map of cached AudioOutputDispatcher instances. Must only be touched 199 // Map of cached AudioOutputDispatcher instances. Must only be touched
186 // from the audio thread (no locking). 200 // from the audio thread (no locking).
187 AudioOutputDispatchers output_dispatchers_; 201 AudioOutputDispatchers output_dispatchers_;
188 202
189 // Proxy for creating AudioLog objects. 203 // Proxy for creating AudioLog objects.
190 AudioLogFactory* const audio_log_factory_; 204 AudioLogFactory* const audio_log_factory_;
191 205
206 // Callback for creating AudioFileWriter objects.
207 CreateAudioFileWriterCallback create_audio_file_writer_callback_;
208
209 // The base file name for debug recording files. If this is non-empty, debug
210 // recording is enabled, otherwise disabled.
211 base::FilePath debug_recording_base_file_name_;
212
192 DISALLOW_COPY_AND_ASSIGN(AudioManagerBase); 213 DISALLOW_COPY_AND_ASSIGN(AudioManagerBase);
193 }; 214 };
194 215
195 } // namespace media 216 } // namespace media
196 217
197 #endif // MEDIA_AUDIO_AUDIO_MANAGER_BASE_H_ 218 #endif // MEDIA_AUDIO_AUDIO_MANAGER_BASE_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698