2 * Copyright (c) 2021 Samsung Electronics Co., Ltd All Rights Reserved
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 * http://www.apache.org/licenses/LICENSE-2.0
7 * Unless required by applicable law or agreed to in writing, software
8 * distributed under the License is distributed on an "AS IS" BASIS,
9 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
10 * See the License for the specific language governing permissions and
11 * limitations under the License.
15 #ifndef __TTSD_PLAYER_MANAGER_H_
16 #define __TTSD_PLAYER_MANAGER_H_
20 #include <condition_variable>
27 typedef void (*PlayUtteranceCallback)(PlayerThread* player_instance, unsigned int uid);
29 PlayerThread(PlayUtteranceCallback threadFucntion);
32 unsigned int getCurrentUid();
33 bool isCurrentUid(unsigned int uid);
35 void requestPlay(unsigned int uid);
38 static void runThread(PlayerThread* player);
41 void tryToStopPlayer();
42 bool isPlayerAvailable();
43 bool isThreadStopped();
46 std::atomic<unsigned int> __currentUid;
47 std::atomic<bool> __playerAvailable;
49 std::thread __playerThread;
50 std::mutex __threadMutex;
51 std::mutex __controlMutex;
52 std::mutex __stopCheckMutex;
53 std::condition_variable __threadCond;
54 std::condition_variable __stopCheckCond;
56 PlayUtteranceCallback __playUtterance;
60 #endif /* __TTSD_PLAYER_MANAGER_H_ */