Merge "audio: Fix the type used for timekeeping" into main am: e3ed739865 am: da3b33a4f4 am: 6178a82724

Original change: https://android-review.googlesource.com/c/platform/hardware/interfaces/+/2894924

Change-Id: I6dead6af17b8364d52548c5d73e0984e1341d18e
Signed-off-by: Automerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com>
This commit is contained in:
Mikhail Naganov 2024-01-04 02:38:49 +00:00 committed by Automerger Merge Worker
commit 5f8f8cc16b
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; std::vector<alsa::DeviceProfile> getDeviceProfiles() override;
const bool mIsAsynchronous; const bool mIsAsynchronous;
long mStartTimeNs = 0; int64_t mStartTimeNs = 0;
long mFramesSinceStart = 0; long mFramesSinceStart = 0;
bool mSkipNextTransfer = false; bool mSkipNextTransfer = false;
}; };

View file

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

View file

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