*/
int wav_player_play_simple(const char *path, const char *stream_role);
+/**
+ * @internal
+ * @brief Plays a WAV file after stopping previous WAV playbacks
+ * @since_tizen 7.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 times the file should be played (@c 0 indicates infinite loops)
+ * @param[in] callback The callback function to be invoked when the 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
+ *
+ */
+int wav_player_start_loop_stop_others(const char *path,
+ sound_stream_info_h stream_info,
+ unsigned int loop_count,
+ wav_player_playback_completed_cb callback,
+ void *user_data,
+ int *id);
+
/**
* @}
}
#endif
-#endif /* __TIZEN_MEDIA_WAV_PLAYER_INTERNAL_H__ */
\ No newline at end of file
+#endif /* __TIZEN_MEDIA_WAV_PLAYER_INTERNAL_H__ */
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);
+ wav_player_playback_completed_cb cb, void *user_data, bool stop_others, int *id);
int _wav_play_sound_simple(const char *path, const char *stream_role);
int _wav_stop_sound(int id);
Name: capi-media-wav-player
Summary: A wav player library in Tizen C API
-Version: 0.3.8
+Version: 0.3.9
Release: 0
Group: Multimedia/API
License: Apache-2.0
int wav_player_start_new(const char *path, sound_stream_info_h stream_info,
wav_player_playback_completed_cb callback, void *user_data, int *id)
{
- return _wav_play_sound(path, stream_info, 1, callback, user_data, id);
+ return _wav_play_sound(path, stream_info, 1, callback, user_data, false, id);
}
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)
{
- return _wav_play_sound(path, stream_info, loop_count, callback, user_data, id);
+ return _wav_play_sound(path, stream_info, loop_count, callback, user_data, false, id);
}
int wav_player_stop(int id)
{
return _wav_play_sound_simple(path, stream_role);
}
+
+int wav_player_start_loop_stop_others(const char *path,
+ sound_stream_info_h stream_info,
+ unsigned int loop_count,
+ wav_player_playback_completed_cb callback,
+ void *user_data,
+ int *id)
+{
+ return _wav_play_sound(path, stream_info, loop_count, callback, user_data, true, id);
+}
}
int _wav_play_sound(const char *path, sound_stream_info_h stream_info, unsigned loop_count,
- wav_player_playback_completed_cb callback, void *user_data, int *id)
+ wav_player_playback_completed_cb callback, void *user_data, bool stop_others, int *id)
{
int ret = WAV_PLAYER_ERROR_NONE;
char m_path[PATH_MAX];
PA_SOUND_PLAYER_OBJECT_PATH,
PA_SOUND_PLAYER_INTERFACE,
PA_SOUND_PLAYER_METHOD_NAME_SOUND_PLAY,
- g_variant_new("(siisi)", m_path, loop_count == 0 ? -1 : loop_count,
- getpid(), stream_type, stream_id),
+ g_variant_new("(siisib)", m_path, loop_count == 0 ? -1 : loop_count,
+ getpid(), stream_type, stream_id, (gboolean)stop_others),
NULL, G_DBUS_CALL_FLAGS_NONE, -1, NULL, &err);
if (!reply) {
LOGE("g_dbus_connection_call_sync error (%s)", err->message);
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),
+ g_variant_new("(siisib)", m_path, 1,
+ getpid(), stream_role, -1, FALSE),
NULL, G_DBUS_CALL_FLAGS_NONE, -1, NULL, &err);
if (!reply) {
if (err) {
" -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"
+ " -o, --stopothers play after stopping others\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, bool stop_others)
{
int ret = 0;
sound_stream_info_h stream_info;
}
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, &gid);
- printf("wav_player_start_loop(id=%d) ret = %d\n", gid, ret);
+ if (stop_others) {
+ ret = wav_player_start_loop_stop_others(file_path, stream_info, iterate, _player_stop_cb, (void*)stream_info, &gid);
+ printf("wav_player_start_loop_stop_others(id=%d) ret = %d\n", gid, ret);
+ } else {
+ ret = wav_player_start_loop(file_path, stream_info, iterate, _player_stop_cb, (void*)stream_info, &gid);
+ printf("wav_player_start_loop(id=%d) ret = %d\n", gid, ret);
+ }
if (ret) {
sound_manager_destroy_stream_information(stream_info);
return;
int iterate = 1;
int stream_type = 0;
bool quickplay = false;
+ bool stop_others = false;
char file_path[FILE_PATH_MAX] = DEFAULT_FILE;
struct sigaction sig_action;
sig_action.sa_handler = __sig_handler;
{"file" , required_argument, 0, 'f'},
{"streamtype" , required_argument, 0, 's'},
{"quickplay" , no_argument, 0, 'q'},
+ {"stopothers" , no_argument, 0, 'o'},
+ {"help" , no_argument, 0, 'h'},
{ 0, 0, 0, 0 }
};
- if ((opt = getopt_long(argc, argv, "i:f:s:q", long_options, &opt_idx)) == -1)
+ if ((opt = getopt_long(argc, argv, "i:f:s:qoh", long_options, &opt_idx)) == -1)
break;
+ printf("opt = %d(%c), opt_idx = %d\n", opt, opt, opt_idx);
+
switch (opt) {
- case 'f':
- strncpy(file_path, optarg, FILE_PATH_MAX - 1);
- file_path[FILE_PATH_MAX - 1] = '\0';
- break;
case 'i':
iterate = atoi(optarg);
break;
+ case 'f':
+ snprintf(file_path, FILE_PATH_MAX, "%s", optarg);
+ break;
case 's':
stream_type = atoi(optarg);
break;
case 'q':
quickplay = true;
break;
+ case 'o':
+ stop_others = true;
+ break;
case 'h':
default:
help();
if (quickplay)
wav_play_test_quick(file_path);
else
- wav_play_test(file_path, iterate, stream_type);
+ wav_play_test(file_path, iterate, stream_type, stop_others);
return 0;
}