• 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 
16 #ifndef AUDIO_WORKGROUP_H
17 #define AUDIO_WORKGROUP_H
18 
19 #include <vector>
20 #include <unordered_map>
21 #include "audio_manager_base.h"
22 
23 namespace OHOS {
24 namespace AudioStandard {
25 
26 class AudioWorkgroupCallbackForMonitor {
27 public:
28     virtual ~AudioWorkgroupCallbackForMonitor() = default;
29     virtual void OnWorkgroupChange(const AudioWorkgroupChangeInfo &info) = 0;
30 };
31 
32 class AudioWorkgroup {
33 public:
34     explicit AudioWorkgroup(int32_t id);
~AudioWorkgroup()35     ~AudioWorkgroup() {};
36 
37     int32_t GetWorkgroupId();
38     uint32_t GetThreadsNums();
39     int32_t AddThread(int32_t tid);
40     int32_t RemoveThread(int32_t tid);
41     int32_t Start(uint64_t startTime, uint64_t deadlineTime);
42     int32_t Stop();
43     std::shared_ptr<AudioWorkgroupCallbackForMonitor> callback;
44 
45 private:
46     int32_t workgroupId;
47     std::unordered_map<int32_t, bool> threads;
48 };
49 
50 } // namespace AudioStandard
51 } // namespace OHOS
52 
53 #endif