Move volume vconf set to pulseaudio
[platform/core/multimedia/libmm-sound.git] / include / mm_sound_common.h
1 /*
2  * libmm-sound
3  *
4  * Copyright (c) 2000 - 2011 Samsung Electronics Co., Ltd. All rights reserved.
5  *
6  * Contact: Seungbae Shin <seungbae.shin@samsung.com>
7  *
8  * Licensed under the Apache License, Version 2.0 (the "License");
9  * you may not use this file except in compliance with the License.
10  * You may obtain a copy of the License at
11  *
12  * http://www.apache.org/licenses/LICENSE-2.0
13  *
14  * Unless required by applicable law or agreed to in writing, software
15  * distributed under the License is distributed on an "AS IS" BASIS,
16  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
17  * See the License for the specific language governing permissions and
18  * limitations under the License.
19  *
20  */
21
22 #ifndef __MM_SOUND_COMMON_H__
23 #define __MM_SOUND_COMMON_H__
24
25 #include <errno.h>
26
27 #define PA_READY "/tmp/.pa_ready"
28 #define SOUND_SERVER_READY "/tmp/.sound_server_ready"
29 #define FOCUS_SERVER_READY "/tmp/.focus_server_ready"
30
31 #define MMSOUND_ENTER_CRITICAL_SECTION(x_mutex) \
32 switch ( pthread_mutex_lock( x_mutex ) ) \
33 { \
34 case EINVAL: \
35         debug_warning("try mutex init..\n"); \
36         if( 0 > pthread_mutex_init( x_mutex, NULL) ) { \
37                 return; \
38         } else { \
39                 break; \
40         } \
41         return; \
42 case 0: \
43         break; \
44 default: \
45         debug_error("mutex lock failed\n"); \
46         return; \
47 }
48
49 #define MMSOUND_ENTER_CRITICAL_SECTION_WITH_RETURN(x_mutex,x_return) \
50 switch ( pthread_mutex_lock( x_mutex ) ) \
51 { \
52 case EINVAL: \
53         debug_warning("try mutex init..\n"); \
54         if( 0 > pthread_mutex_init( x_mutex, NULL) ) { \
55                 return x_return; \
56         } else { \
57                 break; \
58         } \
59         return x_return; \
60 case 0: \
61         break; \
62 default: \
63         debug_error("mutex lock failed\n"); \
64         return x_return; \
65 }
66
67 #define MMSOUND_LEAVE_CRITICAL_SECTION(x_mutex) \
68 if( pthread_mutex_unlock( x_mutex ) ) { \
69         debug_error("mutex unlock failed\n"); \
70 }
71
72 #define MMSOUND_STRNCPY(dst, src, size) \
73 do { \
74         if (dst == NULL) \
75                 debug_error("STRNCPY ERROR: Destination String is NULL"); \
76         else if (src == NULL) \
77                 debug_error("STRNCPY ERROR: Source String is NULL"); \
78         else if (size <= 0) \
79                 debug_error("STRNCPY ERROR: Size(%d) <= 0", size); \
80         else { \
81                 strncpy(dst, src, size - 1); \
82                 dst[size - 1] = '\0';\
83         } \
84 } while(0)
85
86 #endif /* __MM_SOUND_COMMON_H__ */
87