diff --git a/services/audiomanager/managersink/src/daudio_sink_dev.cpp b/services/audiomanager/managersink/src/daudio_sink_dev.cpp index 908b945fa7a71abc07d45bf54a5729eb6d7de1e1..33274a1f91b6f08907b4a561314fac15327f940c 100644 --- a/services/audiomanager/managersink/src/daudio_sink_dev.cpp +++ b/services/audiomanager/managersink/src/daudio_sink_dev.cpp @@ -387,7 +387,6 @@ void DAudioSinkDev::NotifySourceDev(const AudioEventType type, const std::string { std::random_device rd; const uint32_t randomTaskCode = rd(); - cJSON *jEvent = cJSON_CreateObject(); if (jEvent == nullptr) { DHLOGE("Failed to create JSON data."); @@ -397,7 +396,6 @@ void DAudioSinkDev::NotifySourceDev(const AudioEventType type, const std::string cJSON_AddNumberToObject(jEvent, KEY_RESULT, result); cJSON_AddNumberToObject(jEvent, KEY_EVENT_TYPE, static_cast(type)); cJSON_AddNumberToObject(jEvent, KEY_RANDOM_TASK_CODE, randomTaskCode); - DHLOGD("Notify source dev, new engine, random task code:%u", randomTaskCode); if (type == NOTIFY_OPEN_CTRL_RESULT || type == NOTIFY_CLOSE_CTRL_RESULT) { DHLOGE("In new engine mode, ctrl is not allowed."); @@ -411,7 +409,6 @@ void DAudioSinkDev::NotifySourceDev(const AudioEventType type, const std::string return; } std::string messageStr(message); - if (speakerClient_ != nullptr) { speakerClient_->SendMessage(static_cast(type), messageStr, devId_); } diff --git a/services/audiomanager/managersource/src/daudio_source_dev.cpp b/services/audiomanager/managersource/src/daudio_source_dev.cpp index c3a16f4dd2bc3e371405470b7030abcea35b3aa2..528f5f3030e42f32134e918554695a19a3d62fd8 100644 --- a/services/audiomanager/managersource/src/daudio_source_dev.cpp +++ b/services/audiomanager/managersource/src/daudio_source_dev.cpp @@ -654,15 +654,14 @@ int32_t DAudioSourceDev::TaskEnableDAudio(const std::string &args) return ERR_DH_AUDIO_NULLPTR; } int32_t dhId = std::atoi(jsonDhId->valuestring); - char *attrs = cJSON_PrintUnformatted(cJSON_GetObjectItem(jParam, KEY_ATTRS)); - std::string attrsStr(attrs); int32_t result = 0; switch (GetDevTypeByDHId(dhId)) { case AUDIO_DEVICE_TYPE_SPEAKER: - result = EnableDSpeaker(dhId, attrsStr); + result = EnableDSpeaker(dhId, + std::string(cJSON_GetObjectItemCaseSensitive(jParam, KEY_ATTRS)->valuestring)); break; case AUDIO_DEVICE_TYPE_MIC: - result = EnableDMic(dhId, attrsStr); + result = EnableDMic(dhId, std::string(cJSON_GetObjectItemCaseSensitive(jParam, KEY_ATTRS)->valuestring)); break; default: DHLOGE("Unknown audio device."); @@ -670,7 +669,6 @@ int32_t DAudioSourceDev::TaskEnableDAudio(const std::string &args) break; } cJSON_Delete(jParam); - cJSON_free(attrs); return result; } @@ -717,18 +715,10 @@ void DAudioSourceDev::OnEnableTaskResult(int32_t resultCode, const std::string & cJSON_Delete(jParam); return; } - char *devId = cJSON_PrintUnformatted(cJSON_GetObjectItem(jParam, KEY_DEV_ID)); - std::string devIdStr(devId); - char *dhId = cJSON_PrintUnformatted(cJSON_GetObjectItem(jParam, KEY_DH_ID)); - std::string dhIdStr(dhId); - mgrCallback_->OnEnableAudioResult(devIdStr, dhIdStr, resultCode); + mgrCallback_->OnEnableAudioResult(std::string(cJSON_GetObjectItemCaseSensitive(jParam, KEY_DEV_ID)->valuestring), + std::string(cJSON_GetObjectItemCaseSensitive(jParam, KEY_DH_ID)->valuestring), + resultCode); cJSON_Delete(jParam); - if (devId != nullptr) { - cJSON_free(devId); - } - if (dhId != nullptr) { - cJSON_free(dhId); - } } int32_t DAudioSourceDev::TaskDisableDAudio(const std::string &args) @@ -815,18 +805,10 @@ void DAudioSourceDev::OnDisableTaskResult(int32_t resultCode, const std::string cJSON_Delete(jParam); return; } - char *devId = cJSON_PrintUnformatted(cJSON_GetObjectItem(jParam, KEY_DEV_ID)); - std::string devIdStr(devId); - char *dhId = cJSON_PrintUnformatted(cJSON_GetObjectItem(jParam, KEY_DH_ID)); - std::string dhIdStr(dhId); - mgrCallback_->OnDisableAudioResult(devIdStr, dhIdStr, resultCode); + mgrCallback_->OnDisableAudioResult(std::string(cJSON_GetObjectItemCaseSensitive(jParam, KEY_DEV_ID)->valuestring), + std::string(cJSON_GetObjectItemCaseSensitive(jParam, KEY_DH_ID)->valuestring), + resultCode); cJSON_Delete(jParam); - if (devId != nullptr) { - cJSON_free(devId); - } - if (dhId != nullptr) { - cJSON_free(dhId); - } } int32_t DAudioSourceDev::TaskOpenDSpeaker(const std::string &args)