Arduino AudioKit HAL
audio_mutex.h
1 /*
2  * ESPRESSIF MIT License
3  *
4  * Copyright (c) 2018 <ESPRESSIF SYSTEMS (SHANGHAI) PTE LTD>
5  *
6  * Permission is hereby granted for use on all ESPRESSIF SYSTEMS products, in which case,
7  * it is free of charge, to any person obtaining a copy of this software and associated
8  * documentation files (the "Software"), to deal in the Software without restriction, including
9  * without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense,
10  * and/or sell copies of the Software, and to permit persons to whom the Software is furnished
11  * to do so, subject to the following conditions:
12  *
13  * The above copyright notice and this permission notice shall be included in all copies or
14  * substantial portions of the Software.
15  *
16  * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
17  * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS
18  * FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
19  * COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
20  * IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
21  * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
22  *
23  */
24 
25 #ifndef __AUDIO_MUTEX_H__
26 #define __AUDIO_MUTEX_H__
27 
28 #ifdef __cplusplus
29 extern "C" {
30 #endif
31 
32 /**
33  * @brief Create a mutex instance
34  *
35  * @return - Others: A mutex handle is returned
36  * - NULL: Failed to create mutex
37  */
38 void *mutex_create(void);
39 
40 /**
41  * @brief Delete the mutex instance
42  *
43  * @param mutex The pointer to mutex handle
44  *
45  * @return - 0: Success to delete mutex
46  */
47 int mutex_destroy(void *mutex);
48 
49 /**
50  * @brief Take the mutex
51  *
52  * @param mutex The pointer to mutex handle
53  *
54  * @return - 0: The lock was obtained
55  */
56 int mutex_lock(void *mutex);
57 
58 /**
59  * @brief Release the mutex
60  *
61  * @param mutex The pointer to mutex handle
62  *
63  * @return - 0: The lock was released
64  */
65 int mutex_unlock(void *mutex);
66 
67 #ifdef __cplusplus
68 }
69 #endif
70 
71 #endif /* #ifndef __AUDIO_MUTEX_H__ */