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 // Returns the platform specific number of audio streams allowed. This is a | |
| 68 // practical limit to prevent failure caused by too many audio streams opened. | |
| 69 virtual int GetMaxOutputStreamsAllowed() = 0; | |
|
tommi (sloooow) - chröme
2012/03/06 16:16:04
nit: Instead of a pure virtual function + implemen
no longer working on chromium
2012/03/06 17:38:41
Done.
| |
| 70 | |
| 71 // Creates the output stream for the |AUDIO_PCM_LINEAR format|. The legacy | |
| 72 // name is also from |AUDIO_PCM_LINEAR|. | |
| 73 virtual AudioOutputStream* MakeLinearOutputStream( | |
| 74 const AudioParameters& params) = 0; | |
| 75 | |
| 76 // Creates the output stream for the |AUDIO_PCM_LOW_LATENCY| format. | |
| 77 virtual AudioOutputStream* MakeLowLatencyOutputStream( | |
| 78 const AudioParameters& params) = 0; | |
| 79 | |
| 80 // Creates the input stream for the |AUDIO_PCM_LINEAR format|. The legacy | |
| 81 // name is also from |AUDIO_PCM_LINEAR|. | |
| 82 virtual AudioInputStream* MakeLinearInputStream( | |
| 83 const AudioParameters& params, const std::string& device_id) = 0; | |
| 84 | |
| 85 // Creates the input stream for the |AUDIO_PCM_LOW_LATENCY| format. | |
| 86 virtual AudioInputStream* MakeLowLatencyInputStream( | |
| 87 const AudioParameters& params, const std::string& device_id) = 0; | |
| 88 | |
| 57 protected: | 89 protected: |
| 58 AudioManagerBase(); | 90 AudioManagerBase(); |
| 59 | 91 |
| 60 typedef std::map<AudioParameters, scoped_refptr<AudioOutputDispatcher>, | 92 typedef std::map<AudioParameters, scoped_refptr<AudioOutputDispatcher>, |
| 61 AudioParameters::Compare> | 93 AudioParameters::Compare> |
| 62 AudioOutputDispatchersMap; | 94 AudioOutputDispatchersMap; |
| 63 | 95 |
| 64 void ShutdownOnAudioThread(); | 96 void ShutdownOnAudioThread(); |
| 65 | 97 |
| 66 // Thread used to interact with AudioOutputStreams created by this | 98 // Thread used to interact with AudioOutputStreams created by this |
| 67 // audio manger. | 99 // audio manger. |
| 68 scoped_ptr<base::Thread> audio_thread_; | 100 scoped_ptr<base::Thread> audio_thread_; |
| 69 mutable base::Lock audio_thread_lock_; | 101 mutable base::Lock audio_thread_lock_; |
| 70 | 102 |
| 71 // Map of cached AudioOutputDispatcher instances. Must only be touched | 103 // Map of cached AudioOutputDispatcher instances. Must only be touched |
| 72 // from the audio thread (no locking). | 104 // from the audio thread (no locking). |
| 73 AudioOutputDispatchersMap output_dispatchers_; | 105 AudioOutputDispatchersMap output_dispatchers_; |
| 74 | 106 |
| 75 // Counts the number of active input streams to find out if something else | 107 // Counts the number of active input streams to find out if something else |
| 76 // is currently recording in Chrome. | 108 // is currently recording in Chrome. |
| 77 base::AtomicRefCount num_active_input_streams_; | 109 base::AtomicRefCount num_active_input_streams_; |
| 78 | 110 |
| 111 // Number of currently open output streams. | |
| 112 int num_output_streams_; | |
| 113 | |
| 79 DISALLOW_COPY_AND_ASSIGN(AudioManagerBase); | 114 DISALLOW_COPY_AND_ASSIGN(AudioManagerBase); |
| 80 }; | 115 }; |
| 81 | 116 |
| 82 #endif // MEDIA_AUDIO_AUDIO_MANAGER_BASE_H_ | 117 #endif // MEDIA_AUDIO_AUDIO_MANAGER_BASE_H_ |
| OLD | NEW |