Rebase code with tizen 2.3 with following additional changes
[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 ///////////////////////////////////
26 ////     MMSOUND VOLUME APIs
27 ///////////////////////////////////
28 #define VCONF_KEY_VOLUME_PREFIX                         "file/private/sound/volume"
29 #define VCONF_KEY_VOLUME_TYPE_SYSTEM            VCONF_KEY_VOLUME_PREFIX"/system"
30 #define VCONF_KEY_VOLUME_TYPE_NOTIFICATION      VCONF_KEY_VOLUME_PREFIX"/notification"
31 #define VCONF_KEY_VOLUME_TYPE_ALARM                     VCONF_KEY_VOLUME_PREFIX"/alarm"
32 #define VCONF_KEY_VOLUME_TYPE_RINGTONE          VCONF_KEY_VOLUME_PREFIX"/ringtone"
33 #define VCONF_KEY_VOLUME_TYPE_MEDIA                     VCONF_KEY_VOLUME_PREFIX"/media"
34 #define VCONF_KEY_VOLUME_TYPE_CALL                      VCONF_KEY_VOLUME_PREFIX"/call"
35 #define VCONF_KEY_VOLUME_TYPE_VOIP                      VCONF_KEY_VOLUME_PREFIX"/voip"
36 #define VCONF_KEY_VOLUME_TYPE_VOICE             VCONF_KEY_VOLUME_PREFIX"/voice"
37 #define VCONF_KEY_VOLUME_TYPE_ANDROID           VCONF_KEY_VOLUME_PREFIX"/fixed"
38
39 #define VCONF_KEY_VOLUME_BALANCE                        VCONF_KEY_VOLUME_PREFIX"/balance"
40 #define VCONF_KEY_MUTE_ALL                              VCONF_KEY_VOLUME_PREFIX"/muteall"
41 #define VCONF_KEY_MONO_AUDIO                            VCONFKEY_SETAPPL_ACCESSIBILITY_MONO_AUDIO
42
43 #define VCONFKEY_SOUND_PRIMARY_VOLUME_TYPE              "memory/private/sound/PrimaryVolumetype"
44 #define VCONFKEY_SOUND_PRIMARY_VOLUME_TYPE_FORCE        "memory/private/sound/PrimaryVolumetypeForce"
45
46
47 #ifndef _TIZEN_PUBLIC_
48 #define VCONF_KEY_NOISE_REDUCTION                       VCONFKEY_CALL_NOISE_REDUCTION_STATE_BOOL
49 #define VCONF_KEY_EXTRA_VOLUME                          VCONFKEY_CALL_EXTRA_VOLUME_STATE_BOOL
50 #define VCONF_KEY_WBAMR                                         VCONFKEY_CALL_WBAMR_STATE_BOOL
51 #define VCONF_KEY_VR_ENABLED                            VCONFKEY_VOICE_CONTROL_ENABLED
52 #define VCONF_KEY_VR_RINGTONE_ENABLED           VCONFKEY_VOICE_CONTROL_INCOMING_CALL_ENABLED
53 #ifdef TIZEN_MICRO
54 #define VCONF_KEY_VR_LEFTHAND_ENABLED           VCONFKEY_SETAPPL_PERFERED_ARM_LEFT_BOOL
55 #endif
56 #endif
57 #define ASM_READY_KEY           "memory/private/Sound/ASMReady"
58 #define VCONF_KEY_FMRADIO_RECORDING     "memory/private/Sound/FMRadioRecording"
59
60 #define PA_READY "/tmp/.pa_ready"
61
62 #define MMSOUND_ENTER_CRITICAL_SECTION(x_mutex) \
63 switch ( pthread_mutex_lock( x_mutex ) ) \
64 { \
65 case EINVAL: \
66         debug_warning("try mutex init..\n"); \
67         if( 0 > pthread_mutex_init( x_mutex, NULL) ) { \
68                 return; \
69         } else { \
70                 break; \
71         } \
72         return; \
73 case 0: \
74         break; \
75 default: \
76         debug_error("mutex lock failed\n"); \
77         return; \
78 }
79
80 #define MMSOUND_ENTER_CRITICAL_SECTION_WITH_RETURN(x_mutex,x_return) \
81 switch ( pthread_mutex_lock( x_mutex ) ) \
82 { \
83 case EINVAL: \
84         debug_warning("try mutex init..\n"); \
85         if( 0 > pthread_mutex_init( x_mutex, NULL) ) { \
86                 return x_return; \
87         } else { \
88                 break; \
89         } \
90         return x_return; \
91 case 0: \
92         break; \
93 default: \
94         debug_error("mutex lock failed\n"); \
95         return x_return; \
96 }
97
98 #define MMSOUND_LEAVE_CRITICAL_SECTION(x_mutex) \
99 if( pthread_mutex_unlock( x_mutex ) ) { \
100         debug_error("mutex unlock failed\n"); \
101 }
102
103 #define MMSOUND_STRNCPY(dst,src,size)\
104 do { \
105         if(src != NULL && dst != NULL && size > 0) {\
106                 strncpy(dst,src,size); \
107                 dst[size-1] = '\0';\
108         } else if(dst == NULL) {       \
109                 debug_error("STRNCPY ERROR: Destination String is NULL\n"); \
110         }       \
111         else if(size <= 0) {      \
112                 debug_error("STRNCPY ERROR: Destination String is NULL\n"); \
113         }       \
114         else {    \
115                 debug_error("STRNCPY ERROR: Destination String is NULL\n"); \
116         }       \
117 } while(0)
118
119 #endif /* __MM_SOUND_COMMON_H__ */
120