Merge "audio: Fix the type used for timekeeping" into main

This commit is contained in:
Mikhail Naganov 2024-01-04 01:26:12 +00:00 committed by Gerrit Code Review
commit e3ed739865
3 changed files with 5 additions and 5 deletions

View file

@ -36,7 +36,7 @@ class StreamPrimary : public StreamAlsa {
std::vector<alsa::DeviceProfile> getDeviceProfiles() override;
const bool mIsAsynchronous;
long mStartTimeNs = 0;
int64_t mStartTimeNs = 0;
long mFramesSinceStart = 0;
bool mSkipNextTransfer = false;
};

View file

@ -64,7 +64,7 @@ class StreamRemoteSubmix : public StreamCommonImpl {
// 5ms between two read attempts when pipe is empty
static constexpr int kReadAttemptSleepUs = 5000;
long mStartTimeNs = 0;
int64_t mStartTimeNs = 0;
long mFramesSinceStart = 0;
int mReadErrorCount = 0;
};

View file

@ -138,7 +138,7 @@ void StreamRemoteSubmix::shutdown() {
: outWrite(buffer, frameCount, actualFrameCount));
const long bufferDurationUs =
(*actualFrameCount) * MICROS_PER_SECOND / mContext.getSampleRate();
const long totalDurationUs = (::android::uptimeNanos() - mStartTimeNs) / NANOS_PER_MICROSECOND;
const auto totalDurationUs = (::android::uptimeNanos() - mStartTimeNs) / NANOS_PER_MICROSECOND;
mFramesSinceStart += *actualFrameCount;
const long totalOffsetUs =
mFramesSinceStart * MICROS_PER_SECOND / mContext.getSampleRate() - totalDurationUs;
@ -274,8 +274,8 @@ size_t StreamRemoteSubmix::getStreamPipeSizeInFrames() {
char* buff = (char*)buffer;
size_t actuallyRead = 0;
long remainingFrames = frameCount;
const long deadlineTimeNs = ::android::uptimeNanos() +
getDelayInUsForFrameCount(frameCount) * NANOS_PER_MICROSECOND;
const int64_t deadlineTimeNs = ::android::uptimeNanos() +
getDelayInUsForFrameCount(frameCount) * NANOS_PER_MICROSECOND;
while (remainingFrames > 0) {
ssize_t framesRead = source->read(buff, remainingFrames);
LOG(VERBOSE) << __func__ << ": frames read " << framesRead;