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 #include "effect_core.h"
17 #include "hdf_base.h"
18 #include "hdf_log.h"
19
20 #define HDF_LOG_TAG HDF_AUDIO_EFFECT
21
EffectControlEffectProcess(struct IEffectControl * self,const struct AudioEffectBuffer * input,struct AudioEffectBuffer * output)22 int32_t EffectControlEffectProcess(struct IEffectControl *self, const struct AudioEffectBuffer *input,
23 struct AudioEffectBuffer *output)
24 {
25 if (self == NULL || input == NULL || output == NULL) {
26 HDF_LOGE("%{public}s: invailid input params", __func__);
27 return HDF_ERR_INVALID_PARAM;
28 }
29
30 struct ControllerManager *manager = (struct ControllerManager *)self;
31 if (manager->ctrlOps == NULL || manager->ctrlOps->EffectProcess == NULL) {
32 HDF_LOGE("%{public}s: controller has no options", __func__);
33 return HDF_FAILURE;
34 }
35
36 return manager->ctrlOps->EffectProcess(manager->ctrlOps, input, output);
37 }
38
EffectControlSendCommand(struct IEffectControl * self,uint32_t cmdId,const int8_t * cmdData,uint32_t cmdDataLen,int8_t * replyData,uint32_t * replyDataLen)39 int32_t EffectControlSendCommand(struct IEffectControl *self, uint32_t cmdId, const int8_t *cmdData,
40 uint32_t cmdDataLen, int8_t *replyData, uint32_t *replyDataLen)
41 {
42 if (self == NULL || cmdData == NULL || replyData == NULL || replyDataLen == NULL) {
43 HDF_LOGE("%{public}s: invailid input params", __func__);
44 return HDF_ERR_INVALID_PARAM;
45 }
46
47 struct ControllerManager *manager = (struct ControllerManager *)self;
48 if (manager->ctrlOps == NULL || manager->ctrlOps->SendCommand == NULL) {
49 HDF_LOGE("%{public}s: controller has no options", __func__);
50 return HDF_FAILURE;
51 }
52
53 return manager->ctrlOps->SendCommand(manager->ctrlOps, cmdId, (void *)cmdData, cmdDataLen,
54 (void *)replyData, replyDataLen);
55 }
56
EffectGetOwnDescriptor(struct IEffectControl * self,struct EffectControllerDescriptor * desc)57 int32_t EffectGetOwnDescriptor(struct IEffectControl *self, struct EffectControllerDescriptor *desc)
58 {
59 if (self == NULL || desc == NULL) {
60 HDF_LOGE("%{public}s: invailid input params", __func__);
61 return HDF_ERR_INVALID_PARAM;
62 }
63
64 struct ControllerManager *manager = (struct ControllerManager *)self;
65 if (manager->ctrlOps == NULL || manager->ctrlOps->GetEffectDescriptor == NULL) {
66 HDF_LOGE("%{public}s: controller has no options", __func__);
67 return HDF_FAILURE;
68 }
69
70 return manager->ctrlOps->GetEffectDescriptor(manager->ctrlOps, desc);
71 }
72
EffectControlEffectReverse(struct IEffectControl * self,const struct AudioEffectBuffer * input,struct AudioEffectBuffer * output)73 int32_t EffectControlEffectReverse(struct IEffectControl *self, const struct AudioEffectBuffer *input,
74 struct AudioEffectBuffer *output)
75 {
76 if (self == NULL || input == NULL || output == NULL) {
77 HDF_LOGE("%{public}s: invailid input params", __func__);
78 return HDF_ERR_INVALID_PARAM;
79 }
80
81 struct ControllerManager *manager = (struct ControllerManager *)self;
82 if (manager->ctrlOps == NULL || manager->ctrlOps->EffectReverse == NULL) {
83 HDF_LOGE("%{public}s: controller has no options", __func__);
84 return HDF_FAILURE;
85 }
86
87 return manager->ctrlOps->EffectReverse(manager->ctrlOps, input, output);
88 }
89