1 /* 2 * Copyright (c) 2022-2024 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 <v2_0/id_audio_callback.h> 20 #include <v2_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::V2_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 CreateStream(int32_t streamId) override; 32 33 int32_t DestroyStream(int32_t streamId) override; 34 35 int32_t SetParameters(int32_t streamId, 36 const OHOS::HDI::DistributedAudio::Audioext::V2_0::AudioParameter ¶m) override; 37 38 int32_t NotifyEvent(int32_t streamId, 39 const OHOS::HDI::DistributedAudio::Audioext::V2_0::DAudioEvent &event) override; 40 41 int32_t WriteStreamData(int32_t streamId, 42 const OHOS::HDI::DistributedAudio::Audioext::V2_0::AudioData &data) override; 43 44 int32_t ReadStreamData(int32_t streamId, 45 OHOS::HDI::DistributedAudio::Audioext::V2_0::AudioData &data) override; 46 47 int32_t ReadMmapPosition(int32_t streamId, uint64_t &frames, 48 OHOS::HDI::DistributedAudio::Audioext::V2_0::CurrentTime &time) override; 49 50 int32_t RefreshAshmemInfo(int32_t streamId, int fd, int32_t ashmemLength, int32_t lengthPerTrans) override; 51 52 private: 53 int32_t GetAudioParamHDF(const OHOS::HDI::DistributedAudio::Audioext::V2_0::AudioParameter& param, 54 AudioParamHDF& paramHDF); 55 56 private: 57 std::shared_ptr<IDAudioHdiCallback> callback_; 58 }; 59 } // DistributedHardware 60 } // OHOS 61 #endif // OHOS_DAUDIO_MANAGER_CALLBACK_H 62