Removes usage of system_wrappers/include/clock.h in audio_device/
BUG=webrtc:6687 NOTRY=TRUE Review-Url: https://codereview.webrtc.org/2501603002 Cr-Commit-Position: refs/heads/master@{#15084}
This commit is contained in:
parent
43c31e7afe
commit
92fd8e6b17
@ -20,6 +20,7 @@
|
||||
#include "webrtc/base/criticalsection.h"
|
||||
#include "webrtc/base/format_macros.h"
|
||||
#include "webrtc/base/scoped_ref_ptr.h"
|
||||
#include "webrtc/base/timeutils.h"
|
||||
#include "webrtc/modules/audio_device/android/audio_common.h"
|
||||
#include "webrtc/modules/audio_device/android/audio_manager.h"
|
||||
#include "webrtc/modules/audio_device/android/build_info.h"
|
||||
@ -27,7 +28,6 @@
|
||||
#include "webrtc/modules/audio_device/audio_device_impl.h"
|
||||
#include "webrtc/modules/audio_device/include/audio_device.h"
|
||||
#include "webrtc/modules/audio_device/include/mock_audio_transport.h"
|
||||
#include "webrtc/system_wrappers/include/clock.h"
|
||||
#include "webrtc/system_wrappers/include/event_wrapper.h"
|
||||
#include "webrtc/system_wrappers/include/sleep.h"
|
||||
#include "webrtc/test/gmock.h"
|
||||
@ -252,8 +252,7 @@ class FifoAudioStream : public AudioStreamInterface {
|
||||
class LatencyMeasuringAudioStream : public AudioStreamInterface {
|
||||
public:
|
||||
explicit LatencyMeasuringAudioStream(size_t frames_per_buffer)
|
||||
: clock_(Clock::GetRealTimeClock()),
|
||||
frames_per_buffer_(frames_per_buffer),
|
||||
: frames_per_buffer_(frames_per_buffer),
|
||||
bytes_per_buffer_(frames_per_buffer_ * sizeof(int16_t)),
|
||||
play_count_(0),
|
||||
rec_count_(0),
|
||||
@ -270,7 +269,7 @@ class LatencyMeasuringAudioStream : public AudioStreamInterface {
|
||||
memset(destination, 0, bytes_per_buffer_);
|
||||
if (play_count_ % (kNumCallbacksPerSecond / kImpulseFrequencyInHz) == 0) {
|
||||
if (pulse_time_ == 0) {
|
||||
pulse_time_ = clock_->TimeInMilliseconds();
|
||||
pulse_time_ = rtc::TimeMillis();
|
||||
}
|
||||
PRINT(".");
|
||||
const int16_t impulse = std::numeric_limits<int16_t>::max();
|
||||
@ -301,7 +300,7 @@ class LatencyMeasuringAudioStream : public AudioStreamInterface {
|
||||
max));
|
||||
if (max > kImpulseThreshold) {
|
||||
PRINTD("(%d,%d)", max, index_of_max);
|
||||
int64_t now_time = clock_->TimeInMilliseconds();
|
||||
int64_t now_time = rtc::TimeMillis();
|
||||
int extra_delay = IndexToMilliseconds(static_cast<double> (index_of_max));
|
||||
PRINTD("[%d]", static_cast<int> (now_time - pulse_time_));
|
||||
PRINTD("[%d]", extra_delay);
|
||||
@ -356,7 +355,6 @@ class LatencyMeasuringAudioStream : public AudioStreamInterface {
|
||||
}
|
||||
|
||||
private:
|
||||
Clock* clock_;
|
||||
const size_t frames_per_buffer_;
|
||||
const size_t bytes_per_buffer_;
|
||||
size_t play_count_;
|
||||
|
||||
@ -42,8 +42,7 @@ FileAudioDevice::FileAudioDevice(const int32_t id,
|
||||
_outputFile(*FileWrapper::Create()),
|
||||
_inputFile(*FileWrapper::Create()),
|
||||
_outputFilename(outputFilename),
|
||||
_inputFilename(inputFilename),
|
||||
_clock(Clock::GetRealTimeClock()) {
|
||||
_inputFilename(inputFilename) {
|
||||
}
|
||||
|
||||
FileAudioDevice::~FileAudioDevice() {
|
||||
@ -480,10 +479,10 @@ bool FileAudioDevice::RecThreadFunc(void* pThis)
|
||||
|
||||
bool FileAudioDevice::PlayThreadProcess()
|
||||
{
|
||||
if(!_playing) {
|
||||
if (!_playing) {
|
||||
return false;
|
||||
}
|
||||
uint64_t currentTime = _clock->CurrentNtpInMilliseconds();
|
||||
int64_t currentTime = rtc::TimeMillis();
|
||||
_critSect.Enter();
|
||||
|
||||
if (_lastCallPlayoutMillis == 0 ||
|
||||
@ -502,8 +501,8 @@ bool FileAudioDevice::PlayThreadProcess()
|
||||
_playoutFramesLeft = 0;
|
||||
_critSect.Leave();
|
||||
|
||||
uint64_t deltaTimeMillis = _clock->CurrentNtpInMilliseconds() - currentTime;
|
||||
if(deltaTimeMillis < 10) {
|
||||
int64_t deltaTimeMillis = rtc::TimeMillis() - currentTime;
|
||||
if (deltaTimeMillis < 10) {
|
||||
SleepMs(10 - deltaTimeMillis);
|
||||
}
|
||||
|
||||
@ -516,7 +515,7 @@ bool FileAudioDevice::RecThreadProcess()
|
||||
return false;
|
||||
}
|
||||
|
||||
uint64_t currentTime = _clock->CurrentNtpInMilliseconds();
|
||||
int64_t currentTime = rtc::TimeMillis();
|
||||
_critSect.Enter();
|
||||
|
||||
if (_lastCallRecordMillis == 0 ||
|
||||
@ -537,8 +536,8 @@ bool FileAudioDevice::RecThreadProcess()
|
||||
|
||||
_critSect.Leave();
|
||||
|
||||
uint64_t deltaTimeMillis = _clock->CurrentNtpInMilliseconds() - currentTime;
|
||||
if(deltaTimeMillis < 10) {
|
||||
int64_t deltaTimeMillis = rtc::TimeMillis() - currentTime;
|
||||
if (deltaTimeMillis < 10) {
|
||||
SleepMs(10 - deltaTimeMillis);
|
||||
}
|
||||
|
||||
|
||||
@ -16,10 +16,10 @@
|
||||
#include <memory>
|
||||
#include <string>
|
||||
|
||||
#include "webrtc/base/timeutils.h"
|
||||
#include "webrtc/modules/audio_device/audio_device_generic.h"
|
||||
#include "webrtc/system_wrappers/include/critical_section_wrapper.h"
|
||||
#include "webrtc/system_wrappers/include/file_wrapper.h"
|
||||
#include "webrtc/system_wrappers/include/clock.h"
|
||||
|
||||
namespace rtc {
|
||||
class PlatformThread;
|
||||
@ -188,15 +188,13 @@ class FileAudioDevice : public AudioDeviceGeneric {
|
||||
|
||||
bool _playing;
|
||||
bool _recording;
|
||||
uint64_t _lastCallPlayoutMillis;
|
||||
uint64_t _lastCallRecordMillis;
|
||||
int64_t _lastCallPlayoutMillis;
|
||||
int64_t _lastCallRecordMillis;
|
||||
|
||||
FileWrapper& _outputFile;
|
||||
FileWrapper& _inputFile;
|
||||
std::string _outputFilename;
|
||||
std::string _inputFilename;
|
||||
|
||||
Clock* _clock;
|
||||
};
|
||||
|
||||
} // namespace webrtc
|
||||
|
||||
@ -21,11 +21,11 @@
|
||||
#include "webrtc/base/format_macros.h"
|
||||
#include "webrtc/base/logging.h"
|
||||
#include "webrtc/base/scoped_ref_ptr.h"
|
||||
#include "webrtc/base/timeutils.h"
|
||||
#include "webrtc/modules/audio_device/audio_device_impl.h"
|
||||
#include "webrtc/modules/audio_device/include/audio_device.h"
|
||||
#include "webrtc/modules/audio_device/include/mock_audio_transport.h"
|
||||
#include "webrtc/modules/audio_device/ios/audio_device_ios.h"
|
||||
#include "webrtc/system_wrappers/include/clock.h"
|
||||
#include "webrtc/system_wrappers/include/event_wrapper.h"
|
||||
#include "webrtc/system_wrappers/include/sleep.h"
|
||||
#include "webrtc/test/gmock.h"
|
||||
@ -247,8 +247,7 @@ class FifoAudioStream : public AudioStreamInterface {
|
||||
class LatencyMeasuringAudioStream : public AudioStreamInterface {
|
||||
public:
|
||||
explicit LatencyMeasuringAudioStream(size_t frames_per_buffer)
|
||||
: clock_(Clock::GetRealTimeClock()),
|
||||
frames_per_buffer_(frames_per_buffer),
|
||||
: frames_per_buffer_(frames_per_buffer),
|
||||
bytes_per_buffer_(frames_per_buffer_ * sizeof(int16_t)),
|
||||
play_count_(0),
|
||||
rec_count_(0),
|
||||
@ -264,7 +263,7 @@ class LatencyMeasuringAudioStream : public AudioStreamInterface {
|
||||
memset(destination, 0, bytes_per_buffer_);
|
||||
if (play_count_ % (kNumCallbacksPerSecond / kImpulseFrequencyInHz) == 0) {
|
||||
if (pulse_time_ == 0) {
|
||||
pulse_time_ = clock_->TimeInMilliseconds();
|
||||
pulse_time_ = rtc::TimeMillis();
|
||||
}
|
||||
PRINT(".");
|
||||
const int16_t impulse = std::numeric_limits<int16_t>::max();
|
||||
@ -294,7 +293,7 @@ class LatencyMeasuringAudioStream : public AudioStreamInterface {
|
||||
std::distance(vec.begin(), std::find(vec.begin(), vec.end(), max));
|
||||
if (max > kImpulseThreshold) {
|
||||
PRINTD("(%d,%d)", max, index_of_max);
|
||||
int64_t now_time = clock_->TimeInMilliseconds();
|
||||
int64_t now_time = rtc::TimeMillis();
|
||||
int extra_delay = IndexToMilliseconds(static_cast<double>(index_of_max));
|
||||
PRINTD("[%d]", static_cast<int>(now_time - pulse_time_));
|
||||
PRINTD("[%d]", extra_delay);
|
||||
@ -348,7 +347,6 @@ class LatencyMeasuringAudioStream : public AudioStreamInterface {
|
||||
}
|
||||
|
||||
private:
|
||||
Clock* clock_;
|
||||
const size_t frames_per_buffer_;
|
||||
const size_t bytes_per_buffer_;
|
||||
size_t play_count_;
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user