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 42 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
53 | 53 |
54 void StreamVolumeSet(AudioOutputProxy* stream_proxy, double volume) override; | 54 void StreamVolumeSet(AudioOutputProxy* stream_proxy, double volume) override; |
55 | 55 |
56 // Closes |idle_streams_| until the number of |idle_streams_| is equal to the | 56 // Closes |idle_streams_| until the number of |idle_streams_| is equal to the |
57 // |idle_proxies_| count. If there are no |idle_proxies_| a single stream is | 57 // |idle_proxies_| count. If there are no |idle_proxies_| a single stream is |
58 // kept alive until |close_timer_| fires. | 58 // kept alive until |close_timer_| fires. |
59 void CloseStream(AudioOutputProxy* stream_proxy) override; | 59 void CloseStream(AudioOutputProxy* stream_proxy) override; |
60 | 60 |
61 void Shutdown() override; | 61 void Shutdown() override; |
62 | 62 |
| 63 // Returns true if there are any open AudioOutputProxy objects. |
| 64 bool HasOutputProxies() const; |
| 65 |
63 private: | 66 private: |
64 friend class base::RefCountedThreadSafe<AudioOutputDispatcherImpl>; | 67 friend class base::RefCountedThreadSafe<AudioOutputDispatcherImpl>; |
65 ~AudioOutputDispatcherImpl() override; | 68 ~AudioOutputDispatcherImpl() override; |
66 | 69 |
67 // Creates a new physical output stream, opens it and pushes to | 70 // Creates a new physical output stream, opens it and pushes to |
68 // |idle_streams_|. Returns false if the stream couldn't be created or | 71 // |idle_streams_|. Returns false if the stream couldn't be created or |
69 // opened. | 72 // opened. |
70 bool CreateAndOpenStream(); | 73 bool CreateAndOpenStream(); |
71 | 74 |
72 // Closes all |idle_streams_|. | 75 // Closes all |idle_streams_|. |
(...skipping 16 matching lines...) Expand all Loading... |
89 typedef std::map<AudioOutputStream*, int> AudioStreamIDMap; | 92 typedef std::map<AudioOutputStream*, int> AudioStreamIDMap; |
90 AudioStreamIDMap audio_stream_ids_; | 93 AudioStreamIDMap audio_stream_ids_; |
91 int audio_stream_id_; | 94 int audio_stream_id_; |
92 | 95 |
93 DISALLOW_COPY_AND_ASSIGN(AudioOutputDispatcherImpl); | 96 DISALLOW_COPY_AND_ASSIGN(AudioOutputDispatcherImpl); |
94 }; | 97 }; |
95 | 98 |
96 } // namespace media | 99 } // namespace media |
97 | 100 |
98 #endif // MEDIA_AUDIO_AUDIO_OUTPUT_DISPATCHER_IMPL_H_ | 101 #endif // MEDIA_AUDIO_AUDIO_OUTPUT_DISPATCHER_IMPL_H_ |
OLD | NEW |