mirror of
https://gitlab.freedesktop.org/pulseaudio/pulseaudio.git
synced 2025-10-29 05:40:23 -04:00
introspect: Get formats for sinks
This gets the list of supported formats for a sink in pa_context_get_sink_info*(). Also prints these in 'pactl list'.
This commit is contained in:
parent
dedbc942ab
commit
322980e2e3
5 changed files with 68 additions and 1 deletions
8
PROTOCOL
8
PROTOCOL
|
|
@ -228,3 +228,11 @@ New fields PA_COMMAND_CREATE_PLAYBACK_STREAM:
|
||||||
One new field in reply from PA_COMMAND_CREATE_PLAYBACK_STREAM:
|
One new field in reply from PA_COMMAND_CREATE_PLAYBACK_STREAM:
|
||||||
|
|
||||||
format_info format
|
format_info format
|
||||||
|
|
||||||
|
New fields in reply from PA_COMMAND_GET_SINK_INFO (and thus
|
||||||
|
PA_COMMAND_GET_SINK_INFO_LIST)
|
||||||
|
|
||||||
|
uint8_t n_formats
|
||||||
|
format_info format1
|
||||||
|
...
|
||||||
|
format_info formatn
|
||||||
|
|
|
||||||
|
|
@ -240,6 +240,33 @@ static void context_get_sink_info_callback(pa_pdispatch *pd, uint32_t command, u
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (o->context->version >= 21) {
|
||||||
|
i.formats = NULL;
|
||||||
|
|
||||||
|
if (pa_tagstruct_getu8(t, &i.n_formats)) {
|
||||||
|
pa_context_fail(o->context, PA_ERR_PROTOCOL);
|
||||||
|
pa_proplist_free(i.proplist);
|
||||||
|
goto finish;
|
||||||
|
}
|
||||||
|
|
||||||
|
pa_assert(i.n_formats > 0);
|
||||||
|
i.formats = pa_xnew0(pa_format_info*, i.n_formats);
|
||||||
|
|
||||||
|
for (j = 0; j < i.n_formats; j++) {
|
||||||
|
i.formats[j] = pa_format_info_new();
|
||||||
|
if (pa_tagstruct_get_format_info(t, i.formats[j]) < 0) {
|
||||||
|
do {
|
||||||
|
pa_format_info_free(i.formats[j]);
|
||||||
|
} while (j--);
|
||||||
|
pa_xfree(i.formats);
|
||||||
|
|
||||||
|
pa_context_fail(o->context, PA_ERR_PROTOCOL);
|
||||||
|
pa_proplist_free(i.proplist);
|
||||||
|
goto finish;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
i.mute = (int) mute;
|
i.mute = (int) mute;
|
||||||
i.flags = (pa_sink_flags_t) flags;
|
i.flags = (pa_sink_flags_t) flags;
|
||||||
i.state = (pa_sink_state_t) state;
|
i.state = (pa_sink_state_t) state;
|
||||||
|
|
@ -253,6 +280,13 @@ static void context_get_sink_info_callback(pa_pdispatch *pd, uint32_t command, u
|
||||||
pa_xfree(i.ports[0]);
|
pa_xfree(i.ports[0]);
|
||||||
pa_xfree(i.ports);
|
pa_xfree(i.ports);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (i.formats) {
|
||||||
|
for (j = 0; j < i.n_formats; j++)
|
||||||
|
pa_format_info_free(i.formats[j]);
|
||||||
|
pa_xfree(i.formats);
|
||||||
|
}
|
||||||
|
|
||||||
pa_proplist_free(i.proplist);
|
pa_proplist_free(i.proplist);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -32,6 +32,7 @@
|
||||||
#include <pulse/channelmap.h>
|
#include <pulse/channelmap.h>
|
||||||
#include <pulse/volume.h>
|
#include <pulse/volume.h>
|
||||||
#include <pulse/proplist.h>
|
#include <pulse/proplist.h>
|
||||||
|
#include <pulse/format.h>
|
||||||
#include <pulse/version.h>
|
#include <pulse/version.h>
|
||||||
|
|
||||||
/** \page introspect Server Query and Control
|
/** \page introspect Server Query and Control
|
||||||
|
|
@ -230,6 +231,8 @@ typedef struct pa_sink_info {
|
||||||
uint32_t n_ports; /**< Number of entries in port array \since 0.9.16 */
|
uint32_t n_ports; /**< Number of entries in port array \since 0.9.16 */
|
||||||
pa_sink_port_info** ports; /**< Array of available ports, or NULL. Array is terminated by an entry set to NULL. The number of entries is stored in n_ports \since 0.9.16 */
|
pa_sink_port_info** ports; /**< Array of available ports, or NULL. Array is terminated by an entry set to NULL. The number of entries is stored in n_ports \since 0.9.16 */
|
||||||
pa_sink_port_info* active_port; /**< Pointer to active port in the array, or NULL \since 0.9.16 */
|
pa_sink_port_info* active_port; /**< Pointer to active port in the array, or NULL \since 0.9.16 */
|
||||||
|
uint8_t n_formats; /**< Number of formats supported by the sink. \since 1.0 */
|
||||||
|
pa_format_info **formats; /**< Array of formats supported by the sink. \since 1.0 */
|
||||||
} pa_sink_info;
|
} pa_sink_info;
|
||||||
|
|
||||||
/** Callback prototype for pa_context_get_sink_info_by_name() and friends */
|
/** Callback prototype for pa_context_get_sink_info_by_name() and friends */
|
||||||
|
|
|
||||||
|
|
@ -2984,6 +2984,19 @@ static void sink_fill_tagstruct(pa_native_connection *c, pa_tagstruct *t, pa_sin
|
||||||
|
|
||||||
pa_tagstruct_puts(t, sink->active_port ? sink->active_port->name : NULL);
|
pa_tagstruct_puts(t, sink->active_port ? sink->active_port->name : NULL);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (c->version >= 21) {
|
||||||
|
uint32_t i;
|
||||||
|
pa_format_info *f;
|
||||||
|
pa_idxset *formats = pa_sink_get_formats(sink);
|
||||||
|
|
||||||
|
pa_tagstruct_putu8(t, (uint8_t) pa_idxset_size(formats));
|
||||||
|
PA_IDXSET_FOREACH(f, formats, i) {
|
||||||
|
pa_tagstruct_put_format_info(t, f);
|
||||||
|
}
|
||||||
|
|
||||||
|
pa_idxset_free(formats, (pa_free2_cb_t) pa_format_info_free2, NULL);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
static void source_fill_tagstruct(pa_native_connection *c, pa_tagstruct *t, pa_source *source) {
|
static void source_fill_tagstruct(pa_native_connection *c, pa_tagstruct *t, pa_source *source) {
|
||||||
|
|
|
||||||
|
|
@ -222,7 +222,8 @@ static void get_sink_info_callback(pa_context *c, const pa_sink_info *i, int is_
|
||||||
cvdb[PA_SW_CVOLUME_SNPRINT_DB_MAX],
|
cvdb[PA_SW_CVOLUME_SNPRINT_DB_MAX],
|
||||||
v[PA_VOLUME_SNPRINT_MAX],
|
v[PA_VOLUME_SNPRINT_MAX],
|
||||||
vdb[PA_SW_VOLUME_SNPRINT_DB_MAX],
|
vdb[PA_SW_VOLUME_SNPRINT_DB_MAX],
|
||||||
cm[PA_CHANNEL_MAP_SNPRINT_MAX];
|
cm[PA_CHANNEL_MAP_SNPRINT_MAX],
|
||||||
|
f[PA_FORMAT_INFO_SNPRINT_MAX];
|
||||||
char *pl;
|
char *pl;
|
||||||
|
|
||||||
if (is_last < 0) {
|
if (is_last < 0) {
|
||||||
|
|
@ -307,6 +308,14 @@ static void get_sink_info_callback(pa_context *c, const pa_sink_info *i, int is_
|
||||||
if (i->active_port)
|
if (i->active_port)
|
||||||
printf(_("\tActive Port: %s\n"),
|
printf(_("\tActive Port: %s\n"),
|
||||||
i->active_port->name);
|
i->active_port->name);
|
||||||
|
|
||||||
|
if (i->formats) {
|
||||||
|
uint8_t j;
|
||||||
|
|
||||||
|
printf(_("\tFormats:\n"));
|
||||||
|
for (j = 0; j < i->n_formats; j++)
|
||||||
|
printf("\t\t%s\n", pa_format_info_snprint(f, sizeof(f), i->formats[j]));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
static void get_source_info_callback(pa_context *c, const pa_source_info *i, int is_last, void *userdata) {
|
static void get_source_info_callback(pa_context *c, const pa_source_info *i, int is_last, void *userdata) {
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue