mirror of
https://gitlab.freedesktop.org/pipewire/pipewire.git
synced 2025-12-18 08:56:45 -05:00
access: cleanups
Rename some callbacks Pass result in complete callback
This commit is contained in:
parent
34450ed7ed
commit
b5e60ad02a
3 changed files with 24 additions and 29 deletions
|
|
@ -124,8 +124,8 @@ add_pending(struct client_info *cinfo, const char *handle, struct pw_access_data
|
||||||
struct async_pending *p;
|
struct async_pending *p;
|
||||||
struct pw_access_data *ad;
|
struct pw_access_data *ad;
|
||||||
|
|
||||||
ad = access_data->async_copy(access_data, sizeof(struct async_pending));
|
ad = access_data->async_start(access_data, sizeof(struct async_pending));
|
||||||
ad->free_cb = free_pending;
|
ad->free = free_pending;
|
||||||
|
|
||||||
p = ad->user_data;
|
p = ad->user_data;
|
||||||
p->info = cinfo;
|
p->info = cinfo;
|
||||||
|
|
@ -142,8 +142,7 @@ static void client_info_free(struct client_info *cinfo)
|
||||||
struct async_pending *p, *tmp;
|
struct async_pending *p, *tmp;
|
||||||
|
|
||||||
spa_list_for_each_safe(p, tmp, &cinfo->async_pending, link) {
|
spa_list_for_each_safe(p, tmp, &cinfo->async_pending, link) {
|
||||||
p->access_data->res = SPA_RESULT_NO_PERMISSION;
|
p->access_data->complete(p->access_data, SPA_RESULT_NO_PERMISSION);
|
||||||
p->access_data->complete_cb(p->access_data);
|
|
||||||
}
|
}
|
||||||
spa_list_remove(&cinfo->link);
|
spa_list_remove(&cinfo->link);
|
||||||
free(cinfo);
|
free(cinfo);
|
||||||
|
|
@ -272,8 +271,7 @@ portal_response(DBusConnection *connection, DBusMessage *msg, void *user_data)
|
||||||
|
|
||||||
pw_log_debug("portal check result: %d", response);
|
pw_log_debug("portal check result: %d", response);
|
||||||
|
|
||||||
d->res = response == 0 ? SPA_RESULT_OK : SPA_RESULT_NO_PERMISSION;
|
d->complete(d, response == 0 ? SPA_RESULT_OK : SPA_RESULT_NO_PERMISSION);
|
||||||
d->complete_cb(d);
|
|
||||||
|
|
||||||
return DBUS_HANDLER_RESULT_HANDLED;
|
return DBUS_HANDLER_RESULT_HANDLED;
|
||||||
}
|
}
|
||||||
|
|
@ -298,13 +296,11 @@ do_create_node(struct pw_access *access,
|
||||||
const char *device;
|
const char *device;
|
||||||
|
|
||||||
if (!cinfo->is_sandboxed) {
|
if (!cinfo->is_sandboxed) {
|
||||||
data->res = SPA_RESULT_OK;
|
data->complete(data, SPA_RESULT_OK);
|
||||||
data->complete_cb(data);
|
|
||||||
return SPA_RESULT_OK;
|
return SPA_RESULT_OK;
|
||||||
}
|
}
|
||||||
if (strcmp(factory_name, "client-node") != 0) {
|
if (strcmp(factory_name, "client-node") != 0) {
|
||||||
data->res = SPA_RESULT_NO_PERMISSION;
|
data->complete(data, SPA_RESULT_NO_PERMISSION);
|
||||||
data->complete_cb(data);
|
|
||||||
return SPA_RESULT_NO_PERMISSION;
|
return SPA_RESULT_NO_PERMISSION;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -387,13 +383,14 @@ do_create_link(struct pw_access *access,
|
||||||
{
|
{
|
||||||
struct impl *impl = SPA_CONTAINER_OF(access, struct impl, access);
|
struct impl *impl = SPA_CONTAINER_OF(access, struct impl, access);
|
||||||
struct client_info *cinfo = find_client_info(impl, data->resource->client);
|
struct client_info *cinfo = find_client_info(impl, data->resource->client);
|
||||||
|
int res;
|
||||||
|
|
||||||
if (cinfo->is_sandboxed)
|
if (cinfo->is_sandboxed)
|
||||||
data->res = SPA_RESULT_NO_PERMISSION;
|
res = SPA_RESULT_NO_PERMISSION;
|
||||||
else
|
else
|
||||||
data->res = SPA_RESULT_OK;
|
res = SPA_RESULT_OK;
|
||||||
|
|
||||||
data->complete_cb(data);
|
data->complete(data, res);
|
||||||
return SPA_RESULT_OK;
|
return SPA_RESULT_OK;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -32,12 +32,11 @@ extern "C" {
|
||||||
#include <pipewire/server/resource.h>
|
#include <pipewire/server/resource.h>
|
||||||
|
|
||||||
struct pw_access_data {
|
struct pw_access_data {
|
||||||
int res;
|
|
||||||
struct pw_resource *resource;
|
struct pw_resource *resource;
|
||||||
|
|
||||||
void *(*async_copy) (struct pw_access_data *data, size_t size);
|
void *(*async_start) (struct pw_access_data *data, size_t size);
|
||||||
void (*complete_cb) (struct pw_access_data *data);
|
void (*complete) (struct pw_access_data *data, int res);
|
||||||
void (*free_cb) (struct pw_access_data *data);
|
void (*free) (struct pw_access_data *data);
|
||||||
void *user_data;
|
void *user_data;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -143,7 +143,7 @@ static void core_get_registry(void *object, uint32_t new_id)
|
||||||
resource->id, SPA_RESULT_NO_MEMORY, "no memory");
|
resource->id, SPA_RESULT_NO_MEMORY, "no memory");
|
||||||
}
|
}
|
||||||
|
|
||||||
static void *async_create_node_copy(struct pw_access_data *data, size_t size)
|
static void *async_create_node_start(struct pw_access_data *data, size_t size)
|
||||||
{
|
{
|
||||||
struct access_create_node *d;
|
struct access_create_node *d;
|
||||||
|
|
||||||
|
|
@ -163,22 +163,22 @@ static void async_create_node_free(struct pw_access_data *data)
|
||||||
if (d->properties)
|
if (d->properties)
|
||||||
pw_properties_free(d->properties);
|
pw_properties_free(d->properties);
|
||||||
if (d->async) {
|
if (d->async) {
|
||||||
if (d->data.free_cb)
|
if (d->data.free)
|
||||||
d->data.free_cb(&d->data);
|
d->data.free(&d->data);
|
||||||
free(d->factory_name);
|
free(d->factory_name);
|
||||||
free(d->name);
|
free(d->name);
|
||||||
free(d);
|
free(d);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
static void async_create_node_complete(struct pw_access_data *data)
|
static void async_create_node_complete(struct pw_access_data *data, int res)
|
||||||
{
|
{
|
||||||
struct access_create_node *d = (struct access_create_node *) data;
|
struct access_create_node *d = (struct access_create_node *) data;
|
||||||
struct pw_resource *resource = d->data.resource;
|
struct pw_resource *resource = d->data.resource;
|
||||||
struct pw_client *client = resource->client;
|
struct pw_client *client = resource->client;
|
||||||
struct pw_node_factory *factory;
|
struct pw_node_factory *factory;
|
||||||
|
|
||||||
if (data->res != SPA_RESULT_OK)
|
if (res != SPA_RESULT_OK)
|
||||||
goto denied;
|
goto denied;
|
||||||
|
|
||||||
factory = pw_core_find_node_factory(client->core, d->factory_name);
|
factory = pw_core_find_node_factory(client->core, d->factory_name);
|
||||||
|
|
@ -197,7 +197,7 @@ static void async_create_node_complete(struct pw_access_data *data)
|
||||||
resource->id, SPA_RESULT_INVALID_ARGUMENTS, "unknown factory name");
|
resource->id, SPA_RESULT_INVALID_ARGUMENTS, "unknown factory name");
|
||||||
goto done;
|
goto done;
|
||||||
denied:
|
denied:
|
||||||
pw_log_error("create node refused");
|
pw_log_error("create node refused %d", res);
|
||||||
pw_core_notify_error(client->core_resource,
|
pw_core_notify_error(client->core_resource,
|
||||||
resource->id, SPA_RESULT_NO_PERMISSION, "operation not allowed");
|
resource->id, SPA_RESULT_NO_PERMISSION, "operation not allowed");
|
||||||
done:
|
done:
|
||||||
|
|
@ -228,9 +228,9 @@ core_create_node(void *object,
|
||||||
}
|
}
|
||||||
|
|
||||||
access_data.data.resource = resource;
|
access_data.data.resource = resource;
|
||||||
access_data.data.async_copy = async_create_node_copy;
|
access_data.data.async_start = async_create_node_start;
|
||||||
access_data.data.complete_cb = async_create_node_complete;
|
access_data.data.complete = async_create_node_complete;
|
||||||
access_data.data.free_cb = NULL;
|
access_data.data.free = NULL;
|
||||||
access_data.factory_name = (char *) factory_name;
|
access_data.factory_name = (char *) factory_name;
|
||||||
access_data.name = (char *) name;
|
access_data.name = (char *) name;
|
||||||
access_data.properties = properties;
|
access_data.properties = properties;
|
||||||
|
|
@ -238,17 +238,16 @@ core_create_node(void *object,
|
||||||
access_data.async = false;
|
access_data.async = false;
|
||||||
|
|
||||||
if (client->core->access) {
|
if (client->core->access) {
|
||||||
access_data.data.res = SPA_RESULT_NO_PERMISSION;
|
|
||||||
res = client->core->access->create_node(client->core->access,
|
res = client->core->access->create_node(client->core->access,
|
||||||
&access_data.data,
|
&access_data.data,
|
||||||
factory_name,
|
factory_name,
|
||||||
name,
|
name,
|
||||||
properties);
|
properties);
|
||||||
} else {
|
} else {
|
||||||
res = access_data.data.res = SPA_RESULT_OK;
|
res = SPA_RESULT_OK;
|
||||||
}
|
}
|
||||||
if (!SPA_RESULT_IS_ASYNC(res))
|
if (!SPA_RESULT_IS_ASYNC(res))
|
||||||
async_create_node_complete(&access_data.data);
|
async_create_node_complete(&access_data.data, res);
|
||||||
return;
|
return;
|
||||||
|
|
||||||
no_mem:
|
no_mem:
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue