wav-player : Change APIs based on Tizen 2.3 53/33953/1 tizen_3.0.2014.q4_common tizen_3.0.2015.q1_common tizen_3.0.2015.q2_common accepted/tizen/common/20150122.095546 accepted/tizen/mobile/20150123.091440 accepted/tizen/tv/20150123.004446 accepted/tizen/wearable/20150122.104137 submit/tizen/20150115.120604 submit/tizen/20150122.071700
authordh8210.kim <dh8210.kim@samsung.com>
Mon, 19 Jan 2015 06:09:08 +0000 (15:09 +0900)
committerdh8210.kim <dh8210.kim@samsung.com>
Mon, 19 Jan 2015 06:09:31 +0000 (15:09 +0900)
Signed-off-by: dh8210.kim <dh8210.kim@samsung.com>
Change-Id: I7719e96bf44bc0098b649ea066d8dc342a0347ae

AUTHORS
CMakeLists.txt
doc/wave_player_doc.h [new file with mode: 0755]
include/wav_player_private.h [new file with mode: 0755]
packaging/capi-media-wav-player.spec [changed mode: 0644->0755]
src/wav_player.c
src/wav_player_private.c [new file with mode: 0755]

diff --git a/AUTHORS b/AUTHORS
index 0c10a61..78092f0 100755 (executable)
--- a/AUTHORS
+++ b/AUTHORS
@@ -1,3 +1,2 @@
-Seungkeun Lee <sngn.lee@samsung.com>
-Kangho Hur <kanho.hur@samsung.com>
 Seungbae Shin <seungbae.shin at samsung dot com>
+Doohwan Kim <dh8210.kim at samsung dot com>
index d84f1f0..12a3ed3 100755 (executable)
@@ -44,7 +44,7 @@ FOREACH(flag ${${fw_name}_CFLAGS})
     SET(EXTRA_CFLAGS "${EXTRA_CFLAGS} ${flag}")
 ENDFOREACH(flag)
 
-SET(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} ${EXTRA_CFLAGS} -fPIC -Wall -Werror")
+SET(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} ${EXTRA_CFLAGS} -fPIC -Wall")
 SET(CMAKE_C_FLAGS_DEBUG "-O0 -g")
 
 IF("${ARCH}" MATCHES "^arm.*")
diff --git a/doc/wave_player_doc.h b/doc/wave_player_doc.h
new file mode 100755 (executable)
index 0000000..3660786
--- /dev/null
@@ -0,0 +1,47 @@
+/*
+ * Copyright (c) 2011 Samsung Electronics Co., Ltd All Rights Reserved
+ *
+ * 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 __TIZEN_MEDIA_WAV_PLAYER_DOC_H__
+#define __TIZEN_MEDIA_WAV_PLAYER_DOC_H__
+
+
+/**
+ * @file wave_player_doc.h
+ * @brief This file contains high level documentation for the WAV Player API.
+ *
+ */
+
+/**
+ * @ingroup CAPI_MEDIA_FRAMEWORK
+ * @defgroup CAPI_MEDIA_WAV_PLAYER_MODULE WAV Player
+ */
+
+/**
+ * @ingroup CAPI_MEDIA_FRAMEWORK
+ * @addtogroup CAPI_MEDIA_WAV_PLAYER_MODULE
+ * @brief The @ref CAPI_MEDIA_WAV_PLAYER_MODULE API provides functions for playing the waveform audio file format(*.wav).
+  * @section CAPI_MEDIA_WAV_PLAYER_MODULE_HEADER Required Header
+ *    \#include <wav_player.h>
+ *
+ * @section CAPI_MEDIA_WAV_PLAYER_OVERVIEW Overview
+ * The @ref CAPI_MEDIA_WAV_PLAYER_MODULE API allows you to simply play and stop a wav file. To play a certain wav file, call wave_player_start() with a path to the .wav file. 
+ * When playing a wav file is finished, wav_player_playback_completed_cb() will be invoked.
+ */
+
+#endif /* __TIZEN_MEDIA_WAV_PLAYER_DOC_H__ */
+
+
diff --git a/include/wav_player_private.h b/include/wav_player_private.h
new file mode 100755 (executable)
index 0000000..e6458b6
--- /dev/null
@@ -0,0 +1,59 @@
+/*
+* Copyright (c) 2011 Samsung Electronics Co., Ltd All Rights Reserved
+*
+* 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 __TIZEN_MEDIA_WAV_PLAYER_PRIVATE_H__
+#define __TIZEN_MEDIA_WAV_PLAYER_PRIVATE_H__
+
+#include <tizen.h>
+#include <sound_manager.h>
+#include <sound_manager_internal.h>
+#include <wav_player.h>
+
+#ifdef __cplusplus
+extern "C"
+{
+#endif
+
+#define WAV_PLAYER_ERROR_CLASS          TIZEN_ERROR_MULTIMEDIA_CLASS | 0x50
+
+/**
+ * @file wav_player_private.h
+ * @brief This file contains the WAV player API
+ */
+
+/**
+ * @addtogroup CAPI_MEDIA_WAV_PLAYER_MODULE
+ * @{
+ */
+
+
+typedef struct _cb_data_{
+       wav_player_playback_completed_cb cb;
+       void * user_data;
+} _cb_data;
+
+/**
+ * @}
+ */
+
+#ifdef __cplusplus
+}
+#endif
+
+int __convert_wav_player_error_code(const char *func, int code);
+void __internal_complete_cb(void *user_data, int id);
+
+#endif /* __TIZEN_MEDIA_WAV_PLAYER_PRIVATE_H__ */
old mode 100644 (file)
new mode 100755 (executable)
index 7b882db..8009c3c
@@ -1,6 +1,6 @@
 Name:       capi-media-wav-player
 Summary:    A wav player library in Tizen C API
-Version:    0.1.0
+Version:    0.1.1
 Release:    0
 Group:      Multimedia/API
 License:    Apache-2.0
index eebede9..70afc9a 100755 (executable)
 #include <string.h>
 #include <unistd.h>
 #include <dlog.h>
-#include <wav_player.h>
+#include "wav_player.h"
+#include "wav_player_private.h"
 #include <stdlib.h>
 
 
-typedef struct _cb_data_{
-       wav_player_playback_completed_cb cb;
-       void * uesr_data;
-       int id;
-} _cb_data;
-
-
-
-static int __convert_wav_player_error_code(const char *func, int code){
-       int ret = WAV_PLAYER_ERROR_INVALID_OPERATION;
-       char *errorstr = NULL;
-       switch(code)
-       {
-               case MM_ERROR_NONE:
-                       ret = WAV_PLAYER_ERROR_NONE;
-                       errorstr = "ERROR_NONE";
-                       break;
-               case MM_ERROR_INVALID_ARGUMENT: 
-               case MM_ERROR_SOUND_INVALID_POINTER:
-               case WAV_PLAYER_ERROR_INVALID_PARAMETER:                        
-                       ret = WAV_PLAYER_ERROR_INVALID_PARAMETER;
-                       errorstr = "INVALID_PARAMETER";                 
-                       break;
-               case MM_ERROR_SOUND_INTERNAL:
-                       ret = WAV_PLAYER_ERROR_INVALID_OPERATION;
-                       errorstr = "INVALID_OPERATION";                 
-                       break;
-               case MM_ERROR_SOUND_UNSUPPORTED_MEDIA_TYPE:
-                       ret = WAV_PLAYER_ERROR_FORMAT_NOT_SUPPORTED;
-                       errorstr = "FORMAT_NOT_SUPPORTED";
-                       break;
-               default:
-                       ret = WAV_PLAYER_ERROR_INVALID_OPERATION;
-                       errorstr = "INVALID_OPERATION";
-                       
-       }       
-       LOGE( "[%s] %s(0x%08x)",func, errorstr, ret);
-       return ret;
-}
-
-
-static void __internal_complete_cb(void *user_data){
-       _cb_data * cb_data = (_cb_data*)user_data;
-       if(!cb_data)
-               return;
-       
-       if( cb_data->cb )
-               cb_data->cb(cb_data->id, cb_data->uesr_data);
-       free(cb_data);  
-}
-
-
-int wav_player_start(const char *path,  sound_type_e type , wav_player_playback_completed_cb cb, void *user_data,  int * id){
-       int ret ; 
-       int player;
+int wav_player_start(const char *path, sound_type_e type, wav_player_playback_completed_cb cb, void *user_data,  int * id)
+{
+       int ret = MM_ERROR_NONE;
+       int player = -1;
        char m_path[PATH_MAX];
-       void (*_completed_cb)(void *);
+       void (*_completed_cb)(void *, int);
        _completed_cb = NULL;
        _cb_data *cb_data = NULL;
-       
-       
+
+
        if( path == NULL)
                return __convert_wav_player_error_code(__func__, WAV_PLAYER_ERROR_INVALID_PARAMETER);
 
-       if( type < SOUND_TYPE_SYSTEM || type >  SOUND_TYPE_CALL )
+       if( type < SOUND_TYPE_SYSTEM || type >= SOUND_TYPE_NUM )
                return __convert_wav_player_error_code(__func__, WAV_PLAYER_ERROR_INVALID_PARAMETER);
 
        m_path[0] = '\0';
@@ -110,23 +60,24 @@ int wav_player_start(const char *path,  sound_type_e type , wav_player_playback_
                if(cb_data == NULL )
                        return __convert_wav_player_error_code(__func__, WAV_PLAYER_ERROR_INVALID_OPERATION);
                cb_data->cb = cb;
-               cb_data->uesr_data = user_data;         
+               cb_data->user_data = user_data;
        }
-       
+
+
        ret = mm_sound_play_sound(m_path, type, _completed_cb , cb_data, &player);
-       if( ret == 0 && id != NULL)
-               *id = player;           
-       if( ret == 0 && cb_data )
-               cb_data->id = player;
-       
+
+       if( ret == 0 && id != NULL){
+               *id = player;
+       }
+
        if( ret != 0 && cb_data != NULL)
                free(cb_data);
 
-                       
        return __convert_wav_player_error_code(__func__, ret);
 }
 
-int wav_player_stop(int id){
+int wav_player_stop(int id)
+{
        return __convert_wav_player_error_code(__func__, mm_sound_stop_sound(id));
 }
 
diff --git a/src/wav_player_private.c b/src/wav_player_private.c
new file mode 100755 (executable)
index 0000000..b856fd5
--- /dev/null
@@ -0,0 +1,76 @@
+/*
+* Copyright (c) 2011 Samsung Electronics Co., Ltd All Rights Reserved
+*
+* 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.
+*/
+
+
+#define LOG_TAG "CAPI_MEDIA_WAV_PLAYER"
+
+#include <mm_sound.h>
+#include <mm_sound_private.h>
+#include <stdio.h>
+#include <limits.h>
+#include <string.h>
+#include <unistd.h>
+#include <dlog.h>
+#include <stdlib.h>
+#include "wav_player_private.h"
+
+int __convert_wav_player_error_code(const char *func, int code)
+{
+       int ret = WAV_PLAYER_ERROR_INVALID_OPERATION;
+       char *errorstr = NULL;
+       switch(code)
+       {
+               case MM_ERROR_NONE:
+                       ret = WAV_PLAYER_ERROR_NONE;
+                       errorstr = "ERROR_NONE";
+                       break;
+               case MM_ERROR_INVALID_ARGUMENT:
+               case MM_ERROR_SOUND_INVALID_POINTER:
+               case WAV_PLAYER_ERROR_INVALID_PARAMETER:
+                       ret = WAV_PLAYER_ERROR_INVALID_PARAMETER;
+                       errorstr = "INVALID_PARAMETER";
+                       break;
+               case MM_ERROR_SOUND_INTERNAL:
+                       ret = WAV_PLAYER_ERROR_INVALID_OPERATION;
+                       errorstr = "INVALID_OPERATION";
+                       break;
+               case MM_ERROR_SOUND_UNSUPPORTED_MEDIA_TYPE:
+                       ret = WAV_PLAYER_ERROR_FORMAT_NOT_SUPPORTED;
+                       errorstr = "FORMAT_NOT_SUPPORTED";
+                       break;
+               default:
+                       ret = WAV_PLAYER_ERROR_INVALID_OPERATION;
+                       errorstr = "INVALID_OPERATION";
+                       break;
+       }
+       LOGE( "[%s] %s(0x%08x)",func, errorstr, ret);
+       return ret;
+}
+
+
+void __internal_complete_cb(void *user_data, int id)
+{
+       _cb_data * cb_data = (_cb_data*)user_data;
+       if(!cb_data)
+               return;
+
+       if( cb_data->cb ){
+               LOGD( "user callback for handle %d call", id);
+               cb_data->cb(id, cb_data->user_data);
+       }
+       free(cb_data);
+}
+