1 /* 2 * Copyright (c) 2021-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 AUDIO_RENDERER_SINK_H 17 #define AUDIO_RENDERER_SINK_H 18 19 #include "audio_info.h" 20 #include "audio_proxy_manager.h" 21 22 #include <cstdio> 23 #include <list> 24 25 namespace OHOS { 26 namespace AudioStandard { 27 typedef struct { 28 AudioFormat format; 29 uint32_t sampleFmt; 30 uint32_t sampleRate; 31 uint32_t channel; 32 float volume; 33 } AudioSinkAttr; 34 35 class AudioRendererSink { 36 public: 37 int32_t Init(AudioSinkAttr &atrr); 38 void DeInit(void); 39 int32_t Start(void); 40 int32_t Stop(void); 41 int32_t Flush(void); 42 int32_t Reset(void); 43 int32_t Pause(void); 44 int32_t Resume(void); 45 int32_t RenderFrame(char &frame, uint64_t len, uint64_t &writeLen); 46 int32_t SetVolume(float left, float right); 47 int32_t GetVolume(float &left, float &right); 48 int32_t GetLatency(uint32_t *latency); 49 int32_t SetAudioScene(AudioScene audioScene); 50 int32_t OpenOutput(DeviceType deviceType); 51 static AudioRendererSink *GetInstance(void); 52 bool rendererInited_; 53 private: 54 AudioRendererSink(); 55 ~AudioRendererSink(); 56 AudioSinkAttr attr_; 57 bool started_; 58 bool paused_; 59 float leftVolume_; 60 float rightVolume_; 61 int32_t routeHandle_ = -1; 62 struct AudioProxyManager *audioManager_; 63 struct AudioAdapter *audioAdapter_; 64 struct AudioRender *audioRender_; 65 struct AudioPort audioPort_; 66 67 int32_t CreateRender(struct AudioPort &renderPort); 68 int32_t InitAudioManager(); 69 int32_t GetAndLoadAdapter(void); 70 #ifdef DUMPFILE 71 FILE *pfd; 72 #endif // DUMPFILE 73 }; 74 } // namespace AudioStandard 75 } // namespace OHOS 76 #endif // AUDIO_RENDERER_SINK_H 77