Chromium Code Reviews| Index: media/audio/audio_manager.h |
| diff --git a/media/audio/audio_manager.h b/media/audio/audio_manager.h |
| index d3eea4a6b9cdcf5b944e076dc12e983a82109b05..8018d68ab024fb64822b5b2373484835165f4325 100644 |
| --- a/media/audio/audio_manager.h |
| +++ b/media/audio/audio_manager.h |
| @@ -49,18 +49,25 @@ class MEDIA_EXPORT AudioManager { |
| // Construct the audio manager; only one instance is allowed. The manager |
| // will forward CreateAudioLog() calls to the provided AudioLogFactory; as |
| // such |audio_log_factory| must outlive the AudioManager. |
| + // DO NOT DELETE the returned instance. Use AudioManager::Destroy. |
| static AudioManager* Create(AudioLogFactory* audio_log_factory); |
|
DaleCurtis
2016/03/18 00:19:10
Hmm, I thought you were changing this to Create(..
alokp
2016/03/18 00:35:19
I wanted to keep task_runner an internal detail of
DaleCurtis
2016/03/18 00:40:41
No, I was expecting that you would require the tas
alokp
2016/03/18 06:46:52
I was under the impression that those tests were i
|
| // Similar to Create() except also schedules a monitor on the given task |
| // runner to ensure the audio thread is not stuck for more than 60 seconds; if |
| // a hang is detected, the process will be crashed. See EnableHangMonitor(). |
| + // DO NOT DELETE the returned instance. Use AudioManager::Destroy. |
| static AudioManager* CreateWithHangTimer( |
| AudioLogFactory* audio_log_factory, |
| const scoped_refptr<base::SingleThreadTaskRunner>& monitor_task_runner); |
| // Similar to Create() except uses a FakeAudioLogFactory for testing. |
| + // DO NOT DELETE the returned instance. Use AudioManager::Destroy. |
| static AudioManager* CreateForTesting(); |
| + // Helper function to ensure that AudioManager is properly shutdown |
| + // and destroyed on the audio thread. |
| + static void Destroy(AudioManager* instance); |
| + |
| // Enables non-crash dumps when audio thread hangs are detected. |
| // TODO(dalecurtis): There are no callers to this function at present. A list |
| // of bad drivers has been given to Microsoft. This should be re-enabled in |
| @@ -178,12 +185,18 @@ class MEDIA_EXPORT AudioManager { |
| const std::string& device_id) = 0; |
| // Returns the task runner used for audio IO. |
| - virtual scoped_refptr<base::SingleThreadTaskRunner> GetTaskRunner() = 0; |
| + // TODO(alokp): Rename to task_runner(). |
| + scoped_refptr<base::SingleThreadTaskRunner> GetTaskRunner() const { |
| + return task_runner_; |
| + } |
| // Heavyweight tasks should use GetWorkerTaskRunner() instead of |
| // GetTaskRunner(). On most platforms they are the same, but some share the |
| // UI loop with the audio IO loop. |
| - virtual scoped_refptr<base::SingleThreadTaskRunner> GetWorkerTaskRunner() = 0; |
| + // TODO(alokp): Rename to worker_task_runner(). |
| + scoped_refptr<base::SingleThreadTaskRunner> GetWorkerTaskRunner() const { |
| + return worker_task_runner_; |
| + } |
| // Allows clients to listen for device state changes; e.g. preferred sample |
| // rate or channel layout changes. The typical response to receiving this |
| @@ -230,9 +243,13 @@ class MEDIA_EXPORT AudioManager { |
| AudioLogFactory::AudioComponent component) = 0; |
| protected: |
| - AudioManager(); |
| + AudioManager( |
| + const scoped_refptr<base::SingleThreadTaskRunner>& task_runner, |
| + const scoped_refptr<base::SingleThreadTaskRunner>& worker_task_runner); |
| private: |
| + scoped_refptr<base::SingleThreadTaskRunner> task_runner_; |
| + scoped_refptr<base::SingleThreadTaskRunner> worker_task_runner_; |
| DISALLOW_COPY_AND_ASSIGN(AudioManager); |
| }; |