diff --git a/frameworks/native/audioadapter/src/pulse_audio_service_adapter_impl.cpp b/frameworks/native/audioadapter/src/pulse_audio_service_adapter_impl.cpp index a7cabeb9a6373a136ae07fb737479d742b1b7548..6af9d39ba5459dfda12f184a1f46ed1f4e1a18f1 100644 --- a/frameworks/native/audioadapter/src/pulse_audio_service_adapter_impl.cpp +++ b/frameworks/native/audioadapter/src/pulse_audio_service_adapter_impl.cpp @@ -878,7 +878,7 @@ void PulseAudioServiceAdapterImpl::PaGetAllSourceOutputsCb(pa_context *c, const CHECK_AND_RETURN_LOG(i->proplist != nullptr, "Invalid Proplist for source output (%{public}d).", i->index); - uint32_t sessionID = 0; + int32_t sessionID = 0; const char *sessionCStr = pa_proplist_gets(i->proplist, "stream.sessionID"); if (sessionCStr != nullptr) { std::stringstream sessionStr; diff --git a/frameworks/native/audioutils/include/audio_utils.h b/frameworks/native/audioutils/include/audio_utils.h index cd85b41411a341735db78d769f300e3c77eca034..08dadbe045aacc491b95029ec4a2ff0434ba44e1 100644 --- a/frameworks/native/audioutils/include/audio_utils.h +++ b/frameworks/native/audioutils/include/audio_utils.h @@ -26,7 +26,7 @@ #define AUDIO_MS_PER_SECOND 1000 #define AUDIO_US_PER_SECOND 1000000 -#define AUDIO_NS_PER_SECOND ((int64_t)1000000000) +#define AUDIO_NS_PER_SECOND ((uint64_t)1000000000) #define FLOAT_EPS 1e-9f #define OFFSET_BIT_24 3 diff --git a/frameworks/native/audioutils/src/audio_channel_blend.cpp b/frameworks/native/audioutils/src/audio_channel_blend.cpp index 99c6e94389dd0c8882b59fe7e9497d39184a458c..bf6e370bab2e789dafe4a31abc9fe46ba8353e59 100644 --- a/frameworks/native/audioutils/src/audio_channel_blend.cpp +++ b/frameworks/native/audioutils/src/audio_channel_blend.cpp @@ -69,7 +69,7 @@ void AudioBlend::ProcessWithBlendMode(T *buffer, size_t bufferSize) return; } - int frameCount = 0; + uint32_t frameCount = 0; frameCount = bufferSize / (channels_ * (format_ + 1)); switch (blendMode_) { case MODE_BLEND_LR: @@ -107,7 +107,7 @@ void AudioBlend::BlendLR(int24_t& left, int24_t& right) template void AudioBlend::ProcessBlendLRModeWithFormat(T *buffer, size_t count, AudioChannel channel) { - for (int i = count; i > 0; i--) { + for (uint32_t i = count; i > 0; i--) { switch (channel) { case CHANNEL_8: BlendLR(buffer[CHANNEL_SEVEN], buffer[CHANNEL_EIGHT]); diff --git a/frameworks/native/audioutils/src/audio_utils.cpp b/frameworks/native/audioutils/src/audio_utils.cpp index 205676d17eea8a44a0c933e9bc00ac7af543c6d7..4d470f0c651ceba05800531efd7c637aa1b267a0 100644 --- a/frameworks/native/audioutils/src/audio_utils.cpp +++ b/frameworks/native/audioutils/src/audio_utils.cpp @@ -413,7 +413,7 @@ float UpdateMaxAmplitude(ConvertHdiFormat adapterFormat, char *frame, uint64_t r float CalculateMaxAmplitudeForPCM8Bit(int8_t *frame, uint64_t nSamples) { int curMaxAmplitude = 0; - for (int i = nSamples; i > 0; --i) { + for (uint32_t i = nSamples; i > 0; --i) { int8_t value = *frame++; if (value < 0) { value = -value; @@ -428,7 +428,7 @@ float CalculateMaxAmplitudeForPCM8Bit(int8_t *frame, uint64_t nSamples) float CalculateMaxAmplitudeForPCM16Bit(int16_t *frame, uint64_t nSamples) { int curMaxAmplitude = 0; - for (int i = nSamples; i > 0; --i) { + for (uint32_t i = nSamples; i > 0; --i) { int16_t value = *frame++; if (value < 0) { value = -value; @@ -443,7 +443,7 @@ float CalculateMaxAmplitudeForPCM16Bit(int16_t *frame, uint64_t nSamples) float CalculateMaxAmplitudeForPCM24Bit(char *frame, uint64_t nSamples) { int curMaxAmplitude = 0; - for (int i = 0; i < nSamples; ++i) { + for (uint32_t i = 0; i < nSamples; ++i) { char *curPos = frame + (i * 3); // 3 bytes int curValue = 0; for (int j = 0; j < 3; ++j) { // 3 bytes @@ -462,7 +462,7 @@ float CalculateMaxAmplitudeForPCM24Bit(char *frame, uint64_t nSamples) float CalculateMaxAmplitudeForPCM32Bit(int32_t *frame, uint64_t nSamples) { int curMaxAmplitude = 0; - for (int i = nSamples; i > 0; --i) { + for (uint32_t i = nSamples; i > 0; --i) { int32_t value = *frame++; if (value < 0) { value = -value; @@ -687,7 +687,7 @@ bool SignalDetectAgent::CheckAudioData(uint8_t *buffer, size_t bufferLen) bool SignalDetectAgent::DetectSignalData(int32_t *buffer, size_t bufferLen) { std::string curTime = GetTime(); - int32_t rightZeroSignal = 0; + uint32_t rightZeroSignal = 0; int32_t currentPeakIndex = -1; int32_t currentPeakSignal = SHRT_MIN; int32_t tempMax; diff --git a/frameworks/native/hdiadapter/devicemanager/src/audio_device_manager_impl.cpp b/frameworks/native/hdiadapter/devicemanager/src/audio_device_manager_impl.cpp index 09395445695376a4e8a13aef1896acdcfebdd03f..dad208c10f11a4dd8440da4ec0b7981e1d5df461 100644 --- a/frameworks/native/hdiadapter/devicemanager/src/audio_device_manager_impl.cpp +++ b/frameworks/native/hdiadapter/devicemanager/src/audio_device_manager_impl.cpp @@ -120,7 +120,7 @@ struct AudioAdapterDescriptor *AudioDeviceManagerImpl::GetTargetAdapterDesc(cons CHECK_AND_RETURN_RET_LOG(ret == SUCCESS, nullptr, "Get all adapters fail, audioMgrType %{public}d, ret %{public}d.", audioMgrType_, ret); - int32_t targetIdx = INVALID_INDEX; + uint32_t targetIdx = INVALID_INDEX; for (uint32_t index = 0; index < descriptors_.size(); index++) { struct AudioAdapterDescriptor desc = descriptors_[index]; if (desc.adapterName.c_str() == nullptr) { diff --git a/frameworks/native/hdiadapter/sink/fast/fast_audio_renderer_sink.cpp b/frameworks/native/hdiadapter/sink/fast/fast_audio_renderer_sink.cpp index 0779b2a76487fc41290d449bbeb80992899c4aca..b4c808f4ca49a938b8df50a0e27d13c352c91090 100644 --- a/frameworks/native/hdiadapter/sink/fast/fast_audio_renderer_sink.cpp +++ b/frameworks/native/hdiadapter/sink/fast/fast_audio_renderer_sink.cpp @@ -346,9 +346,9 @@ void FastAudioRendererSinkInner::ReleaseMmapBuffer() int32_t FastAudioRendererSinkInner::PrepareMmapBuffer() { - int32_t totalBifferInMs = 40; // 5 * (6 + 2 * (1)) = 40ms, the buffer size, not latency. + uint32_t totalBifferInMs = 40; // 5 * (6 + 2 * (1)) = 40ms, the buffer size, not latency. frameSizeInByte_ = PcmFormatToBits(attr_.format) * attr_.channel / PCM_8_BIT; - int32_t reqBufferFrameSize = totalBifferInMs * (attr_.sampleRate / 1000); + uint32_t reqBufferFrameSize = totalBifferInMs * (attr_.sampleRate / 1000); struct AudioMmapBufferDescriptor desc = {0}; int32_t ret = audioRender_->ReqMmapBuffer(audioRender_, reqBufferFrameSize, &desc); diff --git a/frameworks/native/hdiadapter/sink/offload/offload_audio_renderer_sink.cpp b/frameworks/native/hdiadapter/sink/offload/offload_audio_renderer_sink.cpp index 543af76636a4679e4afe59b7bdfd6db2dc4e0163..29002c6ab7f34a5926a4e4516a3ce740b5c5e540 100644 --- a/frameworks/native/hdiadapter/sink/offload/offload_audio_renderer_sink.cpp +++ b/frameworks/native/hdiadapter/sink/offload/offload_audio_renderer_sink.cpp @@ -55,9 +55,9 @@ const uint32_t STEREO_CHANNEL_COUNT = 2; #ifdef FEATURE_POWER_MANAGER constexpr int32_t RUNNINGLOCK_LOCK_TIMEOUTMS_LASTING = -1; #endif -const int64_t SECOND_TO_NANOSECOND = 1000000000; -const int64_t SECOND_TO_MICROSECOND = 1000000; -const int64_t SECOND_TO_MILLISECOND = 1000; +const uint64_t SECOND_TO_NANOSECOND = 1000000000; +const uint64_t SECOND_TO_MICROSECOND = 1000000; +const uint64_t SECOND_TO_MILLISECOND = 1000; const uint32_t BIT_IN_BYTE = 8; const uint16_t GET_MAX_AMPLITUDE_FRAMES_THRESHOLD = 10; } @@ -841,7 +841,7 @@ int32_t OffloadAudioRendererSinkInner::SetBufferSize(uint32_t sizeMs) int32_t ret; // bytewidth is 4 - uint32_t size = (int64_t) sizeMs * AUDIO_SAMPLE_RATE_48K * 4 * STEREO_CHANNEL_COUNT / SECOND_TO_MILLISECOND; + uint32_t size = (uint64_t) sizeMs * AUDIO_SAMPLE_RATE_48K * 4 * STEREO_CHANNEL_COUNT / SECOND_TO_MILLISECOND; CHECK_AND_RETURN_RET_LOG(audioRender_ != nullptr, ERR_INVALID_HANDLE, "failed audio render null"); @@ -924,7 +924,7 @@ void OffloadAudioRendererSinkInner::CheckLatencySignal(uint8_t *data, size_t len return; } CHECK_AND_RETURN_LOG(signalDetectAgent_ != nullptr, "LatencyMeas signalDetectAgent_ is nullptr"); - int32_t byteSize = GetFormatByteSize(attr_.format); + uint32_t byteSize = GetFormatByteSize(attr_.format); size_t newlyCheckedTime = len / (attr_.sampleRate / MILLISECOND_PER_SECOND) / (byteSize * sizeof(uint8_t) * attr_.channel); detectedTime_ += newlyCheckedTime; diff --git a/frameworks/native/hdiadapter/sink/primary/audio_renderer_sink.cpp b/frameworks/native/hdiadapter/sink/primary/audio_renderer_sink.cpp index 125561f82865cf651f69a1d0c09d928d314a29e7..c9528cdac2e3648db9f3e554d387b14d8bdcc72e 100644 --- a/frameworks/native/hdiadapter/sink/primary/audio_renderer_sink.cpp +++ b/frameworks/native/hdiadapter/sink/primary/audio_renderer_sink.cpp @@ -1208,7 +1208,7 @@ int32_t AudioRendererSinkInner::UpdateDPAttrs(const std::string &usbInfoStr) if (attr_.channel <= 0 || attr_.sampleRate <= 0) { AUDIO_ERR_LOG("check attr failed channel[%{public}d] sampleRate[%{public}d]", attr_.channel, attr_.sampleRate); } - int32_t formatByte = stoi(bufferSize) * BUFFER_CALC_1000MS / BUFFER_CALC_20MS / attr_.channel / attr_.sampleRate; + uint32_t formatByte = stoi(bufferSize) * BUFFER_CALC_1000MS / BUFFER_CALC_20MS / attr_.channel / attr_.sampleRate; attr_.format = static_cast(ConvertByteToAudioFormat(formatByte)); AUDIO_DEBUG_LOG("UpdateDPAttrs sampleRate %{public}d, format: %{public}d,channelCount: %{public}d", @@ -1325,7 +1325,7 @@ void AudioRendererSinkInner::CheckLatencySignal(uint8_t *data, size_t len) return; } CHECK_AND_RETURN_LOG(signalDetectAgent_ != nullptr, "LatencyMeas signalDetectAgent_ is nullptr"); - int32_t byteSize = GetFormatByteSize(attr_.format); + uint32_t byteSize = GetFormatByteSize(attr_.format); size_t newlyCheckedTime = len / (attr_.sampleRate / MILLISECOND_PER_SECOND) / (byteSize * sizeof(uint8_t) * attr_.channel); detectedTime_ += newlyCheckedTime; diff --git a/frameworks/native/hdiadapter/source/fast/fast_audio_capturer_source.cpp b/frameworks/native/hdiadapter/source/fast/fast_audio_capturer_source.cpp index 31140984911a54ee6238dbb5a6b250a7f6e16c56..70d8932bc8ec8a018dff2a1b6b428c2ad818dabb 100644 --- a/frameworks/native/hdiadapter/source/fast/fast_audio_capturer_source.cpp +++ b/frameworks/native/hdiadapter/source/fast/fast_audio_capturer_source.cpp @@ -338,9 +338,9 @@ int32_t FastAudioCapturerSourceInner::GetMmapHandlePosition(uint64_t &frames, in int32_t FastAudioCapturerSourceInner::PrepareMmapBuffer() { - int32_t totalBifferInMs = 40; // 5 * (6 + 2 * (1)) = 40ms, the buffer size, not latency. + uint32_t totalBifferInMs = 40; // 5 * (6 + 2 * (1)) = 40ms, the buffer size, not latency. uint32_t frameSizeInByte = PcmFormatToBits(attr_.format) * attr_.channel / PCM_8_BIT; - int32_t reqBufferFrameSize = totalBifferInMs * (attr_.sampleRate / 1000); + uint32_t reqBufferFrameSize = totalBifferInMs * (attr_.sampleRate / 1000); struct AudioMmapBufferDescriptor desc = {0}; int32_t ret = audioCapture_->ReqMmapBuffer(audioCapture_, reqBufferFrameSize, &desc); diff --git a/frameworks/native/ohaudio/OHAudioRoutingManager.cpp b/frameworks/native/ohaudio/OHAudioRoutingManager.cpp index 78d33176402790d39a6f18b8ffa00029b9a3e686..93883355841fd978de08073c9ec6199e6fee252f 100644 --- a/frameworks/native/ohaudio/OHAudioRoutingManager.cpp +++ b/frameworks/native/ohaudio/OHAudioRoutingManager.cpp @@ -97,7 +97,7 @@ OH_AudioCommon_Result OH_AudioRoutingManager_ReleaseDevices( if (audioDeviceDescriptorArray == nullptr) { return AUDIOCOMMON_RESULT_ERROR_INVALID_PARAM; } - for (int32_t index = 0; index < audioDeviceDescriptorArray->size; index++) { + for (uint32_t index = 0; index < audioDeviceDescriptorArray->size; index++) { OHAudioDeviceDescriptor* ohAudioDeviceDescriptor = (OHAudioDeviceDescriptor*)audioDeviceDescriptorArray->descriptors[index]; delete ohAudioDeviceDescriptor; @@ -116,7 +116,7 @@ namespace AudioStandard { void DestroyAudioDeviceDescriptor(OH_AudioDeviceDescriptorArray *array) { if (array) { - for (int32_t index = 0; index < array->size; index++) { + for (uint32_t index = 0; index < array->size; index++) { OHAudioDeviceDescriptor* ohAudioDeviceDescriptor = (OHAudioDeviceDescriptor*)array->descriptors[index]; delete ohAudioDeviceDescriptor; array->descriptors[index] = nullptr; diff --git a/services/audio_policy/client/src/audio_policy_proxy.cpp b/services/audio_policy/client/src/audio_policy_proxy.cpp index 7ef89a138839012bfeb7f36bbeb13d45259044ec..ce4bbac88a3452be342de71a1f9dd50ce13e7f83 100644 --- a/services/audio_policy/client/src/audio_policy_proxy.cpp +++ b/services/audio_policy/client/src/audio_policy_proxy.cpp @@ -513,7 +513,7 @@ int32_t AudioPolicyProxy::SelectOutputDevice(sptr audioRend bool tmp = audioRendererFilter->Marshalling(data); CHECK_AND_RETURN_RET_LOG(tmp, -1, "AudioRendererFilter Marshalling() failed"); - int size = audioDeviceDescriptors.size(); + uint32_t size = audioDeviceDescriptors.size(); int validSize = 20; // Use 20 as limit. CHECK_AND_RETURN_RET_LOG(size > 0 && size <= validSize, -1, "SelectOutputDevice get invalid device size."); data.WriteInt32(size); @@ -557,7 +557,7 @@ int32_t AudioPolicyProxy::SelectInputDevice(sptr audioCaptu bool tmp = audioCapturerFilter->Marshalling(data); CHECK_AND_RETURN_RET_LOG(tmp, -1, "AudioCapturerFilter Marshalling() failed"); - int size = audioDeviceDescriptors.size(); + uint32_t size = audioDeviceDescriptors.size(); int validSize = 20; // Use 20 as limit. CHECK_AND_RETURN_RET_LOG(size > 0 && size <= validSize, -1, "SelectOutputDevice get invalid device size."); data.WriteInt32(size); diff --git a/services/audio_policy/server/include/service/audio_policy_service.h b/services/audio_policy/server/include/service/audio_policy_service.h index 6d4780b5ca0c580e545c12215a5a37f5ee403d32..1732e20f8d54c72353252e8ffb8c7cdd81376806 100644 --- a/services/audio_policy/server/include/service/audio_policy_service.h +++ b/services/audio_policy/server/include/service/audio_policy_service.h @@ -710,7 +710,7 @@ private: void ClearScoDeviceSuspendState(string macAddress = ""); - int32_t OpenPortAndInsertIOHandle(const std::string &moduleName, const AudioModuleInfo &moduleInfo); + AudioIOHandle OpenPortAndInsertIOHandle(const std::string &moduleName, const AudioModuleInfo &moduleInfo); int32_t ClosePortAndEraseIOHandle(const std::string &moduleName); diff --git a/services/audio_policy/server/src/audio_policy_manager_stub.cpp b/services/audio_policy/server/src/audio_policy_manager_stub.cpp index 3a757ca81d9cf68203e07f4ff176d706ac1041e4..77927416af9ac268289b8b8a2798b641b7c915db 100644 --- a/services/audio_policy/server/src/audio_policy_manager_stub.cpp +++ b/services/audio_policy/server/src/audio_policy_manager_stub.cpp @@ -261,7 +261,7 @@ void AudioPolicyManagerStub::GetPreferredInputDeviceDescriptorsInternal(MessageP AudioCapturerInfo captureInfo; captureInfo.Unmarshalling(data); std::vector> devices = GetPreferredInputDeviceDescriptors(captureInfo); - size_t size = static_cast(devices.size()); + int32_t size = static_cast(devices.size()); reply.WriteInt32(size); for (size_t i = 0; i < size; i++) { devices[i]->Marshalling(reply); @@ -463,7 +463,7 @@ void AudioPolicyManagerStub::CheckRecordingCreateInternal(MessageParcel &data, M { uint32_t appTokenId = data.ReadUint32(); uint64_t appFullTokenId = data.ReadUint64(); - uint32_t appUid = data.ReadInt32(); + int32_t appUid = data.ReadInt32(); SourceType sourceType = static_cast (data.ReadInt32()); bool ret = CheckRecordingCreate(appTokenId, appFullTokenId, appUid, sourceType); reply.WriteBool(ret); @@ -647,7 +647,7 @@ void AudioPolicyManagerStub::GetMaxRendererInstancesInternal(MessageParcel &data static void PreprocessMode(SupportedEffectConfig &supportedEffectConfig, MessageParcel &reply, int32_t i, int32_t j) { reply.WriteString(supportedEffectConfig.preProcessNew.stream[i].streamEffectMode[j].mode); - int32_t countDev = supportedEffectConfig.preProcessNew.stream[i].streamEffectMode[j].devicePort.size(); + uint32_t countDev = supportedEffectConfig.preProcessNew.stream[i].streamEffectMode[j].devicePort.size(); reply.WriteInt32(countDev); if (countDev > 0) { for (int32_t k = 0; k < countDev; k++) { @@ -659,7 +659,7 @@ static void PreprocessMode(SupportedEffectConfig &supportedEffectConfig, Message static void PreprocessProcess(SupportedEffectConfig &supportedEffectConfig, MessageParcel &reply, int32_t i) { reply.WriteString(supportedEffectConfig.preProcessNew.stream[i].scene); - int32_t countMode = supportedEffectConfig.preProcessNew.stream[i].streamEffectMode.size(); + uint32_t countMode = supportedEffectConfig.preProcessNew.stream[i].streamEffectMode.size(); reply.WriteInt32(countMode); if (countMode > 0) { for (int32_t j = 0; j < countMode; j++) { @@ -670,7 +670,7 @@ static void PreprocessProcess(SupportedEffectConfig &supportedEffectConfig, Mess static void PostprocessMode(SupportedEffectConfig &supportedEffectConfig, MessageParcel &reply, int32_t i, int32_t j) { reply.WriteString(supportedEffectConfig.postProcessNew.stream[i].streamEffectMode[j].mode); - int32_t countDev = supportedEffectConfig.postProcessNew.stream[i].streamEffectMode[j].devicePort.size(); + uint32_t countDev = supportedEffectConfig.postProcessNew.stream[i].streamEffectMode[j].devicePort.size(); reply.WriteInt32(countDev); if (countDev > 0) { for (int32_t k = 0; k < countDev; k++) { @@ -683,7 +683,7 @@ static void PostprocessProcess(SupportedEffectConfig &supportedEffectConfig, Mes { // i th stream reply.WriteString(supportedEffectConfig.postProcessNew.stream[i].scene); - int countMode = supportedEffectConfig.postProcessNew.stream[i].streamEffectMode.size(); + uint32_t countMode = supportedEffectConfig.postProcessNew.stream[i].streamEffectMode.size(); reply.WriteInt32(countMode); if (countMode > 0) { for (int32_t j = 0; j < countMode; j++) { @@ -699,9 +699,9 @@ void AudioPolicyManagerStub::QueryEffectSceneModeInternal(MessageParcel &data, M int32_t ret = QueryEffectSceneMode(supportedEffectConfig); // audio_policy_server.cpp CHECK_AND_RETURN_LOG(ret != -1, "default mode is unavailable !"); - int32_t countPre = supportedEffectConfig.preProcessNew.stream.size(); - int32_t countPost = supportedEffectConfig.postProcessNew.stream.size(); - int32_t countPostMap = supportedEffectConfig.postProcessSceneMap.size(); + uint32_t countPre = supportedEffectConfig.preProcessNew.stream.size(); + uint32_t countPost = supportedEffectConfig.postProcessNew.stream.size(); + uint32_t countPostMap = supportedEffectConfig.postProcessSceneMap.size(); reply.WriteInt32(countPre); reply.WriteInt32(countPost); reply.WriteInt32(countPostMap); diff --git a/services/audio_policy/server/src/service/audio_policy_service.cpp b/services/audio_policy/server/src/service/audio_policy_service.cpp index 2aae1a017bc23c54c7d749b4d8defa812dc2fe9a..198f424d01ca2e42582de1ea47fb1260addf00f5 100644 --- a/services/audio_policy/server/src/service/audio_policy_service.cpp +++ b/services/audio_policy/server/src/service/audio_policy_service.cpp @@ -5875,7 +5875,8 @@ float AudioPolicyService::GetMaxAmplitude(const int32_t deviceId) return 0; } -int32_t AudioPolicyService::OpenPortAndInsertIOHandle(const std::string &moduleName, const AudioModuleInfo &moduleInfo) +AudioIOHandle AudioPolicyService::OpenPortAndInsertIOHandle(const std::string &moduleName, + const AudioModuleInfo &moduleInfo) { AudioIOHandle ioHandle = audioPolicyManager_.OpenAudioPort(moduleInfo); CHECK_AND_RETURN_RET_LOG(ioHandle != OPEN_PORT_FAILURE, ERR_INVALID_HANDLE, "OpenAudioPort failed %{public}d", diff --git a/services/audio_policy/server/src/service/config/audio_device_parser.cpp b/services/audio_policy/server/src/service/config/audio_device_parser.cpp index 9c8605b06ae9166294699cea1bae87b8af4ab1b9..ea65081c56a5c11040083cd1f891e1d30e232b01 100644 --- a/services/audio_policy/server/src/service/config/audio_device_parser.cpp +++ b/services/audio_policy/server/src/service/config/audio_device_parser.cpp @@ -193,7 +193,7 @@ DeviceNodeName AudioDeviceParser::GetDeviceNodeNameAsInt(xmlNode *node) std::vector split(const std::string &line, const std::string &sep) { std::vector buf; - int temp = 0; + size_t temp = 0; std::string::size_type pos = 0; while (true) { pos = line.find(sep, temp); diff --git a/services/audio_policy/server/src/service/config/audio_strategy_router_parser.cpp b/services/audio_policy/server/src/service/config/audio_strategy_router_parser.cpp index 777eb22ae524dc1ab71c4464dc365bdc0ac6f6cc..878de1f660e0632af04195e3cb6bcc00cb0f2c3b 100644 --- a/services/audio_policy/server/src/service/config/audio_strategy_router_parser.cpp +++ b/services/audio_policy/server/src/service/config/audio_strategy_router_parser.cpp @@ -114,7 +114,7 @@ std::string AudioStrategyRouterParser::ExtractPropertyValue(const std::string &p std::vector AudioStrategyRouterParser::split(const std::string &line, const std::string &sep) { std::vector buf; - int temp = 0; + size_t temp = 0; std::string::size_type pos = 0; while (true) { pos = line.find(sep, temp); diff --git a/services/audio_policy/server/src/service/config/audio_usage_strategy_parser.cpp b/services/audio_policy/server/src/service/config/audio_usage_strategy_parser.cpp index 392333aa45c98ab845fa9bd79f2031b07512f577..3381091fd5fa22c7f0ec1c03b2b1e1f499286921 100644 --- a/services/audio_policy/server/src/service/config/audio_usage_strategy_parser.cpp +++ b/services/audio_policy/server/src/service/config/audio_usage_strategy_parser.cpp @@ -108,7 +108,7 @@ void AudioUsageStrategyParser::ParserSourceTypeList(xmlNode *node) std::vector AudioUsageStrategyParser::split(const std::string &line, const std::string &sep) { std::vector buf; - int temp = 0; + size_t temp = 0; std::string::size_type pos = 0; while (true) { pos = line.find(sep, temp); diff --git a/services/audio_policy/server/src/service/manager/audio_adapter_manager.cpp b/services/audio_policy/server/src/service/manager/audio_adapter_manager.cpp index 72798c0b91b692f780f1962e3677218c5021dac5..a0f4de538ac33dcfba622f2eb04319d9cf7c19c8 100644 --- a/services/audio_policy/server/src/service/manager/audio_adapter_manager.cpp +++ b/services/audio_policy/server/src/service/manager/audio_adapter_manager.cpp @@ -1541,7 +1541,7 @@ float AudioAdapterManager::CalculateVolumeDbNonlinear(AudioStreamType streamType DeviceVolumeType deviceCategory = GetDeviceCategory(deviceType); std::vector volumePoints; GetVolumePoints(streamAlias, deviceCategory, volumePoints); - int32_t pointSize = volumePoints.size(); + uint32_t pointSize = volumePoints.size(); int32_t volSteps = 1 + volumePoints[pointSize - 1].index - volumePoints[0].index; int32_t idxRatio = (volSteps * (volumeLevel - minVolIndex)) / (maxVolIndex - minVolIndex); diff --git a/services/audio_service/client/src/audio_manager_proxy.cpp b/services/audio_service/client/src/audio_manager_proxy.cpp index 9d8868f07039050045a86fbb866e3cdf9350a4dd..ec5b1991f601955d1db1b7b0647330e37515d4dc 100644 --- a/services/audio_service/client/src/audio_manager_proxy.cpp +++ b/services/audio_service/client/src/audio_manager_proxy.cpp @@ -629,8 +629,8 @@ bool AudioManagerProxy::LoadAudioEffectLibraries(const vector libraries bool ret = dataParcel.WriteInterfaceToken(GetDescriptor()); CHECK_AND_RETURN_RET_LOG(ret, false, "WriteInterfaceToken failed"); - int32_t countLib = libraries.size(); - int32_t countEff = effects.size(); + uint32_t countLib = libraries.size(); + uint32_t countEff = effects.size(); dataParcel.WriteInt32(countLib); dataParcel.WriteInt32(countEff); @@ -690,7 +690,7 @@ bool AudioManagerProxy::CreateEffectChainManager(std::vector &effec bool ret = dataParcel.WriteInterfaceToken(GetDescriptor()); CHECK_AND_RETURN_RET_LOG(ret, false, "WriteInterfaceToken failed"); - int32_t countEffectChains = effectChains.size(); + uint32_t countEffectChains = effectChains.size(); std::vector listCountEffects; for (EffectChain &effectChain: effectChains) { diff --git a/services/audio_service/client/src/audio_process_in_client.cpp b/services/audio_service/client/src/audio_process_in_client.cpp index 19e6558890eca7852c5fbd79eb18ad48c4af003d..d7871a3d35ccdb4c0bb0944d86c5002fccba2d13 100644 --- a/services/audio_service/client/src/audio_process_in_client.cpp +++ b/services/audio_service/client/src/audio_process_in_client.cpp @@ -430,7 +430,7 @@ void AudioProcessInClientInner::SetPreferredFrameSize(int32_t frameSize) { size_t originalSpanSizeInFrame = static_cast(spanSizeInFrame_); size_t tmp = static_cast(frameSize); - size_t count = frameSize / spanSizeInFrame_; + size_t count = static_cast(frameSize / spanSizeInFrame_); size_t rest = frameSize % spanSizeInFrame_; if (tmp <= originalSpanSizeInFrame) { clientSpanSizeInFrame_ = originalSpanSizeInFrame; @@ -1536,7 +1536,7 @@ bool AudioProcessInClientInner::PrepareNextIndependent(uint64_t curWritePos, int uint64_t nextHandlePos = curWritePos + spanSizeInFrame_; Trace prepareTrace("AudioEndpoint::PrepareNextLoop " + std::to_string(nextHandlePos)); int64_t nextHdiReadTime = GetPredictNextHandleTime(nextHandlePos, true); - int64_t aheadTime = spanSizeInFrame_ * AUDIO_NS_PER_SECOND / processConfig_.streamInfo.samplingRate; + uint64_t aheadTime = spanSizeInFrame_ * AUDIO_NS_PER_SECOND / processConfig_.streamInfo.samplingRate; int64_t nextServerHandleTime = nextHdiReadTime - aheadTime; if (nextServerHandleTime < ClockTime::GetCurNano()) { wakeUpTime = ClockTime::GetCurNano() + ONE_MILLISECOND_DURATION; // make sure less than duration diff --git a/services/audio_service/client/src/audio_service_client.cpp b/services/audio_service/client/src/audio_service_client.cpp index 3c73a374fb428498f9fc98f7f3699f6a307790d7..f8c779b1e5325725f141707d0204975ff2282a85 100644 --- a/services/audio_service/client/src/audio_service_client.cpp +++ b/services/audio_service/client/src/audio_service_client.cpp @@ -2336,7 +2336,7 @@ void AudioServiceClient::GetOffloadApproximatelyCacheTime(uint64_t paTimeStamp, ppTimeStamp = timeNowSteady; int64_t timeDelta = static_cast(timeNowSteady) - static_cast(offloadLastHdiPosTs_); timeDelta = timeDelta > 0 ? timeDelta : 0; - frames = offloadLastHdiPosFrames_ + timeDelta; + frames = offloadLastHdiPosFrames_ + static_cast(timeDelta); } int64_t timeDelta = static_cast(paTimeStamp) - static_cast(ppTimeStamp); @@ -2394,7 +2394,7 @@ int32_t AudioServiceClient::GetCurrentPosition(uint64_t &framePosition, uint64_t void AudioServiceClient::GetAudioLatencyOffload(uint64_t &latency) { - int64_t timeNow = static_cast(std::chrono::duration_cast( + uint64_t timeNow = static_cast(std::chrono::duration_cast( std::chrono::system_clock::now().time_since_epoch()).count()); bool offloadPwrActive = offloadStatePolicy_ != OFFLOAD_INACTIVE_BACKGROUND; if (offloadPwrActive || diff --git a/services/audio_service/client/src/audio_spatial_channel_converter.cpp b/services/audio_service/client/src/audio_spatial_channel_converter.cpp index 7fef760c8bea9b3fd9812965dafa6b86d594786b..059d0224fffca44a5297791c62f68a649a830996 100644 --- a/services/audio_service/client/src/audio_spatial_channel_converter.cpp +++ b/services/audio_service/client/src/audio_spatial_channel_converter.cpp @@ -236,7 +236,7 @@ bool LibLoader::AddAlgoHandle(Library library) bool LibLoader::Init() { int32_t ret = 0; - int32_t replyData = 0; + uint32_t replyData = 0; AudioEffectTransInfo cmdInfo = {sizeof(AudioEffectConfig), &ioBufferConfig_}; AudioEffectTransInfo replyInfo = {sizeof(int32_t), &replyData}; ret = (*handle_)->command(handle_, EFFECT_CMD_INIT, &cmdInfo, &replyInfo); diff --git a/services/audio_service/client/src/audio_stream_manager.cpp b/services/audio_service/client/src/audio_stream_manager.cpp index 383fca3e58335ae4d8af5f385c2c0c17204b7917..4fdab5c97ae660f4ce3bf6ca3d9c6ea4e4177b56 100644 --- a/services/audio_service/client/src/audio_stream_manager.cpp +++ b/services/audio_service/client/src/audio_stream_manager.cpp @@ -107,7 +107,7 @@ int32_t AudioStreamManager::GetEffectInfoArray(AudioSceneEffectInfo &audioSceneE std::string effectScene = IAudioStream::GetEffectSceneName(streamUsage); SupportedEffectConfig supportedEffectConfig; int32_t ret = AudioPolicyManager::GetInstance().QueryEffectSceneMode(supportedEffectConfig); - int32_t streamNum = supportedEffectConfig.postProcessNew.stream.size(); + uint32_t streamNum = supportedEffectConfig.postProcessNew.stream.size(); if (streamNum >= 0) { int32_t sceneFlag = 0; for (int32_t i = 0; i < streamNum; i++) { diff --git a/services/audio_service/client/src/audio_system_manager.cpp b/services/audio_service/client/src/audio_system_manager.cpp index 2ea97d71482670304b887c236ce199fde38b55e2..224e1cfc58c34d3591e8397681b64972c1987b4b 100644 --- a/services/audio_service/client/src/audio_system_manager.cpp +++ b/services/audio_service/client/src/audio_system_manager.cpp @@ -684,7 +684,7 @@ int32_t AudioSystemManager::RegisterFocusInfoChangeCallback( { CHECK_AND_RETURN_RET_LOG(callback != nullptr, ERR_INVALID_PARAM, "callback is null"); - int32_t clientId = GetCallingPid(); + int32_t clientId = static_cast(GetCallingPid()); AUDIO_DEBUG_LOG("RegisterFocusInfoChangeCallback clientId:%{public}d", clientId); if (audioFocusInfoCallback_ == nullptr) { audioFocusInfoCallback_ = std::make_shared(); @@ -706,7 +706,7 @@ int32_t AudioSystemManager::RegisterFocusInfoChangeCallback( int32_t AudioSystemManager::UnregisterFocusInfoChangeCallback( const std::shared_ptr &callback) { - int32_t clientId = GetCallingPid(); + int32_t clientId = static_cast(GetCallingPid()); int32_t ret = 0; if (callback == nullptr) { @@ -896,7 +896,7 @@ int32_t AudioSystemManager::DeactivateAudioInterrupt(const AudioInterrupt &audio int32_t AudioSystemManager::SetAudioManagerInterruptCallback(const std::shared_ptr &callback) { - int32_t clientId = GetCallingPid(); + int32_t clientId = static_cast(GetCallingPid()); AUDIO_INFO_LOG("client id: %{public}d", clientId); CHECK_AND_RETURN_RET_LOG(callback != nullptr, ERR_INVALID_PARAM, "callback is null"); @@ -926,7 +926,7 @@ int32_t AudioSystemManager::SetAudioManagerInterruptCallback(const std::shared_p int32_t AudioSystemManager::UnsetAudioManagerInterruptCallback() { - int32_t clientId = GetCallingPid(); + int32_t clientId = static_cast(GetCallingPid()); AUDIO_INFO_LOG("client id: %{public}d", clientId); int32_t ret = AudioPolicyManager::GetInstance().UnsetAudioManagerInterruptCallback(clientId); @@ -940,7 +940,7 @@ int32_t AudioSystemManager::UnsetAudioManagerInterruptCallback() int32_t AudioSystemManager::RequestAudioFocus(const AudioInterrupt &audioInterrupt) { - int32_t clientId = GetCallingPid(); + int32_t clientId = static_cast(GetCallingPid()); AUDIO_INFO_LOG("RequestAudioFocus client id: %{public}d", clientId); CHECK_AND_RETURN_RET_LOG(audioInterrupt.contentType >= CONTENT_TYPE_UNKNOWN && audioInterrupt.contentType <= CONTENT_TYPE_ULTRASONIC, ERR_INVALID_PARAM, "Invalid content type"); @@ -953,7 +953,7 @@ int32_t AudioSystemManager::RequestAudioFocus(const AudioInterrupt &audioInterru int32_t AudioSystemManager::AbandonAudioFocus(const AudioInterrupt &audioInterrupt) { - int32_t clientId = GetCallingPid(); + int32_t clientId = static_cast(GetCallingPid()); AUDIO_INFO_LOG("AbandonAudioFocus client id: %{public}d", clientId); CHECK_AND_RETURN_RET_LOG(audioInterrupt.contentType >= CONTENT_TYPE_UNKNOWN && audioInterrupt.contentType <= CONTENT_TYPE_ULTRASONIC, ERR_INVALID_PARAM, "Invalid content type"); @@ -1039,7 +1039,7 @@ bool AudioSystemManager::RequestIndependentInterrupt(FocusType focusType) { AUDIO_INFO_LOG("RequestIndependentInterrupt : foncusType"); AudioInterrupt audioInterrupt; - int32_t clientId = GetCallingPid(); + int32_t clientId = static_cast(GetCallingPid()); audioInterrupt.contentType = ContentType::CONTENT_TYPE_SPEECH; audioInterrupt.streamUsage = StreamUsage::STREAM_USAGE_MEDIA; audioInterrupt.audioFocusType.streamType = AudioStreamType::STREAM_RECORDING; @@ -1053,7 +1053,7 @@ bool AudioSystemManager::AbandonIndependentInterrupt(FocusType focusType) { AUDIO_INFO_LOG("AbandonIndependentInterrupt : foncusType"); AudioInterrupt audioInterrupt; - int32_t clientId = GetCallingPid(); + int32_t clientId = static_cast(GetCallingPid()); audioInterrupt.contentType = ContentType::CONTENT_TYPE_SPEECH; audioInterrupt.streamUsage = StreamUsage::STREAM_USAGE_MEDIA; audioInterrupt.audioFocusType.streamType = AudioStreamType::STREAM_RECORDING; diff --git a/services/audio_service/client/src/capturer_in_client.cpp b/services/audio_service/client/src/capturer_in_client.cpp index 7d947935b3ef8986c626effa238d76149fb7666a..a6e36e8336bc17a2293c24b10d3c0570bb4de530 100644 --- a/services/audio_service/client/src/capturer_in_client.cpp +++ b/services/audio_service/client/src/capturer_in_client.cpp @@ -290,7 +290,7 @@ private: std::mutex readMutex_; // used for prevent multi thread call read // Mark reach and period reach callback - int64_t totalBytesRead_ = 0; + uint64_t totalBytesRead_ = 0; std::mutex markReachMutex_; bool capturerMarkReached_ = false; int64_t capturerMarkPosition_ = 0; @@ -792,7 +792,7 @@ bool CapturerInClientInner::GetAudioTime(Timestamp ×tamp, Timestamp::Timest { CHECK_AND_RETURN_RET_LOG(paramsIsSet_ == true, false, "Params is not set"); CHECK_AND_RETURN_RET_LOG(state_ != STOPPED, false, "Invalid status:%{public}d", state_.load()); - int64_t currentReadPos = totalBytesRead_ / sizePerFrameInByte_; + uint64_t currentReadPos = totalBytesRead_ / sizePerFrameInByte_; timestamp.framePosition = currentReadPos; uint64_t writePos = 0; @@ -1191,7 +1191,7 @@ int64_t CapturerInClientInner::GetFramesWritten() int64_t CapturerInClientInner::GetFramesRead() { CHECK_AND_RETURN_RET_LOG(sizePerFrameInByte_ != 0, INVALID_FRAME_SIZE, "sizePerFrameInByte_ is 0!"); - int64_t readFrameNumber = totalBytesRead_ / sizePerFrameInByte_; + uint64_t readFrameNumber = totalBytesRead_ / sizePerFrameInByte_; return readFrameNumber; } @@ -1587,7 +1587,7 @@ void CapturerInClientInner::HandleCapturerPositionChanges(size_t bytesRead) AUDIO_ERR_LOG("HandleCapturerPositionChanges: sizePerFrameInByte_ is 0"); return; } - int64_t readFrameNumber = totalBytesRead_ / sizePerFrameInByte_; + uint64_t readFrameNumber = totalBytesRead_ / sizePerFrameInByte_; AUDIO_DEBUG_LOG("totalBytesRead_ %{public}" PRId64 ", frame size: %{public}zu", totalBytesRead_, sizePerFrameInByte_); { diff --git a/services/audio_service/client/src/renderer_in_client.cpp b/services/audio_service/client/src/renderer_in_client.cpp index cc75d5c5dcd5a69fd7a46e64a9e01c7c61a761e9..d8ee0ea59e77ac0c93f9be7b08f3a50848c5620b 100644 --- a/services/audio_service/client/src/renderer_in_client.cpp +++ b/services/audio_service/client/src/renderer_in_client.cpp @@ -64,7 +64,7 @@ namespace AudioStandard { namespace { const uint64_t OLD_BUF_DURATION_IN_USEC = 92880; // This value is used for compatibility purposes. const uint64_t AUDIO_US_PER_MS = 1000; -const int64_t AUDIO_NS_PER_US = 1000; +const uint64_t AUDIO_NS_PER_US = 1000; const uint64_t AUDIO_US_PER_S = 1000000; const uint64_t AUDIO_MS_PER_S = 1000; const uint64_t MAX_BUF_DURATION_IN_USEC = 2000000; // 2S @@ -321,7 +321,7 @@ private: size_t clientSpanSizeInByte_ = 0; size_t sizePerFrameInByte_ = 4; // 16bit 2ch as default - int32_t bufferSizeInMsec_ = 20; // 20ms + uint32_t bufferSizeInMsec_ = 20; // 20ms std::string cachePath_; std::string dumpOutFile_; FILE *dumpOutFd_ = nullptr; @@ -909,7 +909,7 @@ bool RendererInClientInner::GetAudioTime(Timestamp ×tamp, Timestamp::Timest int64_t timeNow = static_cast(std::chrono::duration_cast( std::chrono::system_clock::now().time_since_epoch()).count()); int64_t deltaTimeStamp = (static_cast(timeNow) - static_cast(timestampHdi)) * AUDIO_NS_PER_US; - int64_t paWriteIndexNs = paWriteIndex * AUDIO_NS_PER_US; + uint64_t paWriteIndexNs = paWriteIndex * AUDIO_NS_PER_US; uint64_t readPosNs = readPos * AUDIO_MS_PER_SECOND / curStreamParams_.samplingRate * AUDIO_US_PER_S; int64_t deltaPaWriteIndexNs = static_cast(readPosNs) - static_cast(paWriteIndexNs); diff --git a/services/audio_service/common/src/linear_pos_time_model.cpp b/services/audio_service/common/src/linear_pos_time_model.cpp index 751328b0d65f687c6d76b1f7b806ae91a981a72a..919baf4a48fd154e08203f8baea6d7fbf9b16aaf 100644 --- a/services/audio_service/common/src/linear_pos_time_model.cpp +++ b/services/audio_service/common/src/linear_pos_time_model.cpp @@ -110,7 +110,7 @@ void LinearPosTimeModel::SetSpanCount(uint64_t spanCountInFrame) int64_t LinearPosTimeModel::GetTimeOfPos(uint64_t posInFrame) { - int64_t deltaFrame = 0; + uint64_t deltaFrame = 0; int64_t invalidTime = -1; CHECK_AND_RETURN_RET_LOG(isConfiged, invalidTime, "SampleRate is not configed!"); if (posInFrame >= stampFrame_) { diff --git a/services/audio_service/server/src/audio_endpoint.cpp b/services/audio_service/server/src/audio_endpoint.cpp index 31b2ebc12bb9e89e41fbe0b208851e165157cdf4..83d976cfba4b31abdafd77ad8adceca7bcfbb46c 100644 --- a/services/audio_service/server/src/audio_endpoint.cpp +++ b/services/audio_service/server/src/audio_endpoint.cpp @@ -1526,7 +1526,7 @@ void AudioEndpointInner::CheckPlaySignal(uint8_t *buffer, size_t bufferSize) return; } CHECK_AND_RETURN_LOG(signalDetectAgent_ != nullptr, "LatencyMeas signalDetectAgent_ is nullptr"); - int32_t byteSize = GetFormatByteSize(dstStreamInfo_.format); + size_t byteSize = GetFormatByteSize(dstStreamInfo_.format); size_t newlyCheckedTime = bufferSize / (dstStreamInfo_.samplingRate / MILLISECOND_PER_SECOND) / (byteSize * sizeof(uint8_t) * dstStreamInfo_.channels); detectedTime_ += newlyCheckedTime; diff --git a/services/audio_service/server/src/audio_server.cpp b/services/audio_service/server/src/audio_server.cpp index 6d5f2f89523ac371a0c63865262d5acf4a2f4a82..5f8a286b6d03895bbf500429d35a8668006cbcfa 100644 --- a/services/audio_service/server/src/audio_server.cpp +++ b/services/audio_service/server/src/audio_server.cpp @@ -1257,7 +1257,7 @@ void AudioServer::RequestThreadPriority(uint32_t tid, string bundleName) { AUDIO_INFO_LOG("RequestThreadPriority tid: %{public}u", tid); - uint32_t pid = IPCSkeleton::GetCallingPid(); + int32_t pid = IPCSkeleton::GetCallingPid(); AudioXCollie audioXCollie("AudioServer::ScheduleReportData", SCHEDULE_REPORT_TIME_OUT_SECONDS); ScheduleReportData(pid, tid, bundleName.c_str()); } diff --git a/services/audio_service/server/src/pa_renderer_stream_impl.cpp b/services/audio_service/server/src/pa_renderer_stream_impl.cpp index 369da6157dda27880b8a6fb74d133903c207766a..1f139624bac09253e2f6a6c280042169c51bbc79 100644 --- a/services/audio_service/server/src/pa_renderer_stream_impl.cpp +++ b/services/audio_service/server/src/pa_renderer_stream_impl.cpp @@ -863,7 +863,7 @@ int32_t PaRendererStreamImpl::GetOffloadApproximatelyCacheTime(uint64_t ×ta timestamp = info->timestamp.tv_sec * AUDIO_US_PER_SECOND + info->timestamp.tv_usec; lock.Unlock(); - int64_t cacheTimeInPulse = writeIndex > readIndex ? writeIndex - readIndex : 0; + uint64_t cacheTimeInPulse = writeIndex > readIndex ? writeIndex - readIndex : 0; cacheTimePa = static_cast(cacheTimeInPulse); paWriteIndex = writeIndex;