X-Git-Url: http://review.tizen.org/git/?a=blobdiff_plain;f=src%2Fwav_player.c;fp=mobile%2Fsrc%2Fwav_player.c;h=70afc9ac1670d715e19d9f02827b7ac28fdd9ac9;hb=89ce6e9de91a2551597ae67e3f9d5b7e9a1cbcef;hp=eebede9738464fcba2b0fd4b1ba021178d1fae2f;hpb=9faf15a27f32262cd0c40179ced58447d2f1e05a;p=framework%2Fapi%2Fwav-player.git diff --git a/mobile/src/wav_player.c b/src/wav_player.c old mode 100755 new mode 100644 similarity index 52% rename from mobile/src/wav_player.c rename to src/wav_player.c index eebede9..70afc9a --- a/mobile/src/wav_player.c +++ b/src/wav_player.c @@ -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)); }