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

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

Issue 2582703003: Audio output debug recording. (Closed)
Patch Set: Code review. Created 3 years, 9 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/audio_debug_recording_manager_unittest.cc ('k') | media/audio/audio_manager.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_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 <memory> 8 #include <memory>
9 #include <string> 9 #include <string>
10 10
11 #include "base/callback_forward.h" 11 #include "base/callback_forward.h"
12 #include "base/gtest_prod_util.h"
12 #include "base/macros.h" 13 #include "base/macros.h"
13 #include "base/memory/ref_counted.h" 14 #include "base/memory/ref_counted.h"
14 #include "base/sequenced_task_runner_helpers.h" 15 #include "base/sequenced_task_runner_helpers.h"
15 #include "base/strings/string16.h" 16 #include "base/strings/string16.h"
16 #include "build/build_config.h" 17 #include "build/build_config.h"
17 #include "media/audio/audio_device_description.h" 18 #include "media/audio/audio_device_description.h"
18 #include "media/audio/audio_logging.h" 19 #include "media/audio/audio_logging.h"
19 #include "media/base/audio_parameters.h" 20 #include "media/base/audio_parameters.h"
20 21
21 namespace base { 22 namespace base {
23 class FilePath;
22 class SingleThreadTaskRunner; 24 class SingleThreadTaskRunner;
23 } 25 }
24 26
25 namespace media { 27 namespace media {
26 28
27 class AudioInputStream; 29 class AudioInputStream;
28 class AudioManager; 30 class AudioManager;
29 class AudioOutputStream; 31 class AudioOutputStream;
30 32
31 class MEDIA_EXPORT AudioManagerDeleter { 33 class MEDIA_EXPORT AudioManagerDeleter {
(...skipping 19 matching lines...) Expand all
51 // The manager will use |task_runner| for audio IO. This same task runner 53 // The manager will use |task_runner| for audio IO. This same task runner
52 // is returned by GetTaskRunner(). 54 // is returned by GetTaskRunner().
53 // On OS_MACOSX, CoreAudio requires that |task_runner| must belong to the 55 // On OS_MACOSX, CoreAudio requires that |task_runner| must belong to the
54 // main thread of the process, which in our case is sadly the browser UI 56 // main thread of the process, which in our case is sadly the browser UI
55 // thread. Failure to execute calls on the right thread leads to crashes and 57 // thread. Failure to execute calls on the right thread leads to crashes and
56 // odd behavior. See http://crbug.com/158170. 58 // odd behavior. See http://crbug.com/158170.
57 // 59 //
58 // The manager will use |worker_task_runner| for heavyweight tasks. 60 // The manager will use |worker_task_runner| for heavyweight tasks.
59 // The |worker_task_runner| may be the same as |task_runner|. This same 61 // The |worker_task_runner| may be the same as |task_runner|. This same
60 // task runner is returned by GetWorkerTaskRunner. 62 // task runner is returned by GetWorkerTaskRunner.
63 //
64 // |file_task_runner| is used for audio debug recordings and is the task
65 // runner to do file output operations on.
61 static ScopedAudioManagerPtr Create( 66 static ScopedAudioManagerPtr Create(
62 scoped_refptr<base::SingleThreadTaskRunner> task_runner, 67 scoped_refptr<base::SingleThreadTaskRunner> task_runner,
63 scoped_refptr<base::SingleThreadTaskRunner> worker_task_runner, 68 scoped_refptr<base::SingleThreadTaskRunner> worker_task_runner,
69 scoped_refptr<base::SingleThreadTaskRunner> file_task_runner,
64 AudioLogFactory* audio_log_factory); 70 AudioLogFactory* audio_log_factory);
65 71
66 // A convenience wrapper of AudioManager::Create for testing. 72 // A convenience wrapper of AudioManager::Create for testing.
67 // The given |task_runner| is shared for both audio io and heavyweight tasks. 73 // The given |task_runner| is shared for both audio io and heavyweight tasks.
68 static ScopedAudioManagerPtr CreateForTesting( 74 static ScopedAudioManagerPtr CreateForTesting(
69 scoped_refptr<base::SingleThreadTaskRunner> task_runner); 75 scoped_refptr<base::SingleThreadTaskRunner> task_runner);
70 76
71 // Starts monitoring AudioManager task runner for hangs. 77 // Starts monitoring AudioManager task runner for hangs.
72 // Runs the monitor on the given |task_runner|, which must be different from 78 // Runs the monitor on the given |task_runner|, which must be different from
73 // AudioManager::GetTaskRunner to be meaningful. 79 // AudioManager::GetTaskRunner to be meaningful.
(...skipping 158 matching lines...) Expand 10 before | Expand all | Expand 10 after
232 // an empty string. Must be called on the audio worker thread (see 238 // an empty string. Must be called on the audio worker thread (see
233 // GetTaskRunner()). 239 // GetTaskRunner()).
234 virtual std::string GetAssociatedOutputDeviceID( 240 virtual std::string GetAssociatedOutputDeviceID(
235 const std::string& input_device_id) = 0; 241 const std::string& input_device_id) = 0;
236 242
237 // Create a new AudioLog object for tracking the behavior for one or more 243 // Create a new AudioLog object for tracking the behavior for one or more
238 // instances of the given component. See AudioLogFactory for more details. 244 // instances of the given component. See AudioLogFactory for more details.
239 virtual std::unique_ptr<AudioLog> CreateAudioLog( 245 virtual std::unique_ptr<AudioLog> CreateAudioLog(
240 AudioLogFactory::AudioComponent component) = 0; 246 AudioLogFactory::AudioComponent component) = 0;
241 247
248 // Enable output debug recording. InitializeOutputDebugRecording() must be
249 // called before this function.
250 // TODO(grunell): Control input debug recording via these functions too.
251 virtual void EnableOutputDebugRecording(
252 const base::FilePath& base_file_name) = 0;
253
254 // Disable output debug recording.
255 virtual void DisableOutputDebugRecording() = 0;
256
242 // Gets the name of the audio manager (e.g., Windows, Mac, PulseAudio). 257 // Gets the name of the audio manager (e.g., Windows, Mac, PulseAudio).
243 virtual const char* GetName() = 0; 258 virtual const char* GetName() = 0;
244 259
245 // Limits the number of streams that can be created for testing purposes. 260 // Limits the number of streams that can be created for testing purposes.
246 virtual void SetMaxStreamCountForTesting(int max_input, int max_output); 261 virtual void SetMaxStreamCountForTesting(int max_input, int max_output);
247 262
248 protected: 263 protected:
264 FRIEND_TEST_ALL_PREFIXES(AudioManagerTest, AudioDebugRecording);
265
249 AudioManager(scoped_refptr<base::SingleThreadTaskRunner> task_runner, 266 AudioManager(scoped_refptr<base::SingleThreadTaskRunner> task_runner,
250 scoped_refptr<base::SingleThreadTaskRunner> worker_task_runner); 267 scoped_refptr<base::SingleThreadTaskRunner> worker_task_runner);
251 virtual ~AudioManager(); 268 virtual ~AudioManager();
252 269
270 // Initializes output debug recording. Can be called on any thread; will post
271 // to the audio thread if not called on it.
272 virtual void InitializeOutputDebugRecording(
273 scoped_refptr<base::SingleThreadTaskRunner> file_task_runner) = 0;
274
253 private: 275 private:
254 friend class base::DeleteHelper<AudioManager>; 276 friend class base::DeleteHelper<AudioManager>;
255 friend class AudioManagerDeleter; 277 friend class AudioManagerDeleter;
256 278
257 scoped_refptr<base::SingleThreadTaskRunner> task_runner_; 279 scoped_refptr<base::SingleThreadTaskRunner> task_runner_;
258 scoped_refptr<base::SingleThreadTaskRunner> worker_task_runner_; 280 scoped_refptr<base::SingleThreadTaskRunner> worker_task_runner_;
259 DISALLOW_COPY_AND_ASSIGN(AudioManager); 281 DISALLOW_COPY_AND_ASSIGN(AudioManager);
260 }; 282 };
261 283
262 } // namespace media 284 } // namespace media
263 285
264 #endif // MEDIA_AUDIO_AUDIO_MANAGER_H_ 286 #endif // MEDIA_AUDIO_AUDIO_MANAGER_H_
OLDNEW
« no previous file with comments | « media/audio/audio_debug_recording_manager_unittest.cc ('k') | media/audio/audio_manager.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698