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

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

Issue 922663002: Moved the fake input stream's processing onto the audio worker thread. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Rebase Created 5 years, 10 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
« no previous file with comments | « media/audio/simple_sources.cc ('k') | media/audio/virtual_audio_input_stream.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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_VIRTUAL_AUDIO_INPUT_STREAM_H_ 5 #ifndef MEDIA_AUDIO_VIRTUAL_AUDIO_INPUT_STREAM_H_
6 #define MEDIA_AUDIO_VIRTUAL_AUDIO_INPUT_STREAM_H_ 6 #define MEDIA_AUDIO_VIRTUAL_AUDIO_INPUT_STREAM_H_
7 7
8 #include <map> 8 #include <map>
9 #include <set> 9 #include <set>
10 10
11 #include "base/gtest_prod_util.h" 11 #include "base/gtest_prod_util.h"
12 #include "base/memory/scoped_ptr.h" 12 #include "base/memory/scoped_ptr.h"
13 #include "base/synchronization/lock.h" 13 #include "base/synchronization/lock.h"
14 #include "base/threading/thread_checker.h" 14 #include "base/threading/thread_checker.h"
15 #include "media/audio/audio_io.h" 15 #include "media/audio/audio_io.h"
16 #include "media/audio/audio_parameters.h" 16 #include "media/audio/audio_parameters.h"
17 #include "media/audio/fake_audio_consumer.h" 17 #include "media/audio/fake_audio_worker.h"
18 #include "media/base/audio_converter.h" 18 #include "media/base/audio_converter.h"
19 19
20 namespace base { 20 namespace base {
21 class SingleThreadTaskRunner; 21 class SingleThreadTaskRunner;
22 } 22 }
23 23
24 namespace media { 24 namespace media {
25 25
26 class LoopbackAudioConverter; 26 class LoopbackAudioConverter;
27 class VirtualAudioOutputStream; 27 class VirtualAudioOutputStream;
(...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after
70 const AudioParameters& output_params); 70 const AudioParameters& output_params);
71 71
72 private: 72 private:
73 friend class VirtualAudioInputStreamTest; 73 friend class VirtualAudioInputStreamTest;
74 74
75 typedef std::map<AudioParameters, LoopbackAudioConverter*> AudioConvertersMap; 75 typedef std::map<AudioParameters, LoopbackAudioConverter*> AudioConvertersMap;
76 76
77 // Pulls audio data from all attached VirtualAudioOutputStreams, mixes and 77 // Pulls audio data from all attached VirtualAudioOutputStreams, mixes and
78 // converts the streams into one, and pushes the result to |callback_|. 78 // converts the streams into one, and pushes the result to |callback_|.
79 // Invoked on the worker thread. 79 // Invoked on the worker thread.
80 void PumpAudio(AudioBus* audio_bus); 80 void PumpAudio();
81 81
82 const scoped_refptr<base::SingleThreadTaskRunner> worker_task_runner_; 82 const scoped_refptr<base::SingleThreadTaskRunner> worker_task_runner_;
83 83
84 AfterCloseCallback after_close_cb_; 84 AfterCloseCallback after_close_cb_;
85 85
86 AudioInputCallback* callback_; 86 AudioInputCallback* callback_;
87 87
88 // Non-const for testing. 88 // Non-const for testing.
89 scoped_ptr<uint8[]> buffer_; 89 scoped_ptr<uint8[]> buffer_;
90 AudioParameters params_; 90 AudioParameters params_;
91 91
92 // Guards concurrent access to the converter network: converters_, mixer_, and 92 // Guards concurrent access to the converter network: converters_, mixer_, and
93 // num_attached_output_streams_. 93 // num_attached_output_streams_.
94 base::Lock converter_network_lock_; 94 base::Lock converter_network_lock_;
95 95
96 // AudioConverters associated with the attached VirtualAudioOutputStreams, 96 // AudioConverters associated with the attached VirtualAudioOutputStreams,
97 // partitioned by common AudioParameters. 97 // partitioned by common AudioParameters.
98 AudioConvertersMap converters_; 98 AudioConvertersMap converters_;
99 99
100 // AudioConverter that takes all the audio converters and mixes them into one 100 // AudioConverter that takes all the audio converters and mixes them into one
101 // final audio stream. 101 // final audio stream.
102 AudioConverter mixer_; 102 AudioConverter mixer_;
103 103
104 // Number of currently attached VirtualAudioOutputStreams. 104 // Number of currently attached VirtualAudioOutputStreams.
105 int num_attached_output_streams_; 105 int num_attached_output_streams_;
106 106
107 // Handles callback timing for consumption of audio data. 107 // Handles callback timing for consumption of audio data.
108 FakeAudioConsumer fake_consumer_; 108 FakeAudioWorker fake_worker_;
109
110 scoped_ptr<AudioBus> audio_bus_;
109 111
110 base::ThreadChecker thread_checker_; 112 base::ThreadChecker thread_checker_;
111 113
112 DISALLOW_COPY_AND_ASSIGN(VirtualAudioInputStream); 114 DISALLOW_COPY_AND_ASSIGN(VirtualAudioInputStream);
113 }; 115 };
114 116
115 } // namespace media 117 } // namespace media
116 118
117 #endif // MEDIA_AUDIO_VIRTUAL_AUDIO_INPUT_STREAM_H_ 119 #endif // MEDIA_AUDIO_VIRTUAL_AUDIO_INPUT_STREAM_H_
OLDNEW
« no previous file with comments | « media/audio/simple_sources.cc ('k') | media/audio/virtual_audio_input_stream.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698