From: inhyeok Date: Fri, 30 Oct 2015 10:06:58 +0000 (+0900) Subject: modify codes for complying tizen coding rule X-Git-Tag: accepted/tizen/ivi/20160218.023326^0 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=refs%2Fchanges%2F27%2F50727%2F3;p=platform%2Fcore%2Fapi%2Fwav-player.git modify codes for complying tizen coding rule [Version] Release 0.1.15 [Profile] Common [Issue Type] Coding Rule Change-Id: I188c99c9cf38e9ff4d8756627fe52eaec1311345 Signed-off-by: inhyeok --- diff --git a/include/wav_player.h b/include/wav_player.h index b43818f..2f9152a 100644 --- a/include/wav_player.h +++ b/include/wav_player.h @@ -44,8 +44,7 @@ extern "C" * @brief Enumeration of error codes for WAV player. * @since_tizen @if MOBILE 2.3 @elseif WEARABLE 2.3.1 @endif */ -typedef enum -{ +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 */ diff --git a/include/wav_player_private.h b/include/wav_player_private.h index e6458b6..4245c08 100755 --- a/include/wav_player_private.h +++ b/include/wav_player_private.h @@ -40,7 +40,7 @@ extern "C" */ -typedef struct _cb_data_{ +typedef struct _cb_data_ { wav_player_playback_completed_cb cb; void * user_data; } _cb_data; diff --git a/packaging/capi-media-wav-player.spec b/packaging/capi-media-wav-player.spec index d7582b1..b516f6d 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.14 +Version: 0.1.15 Release: 0 Group: Multimedia/API License: Apache-2.0 diff --git a/src/wav_player.c b/src/wav_player.c index c655b51..319ea4b 100755 --- a/src/wav_player.c +++ b/src/wav_player.c @@ -41,25 +41,24 @@ int wav_player_start(const char *path, sound_type_e type, wav_player_playback_co _cb_data *cb_data = NULL; - if( path == NULL) + if (path == NULL) return __convert_wav_player_error_code(__func__, WAV_PLAYER_ERROR_INVALID_PARAMETER); - if( type < SOUND_TYPE_SYSTEM || type >= SOUND_TYPE_NUM ) + 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'; - if( path[0] != '/' ){ + if (path[0] != '/') { - if( getcwd(m_path, PATH_MAX) != NULL){ - strncat(m_path, "/",PATH_MAX-strlen(m_path) ); - } + 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 ){ + if (cb) { _completed_cb = __internal_complete_cb; cb_data = (_cb_data *)malloc(sizeof(_cb_data)); - if(cb_data == NULL ) + 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; @@ -68,11 +67,10 @@ int wav_player_start(const char *path, sound_type_e type, wav_player_playback_co ret = mm_sound_play_sound(m_path, type, _completed_cb , cb_data, &player); - if( ret == 0 && id != NULL){ + if (ret == 0 && id != NULL) *id = player; - } - if( ret != 0 && cb_data != NULL) + if (ret != 0 && cb_data != NULL) free(cb_data); return __convert_wav_player_error_code(__func__, ret); @@ -90,33 +88,32 @@ int wav_player_start_with_stream_info(const char *path, sound_stream_info_h stre int stream_id; bool result = false; - if( path == NULL || stream_info == NULL ) + if (path == NULL || stream_info == NULL) return __convert_wav_player_error_code(__func__, WAV_PLAYER_ERROR_INVALID_PARAMETER); ret = sound_manager_is_available_stream_information(stream_info, NATIVE_API_WAV_PLAYER, &result); - if ( !result ) + if (!result) return __convert_wav_player_error_code(__func__, WAV_PLAYER_ERROR_NOT_SUPPORTED_TYPE); ret = sound_manager_get_type_from_stream_information(stream_info, &stream_type); - if( ret ) + if (ret) return __convert_wav_player_error_code(__func__, ret); ret = sound_manager_get_index_from_stream_information(stream_info, &stream_id); - if( ret ) + if (ret) return __convert_wav_player_error_code(__func__, ret); m_path[0] = '\0'; - if( path[0] != '/' ){ + if (path[0] != '/') { - if( getcwd(m_path, PATH_MAX) != NULL){ - strncat(m_path, "/",PATH_MAX-strlen(m_path) ); - } + 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 ){ + if (cb) { _completed_cb = __internal_complete_cb; cb_data = (_cb_data *)malloc(sizeof(_cb_data)); - if(cb_data == NULL ) + 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; @@ -125,11 +122,10 @@ int wav_player_start_with_stream_info(const char *path, sound_stream_info_h stre ret = mm_sound_play_sound_with_stream_info(m_path, stream_type, stream_id, _completed_cb , cb_data, &player); - if( ret == 0 && id != NULL){ + if (ret == 0 && id != NULL) *id = player; - } - if( ret != 0 && cb_data != NULL) + if (ret != 0 && cb_data != NULL) free(cb_data); return __convert_wav_player_error_code(__func__, ret); diff --git a/src/wav_player_private.c b/src/wav_player_private.c index 71ebebe..70eea22 100755 --- a/src/wav_player_private.c +++ b/src/wav_player_private.c @@ -31,48 +31,47 @@ 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; - case WAV_PLAYER_ERROR_NOT_SUPPORTED_TYPE: - ret = WAV_PLAYER_ERROR_NOT_SUPPORTED_TYPE; - errorstr = "NOT_SUPPORTED_TYPE"; - break; - default: - ret = WAV_PLAYER_ERROR_INVALID_OPERATION; - errorstr = "INVALID_OPERATION"; - break; + 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; + case WAV_PLAYER_ERROR_NOT_SUPPORTED_TYPE: + ret = WAV_PLAYER_ERROR_NOT_SUPPORTED_TYPE; + errorstr = "NOT_SUPPORTED_TYPE"; + break; + default: + ret = WAV_PLAYER_ERROR_INVALID_OPERATION; + errorstr = "INVALID_OPERATION"; + break; } - LOGE( "[%s] %s(0x%08x)",func, errorstr, ret); + 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) + _cb_data *cb_data = (_cb_data*)user_data; + if (!cb_data) return; - if( cb_data->cb ){ - LOGD( "user callback for handle %d call", id); + if (cb_data->cb) { + LOGD("user callback for handle %d call %p", id, cb_data->cb); cb_data->cb(id, cb_data->user_data); } free(cb_data); diff --git a/test/multimedia_wav_player_test.c b/test/multimedia_wav_player_test.c index 0d9229d..a96d60f 100755 --- a/test/multimedia_wav_player_test.c +++ b/test/multimedia_wav_player_test.c @@ -30,14 +30,16 @@ static GMainLoop *g_mainloop = NULL; static GThread *event_thread; -gpointer GmainThread(gpointer data){ - g_mainloop = g_main_loop_new (NULL, 0); - g_main_loop_run (g_mainloop); +gpointer GmainThread(gpointer data) +{ + g_mainloop = g_main_loop_new(NULL, 0); + g_main_loop_run(g_mainloop); return NULL; } -void help() { +void help() +{ printf("Usage : "); printf("multimedia_wav_player_test [OPTION]\n\n" " -i, --iterate how many time to play\n" @@ -45,24 +47,26 @@ void help() { " -h, --help help\n"); } -void _player_stop_cb(int id, void *user_data){ +void _player_stop_cb(int id, void *user_data) +{ printf("complete id = %d,%d\n", id, (int)user_data); } -void wav_play_test(const char* file_path, int iterate){ - int ret=0; +void wav_play_test(const char* file_path, int iterate) +{ + int ret = 0; int id; int i; - if(iterate <= 0 || file_path == NULL) { + if (iterate <= 0 || file_path == NULL) { printf("invalid param : %d\n", time); return; } printf("Play Wav, File Path : %s, Iterate : %d\n", file_path, iterate); - for(i =0 ; i < iterate; i++){ - ret = wav_player_start(file_path, SOUND_TYPE_MEDIA, _player_stop_cb,(void*)i, &id); - printf("wav_player_start(%d)(id=%d) ret = %d\n",i,id, ret); + for (i = 0 ; i < iterate; i++) { + ret = wav_player_start(file_path, SOUND_TYPE_MEDIA, _player_stop_cb, (void*)i, &id); + printf("wav_player_start(%d)(id=%d) ret = %d\n", i, id, ret); } } @@ -77,8 +81,7 @@ int main(int argc, char**argv) int opt; int opt_idx = 0; - static struct option long_options[] = - { + static struct option long_options[] = { {"iterate" , required_argument, 0, 'i'}, {"file" , required_argument, 0, 'f'}, { 0, 0, 0, 0 } @@ -88,16 +91,16 @@ int main(int argc, char**argv) break; switch (opt) { - case 'f': - strcpy(file_path, optarg); - break; - case 'i': - iterate = atoi(optarg); - break; - case 'h': - default: - help(); - return 0; + case 'f': + strcpy(file_path, optarg); + break; + case 'i': + iterate = atoi(optarg); + break; + case 'h': + default: + help(); + return 0; } }