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 // AudioOutputDispatcher is a single-threaded class that dispatches creation and | 5 // AudioOutputDispatcher is a single-threaded class that dispatches creation and |
6 // deletion of audio output streams. AudioOutputProxy objects use this class to | 6 // deletion of audio output streams. AudioOutputProxy objects use this class to |
7 // allocate and recycle actual audio output streams. When playback is started, | 7 // allocate and recycle actual audio output streams. When playback is started, |
8 // the proxy calls StreamStarted() to get an output stream that it uses to play | 8 // the proxy calls StreamStarted() to get an output stream that it uses to play |
9 // audio. When playback is stopped, the proxy returns the stream back to the | 9 // audio. When playback is stopped, the proxy returns the stream back to the |
10 // dispatcher by calling StreamStopped(). | 10 // dispatcher by calling StreamStopped(). |
(...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
62 // added to the pool of pending streams (i.e. |idle_streams_|). | 62 // added to the pool of pending streams (i.e. |idle_streams_|). |
63 // Ownership of the |stream| is passed to the dispatcher. | 63 // Ownership of the |stream| is passed to the dispatcher. |
64 void StreamStopped(AudioOutputStream* stream); | 64 void StreamStopped(AudioOutputStream* stream); |
65 | 65 |
66 // Called by AudioOutputProxy when the stream is closed. | 66 // Called by AudioOutputProxy when the stream is closed. |
67 void StreamClosed(); | 67 void StreamClosed(); |
68 | 68 |
69 // Called on the audio thread when the AudioManager is shutting down. | 69 // Called on the audio thread when the AudioManager is shutting down. |
70 void Shutdown(); | 70 void Shutdown(); |
71 | 71 |
72 MessageLoop* message_loop(); | 72 // Used to DCHECK correct usage. The method _should_ always be called |
| 73 // from the audio thread, so we don't have any locks to protect the |
| 74 // message loop pointer. |
| 75 bool CurrentThreadIsAudioThread() const; |
73 | 76 |
74 private: | 77 private: |
75 friend class AudioOutputProxyTest; | 78 friend class AudioOutputProxyTest; |
76 | 79 |
77 // Creates a new physical output stream, opens it and pushes to | 80 // Creates a new physical output stream, opens it and pushes to |
78 // |idle_streams_|. Returns false if the stream couldn't be created or | 81 // |idle_streams_|. Returns false if the stream couldn't be created or |
79 // opened. | 82 // opened. |
80 bool CreateAndOpenStream(); | 83 bool CreateAndOpenStream(); |
81 | 84 |
82 // A task scheduled by StreamStarted(). Opens a new stream and puts | 85 // A task scheduled by StreamStarted(). Opens a new stream and puts |
(...skipping 20 matching lines...) Expand all Loading... |
103 AudioOutputStreamList pausing_streams_; | 106 AudioOutputStreamList pausing_streams_; |
104 | 107 |
105 // Used to post delayed tasks to ourselves that we cancel inside Shutdown(). | 108 // Used to post delayed tasks to ourselves that we cancel inside Shutdown(). |
106 base::WeakPtrFactory<AudioOutputDispatcher> weak_this_; | 109 base::WeakPtrFactory<AudioOutputDispatcher> weak_this_; |
107 base::DelayTimer<AudioOutputDispatcher> close_timer_; | 110 base::DelayTimer<AudioOutputDispatcher> close_timer_; |
108 | 111 |
109 DISALLOW_COPY_AND_ASSIGN(AudioOutputDispatcher); | 112 DISALLOW_COPY_AND_ASSIGN(AudioOutputDispatcher); |
110 }; | 113 }; |
111 | 114 |
112 #endif // MEDIA_AUDIO_AUDIO_OUTPUT_DISPATCHER_H_ | 115 #endif // MEDIA_AUDIO_AUDIO_OUTPUT_DISPATCHER_H_ |
OLD | NEW |