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
3 // found in the LICENSE file.
5 #ifndef MEDIA_AUDIO_AUDIO_OUTPUT_PROXY_H_
6 #define MEDIA_AUDIO_AUDIO_OUTPUT_PROXY_H_
8 #include "base/basictypes.h"
10 #include "media/audio/audio_io.h"
11 #include "media/audio/audio_parameters.h"
13 class AudioOutputDispatcher
;
15 // AudioOutputProxy is an audio otput stream that uses resources more
16 // efficiently than a regular audio output stream: it opens audio
17 // device only when sound is playing, i.e. between Start() and Stop()
18 // (there is still one physical stream per each audio output proxy in
21 // AudioOutputProxy uses AudioOutputDispatcher to open and close
22 // physical output streams.
23 class MEDIA_EXPORT AudioOutputProxy
: public AudioOutputStream
{
25 // Caller keeps ownership of |dispatcher|.
26 explicit AudioOutputProxy(AudioOutputDispatcher
* dispatcher
);
28 // AudioOutputStream interface.
29 virtual bool Open() OVERRIDE
;
30 virtual void Start(AudioSourceCallback
* callback
) OVERRIDE
;
31 virtual void Stop() OVERRIDE
;
32 virtual void SetVolume(double volume
) OVERRIDE
;
33 virtual void GetVolume(double* volume
) OVERRIDE
;
34 virtual void Close() OVERRIDE
;
45 virtual ~AudioOutputProxy();
47 scoped_refptr
<AudioOutputDispatcher
> dispatcher_
;
50 // The actual audio stream. Must be set to NULL in any state other
52 AudioOutputStream
* physical_stream_
;
54 // Need to save volume here, so that we can restore it in case the stream
55 // is stopped, and then started again.
58 DISALLOW_COPY_AND_ASSIGN(AudioOutputProxy
);
61 #endif // MEDIA_AUDIO_AUDIO_OUTPUT_PROXY_H_