• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * Copyright (c) 2023 Huawei Device Co., Ltd.
3  * Licensed under the Apache License, Version 2.0 (the "License");
4  * you may not use this file except in compliance with the License.
5  * You may obtain a copy of the License at
6  *
7  *     http://www.apache.org/licenses/LICENSE-2.0
8  *
9  * Unless required by applicable law or agreed to in writing, software
10  * distributed under the License is distributed on an "AS IS" BASIS,
11  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12  * See the License for the specific language governing permissions and
13  * limitations under the License.
14  */
15 
16 /**
17  * @addtogroup Effect
18  * @{
19  *
20  * @brief defines the effect core methods
21  *
22  * @since 4.0
23  * @version 1.0
24  */
25 
26 #include "effect_core.h"
27 #include "hdf_base.h"
28 #include "osal_mem.h"
29 #include "audio_uhdf_log.h"
30 
31 #define HDF_LOG_TAG HDF_AUDIO_EFFECT
32 #define AUDIO_EFFECT_DESC_LEN 256
33 
34 /* list to manager the effect factory libs */
35 AEM_GET_INITED_DLIST(g_libList);
36 
37 /* list to manager the effect controller */
38 AEM_GET_INITED_DLIST(g_controllerList);
39 
IsEffectLibExist(void)40 bool IsEffectLibExist(void)
41 {
42     bool isSupply = true;
43 
44     if (DListIsEmpty(&g_libList)) {
45         HDF_LOGE("effect lib list is empty, no effect lib");
46         isSupply = false;
47     }
48 
49     return isSupply;
50 }
51 
ConstructDescriptor(struct EffectControllerDescriptorVdi * descsVdi)52 int32_t ConstructDescriptor(struct EffectControllerDescriptorVdi *descsVdi)
53 {
54     if (descsVdi == NULL) {
55         HDF_LOGE("%{public}s: invailid input params", __func__);
56         return HDF_FAILURE;
57     }
58 
59     descsVdi->effectId = (char*)OsalMemCalloc(sizeof(char) * AUDIO_EFFECT_DESC_LEN);
60     if (descsVdi->effectId == NULL) {
61         HDF_LOGE("%{public}s: effectId OsalMemCalloc fail", __func__);
62         return HDF_FAILURE;
63     }
64     descsVdi->effectName = (char*)OsalMemCalloc(sizeof(char) * AUDIO_EFFECT_DESC_LEN);
65     if (descsVdi->effectName == NULL) {
66         OsalMemFree(descsVdi->effectId);
67         HDF_LOGE("%{public}s: effectName OsalMemCalloc fail", __func__);
68         return HDF_FAILURE;
69     }
70     descsVdi->libName = (char*)OsalMemCalloc(sizeof(char) * AUDIO_EFFECT_DESC_LEN);
71     if (descsVdi->libName == NULL) {
72         OsalMemFree(descsVdi->effectId);
73         OsalMemFree(descsVdi->effectName);
74         HDF_LOGE("%{public}s: libName OsalMemCalloc fail", __func__);
75         return HDF_FAILURE;
76     }
77     descsVdi->supplier = (char*)OsalMemCalloc(sizeof(char) * AUDIO_EFFECT_DESC_LEN);
78     if (descsVdi->supplier == NULL) {
79         OsalMemFree(descsVdi->effectId);
80         OsalMemFree(descsVdi->effectName);
81         OsalMemFree(descsVdi->libName);
82         HDF_LOGE("%{public}s: supplier OsalMemCalloc fail", __func__);
83         return HDF_FAILURE;
84     }
85     return HDF_SUCCESS;
86 }