mirror of
https://gitlab.freedesktop.org/pipewire/pipewire.git
synced 2025-11-02 09:01:50 -05:00
adapter: set driver property
Pass the node.driver property from the slave to the adapter. Set the media-class on the adapter.
This commit is contained in:
parent
9364f64b10
commit
a07fb58a21
2 changed files with 22 additions and 10 deletions
|
|
@ -74,6 +74,7 @@ struct impl {
|
||||||
unsigned int started:1;
|
unsigned int started:1;
|
||||||
unsigned int active:1;
|
unsigned int active:1;
|
||||||
unsigned int driver:1;
|
unsigned int driver:1;
|
||||||
|
unsigned int master:1;
|
||||||
};
|
};
|
||||||
|
|
||||||
/** \endcond */
|
/** \endcond */
|
||||||
|
|
@ -180,7 +181,14 @@ static void emit_node_info(struct impl *this, bool full)
|
||||||
{
|
{
|
||||||
if (full)
|
if (full)
|
||||||
this->info.change_mask = this->info_all;
|
this->info.change_mask = this->info_all;
|
||||||
|
|
||||||
if (this->info.change_mask) {
|
if (this->info.change_mask) {
|
||||||
|
struct spa_dict_item items[1];
|
||||||
|
|
||||||
|
this->info.change_mask |= SPA_NODE_CHANGE_MASK_PROPS;
|
||||||
|
items[0] = SPA_DICT_ITEM_INIT(SPA_KEY_NODE_DRIVER, this->driver ? "1" : "0");
|
||||||
|
this->info.props = &SPA_DICT_INIT(items, 1);
|
||||||
|
|
||||||
spa_node_emit_info(&this->hooks, &this->info);
|
spa_node_emit_info(&this->hooks, &this->info);
|
||||||
this->info.change_mask = 0;
|
this->info.change_mask = 0;
|
||||||
}
|
}
|
||||||
|
|
@ -307,17 +315,21 @@ static const struct spa_node_events convert_node_events = {
|
||||||
static void slave_info(void *data, const struct spa_node_info *info)
|
static void slave_info(void *data, const struct spa_node_info *info)
|
||||||
{
|
{
|
||||||
struct impl *this = data;
|
struct impl *this = data;
|
||||||
const char *dir;
|
const char *str;
|
||||||
|
|
||||||
if (info->max_input_ports > 0) {
|
if (info->max_input_ports > 0)
|
||||||
this->direction = SPA_DIRECTION_INPUT;
|
this->direction = SPA_DIRECTION_INPUT;
|
||||||
dir = "input";
|
else
|
||||||
}
|
|
||||||
else {
|
|
||||||
this->direction = SPA_DIRECTION_OUTPUT;
|
this->direction = SPA_DIRECTION_OUTPUT;
|
||||||
dir = "output";
|
|
||||||
|
spa_log_debug(this->log, NAME" %p: slave info %s", this,
|
||||||
|
this->direction == SPA_DIRECTION_INPUT ?
|
||||||
|
"Input" : "Output");
|
||||||
|
|
||||||
|
if (info->props) {
|
||||||
|
if ((str = spa_dict_lookup(info->props, SPA_KEY_NODE_DRIVER)) != NULL)
|
||||||
|
this->driver = strcmp(str, "true") == 0 || atoi(str) == 1;
|
||||||
}
|
}
|
||||||
spa_log_debug(this->log, NAME" %p: slave info %s", this, dir);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static const struct spa_node_events slave_node_events = {
|
static const struct spa_node_events slave_node_events = {
|
||||||
|
|
@ -770,7 +782,7 @@ static int impl_node_process(void *object)
|
||||||
|
|
||||||
status = spa_node_process(this->slave);
|
status = spa_node_process(this->slave);
|
||||||
|
|
||||||
if (this->direction == SPA_DIRECTION_OUTPUT) {
|
if (this->direction == SPA_DIRECTION_OUTPUT && !this->master) {
|
||||||
if (this->use_converter)
|
if (this->use_converter)
|
||||||
status = spa_node_process(this->convert);
|
status = spa_node_process(this->convert);
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -268,8 +268,6 @@ struct pw_node *pw_adapter_new(struct pw_core *core,
|
||||||
enum pw_direction direction;
|
enum pw_direction direction;
|
||||||
int res = -ENOENT;
|
int res = -ENOENT;
|
||||||
|
|
||||||
pw_properties_set(props, PW_KEY_MEDIA_CLASS, NULL);
|
|
||||||
|
|
||||||
info = pw_node_get_info(slave);
|
info = pw_node_get_info(slave);
|
||||||
if (info == NULL) {
|
if (info == NULL) {
|
||||||
errno = EINVAL;
|
errno = EINVAL;
|
||||||
|
|
@ -297,6 +295,8 @@ struct pw_node *pw_adapter_new(struct pw_core *core,
|
||||||
pw_properties_setf(props, "audio.adapt.slave", "%p", slave->node);
|
pw_properties_setf(props, "audio.adapt.slave", "%p", slave->node);
|
||||||
pw_properties_set(props, "factory.mode", mode);
|
pw_properties_set(props, "factory.mode", mode);
|
||||||
pw_properties_set(props, SPA_KEY_LIBRARY_NAME, "audioconvert/libspa-audioconvert");
|
pw_properties_set(props, SPA_KEY_LIBRARY_NAME, "audioconvert/libspa-audioconvert");
|
||||||
|
pw_properties_setf(props, PW_KEY_MEDIA_CLASS, "Audio/%s",
|
||||||
|
direction == PW_DIRECTION_INPUT ? "Sink" : "Source");
|
||||||
|
|
||||||
node = pw_spa_node_load(core, NULL, NULL,
|
node = pw_spa_node_load(core, NULL, NULL,
|
||||||
SPA_NAME_AUDIO_ADAPT,
|
SPA_NAME_AUDIO_ADAPT,
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue