summaryrefslogtreecommitdiffstats
path: root/src/pulsecore
diff options
context:
space:
mode:
Diffstat (limited to 'src/pulsecore')
-rw-r--r--src/pulsecore/card.c13
-rw-r--r--src/pulsecore/card.h12
-rw-r--r--src/pulsecore/cli-command.c1
-rw-r--r--src/pulsecore/cli-text.c67
-rw-r--r--src/pulsecore/module.c30
-rw-r--r--src/pulsecore/module.h7
-rw-r--r--src/pulsecore/protocol-native.c14
-rw-r--r--src/pulsecore/strbuf.c6
-rw-r--r--src/pulsecore/strbuf.h3
9 files changed, 114 insertions, 39 deletions
diff --git a/src/pulsecore/card.c b/src/pulsecore/card.c
index 99c0cc55..ec4a50c5 100644
--- a/src/pulsecore/card.c
+++ b/src/pulsecore/card.c
@@ -36,13 +36,14 @@
#include "card.h"
-pa_card_profile *pa_card_profile_new(const char *name) {
+pa_card_profile *pa_card_profile_new(const char *name, const char *description, size_t extra) {
pa_card_profile *c;
pa_assert(name);
- c = pa_xnew0(pa_card_profile, 1);
+ c = pa_xmalloc(PA_ALIGN(sizeof(pa_card_profile)) + extra);
c->name = pa_xstrdup(name);
+ c->description = pa_xstrdup(description);
return c;
}
@@ -51,6 +52,7 @@ void pa_card_profile_free(pa_card_profile *c) {
pa_assert(c);
pa_xfree(c->name);
+ pa_xfree(c->description);
pa_xfree(c);
}
@@ -122,7 +124,9 @@ pa_card *pa_card_new(pa_core *core, pa_card_new_data *data) {
c->profiles = data->profiles;
data->profiles = NULL;
- c->active_profile = data->active_profile;
+ if (!(c->active_profile = data->active_profile))
+ if (c->profiles)
+ c->active_profile = pa_hashmap_first(c->profiles);
data->active_profile = NULL;
c->userdata = NULL;
@@ -189,6 +193,9 @@ int pa_card_set_profile(pa_card *c, const char *name) {
if (!(profile = pa_hashmap_get(c->profiles, name)))
return -1;
+ if (c->active_profile == profile)
+ return 0;
+
if (c->set_profile(c, profile) < 0)
return -1;
diff --git a/src/pulsecore/card.h b/src/pulsecore/card.h
index e32e8809..b4e68b04 100644
--- a/src/pulsecore/card.h
+++ b/src/pulsecore/card.h
@@ -31,17 +31,20 @@ typedef struct pa_card pa_card;
typedef struct pa_card_profile {
char *name;
+ char *description;
- pa_bool_t optical_sink:1;
- pa_bool_t optical_source:1;
-
+ /* We probably want to have different properties later on here */
unsigned n_sinks;
unsigned n_sources;
unsigned max_sink_channels;
unsigned max_source_channels;
+
+ /* .. followed by some implementation specific data */
} pa_card_profile;
+#define PA_CARD_PROFILE_DATA(d) ((void*) ((uint8_t*) d + PA_ALIGN(sizeof(pa_card_profile))))
+
struct pa_card {
uint32_t index;
pa_core *core;
@@ -65,6 +68,7 @@ struct pa_card {
typedef struct pa_card_new_data {
char *name;
+ char *description;
pa_proplist *proplist;
const char *driver;
@@ -76,7 +80,7 @@ typedef struct pa_card_new_data {
pa_bool_t namereg_fail:1;
} pa_card_new_data;
-pa_card_profile *pa_card_profile_new(const char *name);
+pa_card_profile *pa_card_profile_new(const char *name, const char *description, size_t extra);
void pa_card_profile_free(pa_card_profile *c);
pa_card_new_data *pa_card_new_data_init(pa_card_new_data *data);
diff --git a/src/pulsecore/cli-command.c b/src/pulsecore/cli-command.c
index 8f5d9bdd..f810579e 100644
--- a/src/pulsecore/cli-command.c
+++ b/src/pulsecore/cli-command.c
@@ -51,6 +51,7 @@
#include <pulsecore/shared.h>
#include <pulsecore/core-util.h>
#include <pulsecore/core-error.h>
+#include <pulsecore/modinfo.h>
#include "cli-command.h"
diff --git a/src/pulsecore/cli-text.c b/src/pulsecore/cli-text.c
index 0f4a273d..79620398 100644
--- a/src/pulsecore/cli-text.c
+++ b/src/pulsecore/cli-text.c
@@ -54,6 +54,8 @@ char *pa_module_list_to_string(pa_core *c) {
pa_strbuf_printf(s, "%u module(s) loaded.\n", pa_idxset_size(c->modules));
for (m = pa_idxset_first(c->modules, &idx); m; m = pa_idxset_next(c->modules, &idx)) {
+ char *t;
+
pa_strbuf_printf(s, " index: %u\n"
"\tname: <%s>\n"
"\targument: <%s>\n"
@@ -64,6 +66,10 @@ char *pa_module_list_to_string(pa_core *c) {
pa_strempty(m->argument),
pa_module_get_n_used(m),
pa_yes_no(m->load_once));
+
+ 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);
}
return pa_strbuf_tostring_free(s);
@@ -91,8 +97,8 @@ char *pa_client_list_to_string(pa_core *c) {
if (client->module)
pa_strbuf_printf(s, "\towner module: %u\n", client->module->index);
- t = pa_proplist_to_string(client->proplist);
- pa_strbuf_printf(s, "\tproperties:\n%s", t);
+ t = pa_proplist_to_string_sep(client->proplist, "\n\t\t");
+ pa_strbuf_printf(s, "\tproperties:\n\t\t%s\n", t);
pa_xfree(t);
}
@@ -107,7 +113,7 @@ char *pa_card_list_to_string(pa_core *c) {
s = pa_strbuf_new();
- pa_strbuf_printf(s, "%u card(s) available in.\n", pa_idxset_size(c->cards));
+ pa_strbuf_printf(s, "%u card(s) available.\n", pa_idxset_size(c->cards));
for (card = pa_idxset_first(c->cards, &idx); card; card = pa_idxset_next(c->cards, &idx)) {
char *t;
@@ -123,9 +129,22 @@ char *pa_card_list_to_string(pa_core *c) {
if (card->module)
pa_strbuf_printf(s, "\towner module: %u\n", card->module->index);
- t = pa_proplist_to_string(card->proplist);
- pa_strbuf_printf(s, "\tproperties:\n%s", t);
+ t = pa_proplist_to_string_sep(card->proplist, "\n\t\t");
+ pa_strbuf_printf(s, "\tproperties:\n\t\t%s\n", t);
pa_xfree(t);
+
+ if (card->profiles) {
+ pa_card_profile *p;
+ void *state = NULL;
+
+ pa_strbuf_puts(
+ s,
+ "\tprofiles:\n");
+
+ while ((p = pa_hashmap_iterate(card->profiles, &state, NULL)))
+ pa_strbuf_printf(s, "\t\t%s: %s\n", p->name, p->description);
+ }
+
}
return pa_strbuf_tostring_free(s);
@@ -167,6 +186,7 @@ char *pa_sink_list_to_string(pa_core *c) {
"\tflags: %s%s%s%s%s%s\n"
"\tstate: %s\n"
"\tvolume: %s%s%s\n"
+ "\t balance %0.2f\n"
"\tbase volume: %s%s%s\n"
"\tmuted: %s\n"
"\tcurrent latency: %0.2f ms\n"
@@ -192,6 +212,7 @@ char *pa_sink_list_to_string(pa_core *c) {
pa_cvolume_snprint(cv, sizeof(cv), pa_sink_get_volume(sink, FALSE)),
sink->flags & PA_SINK_DECIBEL_VOLUME ? "\n\t " : "",
sink->flags & PA_SINK_DECIBEL_VOLUME ? pa_sw_cvolume_snprint_dB(cvdb, sizeof(cvdb), pa_sink_get_volume(sink, FALSE)) : "",
+ pa_cvolume_get_balance(&sink->channel_map, pa_sink_get_volume(sink, FALSE)),
pa_volume_snprint(v, sizeof(v), sink->base_volume),
sink->flags & PA_SINK_DECIBEL_VOLUME ? "\n\t " : "",
sink->flags & PA_SINK_DECIBEL_VOLUME ? pa_sw_volume_snprint_dB(vdb, sizeof(vdb), sink->base_volume) : "",
@@ -213,8 +234,8 @@ char *pa_sink_list_to_string(pa_core *c) {
if (sink->module)
pa_strbuf_printf(s, "\tmodule: %u\n", sink->module->index);
- t = pa_proplist_to_string(sink->proplist);
- pa_strbuf_printf(s, "\tproperties:\n%s", t);
+ t = pa_proplist_to_string_sep(sink->proplist, "\n\t\t");
+ pa_strbuf_printf(s, "\tproperties:\n\t\t%s\n", t);
pa_xfree(t);
}
@@ -257,6 +278,7 @@ char *pa_source_list_to_string(pa_core *c) {
"\tflags: %s%s%s%s%s%s\n"
"\tstate: %s\n"
"\tvolume: %s%s%s\n"
+ "\t balance %0.2f\n"
"\tbase volume: %s%s%s\n"
"\tmuted: %s\n"
"\tcurrent latency: %0.2f ms\n"
@@ -280,6 +302,7 @@ char *pa_source_list_to_string(pa_core *c) {
pa_cvolume_snprint(cv, sizeof(cv), pa_source_get_volume(source, FALSE)),
source->flags & PA_SOURCE_DECIBEL_VOLUME ? "\n\t " : "",
source->flags & PA_SOURCE_DECIBEL_VOLUME ? pa_sw_cvolume_snprint_dB(cvdb, sizeof(cvdb), pa_source_get_volume(source, FALSE)) : "",
+ pa_cvolume_get_balance(&source->channel_map, pa_source_get_volume(source, FALSE)),
pa_volume_snprint(v, sizeof(v), source->base_volume),
source->flags & PA_SOURCE_DECIBEL_VOLUME ? "\n\t " : "",
source->flags & PA_SOURCE_DECIBEL_VOLUME ? pa_sw_volume_snprint_dB(vdb, sizeof(vdb), source->base_volume) : "",
@@ -301,8 +324,8 @@ char *pa_source_list_to_string(pa_core *c) {
if (source->module)
pa_strbuf_printf(s, "\tmodule: %u\n", source->module->index);
- t = pa_proplist_to_string(source->proplist);
- pa_strbuf_printf(s, "\tproperties:\n%s", t);
+ t = pa_proplist_to_string_sep(source->proplist, "\n\t\t");
+ pa_strbuf_printf(s, "\tproperties:\n\t\t%s\n", t);
pa_xfree(t);
}
@@ -373,8 +396,8 @@ char *pa_source_output_list_to_string(pa_core *c) {
if (o->direct_on_input)
pa_strbuf_printf(s, "\tdirect on input: %u\n", o->direct_on_input->index);
- t = pa_proplist_to_string(o->proplist);
- pa_strbuf_printf(s, "\tproperties:\n%s", t);
+ t = pa_proplist_to_string_sep(o->proplist, "\n\t\t");
+ pa_strbuf_printf(s, "\tproperties:\n\t\t%s\n", t);
pa_xfree(t);
}
@@ -399,7 +422,7 @@ char *pa_sink_input_list_to_string(pa_core *c) {
pa_strbuf_printf(s, "%u sink input(s) available.\n", pa_idxset_size(c->sink_inputs));
for (i = pa_idxset_first(c->sink_inputs, &idx); i; i = pa_idxset_next(c->sink_inputs, &idx)) {
- char ss[PA_SAMPLE_SPEC_SNPRINT_MAX], cv[PA_CVOLUME_SNPRINT_MAX], cm[PA_CHANNEL_MAP_SNPRINT_MAX], *t, clt[28];
+ char ss[PA_SAMPLE_SPEC_SNPRINT_MAX], cvdb[PA_SW_CVOLUME_SNPRINT_DB_MAX], cv[PA_CVOLUME_SNPRINT_MAX], cm[PA_CHANNEL_MAP_SNPRINT_MAX], *t, clt[28];
pa_usec_t cl;
if ((cl = pa_sink_input_get_requested_latency(i)) == (pa_usec_t) -1)
@@ -417,6 +440,8 @@ char *pa_sink_input_list_to_string(pa_core *c) {
"\tstate: %s\n"
"\tsink: %u <%s>\n"
"\tvolume: %s\n"
+ "\t %s\n"
+ "\t balance %0.2f\n"
"\tmuted: %s\n"
"\tcurrent latency: %0.2f ms\n"
"\trequested latency: %s\n"
@@ -436,6 +461,8 @@ char *pa_sink_input_list_to_string(pa_core *c) {
state_table[pa_sink_input_get_state(i)],
i->sink->index, i->sink->name,
pa_cvolume_snprint(cv, sizeof(cv), pa_sink_input_get_volume(i)),
+ pa_sw_cvolume_snprint_dB(cvdb, sizeof(cvdb), pa_sink_input_get_volume(i)),
+ pa_cvolume_get_balance(&i->channel_map, pa_sink_input_get_volume(i)),
pa_yes_no(pa_sink_input_get_mute(i)),
(double) pa_sink_input_get_latency(i, NULL) / PA_USEC_PER_MSEC,
clt,
@@ -448,8 +475,8 @@ char *pa_sink_input_list_to_string(pa_core *c) {
if (i->client)
pa_strbuf_printf(s, "\tclient: %u <%s>\n", i->client->index, pa_strnull(pa_proplist_gets(i->client->proplist, PA_PROP_APPLICATION_NAME)));
- t = pa_proplist_to_string(i->proplist);
- pa_strbuf_printf(s, "\tproperties:\n%s", t);
+ t = pa_proplist_to_string_sep(i->proplist, "\n\t\t");
+ pa_strbuf_printf(s, "\tproperties:\n\t\t%s\n", t);
pa_xfree(t);
}
@@ -462,7 +489,7 @@ char *pa_scache_list_to_string(pa_core *c) {
s = pa_strbuf_new();
- pa_strbuf_printf(s, "%u cache entries available.\n", c->scache ? pa_idxset_size(c->scache) : 0);
+ pa_strbuf_printf(s, "%u cache entrie(s) available.\n", c->scache ? pa_idxset_size(c->scache) : 0);
if (c->scache) {
pa_scache_entry *e;
@@ -470,7 +497,7 @@ char *pa_scache_list_to_string(pa_core *c) {
for (e = pa_idxset_first(c->scache, &idx); e; e = pa_idxset_next(c->scache, &idx)) {
double l = 0;
- char ss[PA_SAMPLE_SPEC_SNPRINT_MAX] = "n/a", cv[PA_CVOLUME_SNPRINT_MAX], cm[PA_CHANNEL_MAP_SNPRINT_MAX] = "n/a", *t;
+ char ss[PA_SAMPLE_SPEC_SNPRINT_MAX] = "n/a", cv[PA_CVOLUME_SNPRINT_MAX], cvdb[PA_SW_CVOLUME_SNPRINT_DB_MAX], cm[PA_CHANNEL_MAP_SNPRINT_MAX] = "n/a", *t;
if (e->memchunk.memblock) {
pa_sample_spec_snprint(ss, sizeof(ss), &e->sample_spec);
@@ -487,6 +514,8 @@ char *pa_scache_list_to_string(pa_core *c) {
"\tlength: %lu\n"
"\tduration: %0.1f s\n"
"\tvolume: %s\n"
+ "\t %s\n"
+ "\t balance %0.2f\n"
"\tlazy: %s\n"
"\tfilename: <%s>\n",
e->name,
@@ -496,11 +525,13 @@ char *pa_scache_list_to_string(pa_core *c) {
(long unsigned)(e->memchunk.memblock ? e->memchunk.length : 0),
l,
pa_cvolume_snprint(cv, sizeof(cv), &e->volume),
+ pa_sw_cvolume_snprint_dB(cvdb, sizeof(cvdb), &e->volume),
+ e->memchunk.memblock ? pa_cvolume_get_balance(&e->channel_map, &e->volume) : 0.0f,
pa_yes_no(e->lazy),
e->filename ? e->filename : "n/a");
- t = pa_proplist_to_string(e->proplist);
- pa_strbuf_printf(s, "\tproperties:\n%s", t);
+ t = pa_proplist_to_string_sep(e->proplist, "\n\t\t");
+ pa_strbuf_printf(s, "\tproperties:\n\t\t%s\n", t);
pa_xfree(t);
}
}
diff --git a/src/pulsecore/module.c b/src/pulsecore/module.c
index c4dcb478..d470bb0b 100644
--- a/src/pulsecore/module.c
+++ b/src/pulsecore/module.c
@@ -33,12 +33,14 @@
#include <pulse/timeval.h>
#include <pulse/xmalloc.h>
+#include <pulse/proplist.h>
#include <pulsecore/core-subscribe.h>
#include <pulsecore/log.h>
#include <pulsecore/core-util.h>
#include <pulsecore/macro.h>
#include <pulsecore/ltdl-helper.h>
+#include <pulsecore/modinfo.h>
#include "module.h"
@@ -50,6 +52,7 @@
pa_module* pa_module_load(pa_core *c, const char *name, const char *argument) {
pa_module *m = NULL;
pa_bool_t (*load_once)(void);
+ pa_modinfo *mi;
pa_assert(c);
pa_assert(name);
@@ -61,6 +64,7 @@ pa_module* pa_module_load(pa_core *c, const char *name, const char *argument) {
m->name = pa_xstrdup(name);
m->argument = pa_xstrdup(argument);
m->load_once = FALSE;
+ m->proplist = pa_proplist_new();
if (!(m->dl = lt_dlopenext(name))) {
pa_log("Failed to open module \"%s\": %s", name, lt_dlerror());
@@ -111,11 +115,28 @@ pa_module* pa_module_load(pa_core *c, const char *name, const char *argument) {
pa_subscription_post(c, PA_SUBSCRIPTION_EVENT_MODULE|PA_SUBSCRIPTION_EVENT_NEW, m->index);
+ if ((mi = pa_modinfo_get_by_handle(m->dl, name))) {
+
+ if (mi->author && !pa_proplist_contains(m->proplist, PA_PROP_MODULE_AUTHOR))
+ pa_proplist_sets(m->proplist, PA_PROP_MODULE_AUTHOR, mi->author);
+
+ if (mi->description && !pa_proplist_contains(m->proplist, PA_PROP_MODULE_DESCRIPTION))
+ pa_proplist_sets(m->proplist, PA_PROP_MODULE_DESCRIPTION, mi->description);
+
+ if (mi->version && !pa_proplist_contains(m->proplist, PA_PROP_MODULE_VERSION))
+ pa_proplist_sets(m->proplist, PA_PROP_MODULE_VERSION, mi->version);
+
+ pa_modinfo_free(mi);
+ }
+
return m;
fail:
if (m) {
+ if (m->proplist)
+ pa_proplist_free(m->proplist);
+
pa_xfree(m->argument);
pa_xfree(m->name);
@@ -137,6 +158,9 @@ static void pa_module_free(pa_module *m) {
if (m->done)
m->done(m);
+ if (m->proplist)
+ pa_proplist_free(m->proplist);
+
lt_dlclose(m->dl);
pa_log_info("Unloaded \"%s\" (index: #%u).", m->name, m->index);
@@ -234,12 +258,6 @@ void pa_module_unload_request_by_index(pa_core *c, uint32_t idx, pa_bool_t force
pa_module_unload_request(m, force);
}
-pa_modinfo *pa_module_get_info(pa_module *m) {
- pa_assert(m);
-
- return pa_modinfo_get_by_handle(m->dl, m->name);
-}
-
int pa_module_get_n_used(pa_module*m) {
pa_assert(m);
diff --git a/src/pulsecore/module.h b/src/pulsecore/module.h
index 986f0d22..6ab43dcf 100644
--- a/src/pulsecore/module.h
+++ b/src/pulsecore/module.h
@@ -27,8 +27,9 @@
typedef struct pa_module pa_module;
+#include <pulse/proplist.h>
+
#include <pulsecore/core.h>
-#include <pulsecore/modinfo.h>
struct pa_module {
pa_core *core;
@@ -45,6 +46,8 @@ struct pa_module {
pa_bool_t load_once:1;
pa_bool_t unload_requested:1;
+
+ pa_proplist *proplist;
};
pa_module* pa_module_load(pa_core *c, const char *name, const char*argument);
@@ -79,6 +82,4 @@ int pa_module_get_n_used(pa_module*m);
pa_bool_t pa__load_once(void) { return b; } \
struct __stupid_useless_struct_to_allow_trailing_semicolon
-pa_modinfo *pa_module_get_info(pa_module *m);
-
#endif
diff --git a/src/pulsecore/protocol-native.c b/src/pulsecore/protocol-native.c
index 54122679..eb555050 100644
--- a/src/pulsecore/protocol-native.c
+++ b/src/pulsecore/protocol-native.c
@@ -2728,10 +2728,9 @@ static void client_fill_tagstruct(pa_native_connection *c, pa_tagstruct *t, pa_c
if (c->version >= 13)
pa_tagstruct_put_proplist(t, client->proplist);
-
}
-static void module_fill_tagstruct(pa_tagstruct *t, pa_module *module) {
+static void module_fill_tagstruct(pa_native_connection *c, pa_tagstruct *t, pa_module *module) {
pa_assert(t);
pa_assert(module);
@@ -2739,7 +2738,12 @@ static void module_fill_tagstruct(pa_tagstruct *t, pa_module *module) {
pa_tagstruct_puts(t, module->name);
pa_tagstruct_puts(t, module->argument);
pa_tagstruct_putu32(t, (uint32_t) pa_module_get_n_used(module));
- pa_tagstruct_put_boolean(t, FALSE); /* autoload is obsolete */
+
+ if (c->version < 15)
+ pa_tagstruct_put_boolean(t, FALSE); /* autoload is obsolete */
+
+ if (c->version >= 15)
+ pa_tagstruct_put_proplist(t, module->proplist);
}
static void sink_input_fill_tagstruct(pa_native_connection *c, pa_tagstruct *t, pa_sink_input *s) {
@@ -2891,7 +2895,7 @@ static void command_get_info(pa_pdispatch *pd, uint32_t command, uint32_t tag, p
else if (client)
client_fill_tagstruct(c, reply, client);
else if (module)
- module_fill_tagstruct(reply, module);
+ module_fill_tagstruct(c, reply, module);
else if (si)
sink_input_fill_tagstruct(c, reply, si);
else if (so)
@@ -2946,7 +2950,7 @@ static void command_get_info_list(pa_pdispatch *pd, uint32_t command, uint32_t t
else if (command == PA_COMMAND_GET_CLIENT_INFO_LIST)
client_fill_tagstruct(c, reply, p);
else if (command == PA_COMMAND_GET_MODULE_INFO_LIST)
- module_fill_tagstruct(reply, p);
+ module_fill_tagstruct(c, reply, p);
else if (command == PA_COMMAND_GET_SINK_INPUT_INFO_LIST)
sink_input_fill_tagstruct(c, reply, p);
else if (command == PA_COMMAND_GET_SOURCE_OUTPUT_INFO_LIST)
diff --git a/src/pulsecore/strbuf.c b/src/pulsecore/strbuf.c
index 540faef9..8b952788 100644
--- a/src/pulsecore/strbuf.c
+++ b/src/pulsecore/strbuf.c
@@ -180,3 +180,9 @@ size_t pa_strbuf_printf(pa_strbuf *sb, const char *format, ...) {
size *= 2;
}
}
+
+pa_bool_t pa_strbuf_isempty(pa_strbuf *sb) {
+ pa_assert(sb);
+
+ return sb->length <= 0;
+}
diff --git a/src/pulsecore/strbuf.h b/src/pulsecore/strbuf.h
index ac68d7be..1d2a588f 100644
--- a/src/pulsecore/strbuf.h
+++ b/src/pulsecore/strbuf.h
@@ -23,6 +23,7 @@
***/
#include <pulse/gccmacro.h>
+#include <pulsecore/macro.h>
typedef struct pa_strbuf pa_strbuf;
@@ -35,4 +36,6 @@ size_t pa_strbuf_printf(pa_strbuf *sb, const char *format, ...) PA_GCC_PRINTF_A
void pa_strbuf_puts(pa_strbuf *sb, const char *t);
void pa_strbuf_putsn(pa_strbuf *sb, const char *t, size_t m);
+pa_bool_t pa_strbuf_isempty(pa_strbuf *sb);
+
#endif