Fix float->int(short) clipping issue when playing ogg content
[platform/core/multimedia/libmm-sound.git] / include / mm_sound_common.h
index 84d9d27..ef977aa 100644 (file)
@@ -1,83 +1,85 @@
-/*\r
- * libmm-sound\r
- *\r
- * Copyright (c) 2000 - 2011 Samsung Electronics Co., Ltd. All rights reserved.\r
- *\r
- * Contact: Seungbae Shin <seungbae.shin@samsung.com>\r
- *\r
- * Licensed under the Apache License, Version 2.0 (the "License");\r
- * you may not use this file except in compliance with the License.\r
- * You may obtain a copy of the License at\r
- *\r
- * http://www.apache.org/licenses/LICENSE-2.0\r
- *\r
- * Unless required by applicable law or agreed to in writing, software\r
- * distributed under the License is distributed on an "AS IS" BASIS,\r
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\r
- * See the License for the specific language governing permissions and\r
- * limitations under the License.\r
- *\r
- */\r
-\r
-#ifndef __MM_SOUND_COMMON_H__\r
-#define __MM_SOUND_COMMON_H__\r
-\r
-///////////////////////////////////\r
-////     MMSOUND VOLUME APIs\r
-///////////////////////////////////\r
-#define VCONF_KEY_VOLUME_PREFIX                                "file/private/sound/volume"\r
-#define VCONF_KEY_VOLUME_TYPE_SYSTEM           VCONF_KEY_VOLUME_PREFIX"/system"\r
-#define VCONF_KEY_VOLUME_TYPE_NOTIFICATION     VCONF_KEY_VOLUME_PREFIX"/notification"\r
-#define VCONF_KEY_VOLUME_TYPE_ALARM                    VCONF_KEY_VOLUME_PREFIX"/alarm"\r
-#define VCONF_KEY_VOLUME_TYPE_RINGTONE         VCONF_KEY_VOLUME_PREFIX"/ringtone"\r
-#define VCONF_KEY_VOLUME_TYPE_MEDIA                    VCONF_KEY_VOLUME_PREFIX"/media"\r
-#define VCONF_KEY_VOLUME_TYPE_CALL                     VCONF_KEY_VOLUME_PREFIX"/call"\r
-#define VCONF_KEY_VOLUME_TYPE_VOIP                     VCONF_KEY_VOLUME_PREFIX"/voip"\r
-#define VCONF_KEY_VOLUME_TYPE_ANDROID          VCONF_KEY_VOLUME_PREFIX"/fixed"\r
-#define VCONF_KEY_VOLUME_TYPE_JAVA                     VCONF_KEY_VOLUME_PREFIX"/java"\r
-\r
-#define ASM_READY_KEY          "memory/Sound/ASMReady"\r
-\r
-#define MMSOUND_ENTER_CRITICAL_SECTION(x_mutex) \\r
-switch ( pthread_mutex_lock( x_mutex ) ) \\r
-{ \\r
-case EINVAL: \\r
-       debug_warning("try mutex init..\n"); \\r
-       if( 0 > pthread_mutex_init( x_mutex, NULL) ) { \\r
-               return; \\r
-       } else { \\r
-               break; \\r
-       } \\r
-       return; \\r
-case 0: \\r
-       break; \\r
-default: \\r
-       debug_error("mutex lock failed\n"); \\r
-       return; \\r
-}\r
-\r
-#define MMSOUND_ENTER_CRITICAL_SECTION_WITH_RETURN(x_mutex,x_return) \\r
-switch ( pthread_mutex_lock( x_mutex ) ) \\r
-{ \\r
-case EINVAL: \\r
-       debug_warning("try mutex init..\n"); \\r
-       if( 0 > pthread_mutex_init( x_mutex, NULL) ) { \\r
-               return x_return; \\r
-       } else { \\r
-               break; \\r
-       } \\r
-       return x_return; \\r
-case 0: \\r
-       break; \\r
-default: \\r
-       debug_error("mutex lock failed\n"); \\r
-       return x_return; \\r
-}\r
-\r
-#define MMSOUND_LEAVE_CRITICAL_SECTION(x_mutex) \\r
-if( pthread_mutex_unlock( x_mutex ) ) { \\r
-       debug_error("mutex unlock failed\n"); \\r
-}\r
-\r
-#endif /* __MM_SOUND_COMMON_H__ */\r
-\r
+/*
+ * libmm-sound
+ *
+ * Copyright (c) 2000 - 2011 Samsung Electronics Co., Ltd. All rights reserved.
+ *
+ * Contact: Seungbae Shin <seungbae.shin@samsung.com>
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ */
+
+#ifndef __MM_SOUND_COMMON_H__
+#define __MM_SOUND_COMMON_H__
+
+#include <errno.h>
+
+#define PA_READY "/tmp/.pa_ready"
+#define SOUND_SERVER_READY "/tmp/.sound_server_ready"
+#define FOCUS_SERVER_READY "/tmp/.focus_server_ready"
+
+#define MMSOUND_ENTER_CRITICAL_SECTION(x_mutex) \
+switch (pthread_mutex_lock(x_mutex)) { \
+case EINVAL: \
+       debug_warning("try mutex init.."); \
+       if (0 > pthread_mutex_init(x_mutex, NULL)) { \
+               return; \
+       } else { \
+               break; \
+       } \
+       return; \
+case 0: \
+       break; \
+default: \
+       debug_error("mutex lock failed"); \
+       return; \
+}
+
+#define MMSOUND_ENTER_CRITICAL_SECTION_WITH_RETURN(x_mutex, x_return) \
+switch (pthread_mutex_lock(x_mutex)) { \
+case EINVAL: \
+       debug_warning("try mutex init.."); \
+       if (0 > pthread_mutex_init(x_mutex, NULL)) { \
+               return x_return; \
+       } else { \
+               break; \
+       } \
+       return x_return; \
+case 0: \
+       break; \
+default: \
+       debug_error("mutex lock failed"); \
+       return x_return; \
+}
+
+#define MMSOUND_LEAVE_CRITICAL_SECTION(x_mutex) \
+if (pthread_mutex_unlock(x_mutex)) { \
+       debug_error("mutex unlock failed"); \
+}
+
+#define MMSOUND_STRNCPY(dst, src, size) \
+do { \
+       if (dst == NULL) \
+               debug_error("STRNCPY ERROR: Destination String is NULL"); \
+       else if (src == NULL) \
+               debug_error("STRNCPY ERROR: Source String is NULL"); \
+       else if (size <= 0) \
+               debug_error("STRNCPY ERROR: Size(%d) <= 0", size); \
+       else { \
+               strncpy(dst, src, size - 1); \
+               dst[size - 1] = '\0';\
+       } \
+} while (0)
+
+#endif /* __MM_SOUND_COMMON_H__ */
+