OLD | NEW |
(Empty) | |
| 1 // Copyright (c) 2010 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. |
| 4 |
| 5 #ifndef MEDIA_AUDIO_AUDIO_OUTPUT_STREAM_PROXY_H_ |
| 6 #define MEDIA_AUDIO_AUDIO_OUTPUT_STREAM_PROXY_H_ |
| 7 |
| 8 #include "base/basictypes.h" |
| 9 #include "base/task.h" |
| 10 #include "media/audio/audio_io.h" |
| 11 #include "media/audio/audio_parameters.h" |
| 12 |
| 13 class AudioOutputDispatcher; |
| 14 |
| 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). |
| 20 // |
| 21 // AudioOutputProxy uses AudioOutputDispatcher to open and close |
| 22 // physical output streams. |
| 23 class AudioOutputProxy : public AudioOutputStream { |
| 24 public: |
| 25 // Caller keeps ownership of |dispatcher|. |
| 26 AudioOutputProxy(AudioOutputDispatcher* dispatcher); |
| 27 |
| 28 // AudioOutputStream interface. |
| 29 virtual bool Open(); |
| 30 virtual void Start(AudioSourceCallback* callback); |
| 31 virtual void Stop(); |
| 32 virtual void SetVolume(double volume); |
| 33 virtual void GetVolume(double* volume); |
| 34 virtual void Close(); |
| 35 |
| 36 private: |
| 37 // Needs to access destructor. |
| 38 friend class DeleteTask<AudioOutputProxy>; |
| 39 |
| 40 enum State { |
| 41 kCreated, |
| 42 kOpened, |
| 43 kPlaying, |
| 44 kClosed, |
| 45 kError, |
| 46 }; |
| 47 |
| 48 virtual ~AudioOutputProxy(); |
| 49 |
| 50 scoped_refptr<AudioOutputDispatcher> dispatcher_; |
| 51 State state_; |
| 52 |
| 53 // The actual audio stream. Must be set to NULL in any state other |
| 54 // than kPlaying. |
| 55 AudioOutputStream* physical_stream_; |
| 56 |
| 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_; |
| 60 |
| 61 DISALLOW_COPY_AND_ASSIGN(AudioOutputProxy); |
| 62 }; |
| 63 |
| 64 #endif // MEDIA_AUDIO_AUDIO_OUTPUT_STREAM_PROXY_H_ |
OLD | NEW |