#define MUTE_KEY "mute_by_device_disconnection"
#define TIMED_UNMUTE_USEC 300000
+#define MONITORING_INTERVAL_SEC 3 /* FIXME: make this configurable */
+
static const char* process_command_type_str[] = {
[PROCESS_COMMAND_PREPARE] = "PREPARE",
[PROCESS_COMMAND_CHANGE_ROUTE_BY_STREAM_STARTED] = "CHANGE_ROUTE_BY_STREAM_STARTED",
m->time_event_for_unmute = NULL;
}
+static void dump_ducking(pa_stream_manager *m) {
+ stream_ducking *sd = NULL;
+ void *state = NULL;
+ pa_client* client = NULL;
+ unsigned int iteration = 0;
+
+ if (!m->stream_duckings) {
+ pa_log_warn("No stream_duckings hashmap available....");
+ return;
+ }
+
+ if (pa_hashmap_isempty(m->stream_duckings)) {
+ pa_log_warn("No ducking to dump");
+ return;
+ }
+
+ while ((sd = pa_hashmap_iterate(m->stream_duckings, &state, NULL))) {
+ client = pa_idxset_get_by_index(m->core->clients, sd->trigger_index);
+
+ pa_log_warn(" #(%2u/%2u), client(%5d), app(%s, %s), state(%u), ducking_streams(%u, %d), target_role(%s)",
+ ++iteration, pa_hashmap_size(m->stream_duckings),
+ sd->trigger_index,
+ pa_strnull(client ? pa_proplist_gets(client->proplist, PA_PROP_APPLICATION_PROCESS_ID) : NULL),
+ pa_strnull(client ? pa_proplist_gets(client->proplist, PA_PROP_APPLICATION_PROCESS_BINARY) : NULL),
+ sd->state,
+ pa_idxset_size(sd->idx_ducking_streams), sd->ducking_stream_count,
+ pa_strnull(sd->target_role));
+ }
+}
+
+static void monitoring_cb(pa_mainloop_api *a, pa_time_event *e, const struct timeval *t, void *userdata) {
+ pa_stream_manager *m = (pa_stream_manager *)userdata;
+
+ pa_assert(m);
+
+ pa_log_info("monitoring callback invoked, event(%p)", e);
+
+ pa_core_dump_sink_inputs(m->core);
+ pa_core_dump_source_outputs(m->core);
+ dump_ducking(m);
+
+ pa_core_rttime_restart(m->core, e, pa_rtclock_now() + (MONITORING_INTERVAL_SEC * PA_USEC_PER_SEC));
+}
+
static int active_device_filter_func(const void *i, const void *device_type) {
pa_assert(i);
pa_assert(device_type);
set_initial_active_device(m);
+ // FIXME: timer should be configurable by daemon.conf
+ m->time_event_for_monitoring = pa_core_rttime_new(m->core, pa_rtclock_now() + (3 * PA_USEC_PER_SEC), monitoring_cb, m);
+
pa_shared_set(c, SHARED_STREAM_MANAGER, m);
return m;
if (m->stream_duckings)
pa_hashmap_free(m->stream_duckings);
+ if (m->time_event_for_monitoring)
+ m->core->mainloop->time_free(m->time_event_for_monitoring);
+
deinit_volumes(m);
deinit_stream_map(m);
deinit_ipc(m);