mirror of
https://gitlab.freedesktop.org/pulseaudio/pulseaudio.git
synced 2025-10-29 05:40:23 -04:00
introspect: Get format of source output
This gets the negotiated format of source outputs in pa_context_get_source_output*(). Also prints the format and volume in 'pactl list'.
This commit is contained in:
parent
dffc4d18d3
commit
4ab60d0377
5 changed files with 20 additions and 3 deletions
3
PROTOCOL
3
PROTOCOL
|
|
@ -263,9 +263,10 @@ PA_COMMAND_GET_SOURCE_INFO_LIST)
|
||||||
...
|
...
|
||||||
format_info formatn
|
format_info formatn
|
||||||
|
|
||||||
Four new fields in reply from PA_COMMAND_GET_SOURCE_OUTPUT_INFO (and thus
|
Five new fields in reply from PA_COMMAND_GET_SOURCE_OUTPUT_INFO (and thus
|
||||||
PA_COMMAND_GET_SOURCE_OUTPUT_INFO_LIST)
|
PA_COMMAND_GET_SOURCE_OUTPUT_INFO_LIST)
|
||||||
|
|
||||||
|
format_info format
|
||||||
volume
|
volume
|
||||||
bool mute
|
bool mute
|
||||||
bool has_volume
|
bool has_volume
|
||||||
|
|
|
||||||
|
|
@ -1168,6 +1168,7 @@ static void context_get_source_output_info_callback(pa_pdispatch *pd, uint32_t c
|
||||||
|
|
||||||
pa_zero(i);
|
pa_zero(i);
|
||||||
i.proplist = pa_proplist_new();
|
i.proplist = pa_proplist_new();
|
||||||
|
i.format = pa_format_info_new();
|
||||||
|
|
||||||
if (pa_tagstruct_getu32(t, &i.index) < 0 ||
|
if (pa_tagstruct_getu32(t, &i.index) < 0 ||
|
||||||
pa_tagstruct_gets(t, &i.name) < 0 ||
|
pa_tagstruct_gets(t, &i.name) < 0 ||
|
||||||
|
|
@ -1185,10 +1186,12 @@ static void context_get_source_output_info_callback(pa_pdispatch *pd, uint32_t c
|
||||||
(o->context->version >= 22 && (pa_tagstruct_get_cvolume(t, &i.volume) < 0 ||
|
(o->context->version >= 22 && (pa_tagstruct_get_cvolume(t, &i.volume) < 0 ||
|
||||||
pa_tagstruct_get_boolean(t, &mute) < 0 ||
|
pa_tagstruct_get_boolean(t, &mute) < 0 ||
|
||||||
pa_tagstruct_get_boolean(t, &has_volume) < 0 ||
|
pa_tagstruct_get_boolean(t, &has_volume) < 0 ||
|
||||||
pa_tagstruct_get_boolean(t, &volume_writable) < 0))) {
|
pa_tagstruct_get_boolean(t, &volume_writable) < 0 ||
|
||||||
|
pa_tagstruct_get_format_info(t, i.format) < 0))) {
|
||||||
|
|
||||||
pa_context_fail(o->context, PA_ERR_PROTOCOL);
|
pa_context_fail(o->context, PA_ERR_PROTOCOL);
|
||||||
pa_proplist_free(i.proplist);
|
pa_proplist_free(i.proplist);
|
||||||
|
pa_format_info_free(i.format);
|
||||||
goto finish;
|
goto finish;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -1203,6 +1206,7 @@ static void context_get_source_output_info_callback(pa_pdispatch *pd, uint32_t c
|
||||||
}
|
}
|
||||||
|
|
||||||
pa_proplist_free(i.proplist);
|
pa_proplist_free(i.proplist);
|
||||||
|
pa_format_info_free(i.format);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -561,6 +561,7 @@ typedef struct pa_source_output_info {
|
||||||
int mute; /**< Stream muted \since 1.0 */
|
int mute; /**< Stream muted \since 1.0 */
|
||||||
int has_volume; /**< Stream has volume. If not set, then the meaning of this struct's volume member is unspecified. \since 1.0 */
|
int has_volume; /**< Stream has volume. If not set, then the meaning of this struct's volume member is unspecified. \since 1.0 */
|
||||||
int volume_writable; /**< The volume can be set. If not set, the volume can still change even though clients can't control the volume. \since 1.0 */
|
int volume_writable; /**< The volume can be set. If not set, the volume can still change even though clients can't control the volume. \since 1.0 */
|
||||||
|
pa_format_info *format; /**< Stream format information. \since 1.0 */
|
||||||
} pa_source_output_info;
|
} pa_source_output_info;
|
||||||
|
|
||||||
/** Callback prototype for pa_context_get_source_output_info() and friends*/
|
/** Callback prototype for pa_context_get_source_output_info() and friends*/
|
||||||
|
|
|
||||||
|
|
@ -3317,6 +3317,7 @@ static void source_output_fill_tagstruct(pa_native_connection *c, pa_tagstruct *
|
||||||
pa_tagstruct_put_boolean(t, pa_source_output_get_mute(s));
|
pa_tagstruct_put_boolean(t, pa_source_output_get_mute(s));
|
||||||
pa_tagstruct_put_boolean(t, has_volume);
|
pa_tagstruct_put_boolean(t, has_volume);
|
||||||
pa_tagstruct_put_boolean(t, s->volume_writable);
|
pa_tagstruct_put_boolean(t, s->volume_writable);
|
||||||
|
pa_tagstruct_put_format_info(t, s->format);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -639,7 +639,7 @@ static void get_sink_input_info_callback(pa_context *c, const pa_sink_input_info
|
||||||
}
|
}
|
||||||
|
|
||||||
static void get_source_output_info_callback(pa_context *c, const pa_source_output_info *i, int is_last, void *userdata) {
|
static void get_source_output_info_callback(pa_context *c, const pa_source_output_info *i, int is_last, void *userdata) {
|
||||||
char t[32], k[32], s[PA_SAMPLE_SPEC_SNPRINT_MAX], cm[PA_CHANNEL_MAP_SNPRINT_MAX];
|
char t[32], k[32], s[PA_SAMPLE_SPEC_SNPRINT_MAX], cv[PA_CVOLUME_SNPRINT_MAX], cvdb[PA_SW_CVOLUME_SNPRINT_DB_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) {
|
||||||
|
|
@ -680,6 +680,11 @@ static void get_source_output_info_callback(pa_context *c, const pa_source_outpu
|
||||||
"\tSource: %u\n"
|
"\tSource: %u\n"
|
||||||
"\tSample Specification: %s\n"
|
"\tSample Specification: %s\n"
|
||||||
"\tChannel Map: %s\n"
|
"\tChannel Map: %s\n"
|
||||||
|
"\tFormat: %s\n"
|
||||||
|
"\tMute: %s\n"
|
||||||
|
"\tVolume: %s\n"
|
||||||
|
"\t %s\n"
|
||||||
|
"\t balance %0.2f\n"
|
||||||
"\tBuffer Latency: %0.0f usec\n"
|
"\tBuffer Latency: %0.0f usec\n"
|
||||||
"\tSource Latency: %0.0f usec\n"
|
"\tSource Latency: %0.0f usec\n"
|
||||||
"\tResample method: %s\n"
|
"\tResample method: %s\n"
|
||||||
|
|
@ -691,6 +696,11 @@ static void get_source_output_info_callback(pa_context *c, const pa_source_outpu
|
||||||
i->source,
|
i->source,
|
||||||
pa_sample_spec_snprint(s, sizeof(s), &i->sample_spec),
|
pa_sample_spec_snprint(s, sizeof(s), &i->sample_spec),
|
||||||
pa_channel_map_snprint(cm, sizeof(cm), &i->channel_map),
|
pa_channel_map_snprint(cm, sizeof(cm), &i->channel_map),
|
||||||
|
pa_format_info_snprint(f, sizeof(f), i->format),
|
||||||
|
pa_yes_no(i->mute),
|
||||||
|
pa_cvolume_snprint(cv, sizeof(cv), &i->volume),
|
||||||
|
pa_sw_cvolume_snprint_dB(cvdb, sizeof(cvdb), &i->volume),
|
||||||
|
pa_cvolume_get_balance(&i->volume, &i->channel_map),
|
||||||
(double) i->buffer_usec,
|
(double) i->buffer_usec,
|
||||||
(double) i->source_usec,
|
(double) i->source_usec,
|
||||||
i->resample_method ? i->resample_method : _("n/a"),
|
i->resample_method ? i->resample_method : _("n/a"),
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue