Report errors from ChromiumEnv::GetChildren in Posix.
[chromium-blink-merge.git] / media / audio / audio_output_proxy.h
blob86dab513aa5bf2fda85c0724958a12767c193b61
1 // Copyright (c) 2012 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/compiler_specific.h"
10 #include "base/memory/ref_counted.h"
11 #include "base/threading/non_thread_safe.h"
12 #include "media/audio/audio_io.h"
13 #include "media/audio/audio_parameters.h"
15 namespace media {
17 class AudioOutputDispatcher;
19 // AudioOutputProxy is an audio otput stream that uses resources more
20 // efficiently than a regular audio output stream: it opens audio
21 // device only when sound is playing, i.e. between Start() and Stop()
22 // (there is still one physical stream per each audio output proxy in
23 // playing state).
25 // AudioOutputProxy uses AudioOutputDispatcher to open and close
26 // physical output streams.
27 class MEDIA_EXPORT AudioOutputProxy
28 : public AudioOutputStream,
29 public NON_EXPORTED_BASE(base::NonThreadSafe) {
30 public:
31 // Caller keeps ownership of |dispatcher|.
32 explicit AudioOutputProxy(AudioOutputDispatcher* dispatcher);
34 // AudioOutputStream interface.
35 virtual bool Open() OVERRIDE;
36 virtual void Start(AudioSourceCallback* callback) OVERRIDE;
37 virtual void Stop() OVERRIDE;
38 virtual void SetVolume(double volume) OVERRIDE;
39 virtual void GetVolume(double* volume) OVERRIDE;
40 virtual void Close() OVERRIDE;
42 private:
43 enum State {
44 kCreated,
45 kOpened,
46 kPlaying,
47 kClosed,
48 kOpenError,
49 kStartError,
52 virtual ~AudioOutputProxy();
54 scoped_refptr<AudioOutputDispatcher> dispatcher_;
55 State state_;
57 // Need to save volume here, so that we can restore it in case the stream
58 // is stopped, and then started again.
59 double volume_;
61 DISALLOW_COPY_AND_ASSIGN(AudioOutputProxy);
64 } // namespace media
66 #endif // MEDIA_AUDIO_AUDIO_OUTPUT_PROXY_H_