Chromium Code Reviews| Index: media/audio/audio_output_dispatcher.h |
| diff --git a/media/audio/audio_output_dispatcher.h b/media/audio/audio_output_dispatcher.h |
| new file mode 100644 |
| index 0000000000000000000000000000000000000000..532791d1819d063142c59734da15534f625c6d62 |
| --- /dev/null |
| +++ b/media/audio/audio_output_dispatcher.h |
| @@ -0,0 +1,64 @@ |
| +// Copyright (c) 2010 The Chromium Authors. All rights reserved. |
| +// Use of this source code is governed by a BSD-style license that can be |
| +// found in the LICENSE file. |
| + |
| +#ifndef MEDIA_AUDIO_AUDIO_OUTPUT_DISPATCHER_H_ |
| +#define MEDIA_AUDIO_AUDIO_OUTPUT_DISPATCHER_H_ |
| + |
| +#include <vector> |
| + |
| +#include "base/basictypes.h" |
| +#include "base/ref_counted.h" |
| +#include "base/time.h" |
| +#include "media/audio/audio_manager.h" |
| +#include "media/audio/audio_parameters.h" |
| + |
| +class AudioOutputStream; |
| +class MessageLoop; |
| + |
| +// AudioOutputDispatcher dispatches creation and deletion of audio |
| +// output streams. AudioManagerBase creates one AudioOutputDispatcher |
| +// per each possible set of audio parameters. AudioOutputProxy |
| +// objects use this class to allocate and recycle actual audio output |
| +// streams. |
| +class AudioOutputDispatcher |
| + : public base::RefCountedThreadSafe<AudioOutputDispatcher> { |
| + public: |
| + AudioOutputDispatcher(AudioManager* audio_manager, |
| + const AudioParameters& params); |
| + ~AudioOutputDispatcher(); |
|
scherkus (not reviewing)
2010/11/22 06:43:15
virtual
Sergey Ulanov
2010/11/23 19:51:46
Nobody inherits from this class, and there are no
|
| + |
| + // Following 4 methods are called by AudioOutput when a stream |
|
scherkus (not reviewing)
2010/11/22 06:43:15
Might be wrong here.. but do you meant AudioOutput
Sergey Ulanov
2010/11/23 19:51:46
Done.
|
| + // is opened, started, stopped or closed. |
| + bool StreamOpened(); |
| + AudioOutputStream* StreamStarted(); |
| + void StreamStopped(AudioOutputStream* stream); |
|
scherkus (not reviewing)
2010/11/22 06:43:15
I think we need some comments for these functions
Sergey Ulanov
2010/11/23 19:51:46
Done.
|
| + void StreamClosed(); |
| + |
| + MessageLoop* message_loop(); |
| + |
| + void set_close_delay(base::TimeDelta delay); |
|
scherkus (not reviewing)
2010/11/22 06:43:15
is this only used for tests?
consider using FRIEN
Sergey Ulanov
2010/11/23 19:51:46
Yes.
|
| + |
| + private: |
| + friend class AudioOutputProxyTest; |
| + |
| + AudioOutputStream* CreateAndOpenStream(); |
| + void ScheduleCloseTask(); |
| + void OpenTask(); |
| + void CloseTask(); |
| + void ClosePendingStreams(); |
| + |
| + AudioManager* audio_manager_; |
| + MessageLoop* message_loop_; |
| + AudioParameters params_; |
| + base::TimeDelta close_delay_; |
| + |
| + int paused_proxies_; |
| + std::vector<AudioOutputStream*> streams_; |
| + base::Time last_activity_time_; |
|
scherkus (not reviewing)
2010/11/22 06:43:15
I think you can replace a bunch of this last_activ
Sergey Ulanov
2010/11/23 19:51:46
Wow, that is fantastic. I didn't know about it. Ye
|
| + bool close_task_scheduled_; |
| + |
| + DISALLOW_COPY_AND_ASSIGN(AudioOutputDispatcher); |
| +}; |
| + |
| +#endif // MEDIA_AUDIO_AUDIO_OUTPUT_DISPATCHER_H_ |