Index: media/audio/audio_manager.h |
diff --git a/media/audio/audio_manager.h b/media/audio/audio_manager.h |
index d3eea4a6b9cdcf5b944e076dc12e983a82109b05..c878d003c000a4f9b82e2140adbb0b6f6a0ce32a 100644 |
--- a/media/audio/audio_manager.h |
+++ b/media/audio/audio_manager.h |
@@ -22,9 +22,16 @@ class SingleThreadTaskRunner; |
namespace media { |
class AudioInputStream; |
+class AudioManager; |
class AudioManagerFactory; |
class AudioOutputStream; |
+class AudioManagerDeleter { |
+ public: |
+ void operator()(const AudioManager* instance) const; |
+}; |
+using ScopedAudioManagerPtr = scoped_ptr<AudioManager, AudioManagerDeleter>; |
+ |
// Manages all audio resources. Provides some convenience functions that avoid |
// the need to provide iterators over the existing streams. |
// |
@@ -35,7 +42,6 @@ class AudioOutputStream; |
class MEDIA_EXPORT AudioManager { |
public: |
virtual ~AudioManager(); |
- |
// This provides an alternative to the statically linked factory method used |
// to create AudioManager. This is useful for dynamically-linked third |
// party clients seeking to provide a platform-specific implementation of |
@@ -46,20 +52,27 @@ class MEDIA_EXPORT AudioManager { |
// which must not be NULL. |
static void SetFactory(AudioManagerFactory* factory); |
- // 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. |
- static AudioManager* Create(AudioLogFactory* audio_log_factory); |
- |
- // 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(). |
- static AudioManager* CreateWithHangTimer( |
- AudioLogFactory* audio_log_factory, |
- const scoped_refptr<base::SingleThreadTaskRunner>& monitor_task_runner); |
- |
- // Similar to Create() except uses a FakeAudioLogFactory for testing. |
- static AudioManager* CreateForTesting(); |
+ // Construct the audio manager; only one instance is allowed. |
tommi (sloooow) - chröme
2016/03/19 02:32:41
since it has come up a few times in the past and b
alokp
2016/03/22 21:47:07
Done.
|
+ // The returned instance must be deleted on AudioManager::GetTaskRunnner(). |
+ // |
+ // The manager will forward CreateAudioLog() calls to the provided |
+ // AudioLogFactory; as such |audio_log_factory| must outlive the AudioManager. |
+ // |
+ // The manager will use |task_runner| for audio IO. If the given |task_runner| |
+ // is NULL, the implementation will choose a default task runner, which can |
+ // be obtained by calling GetTaskRunner(). |
+ // |
+ // The manager will use |worker_task_runner| for heavyweight tasks. |
+ // The |worker_task_runner| may be the same as |task_runner| or NULL, in |
+ // which case the implementation will choose a default one. |
+ // |
+ // If |monitor_task_runner| is not NULL, a monitor will be scheduled on |
+ // |monitor_task_runner| to monitor |task_runner|. See EnableHangMonitor(). |
+ static ScopedAudioManagerPtr Create( |
+ scoped_refptr<base::SingleThreadTaskRunner> task_runner, |
tommi (sloooow) - chröme
2016/03/19 02:32:41
nit: passing by value implies that the caller migh
alokp
2016/03/22 21:47:07
I agree. I plan to look into it in a later patch.
|
+ scoped_refptr<base::SingleThreadTaskRunner> worker_task_runner, |
+ scoped_refptr<base::SingleThreadTaskRunner> monitor_task_runner, |
+ AudioLogFactory* audio_log_factory); |
// Enables non-crash dumps when audio thread hangs are detected. |
// TODO(dalecurtis): There are no callers to this function at present. A list |
@@ -178,12 +191,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 +249,12 @@ class MEDIA_EXPORT AudioManager { |
AudioLogFactory::AudioComponent component) = 0; |
protected: |
- AudioManager(); |
+ AudioManager(scoped_refptr<base::SingleThreadTaskRunner> task_runner, |
+ 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); |
}; |