diff --git a/frameworks/js/napi/audiocapturer/napi_audio_capturer.cpp b/frameworks/js/napi/audiocapturer/napi_audio_capturer.cpp index 41a7c73cc724d3df88d11b5bc564081f45209918..55806c40e50aa4b5f7d26de1a9191e4b515f0ee8 100644 --- a/frameworks/js/napi/audiocapturer/napi_audio_capturer.cpp +++ b/frameworks/js/napi/audiocapturer/napi_audio_capturer.cpp @@ -496,7 +496,8 @@ napi_value NapiAudioCapturer::GetAudioTime(napi_env env, napi_callback_info info Timestamp timestamp; if (napiAudioCapturer->audioCapturer_->GetAudioTime(timestamp, Timestamp::Timestampbase::MONOTONIC)) { const uint64_t secToNanosecond = 1000000000; - context->time = timestamp.time.tv_nsec + timestamp.time.tv_sec * secToNanosecond; + context->time = static_cast(timestamp.time.tv_nsec) + + static_cast(timestamp.time.tv_sec) * secToNanosecond; } else { context->SignError(NAPI_ERR_SYSTEM); } diff --git a/frameworks/native/audioutils/src/audio_speed.cpp b/frameworks/native/audioutils/src/audio_speed.cpp index 7c1c7e5b3108b915c9598129443b2f633c8c6112..df886b4dafb3cfaa705a053ed7caa4584b17528d 100644 --- a/frameworks/native/audioutils/src/audio_speed.cpp +++ b/frameworks/native/audioutils/src/audio_speed.cpp @@ -136,9 +136,18 @@ int32_t AudioSpeed::ChangeSpeedFor24Bit(uint8_t *buffer, int32_t bufferSize, return ERR_MEMORY_ALLOC_FAILED; } float* bitTofloat = new(std::nothrow) float[bufferSize]; + if (!bitTofloat) { + AUDIO_ERR_LOG("bitTofloat nullptr, No memory"); + return ERR_MEMORY_ALLOC_FAILED; + } ConvertFrom24BitToFloat(bufferSize / formatSize_, buffer, bitTofloat); float* speedBuf = new(std::nothrow) float[MAX_BUFFER_SIZE]; + if (!speedBuf) { + AUDIO_ERR_LOG("speedBuf nullptr, No memory"); + delete [] bitTofloat; + return ERR_MEMORY_ALLOC_FAILED; + } int32_t ret = ChangeSpeedForFloat(bitTofloat, bufferSize, speedBuf, outBufferSize); ConvertFromFloatTo24Bit(outBufferSize / formatSize_, speedBuf, outBuffer.get()); @@ -157,9 +166,18 @@ int32_t AudioSpeed::ChangeSpeedFor32Bit(uint8_t *buffer, int32_t bufferSize, return ERR_MEMORY_ALLOC_FAILED; } float* bitTofloat = new(std::nothrow) float[bufferSize]; + if (!bitTofloat) { + AUDIO_ERR_LOG("bitTofloat nullptr, No memory"); + return ERR_MEMORY_ALLOC_FAILED; + } ConvertFrom32BitToFloat(bufferSize / formatSize_, reinterpret_cast(buffer), bitTofloat); float* speedBuf = new(std::nothrow) float[MAX_BUFFER_SIZE]; + if (!speedBuf) { + AUDIO_ERR_LOG("speedBuf nullptr, No memory"); + delete [] bitTofloat; + return ERR_MEMORY_ALLOC_FAILED; + } int32_t ret = ChangeSpeedForFloat(bitTofloat, bufferSize, speedBuf, outBufferSize); ConvertFromFloatTo32Bit(outBufferSize / formatSize_, speedBuf, reinterpret_cast(outBuffer.get())); diff --git a/frameworks/native/hdiadapter/sink/primary/audio_renderer_sink.cpp b/frameworks/native/hdiadapter/sink/primary/audio_renderer_sink.cpp index 443a5ffb9fceb4c7c6465faca87706f1d3784eeb..6ca630a340244830c4e16cfdd48a7617e0133dc4 100644 --- a/frameworks/native/hdiadapter/sink/primary/audio_renderer_sink.cpp +++ b/frameworks/native/hdiadapter/sink/primary/audio_renderer_sink.cpp @@ -320,7 +320,7 @@ bool AudioRendererSinkInner::AttributesCheck(AudioSampleAttributes &attrInfo) int32_t AudioRendererSinkInner::SetAudioAttrInfo(AudioSampleAttributes &attrInfo) { CHECK_AND_RETURN_RET_LOG(AttributesCheck(attrInfo), ERROR, "AttributesCheck failed"); - int32_t bufferSize = attrInfo.sampleRate * attrInfo.format * attrInfo.channelCount * + uint32_t bufferSize = attrInfo.sampleRate * attrInfo.format * attrInfo.channelCount * BUFFER_CALC_20MS / BUFFER_CALC_1000MS; audioAttrInfo_ = "rate="+to_string(attrInfo.sampleRate)+" format=" + ParseAudioFormatToStr(attrInfo.format) + " channels=" + to_string(attrInfo.channelCount) + " buffer_size="+to_string(bufferSize); diff --git a/frameworks/native/pulseaudio/modules/abstract/module_loopback.c b/frameworks/native/pulseaudio/modules/abstract/module_loopback.c index fad3a22d5d0a349fcf65ef3ff13d4a68c09cc089..d0b015c0222f7d4fc93335e738eda8cbda4d22c1 100644 --- a/frameworks/native/pulseaudio/modules/abstract/module_loopback.c +++ b/frameworks/native/pulseaudio/modules/abstract/module_loopback.c @@ -944,8 +944,8 @@ static int SinkInputProcessMsgCb(pa_msgobject *obj, int code, void *data, int64_ u->latency_snapshot.recv_counter = u->output_thread_info.recv_counter; u->latency_snapshot.loopback_memblockq_length = pa_memblockq_get_length(u->memblockq); /* Add content of render memblockq to sink latency */ - u->latency_snapshot.sink_latency = pa_sink_get_latency_within_thread(u->sink_input->sink, true) + - pa_bytes_to_usec(length, &u->sink_input->sink->sample_spec); + u->latency_snapshot.sink_latency = (int64_t)(pa_sink_get_latency_within_thread(u->sink_input->sink, true) + + pa_bytes_to_usec(length, &u->sink_input->sink->sample_spec)); u->latency_snapshot.sink_timestamp = pa_rtclock_now(); return 0; } diff --git a/services/audio_policy/server/src/service/manager/volume_data_maintainer.cpp b/services/audio_policy/server/src/service/manager/volume_data_maintainer.cpp index 6f371b0af46b475f73f24a719a721f9dd34fba5b..a1ab361abee50ab1437a27b9a995d97b1e149392 100644 --- a/services/audio_policy/server/src/service/manager/volume_data_maintainer.cpp +++ b/services/audio_policy/server/src/service/manager/volume_data_maintainer.cpp @@ -324,7 +324,7 @@ bool VolumeDataMaintainer::SetMuteAffectedToMuteStatusDataBase(int32_t affected) { // transfer mute_streams_affected to mutestatus for (auto &streamtype : VOLUME_MUTE_STREAM_TYPE) { - if (affected & (1 << streamtype)) { + if (static_cast(affected) & (1 << streamtype)) { for (auto &device : DEVICE_TYPE_LIST) { // save mute status to database SaveMuteStatusInternal(device, AUDIO_STREAMTYPE_MAP[streamtype], true); diff --git a/services/audio_service/server/src/audio_effect_server.cpp b/services/audio_service/server/src/audio_effect_server.cpp index 65be1fac7d74190c7e332c91ea4b751a391fa6aa..bbdd4626ac07d8b2b5fddc18d1042cffc1fba28a 100644 --- a/services/audio_service/server/src/audio_effect_server.cpp +++ b/services/audio_service/server/src/audio_effect_server.cpp @@ -56,6 +56,13 @@ static bool LoadLibrary(const std::string &relativePath, std::shared_ptr PATH_MAX) || !resultpath) { + AUDIO_ERR_LOG(" realpath lib %{public}s Fail", relativePath.c_str()); + return false; + } + void* handle = dlopen(absolutePath.c_str(), 1); if (!handle) { AUDIO_ERR_LOG(" dlopen lib %{public}s Fail", relativePath.c_str());