sink, source: Add pa_sink/source_get_description()

This commit is contained in:
Tanu Kaskinen 2013-07-03 14:09:06 +03:00
parent 8d00e420f7
commit 85d0b0bd51
22 changed files with 96 additions and 123 deletions

View file

@ -183,13 +183,13 @@ char *pa_card_list_to_string(pa_core *c) {
if (!pa_idxset_isempty(card->sinks)) {
pa_strbuf_puts(s, "\tsinks:\n");
PA_IDXSET_FOREACH(sink, card->sinks, sidx)
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)));
pa_strbuf_printf(s, "\t\t%s/#%u: %s\n", sink->name, sink->index, pa_sink_get_description(sink));
}
if (!pa_idxset_isempty(card->sources)) {
pa_strbuf_puts(s, "\tsources:\n");
PA_IDXSET_FOREACH(source, card->sources, sidx)
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)));
pa_strbuf_printf(s, "\t\t%s/#%u: %s\n", source->name, source->index, pa_source_get_description(source));
}
append_port_list(s, card->ports);

View file

@ -475,7 +475,7 @@ static void handle_listen(struct connection *c) {
PA_IDXSET_FOREACH(sink, c->protocol->core->sinks, idx) {
char *t, *m;
t = escape_html(pa_strna(pa_proplist_gets(sink->proplist, PA_PROP_DEVICE_DESCRIPTION)));
t = escape_html(pa_sink_get_description(sink));
m = pa_sample_spec_to_mime_type_mimefy(&sink->sample_spec, &sink->channel_map);
pa_ioline_printf(c->line,
@ -497,7 +497,7 @@ static void handle_listen(struct connection *c) {
if (source->monitor_of)
continue;
t = escape_html(pa_strna(pa_proplist_gets(source->proplist, PA_PROP_DEVICE_DESCRIPTION)));
t = escape_html(pa_source_get_description(source));
m = pa_sample_spec_to_mime_type_mimefy(&source->sample_spec, &source->channel_map);
pa_ioline_printf(c->line,

View file

@ -3125,7 +3125,7 @@ static void sink_fill_tagstruct(pa_native_connection *c, pa_tagstruct *t, pa_sin
t,
PA_TAG_U32, sink->index,
PA_TAG_STRING, sink->name,
PA_TAG_STRING, pa_strnull(pa_proplist_gets(sink->proplist, PA_PROP_DEVICE_DESCRIPTION)),
PA_TAG_STRING, pa_sink_get_description(sink),
PA_TAG_SAMPLE_SPEC, &fixed_ss,
PA_TAG_CHANNEL_MAP, &sink->channel_map,
PA_TAG_U32, sink->module ? sink->module->index : PA_INVALID_INDEX,
@ -3195,7 +3195,7 @@ static void source_fill_tagstruct(pa_native_connection *c, pa_tagstruct *t, pa_s
t,
PA_TAG_U32, source->index,
PA_TAG_STRING, source->name,
PA_TAG_STRING, pa_strnull(pa_proplist_gets(source->proplist, PA_PROP_DEVICE_DESCRIPTION)),
PA_TAG_STRING, pa_source_get_description(source),
PA_TAG_SAMPLE_SPEC, &fixed_ss,
PA_TAG_CHANNEL_MAP, &source->channel_map,
PA_TAG_U32, source->module ? source->module->index : PA_INVALID_INDEX,

View file

@ -1377,6 +1377,20 @@ void pa_sink_render_full(pa_sink *s, size_t length, pa_memchunk *result) {
pa_sink_unref(s);
}
/* Called from the main thread. */
const char *pa_sink_get_description(pa_sink *s) {
const char *description;
pa_assert(s);
description = pa_proplist_gets(s->proplist, PA_PROP_DEVICE_DESCRIPTION);
if (!description || !*description)
description = s->name;
return description;
}
/* Called from main thread */
int pa_sink_update_rate(pa_sink *s, uint32_t rate, bool passthrough) {
int ret = -1;

View file

@ -411,6 +411,7 @@ unsigned pa_device_init_priority(pa_proplist *p);
/**** May be called by everyone, from main context */
const char *pa_sink_get_description(pa_sink *s);
int pa_sink_update_rate(pa_sink *s, uint32_t rate, bool passthrough);
void pa_sink_set_latency_offset(pa_sink *s, int64_t offset);

View file

@ -2596,6 +2596,20 @@ void pa_source_set_fixed_latency_within_thread(pa_source *s, pa_usec_t latency)
pa_source_invalidate_requested_latency(s, false);
}
/* Called from the main thread. */
const char *pa_source_get_description(pa_source *s) {
const char *description;
pa_assert(s);
description = pa_proplist_gets(s->proplist, PA_PROP_DEVICE_DESCRIPTION);
if (!description || !*description)
description = s->name;
return description;
}
/* Called from main thread */
void pa_source_set_latency_offset(pa_source *s, int64_t offset) {
pa_source_assert_ref(s);

View file

@ -344,6 +344,7 @@ void pa_source_update_flags(pa_source *s, pa_source_flags_t mask, pa_source_flag
/*** May be called by everyone, from main context */
const char *pa_source_get_description(pa_source *s);
void pa_source_set_latency_offset(pa_source *s, int64_t offset);
/* The returned value is supposed to be in the time domain of the sound card! */