| 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 <memory> | 8 #include <memory> |
| 9 #include <string> | 9 #include <string> |
| 10 #include <unordered_set> |
| 10 #include <utility> | 11 #include <utility> |
| 11 | 12 |
| 12 #include "base/compiler_specific.h" | 13 #include "base/compiler_specific.h" |
| 13 #include "base/macros.h" | 14 #include "base/macros.h" |
| 14 #include "base/memory/scoped_vector.h" | 15 #include "base/memory/scoped_vector.h" |
| 15 #include "base/observer_list.h" | 16 #include "base/observer_list.h" |
| 16 #include "base/threading/thread.h" | 17 #include "base/threading/thread.h" |
| 17 #include "build/build_config.h" | 18 #include "build/build_config.h" |
| 18 #include "media/audio/audio_manager.h" | 19 #include "media/audio/audio_manager.h" |
| 19 #include "media/audio/audio_output_dispatcher.h" | 20 #include "media/audio/audio_output_dispatcher.h" |
| (...skipping 69 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 89 | 90 |
| 90 // Creates the input stream for the |AUDIO_PCM_LOW_LATENCY| format. | 91 // Creates the input stream for the |AUDIO_PCM_LOW_LATENCY| format. |
| 91 virtual AudioInputStream* MakeLowLatencyInputStream( | 92 virtual AudioInputStream* MakeLowLatencyInputStream( |
| 92 const AudioParameters& params, | 93 const AudioParameters& params, |
| 93 const std::string& device_id, | 94 const std::string& device_id, |
| 94 const LogCallback& log_callback) = 0; | 95 const LogCallback& log_callback) = 0; |
| 95 | 96 |
| 96 std::string GetGroupIDOutput(const std::string& output_device_id) override; | 97 std::string GetGroupIDOutput(const std::string& output_device_id) override; |
| 97 std::string GetGroupIDInput(const std::string& input_device_id) override; | 98 std::string GetGroupIDInput(const std::string& input_device_id) override; |
| 98 | 99 |
| 99 // Get number of input or output streams. | |
| 100 int input_stream_count() const { return num_input_streams_; } | |
| 101 int output_stream_count() const { return num_output_streams_; } | |
| 102 | |
| 103 protected: | 100 protected: |
| 104 AudioManagerBase( | 101 AudioManagerBase( |
| 105 scoped_refptr<base::SingleThreadTaskRunner> task_runner, | 102 scoped_refptr<base::SingleThreadTaskRunner> task_runner, |
| 106 scoped_refptr<base::SingleThreadTaskRunner> worker_task_runner, | 103 scoped_refptr<base::SingleThreadTaskRunner> worker_task_runner, |
| 107 AudioLogFactory* audio_log_factory); | 104 AudioLogFactory* audio_log_factory); |
| 108 | 105 |
| 109 // Releases all the audio output dispatchers. | 106 // Releases all the audio output dispatchers. |
| 110 // All audio streams should be closed before Shutdown() is called. | 107 // All audio streams should be closed before Shutdown() is called. |
| 111 // This must be called in the destructor of every AudioManagerBase | 108 // This must be called in the destructor of every AudioManagerBase |
| 112 // implementation. | 109 // implementation. |
| (...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 147 // Max number of open output streams, modified by | 144 // Max number of open output streams, modified by |
| 148 // SetMaxOutputStreamsAllowed(). | 145 // SetMaxOutputStreamsAllowed(). |
| 149 int max_num_output_streams_; | 146 int max_num_output_streams_; |
| 150 | 147 |
| 151 // Max number of open input streams. | 148 // Max number of open input streams. |
| 152 int max_num_input_streams_; | 149 int max_num_input_streams_; |
| 153 | 150 |
| 154 // Number of currently open output streams. | 151 // Number of currently open output streams. |
| 155 int num_output_streams_; | 152 int num_output_streams_; |
| 156 | 153 |
| 157 // Number of currently open input streams. | |
| 158 int num_input_streams_; | |
| 159 | |
| 160 // Track output state change listeners. | 154 // Track output state change listeners. |
| 161 base::ObserverList<AudioDeviceListener> output_listeners_; | 155 base::ObserverList<AudioDeviceListener> output_listeners_; |
| 162 | 156 |
| 157 // Contains currently open input streams. |
| 158 std::unordered_set<AudioInputStream*> input_streams_; |
| 159 |
| 163 // Map of cached AudioOutputDispatcher instances. Must only be touched | 160 // Map of cached AudioOutputDispatcher instances. Must only be touched |
| 164 // from the audio thread (no locking). | 161 // from the audio thread (no locking). |
| 165 AudioOutputDispatchers output_dispatchers_; | 162 AudioOutputDispatchers output_dispatchers_; |
| 166 | 163 |
| 167 // Proxy for creating AudioLog objects. | 164 // Proxy for creating AudioLog objects. |
| 168 AudioLogFactory* const audio_log_factory_; | 165 AudioLogFactory* const audio_log_factory_; |
| 169 | 166 |
| 170 DISALLOW_COPY_AND_ASSIGN(AudioManagerBase); | 167 DISALLOW_COPY_AND_ASSIGN(AudioManagerBase); |
| 171 }; | 168 }; |
| 172 | 169 |
| 173 } // namespace media | 170 } // namespace media |
| 174 | 171 |
| 175 #endif // MEDIA_AUDIO_AUDIO_MANAGER_BASE_H_ | 172 #endif // MEDIA_AUDIO_AUDIO_MANAGER_BASE_H_ |
| OLD | NEW |