{ "repeat", "i", "in" },
{ "client_pid", "i", "in" },
{ "role", "s", "in" },
- { "parent_id", "i", "in" } };
+ { "parent_id", "i", "in" },
+ { "stop_others", "b", "in" } };
static pa_dbus_arg_info sound_stop_args[] = { { "stream_idx", "i", "in" } };
-static const char* signature_args_for_in[] = { "sss", "s", NULL, "sss", "siisi", "i" };
+static const char* signature_args_for_in[] = { "sss", "s", NULL, "sss", "siisib", "i" };
static pa_dbus_method_handler method_handlers[METHOD_HANDLER_MAX] = {
[METHOD_HANDLER_SIMPLE_PLAY] = {
" <arg name=\"client_pid\" direction=\"in\" type=\"i\"/>" \
" <arg name=\"role\" direction=\"in\" type=\"s\"/>" \
" <arg name=\"parent_id\" direction=\"in\" type=\"i\"/>" \
+ " <arg name=\"stop_others\" direction=\"in\" type=\"b\"/>" \
" </method>" \
" <method name=\"SOUND_PLAYER_METHOD_NAME_SOUND_STOP\">" \
" <arg name=\"stream_idx\" direction=\"in\" type=\"i\"/>" \
}
}
+static void _sound_stop_all(struct userdata *u) {
+ pa_sink_input *si;
+ uint32_t idx;
+ int32_t *stream_idx;
+
+ pa_assert(u);
+
+ PA_IDXSET_FOREACH(stream_idx, u->stream_idxs, idx) {
+ pa_assert(stream_idx);
+
+ si = pa_idxset_get_by_index(u->module->core->sink_inputs, *stream_idx);
+ if (!si) {
+ pa_log_warn("null sink input for stream idx(%d)", *stream_idx);
+ continue;
+ }
+
+ pa_log_info("killing sink-input(%d), stream_idx(%d)", si->index, *stream_idx);
+ pa_sink_input_kill(si);
+ }
+}
+
static int _sample_play(struct userdata *u, const char *sample_name, const char *role, const char *vol_gain_type) {
int ret = 0;
pa_sink *sink = NULL;
const char *role;
uint32_t parent_id;
uint32_t stream_idx;
+ dbus_bool_t stop_others = false;
pa_proplist *p;
pa_assert_se(dbus_message_get_args(msg, NULL,
DBUS_TYPE_INT32, &client_pid,
DBUS_TYPE_STRING, &role,
DBUS_TYPE_INT32, &parent_id,
+ DBUS_TYPE_BOOLEAN, &stop_others,
DBUS_TYPE_INVALID));
+ if (stop_others) {
+ pa_log_info("stop_others enabled, stop all other sounds");
+ _sound_stop_all(u);
+ pa_log_info("stop done, ready to play the requested one");
+ }
+
p = pa_proplist_new();
pa_proplist_sets(p, PA_PROP_MEDIA_ROLE, role);
pa_proplist_setf(p, PA_PROP_APPLICATION_PROCESS_ID_ORIGIN, "%d", client_pid);