mirror of
https://gitlab.freedesktop.org/pipewire/pipewire.git
synced 2025-11-05 13:30:02 -05:00
stream: handle endpoint-target for streams
This commit is contained in:
parent
7bce1762de
commit
4ccbce9932
5 changed files with 27 additions and 20 deletions
|
|
@ -121,6 +121,9 @@ static int client_endpoint_create_link(void *object, const struct spa_dict *prop
|
||||||
|
|
||||||
pw_log_debug(NAME" %p: endpoint %p", impl, endpoint);
|
pw_log_debug(NAME" %p: endpoint %p", impl, endpoint);
|
||||||
|
|
||||||
|
if (props == NULL)
|
||||||
|
return -EINVAL;
|
||||||
|
|
||||||
if (!endpoint->active) {
|
if (!endpoint->active) {
|
||||||
endpoint->format.info.raw.rate = 48000;
|
endpoint->format.info.raw.rate = 48000;
|
||||||
|
|
||||||
|
|
@ -287,6 +290,8 @@ static struct endpoint *make_endpoint(struct alsa_node *obj)
|
||||||
endpoint->info.props = &endpoint->props->dict;
|
endpoint->info.props = &endpoint->props->dict;
|
||||||
spa_list_init(&endpoint->stream_list);
|
spa_list_init(&endpoint->stream_list);
|
||||||
|
|
||||||
|
pw_log_debug(NAME" %p: new endpoint %p for alsa node %p", impl, endpoint, obj);
|
||||||
|
|
||||||
pw_client_endpoint_proxy_add_listener(endpoint->client_endpoint,
|
pw_client_endpoint_proxy_add_listener(endpoint->client_endpoint,
|
||||||
&endpoint->client_endpoint_listener,
|
&endpoint->client_endpoint_listener,
|
||||||
&client_endpoint_events,
|
&client_endpoint_events,
|
||||||
|
|
@ -319,9 +324,6 @@ static int setup_alsa_fallback_endpoint(struct alsa_object *obj)
|
||||||
if (s == NULL)
|
if (s == NULL)
|
||||||
return -errno;
|
return -errno;
|
||||||
|
|
||||||
spa_list_append(&endpoint->stream_list, &s->link);
|
|
||||||
endpoint->info.n_streams++;
|
|
||||||
|
|
||||||
s->props = pw_properties_new(NULL, NULL);
|
s->props = pw_properties_new(NULL, NULL);
|
||||||
if ((str = pw_properties_get(n->props, PW_KEY_MEDIA_CLASS)) != NULL)
|
if ((str = pw_properties_get(n->props, PW_KEY_MEDIA_CLASS)) != NULL)
|
||||||
pw_properties_set(s->props, PW_KEY_MEDIA_CLASS, str);
|
pw_properties_set(s->props, PW_KEY_MEDIA_CLASS, str);
|
||||||
|
|
@ -333,18 +335,22 @@ static int setup_alsa_fallback_endpoint(struct alsa_object *obj)
|
||||||
pw_properties_set(s->props, PW_KEY_ENDPOINT_STREAM_NAME, "Capture");
|
pw_properties_set(s->props, PW_KEY_ENDPOINT_STREAM_NAME, "Capture");
|
||||||
|
|
||||||
s->info.version = PW_VERSION_ENDPOINT_STREAM_INFO;
|
s->info.version = PW_VERSION_ENDPOINT_STREAM_INFO;
|
||||||
s->info.id = n->id;
|
s->info.id = endpoint->info.n_streams;
|
||||||
s->info.endpoint_id = endpoint->info.id;
|
s->info.endpoint_id = endpoint->info.id;
|
||||||
s->info.name = (char*)pw_properties_get(s->props, PW_KEY_ENDPOINT_STREAM_NAME);
|
s->info.name = (char*)pw_properties_get(s->props, PW_KEY_ENDPOINT_STREAM_NAME);
|
||||||
s->info.change_mask = PW_ENDPOINT_STREAM_CHANGE_MASK_PROPS;
|
s->info.change_mask = PW_ENDPOINT_STREAM_CHANGE_MASK_PROPS;
|
||||||
s->info.props = &s->props->dict;
|
s->info.props = &s->props->dict;
|
||||||
|
|
||||||
pw_log_debug("stream %d", n->id);
|
pw_log_debug("stream %d", s->info.id);
|
||||||
pw_client_endpoint_proxy_stream_update(endpoint->client_endpoint,
|
pw_client_endpoint_proxy_stream_update(endpoint->client_endpoint,
|
||||||
n->id,
|
n->id,
|
||||||
PW_CLIENT_ENDPOINT_STREAM_UPDATE_INFO,
|
PW_CLIENT_ENDPOINT_STREAM_UPDATE_INFO,
|
||||||
0, NULL,
|
0, NULL,
|
||||||
&s->info);
|
&s->info);
|
||||||
|
|
||||||
|
spa_list_append(&endpoint->stream_list, &s->link);
|
||||||
|
endpoint->info.n_streams++;
|
||||||
|
|
||||||
}
|
}
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -551,7 +551,7 @@ int sm_media_session_roundtrip(struct sm_media_session *sess)
|
||||||
pw_log_debug(NAME" %p: roundtrip %d", impl, seq);
|
pw_log_debug(NAME" %p: roundtrip %d", impl, seq);
|
||||||
|
|
||||||
pw_loop_enter(loop->loop);
|
pw_loop_enter(loop->loop);
|
||||||
while (impl->last_seq != seq) {
|
while (impl->last_seq <= seq) {
|
||||||
if ((res = pw_loop_iterate(loop->loop, -1)) < 0) {
|
if ((res = pw_loop_iterate(loop->loop, -1)) < 0) {
|
||||||
pw_log_warn(NAME" %p: iterate error %d (%s)",
|
pw_log_warn(NAME" %p: iterate error %d (%s)",
|
||||||
loop, res, spa_strerror(res));
|
loop, res, spa_strerror(res));
|
||||||
|
|
|
||||||
|
|
@ -456,7 +456,7 @@ static int rescan_endpoint(struct impl *impl, struct endpoint *ep)
|
||||||
return -EINVAL;
|
return -EINVAL;
|
||||||
}
|
}
|
||||||
|
|
||||||
str = spa_dict_lookup(props, PW_KEY_NODE_TARGET);
|
str = spa_dict_lookup(props, PW_KEY_ENDPOINT_TARGET);
|
||||||
if (str != NULL)
|
if (str != NULL)
|
||||||
find.path_id = atoi(str);
|
find.path_id = atoi(str);
|
||||||
else
|
else
|
||||||
|
|
|
||||||
|
|
@ -150,18 +150,6 @@ static int client_endpoint_create_link(void *object, const struct spa_dict *prop
|
||||||
if (props == NULL)
|
if (props == NULL)
|
||||||
return -EINVAL;
|
return -EINVAL;
|
||||||
|
|
||||||
p = pw_properties_new(NULL, NULL);
|
|
||||||
if (p == NULL)
|
|
||||||
return -errno;
|
|
||||||
|
|
||||||
if (endpoint->info.direction == PW_DIRECTION_OUTPUT) {
|
|
||||||
pw_properties_setf(p, PW_KEY_LINK_OUTPUT_NODE, "%d", endpoint->node->id);
|
|
||||||
pw_properties_setf(p, PW_KEY_LINK_OUTPUT_PORT, "-1");
|
|
||||||
} else {
|
|
||||||
pw_properties_setf(p, PW_KEY_LINK_INPUT_NODE, "%d", endpoint->node->id);
|
|
||||||
pw_properties_setf(p, PW_KEY_LINK_INPUT_PORT, "-1");
|
|
||||||
}
|
|
||||||
|
|
||||||
if (!endpoint->stream.active) {
|
if (!endpoint->stream.active) {
|
||||||
char buf[1024];
|
char buf[1024];
|
||||||
struct spa_pod_builder b = { 0, };
|
struct spa_pod_builder b = { 0, };
|
||||||
|
|
@ -175,7 +163,7 @@ static int client_endpoint_create_link(void *object, const struct spa_dict *prop
|
||||||
SPA_TYPE_OBJECT_ParamPortConfig, SPA_PARAM_PortConfig,
|
SPA_TYPE_OBJECT_ParamPortConfig, SPA_PARAM_PortConfig,
|
||||||
SPA_PARAM_PORT_CONFIG_direction, SPA_POD_Id(endpoint->info.direction),
|
SPA_PARAM_PORT_CONFIG_direction, SPA_POD_Id(endpoint->info.direction),
|
||||||
SPA_PARAM_PORT_CONFIG_mode, SPA_POD_Id(SPA_PARAM_PORT_CONFIG_MODE_dsp),
|
SPA_PARAM_PORT_CONFIG_mode, SPA_POD_Id(SPA_PARAM_PORT_CONFIG_MODE_dsp),
|
||||||
SPA_PARAM_PORT_CONFIG_monitor, SPA_POD_Bool(true),
|
SPA_PARAM_PORT_CONFIG_monitor, SPA_POD_Bool(false),
|
||||||
SPA_PARAM_PORT_CONFIG_format, SPA_POD_Pod(param));
|
SPA_PARAM_PORT_CONFIG_format, SPA_POD_Pod(param));
|
||||||
|
|
||||||
if (pw_log_level_enabled(SPA_LOG_LEVEL_DEBUG))
|
if (pw_log_level_enabled(SPA_LOG_LEVEL_DEBUG))
|
||||||
|
|
@ -187,10 +175,17 @@ static int client_endpoint_create_link(void *object, const struct spa_dict *prop
|
||||||
endpoint->stream.active = true;
|
endpoint->stream.active = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
p = pw_properties_new_dict(props);
|
||||||
|
if (p == NULL)
|
||||||
|
return -errno;
|
||||||
|
|
||||||
if (endpoint->info.direction == PW_DIRECTION_OUTPUT) {
|
if (endpoint->info.direction == PW_DIRECTION_OUTPUT) {
|
||||||
const char *str;
|
const char *str;
|
||||||
struct sm_object *obj;
|
struct sm_object *obj;
|
||||||
|
|
||||||
|
pw_properties_setf(p, PW_KEY_LINK_OUTPUT_NODE, "%d", endpoint->node->id);
|
||||||
|
pw_properties_setf(p, PW_KEY_LINK_OUTPUT_PORT, "-1");
|
||||||
|
|
||||||
str = spa_dict_lookup(props, PW_KEY_ENDPOINT_LINK_INPUT_ENDPOINT);
|
str = spa_dict_lookup(props, PW_KEY_ENDPOINT_LINK_INPUT_ENDPOINT);
|
||||||
if (str == NULL) {
|
if (str == NULL) {
|
||||||
pw_log_warn(NAME" %p: no target endpoint given", impl);
|
pw_log_warn(NAME" %p: no target endpoint given", impl);
|
||||||
|
|
@ -205,6 +200,9 @@ static int client_endpoint_create_link(void *object, const struct spa_dict *prop
|
||||||
}
|
}
|
||||||
pw_endpoint_proxy_create_link((struct pw_endpoint_proxy*)obj->proxy, &p->dict);
|
pw_endpoint_proxy_create_link((struct pw_endpoint_proxy*)obj->proxy, &p->dict);
|
||||||
} else {
|
} else {
|
||||||
|
pw_properties_setf(p, PW_KEY_LINK_INPUT_NODE, "%d", endpoint->node->id);
|
||||||
|
pw_properties_setf(p, PW_KEY_LINK_INPUT_PORT, "-1");
|
||||||
|
|
||||||
sm_media_session_create_links(impl->session, &p->dict);
|
sm_media_session_create_links(impl->session, &p->dict);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -246,6 +244,8 @@ static struct client_endpoint *make_endpoint(struct node *node)
|
||||||
pw_properties_set(props, PW_KEY_ENDPOINT_NAME, name);
|
pw_properties_set(props, PW_KEY_ENDPOINT_NAME, name);
|
||||||
if ((str = spa_dict_lookup(dict, PW_KEY_NODE_AUTOCONNECT)) != NULL)
|
if ((str = spa_dict_lookup(dict, PW_KEY_NODE_AUTOCONNECT)) != NULL)
|
||||||
pw_properties_set(props, PW_KEY_ENDPOINT_AUTOCONNECT, str);
|
pw_properties_set(props, PW_KEY_ENDPOINT_AUTOCONNECT, str);
|
||||||
|
if ((str = spa_dict_lookup(dict, PW_KEY_NODE_TARGET)) != NULL)
|
||||||
|
pw_properties_set(props, PW_KEY_ENDPOINT_TARGET, str);
|
||||||
}
|
}
|
||||||
|
|
||||||
proxy = sm_media_session_create_object(impl->session,
|
proxy = sm_media_session_create_object(impl->session,
|
||||||
|
|
|
||||||
|
|
@ -38,6 +38,7 @@ extern "C" {
|
||||||
* Ex. "sound-card-speakers-usb" */
|
* Ex. "sound-card-speakers-usb" */
|
||||||
#define PW_KEY_ENDPOINT_AUTOCONNECT "endpoint.autoconnect" /**< try to automatically connect this
|
#define PW_KEY_ENDPOINT_AUTOCONNECT "endpoint.autoconnect" /**< try to automatically connect this
|
||||||
* endpoint. */
|
* endpoint. */
|
||||||
|
#define PW_KEY_ENDPOINT_TARGET "endpoint.target" /**< the suggested target to connect to */
|
||||||
|
|
||||||
#define PW_KEY_ENDPOINT_STREAM_ID "endpoint-stream.id" /**< id of a stream */
|
#define PW_KEY_ENDPOINT_STREAM_ID "endpoint-stream.id" /**< id of a stream */
|
||||||
#define PW_KEY_ENDPOINT_STREAM_NAME "endpoint-stream.name" /**< unique name of a stream */
|
#define PW_KEY_ENDPOINT_STREAM_NAME "endpoint-stream.name" /**< unique name of a stream */
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue