Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(121)

Unified Diff: trunk/src/media/audio/audio_output_dispatcher_impl.h

Issue 38533002: Revert 230334 "Improve and simplify AudioOutputDispatcher." (Closed) Base URL: svn://svn.chromium.org/chrome/
Patch Set: Created 7 years, 2 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: trunk/src/media/audio/audio_output_dispatcher_impl.h
===================================================================
--- trunk/src/media/audio/audio_output_dispatcher_impl.h (revision 230541)
+++ trunk/src/media/audio/audio_output_dispatcher_impl.h (working copy)
@@ -13,11 +13,12 @@
#ifndef MEDIA_AUDIO_AUDIO_OUTPUT_DISPATCHER_IMPL_H_
#define MEDIA_AUDIO_AUDIO_OUTPUT_DISPATCHER_IMPL_H_
+#include <list>
#include <map>
-#include <vector>
#include "base/basictypes.h"
#include "base/memory/ref_counted.h"
+#include "base/memory/weak_ptr.h"
#include "base/timer/timer.h"
#include "media/audio/audio_io.h"
#include "media/audio/audio_manager.h"
@@ -30,8 +31,8 @@
class MEDIA_EXPORT AudioOutputDispatcherImpl : public AudioOutputDispatcher {
public:
- // |close_delay| specifies delay after the stream is idle until the audio
- // device is closed.
+ // |close_delay_ms| specifies delay after the stream is paused until
+ // the audio device is closed.
AudioOutputDispatcherImpl(AudioManager* audio_manager,
const AudioParameters& params,
const std::string& output_device_id,
@@ -59,26 +60,38 @@
virtual void Shutdown() OVERRIDE;
private:
+ typedef std::map<AudioOutputProxy*, AudioOutputStream*> AudioStreamMap;
friend class base::RefCountedThreadSafe<AudioOutputDispatcherImpl>;
virtual ~AudioOutputDispatcherImpl();
+ friend class AudioOutputProxyTest;
+
// Creates a new physical output stream, opens it and pushes to
// |idle_streams_|. Returns false if the stream couldn't be created or
// opened.
bool CreateAndOpenStream();
- // Closes all |idle_streams_|.
- void CloseIdleStreams();
+ // A task scheduled by StartStream(). Opens a new stream and puts
+ // it in |idle_streams_|.
+ void OpenTask();
- size_t idle_proxies_;
- std::vector<AudioOutputStream*> idle_streams_;
+ // Before a stream is reused, it should sit idle for a bit. This task is
+ // called once that time has elapsed.
+ void StopStreamTask();
- // When streams are stopped they're added to |idle_streams_|, if no stream is
- // reused before |close_delay_| elapses |close_timer_| will run
- // CloseIdleStreams().
+ // Called by |close_timer_|. Closes all pending streams.
+ void ClosePendingStreams();
+
+ base::TimeDelta pause_delay_;
+ size_t paused_proxies_;
+ typedef std::list<AudioOutputStream*> AudioOutputStreamList;
+ AudioOutputStreamList idle_streams_;
+ AudioOutputStreamList pausing_streams_;
+
+ // Used to post delayed tasks to ourselves that we cancel inside Shutdown().
+ base::WeakPtrFactory<AudioOutputDispatcherImpl> weak_this_;
base::DelayTimer<AudioOutputDispatcherImpl> close_timer_;
- typedef std::map<AudioOutputProxy*, AudioOutputStream*> AudioStreamMap;
AudioStreamMap proxy_to_physical_map_;
DISALLOW_COPY_AND_ASSIGN(AudioOutputDispatcherImpl);
« no previous file with comments | « trunk/src/media/audio/audio_output_dispatcher.h ('k') | trunk/src/media/audio/audio_output_dispatcher_impl.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698