• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
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     DHLOGI("Configure direct audio processor.");
32     if (procCallback == nullptr) {
33         DHLOGE("Processor callback is null.");
34         return ERR_DH_AUDIO_BAD_VALUE;
35     }
36 
37     procCallback_ = procCallback;
38     return DH_SUCCESS;
39 }
40 
ReleaseAudioProcessor()41 int32_t AudioDirectProcessor::ReleaseAudioProcessor()
42 {
43     DHLOGI("Release direct audio processor.");
44     return DH_SUCCESS;
45 }
46 
StartAudioProcessor()47 int32_t AudioDirectProcessor::StartAudioProcessor()
48 {
49     DHLOGI("Start direct audio processor.");
50     return DH_SUCCESS;
51 }
52 
StopAudioProcessor()53 int32_t AudioDirectProcessor::StopAudioProcessor()
54 {
55     DHLOGI("Stop direct audio processor.");
56     return DH_SUCCESS;
57 }
58 
FeedAudioProcessor(const std::shared_ptr<AudioData> & inputData)59 int32_t AudioDirectProcessor::FeedAudioProcessor(const std::shared_ptr<AudioData> &inputData)
60 {
61     DHLOGD("Feed audio processor.");
62     if (inputData == nullptr) {
63         DHLOGE("Input data is null.");
64         return ERR_DH_AUDIO_BAD_VALUE;
65     }
66 
67     auto cbObj = procCallback_.lock();
68     if (cbObj == nullptr) {
69         DHLOGE("Processor callback is null.");
70         return ERR_DH_AUDIO_BAD_VALUE;
71     }
72     cbObj->OnAudioDataDone(inputData);
73     return DH_SUCCESS;
74 }
75 } // namespace DistributedHardware
76 } // namespace OHOS