From: inhyeok Date: Thu, 25 Jun 2015 08:17:07 +0000 (+0900) Subject: Merge based 2.4 X-Git-Tag: accepted/tizen/mobile/20150717.002857^0 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=refs%2Fchanges%2F84%2F42284%2F7;p=platform%2Fcore%2Fapi%2Fwav-player.git Merge based 2.4 [Version] Release 0.1.11 [Profile] Common [Issue Type] Migration Merged main changes - Apply ASLR - Adapt stream-based routing Change-Id: I67d23611f2728290e6f271b0c275523921113064 Signed-off-by: inhyeok --- diff --git a/include/wav_player.h b/include/wav_player.h index 39aa74e..19de4a6 100644 --- a/include/wav_player.h +++ b/include/wav_player.h @@ -11,7 +11,7 @@ * 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. +* limitations under the License. */ @@ -41,14 +41,16 @@ 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_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_NOT_SUPPORTED = TIZEN_ERROR_NOT_SUPPORTED, /**< Not supported (Since 3.0) */ + WAV_PLAYER_ERROR_FORMAT_NOT_SUPPORTED = TIZEN_ERROR_WAV_PLAYER | 0x01 /**< Format not supported */ } wav_player_error_e; /** @@ -64,7 +66,7 @@ typedef enum /** * @brief Called when a WAV file has finished playing. * @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() @@ -73,16 +75,23 @@ typedef void (*wav_player_playback_completed_cb)(int id, void *user_data); /** + * @deprecated Deprecated since 3.0. Use wav_player_start_with_stream_info() instead. * @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 + * + * @remarks Sound can be mixed with other sounds if you don't control the sound session in sound-manager module since 3.0.\n + * You can refer to @ref CAPI_MEDIA_SUOND_MANAGER_MODULE. + * + * @param[in] path The file path to play * @param[in] type The sound type * @param[in] callback The callback function to invoke when a WAV file is finished playing * @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 ) * - * @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. @@ -92,14 +101,38 @@ typedef void (*wav_player_playback_completed_cb)(int id, void *user_data); int wav_player_start(const char *path, sound_type_e type, wav_player_playback_completed_cb callback, void *user_data, int *id); /** - * @brief Stops playing the WAV file. + * @brief Plays a WAV file with stream information of sound-manager. + * @since_tizen 3.0 + * @param[in] path The file path to play + * @param[in] stream_info The sound stream information handle + * @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 @c NULL) + * + * @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 + * @retval #WAV_PLAYER_ERROR_NOT_SUPPORTED Not supported * + * @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() + * @see sound_manager_create_stream_information() + * @see sound_manager_destroy_stream_information() + */ +int wav_player_start_with_stream_info(const char *path, sound_stream_info_h stream_info, wav_player_playback_completed_cb callback, void *user_data, int *id); + +/** + * @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 * * @return 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 + * @retval #WAV_PLAYER_ERROR_INVALID_PARAMETER Invalid parameter + * @retval #WAV_PLAYER_ERROR_INVALID_OPERATION Invalid operation * * @see wav_player_start() */ diff --git a/packaging/capi-media-wav-player.spec b/packaging/capi-media-wav-player.spec index 8009c3c..be0f345 100755 --- a/packaging/capi-media-wav-player.spec +++ b/packaging/capi-media-wav-player.spec @@ -1,6 +1,6 @@ Name: capi-media-wav-player Summary: A wav player library in Tizen C API -Version: 0.1.1 +Version: 0.1.11 Release: 0 Group: Multimedia/API License: Apache-2.0 diff --git a/src/wav_player.c b/src/wav_player.c index 70afc9a..7c8daf4 100755 --- a/src/wav_player.c +++ b/src/wav_player.c @@ -11,12 +11,14 @@ * 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. +* limitations under the License. */ #define LOG_TAG "CAPI_MEDIA_WAV_PLAYER" +#include +#include #include #include #include @@ -76,6 +78,59 @@ int wav_player_start(const char *path, sound_type_e type, wav_player_playback_co return __convert_wav_player_error_code(__func__, ret); } +int wav_player_start_with_stream_info(const char *path, sound_stream_info_h stream_info, 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 *, int); + _completed_cb = NULL; + _cb_data *cb_data = NULL; + char *stream_type = NULL; + int stream_id; + + if( path == NULL) + return __convert_wav_player_error_code(__func__, WAV_PLAYER_ERROR_INVALID_PARAMETER); + + ret = sound_manager_get_type_from_stream_information(stream_info, &stream_type); + if( ret ) + return __convert_wav_player_error_code(__func__, ret); + ret = sound_manager_get_index_from_stream_information(stream_info, &stream_id); + if( ret ) + return __convert_wav_player_error_code(__func__, ret); + + m_path[0] = '\0'; + if( path[0] != '/' ){ + + if( getcwd(m_path, PATH_MAX) != NULL){ + strncat(m_path, "/",PATH_MAX-strlen(m_path) ); + } + } + strncat(m_path, path, PATH_MAX-strlen(m_path)); + + if( cb ){ + _completed_cb = __internal_complete_cb; + cb_data = (_cb_data *)malloc(sizeof(_cb_data)); + if(cb_data == NULL ) + return __convert_wav_player_error_code(__func__, WAV_PLAYER_ERROR_INVALID_OPERATION); + cb_data->cb = cb; + cb_data->user_data = user_data; + } + + + ret = mm_sound_play_sound_with_stream_info(m_path, stream_type, stream_id, _completed_cb , cb_data, &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) { return __convert_wav_player_error_code(__func__, mm_sound_stop_sound(id)); 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 index d9d5c8d..e57cbab 100755 --- a/test/multimedia_wav_player_test.c +++ b/test/multimedia_wav_player_test.c @@ -11,7 +11,7 @@ * 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. +* limitations under the License. */ @@ -43,7 +43,7 @@ void wav_play_test(){ int ret=0; int id; int i; - for(i =0 ; i < 100; i++){ + for(i =0 ; i < 100; i++){ ret = wav_player_start("test.wav", SOUND_TYPE_MEDIA, _player_stop_cb,(void*)i, &id); printf("wav_player_start(%d)(id=%d) ret = %d\n",i,id, ret); @@ -51,18 +51,12 @@ void wav_play_test(){ } void audio_io_test(){ - + } int main(int argc, char**argv) { - if( !g_thread_supported() ) - { - g_thread_init(NULL); - } - - GError *gerr = NULL; - event_thread = g_thread_create(GmainThread, NULL, 1, &gerr); + event_thread = g_thread_new("WavPlayerTest", GmainThread, NULL); wav_play_test(); return 0;