2004-07-16 19:56:36 +00:00
|
|
|
/***
|
2006-06-19 21:53:48 +00:00
|
|
|
This file is part of PulseAudio.
|
2007-01-04 13:43:45 +00:00
|
|
|
|
2007-02-13 15:35:19 +00:00
|
|
|
Copyright 2004-2006 Lennart Poettering
|
|
|
|
|
|
2006-06-19 21:53:48 +00:00
|
|
|
PulseAudio is free software; you can redistribute it and/or modify
|
2004-11-14 14:58:54 +00:00
|
|
|
it under the terms of the GNU Lesser General Public License as published
|
2009-03-03 20:23:02 +00:00
|
|
|
by the Free Software Foundation; either version 2.1 of the License,
|
2004-07-16 19:56:36 +00:00
|
|
|
or (at your option) any later version.
|
2007-01-04 13:43:45 +00:00
|
|
|
|
2006-06-19 21:53:48 +00:00
|
|
|
PulseAudio is distributed in the hope that it will be useful, but
|
2004-07-16 19:56:36 +00:00
|
|
|
WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
|
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
|
|
|
|
General Public License for more details.
|
2007-01-04 13:43:45 +00:00
|
|
|
|
2004-11-14 14:58:54 +00:00
|
|
|
You should have received a copy of the GNU Lesser General Public License
|
2014-11-26 14:14:51 +01:00
|
|
|
along with PulseAudio; if not, see <http://www.gnu.org/licenses/>.
|
2004-07-16 19:56:36 +00:00
|
|
|
***/
|
|
|
|
|
|
2004-07-16 19:16:42 +00:00
|
|
|
#ifdef HAVE_CONFIG_H
|
|
|
|
|
#include <config.h>
|
|
|
|
|
#endif
|
|
|
|
|
|
2006-06-19 21:53:48 +00:00
|
|
|
#include <pulse/volume.h>
|
|
|
|
|
#include <pulse/xmalloc.h>
|
2008-05-15 23:34:41 +00:00
|
|
|
#include <pulse/timeval.h>
|
2006-05-17 16:34:18 +00:00
|
|
|
|
2006-06-19 21:53:48 +00:00
|
|
|
#include <pulsecore/module.h>
|
|
|
|
|
#include <pulsecore/client.h>
|
|
|
|
|
#include <pulsecore/sink.h>
|
|
|
|
|
#include <pulsecore/source.h>
|
|
|
|
|
#include <pulsecore/sink-input.h>
|
|
|
|
|
#include <pulsecore/source-output.h>
|
|
|
|
|
#include <pulsecore/strbuf.h>
|
|
|
|
|
#include <pulsecore/core-scache.h>
|
2007-10-28 19:13:50 +00:00
|
|
|
#include <pulsecore/macro.h>
|
2008-05-15 23:34:41 +00:00
|
|
|
#include <pulsecore/core-util.h>
|
2012-10-16 16:05:52 +02:00
|
|
|
#include <pulsecore/namereg.h>
|
2006-02-17 12:10:58 +00:00
|
|
|
|
|
|
|
|
#include "cli-text.h"
|
2004-07-11 01:09:46 +00:00
|
|
|
|
2006-01-11 01:17:39 +00:00
|
|
|
char *pa_module_list_to_string(pa_core *c) {
|
|
|
|
|
pa_strbuf *s;
|
|
|
|
|
pa_module *m;
|
|
|
|
|
uint32_t idx = PA_IDXSET_INVALID;
|
2007-10-28 19:13:50 +00:00
|
|
|
pa_assert(c);
|
2004-07-11 01:09:46 +00:00
|
|
|
|
|
|
|
|
s = pa_strbuf_new();
|
|
|
|
|
|
2006-01-11 01:17:39 +00:00
|
|
|
pa_strbuf_printf(s, "%u module(s) loaded.\n", pa_idxset_size(c->modules));
|
2007-01-04 13:43:45 +00:00
|
|
|
|
2012-05-29 17:58:12 +05:30
|
|
|
PA_IDXSET_FOREACH(m, c->modules, idx) {
|
2009-01-19 22:02:28 +01:00
|
|
|
char *t;
|
|
|
|
|
|
2007-03-06 15:47:11 +00:00
|
|
|
pa_strbuf_printf(s, " index: %u\n"
|
2008-05-15 23:34:41 +00:00
|
|
|
"\tname: <%s>\n"
|
|
|
|
|
"\targument: <%s>\n"
|
|
|
|
|
"\tused: %i\n"
|
2009-01-15 20:07:13 +01:00
|
|
|
"\tload once: %s\n",
|
|
|
|
|
m->index,
|
|
|
|
|
m->name,
|
|
|
|
|
pa_strempty(m->argument),
|
2009-01-15 20:49:12 +01:00
|
|
|
pa_module_get_n_used(m),
|
2009-01-15 20:07:13 +01:00
|
|
|
pa_yes_no(m->load_once));
|
2009-01-19 22:02:28 +01:00
|
|
|
|
|
|
|
|
t = pa_proplist_to_string_sep(m->proplist, "\n\t\t");
|
|
|
|
|
pa_strbuf_printf(s, "\tproperties:\n\t\t%s\n", t);
|
|
|
|
|
pa_xfree(t);
|
2007-03-06 15:47:11 +00:00
|
|
|
}
|
2007-01-04 13:43:45 +00:00
|
|
|
|
2015-06-12 18:17:07 +05:30
|
|
|
return pa_strbuf_to_string_free(s);
|
2004-07-11 01:09:46 +00:00
|
|
|
}
|
|
|
|
|
|
2006-01-11 01:17:39 +00:00
|
|
|
char *pa_client_list_to_string(pa_core *c) {
|
|
|
|
|
pa_strbuf *s;
|
|
|
|
|
pa_client *client;
|
|
|
|
|
uint32_t idx = PA_IDXSET_INVALID;
|
2007-10-28 19:13:50 +00:00
|
|
|
pa_assert(c);
|
2004-07-11 01:09:46 +00:00
|
|
|
|
|
|
|
|
s = pa_strbuf_new();
|
|
|
|
|
|
2006-01-11 01:17:39 +00:00
|
|
|
pa_strbuf_printf(s, "%u client(s) logged in.\n", pa_idxset_size(c->clients));
|
2007-01-04 13:43:45 +00:00
|
|
|
|
2012-05-29 17:58:12 +05:30
|
|
|
PA_IDXSET_FOREACH(client, c->clients, idx) {
|
2008-05-15 23:34:41 +00:00
|
|
|
char *t;
|
|
|
|
|
pa_strbuf_printf(
|
|
|
|
|
s,
|
|
|
|
|
" index: %u\n"
|
|
|
|
|
"\tdriver: <%s>\n",
|
|
|
|
|
client->index,
|
|
|
|
|
client->driver);
|
2004-07-11 01:09:46 +00:00
|
|
|
|
2008-05-15 23:34:41 +00:00
|
|
|
if (client->module)
|
|
|
|
|
pa_strbuf_printf(s, "\towner module: %u\n", client->module->index);
|
|
|
|
|
|
2009-01-17 02:09:02 +01:00
|
|
|
t = pa_proplist_to_string_sep(client->proplist, "\n\t\t");
|
|
|
|
|
pa_strbuf_printf(s, "\tproperties:\n\t\t%s\n", t);
|
2008-05-15 23:34:41 +00:00
|
|
|
pa_xfree(t);
|
2004-07-11 01:09:46 +00:00
|
|
|
}
|
2007-01-04 13:43:45 +00:00
|
|
|
|
2015-06-12 18:17:07 +05:30
|
|
|
return pa_strbuf_to_string_free(s);
|
2004-07-11 01:09:46 +00:00
|
|
|
}
|
|
|
|
|
|
2013-02-18 09:10:32 +01:00
|
|
|
static const char *available_to_string(pa_available_t a) {
|
2011-11-25 15:17:15 +01:00
|
|
|
switch (a) {
|
2013-02-18 16:13:24 +01:00
|
|
|
case PA_AVAILABLE_UNKNOWN:
|
2011-11-25 15:17:15 +01:00
|
|
|
return "unknown";
|
2013-02-18 16:13:24 +01:00
|
|
|
case PA_AVAILABLE_NO:
|
2011-11-25 15:17:15 +01:00
|
|
|
return "no";
|
2013-02-18 16:13:24 +01:00
|
|
|
case PA_AVAILABLE_YES:
|
2011-11-25 15:17:15 +01:00
|
|
|
return "yes";
|
|
|
|
|
default:
|
|
|
|
|
return "invalid"; /* Should never happen! */
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2013-06-18 22:24:24 +02:00
|
|
|
static void append_port_list(pa_strbuf *s, pa_hashmap *ports) {
|
2011-11-25 15:17:15 +01:00
|
|
|
pa_device_port *p;
|
|
|
|
|
void *state;
|
|
|
|
|
|
2012-06-08 21:49:12 +03:00
|
|
|
pa_assert(ports);
|
|
|
|
|
|
|
|
|
|
if (pa_hashmap_isempty(ports))
|
2011-11-25 15:17:15 +01:00
|
|
|
return;
|
|
|
|
|
|
|
|
|
|
pa_strbuf_puts(s, "\tports:\n");
|
2011-12-02 13:34:54 +01:00
|
|
|
PA_HASHMAP_FOREACH(p, ports, state) {
|
|
|
|
|
char *t = pa_proplist_to_string_sep(p->proplist, "\n\t\t\t\t");
|
2012-06-22 20:55:55 +02:00
|
|
|
pa_strbuf_printf(s, "\t\t%s: %s (priority %u, latency offset %" PRId64 " usec, available: %s)\n",
|
|
|
|
|
p->name, p->description, p->priority, p->latency_offset,
|
2013-02-18 09:10:32 +01:00
|
|
|
available_to_string(p->available));
|
2011-12-02 13:34:54 +01:00
|
|
|
pa_strbuf_printf(s, "\t\t\tproperties:\n\t\t\t\t%s\n", t);
|
|
|
|
|
pa_xfree(t);
|
|
|
|
|
}
|
2011-11-25 15:17:15 +01:00
|
|
|
}
|
|
|
|
|
|
2009-01-15 18:52:11 +01:00
|
|
|
char *pa_card_list_to_string(pa_core *c) {
|
|
|
|
|
pa_strbuf *s;
|
|
|
|
|
pa_card *card;
|
|
|
|
|
uint32_t idx = PA_IDXSET_INVALID;
|
|
|
|
|
pa_assert(c);
|
|
|
|
|
|
|
|
|
|
s = pa_strbuf_new();
|
|
|
|
|
|
2009-01-17 02:09:02 +01:00
|
|
|
pa_strbuf_printf(s, "%u card(s) available.\n", pa_idxset_size(c->cards));
|
2009-01-15 18:52:11 +01:00
|
|
|
|
2012-05-29 17:58:12 +05:30
|
|
|
PA_IDXSET_FOREACH(card, c->cards, idx) {
|
2009-01-15 18:52:11 +01:00
|
|
|
char *t;
|
2009-01-23 22:30:31 +01:00
|
|
|
pa_sink *sink;
|
|
|
|
|
pa_source *source;
|
|
|
|
|
uint32_t sidx;
|
2012-06-08 21:49:10 +03:00
|
|
|
pa_card_profile *profile;
|
|
|
|
|
void *state;
|
2009-01-23 22:30:31 +01:00
|
|
|
|
2009-01-15 18:52:11 +01:00
|
|
|
pa_strbuf_printf(
|
|
|
|
|
s,
|
|
|
|
|
" index: %u\n"
|
|
|
|
|
"\tname: <%s>\n"
|
|
|
|
|
"\tdriver: <%s>\n",
|
|
|
|
|
card->index,
|
|
|
|
|
card->name,
|
|
|
|
|
card->driver);
|
|
|
|
|
|
|
|
|
|
if (card->module)
|
|
|
|
|
pa_strbuf_printf(s, "\towner module: %u\n", card->module->index);
|
|
|
|
|
|
2009-01-17 02:03:59 +01:00
|
|
|
t = pa_proplist_to_string_sep(card->proplist, "\n\t\t");
|
|
|
|
|
pa_strbuf_printf(s, "\tproperties:\n\t\t%s\n", t);
|
2009-01-15 18:52:11 +01:00
|
|
|
pa_xfree(t);
|
2009-01-17 02:03:59 +01:00
|
|
|
|
2012-06-08 21:49:10 +03:00
|
|
|
pa_strbuf_puts(s, "\tprofiles:\n");
|
|
|
|
|
PA_HASHMAP_FOREACH(profile, card->profiles, state)
|
2013-02-18 09:10:32 +01:00
|
|
|
pa_strbuf_printf(s, "\t\t%s: %s (priority %u, available: %s)\n", profile->name, profile->description,
|
|
|
|
|
profile->priority, available_to_string(profile->available));
|
2009-01-17 02:03:59 +01:00
|
|
|
|
2012-06-08 21:49:10 +03:00
|
|
|
pa_strbuf_printf(
|
|
|
|
|
s,
|
|
|
|
|
"\tactive profile: <%s>\n",
|
|
|
|
|
card->active_profile->name);
|
2009-01-23 22:30:31 +01:00
|
|
|
|
|
|
|
|
if (!pa_idxset_isempty(card->sinks)) {
|
|
|
|
|
pa_strbuf_puts(s, "\tsinks:\n");
|
2012-05-29 17:58:12 +05:30
|
|
|
PA_IDXSET_FOREACH(sink, card->sinks, sidx)
|
2009-01-23 22:30:31 +01:00
|
|
|
pa_strbuf_printf(s, "\t\t%s/#%u: %s\n", sink->name, sink->index, pa_strna(pa_proplist_gets(sink->proplist, PA_PROP_DEVICE_DESCRIPTION)));
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (!pa_idxset_isempty(card->sources)) {
|
|
|
|
|
pa_strbuf_puts(s, "\tsources:\n");
|
2012-05-29 17:58:12 +05:30
|
|
|
PA_IDXSET_FOREACH(source, card->sources, sidx)
|
2009-01-23 22:30:31 +01:00
|
|
|
pa_strbuf_printf(s, "\t\t%s/#%u: %s\n", source->name, source->index, pa_strna(pa_proplist_gets(source->proplist, PA_PROP_DEVICE_DESCRIPTION)));
|
|
|
|
|
}
|
2011-11-25 15:17:15 +01:00
|
|
|
|
|
|
|
|
append_port_list(s, card->ports);
|
2009-01-15 18:52:11 +01:00
|
|
|
}
|
|
|
|
|
|
2015-06-12 18:17:07 +05:30
|
|
|
return pa_strbuf_to_string_free(s);
|
2009-01-15 18:52:11 +01:00
|
|
|
}
|
|
|
|
|
|
2006-01-11 01:17:39 +00:00
|
|
|
char *pa_sink_list_to_string(pa_core *c) {
|
|
|
|
|
pa_strbuf *s;
|
improve default sink/source handling
Currently the default sink policy is simple: either the user has
configured it explicitly, in which case we always use that as the
default, or we pick the sink with the highest priority. The sink
priorities are currently static, so there's no need to worry about
updating the default sink when sink priorities change.
I intend to make things a bit more complex: if the active port of a sink
is unavailable, the sink should not be the default sink, and I also want
to make sink priorities dependent on the active port, so changing the
port should cause re-evaluation of which sink to choose as the default.
Currently the default sink choice is done only when someone calls
pa_namereg_get_default_sink(), and change notifications are only sent
when a sink is created or destroyed. That makes it hard to add new rules
to the default sink selection policy.
This patch moves the default sink selection to
pa_core_update_default_sink(), which is called whenever something
happens that can affect the default sink choice. That function needs to
know the previous choice in order to send change notifications as
appropriate, but previously pa_core.default_sink was only set when the
user had configured it explicitly. Now pa_core.default_sink is always
set (unless there are no sinks at all), so pa_core_update_default_sink()
can use that to get the previous choice. The user configuration is saved
in a new variable, pa_core.configured_default_sink.
pa_namereg_get_default_sink() is now unnecessary, because
pa_core.default_sink can be used directly to get the
currently-considered-best sink. pa_namereg_set_default_sink() is
replaced by pa_core_set_configured_default_sink().
I haven't confirmed it, but I expect that this patch will fix problems
in the D-Bus protocol related to default sink handling. The D-Bus
protocol used to get confused when the current default sink gets
removed. It would incorrectly think that if there's no explicitly
configured default sink, then there's no default sink at all. Even
worse, when the D-Bus thinks that there's no default sink, it concludes
that there are no sinks at all, which made it impossible to configure
the default sink via the D-Bus interface. Now that pa_core.default_sink
is always set, except when there really aren't any sinks, the D-Bus
protocol should behave correctly.
BugLink: https://bugs.freedesktop.org/show_bug.cgi?id=99425
2017-02-16 12:09:38 +02:00
|
|
|
pa_sink *sink;
|
2006-01-11 01:17:39 +00:00
|
|
|
uint32_t idx = PA_IDXSET_INVALID;
|
2007-10-28 19:13:50 +00:00
|
|
|
pa_assert(c);
|
2004-07-11 01:09:46 +00:00
|
|
|
|
|
|
|
|
s = pa_strbuf_new();
|
|
|
|
|
|
2006-01-11 01:17:39 +00:00
|
|
|
pa_strbuf_printf(s, "%u sink(s) available.\n", pa_idxset_size(c->sinks));
|
2004-07-11 01:09:46 +00:00
|
|
|
|
2012-05-29 17:58:12 +05:30
|
|
|
PA_IDXSET_FOREACH(sink, c->sinks, idx) {
|
2008-12-24 00:49:43 +01:00
|
|
|
char ss[PA_SAMPLE_SPEC_SNPRINT_MAX],
|
2013-04-03 16:36:43 +03:00
|
|
|
cv[PA_CVOLUME_SNPRINT_VERBOSE_MAX],
|
|
|
|
|
v[PA_VOLUME_SNPRINT_VERBOSE_MAX],
|
2008-12-24 00:49:43 +01:00
|
|
|
cm[PA_CHANNEL_MAP_SNPRINT_MAX], *t;
|
2009-01-27 00:55:35 +01:00
|
|
|
const char *cmn;
|
2017-12-28 12:09:19 +02:00
|
|
|
char suspend_cause_buf[PA_SUSPEND_CAUSE_TO_STRING_BUF_SIZE];
|
2009-01-27 00:55:35 +01:00
|
|
|
|
|
|
|
|
cmn = pa_channel_map_to_pretty_name(&sink->channel_map);
|
2008-06-20 22:32:41 +02:00
|
|
|
|
2004-07-11 01:09:46 +00:00
|
|
|
pa_strbuf_printf(
|
|
|
|
|
s,
|
2006-01-27 16:25:31 +00:00
|
|
|
" %c index: %u\n"
|
|
|
|
|
"\tname: <%s>\n"
|
|
|
|
|
"\tdriver: <%s>\n"
|
2009-03-25 00:30:54 +01:00
|
|
|
"\tflags: %s%s%s%s%s%s%s%s\n"
|
2007-10-28 19:13:50 +00:00
|
|
|
"\tstate: %s\n"
|
2017-12-28 12:09:19 +02:00
|
|
|
"\tsuspend cause: %s\n"
|
2009-08-28 23:30:41 +02:00
|
|
|
"\tpriority: %u\n"
|
2013-04-03 16:36:43 +03:00
|
|
|
"\tvolume: %s\n"
|
2009-01-19 23:06:37 +01:00
|
|
|
"\t balance %0.2f\n"
|
2013-04-03 16:36:43 +03:00
|
|
|
"\tbase volume: %s\n"
|
2009-01-27 04:39:07 +01:00
|
|
|
"\tvolume steps: %u\n"
|
2008-05-15 23:34:41 +00:00
|
|
|
"\tmuted: %s\n"
|
|
|
|
|
"\tcurrent latency: %0.2f ms\n"
|
2008-06-20 22:32:41 +02:00
|
|
|
"\tmax request: %lu KiB\n"
|
|
|
|
|
"\tmax rewind: %lu KiB\n"
|
2008-05-15 23:34:41 +00:00
|
|
|
"\tmonitor source: %u\n"
|
|
|
|
|
"\tsample spec: %s\n"
|
2009-01-27 00:55:35 +01:00
|
|
|
"\tchannel map: %s%s%s\n"
|
2008-05-15 23:34:41 +00:00
|
|
|
"\tused by: %u\n"
|
|
|
|
|
"\tlinked by: %u\n",
|
improve default sink/source handling
Currently the default sink policy is simple: either the user has
configured it explicitly, in which case we always use that as the
default, or we pick the sink with the highest priority. The sink
priorities are currently static, so there's no need to worry about
updating the default sink when sink priorities change.
I intend to make things a bit more complex: if the active port of a sink
is unavailable, the sink should not be the default sink, and I also want
to make sink priorities dependent on the active port, so changing the
port should cause re-evaluation of which sink to choose as the default.
Currently the default sink choice is done only when someone calls
pa_namereg_get_default_sink(), and change notifications are only sent
when a sink is created or destroyed. That makes it hard to add new rules
to the default sink selection policy.
This patch moves the default sink selection to
pa_core_update_default_sink(), which is called whenever something
happens that can affect the default sink choice. That function needs to
know the previous choice in order to send change notifications as
appropriate, but previously pa_core.default_sink was only set when the
user had configured it explicitly. Now pa_core.default_sink is always
set (unless there are no sinks at all), so pa_core_update_default_sink()
can use that to get the previous choice. The user configuration is saved
in a new variable, pa_core.configured_default_sink.
pa_namereg_get_default_sink() is now unnecessary, because
pa_core.default_sink can be used directly to get the
currently-considered-best sink. pa_namereg_set_default_sink() is
replaced by pa_core_set_configured_default_sink().
I haven't confirmed it, but I expect that this patch will fix problems
in the D-Bus protocol related to default sink handling. The D-Bus
protocol used to get confused when the current default sink gets
removed. It would incorrectly think that if there's no explicitly
configured default sink, then there's no default sink at all. Even
worse, when the D-Bus thinks that there's no default sink, it concludes
that there are no sinks at all, which made it impossible to configure
the default sink via the D-Bus interface. Now that pa_core.default_sink
is always set, except when there really aren't any sinks, the D-Bus
protocol should behave correctly.
BugLink: https://bugs.freedesktop.org/show_bug.cgi?id=99425
2017-02-16 12:09:38 +02:00
|
|
|
sink == c->default_sink ? '*' : ' ',
|
2007-10-28 19:13:50 +00:00
|
|
|
sink->index,
|
|
|
|
|
sink->name,
|
2006-01-27 16:25:31 +00:00
|
|
|
sink->driver,
|
2007-10-28 19:13:50 +00:00
|
|
|
sink->flags & PA_SINK_HARDWARE ? "HARDWARE " : "",
|
2007-10-29 21:23:08 +00:00
|
|
|
sink->flags & PA_SINK_NETWORK ? "NETWORK " : "",
|
2008-05-15 23:34:41 +00:00
|
|
|
sink->flags & PA_SINK_HW_MUTE_CTRL ? "HW_MUTE_CTRL " : "",
|
|
|
|
|
sink->flags & PA_SINK_HW_VOLUME_CTRL ? "HW_VOLUME_CTRL " : "",
|
|
|
|
|
sink->flags & PA_SINK_DECIBEL_VOLUME ? "DECIBEL_VOLUME " : "",
|
|
|
|
|
sink->flags & PA_SINK_LATENCY ? "LATENCY " : "",
|
2009-03-25 16:30:46 +01:00
|
|
|
sink->flags & PA_SINK_FLAT_VOLUME ? "FLAT_VOLUME " : "",
|
2009-03-25 00:30:54 +01:00
|
|
|
sink->flags & PA_SINK_DYNAMIC_LATENCY ? "DYNAMIC_LATENCY" : "",
|
2017-12-28 12:09:18 +02:00
|
|
|
pa_sink_state_to_string(pa_sink_get_state(sink)),
|
2017-12-28 12:09:19 +02:00
|
|
|
pa_suspend_cause_to_string(sink->suspend_cause, suspend_cause_buf),
|
2009-08-28 23:30:41 +02:00
|
|
|
sink->priority,
|
2013-04-03 16:36:43 +03:00
|
|
|
pa_cvolume_snprint_verbose(cv,
|
|
|
|
|
sizeof(cv),
|
|
|
|
|
pa_sink_get_volume(sink, false),
|
|
|
|
|
&sink->channel_map,
|
|
|
|
|
sink->flags & PA_SINK_DECIBEL_VOLUME),
|
2013-06-27 19:28:09 +02:00
|
|
|
pa_cvolume_get_balance(pa_sink_get_volume(sink, false), &sink->channel_map),
|
2013-04-03 16:36:43 +03:00
|
|
|
pa_volume_snprint_verbose(v, sizeof(v), sink->base_volume, sink->flags & PA_SINK_DECIBEL_VOLUME),
|
2009-01-27 04:39:07 +01:00
|
|
|
sink->n_volume_steps,
|
2013-06-27 19:28:09 +02:00
|
|
|
pa_yes_no(pa_sink_get_mute(sink, false)),
|
2008-08-19 22:39:54 +02:00
|
|
|
(double) pa_sink_get_latency(sink) / (double) PA_USEC_PER_MSEC,
|
2008-06-20 22:32:41 +02:00
|
|
|
(unsigned long) pa_sink_get_max_request(sink) / 1024,
|
|
|
|
|
(unsigned long) pa_sink_get_max_rewind(sink) / 1024,
|
2006-08-12 17:06:39 +00:00
|
|
|
sink->monitor_source ? sink->monitor_source->index : PA_INVALID_INDEX,
|
2006-01-27 16:25:31 +00:00
|
|
|
pa_sample_spec_snprint(ss, sizeof(ss), &sink->sample_spec),
|
2007-10-28 19:13:50 +00:00
|
|
|
pa_channel_map_snprint(cm, sizeof(cm), &sink->channel_map),
|
2009-01-27 04:39:07 +01:00
|
|
|
cmn ? "\n\t " : "",
|
2009-01-27 00:55:35 +01:00
|
|
|
cmn ? cmn : "",
|
2007-10-28 19:13:50 +00:00
|
|
|
pa_sink_used_by(sink),
|
|
|
|
|
pa_sink_linked_by(sink));
|
2004-07-11 01:09:46 +00:00
|
|
|
|
2009-03-25 00:30:54 +01:00
|
|
|
if (sink->flags & PA_SINK_DYNAMIC_LATENCY) {
|
|
|
|
|
pa_usec_t min_latency, max_latency;
|
|
|
|
|
pa_sink_get_latency_range(sink, &min_latency, &max_latency);
|
|
|
|
|
|
|
|
|
|
pa_strbuf_printf(
|
|
|
|
|
s,
|
|
|
|
|
"\tconfigured latency: %0.2f ms; range is %0.2f .. %0.2f ms\n",
|
|
|
|
|
(double) pa_sink_get_requested_latency(sink) / (double) PA_USEC_PER_MSEC,
|
|
|
|
|
(double) min_latency / PA_USEC_PER_MSEC,
|
|
|
|
|
(double) max_latency / PA_USEC_PER_MSEC);
|
2009-04-10 01:26:04 +02:00
|
|
|
} else
|
|
|
|
|
pa_strbuf_printf(
|
|
|
|
|
s,
|
|
|
|
|
"\tfixed latency: %0.2f ms\n",
|
2009-08-15 00:48:14 +02:00
|
|
|
(double) pa_sink_get_fixed_latency(sink) / PA_USEC_PER_MSEC);
|
2009-03-25 00:30:54 +01:00
|
|
|
|
2009-01-15 18:52:11 +01:00
|
|
|
if (sink->card)
|
|
|
|
|
pa_strbuf_printf(s, "\tcard: %u <%s>\n", sink->card->index, sink->card->name);
|
2007-10-28 19:13:50 +00:00
|
|
|
if (sink->module)
|
2008-05-15 23:34:41 +00:00
|
|
|
pa_strbuf_printf(s, "\tmodule: %u\n", sink->module->index);
|
|
|
|
|
|
2009-01-17 02:09:02 +01:00
|
|
|
t = pa_proplist_to_string_sep(sink->proplist, "\n\t\t");
|
|
|
|
|
pa_strbuf_printf(s, "\tproperties:\n\t\t%s\n", t);
|
2008-05-15 23:34:41 +00:00
|
|
|
pa_xfree(t);
|
2009-06-17 03:45:14 +02:00
|
|
|
|
2011-11-25 15:17:15 +01:00
|
|
|
append_port_list(s, sink->ports);
|
2009-06-17 03:45:14 +02:00
|
|
|
|
|
|
|
|
if (sink->active_port)
|
|
|
|
|
pa_strbuf_printf(
|
|
|
|
|
s,
|
|
|
|
|
"\tactive port: <%s>\n",
|
|
|
|
|
sink->active_port->name);
|
2004-07-11 01:09:46 +00:00
|
|
|
}
|
2007-01-04 13:43:45 +00:00
|
|
|
|
2015-06-12 18:17:07 +05:30
|
|
|
return pa_strbuf_to_string_free(s);
|
2004-07-11 01:09:46 +00:00
|
|
|
}
|
|
|
|
|
|
2006-01-11 01:17:39 +00:00
|
|
|
char *pa_source_list_to_string(pa_core *c) {
|
|
|
|
|
pa_strbuf *s;
|
improve default sink/source handling
Currently the default sink policy is simple: either the user has
configured it explicitly, in which case we always use that as the
default, or we pick the sink with the highest priority. The sink
priorities are currently static, so there's no need to worry about
updating the default sink when sink priorities change.
I intend to make things a bit more complex: if the active port of a sink
is unavailable, the sink should not be the default sink, and I also want
to make sink priorities dependent on the active port, so changing the
port should cause re-evaluation of which sink to choose as the default.
Currently the default sink choice is done only when someone calls
pa_namereg_get_default_sink(), and change notifications are only sent
when a sink is created or destroyed. That makes it hard to add new rules
to the default sink selection policy.
This patch moves the default sink selection to
pa_core_update_default_sink(), which is called whenever something
happens that can affect the default sink choice. That function needs to
know the previous choice in order to send change notifications as
appropriate, but previously pa_core.default_sink was only set when the
user had configured it explicitly. Now pa_core.default_sink is always
set (unless there are no sinks at all), so pa_core_update_default_sink()
can use that to get the previous choice. The user configuration is saved
in a new variable, pa_core.configured_default_sink.
pa_namereg_get_default_sink() is now unnecessary, because
pa_core.default_sink can be used directly to get the
currently-considered-best sink. pa_namereg_set_default_sink() is
replaced by pa_core_set_configured_default_sink().
I haven't confirmed it, but I expect that this patch will fix problems
in the D-Bus protocol related to default sink handling. The D-Bus
protocol used to get confused when the current default sink gets
removed. It would incorrectly think that if there's no explicitly
configured default sink, then there's no default sink at all. Even
worse, when the D-Bus thinks that there's no default sink, it concludes
that there are no sinks at all, which made it impossible to configure
the default sink via the D-Bus interface. Now that pa_core.default_sink
is always set, except when there really aren't any sinks, the D-Bus
protocol should behave correctly.
BugLink: https://bugs.freedesktop.org/show_bug.cgi?id=99425
2017-02-16 12:09:38 +02:00
|
|
|
pa_source *source;
|
2006-01-11 01:17:39 +00:00
|
|
|
uint32_t idx = PA_IDXSET_INVALID;
|
2007-10-28 19:13:50 +00:00
|
|
|
pa_assert(c);
|
2004-07-11 01:09:46 +00:00
|
|
|
|
|
|
|
|
s = pa_strbuf_new();
|
|
|
|
|
|
2006-01-11 01:17:39 +00:00
|
|
|
pa_strbuf_printf(s, "%u source(s) available.\n", pa_idxset_size(c->sources));
|
2004-07-11 01:09:46 +00:00
|
|
|
|
2012-05-29 17:58:12 +05:30
|
|
|
PA_IDXSET_FOREACH(source, c->sources, idx) {
|
2008-12-24 00:49:43 +01:00
|
|
|
char ss[PA_SAMPLE_SPEC_SNPRINT_MAX],
|
2013-04-03 16:36:43 +03:00
|
|
|
cv[PA_CVOLUME_SNPRINT_VERBOSE_MAX],
|
|
|
|
|
v[PA_VOLUME_SNPRINT_VERBOSE_MAX],
|
2008-12-24 00:49:43 +01:00
|
|
|
cm[PA_CHANNEL_MAP_SNPRINT_MAX], *t;
|
2009-01-27 00:55:35 +01:00
|
|
|
const char *cmn;
|
2017-12-28 12:09:19 +02:00
|
|
|
char suspend_cause_buf[PA_SUSPEND_CAUSE_TO_STRING_BUF_SIZE];
|
2009-01-27 00:55:35 +01:00
|
|
|
|
|
|
|
|
cmn = pa_channel_map_to_pretty_name(&source->channel_map);
|
2008-06-20 22:32:41 +02:00
|
|
|
|
2006-01-27 16:25:31 +00:00
|
|
|
pa_strbuf_printf(
|
|
|
|
|
s,
|
|
|
|
|
" %c index: %u\n"
|
|
|
|
|
"\tname: <%s>\n"
|
|
|
|
|
"\tdriver: <%s>\n"
|
2009-03-25 00:30:54 +01:00
|
|
|
"\tflags: %s%s%s%s%s%s%s\n"
|
2007-10-28 19:13:50 +00:00
|
|
|
"\tstate: %s\n"
|
2017-12-28 12:09:19 +02:00
|
|
|
"\tsuspend cause: %s\n"
|
2009-08-28 23:30:41 +02:00
|
|
|
"\tpriority: %u\n"
|
2013-04-03 16:36:43 +03:00
|
|
|
"\tvolume: %s\n"
|
2009-01-19 23:06:37 +01:00
|
|
|
"\t balance %0.2f\n"
|
2013-04-03 16:36:43 +03:00
|
|
|
"\tbase volume: %s\n"
|
2009-01-27 04:39:07 +01:00
|
|
|
"\tvolume steps: %u\n"
|
2008-05-15 23:34:41 +00:00
|
|
|
"\tmuted: %s\n"
|
|
|
|
|
"\tcurrent latency: %0.2f ms\n"
|
2008-06-20 22:32:41 +02:00
|
|
|
"\tmax rewind: %lu KiB\n"
|
2008-05-15 23:34:41 +00:00
|
|
|
"\tsample spec: %s\n"
|
2009-01-27 00:55:35 +01:00
|
|
|
"\tchannel map: %s%s%s\n"
|
2008-05-15 23:34:41 +00:00
|
|
|
"\tused by: %u\n"
|
|
|
|
|
"\tlinked by: %u\n",
|
improve default sink/source handling
Currently the default sink policy is simple: either the user has
configured it explicitly, in which case we always use that as the
default, or we pick the sink with the highest priority. The sink
priorities are currently static, so there's no need to worry about
updating the default sink when sink priorities change.
I intend to make things a bit more complex: if the active port of a sink
is unavailable, the sink should not be the default sink, and I also want
to make sink priorities dependent on the active port, so changing the
port should cause re-evaluation of which sink to choose as the default.
Currently the default sink choice is done only when someone calls
pa_namereg_get_default_sink(), and change notifications are only sent
when a sink is created or destroyed. That makes it hard to add new rules
to the default sink selection policy.
This patch moves the default sink selection to
pa_core_update_default_sink(), which is called whenever something
happens that can affect the default sink choice. That function needs to
know the previous choice in order to send change notifications as
appropriate, but previously pa_core.default_sink was only set when the
user had configured it explicitly. Now pa_core.default_sink is always
set (unless there are no sinks at all), so pa_core_update_default_sink()
can use that to get the previous choice. The user configuration is saved
in a new variable, pa_core.configured_default_sink.
pa_namereg_get_default_sink() is now unnecessary, because
pa_core.default_sink can be used directly to get the
currently-considered-best sink. pa_namereg_set_default_sink() is
replaced by pa_core_set_configured_default_sink().
I haven't confirmed it, but I expect that this patch will fix problems
in the D-Bus protocol related to default sink handling. The D-Bus
protocol used to get confused when the current default sink gets
removed. It would incorrectly think that if there's no explicitly
configured default sink, then there's no default sink at all. Even
worse, when the D-Bus thinks that there's no default sink, it concludes
that there are no sinks at all, which made it impossible to configure
the default sink via the D-Bus interface. Now that pa_core.default_sink
is always set, except when there really aren't any sinks, the D-Bus
protocol should behave correctly.
BugLink: https://bugs.freedesktop.org/show_bug.cgi?id=99425
2017-02-16 12:09:38 +02:00
|
|
|
source == c->default_source ? '*' : ' ',
|
2006-01-27 16:25:31 +00:00
|
|
|
source->index,
|
|
|
|
|
source->name,
|
|
|
|
|
source->driver,
|
2007-10-28 19:13:50 +00:00
|
|
|
source->flags & PA_SOURCE_HARDWARE ? "HARDWARE " : "",
|
2007-10-29 21:23:08 +00:00
|
|
|
source->flags & PA_SOURCE_NETWORK ? "NETWORK " : "",
|
2008-05-15 23:34:41 +00:00
|
|
|
source->flags & PA_SOURCE_HW_MUTE_CTRL ? "HW_MUTE_CTRL " : "",
|
|
|
|
|
source->flags & PA_SOURCE_HW_VOLUME_CTRL ? "HW_VOLUME_CTRL " : "",
|
|
|
|
|
source->flags & PA_SOURCE_DECIBEL_VOLUME ? "DECIBEL_VOLUME " : "",
|
|
|
|
|
source->flags & PA_SOURCE_LATENCY ? "LATENCY " : "",
|
2009-03-25 00:30:54 +01:00
|
|
|
source->flags & PA_SOURCE_DYNAMIC_LATENCY ? "DYNAMIC_LATENCY" : "",
|
2017-12-28 12:09:18 +02:00
|
|
|
pa_source_state_to_string(pa_source_get_state(source)),
|
2017-12-28 12:09:19 +02:00
|
|
|
pa_suspend_cause_to_string(source->suspend_cause, suspend_cause_buf),
|
2009-08-28 23:30:41 +02:00
|
|
|
source->priority,
|
2013-04-03 16:36:43 +03:00
|
|
|
pa_cvolume_snprint_verbose(cv,
|
|
|
|
|
sizeof(cv),
|
|
|
|
|
pa_source_get_volume(source, false),
|
|
|
|
|
&source->channel_map,
|
|
|
|
|
source->flags & PA_SOURCE_DECIBEL_VOLUME),
|
2013-06-27 19:28:09 +02:00
|
|
|
pa_cvolume_get_balance(pa_source_get_volume(source, false), &source->channel_map),
|
2013-04-03 16:36:43 +03:00
|
|
|
pa_volume_snprint_verbose(v, sizeof(v), source->base_volume, source->flags & PA_SOURCE_DECIBEL_VOLUME),
|
2009-01-27 04:39:07 +01:00
|
|
|
source->n_volume_steps,
|
2013-06-27 19:28:09 +02:00
|
|
|
pa_yes_no(pa_source_get_mute(source, false)),
|
2008-05-15 23:34:41 +00:00
|
|
|
(double) pa_source_get_latency(source) / PA_USEC_PER_MSEC,
|
2008-06-20 22:32:41 +02:00
|
|
|
(unsigned long) pa_source_get_max_rewind(source) / 1024,
|
2006-01-27 16:25:31 +00:00
|
|
|
pa_sample_spec_snprint(ss, sizeof(ss), &source->sample_spec),
|
2007-10-28 19:13:50 +00:00
|
|
|
pa_channel_map_snprint(cm, sizeof(cm), &source->channel_map),
|
2009-01-27 04:39:07 +01:00
|
|
|
cmn ? "\n\t " : "",
|
2009-01-27 00:55:35 +01:00
|
|
|
cmn ? cmn : "",
|
2007-10-28 19:13:50 +00:00
|
|
|
pa_source_used_by(source),
|
|
|
|
|
pa_source_linked_by(source));
|
2004-07-11 01:09:46 +00:00
|
|
|
|
2009-03-25 00:30:54 +01:00
|
|
|
if (source->flags & PA_SOURCE_DYNAMIC_LATENCY) {
|
|
|
|
|
pa_usec_t min_latency, max_latency;
|
|
|
|
|
pa_source_get_latency_range(source, &min_latency, &max_latency);
|
|
|
|
|
|
|
|
|
|
pa_strbuf_printf(
|
|
|
|
|
s,
|
|
|
|
|
"\tconfigured latency: %0.2f ms; range is %0.2f .. %0.2f ms\n",
|
|
|
|
|
(double) pa_source_get_requested_latency(source) / PA_USEC_PER_MSEC,
|
|
|
|
|
(double) min_latency / PA_USEC_PER_MSEC,
|
|
|
|
|
(double) max_latency / PA_USEC_PER_MSEC);
|
2009-04-10 01:26:04 +02:00
|
|
|
} else
|
|
|
|
|
pa_strbuf_printf(
|
|
|
|
|
s,
|
|
|
|
|
"\tfixed latency: %0.2f ms\n",
|
2009-08-15 00:48:14 +02:00
|
|
|
(double) pa_source_get_fixed_latency(source) / PA_USEC_PER_MSEC);
|
2009-03-25 00:30:54 +01:00
|
|
|
|
2007-01-04 13:43:45 +00:00
|
|
|
if (source->monitor_of)
|
2008-05-15 23:34:41 +00:00
|
|
|
pa_strbuf_printf(s, "\tmonitor_of: %u\n", source->monitor_of->index);
|
2009-01-15 18:52:11 +01:00
|
|
|
if (source->card)
|
|
|
|
|
pa_strbuf_printf(s, "\tcard: %u <%s>\n", source->card->index, source->card->name);
|
2007-10-28 19:13:50 +00:00
|
|
|
if (source->module)
|
2008-05-15 23:34:41 +00:00
|
|
|
pa_strbuf_printf(s, "\tmodule: %u\n", source->module->index);
|
|
|
|
|
|
2009-01-17 02:09:02 +01:00
|
|
|
t = pa_proplist_to_string_sep(source->proplist, "\n\t\t");
|
|
|
|
|
pa_strbuf_printf(s, "\tproperties:\n\t\t%s\n", t);
|
2008-05-15 23:34:41 +00:00
|
|
|
pa_xfree(t);
|
2009-06-17 03:45:14 +02:00
|
|
|
|
2011-11-25 15:17:15 +01:00
|
|
|
append_port_list(s, source->ports);
|
2009-06-17 03:45:14 +02:00
|
|
|
|
|
|
|
|
if (source->active_port)
|
|
|
|
|
pa_strbuf_printf(
|
|
|
|
|
s,
|
|
|
|
|
"\tactive port: <%s>\n",
|
|
|
|
|
source->active_port->name);
|
2004-07-11 01:09:46 +00:00
|
|
|
}
|
2007-01-04 13:43:45 +00:00
|
|
|
|
2015-06-12 18:17:07 +05:30
|
|
|
return pa_strbuf_to_string_free(s);
|
2004-07-11 01:09:46 +00:00
|
|
|
}
|
|
|
|
|
|
2006-01-11 01:17:39 +00:00
|
|
|
char *pa_source_output_list_to_string(pa_core *c) {
|
|
|
|
|
pa_strbuf *s;
|
|
|
|
|
pa_source_output *o;
|
|
|
|
|
uint32_t idx = PA_IDXSET_INVALID;
|
2004-09-26 17:02:26 +00:00
|
|
|
static const char* const state_table[] = {
|
2008-05-15 23:34:41 +00:00
|
|
|
[PA_SOURCE_OUTPUT_INIT] = "INIT",
|
2007-10-28 19:13:50 +00:00
|
|
|
[PA_SOURCE_OUTPUT_RUNNING] = "RUNNING",
|
|
|
|
|
[PA_SOURCE_OUTPUT_CORKED] = "CORKED",
|
|
|
|
|
[PA_SOURCE_OUTPUT_UNLINKED] = "UNLINKED"
|
2004-09-26 17:02:26 +00:00
|
|
|
};
|
2007-10-28 19:13:50 +00:00
|
|
|
pa_assert(c);
|
2004-07-11 01:09:46 +00:00
|
|
|
|
|
|
|
|
s = pa_strbuf_new();
|
|
|
|
|
|
2013-05-15 17:49:42 +02:00
|
|
|
pa_strbuf_printf(s, "%u source output(s) available.\n", pa_idxset_size(c->source_outputs));
|
2004-07-11 01:09:46 +00:00
|
|
|
|
2012-05-29 17:58:12 +05:30
|
|
|
PA_IDXSET_FOREACH(o, c->source_outputs, idx) {
|
2013-04-03 16:36:43 +03:00
|
|
|
char ss[PA_SAMPLE_SPEC_SNPRINT_MAX], cv[PA_CVOLUME_SNPRINT_VERBOSE_MAX], cm[PA_CHANNEL_MAP_SNPRINT_MAX], *t, clt[28];
|
2008-05-15 23:34:41 +00:00
|
|
|
pa_usec_t cl;
|
2009-01-27 00:55:35 +01:00
|
|
|
const char *cmn;
|
2012-02-14 11:40:14 +00:00
|
|
|
pa_cvolume v;
|
|
|
|
|
char *volume_str = NULL;
|
2009-01-27 00:55:35 +01:00
|
|
|
|
|
|
|
|
cmn = pa_channel_map_to_pretty_name(&o->channel_map);
|
2008-05-15 23:34:41 +00:00
|
|
|
|
|
|
|
|
if ((cl = pa_source_output_get_requested_latency(o)) == (pa_usec_t) -1)
|
|
|
|
|
pa_snprintf(clt, sizeof(clt), "n/a");
|
|
|
|
|
else
|
|
|
|
|
pa_snprintf(clt, sizeof(clt), "%0.2f ms", (double) cl / PA_USEC_PER_MSEC);
|
2007-01-04 13:43:45 +00:00
|
|
|
|
2007-10-28 19:13:50 +00:00
|
|
|
pa_assert(o->source);
|
2007-01-04 13:43:45 +00:00
|
|
|
|
2012-02-14 11:40:14 +00:00
|
|
|
if (pa_source_output_is_volume_readable(o)) {
|
2013-06-27 19:28:09 +02:00
|
|
|
pa_source_output_get_volume(o, &v, true);
|
2013-04-03 16:36:43 +03:00
|
|
|
volume_str = pa_sprintf_malloc("%s\n\t balance %0.2f",
|
|
|
|
|
pa_cvolume_snprint_verbose(cv, sizeof(cv), &v, &o->channel_map, true),
|
2012-02-14 11:40:14 +00:00
|
|
|
pa_cvolume_get_balance(&v, &o->channel_map));
|
|
|
|
|
} else
|
|
|
|
|
volume_str = pa_xstrdup("n/a");
|
|
|
|
|
|
2004-07-11 01:09:46 +00:00
|
|
|
pa_strbuf_printf(
|
2006-01-27 16:25:31 +00:00
|
|
|
s,
|
|
|
|
|
" index: %u\n"
|
|
|
|
|
"\tdriver: <%s>\n"
|
2012-07-13 17:38:23 +02:00
|
|
|
"\tflags: %s%s%s%s%s%s%s%s%s%s%s%s\n"
|
2006-01-27 16:25:31 +00:00
|
|
|
"\tstate: %s\n"
|
2008-05-15 23:34:41 +00:00
|
|
|
"\tsource: %u <%s>\n"
|
2012-02-14 11:40:14 +00:00
|
|
|
"\tvolume: %s\n"
|
|
|
|
|
"\tmuted: %s\n"
|
2008-05-15 23:34:41 +00:00
|
|
|
"\tcurrent latency: %0.2f ms\n"
|
|
|
|
|
"\trequested latency: %s\n"
|
|
|
|
|
"\tsample spec: %s\n"
|
2009-01-27 00:55:35 +01:00
|
|
|
"\tchannel map: %s%s%s\n"
|
2006-01-27 16:25:31 +00:00
|
|
|
"\tresample method: %s\n",
|
2004-07-11 01:09:46 +00:00
|
|
|
o->index,
|
2006-01-27 16:25:31 +00:00
|
|
|
o->driver,
|
2007-10-28 19:13:50 +00:00
|
|
|
o->flags & PA_SOURCE_OUTPUT_VARIABLE_RATE ? "VARIABLE_RATE " : "",
|
|
|
|
|
o->flags & PA_SOURCE_OUTPUT_DONT_MOVE ? "DONT_MOVE " : "",
|
2008-05-15 23:34:41 +00:00
|
|
|
o->flags & PA_SOURCE_OUTPUT_START_CORKED ? "START_CORKED " : "",
|
2007-11-21 01:30:40 +00:00
|
|
|
o->flags & PA_SOURCE_OUTPUT_NO_REMAP ? "NO_REMAP " : "",
|
|
|
|
|
o->flags & PA_SOURCE_OUTPUT_NO_REMIX ? "NO_REMIX " : "",
|
|
|
|
|
o->flags & PA_SOURCE_OUTPUT_FIX_FORMAT ? "FIX_FORMAT " : "",
|
|
|
|
|
o->flags & PA_SOURCE_OUTPUT_FIX_RATE ? "FIX_RATE " : "",
|
|
|
|
|
o->flags & PA_SOURCE_OUTPUT_FIX_CHANNELS ? "FIX_CHANNELS " : "",
|
2009-02-03 02:23:46 +01:00
|
|
|
o->flags & PA_SOURCE_OUTPUT_DONT_INHIBIT_AUTO_SUSPEND ? "DONT_INHIBIT_AUTO_SUSPEND " : "",
|
2009-08-15 00:12:53 +02:00
|
|
|
o->flags & PA_SOURCE_OUTPUT_NO_CREATE_ON_SUSPEND ? "NO_CREATE_ON_SUSPEND " : "",
|
|
|
|
|
o->flags & PA_SOURCE_OUTPUT_KILL_ON_SUSPEND ? "KILL_ON_SUSPEND " : "",
|
2012-07-13 17:38:23 +02:00
|
|
|
o->flags & PA_SOURCE_OUTPUT_PASSTHROUGH ? "PASSTHROUGH " : "",
|
2007-10-28 19:13:50 +00:00
|
|
|
state_table[pa_source_output_get_state(o)],
|
2004-09-26 17:02:26 +00:00
|
|
|
o->source->index, o->source->name,
|
2012-02-14 11:40:14 +00:00
|
|
|
volume_str,
|
2014-04-15 13:56:11 +03:00
|
|
|
pa_yes_no(o->muted),
|
2008-06-20 22:32:41 +02:00
|
|
|
(double) pa_source_output_get_latency(o, NULL) / PA_USEC_PER_MSEC,
|
2008-05-15 23:34:41 +00:00
|
|
|
clt,
|
2006-01-27 16:25:31 +00:00
|
|
|
pa_sample_spec_snprint(ss, sizeof(ss), &o->sample_spec),
|
|
|
|
|
pa_channel_map_snprint(cm, sizeof(cm), &o->channel_map),
|
2009-01-27 04:39:07 +01:00
|
|
|
cmn ? "\n\t " : "",
|
2009-01-27 00:55:35 +01:00
|
|
|
cmn ? cmn : "",
|
2006-01-27 16:25:31 +00:00
|
|
|
pa_resample_method_to_string(pa_source_output_get_resample_method(o)));
|
2012-02-14 11:40:14 +00:00
|
|
|
|
|
|
|
|
pa_xfree(volume_str);
|
|
|
|
|
|
2006-08-13 19:55:17 +00:00
|
|
|
if (o->module)
|
2008-05-15 23:34:41 +00:00
|
|
|
pa_strbuf_printf(s, "\towner module: %u\n", o->module->index);
|
2004-07-11 01:09:46 +00:00
|
|
|
if (o->client)
|
2008-05-15 23:34:41 +00:00
|
|
|
pa_strbuf_printf(s, "\tclient: %u <%s>\n", o->client->index, pa_strnull(pa_proplist_gets(o->client->proplist, PA_PROP_APPLICATION_NAME)));
|
2008-06-13 21:56:19 +00:00
|
|
|
if (o->direct_on_input)
|
|
|
|
|
pa_strbuf_printf(s, "\tdirect on input: %u\n", o->direct_on_input->index);
|
2008-05-15 23:34:41 +00:00
|
|
|
|
2009-01-17 02:09:02 +01:00
|
|
|
t = pa_proplist_to_string_sep(o->proplist, "\n\t\t");
|
|
|
|
|
pa_strbuf_printf(s, "\tproperties:\n\t\t%s\n", t);
|
2008-05-15 23:34:41 +00:00
|
|
|
pa_xfree(t);
|
2004-07-11 01:09:46 +00:00
|
|
|
}
|
2007-01-04 13:43:45 +00:00
|
|
|
|
2015-06-12 18:17:07 +05:30
|
|
|
return pa_strbuf_to_string_free(s);
|
2004-07-11 01:09:46 +00:00
|
|
|
}
|
|
|
|
|
|
2006-01-11 01:17:39 +00:00
|
|
|
char *pa_sink_input_list_to_string(pa_core *c) {
|
|
|
|
|
pa_strbuf *s;
|
|
|
|
|
pa_sink_input *i;
|
|
|
|
|
uint32_t idx = PA_IDXSET_INVALID;
|
2004-09-26 17:02:26 +00:00
|
|
|
static const char* const state_table[] = {
|
2008-05-15 23:34:41 +00:00
|
|
|
[PA_SINK_INPUT_INIT] = "INIT",
|
2007-10-28 19:13:50 +00:00
|
|
|
[PA_SINK_INPUT_RUNNING] = "RUNNING",
|
|
|
|
|
[PA_SINK_INPUT_CORKED] = "CORKED",
|
|
|
|
|
[PA_SINK_INPUT_UNLINKED] = "UNLINKED"
|
2004-09-26 17:02:26 +00:00
|
|
|
};
|
2004-07-11 01:09:46 +00:00
|
|
|
|
2007-10-28 19:13:50 +00:00
|
|
|
pa_assert(c);
|
2004-07-11 01:09:46 +00:00
|
|
|
s = pa_strbuf_new();
|
|
|
|
|
|
2006-01-11 01:17:39 +00:00
|
|
|
pa_strbuf_printf(s, "%u sink input(s) available.\n", pa_idxset_size(c->sink_inputs));
|
2004-07-11 01:09:46 +00:00
|
|
|
|
2012-05-29 17:58:12 +05:30
|
|
|
PA_IDXSET_FOREACH(i, c->sink_inputs, idx) {
|
2013-04-03 16:36:43 +03:00
|
|
|
char ss[PA_SAMPLE_SPEC_SNPRINT_MAX], cv[PA_CVOLUME_SNPRINT_MAX], cm[PA_CHANNEL_MAP_SNPRINT_MAX], *t, clt[28];
|
2008-05-15 23:34:41 +00:00
|
|
|
pa_usec_t cl;
|
2009-01-27 00:55:35 +01:00
|
|
|
const char *cmn;
|
2009-04-13 22:50:24 +02:00
|
|
|
pa_cvolume v;
|
2011-02-14 13:41:06 +02:00
|
|
|
char *volume_str = NULL;
|
2009-01-27 00:55:35 +01:00
|
|
|
|
|
|
|
|
cmn = pa_channel_map_to_pretty_name(&i->channel_map);
|
2008-05-15 23:34:41 +00:00
|
|
|
|
|
|
|
|
if ((cl = pa_sink_input_get_requested_latency(i)) == (pa_usec_t) -1)
|
|
|
|
|
pa_snprintf(clt, sizeof(clt), "n/a");
|
|
|
|
|
else
|
|
|
|
|
pa_snprintf(clt, sizeof(clt), "%0.2f ms", (double) cl / PA_USEC_PER_MSEC);
|
2004-11-20 16:23:53 +00:00
|
|
|
|
2007-10-28 19:13:50 +00:00
|
|
|
pa_assert(i->sink);
|
2007-01-04 13:43:45 +00:00
|
|
|
|
2011-02-14 13:41:06 +02:00
|
|
|
if (pa_sink_input_is_volume_readable(i)) {
|
2013-06-27 19:28:09 +02:00
|
|
|
pa_sink_input_get_volume(i, &v, true);
|
2013-04-03 16:36:43 +03:00
|
|
|
volume_str = pa_sprintf_malloc("%s\n\t balance %0.2f",
|
|
|
|
|
pa_cvolume_snprint_verbose(cv, sizeof(cv), &v, &i->channel_map, true),
|
2011-02-14 13:41:06 +02:00
|
|
|
pa_cvolume_get_balance(&v, &i->channel_map));
|
|
|
|
|
} else
|
|
|
|
|
volume_str = pa_xstrdup("n/a");
|
|
|
|
|
|
2004-07-11 01:09:46 +00:00
|
|
|
pa_strbuf_printf(
|
2006-01-27 16:25:31 +00:00
|
|
|
s,
|
|
|
|
|
" index: %u\n"
|
|
|
|
|
"\tdriver: <%s>\n"
|
2012-07-13 17:38:23 +02:00
|
|
|
"\tflags: %s%s%s%s%s%s%s%s%s%s%s%s\n"
|
2006-01-27 16:25:31 +00:00
|
|
|
"\tstate: %s\n"
|
2008-05-15 23:34:41 +00:00
|
|
|
"\tsink: %u <%s>\n"
|
|
|
|
|
"\tvolume: %s\n"
|
|
|
|
|
"\tmuted: %s\n"
|
|
|
|
|
"\tcurrent latency: %0.2f ms\n"
|
|
|
|
|
"\trequested latency: %s\n"
|
|
|
|
|
"\tsample spec: %s\n"
|
2009-01-27 00:55:35 +01:00
|
|
|
"\tchannel map: %s%s%s\n"
|
2006-01-27 16:25:31 +00:00
|
|
|
"\tresample method: %s\n",
|
2004-07-11 01:09:46 +00:00
|
|
|
i->index,
|
2006-01-27 16:25:31 +00:00
|
|
|
i->driver,
|
2007-10-28 19:13:50 +00:00
|
|
|
i->flags & PA_SINK_INPUT_VARIABLE_RATE ? "VARIABLE_RATE " : "",
|
|
|
|
|
i->flags & PA_SINK_INPUT_DONT_MOVE ? "DONT_MOVE " : "",
|
2008-05-15 23:34:41 +00:00
|
|
|
i->flags & PA_SINK_INPUT_START_CORKED ? "START_CORKED " : "",
|
2007-11-21 01:30:40 +00:00
|
|
|
i->flags & PA_SINK_INPUT_NO_REMAP ? "NO_REMAP " : "",
|
|
|
|
|
i->flags & PA_SINK_INPUT_NO_REMIX ? "NO_REMIX " : "",
|
|
|
|
|
i->flags & PA_SINK_INPUT_FIX_FORMAT ? "FIX_FORMAT " : "",
|
|
|
|
|
i->flags & PA_SINK_INPUT_FIX_RATE ? "FIX_RATE " : "",
|
|
|
|
|
i->flags & PA_SINK_INPUT_FIX_CHANNELS ? "FIX_CHANNELS " : "",
|
2009-02-03 02:23:46 +01:00
|
|
|
i->flags & PA_SINK_INPUT_DONT_INHIBIT_AUTO_SUSPEND ? "DONT_INHIBIT_AUTO_SUSPEND " : "",
|
2009-08-15 00:12:53 +02:00
|
|
|
i->flags & PA_SINK_INPUT_NO_CREATE_ON_SUSPEND ? "NO_CREATE_SUSPEND " : "",
|
|
|
|
|
i->flags & PA_SINK_INPUT_KILL_ON_SUSPEND ? "KILL_ON_SUSPEND " : "",
|
2012-07-13 17:38:23 +02:00
|
|
|
i->flags & PA_SINK_INPUT_PASSTHROUGH ? "PASSTHROUGH " : "",
|
2007-10-28 19:13:50 +00:00
|
|
|
state_table[pa_sink_input_get_state(i)],
|
2004-09-26 17:02:26 +00:00
|
|
|
i->sink->index, i->sink->name,
|
2011-02-14 13:41:06 +02:00
|
|
|
volume_str,
|
2014-04-15 13:56:11 +03:00
|
|
|
pa_yes_no(i->muted),
|
2008-06-20 22:32:41 +02:00
|
|
|
(double) pa_sink_input_get_latency(i, NULL) / PA_USEC_PER_MSEC,
|
2008-05-15 23:34:41 +00:00
|
|
|
clt,
|
2006-01-27 16:25:31 +00:00
|
|
|
pa_sample_spec_snprint(ss, sizeof(ss), &i->sample_spec),
|
|
|
|
|
pa_channel_map_snprint(cm, sizeof(cm), &i->channel_map),
|
2009-01-27 04:39:07 +01:00
|
|
|
cmn ? "\n\t " : "",
|
2009-01-27 00:55:35 +01:00
|
|
|
cmn ? cmn : "",
|
2006-01-27 16:25:31 +00:00
|
|
|
pa_resample_method_to_string(pa_sink_input_get_resample_method(i)));
|
2004-07-11 01:09:46 +00:00
|
|
|
|
2011-02-14 13:41:06 +02:00
|
|
|
pa_xfree(volume_str);
|
|
|
|
|
|
2006-08-13 16:19:56 +00:00
|
|
|
if (i->module)
|
2008-05-15 23:34:41 +00:00
|
|
|
pa_strbuf_printf(s, "\tmodule: %u\n", i->module->index);
|
2004-07-11 01:09:46 +00:00
|
|
|
if (i->client)
|
2008-05-15 23:34:41 +00:00
|
|
|
pa_strbuf_printf(s, "\tclient: %u <%s>\n", i->client->index, pa_strnull(pa_proplist_gets(i->client->proplist, PA_PROP_APPLICATION_NAME)));
|
|
|
|
|
|
2009-01-17 02:09:02 +01:00
|
|
|
t = pa_proplist_to_string_sep(i->proplist, "\n\t\t");
|
|
|
|
|
pa_strbuf_printf(s, "\tproperties:\n\t\t%s\n", t);
|
2008-05-15 23:34:41 +00:00
|
|
|
pa_xfree(t);
|
2004-07-11 01:09:46 +00:00
|
|
|
}
|
2007-01-04 13:43:45 +00:00
|
|
|
|
2015-06-12 18:17:07 +05:30
|
|
|
return pa_strbuf_to_string_free(s);
|
2004-07-11 01:09:46 +00:00
|
|
|
}
|
2004-07-20 01:07:06 +00:00
|
|
|
|
2006-01-11 01:17:39 +00:00
|
|
|
char *pa_scache_list_to_string(pa_core *c) {
|
|
|
|
|
pa_strbuf *s;
|
2007-10-28 19:13:50 +00:00
|
|
|
pa_assert(c);
|
2004-07-20 01:07:06 +00:00
|
|
|
|
|
|
|
|
s = pa_strbuf_new();
|
|
|
|
|
|
2009-01-17 02:09:02 +01:00
|
|
|
pa_strbuf_printf(s, "%u cache entrie(s) available.\n", c->scache ? pa_idxset_size(c->scache) : 0);
|
2004-07-20 01:07:06 +00:00
|
|
|
|
2004-08-19 23:14:59 +00:00
|
|
|
if (c->scache) {
|
2006-01-11 01:17:39 +00:00
|
|
|
pa_scache_entry *e;
|
|
|
|
|
uint32_t idx = PA_IDXSET_INVALID;
|
2004-07-20 01:07:06 +00:00
|
|
|
|
2012-05-29 17:58:12 +05:30
|
|
|
PA_IDXSET_FOREACH(e, c->scache, idx) {
|
2004-09-15 14:05:28 +00:00
|
|
|
double l = 0;
|
2013-04-03 16:36:43 +03:00
|
|
|
char ss[PA_SAMPLE_SPEC_SNPRINT_MAX] = "n/a", cv[PA_CVOLUME_SNPRINT_MAX], cm[PA_CHANNEL_MAP_SNPRINT_MAX] = "n/a", *t;
|
2009-01-27 00:55:35 +01:00
|
|
|
const char *cmn;
|
|
|
|
|
|
|
|
|
|
cmn = pa_channel_map_to_pretty_name(&e->channel_map);
|
2007-01-04 13:43:45 +00:00
|
|
|
|
2004-09-15 14:05:28 +00:00
|
|
|
if (e->memchunk.memblock) {
|
|
|
|
|
pa_sample_spec_snprint(ss, sizeof(ss), &e->sample_spec);
|
2006-01-27 16:25:31 +00:00
|
|
|
pa_channel_map_snprint(cm, sizeof(cm), &e->channel_map);
|
2008-08-19 22:39:54 +02:00
|
|
|
l = (double) e->memchunk.length / (double) pa_bytes_per_second(&e->sample_spec);
|
2004-09-15 14:05:28 +00:00
|
|
|
}
|
2007-01-04 13:43:45 +00:00
|
|
|
|
2004-07-20 01:07:06 +00:00
|
|
|
pa_strbuf_printf(
|
2006-01-27 16:25:31 +00:00
|
|
|
s,
|
|
|
|
|
" name: <%s>\n"
|
2008-05-15 23:34:41 +00:00
|
|
|
"\tindex: %u\n"
|
|
|
|
|
"\tsample spec: %s\n"
|
2009-01-27 00:55:35 +01:00
|
|
|
"\tchannel map: %s%s%s\n"
|
2008-05-15 23:34:41 +00:00
|
|
|
"\tlength: %lu\n"
|
|
|
|
|
"\tduration: %0.1f s\n"
|
|
|
|
|
"\tvolume: %s\n"
|
2009-01-19 23:07:13 +01:00
|
|
|
"\t balance %0.2f\n"
|
2006-01-27 16:25:31 +00:00
|
|
|
"\tlazy: %s\n"
|
2008-05-15 23:34:41 +00:00
|
|
|
"\tfilename: <%s>\n",
|
2004-07-20 01:07:06 +00:00
|
|
|
e->name,
|
|
|
|
|
e->index,
|
|
|
|
|
ss,
|
2006-01-27 16:25:31 +00:00
|
|
|
cm,
|
2009-01-27 04:39:07 +01:00
|
|
|
cmn ? "\n\t " : "",
|
2009-01-27 00:55:35 +01:00
|
|
|
cmn ? cmn : "",
|
2006-03-31 08:54:24 +00:00
|
|
|
(long unsigned)(e->memchunk.memblock ? e->memchunk.length : 0),
|
2004-08-03 19:26:56 +00:00
|
|
|
l,
|
2013-04-03 16:36:43 +03:00
|
|
|
e->volume_is_set ? pa_cvolume_snprint_verbose(cv, sizeof(cv), &e->volume, &e->channel_map, true) : "n/a",
|
2009-01-27 03:05:40 +01:00
|
|
|
(e->memchunk.memblock && e->volume_is_set) ? pa_cvolume_get_balance(&e->volume, &e->channel_map) : 0.0f,
|
2008-05-15 23:34:41 +00:00
|
|
|
pa_yes_no(e->lazy),
|
2004-09-15 14:05:28 +00:00
|
|
|
e->filename ? e->filename : "n/a");
|
2008-05-15 23:34:41 +00:00
|
|
|
|
2009-01-17 02:09:02 +01:00
|
|
|
t = pa_proplist_to_string_sep(e->proplist, "\n\t\t");
|
|
|
|
|
pa_strbuf_printf(s, "\tproperties:\n\t\t%s\n", t);
|
2008-05-15 23:34:41 +00:00
|
|
|
pa_xfree(t);
|
2004-07-20 01:07:06 +00:00
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2015-06-12 18:17:07 +05:30
|
|
|
return pa_strbuf_to_string_free(s);
|
2004-07-20 01:07:06 +00:00
|
|
|
}
|
2004-08-04 16:39:30 +00:00
|
|
|
|
2006-01-11 01:17:39 +00:00
|
|
|
char *pa_full_status_string(pa_core *c) {
|
|
|
|
|
pa_strbuf *s;
|
2005-01-12 18:51:38 +00:00
|
|
|
int i;
|
|
|
|
|
|
|
|
|
|
s = pa_strbuf_new();
|
|
|
|
|
|
2009-01-15 20:07:13 +01:00
|
|
|
for (i = 0; i < 8; i++) {
|
2005-01-12 18:51:38 +00:00
|
|
|
char *t = NULL;
|
2007-01-04 13:43:45 +00:00
|
|
|
|
2005-01-12 18:51:38 +00:00
|
|
|
switch (i) {
|
2007-01-04 13:43:45 +00:00
|
|
|
case 0:
|
2005-01-12 18:51:38 +00:00
|
|
|
t = pa_sink_list_to_string(c);
|
|
|
|
|
break;
|
|
|
|
|
case 1:
|
|
|
|
|
t = pa_source_list_to_string(c);
|
|
|
|
|
break;
|
|
|
|
|
case 2:
|
|
|
|
|
t = pa_sink_input_list_to_string(c);
|
|
|
|
|
break;
|
|
|
|
|
case 3:
|
|
|
|
|
t = pa_source_output_list_to_string(c);
|
|
|
|
|
break;
|
2007-01-04 13:43:45 +00:00
|
|
|
case 4:
|
2005-01-12 18:51:38 +00:00
|
|
|
t = pa_client_list_to_string(c);
|
|
|
|
|
break;
|
|
|
|
|
case 5:
|
2009-01-15 18:52:11 +01:00
|
|
|
t = pa_card_list_to_string(c);
|
2005-01-12 18:51:38 +00:00
|
|
|
break;
|
|
|
|
|
case 6:
|
2009-01-15 18:52:11 +01:00
|
|
|
t = pa_module_list_to_string(c);
|
2005-01-12 18:51:38 +00:00
|
|
|
break;
|
|
|
|
|
case 7:
|
2009-01-15 18:52:11 +01:00
|
|
|
t = pa_scache_list_to_string(c);
|
|
|
|
|
break;
|
2005-01-12 18:51:38 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
pa_strbuf_puts(s, t);
|
|
|
|
|
pa_xfree(t);
|
|
|
|
|
}
|
|
|
|
|
|
2015-06-12 18:17:07 +05:30
|
|
|
return pa_strbuf_to_string_free(s);
|
2005-01-12 18:51:38 +00:00
|
|
|
}
|