1 /*
2  * Copyright (c) 2022 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 "audio_direct_processor.h"
17 
18 #include "daudio_errorcode.h"
19 #include "daudio_hisysevent.h"
20 #include "daudio_hitrace.h"
21 #include "daudio_log.h"
22 
23 #undef DH_LOG_TAG
24 #define DH_LOG_TAG "AudioDirectProcessor"
25 
26 namespace OHOS {
27 namespace DistributedHardware {
ConfigureAudioProcessor(const AudioCommonParam & localDevParam,const AudioCommonParam & remoteDevParam,const std::shared_ptr<IAudioProcessorCallback> & procCallback)28 int32_t AudioDirectProcessor::ConfigureAudioProcessor(const AudioCommonParam &localDevParam,
29     const AudioCommonParam &remoteDevParam, const std::shared_ptr<IAudioProcessorCallback> &procCallback)
30 {
31     DHLOGD("Configure direct audio processor.");
32     CHECK_NULL_RETURN(procCallback, ERR_DH_AUDIO_BAD_VALUE);
33     procCallback_ = procCallback;
34     return DH_SUCCESS;
35 }
36 
ReleaseAudioProcessor()37 int32_t AudioDirectProcessor::ReleaseAudioProcessor()
38 {
39     DHLOGD("Release direct audio processor.");
40     return DH_SUCCESS;
41 }
42 
StartAudioProcessor()43 int32_t AudioDirectProcessor::StartAudioProcessor()
44 {
45     DHLOGD("Start direct audio processor.");
46     return DH_SUCCESS;
47 }
48 
StopAudioProcessor()49 int32_t AudioDirectProcessor::StopAudioProcessor()
50 {
51     DHLOGD("Stop direct audio processor.");
52     return DH_SUCCESS;
53 }
54 
FeedAudioProcessor(const std::shared_ptr<AudioData> & inputData)55 int32_t AudioDirectProcessor::FeedAudioProcessor(const std::shared_ptr<AudioData> &inputData)
56 {
57     DHLOGD("Feed audio processor.");
58     CHECK_NULL_RETURN(inputData, ERR_DH_AUDIO_BAD_VALUE);
59     auto cbObj = procCallback_.lock();
60     CHECK_NULL_RETURN(cbObj, ERR_DH_AUDIO_BAD_VALUE);
61     cbObj->OnAudioDataDone(inputData);
62     return DH_SUCCESS;
63 }
64 } // namespace DistributedHardware
65 } // namespace OHOS