Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(486)

Side by Side Diff: media/audio/virtual_audio_sink.h

Issue 1897953003: Unmute Tab Audio For Desktop Share (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Resolving Comments Created 4 years, 7 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
(Empty)
1 // Copyright 2016 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_SINK_H_
6 #define MEDIA_AUDIO_VIRTUAL_AUDIO_SINK_H_
7
8 #include "base/callback.h"
9 #include "base/macros.h"
10 #include "base/memory/weak_ptr.h"
11 #include "media/audio/audio_io.h"
12 #include "media/audio/audio_source_diverter.h"
13 #include "media/base/audio_converter.h"
14 #include "media/base/audio_shifter.h"
15
16 namespace base {
17 class SingleThreadTaskRunner;
18 }
19
20 namespace media {
21
22 class VirtualAudioInputStream;
23
24 // This class is an adapter between push model and pull model for audio stream.
25 // Audio provider calls OnData() to push audio data into this class.
26 // Audio consumer calls ProvideInput() to pull audio data.
27 class MEDIA_EXPORT VirtualAudioSink
28 : public AudioPushSink,
29 public AudioConverter::InputCallback,
30 public base::SupportsWeakPtr<VirtualAudioSink> {
31 public:
32 typedef base::Callback<void(VirtualAudioSink* sink)> AfterCloseCallback;
33
34 // Construct an audio loopback pathway to the given |target| (not owned).
35 // |target| must outlive this instance.
36 VirtualAudioSink(AudioParameters param,
37 VirtualAudioInputStream* target,
38 AfterCloseCallback callback);
39 ~VirtualAudioSink() override;
40
41 // AudioPushSink
42 void Close() override;
43 void OnData(const AudioBus& source, base::TimeTicks reference_time) override;
44
45 // AudioConverter::InputCallback
46 double ProvideInput(AudioBus* audio_bus,
47 base::TimeDelta buffer_delay) override;
48
49 private:
50 void StoreData(AudioBus* source, base::TimeTicks reference_time);
51
52 const AudioParameters params_;
53 VirtualAudioInputStream* const target_;
54 AudioShifter shifter_;
55 scoped_refptr<base::SingleThreadTaskRunner> task_runner_;
56 AfterCloseCallback after_close_callback_;
57 };
58
59 } // namespace media
60
61 #endif // MEDIA_AUDIO_VIRTUAL_AUDIO_SINK_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698