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 // AudioOutputDispatcherImpl is an implementation of AudioOutputDispatcher. | 5 // AudioOutputDispatcherImpl is an implementation of AudioOutputDispatcher. |
6 // | 6 // |
7 // To avoid opening and closing audio devices more frequently than necessary, | 7 // To avoid opening and closing audio devices more frequently than necessary, |
8 // each dispatcher has a pool of inactive physical streams. A stream is closed | 8 // each dispatcher has a pool of inactive physical streams. A stream is closed |
9 // only if it hasn't been used for a certain period of time (specified via the | 9 // only if it hasn't been used for a certain period of time (specified via the |
10 // constructor). | 10 // constructor). |
(...skipping 63 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
74 ~AudioOutputDispatcherImpl() override; | 74 ~AudioOutputDispatcherImpl() override; |
75 | 75 |
76 // Creates a new physical output stream, opens it and pushes to | 76 // Creates a new physical output stream, opens it and pushes to |
77 // |idle_streams_|. Returns false if the stream couldn't be created or | 77 // |idle_streams_|. Returns false if the stream couldn't be created or |
78 // opened. | 78 // opened. |
79 bool CreateAndOpenStream(); | 79 bool CreateAndOpenStream(); |
80 | 80 |
81 // Similar to CloseAllIdleStreams(), but keeps |keep_alive| streams alive. | 81 // Similar to CloseAllIdleStreams(), but keeps |keep_alive| streams alive. |
82 void CloseIdleStreams(size_t keep_alive); | 82 void CloseIdleStreams(size_t keep_alive); |
83 | 83 |
| 84 void OnStatistics(AudioOutputStream* physical_stream, |
| 85 const std::string& name, |
| 86 int value); |
| 87 |
84 size_t idle_proxies_; | 88 size_t idle_proxies_; |
85 std::vector<AudioOutputStream*> idle_streams_; | 89 std::vector<AudioOutputStream*> idle_streams_; |
86 | 90 |
87 // When streams are stopped they're added to |idle_streams_|, if no stream is | 91 // When streams are stopped they're added to |idle_streams_|, if no stream is |
88 // reused before |close_delay_| elapses |close_timer_| will run | 92 // reused before |close_delay_| elapses |close_timer_| will run |
89 // CloseIdleStreams(). | 93 // CloseIdleStreams(). |
90 base::DelayTimer close_timer_; | 94 base::DelayTimer close_timer_; |
91 | 95 |
92 typedef std::map<AudioOutputProxy*, AudioOutputStream*> AudioStreamMap; | 96 typedef std::map<AudioOutputProxy*, AudioOutputStream*> AudioStreamMap; |
93 AudioStreamMap proxy_to_physical_map_; | 97 AudioStreamMap proxy_to_physical_map_; |
94 | 98 |
95 std::unique_ptr<AudioLog> audio_log_; | 99 std::unique_ptr<AudioLog> audio_log_; |
96 typedef std::map<AudioOutputStream*, int> AudioStreamIDMap; | 100 typedef std::map<AudioOutputStream*, int> AudioStreamIDMap; |
97 AudioStreamIDMap audio_stream_ids_; | 101 AudioStreamIDMap audio_stream_ids_; |
98 int audio_stream_id_; | 102 int audio_stream_id_; |
99 | 103 |
100 DISALLOW_COPY_AND_ASSIGN(AudioOutputDispatcherImpl); | 104 DISALLOW_COPY_AND_ASSIGN(AudioOutputDispatcherImpl); |
101 }; | 105 }; |
102 | 106 |
103 } // namespace media | 107 } // namespace media |
104 | 108 |
105 #endif // MEDIA_AUDIO_AUDIO_OUTPUT_DISPATCHER_IMPL_H_ | 109 #endif // MEDIA_AUDIO_AUDIO_OUTPUT_DISPATCHER_IMPL_H_ |
OLD | NEW |