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/compiler_specific.h" | 11 #include "base/compiler_specific.h" |
11 #include "base/threading/thread.h" | 12 #include "base/threading/thread.h" |
12 #include "media/audio/audio_manager.h" | 13 #include "media/audio/audio_manager.h" |
13 | 14 |
14 class AudioOutputDispatcher; | 15 class AudioOutputDispatcher; |
15 | 16 |
16 // AudioManagerBase provides AudioManager functions common for all platforms. | 17 // AudioManagerBase provides AudioManager functions common for all platforms. |
17 class MEDIA_EXPORT AudioManagerBase : public AudioManager { | 18 class MEDIA_EXPORT AudioManagerBase : public AudioManager { |
18 public: | 19 public: |
19 // Name of the generic "default" device. | 20 // Name of the generic "default" device. |
20 static const char kDefaultDeviceName[]; | 21 static const char kDefaultDeviceName[]; |
21 // Unique Id of the generic "default" device. | 22 // Unique Id of the generic "default" device. |
22 static const char kDefaultDeviceId[]; | 23 static const char kDefaultDeviceId[]; |
23 | 24 |
24 AudioManagerBase(); | 25 AudioManagerBase(); |
25 | 26 |
27 #ifndef NDEBUG | |
28 // Overridden to make sure we don't accidentally get added reference counts on | |
29 // the audio thread. The AudioManagerBase instance must always be deleted | |
30 // from outside the audio thread. | |
31 virtual void AddRef() const OVERRIDE; | |
32 virtual void Release() const OVERRIDE; | |
33 #endif | |
34 | |
26 virtual void Init() OVERRIDE; | 35 virtual void Init() OVERRIDE; |
27 virtual void Cleanup() OVERRIDE; | |
28 | 36 |
29 virtual MessageLoop* GetMessageLoop() OVERRIDE; | 37 virtual MessageLoop* GetMessageLoop() OVERRIDE; |
30 | 38 |
31 virtual string16 GetAudioInputDeviceModel() OVERRIDE; | 39 virtual string16 GetAudioInputDeviceModel() OVERRIDE; |
32 | 40 |
33 virtual bool CanShowAudioInputSettings() OVERRIDE; | 41 virtual bool CanShowAudioInputSettings() OVERRIDE; |
34 virtual void ShowAudioInputSettings() OVERRIDE; | 42 virtual void ShowAudioInputSettings() OVERRIDE; |
35 | 43 |
36 virtual void GetAudioInputDeviceNames(media::AudioDeviceNames* device_names) | 44 virtual void GetAudioInputDeviceNames(media::AudioDeviceNames* device_names) |
37 OVERRIDE; | 45 OVERRIDE; |
38 | 46 |
39 virtual AudioOutputStream* MakeAudioOutputStreamProxy( | 47 virtual AudioOutputStream* MakeAudioOutputStreamProxy( |
40 const AudioParameters& params) OVERRIDE; | 48 const AudioParameters& params) OVERRIDE; |
41 | 49 |
42 virtual bool IsRecordingInProcess() OVERRIDE; | 50 virtual bool IsRecordingInProcess() OVERRIDE; |
43 | 51 |
44 void IncreaseActiveInputStreamCount(); | 52 void IncreaseActiveInputStreamCount(); |
45 void DecreaseActiveInputStreamCount(); | 53 void DecreaseActiveInputStreamCount(); |
54 void Shutdown(); | |
scherkus (not reviewing)
2011/12/09 22:47:30
docs?
also I looked through the patch but couldn'
tommi (sloooow) - chröme
2011/12/10 00:11:14
Added.
| |
46 | 55 |
47 protected: | 56 protected: |
48 virtual ~AudioManagerBase(); | 57 virtual ~AudioManagerBase(); |
49 | 58 |
50 typedef std::map<AudioParameters, scoped_refptr<AudioOutputDispatcher>, | 59 typedef std::map<AudioParameters, scoped_refptr<AudioOutputDispatcher>, |
51 AudioParameters::Compare> | 60 AudioParameters::Compare> |
52 AudioOutputDispatchersMap; | 61 AudioOutputDispatchersMap; |
53 | 62 |
54 bool initialized() { return initialized_; } | 63 void ShutdownOnAudioThread(); |
64 | |
65 bool initialized() { return audio_thread_.IsRunning(); } | |
55 | 66 |
56 // Thread used to interact with AudioOutputStreams created by this | 67 // Thread used to interact with AudioOutputStreams created by this |
57 // audio manger. | 68 // audio manger. |
58 base::Thread audio_thread_; | 69 base::Thread audio_thread_; |
59 | 70 |
60 bool initialized_; | |
61 | |
62 AudioOutputDispatchersMap output_dispatchers_; | 71 AudioOutputDispatchersMap output_dispatchers_; |
63 | 72 |
64 // Counts the number of active input streams to find out if something else | 73 // Counts the number of active input streams to find out if something else |
65 // is currently recording in Chrome. | 74 // is currently recording in Chrome. |
66 int num_active_input_streams_; | 75 base::AtomicRefCount num_active_input_streams_; |
67 | |
68 // Lock used to synchronize the access to num_active_input_streams_. | |
69 // Do not use for anything else and try to avoid using other locks | |
70 // in this code whenever possible. | |
71 base::Lock active_input_streams_lock_; | |
72 | 76 |
73 DISALLOW_COPY_AND_ASSIGN(AudioManagerBase); | 77 DISALLOW_COPY_AND_ASSIGN(AudioManagerBase); |
74 }; | 78 }; |
75 | 79 |
76 #endif // MEDIA_AUDIO_AUDIO_MANAGER_BASE_H_ | 80 #endif // MEDIA_AUDIO_AUDIO_MANAGER_BASE_H_ |
OLD | NEW |