Revise AUTHOR and wav_player_test, remove redundant codes and change file mode 20/74620/7 accepted/tizen/common/20160620.162521 accepted/tizen/ivi/20160617.082459 accepted/tizen/mobile/20160617.082003 accepted/tizen/tv/20160617.082046 accepted/tizen/wearable/20160617.082146 submit/tizen/20160616.065630
authorSangchul Lee <sc11.lee@samsung.com>
Wed, 15 Jun 2016 02:25:35 +0000 (11:25 +0900)
committerSangchul Lee <sc11.lee@samsung.com>
Wed, 15 Jun 2016 08:32:00 +0000 (17:32 +0900)
[Version] Release 0.1.18
[Profile] Common
[Issue Type] Code clean up

Change-Id: Ie2ae415a6125f1ba217b4fbbc1e8f07d81756410

AUTHORS [changed mode: 0755->0644]
CMakeLists.txt [changed mode: 0755->0644]
include/wav_player_private.h
packaging/capi-media-wav-player.spec
src/wav_player.c
src/wav_player_internal.c
src/wav_player_private.c
test/CMakeLists.txt
test/test.wav [deleted file]
test/wav_player_test.c [moved from test/multimedia_wav_player_test.c with 59% similarity, mode: 0644]

diff --git a/AUTHORS b/AUTHORS
old mode 100755 (executable)
new mode 100644 (file)
index 78092f0..7171c7c
--- a/AUTHORS
+++ b/AUTHORS
@@ -1,2 +1,3 @@
 Seungbae Shin <seungbae.shin at samsung dot com>
-Doohwan Kim <dh8210.kim at samsung dot com>
+Sangchul Lee <sc11.lee at samsung dot com>
+Jeongho Mok <jho.mok at samsung dot com>
old mode 100755 (executable)
new mode 100644 (file)
index 12a3ed3..13ebcaa
@@ -18,7 +18,7 @@ SET(Services
 SET(project_prefix "capi")
 SET(prefix "/usr")
 SET(version "0.0.1")
-SET(maintainer "Seungkeun Lee <sngn.lee@samsung.com>, Kangho Hur<kagho.hur@samsung.com>")
+SET(maintainer "Seungbae Shin <seungbae.shin@samsung.com>, Sangchul Lee <sc11.lee@samsung.com>, Jeongho Mok <jho.mok@samsung.com>")
 SET(description "A wav player library in Tizen Native API")
 SET(service "media")
 SET(submodule "wav-player")
@@ -87,7 +87,7 @@ CONFIGURE_FILE(
 )
 INSTALL(FILES ${CMAKE_CURRENT_SOURCE_DIR}/${fw_name}.pc DESTINATION ${LIB_INSTALL_DIR}/pkgconfig)
 
-#ADD_SUBDIRECTORY(test)
+ADD_SUBDIRECTORY(test)
 
 IF(UNIX)
 
index 4245c08..2b87c06 100644 (file)
@@ -1,5 +1,5 @@
 /*
-* Copyright (c) 2011 Samsung Electronics Co., Ltd All Rights Reserved
+* Copyright (c) 2011-2016 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.
@@ -49,11 +49,12 @@ typedef struct _cb_data_ {
  * @}
  */
 
+int _convert_wav_player_error_code(const char *func, int code);
+void _internal_complete_cb(void *user_data, int id);
+int _start_with_stream_info(const char *path, sound_stream_info_h stream_info, unsigned int loop_count, wav_player_playback_completed_cb cb, void *user_data, int *id);
+
 #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__ */
index 016121e..fb7ad7a 100755 (executable)
@@ -1,6 +1,6 @@
 Name:       capi-media-wav-player
 Summary:    A wav player library in Tizen C API
-Version:    0.1.17
+Version:    0.1.18
 Release:    0
 Group:      Multimedia/API
 License:    Apache-2.0
@@ -43,6 +43,7 @@ MAJORVER=`echo %{version} | awk 'BEGIN {FS="."}{print $1}'`
 %manifest %{name}.manifest
 %license LICENSE.APLv2
 %{_libdir}/libcapi-media-wav-player.so.*
+%{_bindir}/wav_player_test
 
 %files devel
 %manifest %{name}.manifest
index 3e5f023..eaf5ee2 100755 (executable)
@@ -1,5 +1,5 @@
 /*
-* Copyright (c) 2011 Samsung Electronics Co., Ltd All Rights Reserved
+* Copyright (c) 2011-2016 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.
@@ -14,8 +14,7 @@
 * limitations under the License.
 */
 
-
-#define LOG_TAG "CAPI_MEDIA_WAV_PLAYER"
+#define LOG_TAG "TIZEN_N_WAV_PLAYER"
 
 #include <sound_manager.h>
 #include <sound_manager_internal.h>
 #include <string.h>
 #include <unistd.h>
 #include <dlog.h>
+#include <stdlib.h>
 #include "wav_player.h"
 #include "wav_player_private.h"
-#include <stdlib.h>
-
 
 int wav_player_start(const char *path, sound_type_e type, wav_player_playback_completed_cb cb, void *user_data,  int * id)
 {
@@ -40,12 +38,11 @@ int wav_player_start(const char *path, sound_type_e type, wav_player_playback_co
        _completed_cb = NULL;
        _cb_data *cb_data = NULL;
 
-
        if (path == NULL)
-               return __convert_wav_player_error_code(__func__, WAV_PLAYER_ERROR_INVALID_PARAMETER);
+               return _convert_wav_player_error_code(__func__, WAV_PLAYER_ERROR_INVALID_PARAMETER);
 
        if (type < SOUND_TYPE_SYSTEM || type >= SOUND_TYPE_NUM)
-               return __convert_wav_player_error_code(__func__, WAV_PLAYER_ERROR_INVALID_PARAMETER);
+               return _convert_wav_player_error_code(__func__, WAV_PLAYER_ERROR_INVALID_PARAMETER);
 
        m_path[0] = '\0';
        if (path[0] != '/') {
@@ -56,15 +53,14 @@ int wav_player_start(const char *path, sound_type_e type, wav_player_playback_co
        strncat(m_path, path, PATH_MAX-strlen(m_path));
 
        if (cb) {
-               _completed_cb = __internal_complete_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);
+                       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)
@@ -73,67 +69,16 @@ int wav_player_start(const char *path, sound_type_e type, wav_player_playback_co
        if (ret != 0 && cb_data != NULL)
                free(cb_data);
 
-       return __convert_wav_player_error_code(__func__, ret);
+       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 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)
 {
-       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;
-       bool result = false;
-
-       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)
-               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)
-               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, 1, _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);
-
+       return _start_with_stream_info(path, stream_info, 1, callback, user_data, id);
 }
 
 int wav_player_stop(int id)
 {
-       return __convert_wav_player_error_code(__func__, mm_sound_stop_sound(id));
+       return _convert_wav_player_error_code(__func__, mm_sound_stop_sound(id));
 }
 
index 7f73d67..3adfadf 100755 (executable)
 */
 
 
-#define LOG_TAG "CAPI_MEDIA_WAV_PLAYER"
-
 #include <sound_manager.h>
-#include <sound_manager_internal.h>
-#include <mm_sound.h>
-#include <mm_sound_private.h>
-#include <stdio.h>
-#include <limits.h>
-#include <string.h>
-#include <unistd.h>
-#include <dlog.h>
 #include "wav_player.h"
 #include "wav_player_private.h"
-#include <stdlib.h>
 
 int wav_player_start_loop(const char *path, sound_stream_info_h stream_info, unsigned int loop_count, wav_player_playback_completed_cb callback, 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;
-       bool result = false;
-
-       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)
-               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)
-               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 (callback) {
-               _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 = callback;
-               cb_data->user_data = user_data;
-       }
-
-       ret = mm_sound_play_sound_with_stream_info(m_path, stream_type, stream_id, loop_count, _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);
+       return _start_with_stream_info(path, stream_info, loop_count, callback, user_data, id);
 }
index 70eea22..4a0e649 100755 (executable)
@@ -1,5 +1,5 @@
 /*
-* Copyright (c) 2011 Samsung Electronics Co., Ltd All Rights Reserved
+* Copyright (c) 2011-2016 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.
@@ -14,8 +14,7 @@
 * limitations under the License.
 */
 
-
-#define LOG_TAG "CAPI_MEDIA_WAV_PLAYER"
+#define LOG_TAG "TIZEN_N_WAV_PLAYER"
 
 #include <mm_sound.h>
 #include <mm_sound_private.h>
@@ -27,7 +26,7 @@
 #include <stdlib.h>
 #include "wav_player_private.h"
 
-int __convert_wav_player_error_code(const char *func, int code)
+int _convert_wav_player_error_code(const char *func, int code)
 {
        int ret = WAV_PLAYER_ERROR_INVALID_OPERATION;
        char *errorstr = NULL;
@@ -63,8 +62,7 @@ int __convert_wav_player_error_code(const char *func, int code)
        return ret;
 }
 
-
-void __internal_complete_cb(void *user_data, int id)
+void _internal_complete_cb(void *user_data, int id)
 {
        _cb_data *cb_data = (_cb_data*)user_data;
        if (!cb_data)
@@ -77,3 +75,56 @@ void __internal_complete_cb(void *user_data, int id)
        free(cb_data);
 }
 
+int _start_with_stream_info(const char *path, sound_stream_info_h stream_info, unsigned loop_count, wav_player_playback_completed_cb callback, 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;
+       bool result = false;
+
+       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)
+               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)
+               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 (callback) {
+               _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 = callback;
+               cb_data->user_data = user_data;
+       }
+
+       ret = mm_sound_play_sound_with_stream_info(m_path, stream_type, stream_id, loop_count, _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);
+}
index 74802de..dbd3830 100644 (file)
@@ -9,9 +9,6 @@ ENDFOREACH()
 
 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})
-
 aux_source_directory(. sources)
 FOREACH(src ${sources})
     GET_FILENAME_COMPONENT(src_name ${src} NAME_WE)
@@ -19,3 +16,5 @@ FOREACH(src ${sources})
     ADD_EXECUTABLE(${src_name} ${src})
     TARGET_LINK_LIBRARIES(${src_name} ${fw_name} ${${fw_test}_LDFLAGS})
 ENDFOREACH()
+
+INSTALL(TARGETS wav_player_test DESTINATION bin)
diff --git a/test/test.wav b/test/test.wav
deleted file mode 100755 (executable)
index 033d815..0000000
Binary files a/test/test.wav and /dev/null differ
old mode 100755 (executable)
new mode 100644 (file)
similarity index 59%
rename from test/multimedia_wav_player_test.c
rename to test/wav_player_test.c
index a96d60f..c18747d
@@ -1,5 +1,5 @@
 /*
-* Copyright (c) 2011 Samsung Electronics Co., Ltd All Rights Reserved
+* Copyright (c) 2011-2016 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.
 
 
 #include <stdio.h>
-#include <wav_player.h>
+#include <wav_player_internal.h>
+#include <sound_manager.h>
 #include <glib.h>
 #include <unistd.h>
 #include <string.h>
 #include <stdlib.h>
 #include <getopt.h>
 
-#define FILE_PATH_MAX   30
-#define DEFAULT_FILE    "test.wav"
+#define FILE_PATH_MAX   128
+#define DEFAULT_FILE    "/usr/share/sounds/alsa/Front_Center.wav"
 
 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);
-
-       return NULL;
-}
 
 void help()
 {
        printf("Usage : ");
-       printf("multimedia_wav_player_test [OPTION]\n\n"
-                  "  -i, --iterate                 how many time to play\n"
-                  "  -f, --file                    file path to play\n"
+       printf("wav_player_test [OPTION]\n\n"
+                  "  -f, --file                file path to play\n"
+                  "  -i, --iterate             how many times to play\n"
                   "  -h, --help                help\n");
 }
 
 void _player_stop_cb(int id, void *user_data)
 {
-       printf("complete id = %d,%d\n", id, (int)user_data);
+       printf("complete id = %d,%p\n", id, user_data);
+       sound_manager_destroy_stream_information((sound_stream_info_h)user_data);
+       g_main_loop_quit(g_mainloop);
 }
 
+void stream_focus_cb(sound_stream_info_h stream_info, sound_stream_focus_change_reason_e reason, const char *extra_info, void *user_data)
+{
+       return;
+}
 
 void wav_play_test(const char* file_path, int iterate)
 {
        int ret = 0;
        int id;
        int i;
+       sound_stream_info_h stream_info;
+
        if (iterate <= 0 || file_path == NULL) {
-               printf("invalid param : %d\n", time);
+               printf("invalid param, iterate(%d), file_path(%s)\n", iterate, file_path);
                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);
+       if (sound_manager_create_stream_information(SOUND_STREAM_TYPE_MEDIA, stream_focus_cb, NULL, &stream_info)) {
+               printf("failed to create stream info\n");
+               return;
+       }
 
+       printf("Play Wav, File Path : %s, Iterate : %d\n", file_path, iterate);
+       ret = wav_player_start_loop(file_path, stream_info, iterate, _player_stop_cb, (void*)stream_info, &id);
+       printf("wav_player_start(%d)(id=%d) ret = %d\n", i, id, ret);
+       if (ret) {
+               sound_manager_destroy_stream_information(stream_info);
+               return;
        }
-}
 
+       g_mainloop = g_main_loop_new(NULL, 0);
+       g_main_loop_run(g_mainloop);
+}
 
 int main(int argc, char**argv)
 {
@@ -104,8 +112,6 @@ int main(int argc, char**argv)
                }
        }
 
-       event_thread = g_thread_new("WavPlayerTest", GmainThread, NULL);
-
        wav_play_test(file_path, iterate);
 
        return 0;