• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
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_thread_task.h"
21 
22 namespace OHOS {
23 namespace AudioStandard {
24 class AudioPlaybackEngine : public IAudioEngine {
25 public:
26     AudioPlaybackEngine();
27     virtual ~AudioPlaybackEngine() override;
28     virtual int32_t AddRenderer(const std::shared_ptr<IRendererStream> &stream);
29     virtual void RemoveRenderer(const std::shared_ptr<IRendererStream> &stream);
30 
31     virtual int32_t Init(const AudioDeviceDescriptor &type, bool isVoip) override;
32     virtual int32_t Start() override;
33     virtual int32_t Stop() override;
34     virtual int32_t Pause() override;
35     virtual int32_t Flush() override;
36     virtual uint64_t GetLatency() noexcept override;
37 
38     virtual bool IsPlaybackEngineRunning() const noexcept override;
39 
40 protected:
MixStreams()41     virtual void MixStreams() {}
42 
43 protected:
44     uint32_t renderId_;
45     std::unique_ptr<AudioThreadTask> playbackThread_;
46     std::vector<std::shared_ptr<IRendererStream>> streams_;
47 };
48 } // namespace AudioStandard
49 } // namespace OHOS
50 #endif
51