• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * Copyright (C) 2025 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_RENDERER_MANAGER_H
16 #define AUDIO_RENDERER_MANAGER_H
17 
18 #include <unistd.h>
19 #include <list>
20 #include <utility>
21 #include "media_log.h"
22 #include "media_errors.h"
23 #include "media_dfx.h"
24 #include "audio_renderer.h"
25 #include "soundpool_xcollie.h"
26 #include "parallel_stream_manager.h"
27 #include "stream_id_manager.h"
28 
29 namespace OHOS {
30 namespace Media {
31 
32 class AudioRendererManager {
33 public:
34     AudioRendererManager(const AudioRendererManager&) = delete;
35     AudioRendererManager& operator = (const AudioRendererManager&) = delete;
36     ~AudioRendererManager();
37 
38     static AudioRendererManager& GetInstance();
39     int32_t GetGlobalId();
40     std::unique_ptr<AudioStandard::AudioRenderer> GetAudioRendererInstance(int32_t globalId);
41     void SetAudioRendererInstance(int32_t globalId, std::unique_ptr<AudioStandard::AudioRenderer> audioRenderer);
42     void RemoveOldAudioRenderer();
43     void SetParallelManager(std::weak_ptr<ParallelStreamManager> parallelManager);
44     void SetStreamIDManager(std::weak_ptr<StreamIDManager> streamIDManager);
45     void DelAudioRenderer(int32_t globalId);
46 
47 private:
AudioRendererManager()48     AudioRendererManager() {}
49     void DeleteManager(int32_t globalId);
50     std::mutex renderMgrMutex_;
51     int32_t globalIdNext_ = 0;
52     std::list<std::pair<int32_t, std::unique_ptr<AudioStandard::AudioRenderer>>> audioRendererVector_;
53     std::list<std::weak_ptr<ParallelStreamManager>> parallelManagerList_;
54     std::list<std::weak_ptr<StreamIDManager>> streamIDManagerList_;
55 };
56 } // namespace Media
57 } // namespace OHOS
58 #endif // AUDIO_RENDERER_MANAGER_H
59