| OLD | NEW |
| 1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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_BASE_H_ | 5 #ifndef MEDIA_AUDIO_AUDIO_MANAGER_BASE_H_ |
| 6 #define MEDIA_AUDIO_AUDIO_MANAGER_BASE_H_ | 6 #define MEDIA_AUDIO_AUDIO_MANAGER_BASE_H_ |
| 7 | 7 |
| 8 #include <map> | 8 #include <map> |
| 9 | 9 |
| 10 #include "base/atomic_ref_count.h" | 10 #include "base/atomic_ref_count.h" |
| 11 #include "base/compiler_specific.h" | 11 #include "base/compiler_specific.h" |
| 12 #include "base/threading/thread.h" | 12 #include "base/memory/scoped_ptr.h" |
| 13 #include "base/synchronization/lock.h" |
| 13 #include "media/audio/audio_manager.h" | 14 #include "media/audio/audio_manager.h" |
| 14 | 15 |
| 15 class AudioOutputDispatcher; | 16 class AudioOutputDispatcher; |
| 16 | 17 |
| 18 namespace base { |
| 19 class Thread; |
| 20 } |
| 21 |
| 17 // AudioManagerBase provides AudioManager functions common for all platforms. | 22 // AudioManagerBase provides AudioManager functions common for all platforms. |
| 18 class MEDIA_EXPORT AudioManagerBase : public AudioManager { | 23 class MEDIA_EXPORT AudioManagerBase : public AudioManager { |
| 19 public: | 24 public: |
| 20 // Name of the generic "default" device. | 25 // Name of the generic "default" device. |
| 21 static const char kDefaultDeviceName[]; | 26 static const char kDefaultDeviceName[]; |
| 22 // Unique Id of the generic "default" device. | 27 // Unique Id of the generic "default" device. |
| 23 static const char kDefaultDeviceId[]; | 28 static const char kDefaultDeviceId[]; |
| 24 | 29 |
| 25 AudioManagerBase(); | 30 AudioManagerBase(); |
| 26 | 31 |
| 27 #ifndef NDEBUG | 32 #ifndef NDEBUG |
| 28 // Overridden to make sure we don't accidentally get added reference counts on | 33 // Overridden to make sure we don't accidentally get added reference counts on |
| 29 // the audio thread. The AudioManagerBase instance must always be deleted | 34 // the audio thread. The AudioManagerBase instance must always be deleted |
| 30 // from outside the audio thread. | 35 // from outside the audio thread. |
| 31 virtual void AddRef() const OVERRIDE; | 36 virtual void AddRef() const OVERRIDE; |
| 32 virtual void Release() const OVERRIDE; | 37 virtual void Release() const OVERRIDE; |
| 33 #endif | 38 #endif |
| 34 | 39 |
| 35 virtual void Init() OVERRIDE; | 40 virtual void Init() OVERRIDE; |
| 36 | 41 |
| 37 virtual MessageLoop* GetMessageLoop() OVERRIDE; | 42 virtual scoped_refptr<base::MessageLoopProxy> GetMessageLoop() OVERRIDE; |
| 38 | 43 |
| 39 virtual string16 GetAudioInputDeviceModel() OVERRIDE; | 44 virtual string16 GetAudioInputDeviceModel() OVERRIDE; |
| 40 | 45 |
| 41 virtual bool CanShowAudioInputSettings() OVERRIDE; | 46 virtual bool CanShowAudioInputSettings() OVERRIDE; |
| 42 virtual void ShowAudioInputSettings() OVERRIDE; | 47 virtual void ShowAudioInputSettings() OVERRIDE; |
| 43 | 48 |
| 44 virtual void GetAudioInputDeviceNames(media::AudioDeviceNames* device_names) | 49 virtual void GetAudioInputDeviceNames(media::AudioDeviceNames* device_names) |
| 45 OVERRIDE; | 50 OVERRIDE; |
| 46 | 51 |
| 47 virtual AudioOutputStream* MakeAudioOutputStreamProxy( | 52 virtual AudioOutputStream* MakeAudioOutputStreamProxy( |
| (...skipping 11 matching lines...) Expand all Loading... |
| 59 | 64 |
| 60 protected: | 65 protected: |
| 61 virtual ~AudioManagerBase(); | 66 virtual ~AudioManagerBase(); |
| 62 | 67 |
| 63 typedef std::map<AudioParameters, scoped_refptr<AudioOutputDispatcher>, | 68 typedef std::map<AudioParameters, scoped_refptr<AudioOutputDispatcher>, |
| 64 AudioParameters::Compare> | 69 AudioParameters::Compare> |
| 65 AudioOutputDispatchersMap; | 70 AudioOutputDispatchersMap; |
| 66 | 71 |
| 67 void ShutdownOnAudioThread(); | 72 void ShutdownOnAudioThread(); |
| 68 | 73 |
| 69 bool initialized() { return audio_thread_.IsRunning(); } | |
| 70 | |
| 71 // Thread used to interact with AudioOutputStreams created by this | 74 // Thread used to interact with AudioOutputStreams created by this |
| 72 // audio manger. | 75 // audio manger. |
| 73 base::Thread audio_thread_; | 76 scoped_ptr<base::Thread> audio_thread_; |
| 77 mutable base::Lock audio_thread_lock_; |
| 74 | 78 |
| 79 // Map of cached AudioOutputDispatcher instances. Must only be touched |
| 80 // from the audio thread (no locking). |
| 75 AudioOutputDispatchersMap output_dispatchers_; | 81 AudioOutputDispatchersMap output_dispatchers_; |
| 76 | 82 |
| 77 // Counts the number of active input streams to find out if something else | 83 // Counts the number of active input streams to find out if something else |
| 78 // is currently recording in Chrome. | 84 // is currently recording in Chrome. |
| 79 base::AtomicRefCount num_active_input_streams_; | 85 base::AtomicRefCount num_active_input_streams_; |
| 80 | 86 |
| 81 DISALLOW_COPY_AND_ASSIGN(AudioManagerBase); | 87 DISALLOW_COPY_AND_ASSIGN(AudioManagerBase); |
| 82 }; | 88 }; |
| 83 | 89 |
| 84 #endif // MEDIA_AUDIO_AUDIO_MANAGER_BASE_H_ | 90 #endif // MEDIA_AUDIO_AUDIO_MANAGER_BASE_H_ |
| OLD | NEW |