• 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 #ifndef OHOS_DAUDIO_MANAGER_CALLBACK_H
17 #define OHOS_DAUDIO_MANAGER_CALLBACK_H
18 
19 #include <v1_0/id_audio_callback.h>
20 #include <v1_0/types.h>
21 
22 #include "idaudio_hdi_callback.h"
23 
24 namespace OHOS {
25 namespace DistributedHardware {
26 class DAudioManagerCallback : public OHOS::HDI::DistributedAudio::Audioext::V1_0::IDAudioCallback {
27 public:
DAudioManagerCallback(const std::shared_ptr<IDAudioHdiCallback> callback)28     explicit DAudioManagerCallback(const std::shared_ptr<IDAudioHdiCallback> callback) : callback_(callback) {};
29     ~DAudioManagerCallback() override = default;
30 
31     int32_t OpenDevice(const std::string &adpName, int32_t devId) override;
32 
33     int32_t CloseDevice(const std::string &adpName, int32_t devId) override;
34 
35     int32_t SetParameters(const std::string &adpName, int32_t devId,
36         const OHOS::HDI::DistributedAudio::Audioext::V1_0::AudioParameter &param) override;
37 
38     int32_t NotifyEvent(const std::string &adpName, int32_t devId,
39         const OHOS::HDI::DistributedAudio::Audioext::V1_0::DAudioEvent &event) override;
40 
41     int32_t WriteStreamData(const std::string &adpName, int32_t devId,
42         const OHOS::HDI::DistributedAudio::Audioext::V1_0::AudioData &data) override;
43 
44     int32_t ReadStreamData(const std::string &adpName, int32_t devId,
45         OHOS::HDI::DistributedAudio::Audioext::V1_0::AudioData &data) override;
46 
47     int32_t ReadMmapPosition(const std::string &adpName, int32_t devId, uint64_t &frames,
48         OHOS::HDI::DistributedAudio::Audioext::V1_0::CurrentTime &time) override;
49 
50     int32_t RefreshAshmemInfo(const std::string &adpName, int32_t devId,
51         int fd, int32_t ashmemLength, int32_t lengthPerTrans) override;
52 
53 private:
54     int32_t GetAudioParamHDF(const OHOS::HDI::DistributedAudio::Audioext::V1_0::AudioParameter& param,
55         AudioParamHDF& paramHDF);
56 
57 private:
58     std::shared_ptr<IDAudioHdiCallback> callback_;
59 };
60 } // DistributedHardware
61 } // OHOS
62 #endif // OHOS_DAUDIO_MANAGER_CALLBACK_H
63