mirror of
https://gitlab.freedesktop.org/pipewire/pipewire.git
synced 2025-11-04 13:30:12 -05:00
protocol-native: make the connection earlier
Make the connection as soon as we create the client. We create it without file descriptor and then set it when we connect. This makes it possible to use the connection to queue messages before we connect.
This commit is contained in:
parent
8bb1ccf587
commit
0b2e4a18ff
3 changed files with 21 additions and 6 deletions
|
|
@ -703,12 +703,7 @@ static int impl_connect_fd(struct pw_protocol_client *client, int fd, bool do_cl
|
||||||
|
|
||||||
impl->disconnecting = false;
|
impl->disconnecting = false;
|
||||||
|
|
||||||
impl->connection = pw_protocol_native_connection_new(remote->core, fd);
|
pw_protocol_native_connection_set_fd(impl->connection, fd);
|
||||||
if (impl->connection == NULL) {
|
|
||||||
res = -errno;
|
|
||||||
goto error_cleanup;
|
|
||||||
}
|
|
||||||
|
|
||||||
impl->source = pw_loop_add_io(remote->core->main_loop,
|
impl->source = pw_loop_add_io(remote->core->main_loop,
|
||||||
fd,
|
fd,
|
||||||
SPA_IO_IN | SPA_IO_HUP | SPA_IO_ERR,
|
SPA_IO_IN | SPA_IO_HUP | SPA_IO_ERR,
|
||||||
|
|
@ -766,6 +761,7 @@ impl_new_client(struct pw_protocol *protocol,
|
||||||
struct client *impl;
|
struct client *impl;
|
||||||
struct pw_protocol_client *this;
|
struct pw_protocol_client *this;
|
||||||
const char *str = NULL;
|
const char *str = NULL;
|
||||||
|
int res;
|
||||||
|
|
||||||
if ((impl = calloc(1, sizeof(struct client))) == NULL)
|
if ((impl = calloc(1, sizeof(struct client))) == NULL)
|
||||||
return NULL;
|
return NULL;
|
||||||
|
|
@ -774,6 +770,12 @@ impl_new_client(struct pw_protocol *protocol,
|
||||||
this->protocol = protocol;
|
this->protocol = protocol;
|
||||||
this->remote = remote;
|
this->remote = remote;
|
||||||
|
|
||||||
|
impl->connection = pw_protocol_native_connection_new(remote->core, -1);
|
||||||
|
if (impl->connection == NULL) {
|
||||||
|
res = -errno;
|
||||||
|
goto error_free;
|
||||||
|
}
|
||||||
|
|
||||||
if (properties)
|
if (properties)
|
||||||
str = pw_properties_get(properties, PW_KEY_REMOTE_INTENTION);
|
str = pw_properties_get(properties, PW_KEY_REMOTE_INTENTION);
|
||||||
if (str == NULL)
|
if (str == NULL)
|
||||||
|
|
@ -792,6 +794,11 @@ impl_new_client(struct pw_protocol *protocol,
|
||||||
spa_list_append(&protocol->client_list, &this->link);
|
spa_list_append(&protocol->client_list, &this->link);
|
||||||
|
|
||||||
return this;
|
return this;
|
||||||
|
|
||||||
|
error_free:
|
||||||
|
free(impl);
|
||||||
|
errno = -res;
|
||||||
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
static void destroy_server(struct pw_protocol_server *server)
|
static void destroy_server(struct pw_protocol_server *server)
|
||||||
|
|
|
||||||
|
|
@ -266,6 +266,12 @@ no_mem:
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
int pw_protocol_native_connection_set_fd(struct pw_protocol_native_connection *conn, int fd)
|
||||||
|
{
|
||||||
|
conn->fd = fd;
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
/** Destroy a connection
|
/** Destroy a connection
|
||||||
*
|
*
|
||||||
* \param conn the connection to destroy
|
* \param conn the connection to destroy
|
||||||
|
|
|
||||||
|
|
@ -72,6 +72,8 @@ pw_protocol_native_connection_add_listener(struct pw_protocol_native_connection
|
||||||
struct pw_protocol_native_connection *
|
struct pw_protocol_native_connection *
|
||||||
pw_protocol_native_connection_new(struct pw_core *core, int fd);
|
pw_protocol_native_connection_new(struct pw_core *core, int fd);
|
||||||
|
|
||||||
|
int pw_protocol_native_connection_set_fd(struct pw_protocol_native_connection *conn, int fd);
|
||||||
|
|
||||||
void
|
void
|
||||||
pw_protocol_native_connection_destroy(struct pw_protocol_native_connection *conn);
|
pw_protocol_native_connection_destroy(struct pw_protocol_native_connection *conn);
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue