mirror of
https://gitlab.freedesktop.org/pipewire/pipewire.git
synced 2025-11-04 13:30:12 -05:00
loopback: use _raw_build helpers
Now that the raw_builder supports wildcard for rate, use it in loopback and add an option to force resampling as well.
This commit is contained in:
parent
b318a9e1d3
commit
90de408e31
2 changed files with 15 additions and 16 deletions
|
|
@ -150,14 +150,8 @@ static int module_loopback_load(struct client *client, struct module *module)
|
||||||
&out_stream_events, data);
|
&out_stream_events, data);
|
||||||
|
|
||||||
n_params = 0;
|
n_params = 0;
|
||||||
params[n_params++] = spa_pod_builder_add_object(&b,
|
params[n_params++] = spa_format_audio_raw_build(&b, SPA_PARAM_EnumFormat,
|
||||||
SPA_TYPE_OBJECT_Format, SPA_PARAM_EnumFormat,
|
&data->info);
|
||||||
SPA_FORMAT_mediaType, SPA_POD_Id(SPA_MEDIA_TYPE_audio),
|
|
||||||
SPA_FORMAT_mediaSubtype, SPA_POD_Id(SPA_MEDIA_SUBTYPE_raw),
|
|
||||||
SPA_FORMAT_AUDIO_format, SPA_POD_Id(data->info.format),
|
|
||||||
SPA_FORMAT_AUDIO_channels, SPA_POD_Int(data->info.channels),
|
|
||||||
SPA_FORMAT_AUDIO_position, SPA_POD_Array(sizeof(uint32_t),
|
|
||||||
SPA_TYPE_Id, data->info.channels, data->info.position));
|
|
||||||
|
|
||||||
if ((res = pw_stream_connect(data->capture,
|
if ((res = pw_stream_connect(data->capture,
|
||||||
PW_DIRECTION_INPUT,
|
PW_DIRECTION_INPUT,
|
||||||
|
|
@ -215,6 +209,7 @@ static const struct spa_dict_item module_loopback_info[] = {
|
||||||
{ PW_KEY_MODULE_USAGE, "source=<source to connect to> "
|
{ PW_KEY_MODULE_USAGE, "source=<source to connect to> "
|
||||||
"sink=<sink to connect to> "
|
"sink=<sink to connect to> "
|
||||||
"latency_msec=<latency in ms> "
|
"latency_msec=<latency in ms> "
|
||||||
|
"rate=<sample rate> "
|
||||||
"channels=<number of channels> "
|
"channels=<number of channels> "
|
||||||
"channel_map=<channel map> "
|
"channel_map=<channel map> "
|
||||||
"sink_input_properties=<proplist> "
|
"sink_input_properties=<proplist> "
|
||||||
|
|
@ -266,6 +261,12 @@ static struct module *create_module_loopback(struct impl *impl, const char *argu
|
||||||
} else {
|
} else {
|
||||||
info.channels = 2;
|
info.channels = 2;
|
||||||
}
|
}
|
||||||
|
if ((str = pw_properties_get(props, "rate")) != NULL) {
|
||||||
|
info.rate = pw_properties_parse_int(str);
|
||||||
|
pw_properties_set(props, "rate", NULL);
|
||||||
|
} else {
|
||||||
|
info.rate = 0;
|
||||||
|
}
|
||||||
|
|
||||||
if ((str = pw_properties_get(props, "channel_map")) != NULL) {
|
if ((str = pw_properties_get(props, "channel_map")) != NULL) {
|
||||||
struct channel_map map;
|
struct channel_map map;
|
||||||
|
|
@ -285,7 +286,6 @@ static struct module *create_module_loopback(struct impl *impl, const char *argu
|
||||||
info.position[0] = SPA_AUDIO_CHANNEL_FL;
|
info.position[0] = SPA_AUDIO_CHANNEL_FL;
|
||||||
info.position[1] = SPA_AUDIO_CHANNEL_FR;
|
info.position[1] = SPA_AUDIO_CHANNEL_FR;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* TODO: pull in all of pa_channel_map_init_auto() */
|
/* TODO: pull in all of pa_channel_map_init_auto() */
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -32,7 +32,7 @@
|
||||||
|
|
||||||
#include <spa/utils/result.h>
|
#include <spa/utils/result.h>
|
||||||
#include <spa/pod/builder.h>
|
#include <spa/pod/builder.h>
|
||||||
#include <spa/param/format.h>
|
#include <spa/param/audio/format-utils.h>
|
||||||
#include <spa/param/audio/raw.h>
|
#include <spa/param/audio/raw.h>
|
||||||
|
|
||||||
#include <pipewire/pipewire.h>
|
#include <pipewire/pipewire.h>
|
||||||
|
|
@ -121,12 +121,11 @@ static int setup_streams(struct data *data)
|
||||||
&out_stream_events, data);
|
&out_stream_events, data);
|
||||||
|
|
||||||
n_params = 0;
|
n_params = 0;
|
||||||
params[n_params++] = spa_pod_builder_add_object(&b,
|
params[n_params++] = spa_format_audio_raw_build(&b, SPA_PARAM_EnumFormat,
|
||||||
SPA_TYPE_OBJECT_Format, SPA_PARAM_EnumFormat,
|
&SPA_AUDIO_INFO_RAW_INIT(
|
||||||
SPA_FORMAT_mediaType, SPA_POD_Id(SPA_MEDIA_TYPE_audio),
|
.flags = SPA_AUDIO_FLAG_UNPOSITIONED,
|
||||||
SPA_FORMAT_mediaSubtype, SPA_POD_Id(SPA_MEDIA_SUBTYPE_raw),
|
.format = SPA_AUDIO_FORMAT_F32P,
|
||||||
SPA_FORMAT_AUDIO_format, SPA_POD_Id(SPA_AUDIO_FORMAT_F32P),
|
.channels = data->channels));
|
||||||
SPA_FORMAT_AUDIO_channels, SPA_POD_Int(data->channels));
|
|
||||||
|
|
||||||
if ((res = pw_stream_connect(data->capture,
|
if ((res = pw_stream_connect(data->capture,
|
||||||
PW_DIRECTION_INPUT,
|
PW_DIRECTION_INPUT,
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue