2 * Copyright (c) 2023 Samsung Electronics Co., Ltd All Rights Reserved
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
8 * http://www.apache.org/licenses/LICENSE-2.0
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
20 #include <sys/types.h>
22 #ifndef __TIZEN_MEDIA_AUDIO_IO_CAUDIOLOCKER_H__
23 #define __TIZEN_MEDIA_AUDIO_IO_CAUDIOLOCKER_H__
27 using namespace std::literals::chrono_literals;
29 namespace tizen_media_audio {
31 constexpr auto mutex_timeout_s = 4s;
33 class CAudioTimedLocker {
35 explicit CAudioTimedLocker(const std::string& tag);
36 CAudioTimedLocker(const std::string& tag, std::timed_mutex& m,
37 std::chrono::seconds timeout = mutex_timeout_s);
38 virtual ~CAudioTimedLocker();
40 void lock(std::timed_mutex& m,
41 std::chrono::seconds timeout = mutex_timeout_s);
45 void updateHolder(const std::string& tag, pid_t tid);
47 std::unique_lock<std::timed_mutex> _lock;
50 static std::string _holder;
56 } /* namespace tizen_media_audio */
59 #endif /* __TIZEN_MEDIA_AUDIO_IO_CAUDIOLOCKER_H__ */