core: don't remove client resource in hello

Keep the client resource of a client around and make sure we don't
destroy it in hello.
This commit is contained in:
Wim Taymans 2019-05-10 12:36:28 +02:00
parent a804b71267
commit 4e70cddf1d
4 changed files with 15 additions and 3 deletions

View file

@ -169,6 +169,8 @@ static const struct pw_client_proxy_methods client_methods = {
static void client_unbind_func(void *data) static void client_unbind_func(void *data)
{ {
struct pw_resource *resource = data; struct pw_resource *resource = data;
if (resource->id == 1)
resource->client->client_resource = NULL;
spa_list_remove(&resource->link); spa_list_remove(&resource->link);
} }
@ -199,6 +201,9 @@ global_bind(void *_data, struct pw_client *client, uint32_t permissions,
spa_list_append(&global->resource_list, &resource->link); spa_list_append(&global->resource_list, &resource->link);
if (resource->id == 1)
client->client_resource = resource;
this->info.change_mask = ~0; this->info.change_mask = ~0;
pw_client_resource_info(resource, &this->info); pw_client_resource_info(resource, &this->info);
this->info.change_mask = 0; this->info.change_mask = 0;

View file

@ -151,7 +151,11 @@ static const struct pw_resource_events resource_events = {
static int destroy_resource(void *object, void *data) static int destroy_resource(void *object, void *data)
{ {
struct pw_resource *resource = object; struct pw_resource *resource = object;
if (resource && resource != resource->client->core_resource) { struct pw_client *client = resource->client;
if (resource &&
resource != client->core_resource &&
resource != client->client_resource) {
resource->removed = true; resource->removed = true;
pw_resource_destroy(resource); pw_resource_destroy(resource);
} }
@ -363,6 +367,7 @@ static const struct pw_core_proxy_methods core_methods = {
static void core_unbind_func(void *data) static void core_unbind_func(void *data)
{ {
struct pw_resource *resource = data; struct pw_resource *resource = data;
if (resource->id == 0)
resource->client->core_resource = NULL; resource->client->core_resource = NULL;
spa_list_remove(&resource->link); spa_list_remove(&resource->link);
} }

View file

@ -96,7 +96,8 @@ struct pw_core_proxy_methods {
uint32_t version; uint32_t version;
/** /**
* Start a conversation with the server. This will send * Start a conversation with the server. This will send
* the core info.. * the core info and will destroy all resources for the client
* (except the core and client resource).
*/ */
int (*hello) (void *object, uint32_t version); int (*hello) (void *object, uint32_t version);
/** /**

View file

@ -112,6 +112,7 @@ struct pw_client {
struct pw_client_info info; /**< client info */ struct pw_client_info info; /**< client info */
struct pw_resource *core_resource; /**< core resource object */ struct pw_resource *core_resource; /**< core resource object */
struct pw_resource *client_resource; /**< client resource object */
struct pw_map objects; /**< list of resource objects */ struct pw_map objects; /**< list of resource objects */