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 14 matching lines...) Expand all Loading... | |
25 #include <vector> | 25 #include <vector> |
26 #include <list> | 26 #include <list> |
27 | 27 |
28 #include "base/basictypes.h" | 28 #include "base/basictypes.h" |
29 #include "base/memory/ref_counted.h" | 29 #include "base/memory/ref_counted.h" |
30 #include "base/memory/weak_ptr.h" | 30 #include "base/memory/weak_ptr.h" |
31 #include "base/timer.h" | 31 #include "base/timer.h" |
32 #include "media/audio/audio_manager.h" | 32 #include "media/audio/audio_manager.h" |
33 #include "media/audio/audio_parameters.h" | 33 #include "media/audio/audio_parameters.h" |
34 | 34 |
35 class AudioOutputProxyTest; | |
36 class MessageLoop; | |
37 | |
38 namespace media { | |
39 | |
35 class AudioOutputStream; | 40 class AudioOutputStream; |
36 class MessageLoop; | |
37 | 41 |
38 class MEDIA_EXPORT AudioOutputDispatcher | 42 class MEDIA_EXPORT AudioOutputDispatcher |
39 : public base::RefCountedThreadSafe<AudioOutputDispatcher> { | 43 : public base::RefCountedThreadSafe<AudioOutputDispatcher> { |
40 public: | 44 public: |
41 // |close_delay_ms| specifies delay after the stream is paused until | 45 // |close_delay_ms| specifies delay after the stream is paused until |
42 // the audio device is closed. | 46 // the audio device is closed. |
43 AudioOutputDispatcher(AudioManager* audio_manager, | 47 AudioOutputDispatcher(AudioManager* audio_manager, |
44 const AudioParameters& params, | 48 const AudioParameters& params, |
45 base::TimeDelta close_delay); | 49 base::TimeDelta close_delay); |
46 ~AudioOutputDispatcher(); | 50 ~AudioOutputDispatcher(); |
(...skipping 16 matching lines...) Expand all Loading... | |
63 // Ownership of the |stream| is passed to the dispatcher. | 67 // Ownership of the |stream| is passed to the dispatcher. |
64 void StreamStopped(AudioOutputStream* stream); | 68 void StreamStopped(AudioOutputStream* stream); |
65 | 69 |
66 // Called by AudioOutputProxy when the stream is closed. | 70 // Called by AudioOutputProxy when the stream is closed. |
67 void StreamClosed(); | 71 void StreamClosed(); |
68 | 72 |
69 // Called on the audio thread when the AudioManager is shutting down. | 73 // Called on the audio thread when the AudioManager is shutting down. |
70 void Shutdown(); | 74 void Shutdown(); |
71 | 75 |
72 private: | 76 private: |
73 friend class AudioOutputProxyTest; | 77 // XXX(vrk): See comment in AudioOutputProxyTest. |
scherkus (not reviewing)
2012/03/21 08:50:27
???
vrk (LEFT CHROMIUM)
2012/03/21 20:17:48
Oh, I was just trying to explain why AudioOutputPr
| |
78 friend class ::AudioOutputProxyTest; | |
74 | 79 |
75 // Creates a new physical output stream, opens it and pushes to | 80 // Creates a new physical output stream, opens it and pushes to |
76 // |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 |
77 // opened. | 82 // opened. |
78 bool CreateAndOpenStream(); | 83 bool CreateAndOpenStream(); |
79 | 84 |
80 // A task scheduled by StreamStarted(). Opens a new stream and puts | 85 // A task scheduled by StreamStarted(). Opens a new stream and puts |
81 // it in |idle_streams_|. | 86 // it in |idle_streams_|. |
82 void OpenTask(); | 87 void OpenTask(); |
83 | 88 |
(...skipping 16 matching lines...) Expand all Loading... | |
100 AudioOutputStreamList idle_streams_; | 105 AudioOutputStreamList idle_streams_; |
101 AudioOutputStreamList pausing_streams_; | 106 AudioOutputStreamList pausing_streams_; |
102 | 107 |
103 // 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(). |
104 base::WeakPtrFactory<AudioOutputDispatcher> weak_this_; | 109 base::WeakPtrFactory<AudioOutputDispatcher> weak_this_; |
105 base::DelayTimer<AudioOutputDispatcher> close_timer_; | 110 base::DelayTimer<AudioOutputDispatcher> close_timer_; |
106 | 111 |
107 DISALLOW_COPY_AND_ASSIGN(AudioOutputDispatcher); | 112 DISALLOW_COPY_AND_ASSIGN(AudioOutputDispatcher); |
108 }; | 113 }; |
109 | 114 |
115 } // namespace media | |
116 | |
110 #endif // MEDIA_AUDIO_AUDIO_OUTPUT_DISPATCHER_H_ | 117 #endif // MEDIA_AUDIO_AUDIO_OUTPUT_DISPATCHER_H_ |
OLD | NEW |