summaryrefslogtreecommitdiff
path: root/src/modules/module-protocol-native.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/modules/module-protocol-native.c')
-rw-r--r--src/modules/module-protocol-native.c32
1 files changed, 21 insertions, 11 deletions
diff --git a/src/modules/module-protocol-native.c b/src/modules/module-protocol-native.c
index 6c54e26d..62817a31 100644
--- a/src/modules/module-protocol-native.c
+++ b/src/modules/module-protocol-native.c
@@ -80,6 +80,7 @@ struct protocol_data {
struct client {
struct pw_protocol_client this;
+ struct pw_remote *remote;
struct spa_source *source;
struct pw_protocol_native_connection *connection;
@@ -579,7 +580,7 @@ static void
on_remote_data(void *data, int fd, uint32_t mask)
{
struct client *impl = data;
- struct pw_remote *this = impl->this.remote;
+ struct pw_remote *this = impl->remote;
struct pw_protocol_native_connection *conn = impl->connection;
struct pw_core *core = pw_remote_get_core(this);
int res;
@@ -667,6 +668,8 @@ on_remote_data(void *data, int fd, uint32_t mask)
return;
error:
pw_log_error(NAME" %p: got connection error %d (%s)", impl, res, spa_strerror(res));
+ pw_proxy_notify((struct pw_proxy*)this->core_proxy,
+ struct pw_core_proxy_events, error, 0, 0, this->recv_seq, res, "connection error");
pw_loop_destroy_source(pw_core_get_main_loop(core), impl->source);
impl->source = NULL;
pw_remote_disconnect(this);
@@ -676,7 +679,7 @@ error:
static void on_need_flush(void *data)
{
struct client *impl = data;
- struct pw_remote *remote = impl->this.remote;
+ struct pw_remote *remote = impl->remote;
if (!impl->flushing && impl->source) {
int mask = impl->source->mask;
@@ -695,17 +698,12 @@ static const struct pw_protocol_native_connection_events client_conn_events = {
static int impl_connect_fd(struct pw_protocol_client *client, int fd, bool do_close)
{
struct client *impl = SPA_CONTAINER_OF(client, struct client, this);
- struct pw_remote *remote = client->remote;
+ struct pw_remote *remote = impl->remote;
int res;
impl->disconnecting = false;
- impl->connection = pw_protocol_native_connection_new(remote->core, fd);
- if (impl->connection == NULL) {
- res = -errno;
- goto error_cleanup;
- }
-
+ pw_protocol_native_connection_set_fd(impl->connection, fd);
impl->source = pw_loop_add_io(remote->core->main_loop,
fd,
SPA_IO_IN | SPA_IO_HUP | SPA_IO_ERR,
@@ -732,7 +730,7 @@ error_cleanup:
static void impl_disconnect(struct pw_protocol_client *client)
{
struct client *impl = SPA_CONTAINER_OF(client, struct client, this);
- struct pw_remote *remote = client->remote;
+ struct pw_remote *remote = impl->remote;
impl->disconnecting = true;
@@ -763,13 +761,14 @@ impl_new_client(struct pw_protocol *protocol,
struct client *impl;
struct pw_protocol_client *this;
const char *str = NULL;
+ int res;
if ((impl = calloc(1, sizeof(struct client))) == NULL)
return NULL;
this = &impl->this;
this->protocol = protocol;
- this->remote = remote;
+ impl->remote = remote;
if (properties)
str = pw_properties_get(properties, PW_KEY_REMOTE_INTENTION);
@@ -786,9 +785,20 @@ impl_new_client(struct pw_protocol *protocol,
this->disconnect = impl_disconnect;
this->destroy = impl_destroy;
+ impl->connection = pw_protocol_native_connection_new(remote->core, -1);
+ if (impl->connection == NULL) {
+ res = -errno;
+ goto error_free;
+ }
+
spa_list_append(&protocol->client_list, &this->link);
return this;
+
+error_free:
+ free(impl);
+ errno = -res;
+ return NULL;
}
static void destroy_server(struct pw_protocol_server *server)