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

Side by Side Diff: content/renderer/media/webrtc_audio_device_unittest.cc

Issue 8799011: remove the race related to output_delay_ms_ in ADM and races in the unittests. (Closed) Base URL: http://src.chromium.org/svn/trunk/src/
Patch Set: '' Created 9 years 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 | Annotate | Revision Log
OLDNEW
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
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_; }
scherkus (not reviewing) 2011/12/08 23:49:42 drive by nit: drop } to next line here + below
no longer working on chromium 2011/12/09 09:48:19 Done.
124 int sample_rate() const { return sample_rate_; } 125 int type() const {
125 int channels() const { return channels_; } 126 base::AutoLock auto_lock(lock_);
127 return type_; }
128 int packet_size() const {
129 base::AutoLock auto_lock(lock_);
130 return packet_size_; }
131 int sample_rate() const {
132 base::AutoLock auto_lock(lock_);
133 return sample_rate_; }
134 int channels() const {
135 base::AutoLock auto_lock(lock_);
136 return channels_; }
126 137
127 private: 138 private:
128 base::WaitableEvent* event_; 139 base::WaitableEvent* event_;
129 int channel_id_; 140 int channel_id_;
130 webrtc::ProcessingTypes type_; 141 webrtc::ProcessingTypes type_;
131 int packet_size_; 142 int packet_size_;
132 int sample_rate_; 143 int sample_rate_;
133 int channels_; 144 int channels_;
145 mutable base::Lock lock_;
134 DISALLOW_COPY_AND_ASSIGN(WebRTCMediaProcessImpl); 146 DISALLOW_COPY_AND_ASSIGN(WebRTCMediaProcessImpl);
135 }; 147 };
136 148
137 } // end namespace 149 } // end namespace
138 150
139 // Utility class to delete the AudioManager. 151 // Utility class to delete the AudioManager.
140 // TODO(tommi): Remove when we've fixed issue 105249. 152 // TODO(tommi): Remove when we've fixed issue 105249.
141 class AutoAudioManagerCleanup { 153 class AutoAudioManagerCleanup {
142 public: 154 public:
143 AutoAudioManagerCleanup() { 155 AutoAudioManagerCleanup() {
(...skipping 301 matching lines...) Expand 10 before | Expand all | Expand 10 after
445 new MessageLoop::QuitTask(), 457 new MessageLoop::QuitTask(),
446 TestTimeouts::action_timeout_ms()); 458 TestTimeouts::action_timeout_ms());
447 message_loop_.Run(); 459 message_loop_.Run();
448 460
449 EXPECT_EQ(0, base->StopSend(ch)); 461 EXPECT_EQ(0, base->StopSend(ch));
450 EXPECT_EQ(0, base->StopPlayout(ch)); 462 EXPECT_EQ(0, base->StopPlayout(ch));
451 463
452 EXPECT_EQ(0, base->DeleteChannel(ch)); 464 EXPECT_EQ(0, base->DeleteChannel(ch));
453 EXPECT_EQ(0, base->Terminate()); 465 EXPECT_EQ(0, base->Terminate());
454 } 466 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698