| OLD | NEW |
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 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 | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #ifndef MEDIA_AUDIO_AUDIO_OUTPUT_PROXY_H_ | 5 #ifndef MEDIA_AUDIO_AUDIO_OUTPUT_PROXY_H_ |
| 6 #define MEDIA_AUDIO_AUDIO_OUTPUT_PROXY_H_ | 6 #define MEDIA_AUDIO_AUDIO_OUTPUT_PROXY_H_ |
| 7 | 7 |
| 8 #include "base/compiler_specific.h" | 8 #include "base/compiler_specific.h" |
| 9 #include "base/macros.h" | 9 #include "base/macros.h" |
| 10 #include "base/memory/weak_ptr.h" | 10 #include "base/memory/weak_ptr.h" |
| 11 #include "base/threading/non_thread_safe.h" | 11 #include "base/sequence_checker.h" |
| 12 #include "media/audio/audio_io.h" | 12 #include "media/audio/audio_io.h" |
| 13 #include "media/base/audio_parameters.h" | 13 #include "media/base/audio_parameters.h" |
| 14 | 14 |
| 15 namespace media { | 15 namespace media { |
| 16 | 16 |
| 17 class AudioOutputDispatcher; | 17 class AudioOutputDispatcher; |
| 18 | 18 |
| 19 // AudioOutputProxy is an audio otput stream that uses resources more | 19 // AudioOutputProxy is an audio otput stream that uses resources more |
| 20 // efficiently than a regular audio output stream: it opens audio | 20 // efficiently than a regular audio output stream: it opens audio |
| 21 // device only when sound is playing, i.e. between Start() and Stop() | 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 | 22 // (there is still one physical stream per each audio output proxy in |
| 23 // playing state). | 23 // playing state). |
| 24 // | 24 // |
| 25 // AudioOutputProxy uses AudioOutputDispatcher to open and close | 25 // AudioOutputProxy uses AudioOutputDispatcher to open and close |
| 26 // physical output streams. | 26 // physical output streams. |
| 27 class MEDIA_EXPORT AudioOutputProxy | 27 class MEDIA_EXPORT AudioOutputProxy : public AudioOutputStream { |
| 28 : public AudioOutputStream, | |
| 29 public NON_EXPORTED_BASE(base::NonThreadSafe) { | |
| 30 public: | 28 public: |
| 31 // Caller keeps ownership of |dispatcher|. | 29 // Caller keeps ownership of |dispatcher|. |
| 32 explicit AudioOutputProxy(base::WeakPtr<AudioOutputDispatcher> dispatcher); | 30 explicit AudioOutputProxy(base::WeakPtr<AudioOutputDispatcher> dispatcher); |
| 33 | 31 |
| 34 // AudioOutputStream interface. | 32 // AudioOutputStream interface. |
| 35 bool Open() override; | 33 bool Open() override; |
| 36 void Start(AudioSourceCallback* callback) override; | 34 void Start(AudioSourceCallback* callback) override; |
| 37 void Stop() override; | 35 void Stop() override; |
| 38 void SetVolume(double volume) override; | 36 void SetVolume(double volume) override; |
| 39 void GetVolume(double* volume) override; | 37 void GetVolume(double* volume) override; |
| (...skipping 15 matching lines...) Expand all Loading... |
| 55 | 53 |
| 56 ~AudioOutputProxy() override; | 54 ~AudioOutputProxy() override; |
| 57 | 55 |
| 58 base::WeakPtr<AudioOutputDispatcher> dispatcher_; | 56 base::WeakPtr<AudioOutputDispatcher> dispatcher_; |
| 59 State state_; | 57 State state_; |
| 60 | 58 |
| 61 // Need to save volume here, so that we can restore it in case the stream | 59 // Need to save volume here, so that we can restore it in case the stream |
| 62 // is stopped, and then started again. | 60 // is stopped, and then started again. |
| 63 double volume_; | 61 double volume_; |
| 64 | 62 |
| 63 SEQUENCE_CHECKER(sequence_checker_); |
| 64 |
| 65 DISALLOW_COPY_AND_ASSIGN(AudioOutputProxy); | 65 DISALLOW_COPY_AND_ASSIGN(AudioOutputProxy); |
| 66 }; | 66 }; |
| 67 | 67 |
| 68 } // namespace media | 68 } // namespace media |
| 69 | 69 |
| 70 #endif // MEDIA_AUDIO_AUDIO_OUTPUT_PROXY_H_ | 70 #endif // MEDIA_AUDIO_AUDIO_OUTPUT_PROXY_H_ |
| OLD | NEW |