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_
12 #include "base/basictypes.h"
13 #include "base/compiler_specific.h"
14 #include "base/memory/ref_counted.h"
15 #include "base/threading/non_thread_safe.h"
16 #include "media/audio/audio_io.h"
17 #include "media/audio/audio_parameters.h"
21 class AudioOutputDispatcher;
23 // AudioOutputProxy is an audio otput stream that uses resources more
24 // efficiently than a regular audio output stream: it opens audio
25 // device only when sound is playing, i.e. between Start() and Stop()
26 // (there is still one physical stream per each audio output proxy in
29 // AudioOutputProxy uses AudioOutputDispatcher to open and close
30 // physical output streams.
31 class MEDIA_EXPORT AudioOutputProxy
32 : public AudioOutputStream,
33 public NON_EXPORTED_BASE(base::NonThreadSafe) {
35 // Caller keeps ownership of |dispatcher|.
36 explicit AudioOutputProxy(AudioOutputDispatcher* dispatcher);
38 // AudioOutputStream interface.
40 void Start(AudioSourceCallback* callback) override;
42 void SetVolume(double volume) override;
43 void GetVolume(double* volume) override;
44 void Close() override;
47 void SetMediaStreamProperties(const std::string& app_id,
48 const std::string& app_class) override;
61 ~AudioOutputProxy() override;
63 scoped_refptr<AudioOutputDispatcher> dispatcher_;
66 // Need to save volume here, so that we can restore it in case the stream
67 // is stopped, and then started again.
70 DISALLOW_COPY_AND_ASSIGN(AudioOutputProxy);
75 #endif // MEDIA_AUDIO_AUDIO_OUTPUT_PROXY_H_