1 /* 2 * Copyright (c) 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 #ifndef AUDIO_PLAYBACK_ENGINE_H 16 #define AUDIO_PLAYBACK_ENGINE_H 17 #include <memory> 18 #include "i_audio_engine.h" 19 #include "i_renderer_stream.h" 20 #include "audio_renderer_sink.h" 21 #include "audio_thread_task.h" 22 23 namespace OHOS { 24 namespace AudioStandard { 25 class AudioPlaybackEngine : public IAudioEngine { 26 public: 27 AudioPlaybackEngine(); 28 virtual ~AudioPlaybackEngine() override; 29 virtual int32_t AddRenderer(const std::shared_ptr<IRendererStream> &stream); 30 virtual void RemoveRenderer(const std::shared_ptr<IRendererStream> &stream); 31 32 virtual int32_t Init(const DeviceInfo &type, bool isVoip) override; 33 virtual int32_t Start() override; 34 virtual int32_t Stop() override; 35 virtual int32_t Pause() override; 36 virtual int32_t Flush() override; 37 38 virtual bool IsPlaybackEngineRunning() const noexcept override; 39 40 protected: MixStreams()41 virtual void MixStreams() {} 42 43 protected: 44 IAudioRendererSink *renderSink_; 45 std::unique_ptr<AudioThreadTask> playbackThread_; 46 std::vector<std::shared_ptr<IRendererStream>> streams_; 47 }; 48 } // namespace AudioStandard 49 } // namespace OHOS 50 #endif 51