OLD | NEW |
1 /* | 1 /* |
2 * Copyright (c) 2013 The WebRTC project authors. All Rights Reserved. | 2 * Copyright (c) 2013 The WebRTC project authors. All Rights Reserved. |
3 * | 3 * |
4 * Use of this source code is governed by a BSD-style license | 4 * Use of this source code is governed by a BSD-style license |
5 * that can be found in the LICENSE file in the root of the source | 5 * that can be found in the LICENSE file in the root of the source |
6 * tree. An additional intellectual property rights grant can be found | 6 * tree. An additional intellectual property rights grant can be found |
7 * in the file PATENTS. All contributing project authors may | 7 * in the file PATENTS. All contributing project authors may |
8 * be found in the AUTHORS file in the root of the source tree. | 8 * be found in the AUTHORS file in the root of the source tree. |
9 */ | 9 */ |
10 | 10 |
(...skipping 81 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
92 } | 92 } |
93 | 93 |
94 void FakeAudioDevice::CaptureAudio() { | 94 void FakeAudioDevice::CaptureAudio() { |
95 { | 95 { |
96 rtc::CritScope cs(&lock_); | 96 rtc::CritScope cs(&lock_); |
97 if (capturing_) { | 97 if (capturing_) { |
98 int bytes_read = file_utility_->ReadPCMData( | 98 int bytes_read = file_utility_->ReadPCMData( |
99 *input_stream_.get(), captured_audio_, kBufferSizeBytes); | 99 *input_stream_.get(), captured_audio_, kBufferSizeBytes); |
100 if (bytes_read <= 0) | 100 if (bytes_read <= 0) |
101 return; | 101 return; |
102 int num_samples = bytes_read / 2; // 2 bytes per sample. | 102 // 2 bytes per sample. |
| 103 size_t num_samples = static_cast<size_t>(bytes_read / 2); |
103 uint32_t new_mic_level; | 104 uint32_t new_mic_level; |
104 EXPECT_EQ(0, | 105 EXPECT_EQ(0, |
105 audio_callback_->RecordedDataIsAvailable(captured_audio_, | 106 audio_callback_->RecordedDataIsAvailable(captured_audio_, |
106 num_samples, | 107 num_samples, |
107 2, | 108 2, |
108 1, | 109 1, |
109 kFrequencyHz, | 110 kFrequencyHz, |
110 0, | 111 0, |
111 0, | 112 0, |
112 0, | 113 0, |
113 false, | 114 false, |
114 new_mic_level)); | 115 new_mic_level)); |
115 uint32_t samples_needed = kFrequencyHz / 100; | 116 size_t samples_needed = kFrequencyHz / 100; |
116 int64_t now_ms = clock_->TimeInMilliseconds(); | 117 int64_t now_ms = clock_->TimeInMilliseconds(); |
117 uint32_t time_since_last_playout_ms = now_ms - last_playout_ms_; | 118 uint32_t time_since_last_playout_ms = now_ms - last_playout_ms_; |
118 if (last_playout_ms_ > 0 && time_since_last_playout_ms > 0) { | 119 if (last_playout_ms_ > 0 && time_since_last_playout_ms > 0) { |
119 samples_needed = std::min(kFrequencyHz / time_since_last_playout_ms, | 120 samples_needed = std::min( |
120 kBufferSizeBytes / 2); | 121 static_cast<size_t>(kFrequencyHz / time_since_last_playout_ms), |
| 122 kBufferSizeBytes / 2); |
121 } | 123 } |
122 uint32_t samples_out = 0; | 124 size_t samples_out = 0; |
123 int64_t elapsed_time_ms = -1; | 125 int64_t elapsed_time_ms = -1; |
124 int64_t ntp_time_ms = -1; | 126 int64_t ntp_time_ms = -1; |
125 EXPECT_EQ(0, | 127 EXPECT_EQ(0, |
126 audio_callback_->NeedMorePlayData(samples_needed, | 128 audio_callback_->NeedMorePlayData(samples_needed, |
127 2, | 129 2, |
128 1, | 130 1, |
129 kFrequencyHz, | 131 kFrequencyHz, |
130 playout_buffer_, | 132 playout_buffer_, |
131 samples_out, | 133 samples_out, |
132 &elapsed_time_ms, | 134 &elapsed_time_ms, |
133 &ntp_time_ms)); | 135 &ntp_time_ms)); |
134 } | 136 } |
135 } | 137 } |
136 tick_->Wait(WEBRTC_EVENT_INFINITE); | 138 tick_->Wait(WEBRTC_EVENT_INFINITE); |
137 } | 139 } |
138 | 140 |
139 void FakeAudioDevice::Start() { | 141 void FakeAudioDevice::Start() { |
140 rtc::CritScope cs(&lock_); | 142 rtc::CritScope cs(&lock_); |
141 capturing_ = true; | 143 capturing_ = true; |
142 } | 144 } |
143 | 145 |
144 void FakeAudioDevice::Stop() { | 146 void FakeAudioDevice::Stop() { |
145 rtc::CritScope cs(&lock_); | 147 rtc::CritScope cs(&lock_); |
146 capturing_ = false; | 148 capturing_ = false; |
147 } | 149 } |
148 } // namespace test | 150 } // namespace test |
149 } // namespace webrtc | 151 } // namespace webrtc |
OLD | NEW |