Add new API for playback with loop at wav_player_internal.h 97/74597/1
authorSangchul Lee <sc11.lee@samsung.com>
Wed, 15 Jun 2016 01:38:50 +0000 (10:38 +0900)
committerSangchul Lee <sc11.lee@samsung.com>
Wed, 15 Jun 2016 01:47:11 +0000 (10:47 +0900)
 - wav_player_start_loop()

[Version] Release 0.1.17
[Profile] Common
[Issue Type] New feature

Change-Id: Ifa05ccb1fbebd3f4c1dd68fc52e8890d91b15d48
Signed-off-by: Sangchul Lee <sc11.lee@samsung.com>
include/wav_player_internal.h [new file with mode: 0644]
include/wav_player_private.h [changed mode: 0755->0644]
packaging/capi-media-wav-player.spec
src/wav_player.c
src/wav_player_internal.c [new file with mode: 0755]

diff --git a/include/wav_player_internal.h b/include/wav_player_internal.h
new file mode 100644 (file)
index 0000000..6673510
--- /dev/null
@@ -0,0 +1,78 @@
+/*
+* Copyright (c) 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.
+* You may obtain a copy of the License at
+*
+* http://www.apache.org/licenses/LICENSE-2.0
+*
+* Unless required by applicable law or agreed to in writing, software
+* distributed under the License is distributed on an "AS IS" BASIS,
+* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+* See the License for the specific language governing permissions and
+* limitations under the License.
+*/
+
+
+
+
+#ifndef __TIZEN_MEDIA_WAV_PLAYER_INTERNAL_H__
+#define __TIZEN_MEDIA_WAV_PLAYER_INTERNAL_H__
+
+#include <tizen.h>
+#include <sound_manager.h>
+#include <wav_player.h>
+
+#ifdef __cplusplus
+extern "C"
+{
+#endif
+
+/**
+ * @file wav_player_internal.h
+ * @brief This file contains the Wav Player Internal API
+ */
+
+/**
+ * @addtogroup CAPI_MEDIA_WAV_PLAYER_MODULE
+ * @{
+ */
+
+/**
+ * @internal
+ * @brief Plays a WAV file with loop.
+ * @since_tizen 3.0
+ *
+ * @param[in] path     The file path to play
+ * @param[in] stream_info      The sound stream information handle
+ * @param[in] loop_count       The number of loop (@c 0 = infinite)
+ * @param[in] callback The callback function to be invoked when a WAV file is no longer being played
+ * @param[in] user_data        The user data to be passed to the callback function
+ * @param[out] id      The WAV player ID (can be set to @c NULL)
+ *
+ * @return @c 0 on success,
+ *         otherwise a negative error value
+ * @retval #WAV_PLAYER_ERROR_NONE Successful
+ * @retval #WAV_PLAYER_ERROR_INVALID_PARAMETER Invalid parameter
+ * @retval #WAV_PLAYER_ERROR_INVALID_OPERATION Invalid operation
+ * @retval #WAV_PLAYER_ERROR_FORMAT_NOT_SUPPORTED Not supported format
+ * @retval #WAV_PLAYER_ERROR_NOT_SUPPORTED_TYPE Not supported stream type
+ *
+ * @post       It invokes wav_player_playback_completed_cb() when a WAV file is no longer being played.
+ * @see wav_player_stop()
+ * @see wav_player_playback_completed_cb()
+ * @see sound_manager_create_stream_information()
+ * @see sound_manager_destroy_stream_information()
+ */
+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);
+
+/**
+ * @}
+ */
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif /* __TIZEN_MEDIA_WAV_PLAYER_INTERNAL_H__ */
old mode 100755 (executable)
new mode 100644 (file)
index 47a9890..016121e 100755 (executable)
@@ -1,6 +1,6 @@
 Name:       capi-media-wav-player
 Summary:    A wav player library in Tizen C API
-Version:    0.1.16
+Version:    0.1.17
 Release:    0
 Group:      Multimedia/API
 License:    Apache-2.0
index 319ea4b..3e5f023 100755 (executable)
@@ -120,7 +120,7 @@ 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);
+       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;
diff --git a/src/wav_player_internal.c b/src/wav_player_internal.c
new file mode 100755 (executable)
index 0000000..7f73d67
--- /dev/null
@@ -0,0 +1,85 @@
+/*
+* Copyright (c) 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.
+* You may obtain a copy of the License at
+*
+* http://www.apache.org/licenses/LICENSE-2.0
+*
+* Unless required by applicable law or agreed to in writing, software
+* distributed under the License is distributed on an "AS IS" BASIS,
+* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+* See the License for the specific language governing permissions and
+* limitations under the License.
+*/
+
+
+#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);
+}