OLD | NEW |
(Empty) | |
| 1 // Copyright (c) 2010 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. |
| 4 |
| 5 #ifndef MEDIA_AUDIO_AUDIO_OUTPUT_DISPATCHER_H_ |
| 6 #define MEDIA_AUDIO_AUDIO_OUTPUT_DISPATCHER_H_ |
| 7 |
| 8 #include <vector> |
| 9 |
| 10 #include "base/basictypes.h" |
| 11 #include "base/ref_counted.h" |
| 12 #include "base/time.h" |
| 13 #include "media/audio/audio_manager.h" |
| 14 #include "media/audio/audio_parameters.h" |
| 15 |
| 16 class AudioOutputStream; |
| 17 class MessageLoop; |
| 18 |
| 19 // AudioOutputDispatcher dispatches creation and deletion of audio |
| 20 // output streams. AudioManagerBase creates one AudioOutputDispatcher |
| 21 // per each possible set of audio parameters. AudioOutputProxy |
| 22 // objects use this class to allocate and recycle actual audio output |
| 23 // streams. |
| 24 class AudioOutputDispatcher |
| 25 : public base::RefCountedThreadSafe<AudioOutputDispatcher> { |
| 26 public: |
| 27 AudioOutputDispatcher(AudioManager* audio_manager, |
| 28 const AudioParameters& params); |
| 29 ~AudioOutputDispatcher(); |
| 30 |
| 31 // Following 4 methods are called by AudioOutput when a stream |
| 32 // is opened, started, stopped or closed. |
| 33 bool StreamOpened(); |
| 34 AudioOutputStream* StreamStarted(); |
| 35 void StreamStopped(AudioOutputStream* stream); |
| 36 void StreamClosed(); |
| 37 |
| 38 MessageLoop* message_loop(); |
| 39 |
| 40 void set_close_delay(base::TimeDelta delay); |
| 41 |
| 42 private: |
| 43 friend class AudioOutputProxyTest; |
| 44 |
| 45 AudioOutputStream* CreateAndOpenStream(); |
| 46 void ScheduleCloseTask(); |
| 47 void OpenTask(); |
| 48 void CloseTask(); |
| 49 void ClosePendingStreams(); |
| 50 |
| 51 AudioManager* audio_manager_; |
| 52 MessageLoop* message_loop_; |
| 53 AudioParameters params_; |
| 54 base::TimeDelta close_delay_; |
| 55 |
| 56 int paused_proxies_; |
| 57 std::vector<AudioOutputStream*> streams_; |
| 58 base::Time last_activity_time_; |
| 59 bool close_task_scheduled_; |
| 60 |
| 61 DISALLOW_COPY_AND_ASSIGN(AudioOutputDispatcher); |
| 62 }; |
| 63 |
| 64 #endif // MEDIA_AUDIO_AUDIO_OUTPUT_DISPATCHER_H_ |
OLD | NEW |