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>
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")
)
INSTALL(FILES ${CMAKE_CURRENT_SOURCE_DIR}/${fw_name}.pc DESTINATION ${LIB_INSTALL_DIR}/pkgconfig)
-#ADD_SUBDIRECTORY(test)
+ADD_SUBDIRECTORY(test)
IF(UNIX)
/*
-* 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.
* @}
*/
+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__ */
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
%manifest %{name}.manifest
%license LICENSE.APLv2
%{_libdir}/libcapi-media-wav-player.so.*
+%{_bindir}/wav_player_test
%files devel
%manifest %{name}.manifest
/*
-* 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.
* 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)
{
_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] != '/') {
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)
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));
}
*/
-#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);
}
/*
-* 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.
* 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>
#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;
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)
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);
+}
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)
ADD_EXECUTABLE(${src_name} ${src})
TARGET_LINK_LIBRARIES(${src_name} ${fw_name} ${${fw_test}_LDFLAGS})
ENDFOREACH()
+
+INSTALL(TARGETS wav_player_test DESTINATION bin)
/*
-* 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)
{
}
}
- event_thread = g_thread_new("WavPlayerTest", GmainThread, NULL);
-
wav_play_test(file_path, iterate);
return 0;