* @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 */
*/
-typedef struct _cb_data_{
+typedef struct _cb_data_ {
wav_player_playback_completed_cb cb;
void * user_data;
} _cb_data;
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
_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;
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);
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;
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);
{
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);
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"
" -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);
}
}
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 }
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;
}
}