From c7755beb9233abf4bcab8698aa1983717f82f5d1 Mon Sep 17 00:00:00 2001 From: Bobie Date: Sat, 1 Jul 2023 18:18:43 +0800 Subject: [PATCH] remove offset operation Signed-off-by: Bobie --- .../audio/v1_0/include/audio_render_interface_impl.h | 3 --- .../audio/v1_0/src/audio_render_interface_impl.cpp | 11 +++-------- 2 files changed, 3 insertions(+), 11 deletions(-) diff --git a/hdf_service/distributed_audio/hdi_service/audio/v1_0/include/audio_render_interface_impl.h b/hdf_service/distributed_audio/hdi_service/audio/v1_0/include/audio_render_interface_impl.h index 221eb946..c3562a13 100644 --- a/hdf_service/distributed_audio/hdi_service/audio/v1_0/include/audio_render_interface_impl.h +++ b/hdf_service/distributed_audio/hdi_service/audio/v1_0/include/audio_render_interface_impl.h @@ -116,9 +116,6 @@ private: bool firstOpenFlag_ = true; int64_t frameIndex_ = 0; - int64_t framePeriodNs_ = 0; - int64_t startTime_ = 0; - std::mutex volMtx_; uint32_t vol_ = 0; uint32_t volMax_ = 0; diff --git a/hdf_service/distributed_audio/hdi_service/audio/v1_0/src/audio_render_interface_impl.cpp b/hdf_service/distributed_audio/hdi_service/audio/v1_0/src/audio_render_interface_impl.cpp index 50f61130..a2681d5a 100644 --- a/hdf_service/distributed_audio/hdi_service/audio/v1_0/src/audio_render_interface_impl.cpp +++ b/hdf_service/distributed_audio/hdi_service/audio/v1_0/src/audio_render_interface_impl.cpp @@ -39,10 +39,8 @@ AudioRenderInterfaceImpl::AudioRenderInterfaceImpl(const std::string &adpName, c devAttrs_(attrs), audioExtCallback_(callback) { devAttrs_.frameSize = CalculateFrameSize(attrs.sampleRate, attrs.channelCount, attrs.format, timeInterval_, false); - const int32_t sizePerSec = static_cast(attrs.sampleRate * attrs.channelCount) *attrs.format; - framePeriodNs_ = (static_cast(devAttrs_.frameSize) * AUDIO_NS_PER_SECOND) /sizePerSec; - DHLOGD("Distributed audio render constructed, period(%d), frameSize(%d), framePeriodNs_(%d).", - attrs.period, devAttrs_.frameSize, framePeriodNs_); + DHLOGD("Distributed audio render constructed, period(%d), frameSize(%d).", + attrs.period, devAttrs_.frameSize); } AudioRenderInterfaceImpl::~AudioRenderInterfaceImpl() @@ -92,8 +90,7 @@ int32_t AudioRenderInterfaceImpl::RenderFrame(const std::vector &frame, { DHLOGD("Render frame[sampleRate: %u, channelCount: %u, format: %d, frameSize: %u].", devAttrs_.sampleRate, devAttrs_.channelCount, devAttrs_.format, devAttrs_.frameSize); - int64_t timeOffset = UpdateTimeOffset(frameIndex_, framePeriodNs_, startTime_); - DHLOGD("Render frameIndex: %lld, timeOffset: %lld.", frameIndex_, timeOffset); + DHLOGD("Render frameIndex: %lld.", frameIndex_); std::lock_guard renderLck(renderMtx_); if (renderStatus_ != RENDER_STATUS_START) { @@ -115,7 +112,6 @@ int32_t AudioRenderInterfaceImpl::RenderFrame(const std::vector &frame, } ++frameIndex_; - AbsoluteSleep(startTime_ + frameIndex_ * framePeriodNs_ - timeOffset); DHLOGD("Render audio frame success."); return HDF_SUCCESS; } @@ -194,7 +190,6 @@ int32_t AudioRenderInterfaceImpl::Start() renderStatus_ = RENDER_STATUS_START; currentFrame_ = CUR_FRAME_INIT_VALUE; frameIndex_ = 0; - startTime_ = 0; return HDF_SUCCESS; } -- Gitee