srpcgen: Use 'const char*' for string parameters
[chromium-blink-merge.git] / media / audio / audio_output_proxy.h
blob064771d1b25c82e86e3d17949c2fedc6f993d2e8
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"
9 #include "base/task.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
19 // playing state).
21 // AudioOutputProxy uses AudioOutputDispatcher to open and close
22 // physical output streams.
23 class MEDIA_EXPORT AudioOutputProxy : public AudioOutputStream {
24 public:
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;
36 private:
37 enum State {
38 kCreated,
39 kOpened,
40 kPlaying,
41 kClosed,
42 kError,
45 virtual ~AudioOutputProxy();
47 scoped_refptr<AudioOutputDispatcher> dispatcher_;
48 State state_;
50 // The actual audio stream. Must be set to NULL in any state other
51 // than kPlaying.
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.
56 double volume_;
58 DISALLOW_COPY_AND_ASSIGN(AudioOutputProxy);
61 #endif // MEDIA_AUDIO_AUDIO_OUTPUT_PROXY_H_