OLD | NEW |
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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 #include "base/environment.h" | 5 #include "base/environment.h" |
6 #include "base/test/test_timeouts.h" | 6 #include "base/test/test_timeouts.h" |
7 #include "content/renderer/media/audio_hardware.h" | 7 #include "content/renderer/media/audio_hardware.h" |
8 #include "content/renderer/media/webrtc_audio_device_impl.h" | 8 #include "content/renderer/media/webrtc_audio_device_impl.h" |
9 #include "content/test/webrtc_audio_device_test.h" | 9 #include "content/test/webrtc_audio_device_test.h" |
10 #include "media/audio/audio_manager.h" | 10 #include "media/audio/audio_manager.h" |
(...skipping 89 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
100 } | 100 } |
101 virtual ~WebRTCMediaProcessImpl() {} | 101 virtual ~WebRTCMediaProcessImpl() {} |
102 | 102 |
103 // TODO(henrika): Refactor in WebRTC and convert to Chrome coding style. | 103 // TODO(henrika): Refactor in WebRTC and convert to Chrome coding style. |
104 virtual void Process(const int channel, | 104 virtual void Process(const int channel, |
105 const webrtc::ProcessingTypes type, | 105 const webrtc::ProcessingTypes type, |
106 WebRtc_Word16 audio_10ms[], | 106 WebRtc_Word16 audio_10ms[], |
107 const int length, | 107 const int length, |
108 const int sampling_freq, | 108 const int sampling_freq, |
109 const bool is_stereo) { | 109 const bool is_stereo) { |
| 110 base::AutoLock auto_lock(lock_); |
110 channel_id_ = channel; | 111 channel_id_ = channel; |
111 type_ = type; | 112 type_ = type; |
112 packet_size_ = length; | 113 packet_size_ = length; |
113 sample_rate_ = sampling_freq; | 114 sample_rate_ = sampling_freq; |
114 channels_ = (is_stereo ? 2 : 1); | 115 channels_ = (is_stereo ? 2 : 1); |
115 if (event_) { | 116 if (event_) { |
116 // Signal that a new callback has been received. | 117 // Signal that a new callback has been received. |
117 event_->Signal(); | 118 event_->Signal(); |
118 } | 119 } |
119 } | 120 } |
120 | 121 |
121 int channel_id() const { return channel_id_; } | 122 int channel_id() const { |
122 int type() const { return type_; } | 123 base::AutoLock auto_lock(lock_); |
123 int packet_size() const { return packet_size_; } | 124 return channel_id_; |
124 int sample_rate() const { return sample_rate_; } | 125 } |
125 int channels() const { return channels_; } | 126 |
| 127 int type() const { |
| 128 base::AutoLock auto_lock(lock_); |
| 129 return type_; |
| 130 } |
| 131 |
| 132 int packet_size() const { |
| 133 base::AutoLock auto_lock(lock_); |
| 134 return packet_size_; |
| 135 } |
| 136 |
| 137 int sample_rate() const { |
| 138 base::AutoLock auto_lock(lock_); |
| 139 return sample_rate_; |
| 140 } |
| 141 |
| 142 int channels() const { |
| 143 base::AutoLock auto_lock(lock_); |
| 144 return channels_; |
| 145 } |
126 | 146 |
127 private: | 147 private: |
128 base::WaitableEvent* event_; | 148 base::WaitableEvent* event_; |
129 int channel_id_; | 149 int channel_id_; |
130 webrtc::ProcessingTypes type_; | 150 webrtc::ProcessingTypes type_; |
131 int packet_size_; | 151 int packet_size_; |
132 int sample_rate_; | 152 int sample_rate_; |
133 int channels_; | 153 int channels_; |
| 154 mutable base::Lock lock_; |
134 DISALLOW_COPY_AND_ASSIGN(WebRTCMediaProcessImpl); | 155 DISALLOW_COPY_AND_ASSIGN(WebRTCMediaProcessImpl); |
135 }; | 156 }; |
136 | 157 |
137 } // end namespace | 158 } // end namespace |
138 | 159 |
139 // Utility class to delete the AudioManager. | 160 // Utility class to delete the AudioManager. |
140 // TODO(tommi): Remove when we've fixed issue 105249. | 161 // TODO(tommi): Remove when we've fixed issue 105249. |
141 class AutoAudioManagerCleanup { | 162 class AutoAudioManagerCleanup { |
142 public: | 163 public: |
143 AutoAudioManagerCleanup() { | 164 AutoAudioManagerCleanup() { |
(...skipping 301 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
445 new MessageLoop::QuitTask(), | 466 new MessageLoop::QuitTask(), |
446 TestTimeouts::action_timeout_ms()); | 467 TestTimeouts::action_timeout_ms()); |
447 message_loop_.Run(); | 468 message_loop_.Run(); |
448 | 469 |
449 EXPECT_EQ(0, base->StopSend(ch)); | 470 EXPECT_EQ(0, base->StopSend(ch)); |
450 EXPECT_EQ(0, base->StopPlayout(ch)); | 471 EXPECT_EQ(0, base->StopPlayout(ch)); |
451 | 472 |
452 EXPECT_EQ(0, base->DeleteChannel(ch)); | 473 EXPECT_EQ(0, base->DeleteChannel(ch)); |
453 EXPECT_EQ(0, base->Terminate()); | 474 EXPECT_EQ(0, base->Terminate()); |
454 } | 475 } |
OLD | NEW |