Delete unused downloads page asset.
[chromium-blink-merge.git] / media / audio / virtual_audio_output_stream.h
blobef9863e1441d3a19f569083579b1c7d8c226fd50
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_VIRTUAL_AUDIO_OUTPUT_STREAM_H_
6 #define MEDIA_AUDIO_VIRTUAL_AUDIO_OUTPUT_STREAM_H_
8 #include "base/callback.h"
9 #include "base/threading/thread_checker.h"
10 #include "media/audio/audio_io.h"
11 #include "media/audio/audio_parameters.h"
12 #include "media/base/audio_converter.h"
14 namespace media {
16 class VirtualAudioInputStream;
18 // VirtualAudioOutputStream attaches to a VirtualAudioInputStream when Start()
19 // is called and is used as an audio source. VirtualAudioOutputStream also
20 // implements an interface so it can be used as an input to AudioConverter so
21 // that we can get audio frames that match the AudioParameters that
22 // VirtualAudioInputStream expects.
23 class MEDIA_EXPORT VirtualAudioOutputStream
24 : public AudioOutputStream,
25 public AudioConverter::InputCallback {
26 public:
27 // Callback invoked just after VirtualAudioOutputStream is closed.
28 typedef base::Callback<void(VirtualAudioOutputStream* vaos)>
29 AfterCloseCallback;
31 // Construct an audio loopback pathway to the given |target| (not owned).
32 // |target| must outlive this instance.
33 VirtualAudioOutputStream(const AudioParameters& params,
34 VirtualAudioInputStream* target,
35 const AfterCloseCallback& after_close_cb);
37 ~VirtualAudioOutputStream() override;
39 // AudioOutputStream:
40 bool Open() override;
41 void Start(AudioSourceCallback* callback) override;
42 void Stop() override;
43 void SetVolume(double volume) override;
44 void GetVolume(double* volume) override;
45 void Close() override;
47 private:
48 // AudioConverter::InputCallback:
49 double ProvideInput(AudioBus* audio_bus,
50 base::TimeDelta buffer_delay) override;
52 const AudioParameters params_;
53 // Pointer to the VirtualAudioInputStream to attach to when Start() is called.
54 // This pointer should always be valid because VirtualAudioInputStream should
55 // outlive this class.
56 VirtualAudioInputStream* const target_input_stream_;
58 AfterCloseCallback after_close_cb_;
60 AudioSourceCallback* callback_;
61 double volume_;
63 base::ThreadChecker thread_checker_;
65 DISALLOW_COPY_AND_ASSIGN(VirtualAudioOutputStream);
68 } // namespace media
70 #endif // MEDIA_AUDIO_VIRTUAL_AUDIO_OUTPUT_STREAM_H_