mirror of
https://gitlab.freedesktop.org/pipewire/pipewire.git
synced 2025-11-03 09:01:54 -05:00
stream: improve async connect
This commit is contained in:
parent
1bfb1d9228
commit
220d934842
1 changed files with 11 additions and 5 deletions
|
|
@ -88,6 +88,7 @@ struct stream {
|
||||||
enum spa_direction direction;
|
enum spa_direction direction;
|
||||||
enum pw_stream_flags flags;
|
enum pw_stream_flags flags;
|
||||||
|
|
||||||
|
bool async_connect;
|
||||||
struct spa_hook remote_listener;
|
struct spa_hook remote_listener;
|
||||||
|
|
||||||
struct pw_node *node;
|
struct pw_node *node;
|
||||||
|
|
@ -800,7 +801,6 @@ static int handle_connect(struct pw_stream *stream)
|
||||||
struct stream *impl = SPA_CONTAINER_OF(stream, struct stream, this);
|
struct stream *impl = SPA_CONTAINER_OF(stream, struct stream, this);
|
||||||
|
|
||||||
pw_log_debug("stream %p: creating node", stream);
|
pw_log_debug("stream %p: creating node", stream);
|
||||||
|
|
||||||
impl->node = pw_node_new(impl->core, "export-source",
|
impl->node = pw_node_new(impl->core, "export-source",
|
||||||
pw_properties_copy(stream->properties), 0);
|
pw_properties_copy(stream->properties), 0);
|
||||||
impl->impl_node = impl_node;
|
impl->impl_node = impl_node;
|
||||||
|
|
@ -825,6 +825,9 @@ static void on_remote_state_changed(void *_data, enum pw_remote_state old,
|
||||||
enum pw_remote_state state, const char *error)
|
enum pw_remote_state state, const char *error)
|
||||||
{
|
{
|
||||||
struct pw_stream *stream = _data;
|
struct pw_stream *stream = _data;
|
||||||
|
struct stream *impl = SPA_CONTAINER_OF(stream, struct stream, this);
|
||||||
|
|
||||||
|
pw_log_debug("stream %p: remote state %d", stream, state);
|
||||||
|
|
||||||
switch (state) {
|
switch (state) {
|
||||||
case PW_REMOTE_STATE_ERROR:
|
case PW_REMOTE_STATE_ERROR:
|
||||||
|
|
@ -835,6 +838,7 @@ static void on_remote_state_changed(void *_data, enum pw_remote_state old,
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case PW_REMOTE_STATE_CONNECTED:
|
case PW_REMOTE_STATE_CONNECTED:
|
||||||
|
if (impl->async_connect)
|
||||||
handle_connect(stream);
|
handle_connect(stream);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
|
|
@ -884,7 +888,7 @@ struct pw_stream * pw_stream_new(struct pw_remote *remote, const char *name,
|
||||||
this->properties = props;
|
this->properties = props;
|
||||||
|
|
||||||
this->remote = remote;
|
this->remote = remote;
|
||||||
this->name = strdup(name);
|
this->name = name ? strdup(name) : NULL;
|
||||||
|
|
||||||
init_type(&impl->type, remote->core->type.map);
|
init_type(&impl->type, remote->core->type.map);
|
||||||
|
|
||||||
|
|
@ -1157,8 +1161,10 @@ pw_stream_connect(struct pw_stream *stream,
|
||||||
pw_properties_set(stream->properties, PW_NODE_PROP_EXCLUSIVE, "1");
|
pw_properties_set(stream->properties, PW_NODE_PROP_EXCLUSIVE, "1");
|
||||||
|
|
||||||
state = pw_remote_get_state(stream->remote, NULL);
|
state = pw_remote_get_state(stream->remote, NULL);
|
||||||
if (state == PW_REMOTE_STATE_UNCONNECTED ||
|
impl->async_connect = (state == PW_REMOTE_STATE_UNCONNECTED ||
|
||||||
state == PW_REMOTE_STATE_ERROR)
|
state == PW_REMOTE_STATE_ERROR);
|
||||||
|
|
||||||
|
if (impl->async_connect)
|
||||||
res = pw_remote_connect(stream->remote);
|
res = pw_remote_connect(stream->remote);
|
||||||
else
|
else
|
||||||
res = handle_connect(stream);
|
res = handle_connect(stream);
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue