• 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 HPAE_SIGNAL_PROCESS_THREAD_H
16 #define HPAE_SIGNAL_PROCESS_THREAD_H
17 #include <atomic>
18 #include <thread>
19 #include <condition_variable>
20 #include <mutex>
21 #include "hpae_stream_manager.h"
22 namespace OHOS {
23 namespace AudioStandard {
24 namespace HPAE {
25 class HpaeSignalProcessThread {
26 public:
HpaeSignalProcessThread()27     HpaeSignalProcessThread() : running_(false), recvSignal_(false)
28     {}
29     ~HpaeSignalProcessThread();
30     void ActivateThread(const std::weak_ptr<HpaeStreamManager>& streamManager);
31     void DeactivateThread();
32     void Notify();
33     void Run();
IsRunning()34     bool IsRunning() const
35     {
36         return running_.load();
37     }
IsMsgProcessing()38     bool IsMsgProcessing() const
39     {
40         return recvSignal_.load();
41     }
42 private:
43 
44     std::atomic<bool> running_;
45     std::atomic<bool> recvSignal_;
46     std::weak_ptr<HpaeStreamManager> streamManager_;
47     std::thread thread_;
48     std::condition_variable condition_;
49     std::mutex mutex_;
50 };
51 }  // namespace HPAE
52 }  // namespace AudioStandard
53 }  // namespace OHOS
54 #endif