| Index: media/audio/audio_manager.h
|
| ===================================================================
|
| --- media/audio/audio_manager.h (revision 114012)
|
| +++ media/audio/audio_manager.h (working copy)
|
| @@ -5,7 +5,10 @@
|
| #ifndef MEDIA_AUDIO_AUDIO_MANAGER_H_
|
| #define MEDIA_AUDIO_AUDIO_MANAGER_H_
|
|
|
| +#include <string>
|
| +
|
| #include "base/basictypes.h"
|
| +#include "base/memory/ref_counted.h"
|
| #include "base/string16.h"
|
| #include "base/task.h"
|
| #include "media/audio/audio_device_name.h"
|
| @@ -15,14 +18,29 @@
|
| class AudioOutputStream;
|
| class MessageLoop;
|
|
|
| -// TODO(sergeyu): In this interface and some other places AudioParameters struct
|
| -// is passed by value. It is better to change it to const reference.
|
| -
|
| // Manages all audio resources. In particular it owns the AudioOutputStream
|
| // objects. Provides some convenience functions that avoid the need to provide
|
| // iterators over the existing streams.
|
| -class MEDIA_EXPORT AudioManager {
|
| +// TODO(tommi): Make the manager non-refcounted when it's safe to do so.
|
| +// -> Bug 107087.
|
| +class MEDIA_EXPORT AudioManager
|
| + : public base::RefCountedThreadSafe<AudioManager> {
|
| public:
|
| + AudioManager();
|
| +
|
| +#ifndef NDEBUG
|
| + // Allow base classes in debug builds to override the reference counting
|
| + // functions. This allows us to protect against regressions and enforce
|
| + // correct usage. The default implementation just calls the base class.
|
| + virtual void AddRef() const;
|
| + virtual void Release() const;
|
| +#endif
|
| +
|
| + // Use to construct the audio manager.
|
| + // NOTE: There should only be one instance. If you try to create more than
|
| + // one instance, it will hit a CHECK().
|
| + static scoped_refptr<AudioManager> Create();
|
| +
|
| // Returns true if the OS reports existence of audio devices. This does not
|
| // guarantee that the existing devices support all formats and sample rates.
|
| virtual bool HasAudioOutputDevices() = 0;
|
| @@ -106,28 +124,12 @@
|
| // Returns message loop used for audio IO.
|
| virtual MessageLoop* GetMessageLoop() = 0;
|
|
|
| - // Get AudioManager singleton.
|
| - // TODO(cpu): Define threading requirements for interacting with AudioManager.
|
| - static AudioManager* GetAudioManager();
|
| -
|
| protected:
|
| - virtual ~AudioManager() {}
|
| -
|
| - // Called from GetAudioManager() to initialiaze the instance.
|
| + // Called from Create() to initialize the instance.
|
| virtual void Init() = 0;
|
|
|
| - // Called by Destroy() to cleanup the instance before destruction.
|
| - virtual void Cleanup() = 0;
|
| -
|
| - private:
|
| - // Allow unit tests to delete and recreate the singleton.
|
| - friend class AutoAudioManagerCleanup;
|
| - static void Destroy(void*);
|
| - static bool SingletonExists();
|
| - static void Resurrect();
|
| -
|
| - // Called by GetAudioManager() to create platform-specific audio manager.
|
| - static AudioManager* CreateAudioManager();
|
| + friend class base::RefCountedThreadSafe<AudioManager>;
|
| + virtual ~AudioManager();
|
| };
|
|
|
| DISABLE_RUNNABLE_METHOD_REFCOUNT(AudioManager);
|
|
|