Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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" |
| (...skipping 20 matching lines...) Expand all Loading... | |
| 31 | 31 |
| 32 virtual void Init() OVERRIDE; | 32 virtual void Init() OVERRIDE; |
| 33 | 33 |
| 34 virtual scoped_refptr<base::MessageLoopProxy> GetMessageLoop() OVERRIDE; | 34 virtual scoped_refptr<base::MessageLoopProxy> GetMessageLoop() OVERRIDE; |
| 35 | 35 |
| 36 virtual string16 GetAudioInputDeviceModel() OVERRIDE; | 36 virtual string16 GetAudioInputDeviceModel() OVERRIDE; |
| 37 | 37 |
| 38 virtual bool CanShowAudioInputSettings() OVERRIDE; | 38 virtual bool CanShowAudioInputSettings() OVERRIDE; |
| 39 virtual void ShowAudioInputSettings() OVERRIDE; | 39 virtual void ShowAudioInputSettings() OVERRIDE; |
| 40 | 40 |
| 41 virtual void GetAudioInputDeviceNames(media::AudioDeviceNames* device_names) | 41 virtual void GetAudioInputDeviceNames( |
| 42 OVERRIDE; | 42 media::AudioDeviceNames* device_names) OVERRIDE; |
| 43 | |
| 44 virtual AudioOutputStream* MakeAudioOutputStream( | |
| 45 const AudioParameters& params) OVERRIDE; | |
| 46 | |
| 47 virtual AudioInputStream* MakeAudioInputStream( | |
| 48 const AudioParameters& params, const std::string& device_id) OVERRIDE; | |
| 43 | 49 |
| 44 virtual AudioOutputStream* MakeAudioOutputStreamProxy( | 50 virtual AudioOutputStream* MakeAudioOutputStreamProxy( |
| 45 const AudioParameters& params) OVERRIDE; | 51 const AudioParameters& params) OVERRIDE; |
| 46 | 52 |
| 47 virtual bool IsRecordingInProcess() OVERRIDE; | 53 virtual bool IsRecordingInProcess() OVERRIDE; |
| 48 | 54 |
| 55 // Called internally by the audio stream when it has been closed. | |
| 56 virtual void ReleaseOutputStream(AudioOutputStream* stream); | |
| 57 virtual void ReleaseInputStream(AudioInputStream* stream); | |
| 58 | |
| 49 void IncreaseActiveInputStreamCount(); | 59 void IncreaseActiveInputStreamCount(); |
| 50 void DecreaseActiveInputStreamCount(); | 60 void DecreaseActiveInputStreamCount(); |
| 51 | 61 |
| 52 // Shuts down the audio thread and releases all the audio output dispatchers | 62 // Shuts down the audio thread and releases all the audio output dispatchers |
| 53 // on the audio thread. All AudioOutputProxy instances should be freed before | 63 // on the audio thread. All AudioOutputProxy instances should be freed before |
| 54 // Shutdown is called. | 64 // Shutdown is called. |
| 55 void Shutdown(); | 65 void Shutdown(); |
| 56 | 66 |
| 67 // Creates the output stream for the |AUDIO_PCM_LINEAR format|. The legacy | |
|
scherkus (not reviewing)
2012/03/06 22:31:51
nit: move format outside of ||
no longer working on chromium
2012/03/07 09:57:08
Done.
| |
| 68 // name is also from |AUDIO_PCM_LINEAR|. | |
| 69 virtual AudioOutputStream* MakeLinearOutputStream( | |
| 70 const AudioParameters& params) = 0; | |
| 71 | |
| 72 // Creates the output stream for the |AUDIO_PCM_LOW_LATENCY| format. | |
| 73 virtual AudioOutputStream* MakeLowLatencyOutputStream( | |
| 74 const AudioParameters& params) = 0; | |
| 75 | |
| 76 // Creates the input stream for the |AUDIO_PCM_LINEAR format|. The legacy | |
|
scherkus (not reviewing)
2012/03/06 22:31:51
nit: move format outside of ||
no longer working on chromium
2012/03/07 09:57:08
Done.
| |
| 77 // name is also from |AUDIO_PCM_LINEAR|. | |
| 78 virtual AudioInputStream* MakeLinearInputStream( | |
| 79 const AudioParameters& params, const std::string& device_id) = 0; | |
| 80 | |
| 81 // Creates the input stream for the |AUDIO_PCM_LOW_LATENCY| format. | |
| 82 virtual AudioInputStream* MakeLowLatencyInputStream( | |
| 83 const AudioParameters& params, const std::string& device_id) = 0; | |
| 84 | |
| 57 protected: | 85 protected: |
| 58 AudioManagerBase(); | 86 AudioManagerBase(); |
| 59 | 87 |
| 60 typedef std::map<AudioParameters, scoped_refptr<AudioOutputDispatcher>, | 88 typedef std::map<AudioParameters, scoped_refptr<AudioOutputDispatcher>, |
| 61 AudioParameters::Compare> | 89 AudioParameters::Compare> |
| 62 AudioOutputDispatchersMap; | 90 AudioOutputDispatchersMap; |
| 63 | 91 |
| 64 void ShutdownOnAudioThread(); | 92 void ShutdownOnAudioThread(); |
| 65 | 93 |
| 94 void SetMaxOutputStreamsAllowed(int max) { max_num_output_streams_ = max; } | |
| 95 | |
| 66 // Thread used to interact with AudioOutputStreams created by this | 96 // Thread used to interact with AudioOutputStreams created by this |
| 67 // audio manger. | 97 // audio manger. |
| 68 scoped_ptr<base::Thread> audio_thread_; | 98 scoped_ptr<base::Thread> audio_thread_; |
| 69 mutable base::Lock audio_thread_lock_; | 99 mutable base::Lock audio_thread_lock_; |
| 70 | 100 |
| 71 // Map of cached AudioOutputDispatcher instances. Must only be touched | 101 // Map of cached AudioOutputDispatcher instances. Must only be touched |
| 72 // from the audio thread (no locking). | 102 // from the audio thread (no locking). |
| 73 AudioOutputDispatchersMap output_dispatchers_; | 103 AudioOutputDispatchersMap output_dispatchers_; |
| 74 | 104 |
| 75 // Counts the number of active input streams to find out if something else | 105 // Counts the number of active input streams to find out if something else |
| 76 // is currently recording in Chrome. | 106 // is currently recording in Chrome. |
| 77 base::AtomicRefCount num_active_input_streams_; | 107 base::AtomicRefCount num_active_input_streams_; |
| 78 | 108 |
| 109 // Max number of open output streams, modified by | |
| 110 // SetMaxOutputStreamsAllowed(). | |
| 111 int max_num_output_streams_; | |
| 112 | |
| 113 // Number of currently open output streams. | |
| 114 int num_output_streams_; | |
| 115 | |
| 79 DISALLOW_COPY_AND_ASSIGN(AudioManagerBase); | 116 DISALLOW_COPY_AND_ASSIGN(AudioManagerBase); |
| 80 }; | 117 }; |
| 81 | 118 |
| 82 #endif // MEDIA_AUDIO_AUDIO_MANAGER_BASE_H_ | 119 #endif // MEDIA_AUDIO_AUDIO_MANAGER_BASE_H_ |
| OLD | NEW |