From: jk7744.park Date: Tue, 8 Sep 2015 13:12:43 +0000 (+0900) Subject: tizen 2.3.1 release X-Git-Tag: submit/tizen_2.3.1/20150915.080041 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=refs%2Ftags%2Fsubmit%2Ftizen_2.3.1%2F20150915.080041;p=framework%2Fapi%2Fwav-player.git tizen 2.3.1 release --- diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..e62ee74 --- /dev/null +++ b/.gitignore @@ -0,0 +1,26 @@ +CMakeCache.txt +*/CMakeFiles/* +*.cmake +CMakeFiles* +*.a +*.so +Testing +cmake.depends +cmake.check_depends +cmake.check_cache +core +core.* +gmon.out +install_manifest.txt +*~ +.kdev_include_paths +src.kdev4 +.cproject +.project +tet_captured +tet_lock +*.pc +*-test +*-test_* +*tester.c +.gitattributes diff --git a/AUTHORS b/AUTHORS old mode 100755 new mode 100644 diff --git a/LICENSE b/LICENSE old mode 100755 new mode 100644 diff --git a/capi-media-wav-player.manifest b/capi-media-wav-player.manifest new file mode 100644 index 0000000..a76fdba --- /dev/null +++ b/capi-media-wav-player.manifest @@ -0,0 +1,5 @@ + + + + + diff --git a/doc/wave_player_doc.h b/doc/wave_player_doc.h new file mode 100644 index 0000000..3660786 --- /dev/null +++ b/doc/wave_player_doc.h @@ -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 + * + * @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.h b/include/wav_player.h old mode 100644 new mode 100755 index 39aa74e..db65bf5 --- a/include/wav_player.h +++ b/include/wav_player.h @@ -14,9 +14,6 @@ * limitations under the License. */ - - - #ifndef __TIZEN_MEDIA_WAV_PLAYER_H__ #define __TIZEN_MEDIA_WAV_PLAYER_H__ @@ -28,11 +25,9 @@ extern "C" { #endif -#define WAV_PLAYER_ERROR_CLASS TIZEN_ERROR_MULTIMEDIA_CLASS | 0x50 - /** * @file wav_player.h - * @brief This file contains the WAV player API + * @brief This file contains the WAV player API. */ /** @@ -41,51 +36,43 @@ extern "C" */ /** - * @brief Enumerations of error code for WAV player. + * @brief Enumeration of error codes for WAV player. + * @since_tizen @if MOBILE 2.3 @elseif WEARABLE 2.3.1 @endif */ typedef enum { WAV_PLAYER_ERROR_NONE = TIZEN_ERROR_NONE, /**< Successful */ WAV_PLAYER_ERROR_INVALID_PARAMETER = TIZEN_ERROR_INVALID_PARAMETER, /**< Invalid parameter */ WAV_PLAYER_ERROR_INVALID_OPERATION = TIZEN_ERROR_INVALID_OPERATION, /**< Invalid operation */ - WAV_PLAYER_ERROR_FORMAT_NOT_SUPPORTED = WAV_PLAYER_ERROR_CLASS | 0x01 /**< Not supported format */ + WAV_PLAYER_ERROR_FORMAT_NOT_SUPPORTED = TIZEN_ERROR_WAV_PLAYER | 0x01 /**< Format not supported */ } wav_player_error_e; /** - * @} - */ - - -/** - * @addtogroup CAPI_MEDIA_WAV_PLAYER_MODULE - * @{ - */ - -/** - * @brief Called when a WAV file has finished playing. + * @brief Called when a WAV file is no longer being played. * @details This callback is not invoked by calling wav_player_stop(). - * + * @since_tizen @if MOBILE 2.3 @elseif WEARABLE 2.3.1 @endif * @param[in] id The completed wav player ID * @param[in] user_data The user data passed from the callback registration function * @see wav_player_start() */ typedef void (*wav_player_playback_completed_cb)(int id, void *user_data); - /** * @brief Plays a WAV file. - * @param[in] path The WAV file path to play + * @since_tizen @if MOBILE 2.3 @elseif WEARABLE 2.3.1 @endif + * @param[in] path The WAV file path to the file to be played * @param[in] type The sound type - * @param[in] callback The callback function to invoke when a WAV file is finished playing + * @param[in] callback The callback function to be invoked when a WAV file is no longer being played * @param[in] user_data The user data to be passed to the callback function - * @param[out] id The WAV player ID ( can be set to NULL ) + * @param[out] id The WAV player ID (can be set to @c NULL) * - * @return 0 on success, otherwise a negative error value. + * @return @c 0 on success, + * otherwise a negative error value * @retval #WAV_PLAYER_ERROR_NONE Successful - * @retval #WAV_PLAYER_ERROR_INVALID_PARAMETER Invalid parameter + * @retval #WAV_PLAYER_ERROR_INVALID_PARAMETER Invalid parameter * @retval #WAV_PLAYER_ERROR_INVALID_OPERATION Invalid operation * - * @post It invokes wav_player_playback_completed_cb() when a WAV file has finished playing. + * @post It invokes wav_player_playback_completed_cb() when a WAV file is no longer being played. * @see wav_player_stop() * @see wav_player_playback_completed_cb() */ @@ -93,10 +80,11 @@ int wav_player_start(const char *path, sound_type_e type, wav_player_playback_co /** * @brief Stops playing the WAV file. + * @since_tizen @if MOBILE 2.3 @elseif WEARABLE 2.3.1 @endif + * @param[in] id The WAV player ID to stop * - * @param[in] id The WAV player ID to stop - * - * @return 0 on success, otherwise a negative error value. + * @return @c 0 on success, + * otherwise a negative error value * @retval #WAV_PLAYER_ERROR_NONE Successful * @retval #WAV_PLAYER_ERROR_INVALID_PARAMETER Invalid parameter * @retval #WAV_PLAYER_ERROR_INVALID_OPERATION Invalid operation diff --git a/include/wav_player_private.h b/include/wav_player_private.h new file mode 100644 index 0000000..e6458b6 --- /dev/null +++ b/include/wav_player_private.h @@ -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 +#include +#include +#include + +#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__ */ diff --git a/packaging/capi-media-wav-player.spec b/packaging/capi-media-wav-player.spec index b9020a8..2405a34 100644 --- a/packaging/capi-media-wav-player.spec +++ b/packaging/capi-media-wav-player.spec @@ -1,10 +1,10 @@ #sbs-git:slp/api/wav-player capi-media-wav-player 0.1.0 8d904bb3bd0ca7fa01ebd8f4185e4b993d94c08d Name: capi-media-wav-player -Summary: A wav player library in Tizen C API -Version: 0.1.0 -Release: 10 +Summary: A wav player library in SLP C API +Version: 0.1.12 +Release: 0 Group: TO_BE/FILLED_IN -License: TO BE FILLED IN +License: Apache License, Version 2.0 Source0: %{name}-%{version}.tar.gz BuildRequires: cmake BuildRequires: pkgconfig(mm-sound) @@ -13,19 +13,19 @@ BuildRequires: pkgconfig(capi-base-common) BuildRequires: pkgconfig(capi-media-sound-manager) Requires(post): /sbin/ldconfig Requires(postun): /sbin/ldconfig +Requires(post): libprivilege-control %description %package devel -Summary: A wav player library in Tizen C API (Development) +Summary: A wav player library in SLP C API (Development) Group: TO_BE/FILLED_IN Requires: %{name} = %{version}-%{release} %description devel - %prep %setup -q @@ -38,15 +38,23 @@ make %{?jobs:-j%jobs} %install rm -rf %{buildroot} +mkdir -p %{buildroot}/usr/share/license +cp LICENSE %{buildroot}/usr/share/license/%{name} +mkdir -p %{buildroot}/usr/share/privilege-control + %make_install -%post -p /sbin/ldconfig +%post +/sbin/ldconfig +/usr/bin/api_feature_loader --verbose --dir=/usr/share/privilege-control %postun -p /sbin/ldconfig %files %{_libdir}/libcapi-media-wav-player.so.* +%{_datadir}/license/%{name} +%manifest capi-media-wav-player.manifest %files devel %{_includedir}/media/*.h diff --git a/src/wav_player.c b/src/wav_player.c old mode 100755 new mode 100644 index 34ef36b..70afc9a --- a/src/wav_player.c +++ b/src/wav_player.c @@ -15,7 +15,7 @@ */ -#define LOG_TAG "TIZEN_N_WAV_PLAYER" +#define LOG_TAG "CAPI_MEDIA_WAV_PLAYER" #include #include @@ -24,75 +24,25 @@ #include #include #include -#include +#include "wav_player.h" +#include "wav_player_private.h" #include -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 100644 index 0000000..b856fd5 --- /dev/null +++ b/src/wav_player_private.c @@ -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 +#include +#include +#include +#include +#include +#include +#include +#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); +} + diff --git a/test/CMakeLists.txt b/test/CMakeLists.txt index 353da53..74802de 100644 --- a/test/CMakeLists.txt +++ b/test/CMakeLists.txt @@ -7,7 +7,7 @@ FOREACH(flag ${${fw_test}_CFLAGS}) MESSAGE(${flag}) ENDFOREACH() -SET(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} ${EXTRA_CFLAGS} -Wall") +SET(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} ${EXTRA_CFLAGS} -Wall -pie") #ADD_EXECUTABLE("system-sensor" system-sensor.c) #TARGET_LINK_LIBRARIES("system-sensor" ${fw_name} ${${fw_test}_LDFLAGS}) diff --git a/test/multimedia_wav_player_test.c b/test/multimedia_wav_player_test.c old mode 100755 new mode 100644 diff --git a/test/test.wav b/test/test.wav old mode 100755 new mode 100644