audio: Fix the type used for timekeeping

On 32-bit builds, the 'long' type is 32 bit. Thus, it can not
be used to store the value returned from 'uptimeNanos'.

Bug: 318055805
Test: atest CtsMediaAudioTestCases
Change-Id: I4abf72415b7241728d3ddb1d11043dfd59a8d08a
This commit is contained in:
Mikhail Naganov
2024-01-03 11:22:42 -08:00
parent 5df990f75d
commit 878afae8f8
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;