OLD | NEW |
---|---|
(Empty) | |
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. | |
4 | |
5 #ifndef MEDIA_AUDIO_VIRTUAL_AUDIO_OUTPUT_STREAM_H_ | |
6 #define MEDIA_AUDIO_VIRTUAL_AUDIO_OUTPUT_STREAM_H_ | |
7 | |
8 #include "media/audio/audio_io.h" | |
9 #include "media/audio/audio_parameters.h" | |
10 #include "media/base/audio_converter.h" | |
11 | |
12 namespace media { | |
13 | |
14 class AudioManagerBase; | |
15 class VirtualAudioInputStream; | |
16 | |
17 // VirtualAudioOutputStream attaches to a VirtualAudioInputStream when Start() | |
18 // is called and is used as an audio source. VirtualAudioOutputStream also | |
19 // implements an interface so it can be used as an input to AudioConverter so | |
20 // that we can get audio frames that match the AudioParameters that | |
21 // VirtualAudioInputStream expects. | |
22 class MEDIA_EXPORT VirtualAudioOutputStream | |
23 : public AudioOutputStream, | |
24 public AudioConverter::InputCallback { | |
25 public: | |
26 static VirtualAudioOutputStream* MakeStream(AudioManagerBase* manager, | |
27 const AudioParameters& params, | |
28 VirtualAudioInputStream* target); | |
29 | |
30 virtual ~VirtualAudioOutputStream(); | |
31 | |
32 // AudioOutputStream: | |
33 virtual bool Open() OVERRIDE; | |
34 virtual void Start(AudioSourceCallback* callback) OVERRIDE; | |
35 virtual void Stop() OVERRIDE; | |
36 virtual void SetVolume(double volume) OVERRIDE; | |
37 virtual void GetVolume(double* volume) OVERRIDE; | |
38 virtual void Close() OVERRIDE; | |
39 | |
40 protected: | |
41 VirtualAudioOutputStream(AudioManagerBase* manager, | |
42 const AudioParameters& params, | |
43 VirtualAudioInputStream* target); | |
44 | |
45 private: | |
46 // AudioConverter::InputCallback: | |
47 virtual double ProvideInput(AudioBus* audio_bus, | |
48 base::TimeDelta buffer_delay) OVERRIDE; | |
49 | |
50 // Helper method to make sure methods are called on the audio thread. This is | |
51 // overridden by tests. | |
52 virtual bool CalledOnAudioThread(); | |
DaleCurtis
2012/12/03 19:27:28
Same comments as the other class.
justinlin
2012/12/03 21:18:42
Done.
| |
53 | |
54 AudioManagerBase* audio_manager_; | |
55 AudioSourceCallback* callback_; | |
56 AudioParameters params_; | |
57 | |
58 // Pointer to the VirtualAudioInputStream to attach to when Start() is called. | |
59 // This pointer should always be valid because VirtualAudioInputStream should | |
60 // outlive this class. | |
61 VirtualAudioInputStream* target_input_stream_; | |
62 float volume_; | |
63 bool attached_; | |
64 | |
65 DISALLOW_COPY_AND_ASSIGN(VirtualAudioOutputStream); | |
66 }; | |
67 | |
68 } // namespace media | |
69 | |
70 #endif // MEDIA_AUDIO_VIRTUAL_AUDIO_OUTPUT_STREAM_H_ | |
OLD | NEW |