--- /dev/null
+/*
+* Copyright (c) 2020 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 <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 by simple
+ * @since_tizen 6.0
+ *
+ *
+ * @param[in] path The file path to play
+ * @param[in] stream_role The sound stream role
+ *
+ * @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
+ *
+ */
+int wav_player_play_simple(const char *path, const char *stream_role);
+
+
+/**
+ * @}
+ */
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif /* __TIZEN_MEDIA_WAV_PLAYER_INTERNAL_H__ */
\ No newline at end of file
int _convert_wav_player_error_code(const char *func, int code);
int _wav_play_sound(const char *path, sound_stream_info_h stream_info, unsigned int loop_count,
wav_player_playback_completed_cb cb, void *user_data, int *id);
+int _wav_play_sound_simple(const char *path, const char *stream_role);
int _wav_stop_sound(int id);
#ifdef __cplusplus
Name: capi-media-wav-player
Summary: A wav player library in Tizen C API
-Version: 0.3.3
+Version: 0.3.4
Release: 0
Group: Multimedia/API
License: Apache-2.0
--- /dev/null
+/*
+* Copyright (c) 2020 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 "TIZEN_N_WAV_PLAYER"
+
+#include "wav_player_private.h"
+
+int wav_player_play_simple(const char *path, const char *stream_role)
+{
+ return _wav_play_sound_simple(path, stream_role);
+}
return WAV_PLAYER_ERROR_NONE;
}
+int _wav_play_sound_simple(const char *path, const char *stream_role)
+{
+ int ret = WAV_PLAYER_ERROR_NONE;
+ char m_path[PATH_MAX];
+ int handle;
+ GError *err = NULL;
+ GVariant *reply = NULL;
+ GDBusConnection *conn = NULL;
+
+ if (!path || !stream_role) {
+ LOGE("invalid params path(%p), stream_role(%p)", path, stream_role);
+ return WAV_PLAYER_ERROR_INVALID_PARAMETER;
+ }
+
+ LOGI("path(%s), stream_role(%s)", path, stream_role);
+
+ /* FIXME : need extraction of duplicated path validation code */
+ m_path[0] = '\0';
+ if (path[0] != '/' && getcwd(m_path, PATH_MAX) != NULL)
+ strncat(m_path, "/", PATH_MAX - strlen(m_path) - 1);
+
+ strncat(m_path, path, PATH_MAX - strlen(m_path) - 1);
+ if (access(m_path, R_OK) != 0) {
+ char str_error[256];
+ strerror_r(errno, str_error, sizeof(str_error));
+ LOGE("file [%s] doesn't exists : [%s][%d]", m_path, str_error, errno);
+ return WAV_PLAYER_ERROR_INVALID_OPERATION;
+ }
+
+ if (!(conn = __get_dbus_connection()))
+ return WAV_PLAYER_ERROR_INVALID_OPERATION;
+
+ reply = g_dbus_connection_call_sync(conn, PA_BUS_NAME,
+ PA_SOUND_PLAYER_OBJECT_PATH,
+ PA_SOUND_PLAYER_INTERFACE,
+ PA_SOUND_PLAYER_METHOD_NAME_SOUND_PLAY,
+ g_variant_new("(siisi)", m_path, 1,
+ getpid(), stream_role, -1),
+ NULL, G_DBUS_CALL_FLAGS_NONE, -1, NULL, &err);
+ if (!reply) {
+ if (err) {
+ LOGE("g_dbus_connection_call_sync error (%s)", err->message);
+ ret = __convert_dbus_error(err->message);
+ g_error_free(err);
+ } else {
+ ret = WAV_PLAYER_ERROR_INVALID_OPERATION;
+ }
+ goto finish;
+ }
+
+ g_variant_get(reply, "(i)", &handle);
+ g_variant_unref(reply);
+
+ LOGI("handle : %d", handle);
+
+finish:
+ g_object_unref(conn);
+
+ return ret;
+}
+
int _wav_stop_sound(int id)
{
GDBusConnection *conn = NULL;
#include <stdio.h>
#include <wav_player.h>
+#include <wav_player_internal.h>
#include <sound_manager.h>
#include <sound_manager_internal.h>
#include <glib.h>
" -f, --file file path to play\n"
" -s, --streamtype stream type (0:media(default), 1:system, 2:notification, 3:voice-information, 4:solo)\n"
" -i, --iterate how many times to play\n"
+ " -q, --quickplay play quick\n"
" -h, --help help\n");
}
return;
}
-void wav_play_test(const char* file_path, int iterate, int stream_type)
+void wav_play_test(const char *file_path, int iterate, int stream_type)
{
int ret = 0;
sound_stream_info_h stream_info;
g_main_loop_run(g_mainloop);
}
+void wav_play_test_quick(const char *file_path)
+{
+ int ret = 0;
+
+ if (file_path == NULL) {
+ printf("invalid file path\n");
+ return;
+ }
+
+ printf("Play Wav, File Path : %s\n", file_path);
+
+ ret = wav_player_play_simple(file_path, "system");
+ printf("wav_player_play_simple() ret = 0x%X\n", ret);
+}
+
void __sig_handler(int signo)
{
sigset_t old_mask, all_mask;
{
int iterate = 1;
int stream_type = 0;
+ bool quickplay = false;
char file_path[FILE_PATH_MAX] = DEFAULT_FILE;
struct sigaction sig_action;
sig_action.sa_handler = __sig_handler;
{"iterate" , required_argument, 0, 'i'},
{"file" , required_argument, 0, 'f'},
{"streamtype" , required_argument, 0, 's'},
+ {"quickplay" , no_argument, 0, 'q'},
{ 0, 0, 0, 0 }
};
- if ((opt = getopt_long(argc, argv, "i:f:s:", long_options, &opt_idx)) == -1)
+ if ((opt = getopt_long(argc, argv, "i:f:s:q", long_options, &opt_idx)) == -1)
break;
switch (opt) {
case 's':
stream_type = atoi(optarg);
break;
+ case 'q':
+ quickplay = true;
+ break;
case 'h':
default:
help();
}
}
- wav_play_test(file_path, iterate, stream_type);
+ if (quickplay)
+ wav_play_test_quick(file_path);
+ else
+ wav_play_test(file_path, iterate, stream_type);
return 0;
}