| OLD | NEW |
| 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 |
| (...skipping 21 matching lines...) Expand all Loading... |
| 32 public: | 32 public: |
| 33 void operator()(const AudioManager* instance) const; | 33 void operator()(const AudioManager* instance) const; |
| 34 }; | 34 }; |
| 35 using ScopedAudioManagerPtr = | 35 using ScopedAudioManagerPtr = |
| 36 std::unique_ptr<AudioManager, AudioManagerDeleter>; | 36 std::unique_ptr<AudioManager, AudioManagerDeleter>; |
| 37 | 37 |
| 38 // Manages all audio resources. Provides some convenience functions that avoid | 38 // Manages all audio resources. Provides some convenience functions that avoid |
| 39 // the need to provide iterators over the existing streams. | 39 // the need to provide iterators over the existing streams. |
| 40 // | 40 // |
| 41 // Except on OSX, a hang monitor for the audio thread is always created. When a | 41 // Except on OSX, a hang monitor for the audio thread is always created. When a |
| 42 // thread hang is detected, it is reported to UMA. Optionally, if called prior, | 42 // thread hang is detected, it is reported to UMA. |
| 43 // EnableCrashKeyLoggingForAudioThreadHangs() will cause a non-crash dump to be | |
| 44 // logged on Windows (this allows us to report driver hangs to Microsoft). | |
| 45 class MEDIA_EXPORT AudioManager { | 43 class MEDIA_EXPORT AudioManager { |
| 46 public: | 44 public: |
| 47 // Construct the audio manager; only one instance is allowed. | 45 // Construct the audio manager; only one instance is allowed. |
| 48 // The returned instance must be deleted on AudioManager::GetTaskRunnner(). | 46 // The returned instance must be deleted on AudioManager::GetTaskRunnner(). |
| 49 // | 47 // |
| 50 // The manager will forward CreateAudioLog() calls to the provided | 48 // The manager will forward CreateAudioLog() calls to the provided |
| 51 // AudioLogFactory; as such |audio_log_factory| must outlive the AudioManager. | 49 // AudioLogFactory; as such |audio_log_factory| must outlive the AudioManager. |
| 52 // | 50 // |
| 53 // The manager will use |task_runner| for audio IO. This same task runner | 51 // The manager will use |task_runner| for audio IO. This same task runner |
| 54 // is returned by GetTaskRunner(). | 52 // is returned by GetTaskRunner(). |
| (...skipping 15 matching lines...) Expand all Loading... |
| 70 static ScopedAudioManagerPtr CreateForTesting( | 68 static ScopedAudioManagerPtr CreateForTesting( |
| 71 scoped_refptr<base::SingleThreadTaskRunner> task_runner); | 69 scoped_refptr<base::SingleThreadTaskRunner> task_runner); |
| 72 | 70 |
| 73 // Starts monitoring AudioManager task runner for hangs. | 71 // Starts monitoring AudioManager task runner for hangs. |
| 74 // Runs the monitor on the given |task_runner|, which must be different from | 72 // Runs the monitor on the given |task_runner|, which must be different from |
| 75 // AudioManager::GetTaskRunner to be meaningful. | 73 // AudioManager::GetTaskRunner to be meaningful. |
| 76 // This must be called only after an AudioManager instance is created. | 74 // This must be called only after an AudioManager instance is created. |
| 77 static void StartHangMonitorIfNeeded( | 75 static void StartHangMonitorIfNeeded( |
| 78 scoped_refptr<base::SingleThreadTaskRunner> task_runner); | 76 scoped_refptr<base::SingleThreadTaskRunner> task_runner); |
| 79 | 77 |
| 80 // Enables non-crash dumps when audio thread hangs are detected. | |
| 81 // TODO(dalecurtis): There are no callers to this function at present. A list | |
| 82 // of bad drivers has been given to Microsoft. This should be re-enabled in | |
| 83 // the future if Microsoft is able to triage third party drivers. | |
| 84 // See http://crbug.com/422522 | |
| 85 static void EnableCrashKeyLoggingForAudioThreadHangs(); | |
| 86 | |
| 87 #if defined(OS_LINUX) | 78 #if defined(OS_LINUX) |
| 88 // Sets the name of the audio source as seen by external apps. Only actually | 79 // Sets the name of the audio source as seen by external apps. Only actually |
| 89 // used with PulseAudio as of this writing. | 80 // used with PulseAudio as of this writing. |
| 90 static void SetGlobalAppName(const std::string& app_name); | 81 static void SetGlobalAppName(const std::string& app_name); |
| 91 | 82 |
| 92 // Returns the app name or an empty string if it is not set. | 83 // Returns the app name or an empty string if it is not set. |
| 93 static const std::string& GetGlobalAppName(); | 84 static const std::string& GetGlobalAppName(); |
| 94 #endif | 85 #endif |
| 95 | 86 |
| 96 // Returns the pointer to the last created instance, or NULL if not yet | 87 // Returns the pointer to the last created instance, or NULL if not yet |
| (...skipping 167 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 264 friend class AudioManagerDeleter; | 255 friend class AudioManagerDeleter; |
| 265 | 256 |
| 266 scoped_refptr<base::SingleThreadTaskRunner> task_runner_; | 257 scoped_refptr<base::SingleThreadTaskRunner> task_runner_; |
| 267 scoped_refptr<base::SingleThreadTaskRunner> worker_task_runner_; | 258 scoped_refptr<base::SingleThreadTaskRunner> worker_task_runner_; |
| 268 DISALLOW_COPY_AND_ASSIGN(AudioManager); | 259 DISALLOW_COPY_AND_ASSIGN(AudioManager); |
| 269 }; | 260 }; |
| 270 | 261 |
| 271 } // namespace media | 262 } // namespace media |
| 272 | 263 |
| 273 #endif // MEDIA_AUDIO_AUDIO_MANAGER_H_ | 264 #endif // MEDIA_AUDIO_AUDIO_MANAGER_H_ |
| OLD | NEW |