diff --git a/audio/bundle.json b/audio/bundle.json index 78478c1d8acb7332c5780e323590a763614b4a6a..a1e89a5652a474549c0b43fc4321ecbefe29af44 100755 --- a/audio/bundle.json +++ b/audio/bundle.json @@ -41,13 +41,15 @@ }, "build": { "sub_component": [ - "//drivers/peripheral/audio:hdi_audio" + "//drivers/peripheral/audio:hdi_audio", + "//drivers/peripheral/audio/effect:effect_model" ], "test": [ "//drivers/peripheral/audio/test:audio_test_entry", "//drivers/peripheral/audio/test/sample:audio_sample", "//drivers/peripheral/audio/test/sample:idl_audio_sample", - "//drivers/peripheral/audio/test/audio_utils/audio_mixer:audio_mixer" + "//drivers/peripheral/audio/test/audio_utils/audio_mixer:audio_mixer", + "//drivers/peripheral/audio/effect/test:effect_test" ], "inner_kits":[ { diff --git a/audio/config/linux/BUILD.gn b/audio/config/linux/BUILD.gn index db5f1b242dd0875dd0fb463984004f76462581b5..f99e1b187a0af9643411532be99144bdfa20b65d 100644 --- a/audio/config/linux/BUILD.gn +++ b/audio/config/linux/BUILD.gn @@ -12,6 +12,7 @@ # limitations under the License import("//build/ohos.gni") +import("//drivers/peripheral/audio/audio.gni") import("//drivers/peripheral/audio/config/audio_config.gni") if (is_standard_system) { @@ -62,12 +63,14 @@ if (is_standard_system) { part_name = "drivers_peripheral_audio" } - ohos_prebuilt_etc("hdf_audio_effect_json") { - source = "${AUDIO_JSON_PATH}/audio_effect.json" + if (drivers_peripheral_audio_community) { + ohos_prebuilt_etc("hdf_audio_effect_json") { + source = "${AUDIO_JSON_PATH}/audio_effect.json" - relative_install_dir = "hdfconfig" - install_images = [ chipset_base_dir ] - subsystem_name = "hdf" - part_name = "drivers_peripheral_audio" + relative_install_dir = "hdfconfig" + install_images = [ chipset_base_dir ] + subsystem_name = "hdf" + part_name = "drivers_peripheral_audio" + } } } diff --git a/audio/effect/BUILD.gn b/audio/effect/BUILD.gn index 875db23e39d0da79b4b261c63d229a2a8f0a1331..2f05011c4a0eccd77bda8771312c214d6297b406 100644 --- a/audio/effect/BUILD.gn +++ b/audio/effect/BUILD.gn @@ -11,13 +11,17 @@ # See the License for the specific language governing permissions and # limitations under the License. +import("//drivers/peripheral/audio/audio.gni") + group("effect_model") { if (!defined(ohos_lite)) { deps = [ - "../config/linux:hdf_audio_effect_json", "host:effect_model_service", "model:effect_model_service_1.0", "model/src/mock_effect:mock_effect_lib", ] + if (drivers_peripheral_audio_community) { + deps += [ "../config/linux:hdf_audio_effect_json" ] + } } } diff --git a/audio/effect/config/src/parse_effect_config.c b/audio/effect/config/src/parse_effect_config.c index 1ffc9868e476c222925d2d59c62df1ba501e5880..9c76e31207fdb69b9b70271e7a33e16fd624b033 100644 --- a/audio/effect/config/src/parse_effect_config.c +++ b/audio/effect/config/src/parse_effect_config.c @@ -360,7 +360,7 @@ void AudioEffectReleaseCfgDesc(struct ConfigDescriptor *cfgDesc) AudioEffectLibraryReleaseDescs(cfgDesc->libCfgDescs, cfgDesc->libNum); OsalMemFree((void *)cfgDesc->libCfgDescs); } - + if (cfgDesc->effectCfgDescs != NULL) { AudioEffectReleaseDescs(cfgDesc->effectCfgDescs, cfgDesc->effectNum); OsalMemFree((void *)cfgDesc->effectCfgDescs); diff --git a/audio/effect/host/BUILD.gn b/audio/effect/host/BUILD.gn index 5356d062a51f934e655193994970b807a7e7e29c..b37f2f11bfcefbe5cec55f389dc2be60f484f95f 100644 --- a/audio/effect/host/BUILD.gn +++ b/audio/effect/host/BUILD.gn @@ -9,7 +9,7 @@ # distributed under the License is distributed on an "AS IS" BASIS, # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. # See the License for the specific language governing permissions and -# limitations under the License. +# limitations under the License. import("//build/ohos.gni") import("//drivers/hdf_core/adapter/uhdf2/hdi.gni") @@ -24,6 +24,7 @@ ohos_shared_library("effect_model_service") { "drivers_interface_audio:libeffect_stub_1.0", "hdf_core:libhdf_host", "hdf_core:libhdf_utils", + "hdf_core:libhdi", "hiviewdfx_hilog_native:libhilog", ] } else { diff --git a/audio/effect/model/src/effect_model.c b/audio/effect/model/src/effect_model.c index 9dc3a0bc2db0041efee0b68ad9c9019df37b6004..2a8cf041bd62386ed54f1614bec6d68a4ba665f7 100644 --- a/audio/effect/model/src/effect_model.c +++ b/audio/effect/model/src/effect_model.c @@ -254,7 +254,7 @@ ret = snprintf_s(path, PATH_MAX, PATH_MAX, "/vendor/lib/%s.z.so", (*libCfgDescs) HDF_LOGE("%{public}s: get libPath failed", __func__); continue; } - + if (realpath(path, pathBuf) == NULL) { HDF_LOGE("%{public}s: realpath is null! [%{public}d]", __func__, errno); continue; @@ -279,7 +279,7 @@ void ModelInit() HDF_LOGE("cfgDesc is null!"); return; } - + g_cfgDescs = cfgDesc; if (RegLibraryInst(&(cfgDesc->libCfgDescs), cfgDesc->libNum) != HDF_SUCCESS) { HDF_LOGE("%{public}s: RegLibraryInst failed", __func__); diff --git a/audio/effect/model/src/mock_effect/mock_effect_lib.c b/audio/effect/model/src/mock_effect/mock_effect_lib.c index 9ef41cd61d6adeb9311392d135e047fb7241f4ec..e1ccbd8f2b6293c70ae649e4aa44061c3cb5c529 100644 --- a/audio/effect/model/src/mock_effect/mock_effect_lib.c +++ b/audio/effect/model/src/mock_effect/mock_effect_lib.c @@ -283,7 +283,7 @@ static int32_t MockDestroyController(struct EffectFactory *self, struct EffectCo return HDF_SUCCESS; } -int32_t MockGetDescriptor(const struct EffectFactory *self, const char *uuid, struct EffectControllerDescriptor *desc) +static int32_t MockGetDescriptor(struct EffectFactory *self, const char *uuid, struct EffectControllerDescriptor *desc) { HDF_LOGI("enter to %{public}s", __func__); if (self == NULL || uuid == NULL || desc == NULL) { diff --git a/audio/effect/test/unittest/effect_common.cpp b/audio/effect/test/unittest/effect_common.cpp index 82e2206217130b6bca7a9a380f74f9079647c9c3..897cbbe0b14269737e9d7b02ba9e532523600a6b 100644 --- a/audio/effect/test/unittest/effect_common.cpp +++ b/audio/effect/test/unittest/effect_common.cpp @@ -17,6 +17,8 @@ #include #include +const int32_t HDF_EFFECT_NUM_MAX = 32; + void EffectControllerReleaseDesc(struct EffectControllerDescriptor *desc) { if (desc == nullptr) { diff --git a/audio/effect/test/unittest/effect_control_test.cpp b/audio/effect/test/unittest/effect_control_test.cpp index e806b0904309f9a2edc0ee0eb3a86ce275b5b36c..0bd406e6e08cab651149c2776f8bb5a41cc1ef94 100644 --- a/audio/effect/test/unittest/effect_control_test.cpp +++ b/audio/effect/test/unittest/effect_control_test.cpp @@ -20,7 +20,6 @@ #include "v1_0/ieffect_control.h" #include "v1_0/ieffect_model.h" #include "effect_common.h" -#include "effect_core.h" #include "osal_mem.h" using namespace std; @@ -161,7 +160,7 @@ HWTEST_F(EffectControlTest, HdfAudioSendCommandInit001, TestSize.Level1) int8_t input[SEND_COMMAND_LEN] = {0}; int8_t output[GET_BUFFER_LEN] = {0}; uint32_t replyLen = GET_BUFFER_LEN; - + int32_t ret = controller_->SendCommand(controller_, AUDIO_EFFECT_COMMAND_INIT_CONTOLLER, input, SEND_COMMAND_LEN, output, &replyLen); EXPECT_EQ(ret, HDF_SUCCESS); @@ -178,7 +177,7 @@ HWTEST_F(EffectControlTest, HdfAudioSendCommandSetConf001, TestSize.Level1) int8_t input[SEND_COMMAND_LEN] = {0}; int8_t output[GET_BUFFER_LEN] = {0}; uint32_t replyLen = GET_BUFFER_LEN; - + int32_t ret = controller_->SendCommand(controller_, AUDIO_EFFECT_COMMAND_SET_CONFIG, input, SEND_COMMAND_LEN, output, &replyLen); EXPECT_EQ(ret, HDF_SUCCESS); @@ -195,7 +194,7 @@ HWTEST_F(EffectControlTest, HdfAudioSendCommandGetConf001, TestSize.Level1) int8_t input[SEND_COMMAND_LEN] = {0}; int8_t output[GET_BUFFER_LEN] = {0}; uint32_t replyLen = GET_BUFFER_LEN; - + int32_t ret = controller_->SendCommand(controller_, AUDIO_EFFECT_COMMAND_GET_CONFIG, input, SEND_COMMAND_LEN, output, &replyLen); EXPECT_EQ(ret, HDF_SUCCESS); @@ -212,7 +211,7 @@ HWTEST_F(EffectControlTest, HdfAudioSendCommandRest001, TestSize.Level1) int8_t input[SEND_COMMAND_LEN] = {0}; int8_t output[GET_BUFFER_LEN] = {0}; uint32_t replyLen = GET_BUFFER_LEN; - + int32_t ret = controller_->SendCommand(controller_, AUDIO_EFFECT_COMMAND_RESET, input, SEND_COMMAND_LEN, output, &replyLen); EXPECT_EQ(ret, HDF_SUCCESS); @@ -229,7 +228,7 @@ HWTEST_F(EffectControlTest, HdfAudioSendCommandEnable001, TestSize.Level1) int8_t input[SEND_COMMAND_LEN] = {0}; int8_t output[GET_BUFFER_LEN] = {0}; uint32_t replyLen = GET_BUFFER_LEN; - + int32_t ret = controller_->SendCommand(controller_, AUDIO_EFFECT_COMMAND_ENABLE, input, SEND_COMMAND_LEN, output, &replyLen); EXPECT_EQ(ret, HDF_SUCCESS); @@ -262,7 +261,7 @@ HWTEST_F(EffectControlTest, HdfAudioSendCommandSetParam001, TestSize.Level1) int8_t input[SEND_COMMAND_LEN] = {0}; int8_t output[GET_BUFFER_LEN] = {0}; uint32_t replyLen = GET_BUFFER_LEN; - + int32_t ret = controller_->SendCommand(controller_, AUDIO_EFFECT_COMMAND_SET_PARAM, input, SEND_COMMAND_LEN, output, &replyLen); EXPECT_EQ(ret, HDF_SUCCESS); @@ -279,7 +278,7 @@ HWTEST_F(EffectControlTest, HdfAudioSendCommandGetParam001, TestSize.Level1) int8_t input[SEND_COMMAND_LEN] = {0}; int8_t output[GET_BUFFER_LEN] = {0}; uint32_t replyLen = GET_BUFFER_LEN; - + int32_t ret = controller_->SendCommand(controller_, AUDIO_EFFECT_COMMAND_GET_PARAM, input, SEND_COMMAND_LEN, output, &replyLen); EXPECT_EQ(ret, HDF_SUCCESS); @@ -309,7 +308,7 @@ HWTEST_F(EffectControlTest, HdfAudioGetDescriptor002, TestSize.Level1) { struct EffectControllerDescriptor desc; int32_t ret = controller_->GetEffectDescriptor(controller_, &desc); - EXPECT_EQ(ret, HDF_SUCCESS); + ASSERT_EQ(ret, HDF_SUCCESS); EXPECT_STREQ(desc.effectId, effectId_); EXPECT_STREQ(desc.effectName, "mock_effect"); EXPECT_STREQ(desc.libName, libName_); diff --git a/audio/effect/test/unittest/effect_model_test.cpp b/audio/effect/test/unittest/effect_model_test.cpp index 06514254d14e04350eb21ac005614d251d46725d..f695a81295be51ca283ca0311983c133c7fa7dc1 100644 --- a/audio/effect/test/unittest/effect_model_test.cpp +++ b/audio/effect/test/unittest/effect_model_test.cpp @@ -196,7 +196,7 @@ HWTEST_F(EffectModelTest, HdfAudioGetEffectDescriptor002, TestSize.Level1) struct EffectControllerDescriptor desc; int32_t ret = model_->GetEffectDescriptor(model_, effectId_, &desc); - EXPECT_EQ(ret, HDF_SUCCESS); + ASSERT_EQ(ret, HDF_SUCCESS); EXPECT_STREQ(desc.effectId, effectId_); EXPECT_STREQ(desc.effectName, "mock_effect"); EXPECT_STREQ(desc.libName, libName_);