Chromium Code Reviews| OLD | NEW | 
|---|---|
| 1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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 dispatches creation and deletion of audio | 5 // AudioOutputDispatcher dispatches creation and deletion of audio | 
| 6 // output streams. AudioOutputProxy objects use this class to allocate | 6 // output streams. AudioOutputProxy objects use this class to allocate | 
| 7 // and recycle actual audio output streams. When playback is started, | 7 // and recycle actual audio output streams. When playback is started, | 
| 8 // the proxy calls StreamStarted() to get an output stream that it | 8 // the proxy calls StreamStarted() to get an output stream that it | 
| 9 // uses to play the sound. When playback is stopped, the proxy returns | 9 // uses to play the sound. When playback is stopped, the proxy returns | 
| 10 // the stream back to the dispatcher by calling StreamStopped(). | 10 // the stream back to the dispatcher by calling StreamStopped(). | 
| 11 // | 11 // | 
| 12 // To avoid opening and closing audio devices more frequently than it | 12 // To avoid opening and closing audio devices more frequently than it | 
| 13 // is neccessary, each dispatcher has a pool of inactive physical | 13 // is neccessary, each dispatcher has a pool of inactive physical | 
| 14 // streams. A stream is closed only if it hasn't been used for a | 14 // streams. A stream is closed only if it hasn't been used for a | 
| 15 // certain period of time (specified in the constructor). | 15 // certain period of time (specified in the constructor). | 
| 16 // | 16 // | 
| 17 // AudioManagerBase creates one AudioOutputDispatcher per each | 17 // AudioManagerBase creates one AudioOutputDispatcher per each | 
| 18 // possible set of audio parameters, i.e. streams with different | 18 // possible set of audio parameters, i.e. streams with different | 
| 19 // parameters are managed independently. | 19 // parameters are managed independently. | 
| 20 | 20 | 
| 21 #ifndef MEDIA_AUDIO_AUDIO_OUTPUT_DISPATCHER_H_ | 21 #ifndef MEDIA_AUDIO_AUDIO_OUTPUT_DISPATCHER_H_ | 
| 22 #define MEDIA_AUDIO_AUDIO_OUTPUT_DISPATCHER_H_ | 22 #define MEDIA_AUDIO_AUDIO_OUTPUT_DISPATCHER_H_ | 
| 23 | 23 | 
| 24 #include <vector> | 24 #include <vector> | 
| 25 #include <list> | |
| 
 
scherkus (not reviewing)
2011/04/11 22:32:33
nit: list comes before vector
 
 | |
| 25 | 26 | 
| 26 #include "base/basictypes.h" | 27 #include "base/basictypes.h" | 
| 27 #include "base/memory/ref_counted.h" | 28 #include "base/memory/ref_counted.h" | 
| 28 #include "base/timer.h" | 29 #include "base/timer.h" | 
| 29 #include "media/audio/audio_manager.h" | 30 #include "media/audio/audio_manager.h" | 
| 30 #include "media/audio/audio_parameters.h" | 31 #include "media/audio/audio_parameters.h" | 
| 31 | 32 | 
| 32 class AudioOutputStream; | 33 class AudioOutputStream; | 
| 33 class MessageLoop; | 34 class MessageLoop; | 
| 34 | 35 | 
| (...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 69 | 70 | 
| 70 // Creates a new physical output stream, opens it and pushes to | 71 // Creates a new physical output stream, opens it and pushes to | 
| 71 // |streams_|. Returns false if the stream couldn't be created or | 72 // |streams_|. Returns false if the stream couldn't be created or | 
| 72 // opened. | 73 // opened. | 
| 73 bool CreateAndOpenStream(); | 74 bool CreateAndOpenStream(); | 
| 74 | 75 | 
| 75 // A task scheduled by StreamStarted(). Opens a new stream and puts | 76 // A task scheduled by StreamStarted(). Opens a new stream and puts | 
| 76 // it in |streams_|. | 77 // it in |streams_|. | 
| 77 void OpenTask(); | 78 void OpenTask(); | 
| 78 | 79 | 
| 80 // Before a stream is reused, it should sit idle for a bit. This task is | |
| 81 // called once that time has elapsed. | |
| 82 void StopStreamTask(); | |
| 83 | |
| 79 // Called by |close_timer_|. Closes all pending stream. | 84 // Called by |close_timer_|. Closes all pending stream. | 
| 80 void ClosePendingStreams(); | 85 void ClosePendingStreams(); | 
| 81 | 86 | 
| 82 AudioManager* audio_manager_; | 87 AudioManager* audio_manager_; | 
| 83 MessageLoop* message_loop_; | 88 MessageLoop* message_loop_; | 
| 84 AudioParameters params_; | 89 AudioParameters params_; | 
| 85 | 90 | 
| 86 size_t paused_proxies_; | 91 size_t paused_proxies_; | 
| 87 std::vector<AudioOutputStream*> streams_; | 92 std::vector<AudioOutputStream*> streams_; | 
| 93 std::list<AudioOutputStream*> idle_streams_; | |
| 
 
Sergey Ulanov
2011/04/09 07:02:05
Please add comments that explain difference betwee
 
 | |
| 88 base::DelayTimer<AudioOutputDispatcher> close_timer_; | 94 base::DelayTimer<AudioOutputDispatcher> close_timer_; | 
| 89 | 95 | 
| 90 DISALLOW_COPY_AND_ASSIGN(AudioOutputDispatcher); | 96 DISALLOW_COPY_AND_ASSIGN(AudioOutputDispatcher); | 
| 91 }; | 97 }; | 
| 92 | 98 | 
| 93 #endif // MEDIA_AUDIO_AUDIO_OUTPUT_DISPATCHER_H_ | 99 #endif // MEDIA_AUDIO_AUDIO_OUTPUT_DISPATCHER_H_ | 
| OLD | NEW |