OLD | NEW |
1 /* | 1 /* |
2 * Copyright (c) 2014 The WebRTC project authors. All Rights Reserved. | 2 * Copyright (c) 2014 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 |
| 11 #include "webrtc/base/checks.h" |
10 #include "webrtc/base/logging.h" | 12 #include "webrtc/base/logging.h" |
11 #include "webrtc/base/platform_thread.h" | 13 #include "webrtc/base/platform_thread.h" |
12 #include "webrtc/modules/audio_device/dummy/file_audio_device.h" | 14 #include "webrtc/modules/audio_device/dummy/file_audio_device.h" |
13 #include "webrtc/system_wrappers/include/sleep.h" | 15 #include "webrtc/system_wrappers/include/sleep.h" |
14 | 16 |
15 namespace webrtc { | 17 namespace webrtc { |
16 | 18 |
17 const int kRecordingFixedSampleRate = 48000; | 19 const int kRecordingFixedSampleRate = 48000; |
18 const size_t kRecordingNumChannels = 2; | 20 const size_t kRecordingNumChannels = 2; |
19 const int kPlayoutFixedSampleRate = 48000; | 21 const int kPlayoutFixedSampleRate = 48000; |
(...skipping 465 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
485 int64_t currentTime = rtc::TimeMillis(); | 487 int64_t currentTime = rtc::TimeMillis(); |
486 _critSect.Enter(); | 488 _critSect.Enter(); |
487 | 489 |
488 if (_lastCallPlayoutMillis == 0 || | 490 if (_lastCallPlayoutMillis == 0 || |
489 currentTime - _lastCallPlayoutMillis >= 10) { | 491 currentTime - _lastCallPlayoutMillis >= 10) { |
490 _critSect.Leave(); | 492 _critSect.Leave(); |
491 _ptrAudioBuffer->RequestPlayoutData(_playoutFramesIn10MS); | 493 _ptrAudioBuffer->RequestPlayoutData(_playoutFramesIn10MS); |
492 _critSect.Enter(); | 494 _critSect.Enter(); |
493 | 495 |
494 _playoutFramesLeft = _ptrAudioBuffer->GetPlayoutData(_playoutBuffer); | 496 _playoutFramesLeft = _ptrAudioBuffer->GetPlayoutData(_playoutBuffer); |
495 assert(_playoutFramesLeft == _playoutFramesIn10MS); | 497 RTC_DCHECK_EQ(_playoutFramesIn10MS, _playoutFramesLeft); |
496 if (_outputFile.is_open()) { | 498 if (_outputFile.is_open()) { |
497 _outputFile.Write(_playoutBuffer, kPlayoutBufferSize); | 499 _outputFile.Write(_playoutBuffer, kPlayoutBufferSize); |
498 } | 500 } |
499 _lastCallPlayoutMillis = currentTime; | 501 _lastCallPlayoutMillis = currentTime; |
500 } | 502 } |
501 _playoutFramesLeft = 0; | 503 _playoutFramesLeft = 0; |
502 _critSect.Leave(); | 504 _critSect.Leave(); |
503 | 505 |
504 int64_t deltaTimeMillis = rtc::TimeMillis() - currentTime; | 506 int64_t deltaTimeMillis = rtc::TimeMillis() - currentTime; |
505 if (deltaTimeMillis < 10) { | 507 if (deltaTimeMillis < 10) { |
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
538 | 540 |
539 int64_t deltaTimeMillis = rtc::TimeMillis() - currentTime; | 541 int64_t deltaTimeMillis = rtc::TimeMillis() - currentTime; |
540 if (deltaTimeMillis < 10) { | 542 if (deltaTimeMillis < 10) { |
541 SleepMs(10 - deltaTimeMillis); | 543 SleepMs(10 - deltaTimeMillis); |
542 } | 544 } |
543 | 545 |
544 return true; | 546 return true; |
545 } | 547 } |
546 | 548 |
547 } // namespace webrtc | 549 } // namespace webrtc |
OLD | NEW |