mirror of
https://gitlab.freedesktop.org/pipewire/pipewire.git
synced 2025-10-29 05:40:27 -04:00
improve debug
This commit is contained in:
parent
3ee9cbd57d
commit
a42c517682
17 changed files with 418 additions and 365 deletions
|
|
@ -1 +1 @@
|
||||||
Subproject commit f84821f82145c78bfa0700feffefffca58565fb0
|
Subproject commit 48f28f7b63658832f348b65511906eceb329b1ba
|
||||||
|
|
@ -31,6 +31,8 @@
|
||||||
#include "pipewire/resource.h"
|
#include "pipewire/resource.h"
|
||||||
#include "pipewire/type.h"
|
#include "pipewire/type.h"
|
||||||
|
|
||||||
|
#define NAME "client"
|
||||||
|
|
||||||
/** \cond */
|
/** \cond */
|
||||||
struct impl {
|
struct impl {
|
||||||
struct pw_client this;
|
struct pw_client this;
|
||||||
|
|
@ -206,7 +208,7 @@ global_bind(void *_data, struct pw_client *client, uint32_t permissions,
|
||||||
&data->object_listener,
|
&data->object_listener,
|
||||||
&client_methods, resource);
|
&client_methods, resource);
|
||||||
|
|
||||||
pw_log_debug("client %p: bound to %d", this, resource->id);
|
pw_log_debug(NAME" %p: bound to %d", this, resource->id);
|
||||||
|
|
||||||
spa_list_append(&global->resource_list, &resource->link);
|
spa_list_append(&global->resource_list, &resource->link);
|
||||||
|
|
||||||
|
|
@ -220,7 +222,7 @@ global_bind(void *_data, struct pw_client *client, uint32_t permissions,
|
||||||
return 0;
|
return 0;
|
||||||
|
|
||||||
error_resource:
|
error_resource:
|
||||||
pw_log_error("can't create client resource: %m");
|
pw_log_error(NAME" %p: can't create client resource: %m", this);
|
||||||
return -errno;
|
return -errno;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -229,7 +231,7 @@ static void pool_added(void *data, struct pw_memblock *block)
|
||||||
struct impl *impl = data;
|
struct impl *impl = data;
|
||||||
struct pw_client *client = &impl->this;
|
struct pw_client *client = &impl->this;
|
||||||
|
|
||||||
pw_log_debug("client %p: added block %d", client, block->id);
|
pw_log_debug(NAME" %p: added block %d", client, block->id);
|
||||||
if (client->core_resource) {
|
if (client->core_resource) {
|
||||||
pw_core_resource_add_mem(client->core_resource,
|
pw_core_resource_add_mem(client->core_resource,
|
||||||
block->id, block->type, block->fd,
|
block->id, block->type, block->fd,
|
||||||
|
|
@ -241,7 +243,7 @@ static void pool_removed(void *data, struct pw_memblock *block)
|
||||||
{
|
{
|
||||||
struct impl *impl = data;
|
struct impl *impl = data;
|
||||||
struct pw_client *client = &impl->this;
|
struct pw_client *client = &impl->this;
|
||||||
pw_log_debug("client %p: removed block %d", client, block->id);
|
pw_log_debug(NAME" %p: removed block %d", client, block->id);
|
||||||
if (client->core_resource)
|
if (client->core_resource)
|
||||||
pw_core_resource_remove_mem(client->core_resource, block->id);
|
pw_core_resource_remove_mem(client->core_resource, block->id);
|
||||||
}
|
}
|
||||||
|
|
@ -260,7 +262,7 @@ core_global_removed(void *data, struct pw_global *global)
|
||||||
struct pw_permission *p;
|
struct pw_permission *p;
|
||||||
|
|
||||||
p = find_permission(client, global->id);
|
p = find_permission(client, global->id);
|
||||||
pw_log_debug("client %p: global %d removed, %p", client, global->id, p);
|
pw_log_debug(NAME" %p: global %d removed, %p", client, global->id, p);
|
||||||
if (p->id != SPA_ID_INVALID)
|
if (p->id != SPA_ID_INVALID)
|
||||||
p->permissions = SPA_ID_INVALID;
|
p->permissions = SPA_ID_INVALID;
|
||||||
}
|
}
|
||||||
|
|
@ -296,7 +298,7 @@ struct pw_client *pw_client_new(struct pw_core *core,
|
||||||
}
|
}
|
||||||
|
|
||||||
this = &impl->this;
|
this = &impl->this;
|
||||||
pw_log_debug("client %p: new", this);
|
pw_log_debug(NAME" %p: new", this);
|
||||||
|
|
||||||
this->core = core;
|
this->core = core;
|
||||||
|
|
||||||
|
|
@ -377,7 +379,7 @@ int pw_client_register(struct pw_client *client,
|
||||||
if (client->registered)
|
if (client->registered)
|
||||||
goto error_existed;
|
goto error_existed;
|
||||||
|
|
||||||
pw_log_debug("client %p: register parent %d", client, parent ? parent->id : SPA_ID_INVALID);
|
pw_log_debug(NAME" %p: register parent %d", client, parent ? parent->id : SPA_ID_INVALID);
|
||||||
|
|
||||||
client->global = pw_global_new(core,
|
client->global = pw_global_new(core,
|
||||||
PW_TYPE_INTERFACE_Client,
|
PW_TYPE_INTERFACE_Client,
|
||||||
|
|
@ -458,7 +460,7 @@ void pw_client_destroy(struct pw_client *client)
|
||||||
{
|
{
|
||||||
struct impl *impl = SPA_CONTAINER_OF(client, struct impl, this);
|
struct impl *impl = SPA_CONTAINER_OF(client, struct impl, this);
|
||||||
|
|
||||||
pw_log_debug("client %p: destroy", client);
|
pw_log_debug(NAME" %p: destroy", client);
|
||||||
pw_client_emit_destroy(client);
|
pw_client_emit_destroy(client);
|
||||||
|
|
||||||
spa_hook_remove(&impl->core_listener);
|
spa_hook_remove(&impl->core_listener);
|
||||||
|
|
@ -473,7 +475,7 @@ void pw_client_destroy(struct pw_client *client)
|
||||||
pw_global_destroy(client->global);
|
pw_global_destroy(client->global);
|
||||||
}
|
}
|
||||||
|
|
||||||
pw_log_debug("client %p: free", impl);
|
pw_log_debug(NAME" %p: free", impl);
|
||||||
pw_client_emit_free(client);
|
pw_client_emit_free(client);
|
||||||
|
|
||||||
pw_map_clear(&client->objects);
|
pw_map_clear(&client->objects);
|
||||||
|
|
@ -519,7 +521,7 @@ int pw_client_update_properties(struct pw_client *client, const struct spa_dict
|
||||||
|
|
||||||
changed = pw_properties_update(client->properties, dict);
|
changed = pw_properties_update(client->properties, dict);
|
||||||
|
|
||||||
pw_log_debug("client %p: updated %d properties", client, changed);
|
pw_log_debug(NAME" %p: updated %d properties", client, changed);
|
||||||
|
|
||||||
if (!changed)
|
if (!changed)
|
||||||
return 0;
|
return 0;
|
||||||
|
|
@ -561,7 +563,7 @@ int pw_client_update_permissions(struct pw_client *client,
|
||||||
if (core->current_client == client)
|
if (core->current_client == client)
|
||||||
new_perm &= old_perm;
|
new_perm &= old_perm;
|
||||||
|
|
||||||
pw_log_debug("client %p: set default permissions %08x -> %08x",
|
pw_log_debug(NAME" %p: set default permissions %08x -> %08x",
|
||||||
client, old_perm, new_perm);
|
client, old_perm, new_perm);
|
||||||
|
|
||||||
def->permissions = new_perm;
|
def->permissions = new_perm;
|
||||||
|
|
@ -578,12 +580,12 @@ int pw_client_update_permissions(struct pw_client *client,
|
||||||
|
|
||||||
global = pw_core_find_global(client->core, permissions[i].id);
|
global = pw_core_find_global(client->core, permissions[i].id);
|
||||||
if (global == NULL || global->id != permissions[i].id) {
|
if (global == NULL || global->id != permissions[i].id) {
|
||||||
pw_log_warn("client %p: invalid global %d", client, permissions[i].id);
|
pw_log_warn(NAME" %p: invalid global %d", client, permissions[i].id);
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
p = ensure_permissions(client, permissions[i].id);
|
p = ensure_permissions(client, permissions[i].id);
|
||||||
if (p == NULL) {
|
if (p == NULL) {
|
||||||
pw_log_warn("client %p: can't ensure permission: %m", client);
|
pw_log_warn(NAME" %p: can't ensure permission: %m", client);
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
old_perm = p->permissions == SPA_ID_INVALID ? def->permissions : p->permissions;
|
old_perm = p->permissions == SPA_ID_INVALID ? def->permissions : p->permissions;
|
||||||
|
|
@ -592,7 +594,7 @@ int pw_client_update_permissions(struct pw_client *client,
|
||||||
if (core->current_client == client)
|
if (core->current_client == client)
|
||||||
new_perm &= old_perm;
|
new_perm &= old_perm;
|
||||||
|
|
||||||
pw_log_debug("client %p: set global %d permissions %08x -> %08x",
|
pw_log_debug(NAME" %p: set global %d permissions %08x -> %08x",
|
||||||
client, global->id, old_perm, new_perm);
|
client, global->id, old_perm, new_perm);
|
||||||
|
|
||||||
p->permissions = new_perm;
|
p->permissions = new_perm;
|
||||||
|
|
@ -609,7 +611,7 @@ SPA_EXPORT
|
||||||
void pw_client_set_busy(struct pw_client *client, bool busy)
|
void pw_client_set_busy(struct pw_client *client, bool busy)
|
||||||
{
|
{
|
||||||
if (client->busy != busy) {
|
if (client->busy != busy) {
|
||||||
pw_log_debug("client %p: busy %d", client, busy);
|
pw_log_debug(NAME" %p: busy %d", client, busy);
|
||||||
client->busy = busy;
|
client->busy = busy;
|
||||||
pw_client_emit_busy_changed(client, busy);
|
pw_client_emit_busy_changed(client, busy);
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -28,6 +28,8 @@
|
||||||
#include <pipewire/control.h>
|
#include <pipewire/control.h>
|
||||||
#include <pipewire/private.h>
|
#include <pipewire/private.h>
|
||||||
|
|
||||||
|
#define NAME "control"
|
||||||
|
|
||||||
struct impl {
|
struct impl {
|
||||||
struct pw_control this;
|
struct pw_control this;
|
||||||
|
|
||||||
|
|
@ -64,7 +66,7 @@ pw_control_new(struct pw_core *core,
|
||||||
this->id = id;
|
this->id = id;
|
||||||
this->size = size;
|
this->size = size;
|
||||||
|
|
||||||
pw_log_debug("control %p: new %s %d", this,
|
pw_log_debug(NAME" %p: new %s %d", this,
|
||||||
spa_debug_type_find_name(spa_type_io, this->id), direction);
|
spa_debug_type_find_name(spa_type_io, this->id), direction);
|
||||||
|
|
||||||
this->core = core;
|
this->core = core;
|
||||||
|
|
@ -94,7 +96,7 @@ void pw_control_destroy(struct pw_control *control)
|
||||||
struct impl *impl = SPA_CONTAINER_OF(control, struct impl, this);
|
struct impl *impl = SPA_CONTAINER_OF(control, struct impl, this);
|
||||||
struct pw_control_link *link;
|
struct pw_control_link *link;
|
||||||
|
|
||||||
pw_log_debug("control %p: destroy", control);
|
pw_log_debug(NAME" %p: destroy", control);
|
||||||
|
|
||||||
pw_control_emit_destroy(control);
|
pw_control_emit_destroy(control);
|
||||||
|
|
||||||
|
|
@ -114,7 +116,7 @@ void pw_control_destroy(struct pw_control *control)
|
||||||
pw_port_emit_control_removed(control->port, control);
|
pw_port_emit_control_removed(control->port, control);
|
||||||
}
|
}
|
||||||
|
|
||||||
pw_log_debug("control %p: free", control);
|
pw_log_debug(NAME" %p: free", control);
|
||||||
pw_control_emit_free(control);
|
pw_control_emit_free(control);
|
||||||
|
|
||||||
if (control->direction == SPA_DIRECTION_OUTPUT) {
|
if (control->direction == SPA_DIRECTION_OUTPUT) {
|
||||||
|
|
@ -177,7 +179,7 @@ int pw_control_add_link(struct pw_control *control, uint32_t cmix,
|
||||||
|
|
||||||
impl = SPA_CONTAINER_OF(control, struct impl, this);
|
impl = SPA_CONTAINER_OF(control, struct impl, this);
|
||||||
|
|
||||||
pw_log_debug("control %p: link to %p %s", control, other,
|
pw_log_debug(NAME" %p: link to %p %s", control, other,
|
||||||
spa_debug_type_find_name(spa_type_io, control->id));
|
spa_debug_type_find_name(spa_type_io, control->id));
|
||||||
|
|
||||||
size = SPA_MAX(control->size, other->size);
|
size = SPA_MAX(control->size, other->size);
|
||||||
|
|
@ -199,7 +201,7 @@ int pw_control_add_link(struct pw_control *control, uint32_t cmix,
|
||||||
if ((res = port_set_io(control->port, cmix,
|
if ((res = port_set_io(control->port, cmix,
|
||||||
control->id,
|
control->id,
|
||||||
impl->mem->map->ptr, size)) < 0) {
|
impl->mem->map->ptr, size)) < 0) {
|
||||||
pw_log_warn("control %p: set io failed %d %s", control,
|
pw_log_warn(NAME" %p: set io failed %d %s", control,
|
||||||
res, spa_strerror(res));
|
res, spa_strerror(res));
|
||||||
goto exit;
|
goto exit;
|
||||||
}
|
}
|
||||||
|
|
@ -209,7 +211,7 @@ int pw_control_add_link(struct pw_control *control, uint32_t cmix,
|
||||||
if (other->port) {
|
if (other->port) {
|
||||||
if ((res = port_set_io(other->port, omix,
|
if ((res = port_set_io(other->port, omix,
|
||||||
other->id, impl->mem->map->ptr, size)) < 0) {
|
other->id, impl->mem->map->ptr, size)) < 0) {
|
||||||
pw_log_warn("control %p: set io failed %d %s", control,
|
pw_log_warn(NAME" %p: set io failed %d %s", control,
|
||||||
res, spa_strerror(res));
|
res, spa_strerror(res));
|
||||||
goto exit;
|
goto exit;
|
||||||
}
|
}
|
||||||
|
|
@ -236,7 +238,7 @@ int pw_control_remove_link(struct pw_control_link *link)
|
||||||
struct pw_control *output = link->output;
|
struct pw_control *output = link->output;
|
||||||
struct pw_control *input = link->input;
|
struct pw_control *input = link->input;
|
||||||
|
|
||||||
pw_log_debug("control %p: unlink from %p", output, input);
|
pw_log_debug(NAME" %p: unlink from %p", output, input);
|
||||||
|
|
||||||
spa_list_remove(&link->in_link);
|
spa_list_remove(&link->in_link);
|
||||||
spa_list_remove(&link->out_link);
|
spa_list_remove(&link->out_link);
|
||||||
|
|
@ -245,14 +247,14 @@ int pw_control_remove_link(struct pw_control_link *link)
|
||||||
if (spa_list_is_empty(&output->links)) {
|
if (spa_list_is_empty(&output->links)) {
|
||||||
if ((res = port_set_io(output->port, link->out_port,
|
if ((res = port_set_io(output->port, link->out_port,
|
||||||
output->id, NULL, 0)) < 0) {
|
output->id, NULL, 0)) < 0) {
|
||||||
pw_log_warn("control %p: can't unset port control io", output);
|
pw_log_warn(NAME" %p: can't unset port control io", output);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (input->port) {
|
if (input->port) {
|
||||||
if ((res = port_set_io(input->port, link->in_port,
|
if ((res = port_set_io(input->port, link->in_port,
|
||||||
input->id, NULL, 0)) < 0) {
|
input->id, NULL, 0)) < 0) {
|
||||||
pw_log_warn("control %p: can't unset port control io", output);
|
pw_log_warn(NAME" %p: can't unset port control io", output);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -47,6 +47,8 @@
|
||||||
#include <pipewire/module.h>
|
#include <pipewire/module.h>
|
||||||
#include <pipewire/version.h>
|
#include <pipewire/version.h>
|
||||||
|
|
||||||
|
#define NAME "core"
|
||||||
|
|
||||||
/** \cond */
|
/** \cond */
|
||||||
struct impl {
|
struct impl {
|
||||||
struct pw_core this;
|
struct pw_core this;
|
||||||
|
|
@ -184,7 +186,7 @@ static int core_hello(void *object, uint32_t version)
|
||||||
struct pw_client *client = resource->client;
|
struct pw_client *client = resource->client;
|
||||||
struct pw_core *this = resource->core;
|
struct pw_core *this = resource->core;
|
||||||
|
|
||||||
pw_log_debug("core %p: hello %d from resource %p", this, version, resource);
|
pw_log_debug(NAME" %p: hello %d from resource %p", this, version, resource);
|
||||||
this->info.change_mask = PW_CORE_CHANGE_MASK_ALL;
|
this->info.change_mask = PW_CORE_CHANGE_MASK_ALL;
|
||||||
pw_map_for_each(&client->objects, destroy_resource, client);
|
pw_map_for_each(&client->objects, destroy_resource, client);
|
||||||
pw_core_resource_info(resource, &this->info);
|
pw_core_resource_info(resource, &this->info);
|
||||||
|
|
@ -194,7 +196,7 @@ static int core_hello(void *object, uint32_t version)
|
||||||
static int core_sync(void *object, uint32_t id, int seq)
|
static int core_sync(void *object, uint32_t id, int seq)
|
||||||
{
|
{
|
||||||
struct pw_resource *resource = object;
|
struct pw_resource *resource = object;
|
||||||
pw_log_debug("core %p: sync %d for resource %d", resource->core, seq, id);
|
pw_log_debug(NAME" %p: sync %d for resource %d", resource->core, seq, id);
|
||||||
pw_core_resource_done(resource, id, seq);
|
pw_core_resource_done(resource, id, seq);
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
@ -205,7 +207,7 @@ static int core_pong(void *object, uint32_t id, int seq)
|
||||||
struct pw_client *client = resource->client;
|
struct pw_client *client = resource->client;
|
||||||
struct pw_resource *r;
|
struct pw_resource *r;
|
||||||
|
|
||||||
pw_log_debug("core %p: pong %d for resource %d", resource->core, seq, id);
|
pw_log_debug(NAME" %p: pong %d for resource %d", resource->core, seq, id);
|
||||||
|
|
||||||
if ((r = pw_client_find_resource(client, id)) == NULL)
|
if ((r = pw_client_find_resource(client, id)) == NULL)
|
||||||
return -EINVAL;
|
return -EINVAL;
|
||||||
|
|
@ -220,7 +222,7 @@ static int core_error(void *object, uint32_t id, int seq, int res, const char *m
|
||||||
struct pw_client *client = resource->client;
|
struct pw_client *client = resource->client;
|
||||||
struct pw_resource *r;
|
struct pw_resource *r;
|
||||||
|
|
||||||
pw_log_debug("core %p: error %d for resource %d: %s", resource->core, res, id, message);
|
pw_log_debug(NAME" %p: error %d for resource %d: %s", resource->core, res, id, message);
|
||||||
|
|
||||||
if ((r = pw_client_find_resource(client, id)) == NULL)
|
if ((r = pw_client_find_resource(client, id)) == NULL)
|
||||||
return -EINVAL;
|
return -EINVAL;
|
||||||
|
|
@ -280,7 +282,7 @@ static struct pw_registry_proxy * core_get_registry(void *object, uint32_t versi
|
||||||
return (struct pw_registry_proxy *)registry_resource;
|
return (struct pw_registry_proxy *)registry_resource;
|
||||||
|
|
||||||
error_resource:
|
error_resource:
|
||||||
pw_log_error("can't create registry resource: %m");
|
pw_log_error(NAME" %p: can't create registry resource: %m", this);
|
||||||
pw_core_resource_errorf(client->core_resource, new_id,
|
pw_core_resource_errorf(client->core_resource, new_id,
|
||||||
client->recv_seq, res,
|
client->recv_seq, res,
|
||||||
"can't create registry resource: %s", spa_strerror(res));
|
"can't create registry resource: %s", spa_strerror(res));
|
||||||
|
|
@ -303,10 +305,11 @@ core_create_object(void *object,
|
||||||
struct pw_factory *factory;
|
struct pw_factory *factory;
|
||||||
void *obj;
|
void *obj;
|
||||||
struct pw_properties *properties;
|
struct pw_properties *properties;
|
||||||
|
struct pw_core *this = client->core;
|
||||||
uint32_t new_id = user_data_size;
|
uint32_t new_id = user_data_size;
|
||||||
int res;
|
int res;
|
||||||
|
|
||||||
factory = pw_core_find_factory(client->core, factory_name);
|
factory = pw_core_find_factory(this, factory_name);
|
||||||
if (factory == NULL || factory->global == NULL)
|
if (factory == NULL || factory->global == NULL)
|
||||||
goto error_no_factory;
|
goto error_no_factory;
|
||||||
|
|
||||||
|
|
@ -335,18 +338,18 @@ core_create_object(void *object,
|
||||||
|
|
||||||
error_no_factory:
|
error_no_factory:
|
||||||
res = -ENOENT;
|
res = -ENOENT;
|
||||||
pw_log_error("can't find factory '%s'", factory_name);
|
pw_log_error(NAME" %p: can't find factory '%s'", this, factory_name);
|
||||||
pw_resource_error(resource, res, "unknown factory name %s", factory_name);
|
pw_resource_error(resource, res, "unknown factory name %s", factory_name);
|
||||||
goto error_exit;
|
goto error_exit;
|
||||||
error_version:
|
error_version:
|
||||||
error_type:
|
error_type:
|
||||||
res = -EPROTO;
|
res = -EPROTO;
|
||||||
pw_log_error("invalid resource type/version");
|
pw_log_error(NAME" %p: invalid resource type/version", this);
|
||||||
pw_resource_error(resource, res, "wrong resource type/version");
|
pw_resource_error(resource, res, "wrong resource type/version");
|
||||||
goto error_exit;
|
goto error_exit;
|
||||||
error_properties:
|
error_properties:
|
||||||
res = -errno;
|
res = -errno;
|
||||||
pw_log_error("can't create properties: %m");
|
pw_log_error(NAME" %p: can't create properties: %m", this);
|
||||||
pw_resource_error(resource, res, "can't create properties: %s", spa_strerror(res));
|
pw_resource_error(resource, res, "can't create properties: %s", spa_strerror(res));
|
||||||
goto error_exit;
|
goto error_exit;
|
||||||
error_create_failed:
|
error_create_failed:
|
||||||
|
|
@ -364,7 +367,7 @@ static int core_destroy(void *object, void *proxy)
|
||||||
struct pw_resource *resource = object;
|
struct pw_resource *resource = object;
|
||||||
struct pw_client *client = resource->client;
|
struct pw_client *client = resource->client;
|
||||||
struct pw_resource *r = proxy;
|
struct pw_resource *r = proxy;
|
||||||
pw_log_debug("core %p: destroy resource %p from client %p", resource->core, r, client);
|
pw_log_debug(NAME" %p: destroy resource %p from client %p", resource->core, r, client);
|
||||||
pw_resource_destroy(r);
|
pw_resource_destroy(r);
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
@ -429,12 +432,12 @@ global_bind(void *_data,
|
||||||
else
|
else
|
||||||
pw_core_resource_info(resource, &this->info);
|
pw_core_resource_info(resource, &this->info);
|
||||||
|
|
||||||
pw_log_debug("core %p: bound to %d", this, resource->id);
|
pw_log_debug(NAME" %p: bound to %d", this, resource->id);
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
|
|
||||||
error:
|
error:
|
||||||
pw_log_error("core %p: can't create resource: %m", this);
|
pw_log_error(NAME" %p: can't create resource: %m", this);
|
||||||
return res;
|
return res;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -480,7 +483,7 @@ struct pw_core *pw_core_new(struct pw_loop *main_loop,
|
||||||
|
|
||||||
this = &impl->this;
|
this = &impl->this;
|
||||||
|
|
||||||
pw_log_debug("core %p: new", this);
|
pw_log_debug(NAME" %p: new", this);
|
||||||
|
|
||||||
if (user_data_size > 0)
|
if (user_data_size > 0)
|
||||||
this->user_data = SPA_MEMBER(impl, sizeof(struct impl), void);
|
this->user_data = SPA_MEMBER(impl, sizeof(struct impl), void);
|
||||||
|
|
@ -528,7 +531,7 @@ struct pw_core *pw_core_new(struct pw_loop *main_loop,
|
||||||
if (impl->dbus_handle == NULL ||
|
if (impl->dbus_handle == NULL ||
|
||||||
(res = spa_handle_get_interface(impl->dbus_handle,
|
(res = spa_handle_get_interface(impl->dbus_handle,
|
||||||
SPA_TYPE_INTERFACE_DBus, &dbus_iface)) < 0) {
|
SPA_TYPE_INTERFACE_DBus, &dbus_iface)) < 0) {
|
||||||
pw_log_warn("can't load dbus interface: %s", spa_strerror(res));
|
pw_log_warn(NAME" %p: can't load dbus interface: %s", this, spa_strerror(res));
|
||||||
} else {
|
} else {
|
||||||
this->support[n_support++] = SPA_SUPPORT_INIT(SPA_TYPE_INTERFACE_DBus, dbus_iface);
|
this->support[n_support++] = SPA_SUPPORT_INIT(SPA_TYPE_INTERFACE_DBus, dbus_iface);
|
||||||
}
|
}
|
||||||
|
|
@ -626,7 +629,7 @@ void pw_core_destroy(struct pw_core *core)
|
||||||
struct pw_node *node;
|
struct pw_node *node;
|
||||||
struct factory_entry *entry;
|
struct factory_entry *entry;
|
||||||
|
|
||||||
pw_log_debug("core %p: destroy", core);
|
pw_log_debug(NAME" %p: destroy", core);
|
||||||
pw_core_emit_destroy(core);
|
pw_core_emit_destroy(core);
|
||||||
|
|
||||||
spa_hook_remove(&core->global_listener);
|
spa_hook_remove(&core->global_listener);
|
||||||
|
|
@ -649,7 +652,7 @@ void pw_core_destroy(struct pw_core *core)
|
||||||
spa_list_consume(global, &core->global_list, link)
|
spa_list_consume(global, &core->global_list, link)
|
||||||
pw_global_destroy(global);
|
pw_global_destroy(global);
|
||||||
|
|
||||||
pw_log_debug("core %p: free", core);
|
pw_log_debug(NAME" %p: free", core);
|
||||||
pw_core_emit_free(core);
|
pw_core_emit_free(core);
|
||||||
|
|
||||||
pw_mempool_destroy(core->pool);
|
pw_mempool_destroy(core->pool);
|
||||||
|
|
@ -735,7 +738,7 @@ int pw_core_update_properties(struct pw_core *core, const struct spa_dict *dict)
|
||||||
|
|
||||||
changed = pw_properties_update(core->properties, dict);
|
changed = pw_properties_update(core->properties, dict);
|
||||||
|
|
||||||
pw_log_debug("core %p: updated %d properties", core, changed);
|
pw_log_debug(NAME" %p: updated %d properties", core, changed);
|
||||||
|
|
||||||
if (!changed)
|
if (!changed)
|
||||||
return 0;
|
return 0;
|
||||||
|
|
@ -818,7 +821,7 @@ struct pw_port *pw_core_find_port(struct pw_core *core,
|
||||||
|
|
||||||
have_id = id != SPA_ID_INVALID;
|
have_id = id != SPA_ID_INVALID;
|
||||||
|
|
||||||
pw_log_debug("id \"%u\", %d", id, have_id);
|
pw_log_debug(NAME" %p: id:%u", core, id);
|
||||||
|
|
||||||
spa_list_for_each(n, &core->node_list, link) {
|
spa_list_for_each(n, &core->node_list, link) {
|
||||||
if (n->global == NULL)
|
if (n->global == NULL)
|
||||||
|
|
@ -831,11 +834,11 @@ struct pw_port *pw_core_find_port(struct pw_core *core,
|
||||||
!PW_PERM_IS_R(pw_global_get_permissions(n->global, core->current_client)))
|
!PW_PERM_IS_R(pw_global_get_permissions(n->global, core->current_client)))
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
pw_log_debug("node id \"%d\"", n->global->id);
|
pw_log_debug(NAME" %p: node id:%d", core, n->global->id);
|
||||||
|
|
||||||
if (have_id) {
|
if (have_id) {
|
||||||
if (n->global->id == id) {
|
if (n->global->id == id) {
|
||||||
pw_log_debug("id \"%u\" matches node %p", id, n);
|
pw_log_debug(NAME" %p: id:%u matches node %p", core, id, n);
|
||||||
|
|
||||||
best =
|
best =
|
||||||
pw_node_find_port(n,
|
pw_node_find_port(n,
|
||||||
|
|
@ -922,7 +925,7 @@ int pw_core_find_format(struct pw_core *core,
|
||||||
out_state = output->state;
|
out_state = output->state;
|
||||||
in_state = input->state;
|
in_state = input->state;
|
||||||
|
|
||||||
pw_log_debug("core %p: finding best format %d %d", core, out_state, in_state);
|
pw_log_debug(NAME" %p: finding best format %d %d", core, out_state, in_state);
|
||||||
|
|
||||||
/* when a port is configured but the node is idle, we can reconfigure with a different format */
|
/* when a port is configured but the node is idle, we can reconfigure with a different format */
|
||||||
if (out_state > PW_PORT_STATE_CONFIGURE && output->node->info.state == PW_NODE_STATE_IDLE)
|
if (out_state > PW_PORT_STATE_CONFIGURE && output->node->info.state == PW_NODE_STATE_IDLE)
|
||||||
|
|
@ -930,7 +933,7 @@ int pw_core_find_format(struct pw_core *core,
|
||||||
if (in_state > PW_PORT_STATE_CONFIGURE && input->node->info.state == PW_NODE_STATE_IDLE)
|
if (in_state > PW_PORT_STATE_CONFIGURE && input->node->info.state == PW_NODE_STATE_IDLE)
|
||||||
in_state = PW_PORT_STATE_CONFIGURE;
|
in_state = PW_PORT_STATE_CONFIGURE;
|
||||||
|
|
||||||
pw_log_debug("core %p: states %d %d", core, out_state, in_state);
|
pw_log_debug(NAME" %p: states %d %d", core, out_state, in_state);
|
||||||
|
|
||||||
if (in_state == PW_PORT_STATE_CONFIGURE && out_state > PW_PORT_STATE_CONFIGURE) {
|
if (in_state == PW_PORT_STATE_CONFIGURE && out_state > PW_PORT_STATE_CONFIGURE) {
|
||||||
/* only input needs format */
|
/* only input needs format */
|
||||||
|
|
@ -942,7 +945,7 @@ int pw_core_find_format(struct pw_core *core,
|
||||||
asprintf(error, "error get output format: %d", res);
|
asprintf(error, "error get output format: %d", res);
|
||||||
goto error;
|
goto error;
|
||||||
}
|
}
|
||||||
pw_log_debug("Got output format:");
|
pw_log_debug(NAME" %p: Got output format:", core);
|
||||||
if (pw_log_level_enabled(SPA_LOG_LEVEL_DEBUG))
|
if (pw_log_level_enabled(SPA_LOG_LEVEL_DEBUG))
|
||||||
spa_debug_format(2, NULL, filter);
|
spa_debug_format(2, NULL, filter);
|
||||||
|
|
||||||
|
|
@ -963,7 +966,7 @@ int pw_core_find_format(struct pw_core *core,
|
||||||
asprintf(error, "error get input format: %d", res);
|
asprintf(error, "error get input format: %d", res);
|
||||||
goto error;
|
goto error;
|
||||||
}
|
}
|
||||||
pw_log_debug("Got input format:");
|
pw_log_debug(NAME" %p: Got input format:", core);
|
||||||
if (pw_log_level_enabled(SPA_LOG_LEVEL_DEBUG))
|
if (pw_log_level_enabled(SPA_LOG_LEVEL_DEBUG))
|
||||||
spa_debug_format(2, NULL, filter);
|
spa_debug_format(2, NULL, filter);
|
||||||
|
|
||||||
|
|
@ -977,7 +980,7 @@ int pw_core_find_format(struct pw_core *core,
|
||||||
} else if (in_state == PW_PORT_STATE_CONFIGURE && out_state == PW_PORT_STATE_CONFIGURE) {
|
} else if (in_state == PW_PORT_STATE_CONFIGURE && out_state == PW_PORT_STATE_CONFIGURE) {
|
||||||
again:
|
again:
|
||||||
/* both ports need a format */
|
/* both ports need a format */
|
||||||
pw_log_debug("core %p: do enum input %d", core, iidx);
|
pw_log_debug(NAME" %p: do enum input %d", core, iidx);
|
||||||
spa_pod_builder_init(&fb, fbuf, sizeof(fbuf));
|
spa_pod_builder_init(&fb, fbuf, sizeof(fbuf));
|
||||||
if ((res = spa_node_port_enum_params_sync(input->node->node,
|
if ((res = spa_node_port_enum_params_sync(input->node->node,
|
||||||
input->direction, input->port_id,
|
input->direction, input->port_id,
|
||||||
|
|
@ -990,7 +993,7 @@ int pw_core_find_format(struct pw_core *core,
|
||||||
asprintf(error, "no more input formats");
|
asprintf(error, "no more input formats");
|
||||||
goto error;
|
goto error;
|
||||||
}
|
}
|
||||||
pw_log_debug("enum output %d with filter: %p", oidx, filter);
|
pw_log_debug(NAME" %p: enum output %d with filter: %p", core, oidx, filter);
|
||||||
if (pw_log_level_enabled(SPA_LOG_LEVEL_DEBUG))
|
if (pw_log_level_enabled(SPA_LOG_LEVEL_DEBUG))
|
||||||
spa_debug_format(2, NULL, filter);
|
spa_debug_format(2, NULL, filter);
|
||||||
|
|
||||||
|
|
@ -1006,7 +1009,7 @@ int pw_core_find_format(struct pw_core *core,
|
||||||
goto error;
|
goto error;
|
||||||
}
|
}
|
||||||
|
|
||||||
pw_log_debug("Got filtered:");
|
pw_log_debug(NAME" %p: Got filtered:", core);
|
||||||
if (pw_log_level_enabled(SPA_LOG_LEVEL_DEBUG))
|
if (pw_log_level_enabled(SPA_LOG_LEVEL_DEBUG))
|
||||||
spa_debug_format(2, NULL, *format);
|
spa_debug_format(2, NULL, *format);
|
||||||
} else {
|
} else {
|
||||||
|
|
@ -1109,7 +1112,8 @@ int pw_core_recalc_graph(struct pw_core *core)
|
||||||
|
|
||||||
spa_list_for_each(n, &core->node_list, link) {
|
spa_list_for_each(n, &core->node_list, link) {
|
||||||
if (!n->visited) {
|
if (!n->visited) {
|
||||||
pw_log_info("unassigned node %p: '%s' %d", n, n->info.name, n->active);
|
pw_log_info(NAME" %p: unassigned node %p: '%s' %d", core,
|
||||||
|
n, n->info.name, n->active);
|
||||||
pw_node_set_driver(n, NULL);
|
pw_node_set_driver(n, NULL);
|
||||||
}
|
}
|
||||||
n->visited = false;
|
n->visited = false;
|
||||||
|
|
@ -1118,10 +1122,11 @@ int pw_core_recalc_graph(struct pw_core *core)
|
||||||
spa_list_for_each(n, &core->driver_list, driver_link) {
|
spa_list_for_each(n, &core->driver_list, driver_link) {
|
||||||
if (!n->master)
|
if (!n->master)
|
||||||
continue;
|
continue;
|
||||||
pw_log_info("master %p: quantum:%d '%s'", n,
|
pw_log_info(NAME" %p: master %p quantum:%d '%s'", core, n,
|
||||||
n->rt.position ? n->rt.position->size : 0, n->info.name);
|
n->rt.position ? n->rt.position->size : 0, n->info.name);
|
||||||
spa_list_for_each(s, &n->slave_list, slave_link)
|
spa_list_for_each(s, &n->slave_list, slave_link)
|
||||||
pw_log_info("slave %p: active:%d '%s'", s, s->active, s->info.name);
|
pw_log_info(NAME" %p: slave %p: active:%d '%s'",
|
||||||
|
core, s, s->active, s->info.name);
|
||||||
}
|
}
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
@ -1140,13 +1145,13 @@ int pw_core_add_spa_lib(struct pw_core *core,
|
||||||
if ((err = regcomp(&entry->regex, factory_regexp, REG_EXTENDED | REG_NOSUB)) != 0) {
|
if ((err = regcomp(&entry->regex, factory_regexp, REG_EXTENDED | REG_NOSUB)) != 0) {
|
||||||
char errbuf[1024];
|
char errbuf[1024];
|
||||||
regerror(err, &entry->regex, errbuf, sizeof(errbuf));
|
regerror(err, &entry->regex, errbuf, sizeof(errbuf));
|
||||||
pw_log_error("can compile regex: %s", errbuf);
|
pw_log_error(NAME" %p: can compile regex: %s", core, errbuf);
|
||||||
pw_array_remove(&core->factory_lib, entry);
|
pw_array_remove(&core->factory_lib, entry);
|
||||||
return -EINVAL;
|
return -EINVAL;
|
||||||
}
|
}
|
||||||
|
|
||||||
entry->lib = strdup(lib);
|
entry->lib = strdup(lib);
|
||||||
pw_log_debug("core %p: map factory regex '%s' to '%s", core,
|
pw_log_debug(NAME" %p: map factory regex '%s' to '%s", core,
|
||||||
factory_regexp, lib);
|
factory_regexp, lib);
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
@ -1173,13 +1178,13 @@ struct spa_handle *pw_core_load_spa_handle(struct pw_core *core,
|
||||||
uint32_t n_support;
|
uint32_t n_support;
|
||||||
struct spa_handle *handle;
|
struct spa_handle *handle;
|
||||||
|
|
||||||
pw_log_debug("core %p: load factory %s", core, factory_name);
|
pw_log_debug(NAME" %p: load factory %s", core, factory_name);
|
||||||
|
|
||||||
lib = pw_core_find_spa_lib(core, factory_name);
|
lib = pw_core_find_spa_lib(core, factory_name);
|
||||||
if (lib == NULL && info != NULL)
|
if (lib == NULL && info != NULL)
|
||||||
lib = spa_dict_lookup(info, SPA_KEY_LIBRARY_NAME);
|
lib = spa_dict_lookup(info, SPA_KEY_LIBRARY_NAME);
|
||||||
if (lib == NULL) {
|
if (lib == NULL) {
|
||||||
pw_log_warn("core %p: no library for %s: %m",
|
pw_log_warn(NAME" %p: no library for %s: %m",
|
||||||
core, factory_name);
|
core, factory_name);
|
||||||
errno = ENOENT;
|
errno = ENOENT;
|
||||||
return NULL;
|
return NULL;
|
||||||
|
|
|
||||||
|
|
@ -30,20 +30,22 @@
|
||||||
#include "pipewire/data-loop.h"
|
#include "pipewire/data-loop.h"
|
||||||
#include "pipewire/private.h"
|
#include "pipewire/private.h"
|
||||||
|
|
||||||
|
#define NAME "data-loop"
|
||||||
|
|
||||||
static void *do_loop(void *user_data)
|
static void *do_loop(void *user_data)
|
||||||
{
|
{
|
||||||
struct pw_data_loop *this = user_data;
|
struct pw_data_loop *this = user_data;
|
||||||
int res;
|
int res;
|
||||||
|
|
||||||
pw_log_debug("data-loop %p: enter thread", this);
|
pw_log_debug(NAME" %p: enter thread", this);
|
||||||
pw_loop_enter(this->loop);
|
pw_loop_enter(this->loop);
|
||||||
|
|
||||||
while (this->running) {
|
while (this->running) {
|
||||||
if ((res = pw_loop_iterate(this->loop, -1)) < 0)
|
if ((res = pw_loop_iterate(this->loop, -1)) < 0)
|
||||||
pw_log_warn("data-loop %p: iterate error %d (%s)",
|
pw_log_warn(NAME" %p: iterate error %d (%s)",
|
||||||
this, res, spa_strerror(res));
|
this, res, spa_strerror(res));
|
||||||
}
|
}
|
||||||
pw_log_debug("data-loop %p: leave thread", this);
|
pw_log_debug(NAME" %p: leave thread", this);
|
||||||
pw_loop_leave(this->loop);
|
pw_loop_leave(this->loop);
|
||||||
|
|
||||||
return NULL;
|
return NULL;
|
||||||
|
|
@ -53,7 +55,7 @@ static void *do_loop(void *user_data)
|
||||||
static void do_stop(void *data, uint64_t count)
|
static void do_stop(void *data, uint64_t count)
|
||||||
{
|
{
|
||||||
struct pw_data_loop *this = data;
|
struct pw_data_loop *this = data;
|
||||||
pw_log_debug("data-loop %p: stopping", this);
|
pw_log_debug(NAME" %p: stopping", this);
|
||||||
this->running = false;
|
this->running = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -73,20 +75,20 @@ struct pw_data_loop *pw_data_loop_new(struct pw_properties *properties)
|
||||||
goto error_cleanup;
|
goto error_cleanup;
|
||||||
}
|
}
|
||||||
|
|
||||||
pw_log_debug("data-loop %p: new", this);
|
pw_log_debug(NAME" %p: new", this);
|
||||||
|
|
||||||
this->loop = pw_loop_new(properties);
|
this->loop = pw_loop_new(properties);
|
||||||
properties = NULL;
|
properties = NULL;
|
||||||
if (this->loop == NULL) {
|
if (this->loop == NULL) {
|
||||||
res = -errno;
|
res = -errno;
|
||||||
pw_log_error("data-loop %p: can't create loop: %m", this);
|
pw_log_error(NAME" %p: can't create loop: %m", this);
|
||||||
goto error_free;
|
goto error_free;
|
||||||
}
|
}
|
||||||
|
|
||||||
this->event = pw_loop_add_event(this->loop, do_stop, this);
|
this->event = pw_loop_add_event(this->loop, do_stop, this);
|
||||||
if (this->event == NULL) {
|
if (this->event == NULL) {
|
||||||
res = -errno;
|
res = -errno;
|
||||||
pw_log_error("data-loop %p: can't add event: %m", this);
|
pw_log_error(NAME" %p: can't add event: %m", this);
|
||||||
goto error_loop_destroy;
|
goto error_loop_destroy;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -111,7 +113,7 @@ error_cleanup:
|
||||||
*/
|
*/
|
||||||
void pw_data_loop_destroy(struct pw_data_loop *loop)
|
void pw_data_loop_destroy(struct pw_data_loop *loop)
|
||||||
{
|
{
|
||||||
pw_log_debug("data-loop %p: destroy", loop);
|
pw_log_debug(NAME" %p: destroy", loop);
|
||||||
|
|
||||||
pw_data_loop_emit_destroy(loop);
|
pw_data_loop_emit_destroy(loop);
|
||||||
|
|
||||||
|
|
@ -151,7 +153,7 @@ int pw_data_loop_start(struct pw_data_loop *loop)
|
||||||
|
|
||||||
loop->running = true;
|
loop->running = true;
|
||||||
if ((err = pthread_create(&loop->thread, NULL, do_loop, loop)) != 0) {
|
if ((err = pthread_create(&loop->thread, NULL, do_loop, loop)) != 0) {
|
||||||
pw_log_error("data-loop %p: can't create thread: %s", loop, strerror(err));
|
pw_log_error(NAME" %p: can't create thread: %s", loop, strerror(err));
|
||||||
loop->running = false;
|
loop->running = false;
|
||||||
return -err;
|
return -err;
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -34,6 +34,8 @@
|
||||||
|
|
||||||
#include <spa/debug/types.h>
|
#include <spa/debug/types.h>
|
||||||
|
|
||||||
|
#define NAME "global"
|
||||||
|
|
||||||
/** \cond */
|
/** \cond */
|
||||||
struct impl {
|
struct impl {
|
||||||
struct pw_global this;
|
struct pw_global this;
|
||||||
|
|
@ -92,7 +94,7 @@ pw_global_new(struct pw_core *core,
|
||||||
this->id = pw_map_insert_new(&core->globals, this);
|
this->id = pw_map_insert_new(&core->globals, this);
|
||||||
if (this->id == SPA_ID_INVALID) {
|
if (this->id == SPA_ID_INVALID) {
|
||||||
res = -errno;
|
res = -errno;
|
||||||
pw_log_error("global %p: can't allocate new id: %m", this);
|
pw_log_error(NAME" %p: can't allocate new id: %m", this);
|
||||||
goto error_free;
|
goto error_free;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -100,7 +102,7 @@ pw_global_new(struct pw_core *core,
|
||||||
spa_list_init(&this->resource_list);
|
spa_list_init(&this->resource_list);
|
||||||
spa_hook_list_init(&this->listener_list);
|
spa_hook_list_init(&this->listener_list);
|
||||||
|
|
||||||
pw_log_debug("global %p: new %s %d", this,
|
pw_log_debug(NAME" %p: new %s %d", this,
|
||||||
spa_debug_type_find_name(pw_type_info(), this->type),
|
spa_debug_type_find_name(pw_type_info(), this->type),
|
||||||
this->id);
|
this->id);
|
||||||
|
|
||||||
|
|
@ -164,7 +166,7 @@ pw_global_register(struct pw_global *global,
|
||||||
&global->properties->dict : NULL);
|
&global->properties->dict : NULL);
|
||||||
}
|
}
|
||||||
|
|
||||||
pw_log_debug("global %p: registered %u owner %p parent %p", global, global->id, owner, parent);
|
pw_log_debug(NAME" %p: registered %u owner %p parent %p", global, global->id, owner, parent);
|
||||||
pw_core_emit_global_added(core, global);
|
pw_core_emit_global_added(core, global);
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
|
|
@ -199,7 +201,7 @@ static int global_unregister(struct pw_global *global)
|
||||||
pw_map_remove(&core->globals, global->id);
|
pw_map_remove(&core->globals, global->id);
|
||||||
impl->registered = false;
|
impl->registered = false;
|
||||||
|
|
||||||
pw_log_debug("global %p: unregistered %u", global, global->id);
|
pw_log_debug(NAME" %p: unregistered %u", global, global->id);
|
||||||
pw_core_emit_global_removed(core, global);
|
pw_core_emit_global_removed(core, global);
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
|
|
@ -301,7 +303,8 @@ error_bind:
|
||||||
goto error_exit;
|
goto error_exit;
|
||||||
|
|
||||||
error_exit:
|
error_exit:
|
||||||
pw_log_error("can't bind global %u/%u: %d (%s)", id, version, res, spa_strerror(res));
|
pw_log_error(NAME" %p: can't bind global %u/%u: %d (%s)", global, id,
|
||||||
|
version, res, spa_strerror(res));
|
||||||
pw_map_insert_at(&client->objects, id, NULL);
|
pw_map_insert_at(&client->objects, id, NULL);
|
||||||
pw_core_resource_remove_id(client->core_resource, id);
|
pw_core_resource_remove_id(client->core_resource, id);
|
||||||
return res;
|
return res;
|
||||||
|
|
@ -318,8 +321,8 @@ int pw_global_update_permissions(struct pw_global *global, struct pw_client *cli
|
||||||
do_hide = PW_PERM_IS_R(old_permissions) && !PW_PERM_IS_R(new_permissions);
|
do_hide = PW_PERM_IS_R(old_permissions) && !PW_PERM_IS_R(new_permissions);
|
||||||
do_show = !PW_PERM_IS_R(old_permissions) && PW_PERM_IS_R(new_permissions);
|
do_show = !PW_PERM_IS_R(old_permissions) && PW_PERM_IS_R(new_permissions);
|
||||||
|
|
||||||
pw_log_debug("client %p: permissions changed %d %08x -> %08x", client,
|
pw_log_debug(NAME" %p: client %p permissions changed %d %08x -> %08x",
|
||||||
global->id, old_permissions, new_permissions);
|
global, client, global->id, old_permissions, new_permissions);
|
||||||
|
|
||||||
pw_global_emit_permissions_changed(global, client, old_permissions, new_permissions);
|
pw_global_emit_permissions_changed(global, client, old_permissions, new_permissions);
|
||||||
|
|
||||||
|
|
@ -328,11 +331,13 @@ int pw_global_update_permissions(struct pw_global *global, struct pw_client *cli
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
if (do_hide) {
|
if (do_hide) {
|
||||||
pw_log_debug("client %p: hide global %d", client, global->id);
|
pw_log_debug("client %p: resource %p hide global %d",
|
||||||
|
client, resource, global->id);
|
||||||
pw_registry_resource_global_remove(resource, global->id);
|
pw_registry_resource_global_remove(resource, global->id);
|
||||||
}
|
}
|
||||||
else if (do_show) {
|
else if (do_show) {
|
||||||
pw_log_debug("client %p: show global %d", client, global->id);
|
pw_log_debug("client %p: resource %p show global %d",
|
||||||
|
client, resource, global->id);
|
||||||
pw_registry_resource_global(resource,
|
pw_registry_resource_global(resource,
|
||||||
global->id,
|
global->id,
|
||||||
global->parent->id,
|
global->parent->id,
|
||||||
|
|
@ -368,7 +373,7 @@ void pw_global_destroy(struct pw_global *global)
|
||||||
{
|
{
|
||||||
struct pw_resource *resource;
|
struct pw_resource *resource;
|
||||||
|
|
||||||
pw_log_debug("global %p: destroy %u", global, global->id);
|
pw_log_debug(NAME" %p: destroy %u", global, global->id);
|
||||||
pw_global_emit_destroy(global);
|
pw_global_emit_destroy(global);
|
||||||
|
|
||||||
spa_list_consume(resource, &global->resource_list, link)
|
spa_list_consume(resource, &global->resource_list, link)
|
||||||
|
|
@ -376,7 +381,7 @@ void pw_global_destroy(struct pw_global *global)
|
||||||
|
|
||||||
global_unregister(global);
|
global_unregister(global);
|
||||||
|
|
||||||
pw_log_debug("global %p: free", global);
|
pw_log_debug(NAME" %p: free", global);
|
||||||
pw_global_emit_free(global);
|
pw_global_emit_free(global);
|
||||||
|
|
||||||
if (global->properties)
|
if (global->properties)
|
||||||
|
|
|
||||||
|
|
@ -41,11 +41,12 @@
|
||||||
#include "pipewire/type.h"
|
#include "pipewire/type.h"
|
||||||
#include "pipewire/work-queue.h"
|
#include "pipewire/work-queue.h"
|
||||||
|
|
||||||
#undef spa_debug
|
|
||||||
#include <spa/debug/node.h>
|
#include <spa/debug/node.h>
|
||||||
#include <spa/debug/pod.h>
|
#include <spa/debug/pod.h>
|
||||||
#include <spa/debug/format.h>
|
#include <spa/debug/format.h>
|
||||||
|
|
||||||
|
#define NAME "link"
|
||||||
|
|
||||||
#define MAX_BUFFERS 64
|
#define MAX_BUFFERS 64
|
||||||
|
|
||||||
#define pw_link_resource_info(r,...) pw_resource_call(r,struct pw_link_proxy_events,info,0,__VA_ARGS__)
|
#define pw_link_resource_info(r,...) pw_resource_call(r,struct pw_link_proxy_events,info,0,__VA_ARGS__)
|
||||||
|
|
@ -85,7 +86,7 @@ static void debug_link(struct pw_link *link)
|
||||||
{
|
{
|
||||||
struct pw_node *in = link->input->node, *out = link->output->node;
|
struct pw_node *in = link->input->node, *out = link->output->node;
|
||||||
|
|
||||||
pw_log_debug("link %p: %d %d %d out %d %d %d , %d %d %d in %d %d %d", link,
|
pw_log_debug(NAME" %p: %d %d %d out %d %d %d , %d %d %d in %d %d %d", link,
|
||||||
out->n_used_input_links,
|
out->n_used_input_links,
|
||||||
out->n_ready_input_links,
|
out->n_ready_input_links,
|
||||||
out->idle_used_input_links,
|
out->idle_used_input_links,
|
||||||
|
|
@ -122,10 +123,10 @@ static void pw_link_update_state(struct pw_link *link, enum pw_link_state state,
|
||||||
return;
|
return;
|
||||||
|
|
||||||
if (state == PW_LINK_STATE_ERROR) {
|
if (state == PW_LINK_STATE_ERROR) {
|
||||||
pw_log_error("link %p: update state %s -> error (%s)", link,
|
pw_log_error(NAME" %p: update state %s -> error (%s)", link,
|
||||||
pw_link_state_as_string(old), error);
|
pw_link_state_as_string(old), error);
|
||||||
} else {
|
} else {
|
||||||
pw_log_debug("link %p: update state %s -> %s", link,
|
pw_log_debug(NAME" %p: update state %s -> %s", link,
|
||||||
pw_link_state_as_string(old), pw_link_state_as_string(state));
|
pw_link_state_as_string(old), pw_link_state_as_string(state));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -165,7 +166,7 @@ static void complete_ready(void *obj, void *data, int res, uint32_t id)
|
||||||
struct pw_port_mix *mix = obj == this->input->node ? &this->rt.in_mix : &this->rt.out_mix;
|
struct pw_port_mix *mix = obj == this->input->node ? &this->rt.in_mix : &this->rt.out_mix;
|
||||||
struct pw_port *port = mix->p;
|
struct pw_port *port = mix->p;
|
||||||
|
|
||||||
pw_log_debug("port %p: complete READY: %s", port, spa_strerror(res));
|
pw_log_debug(NAME" %p: port %p complete READY: %s", this, port, spa_strerror(res));
|
||||||
|
|
||||||
if (SPA_RESULT_IS_OK(res)) {
|
if (SPA_RESULT_IS_OK(res)) {
|
||||||
pw_port_update_state(port, PW_PORT_STATE_READY, NULL);
|
pw_port_update_state(port, PW_PORT_STATE_READY, NULL);
|
||||||
|
|
@ -183,7 +184,7 @@ static void complete_paused(void *obj, void *data, int res, uint32_t id)
|
||||||
struct pw_port_mix *mix = obj == this->input->node ? &this->rt.in_mix : &this->rt.out_mix;
|
struct pw_port_mix *mix = obj == this->input->node ? &this->rt.in_mix : &this->rt.out_mix;
|
||||||
struct pw_port *port = mix->p;
|
struct pw_port *port = mix->p;
|
||||||
|
|
||||||
pw_log_debug("link %p: port %p: complete PAUSED: %s", this, port, spa_strerror(res));
|
pw_log_debug(NAME" %p: port %p: complete PAUSED: %s", this, port, spa_strerror(res));
|
||||||
|
|
||||||
if (SPA_RESULT_IS_OK(res)) {
|
if (SPA_RESULT_IS_OK(res)) {
|
||||||
pw_port_update_state(port, PW_PORT_STATE_PAUSED, NULL);
|
pw_port_update_state(port, PW_PORT_STATE_PAUSED, NULL);
|
||||||
|
|
@ -218,7 +219,7 @@ static int do_negotiate(struct pw_link *this)
|
||||||
in_state = input->state;
|
in_state = input->state;
|
||||||
out_state = output->state;
|
out_state = output->state;
|
||||||
|
|
||||||
pw_log_debug("link %p: in_state:%d out_state:%d", this, in_state, out_state);
|
pw_log_debug(NAME" %p: in_state:%d out_state:%d", this, in_state, out_state);
|
||||||
|
|
||||||
if (in_state != PW_PORT_STATE_CONFIGURE && out_state != PW_PORT_STATE_CONFIGURE)
|
if (in_state != PW_PORT_STATE_CONFIGURE && out_state != PW_PORT_STATE_CONFIGURE)
|
||||||
return 0;
|
return 0;
|
||||||
|
|
@ -261,7 +262,7 @@ static int do_negotiate(struct pw_link *this)
|
||||||
goto error;
|
goto error;
|
||||||
}
|
}
|
||||||
if (current == NULL || spa_pod_compare(current, format) != 0) {
|
if (current == NULL || spa_pod_compare(current, format) != 0) {
|
||||||
pw_log_debug("link %p: output format change, renegotiate", this);
|
pw_log_debug(NAME" %p: output format change, renegotiate", this);
|
||||||
if (pw_log_level_enabled(SPA_LOG_LEVEL_DEBUG)) {
|
if (pw_log_level_enabled(SPA_LOG_LEVEL_DEBUG)) {
|
||||||
if (current)
|
if (current)
|
||||||
spa_debug_pod(2, NULL, current);
|
spa_debug_pod(2, NULL, current);
|
||||||
|
|
@ -271,7 +272,7 @@ static int do_negotiate(struct pw_link *this)
|
||||||
out_state = PW_PORT_STATE_CONFIGURE;
|
out_state = PW_PORT_STATE_CONFIGURE;
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
pw_log_debug("link %p: format was already set", this);
|
pw_log_debug(NAME" %p: format was already set", this);
|
||||||
changed = false;
|
changed = false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -297,7 +298,7 @@ static int do_negotiate(struct pw_link *this)
|
||||||
goto error;
|
goto error;
|
||||||
}
|
}
|
||||||
if (current == NULL || spa_pod_compare(current, format) != 0) {
|
if (current == NULL || spa_pod_compare(current, format) != 0) {
|
||||||
pw_log_debug("link %p: input format change, renegotiate", this);
|
pw_log_debug(NAME" %p: input format change, renegotiate", this);
|
||||||
if (pw_log_level_enabled(SPA_LOG_LEVEL_DEBUG)) {
|
if (pw_log_level_enabled(SPA_LOG_LEVEL_DEBUG)) {
|
||||||
if (current)
|
if (current)
|
||||||
spa_debug_pod(2, NULL, current);
|
spa_debug_pod(2, NULL, current);
|
||||||
|
|
@ -307,17 +308,17 @@ static int do_negotiate(struct pw_link *this)
|
||||||
in_state = PW_PORT_STATE_CONFIGURE;
|
in_state = PW_PORT_STATE_CONFIGURE;
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
pw_log_debug("link %p: format was already set", this);
|
pw_log_debug(NAME" %p: format was already set", this);
|
||||||
changed = false;
|
changed = false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
pw_log_debug("link %p: doing set format %p", this, format);
|
pw_log_debug(NAME" %p: doing set format %p", this, format);
|
||||||
if (pw_log_level_enabled(SPA_LOG_LEVEL_DEBUG))
|
if (pw_log_level_enabled(SPA_LOG_LEVEL_DEBUG))
|
||||||
spa_debug_format(2, NULL, format);
|
spa_debug_format(2, NULL, format);
|
||||||
|
|
||||||
if (out_state == PW_PORT_STATE_CONFIGURE) {
|
if (out_state == PW_PORT_STATE_CONFIGURE) {
|
||||||
pw_log_debug("link %p: doing set format on output", this);
|
pw_log_debug(NAME" %p: doing set format on output", this);
|
||||||
if ((res = pw_port_set_param(output,
|
if ((res = pw_port_set_param(output,
|
||||||
SPA_PARAM_Format, SPA_NODE_PARAM_FLAG_NEAREST,
|
SPA_PARAM_Format, SPA_NODE_PARAM_FLAG_NEAREST,
|
||||||
format)) < 0) {
|
format)) < 0) {
|
||||||
|
|
@ -333,7 +334,7 @@ static int do_negotiate(struct pw_link *this)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (in_state == PW_PORT_STATE_CONFIGURE) {
|
if (in_state == PW_PORT_STATE_CONFIGURE) {
|
||||||
pw_log_debug("link %p: doing set format on input", this);
|
pw_log_debug(NAME" %p: doing set format on input", this);
|
||||||
if ((res2 = pw_port_set_param(input,
|
if ((res2 = pw_port_set_param(input,
|
||||||
SPA_PARAM_Format, SPA_NODE_PARAM_FLAG_NEAREST,
|
SPA_PARAM_Format, SPA_NODE_PARAM_FLAG_NEAREST,
|
||||||
format)) < 0) {
|
format)) < 0) {
|
||||||
|
|
@ -358,7 +359,7 @@ static int do_negotiate(struct pw_link *this)
|
||||||
this->info.change_mask |= PW_LINK_CHANGE_MASK_FORMAT;
|
this->info.change_mask |= PW_LINK_CHANGE_MASK_FORMAT;
|
||||||
info_changed(this);
|
info_changed(this);
|
||||||
}
|
}
|
||||||
pw_log_debug("link %p: result %d", this, res);
|
pw_log_debug(NAME" %p: result %d", this, res);
|
||||||
return res;
|
return res;
|
||||||
|
|
||||||
error:
|
error:
|
||||||
|
|
@ -414,7 +415,7 @@ static int alloc_buffers(struct pw_link *this,
|
||||||
SPA_PARAM_META_size, SPA_POD_Int(&size)) < 0)
|
SPA_PARAM_META_size, SPA_POD_Int(&size)) < 0)
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
pw_log_debug("link %p: enable meta %d %d", this, type, size);
|
pw_log_debug(NAME" %p: enable meta %d %d", this, type, size);
|
||||||
|
|
||||||
metas[n_metas].type = type;
|
metas[n_metas].type = type;
|
||||||
metas[n_metas].size = size;
|
metas[n_metas].size = size;
|
||||||
|
|
@ -456,7 +457,7 @@ static int alloc_buffers(struct pw_link *this,
|
||||||
if (m == NULL)
|
if (m == NULL)
|
||||||
return -errno;
|
return -errno;
|
||||||
|
|
||||||
pw_log_debug("layout buffers %p data %p", bp, m->map->ptr);
|
pw_log_debug(NAME" %p: layout buffers %p data %p", this, bp, m->map->ptr);
|
||||||
spa_buffer_alloc_layout_array(&info, n_buffers, buffers, bp, m->map->ptr);
|
spa_buffer_alloc_layout_array(&info, n_buffers, buffers, bp, m->map->ptr);
|
||||||
|
|
||||||
allocation->mem = m;
|
allocation->mem = m;
|
||||||
|
|
@ -481,7 +482,7 @@ param_filter(struct pw_link *this,
|
||||||
|
|
||||||
for (iidx = 0;;) {
|
for (iidx = 0;;) {
|
||||||
spa_pod_builder_init(&ib, ibuf, sizeof(ibuf));
|
spa_pod_builder_init(&ib, ibuf, sizeof(ibuf));
|
||||||
pw_log_debug("iparam %d", iidx);
|
pw_log_debug(NAME" %p: input param %d id:%d", this, iidx, id);
|
||||||
if ((res = spa_node_port_enum_params_sync(in_port->node->node,
|
if ((res = spa_node_port_enum_params_sync(in_port->node->node,
|
||||||
in_port->direction, in_port->port_id,
|
in_port->direction, in_port->port_id,
|
||||||
id, &iidx, NULL, &iparam, &ib)) < 0)
|
id, &iidx, NULL, &iparam, &ib)) < 0)
|
||||||
|
|
@ -497,7 +498,7 @@ param_filter(struct pw_link *this,
|
||||||
spa_debug_pod(2, NULL, iparam);
|
spa_debug_pod(2, NULL, iparam);
|
||||||
|
|
||||||
for (oidx = 0;;) {
|
for (oidx = 0;;) {
|
||||||
pw_log_debug("oparam %d", oidx);
|
pw_log_debug(NAME" %p: output param %d id:%d", this, oidx, id);
|
||||||
if (spa_node_port_enum_params_sync(out_port->node->node,
|
if (spa_node_port_enum_params_sync(out_port->node->node,
|
||||||
out_port->direction, out_port->port_id,
|
out_port->direction, out_port->port_id,
|
||||||
id, &oidx, iparam, &oparam, result) != 1) {
|
id, &oidx, iparam, &oparam, result) != 1) {
|
||||||
|
|
@ -521,7 +522,7 @@ static int port_set_io(struct pw_link *this, struct pw_port *port, uint32_t id,
|
||||||
int res = 0;
|
int res = 0;
|
||||||
|
|
||||||
mix->io = data;
|
mix->io = data;
|
||||||
pw_log_debug("link %p: %s port %p %d.%d set io: %d %p %zd", this,
|
pw_log_debug(NAME" %p: %s port %p %d.%d set io: %d %p %zd", this,
|
||||||
pw_direction_as_string(port->direction),
|
pw_direction_as_string(port->direction),
|
||||||
port, port->port_id, mix->port.port_id, id, data, size);
|
port, port->port_id, mix->port.port_id, id, data, size);
|
||||||
|
|
||||||
|
|
@ -532,7 +533,8 @@ static int port_set_io(struct pw_link *this, struct pw_port *port, uint32_t id,
|
||||||
if (res == -ENOTSUP)
|
if (res == -ENOTSUP)
|
||||||
res = 0;
|
res = 0;
|
||||||
else
|
else
|
||||||
pw_log_warn("port %p: can't set io: %s", port, spa_strerror(res));
|
pw_log_warn(NAME" %p: port %p can't set io: %s", this,
|
||||||
|
port, spa_strerror(res));
|
||||||
}
|
}
|
||||||
return res;
|
return res;
|
||||||
}
|
}
|
||||||
|
|
@ -571,24 +573,24 @@ static int do_allocation(struct pw_link *this)
|
||||||
output = this->output;
|
output = this->output;
|
||||||
input = this->input;
|
input = this->input;
|
||||||
|
|
||||||
pw_log_debug("link %p: out-state:%d in-state:%d", this, output->state, input->state);
|
pw_log_debug(NAME" %p: out-state:%d in-state:%d", this, output->state, input->state);
|
||||||
|
|
||||||
pw_link_update_state(this, PW_LINK_STATE_ALLOCATING, NULL);
|
pw_link_update_state(this, PW_LINK_STATE_ALLOCATING, NULL);
|
||||||
|
|
||||||
out_flags = output->spa_flags;
|
out_flags = output->spa_flags;
|
||||||
in_flags = input->spa_flags;
|
in_flags = input->spa_flags;
|
||||||
|
|
||||||
pw_log_debug("link %p: out-node:%p in-node:%p: out-flags:%08x in-flags:%08x",
|
pw_log_debug(NAME" %p: out-node:%p in-node:%p: out-flags:%08x in-flags:%08x",
|
||||||
this, output->node, input->node, out_flags, in_flags);
|
this, output->node, input->node, out_flags, in_flags);
|
||||||
|
|
||||||
if (out_flags & SPA_PORT_FLAG_LIVE) {
|
if (out_flags & SPA_PORT_FLAG_LIVE) {
|
||||||
pw_log_debug("setting link as live");
|
pw_log_debug(NAME" %p: setting link as live", this);
|
||||||
output->node->live = true;
|
output->node->live = true;
|
||||||
input->node->live = true;
|
input->node->live = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (output->allocation.n_buffers) {
|
if (output->allocation.n_buffers) {
|
||||||
pw_log_debug("link %p: reusing %d output buffers %p", this,
|
pw_log_debug(NAME" %p: reusing %d output buffers %p", this,
|
||||||
output->allocation.n_buffers, output->allocation.buffers);
|
output->allocation.n_buffers, output->allocation.buffers);
|
||||||
this->rt.out_mix.have_buffers = true;
|
this->rt.out_mix.have_buffers = true;
|
||||||
} else {
|
} else {
|
||||||
|
|
@ -609,7 +611,7 @@ static int do_allocation(struct pw_link *this)
|
||||||
for (i = 0, offset = 0; i < n_params; i++) {
|
for (i = 0, offset = 0; i < n_params; i++) {
|
||||||
params[i] = SPA_MEMBER(buffer, offset, struct spa_pod);
|
params[i] = SPA_MEMBER(buffer, offset, struct spa_pod);
|
||||||
spa_pod_fixate(params[i]);
|
spa_pod_fixate(params[i]);
|
||||||
pw_log_debug("fixated param %d:", i);
|
pw_log_debug(NAME" %p: fixated param %d:", this, i);
|
||||||
if (pw_log_level_enabled(SPA_LOG_LEVEL_DEBUG))
|
if (pw_log_level_enabled(SPA_LOG_LEVEL_DEBUG))
|
||||||
spa_debug_pod(2, NULL, params[i]);
|
spa_debug_pod(2, NULL, params[i]);
|
||||||
offset += SPA_ROUND_UP_N(SPA_POD_SIZE(params[i]), 8);
|
offset += SPA_ROUND_UP_N(SPA_POD_SIZE(params[i]), 8);
|
||||||
|
|
@ -637,11 +639,11 @@ static int do_allocation(struct pw_link *this)
|
||||||
stride = SPA_MAX(stride, qstride);
|
stride = SPA_MAX(stride, qstride);
|
||||||
align = SPA_MAX(align, qalign);
|
align = SPA_MAX(align, qalign);
|
||||||
|
|
||||||
pw_log_debug("%d %d %d %d -> %zd %zd %d %zd",
|
pw_log_debug(NAME" %p: %d %d %d %d -> %zd %zd %d %zd", this,
|
||||||
qminsize, qstride, qmax_buffers, qalign,
|
qminsize, qstride, qmax_buffers, qalign,
|
||||||
minsize, stride, max_buffers, align);
|
minsize, stride, max_buffers, align);
|
||||||
} else {
|
} else {
|
||||||
pw_log_warn("no buffers param");
|
pw_log_warn(NAME" %p: no buffers param", this);
|
||||||
minsize = 8192;
|
minsize = 8192;
|
||||||
max_buffers = 4;
|
max_buffers = 4;
|
||||||
}
|
}
|
||||||
|
|
@ -671,12 +673,13 @@ static int do_allocation(struct pw_link *this)
|
||||||
goto error;
|
goto error;
|
||||||
}
|
}
|
||||||
|
|
||||||
pw_log_debug("link %p: allocating %d buffers %p %zd %zd", this,
|
pw_log_debug(NAME" %p: allocating %d buffers %p %zd %zd", this,
|
||||||
allocation.n_buffers, allocation.buffers, minsize, stride);
|
allocation.n_buffers, allocation.buffers, minsize, stride);
|
||||||
|
|
||||||
if ((res = pw_port_use_buffers(output, &this->rt.out_mix,
|
if ((res = pw_port_use_buffers(output, &this->rt.out_mix,
|
||||||
flags, allocation.buffers, allocation.n_buffers)) < 0) {
|
flags, allocation.buffers, allocation.n_buffers)) < 0) {
|
||||||
asprintf(&error, "error use output buffers: %d", res);
|
asprintf(&error, "error use output buffers: %d (%s)", res,
|
||||||
|
spa_strerror(res));
|
||||||
goto error;
|
goto error;
|
||||||
}
|
}
|
||||||
move_allocation(&allocation, &output->allocation);
|
move_allocation(&allocation, &output->allocation);
|
||||||
|
|
@ -692,13 +695,13 @@ static int do_allocation(struct pw_link *this)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
pw_log_debug("link %p: using %d buffers %p on input port", this,
|
pw_log_debug(NAME" %p: using %d buffers %p on input port", this,
|
||||||
output->allocation.n_buffers, output->allocation.buffers);
|
output->allocation.n_buffers, output->allocation.buffers);
|
||||||
|
|
||||||
if ((res = pw_port_use_buffers(input, &this->rt.in_mix, 0,
|
if ((res = pw_port_use_buffers(input, &this->rt.in_mix, 0,
|
||||||
output->allocation.buffers,
|
output->allocation.buffers,
|
||||||
output->allocation.n_buffers)) < 0) {
|
output->allocation.n_buffers)) < 0) {
|
||||||
asprintf(&error, "link %p: error use input buffers: %s", this,
|
asprintf(&error, "error use input buffers: %d (%s)", res,
|
||||||
spa_strerror(res));
|
spa_strerror(res));
|
||||||
goto error;
|
goto error;
|
||||||
}
|
}
|
||||||
|
|
@ -725,7 +728,7 @@ do_activate_link(struct spa_loop *loop,
|
||||||
struct pw_link *this = user_data;
|
struct pw_link *this = user_data;
|
||||||
struct impl *impl = SPA_CONTAINER_OF(this, struct impl, this);
|
struct impl *impl = SPA_CONTAINER_OF(this, struct impl, this);
|
||||||
|
|
||||||
pw_log_trace("link %p: activate", this);
|
pw_log_trace(NAME" %p: activate", this);
|
||||||
|
|
||||||
spa_list_append(&this->output->rt.mix_list, &this->rt.out_mix.rt_link);
|
spa_list_append(&this->output->rt.mix_list, &this->rt.out_mix.rt_link);
|
||||||
spa_list_append(&this->input->rt.mix_list, &this->rt.in_mix.rt_link);
|
spa_list_append(&this->input->rt.mix_list, &this->rt.in_mix.rt_link);
|
||||||
|
|
@ -736,7 +739,7 @@ do_activate_link(struct spa_loop *loop,
|
||||||
this->rt.target.activation = impl->inode->rt.activation;
|
this->rt.target.activation = impl->inode->rt.activation;
|
||||||
spa_list_append(&impl->onode->rt.target_list, &this->rt.target.link);
|
spa_list_append(&impl->onode->rt.target_list, &this->rt.target.link);
|
||||||
required = ++this->rt.target.activation->state[0].required;
|
required = ++this->rt.target.activation->state[0].required;
|
||||||
pw_log_trace("link %p: node:%p required:%d", this,
|
pw_log_trace(NAME" %p: node:%p required:%d", this,
|
||||||
impl->inode, required);
|
impl->inode, required);
|
||||||
}
|
}
|
||||||
return 0;
|
return 0;
|
||||||
|
|
@ -747,7 +750,7 @@ int pw_link_activate(struct pw_link *this)
|
||||||
struct impl *impl = SPA_CONTAINER_OF(this, struct impl, this);
|
struct impl *impl = SPA_CONTAINER_OF(this, struct impl, this);
|
||||||
int res;
|
int res;
|
||||||
|
|
||||||
pw_log_debug("link %p: activate %d %d", this, impl->activated, this->info.state);
|
pw_log_debug(NAME" %p: activate %d %d", this, impl->activated, this->info.state);
|
||||||
|
|
||||||
if (impl->activated)
|
if (impl->activated)
|
||||||
return 0;
|
return 0;
|
||||||
|
|
@ -787,13 +790,13 @@ static void check_states(void *obj, void *user_data, int res, uint32_t id)
|
||||||
|
|
||||||
if (output == NULL || input == NULL) {
|
if (output == NULL || input == NULL) {
|
||||||
pw_link_update_state(this, PW_LINK_STATE_ERROR,
|
pw_link_update_state(this, PW_LINK_STATE_ERROR,
|
||||||
strdup("link without input or output port"));
|
strdup(NAME" without input or output port"));
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (output->node->info.state == PW_NODE_STATE_ERROR ||
|
if (output->node->info.state == PW_NODE_STATE_ERROR ||
|
||||||
input->node->info.state == PW_NODE_STATE_ERROR) {
|
input->node->info.state == PW_NODE_STATE_ERROR) {
|
||||||
pw_log_warn("link %p: one of the nodes is in error out:%d in:%d", this,
|
pw_log_warn(NAME" %p: one of the nodes is in error out:%d in:%d", this,
|
||||||
output->node->info.state,
|
output->node->info.state,
|
||||||
input->node->info.state);
|
input->node->info.state);
|
||||||
return;
|
return;
|
||||||
|
|
@ -802,7 +805,7 @@ static void check_states(void *obj, void *user_data, int res, uint32_t id)
|
||||||
out_state = output->state;
|
out_state = output->state;
|
||||||
in_state = input->state;
|
in_state = input->state;
|
||||||
|
|
||||||
pw_log_debug("link %p: output state %d, input state %d", this, out_state, in_state);
|
pw_log_debug(NAME" %p: output state %d, input state %d", this, out_state, in_state);
|
||||||
|
|
||||||
if (out_state == PW_PORT_STATE_ERROR || in_state == PW_PORT_STATE_ERROR) {
|
if (out_state == PW_PORT_STATE_ERROR || in_state == PW_PORT_STATE_ERROR) {
|
||||||
pw_link_update_state(this, PW_LINK_STATE_ERROR, strdup("ports are in error"));
|
pw_link_update_state(this, PW_LINK_STATE_ERROR, strdup("ports are in error"));
|
||||||
|
|
@ -823,7 +826,7 @@ static void check_states(void *obj, void *user_data, int res, uint32_t id)
|
||||||
|
|
||||||
exit:
|
exit:
|
||||||
if (SPA_RESULT_IS_ERROR(res)) {
|
if (SPA_RESULT_IS_ERROR(res)) {
|
||||||
pw_log_debug("link %p: got error result %d (%s)", this, res, spa_strerror(res));
|
pw_log_debug(NAME" %p: got error result %d (%s)", this, res, spa_strerror(res));
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -837,7 +840,7 @@ static void input_remove(struct pw_link *this, struct pw_port *port)
|
||||||
struct pw_port_mix *mix = &this->rt.in_mix;
|
struct pw_port_mix *mix = &this->rt.in_mix;
|
||||||
int res;
|
int res;
|
||||||
|
|
||||||
pw_log_debug("link %p: remove input port %p", this, port);
|
pw_log_debug(NAME" %p: remove input port %p", this, port);
|
||||||
spa_hook_remove(&impl->input_port_listener);
|
spa_hook_remove(&impl->input_port_listener);
|
||||||
spa_hook_remove(&impl->input_node_listener);
|
spa_hook_remove(&impl->input_node_listener);
|
||||||
spa_hook_remove(&impl->input_global_listener);
|
spa_hook_remove(&impl->input_global_listener);
|
||||||
|
|
@ -846,7 +849,7 @@ static void input_remove(struct pw_link *this, struct pw_port *port)
|
||||||
pw_port_emit_link_removed(this->input, this);
|
pw_port_emit_link_removed(this->input, this);
|
||||||
|
|
||||||
if ((res = pw_port_use_buffers(port, mix, 0, NULL, 0)) < 0) {
|
if ((res = pw_port_use_buffers(port, mix, 0, NULL, 0)) < 0) {
|
||||||
pw_log_warn("link %p: port %p clear error %s", this, port, spa_strerror(res));
|
pw_log_warn(NAME" %p: port %p clear error %s", this, port, spa_strerror(res));
|
||||||
}
|
}
|
||||||
pw_port_release_mix(port, mix);
|
pw_port_release_mix(port, mix);
|
||||||
this->input = NULL;
|
this->input = NULL;
|
||||||
|
|
@ -857,7 +860,7 @@ static void output_remove(struct pw_link *this, struct pw_port *port)
|
||||||
struct impl *impl = (struct impl *) this;
|
struct impl *impl = (struct impl *) this;
|
||||||
struct pw_port_mix *mix = &this->rt.out_mix;
|
struct pw_port_mix *mix = &this->rt.out_mix;
|
||||||
|
|
||||||
pw_log_debug("link %p: remove output port %p", this, port);
|
pw_log_debug(NAME" %p: remove output port %p", this, port);
|
||||||
spa_hook_remove(&impl->output_port_listener);
|
spa_hook_remove(&impl->output_port_listener);
|
||||||
spa_hook_remove(&impl->output_node_listener);
|
spa_hook_remove(&impl->output_node_listener);
|
||||||
spa_hook_remove(&impl->output_global_listener);
|
spa_hook_remove(&impl->output_global_listener);
|
||||||
|
|
@ -874,7 +877,7 @@ static void output_remove(struct pw_link *this, struct pw_port *port)
|
||||||
|
|
||||||
static void on_port_destroy(struct pw_link *this, struct pw_port *port)
|
static void on_port_destroy(struct pw_link *this, struct pw_port *port)
|
||||||
{
|
{
|
||||||
pw_log_debug("link %p: port %p", this, port);
|
pw_log_debug(NAME" %p: port %p", this, port);
|
||||||
pw_link_emit_port_unlinked(this, port);
|
pw_link_emit_port_unlinked(this, port);
|
||||||
|
|
||||||
pw_link_update_state(this, PW_LINK_STATE_UNLINKED, NULL);
|
pw_link_update_state(this, PW_LINK_STATE_UNLINKED, NULL);
|
||||||
|
|
@ -897,7 +900,7 @@ int pw_link_prepare(struct pw_link *this)
|
||||||
{
|
{
|
||||||
struct impl *impl = SPA_CONTAINER_OF(this, struct impl, this);
|
struct impl *impl = SPA_CONTAINER_OF(this, struct impl, this);
|
||||||
|
|
||||||
pw_log_debug("link %p: prepare %d", this, impl->prepare);
|
pw_log_debug(NAME" %p: prepare %d", this, impl->prepare);
|
||||||
|
|
||||||
if (impl->prepare)
|
if (impl->prepare)
|
||||||
return 0;
|
return 0;
|
||||||
|
|
@ -928,7 +931,7 @@ do_deactivate_link(struct spa_loop *loop,
|
||||||
struct pw_link *this = user_data;
|
struct pw_link *this = user_data;
|
||||||
struct impl *impl = SPA_CONTAINER_OF(this, struct impl, this);
|
struct impl *impl = SPA_CONTAINER_OF(this, struct impl, this);
|
||||||
|
|
||||||
pw_log_trace("link %p: disable %p and %p", this, &this->rt.in_mix, &this->rt.out_mix);
|
pw_log_trace(NAME" %p: disable %p and %p", this, &this->rt.in_mix, &this->rt.out_mix);
|
||||||
|
|
||||||
spa_list_remove(&this->rt.out_mix.rt_link);
|
spa_list_remove(&this->rt.out_mix.rt_link);
|
||||||
spa_list_remove(&this->rt.in_mix.rt_link);
|
spa_list_remove(&this->rt.in_mix.rt_link);
|
||||||
|
|
@ -938,7 +941,7 @@ do_deactivate_link(struct spa_loop *loop,
|
||||||
|
|
||||||
spa_list_remove(&this->rt.target.link);
|
spa_list_remove(&this->rt.target.link);
|
||||||
required = --this->rt.target.activation->state[0].required;
|
required = --this->rt.target.activation->state[0].required;
|
||||||
pw_log_trace("link %p: node:%p required:%d", this,
|
pw_log_trace(NAME" %p: node:%p required:%d", this,
|
||||||
impl->inode, required);
|
impl->inode, required);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -950,7 +953,7 @@ int pw_link_deactivate(struct pw_link *this)
|
||||||
struct impl *impl = SPA_CONTAINER_OF(this, struct impl, this);
|
struct impl *impl = SPA_CONTAINER_OF(this, struct impl, this);
|
||||||
struct pw_node *input_node, *output_node;
|
struct pw_node *input_node, *output_node;
|
||||||
|
|
||||||
pw_log_debug("link %p: deactivate %d %d", this, impl->prepare, impl->activated);
|
pw_log_debug(NAME" %p: deactivate %d %d", this, impl->prepare, impl->activated);
|
||||||
|
|
||||||
if (!impl->prepare)
|
if (!impl->prepare)
|
||||||
return 0;
|
return 0;
|
||||||
|
|
@ -983,16 +986,16 @@ int pw_link_deactivate(struct pw_link *this)
|
||||||
input_node->n_used_output_links <= input_node->idle_used_output_links &&
|
input_node->n_used_output_links <= input_node->idle_used_output_links &&
|
||||||
input_node->info.state > PW_NODE_STATE_IDLE) {
|
input_node->info.state > PW_NODE_STATE_IDLE) {
|
||||||
pw_node_set_state(input_node, PW_NODE_STATE_IDLE);
|
pw_node_set_state(input_node, PW_NODE_STATE_IDLE);
|
||||||
pw_log_debug("port %p: input state %d -> %d", this->input,
|
pw_log_debug(NAME" %p: input port %p state %d -> %d", this,
|
||||||
this->input->state, PW_PORT_STATE_PAUSED);
|
this->input, this->input->state, PW_PORT_STATE_PAUSED);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (output_node->n_used_input_links <= output_node->idle_used_input_links &&
|
if (output_node->n_used_input_links <= output_node->idle_used_input_links &&
|
||||||
output_node->n_used_output_links <= output_node->idle_used_output_links &&
|
output_node->n_used_output_links <= output_node->idle_used_output_links &&
|
||||||
output_node->info.state > PW_NODE_STATE_IDLE) {
|
output_node->info.state > PW_NODE_STATE_IDLE) {
|
||||||
pw_node_set_state(output_node, PW_NODE_STATE_IDLE);
|
pw_node_set_state(output_node, PW_NODE_STATE_IDLE);
|
||||||
pw_log_debug("port %p: output state %d -> %d", this->output,
|
pw_log_debug(NAME" %p: output port %p state %d -> %d", this,
|
||||||
this->output->state, PW_PORT_STATE_PAUSED);
|
this->output, this->output->state, PW_PORT_STATE_PAUSED);
|
||||||
}
|
}
|
||||||
|
|
||||||
pw_link_update_state(this, PW_LINK_STATE_INIT, NULL);
|
pw_link_update_state(this, PW_LINK_STATE_INIT, NULL);
|
||||||
|
|
@ -1027,7 +1030,7 @@ global_bind(void *_data, struct pw_client *client, uint32_t permissions,
|
||||||
data = pw_resource_get_user_data(resource);
|
data = pw_resource_get_user_data(resource);
|
||||||
pw_resource_add_listener(resource, &data->resource_listener, &resource_events, resource);
|
pw_resource_add_listener(resource, &data->resource_listener, &resource_events, resource);
|
||||||
|
|
||||||
pw_log_debug("link %p: bound to %d", this, resource->id);
|
pw_log_debug(NAME" %p: bound to %d", this, resource->id);
|
||||||
|
|
||||||
spa_list_append(&global->resource_list, &resource->link);
|
spa_list_append(&global->resource_list, &resource->link);
|
||||||
|
|
||||||
|
|
@ -1038,7 +1041,7 @@ global_bind(void *_data, struct pw_client *client, uint32_t permissions,
|
||||||
return 0;
|
return 0;
|
||||||
|
|
||||||
error_resource:
|
error_resource:
|
||||||
pw_log_error("can't create link resource: %m");
|
pw_log_error(NAME" %p: can't create link resource: %m", this);
|
||||||
return -errno;
|
return -errno;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -1093,7 +1096,7 @@ static void input_node_result(void *data, int seq, int res, uint32_t type, const
|
||||||
{
|
{
|
||||||
struct impl *impl = data;
|
struct impl *impl = data;
|
||||||
struct pw_node *node = impl->this.input->node;
|
struct pw_node *node = impl->this.input->node;
|
||||||
pw_log_debug("link %p: input node %p result seq:%d res:%d type:%u",
|
pw_log_debug(NAME" %p: input node %p result seq:%d res:%d type:%u",
|
||||||
impl, node, seq, res, type);
|
impl, node, seq, res, type);
|
||||||
node_result(impl, node, seq, res, type, result);
|
node_result(impl, node, seq, res, type, result);
|
||||||
}
|
}
|
||||||
|
|
@ -1102,7 +1105,7 @@ static void output_node_result(void *data, int seq, int res, uint32_t type, cons
|
||||||
{
|
{
|
||||||
struct impl *impl = data;
|
struct impl *impl = data;
|
||||||
struct pw_node *node = impl->this.output->node;
|
struct pw_node *node = impl->this.output->node;
|
||||||
pw_log_debug("link %p: output node %p result seq:%d res:%d type:%u",
|
pw_log_debug(NAME" %p: output node %p result seq:%d res:%d type:%u",
|
||||||
impl, node, seq, res, type);
|
impl, node, seq, res, type);
|
||||||
|
|
||||||
node_result(impl, node, seq, res, type, result);
|
node_result(impl, node, seq, res, type, result);
|
||||||
|
|
@ -1154,18 +1157,20 @@ static void try_link_controls(struct impl *impl, struct pw_port *output, struct
|
||||||
imix = this->rt.in_mix.port.port_id;
|
imix = this->rt.in_mix.port.port_id;
|
||||||
omix = this->rt.out_mix.port.port_id;
|
omix = this->rt.out_mix.port.port_id;
|
||||||
|
|
||||||
pw_log_debug("link %p: trying controls", impl);
|
pw_log_debug(NAME" %p: trying controls", impl);
|
||||||
spa_list_for_each(cout, &output->control_list[SPA_DIRECTION_OUTPUT], port_link) {
|
spa_list_for_each(cout, &output->control_list[SPA_DIRECTION_OUTPUT], port_link) {
|
||||||
spa_list_for_each(cin, &input->control_list[SPA_DIRECTION_INPUT], port_link) {
|
spa_list_for_each(cin, &input->control_list[SPA_DIRECTION_INPUT], port_link) {
|
||||||
if ((res = pw_control_add_link(cout, omix, cin, imix, &this->control)) < 0)
|
if ((res = pw_control_add_link(cout, omix, cin, imix, &this->control)) < 0)
|
||||||
pw_log_error("failed to link controls: %s", spa_strerror(res));
|
pw_log_error(NAME" %p: failed to link controls: %s",
|
||||||
|
this, spa_strerror(res));
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
spa_list_for_each(cin, &output->control_list[SPA_DIRECTION_INPUT], port_link) {
|
spa_list_for_each(cin, &output->control_list[SPA_DIRECTION_INPUT], port_link) {
|
||||||
spa_list_for_each(cout, &input->control_list[SPA_DIRECTION_OUTPUT], port_link) {
|
spa_list_for_each(cout, &input->control_list[SPA_DIRECTION_OUTPUT], port_link) {
|
||||||
if ((res = pw_control_add_link(cout, imix, cin, omix, &this->notify)) < 0)
|
if ((res = pw_control_add_link(cout, imix, cin, omix, &this->notify)) < 0)
|
||||||
pw_log_error("failed to link controls: %s", spa_strerror(res));
|
pw_log_error(NAME" %p: failed to link controls: %s",
|
||||||
|
this, spa_strerror(res));
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -1176,14 +1181,16 @@ static void try_unlink_controls(struct impl *impl, struct pw_port *output, struc
|
||||||
struct pw_link *this = &impl->this;
|
struct pw_link *this = &impl->this;
|
||||||
int res;
|
int res;
|
||||||
|
|
||||||
pw_log_debug("link %p: unlinking controls", impl);
|
pw_log_debug(NAME" %p: unlinking controls", impl);
|
||||||
if (this->control.valid) {
|
if (this->control.valid) {
|
||||||
if ((res = pw_control_remove_link(&this->control)) < 0)
|
if ((res = pw_control_remove_link(&this->control)) < 0)
|
||||||
pw_log_error("failed to unlink controls: %s", spa_strerror(res));
|
pw_log_error(NAME" %p: failed to unlink controls: %s",
|
||||||
|
this, spa_strerror(res));
|
||||||
}
|
}
|
||||||
if (this->notify.valid) {
|
if (this->notify.valid) {
|
||||||
if ((res = pw_control_remove_link(&this->notify)) < 0)
|
if ((res = pw_control_remove_link(&this->notify)) < 0)
|
||||||
pw_log_error("failed to unlink controls: %s", spa_strerror(res));
|
pw_log_error(NAME" %p: failed to unlink controls: %s",
|
||||||
|
this, spa_strerror(res));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -1214,7 +1221,7 @@ static void permissions_changed(struct pw_link *this, struct pw_port *other,
|
||||||
perm = pw_global_get_permissions(other->global, client);
|
perm = pw_global_get_permissions(other->global, client);
|
||||||
old &= perm;
|
old &= perm;
|
||||||
new &= perm;
|
new &= perm;
|
||||||
pw_log_debug("link %p: permissions changed %08x -> %08x", this, old, new);
|
pw_log_debug(NAME" %p: permissions changed %08x -> %08x", this, old, new);
|
||||||
|
|
||||||
if (check_permission(this->core, this->output, this->input, this->properties) < 0) {
|
if (check_permission(this->core, this->output, this->input, this->properties) < 0) {
|
||||||
pw_link_destroy(this);
|
pw_link_destroy(this);
|
||||||
|
|
@ -1282,7 +1289,7 @@ struct pw_link *pw_link_new(struct pw_core *core,
|
||||||
|
|
||||||
this = &impl->this;
|
this = &impl->this;
|
||||||
this->feedback = pw_node_can_reach(input_node, output_node);
|
this->feedback = pw_node_can_reach(input_node, output_node);
|
||||||
pw_log_debug("link %p: new out-port:%p -> in-port:%p", this, output, input);
|
pw_log_debug(NAME" %p: new out-port:%p -> in-port:%p", this, output, input);
|
||||||
|
|
||||||
if (user_data_size > 0)
|
if (user_data_size > 0)
|
||||||
this->user_data = SPA_MEMBER(impl, sizeof(struct impl), void);
|
this->user_data = SPA_MEMBER(impl, sizeof(struct impl), void);
|
||||||
|
|
@ -1314,7 +1321,7 @@ struct pw_link *pw_link_new(struct pw_core *core,
|
||||||
|
|
||||||
input_node->live = output_node->live;
|
input_node->live = output_node->live;
|
||||||
|
|
||||||
pw_log_debug("link %p: output node %p live %d, passive %d, feedback %d",
|
pw_log_debug(NAME" %p: output node %p live %d, passive %d, feedback %d",
|
||||||
this, output_node, output_node->live, impl->passive, this->feedback);
|
this, output_node, output_node->live, impl->passive, this->feedback);
|
||||||
|
|
||||||
spa_list_append(&output->links, &this->output_link);
|
spa_list_append(&output->links, &this->output_link);
|
||||||
|
|
@ -1344,7 +1351,7 @@ struct pw_link *pw_link_new(struct pw_core *core,
|
||||||
this->rt.target.signal = impl->inode->rt.target.signal;
|
this->rt.target.signal = impl->inode->rt.target.signal;
|
||||||
this->rt.target.data = impl->inode->rt.target.data;
|
this->rt.target.data = impl->inode->rt.target.data;
|
||||||
|
|
||||||
pw_log_debug("link %p: constructed out:%p:%d.%d -> in:%p:%d.%d", impl,
|
pw_log_debug(NAME" %p: constructed out:%p:%d.%d -> in:%p:%d.%d", impl,
|
||||||
output_node, output->port_id, this->rt.out_mix.port.port_id,
|
output_node, output->port_id, this->rt.out_mix.port.port_id,
|
||||||
input_node, input->port_id, this->rt.in_mix.port.port_id);
|
input_node, input->port_id, this->rt.in_mix.port.port_id);
|
||||||
|
|
||||||
|
|
@ -1380,7 +1387,7 @@ error_no_mem:
|
||||||
pw_log_error("alloc failed: %m");
|
pw_log_error("alloc failed: %m");
|
||||||
goto error_exit;
|
goto error_exit;
|
||||||
error_no_io:
|
error_no_io:
|
||||||
pw_log_error("can't set io %d (%s)", res, spa_strerror(res));
|
pw_log_error(NAME" %p: can't set io %d (%s)", this, res, spa_strerror(res));
|
||||||
goto error_free;
|
goto error_free;
|
||||||
error_free:
|
error_free:
|
||||||
free(impl);
|
free(impl);
|
||||||
|
|
@ -1468,7 +1475,7 @@ void pw_link_destroy(struct pw_link *link)
|
||||||
{
|
{
|
||||||
struct impl *impl = SPA_CONTAINER_OF(link, struct impl, this);
|
struct impl *impl = SPA_CONTAINER_OF(link, struct impl, this);
|
||||||
|
|
||||||
pw_log_debug("link %p: destroy", impl);
|
pw_log_debug(NAME" %p: destroy", impl);
|
||||||
pw_link_emit_destroy(link);
|
pw_link_emit_destroy(link);
|
||||||
|
|
||||||
pw_link_deactivate(link);
|
pw_link_deactivate(link);
|
||||||
|
|
@ -1488,7 +1495,7 @@ void pw_link_destroy(struct pw_link *link)
|
||||||
pw_global_destroy(link->global);
|
pw_global_destroy(link->global);
|
||||||
}
|
}
|
||||||
|
|
||||||
pw_log_debug("link %p: free", impl);
|
pw_log_debug(NAME" %p: free", impl);
|
||||||
pw_link_emit_free(link);
|
pw_link_emit_free(link);
|
||||||
|
|
||||||
pw_work_queue_destroy(impl->work);
|
pw_work_queue_destroy(impl->work);
|
||||||
|
|
@ -1508,7 +1515,7 @@ void pw_link_add_listener(struct pw_link *link,
|
||||||
const struct pw_link_events *events,
|
const struct pw_link_events *events,
|
||||||
void *data)
|
void *data)
|
||||||
{
|
{
|
||||||
pw_log_debug("link %p: add listener %p", link, listener);
|
pw_log_debug(NAME" %p: add listener %p", link, listener);
|
||||||
spa_hook_list_append(&link->listener_list, listener, events, data);
|
spa_hook_list_append(&link->listener_list, listener, events, data);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -34,6 +34,8 @@
|
||||||
|
|
||||||
#define DATAS_SIZE (4096 * 8)
|
#define DATAS_SIZE (4096 * 8)
|
||||||
|
|
||||||
|
#define NAME "loop"
|
||||||
|
|
||||||
/** \cond */
|
/** \cond */
|
||||||
|
|
||||||
struct impl {
|
struct impl {
|
||||||
|
|
@ -82,14 +84,14 @@ struct pw_loop *pw_loop_new(struct pw_properties *properties)
|
||||||
n_support, support);
|
n_support, support);
|
||||||
if (impl->system_handle == NULL) {
|
if (impl->system_handle == NULL) {
|
||||||
res = -errno;
|
res = -errno;
|
||||||
pw_log_error("can't make "SPA_NAME_SUPPORT_SYSTEM" handle: %m");
|
pw_log_error(NAME" %p: can't make "SPA_NAME_SUPPORT_SYSTEM" handle: %m", this);
|
||||||
goto error_free;
|
goto error_free;
|
||||||
}
|
}
|
||||||
|
|
||||||
if ((res = spa_handle_get_interface(impl->system_handle,
|
if ((res = spa_handle_get_interface(impl->system_handle,
|
||||||
SPA_TYPE_INTERFACE_System,
|
SPA_TYPE_INTERFACE_System,
|
||||||
&iface)) < 0) {
|
&iface)) < 0) {
|
||||||
pw_log_error("can't get System interface %s", spa_strerror(res));
|
pw_log_error(NAME" %p: can't get System interface: %s", this, spa_strerror(res));
|
||||||
goto error_unload_system;
|
goto error_unload_system;
|
||||||
}
|
}
|
||||||
this->system = iface;
|
this->system = iface;
|
||||||
|
|
@ -107,14 +109,15 @@ struct pw_loop *pw_loop_new(struct pw_properties *properties)
|
||||||
n_support, support);
|
n_support, support);
|
||||||
if (impl->loop_handle == NULL) {
|
if (impl->loop_handle == NULL) {
|
||||||
res = -errno;
|
res = -errno;
|
||||||
pw_log_error("can't make "SPA_NAME_SUPPORT_LOOP" handle: %m");
|
pw_log_error(NAME" %p: can't make "SPA_NAME_SUPPORT_LOOP" handle: %m", this);
|
||||||
goto error_unload_system;
|
goto error_unload_system;
|
||||||
}
|
}
|
||||||
|
|
||||||
if ((res = spa_handle_get_interface(impl->loop_handle,
|
if ((res = spa_handle_get_interface(impl->loop_handle,
|
||||||
SPA_TYPE_INTERFACE_Loop,
|
SPA_TYPE_INTERFACE_Loop,
|
||||||
&iface)) < 0) {
|
&iface)) < 0) {
|
||||||
fprintf(stderr, "can't get Loop interface %d\n", res);
|
pw_log_error(NAME" %p: can't get Loop interface: %s",
|
||||||
|
this, spa_strerror(res));
|
||||||
goto error_unload_loop;
|
goto error_unload_loop;
|
||||||
}
|
}
|
||||||
this->loop = iface;
|
this->loop = iface;
|
||||||
|
|
@ -122,7 +125,8 @@ struct pw_loop *pw_loop_new(struct pw_properties *properties)
|
||||||
if ((res = spa_handle_get_interface(impl->loop_handle,
|
if ((res = spa_handle_get_interface(impl->loop_handle,
|
||||||
SPA_TYPE_INTERFACE_LoopControl,
|
SPA_TYPE_INTERFACE_LoopControl,
|
||||||
&iface)) < 0) {
|
&iface)) < 0) {
|
||||||
fprintf(stderr, "can't get LoopControl interface %d\n", res);
|
pw_log_error(NAME" %p: can't get LoopControl interface: %s",
|
||||||
|
this, spa_strerror(res));
|
||||||
goto error_unload_loop;
|
goto error_unload_loop;
|
||||||
}
|
}
|
||||||
this->control = iface;
|
this->control = iface;
|
||||||
|
|
@ -130,7 +134,8 @@ struct pw_loop *pw_loop_new(struct pw_properties *properties)
|
||||||
if ((res = spa_handle_get_interface(impl->loop_handle,
|
if ((res = spa_handle_get_interface(impl->loop_handle,
|
||||||
SPA_TYPE_INTERFACE_LoopUtils,
|
SPA_TYPE_INTERFACE_LoopUtils,
|
||||||
&iface)) < 0) {
|
&iface)) < 0) {
|
||||||
fprintf(stderr, "can't get LoopUtils interface %d\n", res);
|
pw_log_error(NAME" %p: can't get LoopUtils interface: %s",
|
||||||
|
this, spa_strerror(res));
|
||||||
goto error_unload_loop;
|
goto error_unload_loop;
|
||||||
}
|
}
|
||||||
this->utils = iface;
|
this->utils = iface;
|
||||||
|
|
|
||||||
|
|
@ -26,10 +26,12 @@
|
||||||
#include "pipewire/main-loop.h"
|
#include "pipewire/main-loop.h"
|
||||||
#include "pipewire/private.h"
|
#include "pipewire/private.h"
|
||||||
|
|
||||||
|
#define NAME "main-loop"
|
||||||
|
|
||||||
static void do_stop(void *data, uint64_t count)
|
static void do_stop(void *data, uint64_t count)
|
||||||
{
|
{
|
||||||
struct pw_main_loop *this = data;
|
struct pw_main_loop *this = data;
|
||||||
pw_log_debug("main-loop %p: do stop", this);
|
pw_log_debug(NAME" %p: do stop", this);
|
||||||
this->running = false;
|
this->running = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -50,7 +52,7 @@ struct pw_main_loop *pw_main_loop_new(struct pw_properties *properties)
|
||||||
goto error_cleanup;
|
goto error_cleanup;
|
||||||
}
|
}
|
||||||
|
|
||||||
pw_log_debug("main-loop %p: new", this);
|
pw_log_debug(NAME" %p: new", this);
|
||||||
|
|
||||||
this->loop = pw_loop_new(properties);
|
this->loop = pw_loop_new(properties);
|
||||||
properties = NULL;
|
properties = NULL;
|
||||||
|
|
@ -88,7 +90,7 @@ error_cleanup:
|
||||||
SPA_EXPORT
|
SPA_EXPORT
|
||||||
void pw_main_loop_destroy(struct pw_main_loop *loop)
|
void pw_main_loop_destroy(struct pw_main_loop *loop)
|
||||||
{
|
{
|
||||||
pw_log_debug("main-loop %p: destroy", loop);
|
pw_log_debug(NAME" %p: destroy", loop);
|
||||||
pw_main_loop_emit_destroy(loop);
|
pw_main_loop_emit_destroy(loop);
|
||||||
|
|
||||||
pw_loop_destroy(loop->loop);
|
pw_loop_destroy(loop->loop);
|
||||||
|
|
@ -121,7 +123,7 @@ struct pw_loop * pw_main_loop_get_loop(struct pw_main_loop *loop)
|
||||||
SPA_EXPORT
|
SPA_EXPORT
|
||||||
int pw_main_loop_quit(struct pw_main_loop *loop)
|
int pw_main_loop_quit(struct pw_main_loop *loop)
|
||||||
{
|
{
|
||||||
pw_log_debug("main-loop %p: quit", loop);
|
pw_log_debug(NAME" %p: quit", loop);
|
||||||
return pw_loop_signal_event(loop->loop, loop->event);
|
return pw_loop_signal_event(loop->loop, loop->event);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -138,13 +140,13 @@ int pw_main_loop_run(struct pw_main_loop *loop)
|
||||||
{
|
{
|
||||||
int res = 0;
|
int res = 0;
|
||||||
|
|
||||||
pw_log_debug("main-loop %p: run", loop);
|
pw_log_debug(NAME" %p: run", loop);
|
||||||
|
|
||||||
loop->running = true;
|
loop->running = true;
|
||||||
pw_loop_enter(loop->loop);
|
pw_loop_enter(loop->loop);
|
||||||
while (loop->running) {
|
while (loop->running) {
|
||||||
if ((res = pw_loop_iterate(loop->loop, -1)) < 0)
|
if ((res = pw_loop_iterate(loop->loop, -1)) < 0)
|
||||||
pw_log_warn("main-loop %p: iterate error %d (%s)",
|
pw_log_warn(NAME" %p: iterate error %d (%s)",
|
||||||
loop, res, spa_strerror(res));
|
loop, res, spa_strerror(res));
|
||||||
}
|
}
|
||||||
pw_loop_leave(loop->loop);
|
pw_loop_leave(loop->loop);
|
||||||
|
|
|
||||||
|
|
@ -41,6 +41,8 @@
|
||||||
#include <pipewire/map.h>
|
#include <pipewire/map.h>
|
||||||
#include <pipewire/mem.h>
|
#include <pipewire/mem.h>
|
||||||
|
|
||||||
|
#define NAME "mempool"
|
||||||
|
|
||||||
#define USE_MEMFD
|
#define USE_MEMFD
|
||||||
|
|
||||||
#ifndef HAVE_MEMFD_CREATE
|
#ifndef HAVE_MEMFD_CREATE
|
||||||
|
|
@ -140,7 +142,7 @@ struct pw_mempool *pw_mempool_new(struct pw_properties *props)
|
||||||
|
|
||||||
impl->pagesize = sysconf(_SC_PAGESIZE);
|
impl->pagesize = sysconf(_SC_PAGESIZE);
|
||||||
|
|
||||||
pw_log_debug("mempool %p: new", this);
|
pw_log_debug(NAME" %p: new", this);
|
||||||
|
|
||||||
spa_hook_list_init(&impl->listener_list);
|
spa_hook_list_init(&impl->listener_list);
|
||||||
pw_map_init(&impl->map, 64, 64);
|
pw_map_init(&impl->map, 64, 64);
|
||||||
|
|
@ -156,7 +158,7 @@ void pw_mempool_destroy(struct pw_mempool *pool)
|
||||||
struct mempool *impl = SPA_CONTAINER_OF(pool, struct mempool, this);
|
struct mempool *impl = SPA_CONTAINER_OF(pool, struct mempool, this);
|
||||||
struct memblock *b;
|
struct memblock *b;
|
||||||
|
|
||||||
pw_log_debug("mempool %p: destroy", pool);
|
pw_log_debug(NAME" %p: destroy", pool);
|
||||||
|
|
||||||
pw_mempool_emit_destroy(impl);
|
pw_mempool_emit_destroy(impl);
|
||||||
|
|
||||||
|
|
@ -235,7 +237,7 @@ int pw_memblock_map_old(struct pw_memblock *mem)
|
||||||
mem->ptr = NULL;
|
mem->ptr = NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
pw_log_debug("mem %p: map to %p", mem, mem->ptr);
|
pw_log_debug(NAME" %p: map to %p", mem, mem->ptr);
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
@ -249,7 +251,7 @@ static struct mapping * memblock_find_mapping(struct memblock *b,
|
||||||
|
|
||||||
spa_list_for_each(m, &b->mappings, link) {
|
spa_list_for_each(m, &b->mappings, link) {
|
||||||
if (m->offset <= offset && (m->offset + m->size) >= (offset + size)) {
|
if (m->offset <= offset && (m->offset + m->size) >= (offset + size)) {
|
||||||
pw_log_debug("pool %p: found %p id:%d fd:%d offs:%d size:%d ref:%d",
|
pw_log_debug(NAME" %p: found %p id:%d fd:%d offs:%d size:%d ref:%d",
|
||||||
pool, &b->this, b->this.id, b->this.fd,
|
pool, &b->this, b->this.id, b->this.fd,
|
||||||
offset, size, b->this.ref);
|
offset, size, b->this.ref);
|
||||||
return m;
|
return m;
|
||||||
|
|
@ -272,7 +274,7 @@ static struct mapping * memblock_map(struct memblock *b,
|
||||||
prot |= PROT_WRITE;
|
prot |= PROT_WRITE;
|
||||||
|
|
||||||
if (flags & PW_MEMMAP_FLAG_TWICE) {
|
if (flags & PW_MEMMAP_FLAG_TWICE) {
|
||||||
pw_log_error("pool %p: implement me PW_MEMMAP_FLAG_TWICE", p);
|
pw_log_error(NAME" %p: implement me PW_MEMMAP_FLAG_TWICE", p);
|
||||||
errno = ENOTSUP;
|
errno = ENOTSUP;
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
@ -280,7 +282,7 @@ static struct mapping * memblock_map(struct memblock *b,
|
||||||
|
|
||||||
ptr = mmap(NULL, size, prot, MAP_SHARED, b->this.fd, offset);
|
ptr = mmap(NULL, size, prot, MAP_SHARED, b->this.fd, offset);
|
||||||
if (ptr == MAP_FAILED) {
|
if (ptr == MAP_FAILED) {
|
||||||
pw_log_error("pool %p: Failed to mmap memory fd:%d offset:%u size:%u: %m",
|
pw_log_error(NAME" %p: Failed to mmap memory fd:%d offset:%u size:%u: %m",
|
||||||
p, b->this.fd, offset, size);
|
p, b->this.fd, offset, size);
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
@ -298,7 +300,7 @@ static struct mapping * memblock_map(struct memblock *b,
|
||||||
b->this.ref++;
|
b->this.ref++;
|
||||||
spa_list_append(&b->mappings, &m->link);
|
spa_list_append(&b->mappings, &m->link);
|
||||||
|
|
||||||
pw_log_debug("pool %p: fd:%d map:%p ptr:%p (%d %d)", p,
|
pw_log_debug(NAME" %p: fd:%d map:%p ptr:%p (%d %d)", p,
|
||||||
b->this.fd, m, m->ptr, offset, size);
|
b->this.fd, m, m->ptr, offset, size);
|
||||||
|
|
||||||
return m;
|
return m;
|
||||||
|
|
@ -309,7 +311,7 @@ static void mapping_unmap(struct mapping *m)
|
||||||
struct memblock *b = m->block;
|
struct memblock *b = m->block;
|
||||||
struct mempool *p = SPA_CONTAINER_OF(b->this.pool, struct mempool, this);
|
struct mempool *p = SPA_CONTAINER_OF(b->this.pool, struct mempool, this);
|
||||||
|
|
||||||
pw_log_debug("pool %p: mapping:%p fd:%d ptr:%p size:%d block-ref:%d",
|
pw_log_debug(NAME" %p: mapping:%p fd:%d ptr:%p size:%d block-ref:%d",
|
||||||
p, m, b->this.fd, m->ptr, m->size, b->this.ref);
|
p, m, b->this.fd, m->ptr, m->size, b->this.ref);
|
||||||
|
|
||||||
if (m->do_unmap)
|
if (m->do_unmap)
|
||||||
|
|
@ -357,7 +359,7 @@ struct pw_memmap * pw_memblock_map(struct pw_memblock *block,
|
||||||
|
|
||||||
spa_list_append(&b->maps, &mm->link);
|
spa_list_append(&b->maps, &mm->link);
|
||||||
|
|
||||||
pw_log_debug("pool %p: map:%p fd:%d ptr:%p (%d %d) mapping:%p ref:%d", p,
|
pw_log_debug(NAME" %p: map:%p fd:%d ptr:%p (%d %d) mapping:%p ref:%d", p,
|
||||||
&mm->this, b->this.fd, mm->this.ptr, offset, size, m, m->ref);
|
&mm->this, b->this.fd, mm->this.ptr, offset, size, m, m->ref);
|
||||||
|
|
||||||
return &mm->this;
|
return &mm->this;
|
||||||
|
|
@ -386,7 +388,7 @@ int pw_memmap_free(struct pw_memmap *map)
|
||||||
struct memblock *b = m->block;
|
struct memblock *b = m->block;
|
||||||
struct mempool *p = SPA_CONTAINER_OF(b->this.pool, struct mempool, this);
|
struct mempool *p = SPA_CONTAINER_OF(b->this.pool, struct mempool, this);
|
||||||
|
|
||||||
pw_log_debug("pool %p: map:%p fd:%d ptr:%p mapping:%p ref:%d", p,
|
pw_log_debug(NAME" %p: map:%p fd:%d ptr:%p mapping:%p ref:%d", p,
|
||||||
&mm->this, b->this.fd, mm->this.ptr, m, m->ref);
|
&mm->this, b->this.fd, mm->this.ptr, m, m->ref);
|
||||||
|
|
||||||
spa_list_remove(&mm->link);
|
spa_list_remove(&mm->link);
|
||||||
|
|
@ -443,7 +445,7 @@ struct pw_memblock * pw_mempool_alloc(struct pw_mempool *pool, enum pw_memblock_
|
||||||
b->this.fd = memfd_create("pipewire-memfd", MFD_CLOEXEC | MFD_ALLOW_SEALING);
|
b->this.fd = memfd_create("pipewire-memfd", MFD_CLOEXEC | MFD_ALLOW_SEALING);
|
||||||
if (b->this.fd == -1) {
|
if (b->this.fd == -1) {
|
||||||
res = -errno;
|
res = -errno;
|
||||||
pw_log_error("Failed to create memfd: %m");
|
pw_log_error(NAME" %p: Failed to create memfd: %m", pool);
|
||||||
goto error_free;
|
goto error_free;
|
||||||
}
|
}
|
||||||
#else
|
#else
|
||||||
|
|
@ -451,7 +453,7 @@ struct pw_memblock * pw_mempool_alloc(struct pw_mempool *pool, enum pw_memblock_
|
||||||
b->this.fd = mkostemp(filename, O_CLOEXEC);
|
b->this.fd = mkostemp(filename, O_CLOEXEC);
|
||||||
if (b->this.fd == -1) {
|
if (b->this.fd == -1) {
|
||||||
res = -errno;
|
res = -errno;
|
||||||
pw_log_error("Failed to create temporary file: %m");
|
pw_log_error(NAME" %p: Failed to create temporary file: %m", pool);
|
||||||
goto error_free;
|
goto error_free;
|
||||||
}
|
}
|
||||||
unlink(filename);
|
unlink(filename);
|
||||||
|
|
@ -459,14 +461,14 @@ struct pw_memblock * pw_mempool_alloc(struct pw_mempool *pool, enum pw_memblock_
|
||||||
|
|
||||||
if (ftruncate(b->this.fd, size) < 0) {
|
if (ftruncate(b->this.fd, size) < 0) {
|
||||||
res = -errno;
|
res = -errno;
|
||||||
pw_log_warn("Failed to truncate temporary file: %m");
|
pw_log_warn(NAME" %p: Failed to truncate temporary file: %m", pool);
|
||||||
goto error_close;
|
goto error_close;
|
||||||
}
|
}
|
||||||
#ifdef USE_MEMFD
|
#ifdef USE_MEMFD
|
||||||
if (flags & PW_MEMBLOCK_FLAG_SEAL) {
|
if (flags & PW_MEMBLOCK_FLAG_SEAL) {
|
||||||
unsigned int seals = F_SEAL_GROW | F_SEAL_SHRINK | F_SEAL_SEAL;
|
unsigned int seals = F_SEAL_GROW | F_SEAL_SHRINK | F_SEAL_SEAL;
|
||||||
if (fcntl(b->this.fd, F_ADD_SEALS, seals) == -1) {
|
if (fcntl(b->this.fd, F_ADD_SEALS, seals) == -1) {
|
||||||
pw_log_warn("Failed to add seals: %m");
|
pw_log_warn(NAME" %p: Failed to add seals: %m", pool);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
@ -475,7 +477,7 @@ struct pw_memblock * pw_mempool_alloc(struct pw_mempool *pool, enum pw_memblock_
|
||||||
block_flags_to_mem(flags), 0, size, NULL);
|
block_flags_to_mem(flags), 0, size, NULL);
|
||||||
if (b->this.map == NULL) {
|
if (b->this.map == NULL) {
|
||||||
res = -errno;
|
res = -errno;
|
||||||
pw_log_warn("Failed to map: %m");
|
pw_log_warn(NAME" %p: Failed to map: %m", pool);
|
||||||
goto error_close;
|
goto error_close;
|
||||||
}
|
}
|
||||||
b->this.ref--;
|
b->this.ref--;
|
||||||
|
|
@ -483,7 +485,7 @@ struct pw_memblock * pw_mempool_alloc(struct pw_mempool *pool, enum pw_memblock_
|
||||||
|
|
||||||
b->this.id = pw_map_insert_new(&impl->map, b);
|
b->this.id = pw_map_insert_new(&impl->map, b);
|
||||||
spa_list_append(&impl->blocks, &b->link);
|
spa_list_append(&impl->blocks, &b->link);
|
||||||
pw_log_debug("pool %p: mem %p alloc id:%d type:%u", pool, &b->this, b->this.id, type);
|
pw_log_debug(NAME" %p: mem %p alloc id:%d type:%u", pool, &b->this, b->this.id, type);
|
||||||
|
|
||||||
pw_mempool_emit_added(impl, &b->this);
|
pw_mempool_emit_added(impl, &b->this);
|
||||||
|
|
||||||
|
|
@ -504,7 +506,7 @@ static struct memblock * mempool_find_fd(struct pw_mempool *pool, int fd)
|
||||||
|
|
||||||
spa_list_for_each(b, &impl->blocks, link) {
|
spa_list_for_each(b, &impl->blocks, link) {
|
||||||
if (fd == b->this.fd) {
|
if (fd == b->this.fd) {
|
||||||
pw_log_debug("pool %p: found %p id:%d fd:%d ref:%d",
|
pw_log_debug(NAME" %p: found %p id:%d fd:%d ref:%d",
|
||||||
pool, &b->this, b->this.id, fd, b->this.ref);
|
pool, &b->this, b->this.id, fd, b->this.ref);
|
||||||
return b;
|
return b;
|
||||||
}
|
}
|
||||||
|
|
@ -540,7 +542,7 @@ struct pw_memblock * pw_mempool_import(struct pw_mempool *pool,
|
||||||
b->this.id = pw_map_insert_new(&impl->map, b);
|
b->this.id = pw_map_insert_new(&impl->map, b);
|
||||||
spa_list_append(&impl->blocks, &b->link);
|
spa_list_append(&impl->blocks, &b->link);
|
||||||
|
|
||||||
pw_log_debug("pool %p: import %p id:%u flags:%08x type:%u fd:%d",
|
pw_log_debug(NAME" %p: import %p id:%u flags:%08x type:%u fd:%d",
|
||||||
pool, b, b->this.id, flags, type, fd);
|
pool, b, b->this.id, flags, type, fd);
|
||||||
|
|
||||||
pw_mempool_emit_added(impl, &b->this);
|
pw_mempool_emit_added(impl, &b->this);
|
||||||
|
|
@ -632,7 +634,7 @@ void pw_memblock_free(struct pw_memblock *block)
|
||||||
|
|
||||||
spa_return_if_fail(block != NULL);
|
spa_return_if_fail(block != NULL);
|
||||||
|
|
||||||
pw_log_debug("pool %p: free mem %p id:%d fd:%d ref:%d",
|
pw_log_debug(NAME" %p: free mem %p id:%d fd:%d ref:%d",
|
||||||
pool, block, block->id, block->fd, block->ref);
|
pool, block, block->id, block->fd, block->ref);
|
||||||
|
|
||||||
block->ref++;
|
block->ref++;
|
||||||
|
|
@ -648,7 +650,7 @@ void pw_memblock_free(struct pw_memblock *block)
|
||||||
pw_memmap_free(&mm->this);
|
pw_memmap_free(&mm->this);
|
||||||
|
|
||||||
if (block->fd != -1 && !(block->flags & PW_MEMBLOCK_FLAG_DONT_CLOSE)) {
|
if (block->fd != -1 && !(block->flags & PW_MEMBLOCK_FLAG_DONT_CLOSE)) {
|
||||||
pw_log_debug("pool %p: close fd:%d", pool, block->fd);
|
pw_log_debug(NAME" %p: close fd:%d", pool, block->fd);
|
||||||
close(block->fd);
|
close(block->fd);
|
||||||
}
|
}
|
||||||
free(b);
|
free(b);
|
||||||
|
|
@ -664,7 +666,7 @@ struct pw_memblock * pw_mempool_find_ptr(struct pw_mempool *pool, const void *pt
|
||||||
spa_list_for_each(b, &impl->blocks, link) {
|
spa_list_for_each(b, &impl->blocks, link) {
|
||||||
spa_list_for_each(m, &b->mappings, link) {
|
spa_list_for_each(m, &b->mappings, link) {
|
||||||
if (ptr >= m->ptr && ptr < SPA_MEMBER(m->ptr, m->size, void)) {
|
if (ptr >= m->ptr && ptr < SPA_MEMBER(m->ptr, m->size, void)) {
|
||||||
pw_log_debug("pool %p: found %p id:%d for %p", pool,
|
pw_log_debug(NAME" %p: found %p id:%d for %p", pool,
|
||||||
m->block, b->this.id, ptr);
|
m->block, b->this.id, ptr);
|
||||||
return &b->this;
|
return &b->this;
|
||||||
}
|
}
|
||||||
|
|
@ -680,7 +682,7 @@ struct pw_memblock * pw_mempool_find_id(struct pw_mempool *pool, uint32_t id)
|
||||||
struct memblock *b;
|
struct memblock *b;
|
||||||
|
|
||||||
b = pw_map_lookup(&impl->map, id);
|
b = pw_map_lookup(&impl->map, id);
|
||||||
pw_log_debug("pool %p: found %p for %d", pool, b, id);
|
pw_log_debug(NAME" %p: found %p for %d", pool, b, id);
|
||||||
if (b == NULL)
|
if (b == NULL)
|
||||||
return NULL;
|
return NULL;
|
||||||
|
|
||||||
|
|
@ -706,12 +708,12 @@ struct pw_memmap * pw_mempool_find_tag(struct pw_mempool *pool, uint32_t tag[5],
|
||||||
struct memblock *b;
|
struct memblock *b;
|
||||||
struct memmap *mm;
|
struct memmap *mm;
|
||||||
|
|
||||||
pw_log_debug("pool %p: find tag %zd", pool, size);
|
pw_log_debug(NAME" %p: find tag %zd", pool, size);
|
||||||
|
|
||||||
spa_list_for_each(b, &impl->blocks, link) {
|
spa_list_for_each(b, &impl->blocks, link) {
|
||||||
spa_list_for_each(mm, &b->maps, link) {
|
spa_list_for_each(mm, &b->maps, link) {
|
||||||
if (memcmp(tag, mm->this.tag, size) == 0) {
|
if (memcmp(tag, mm->this.tag, size) == 0) {
|
||||||
pw_log_debug("pool %p: found %p", pool, mm);
|
pw_log_debug(NAME" %p: found %p", pool, mm);
|
||||||
return &mm->this;
|
return &mm->this;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -45,6 +45,8 @@
|
||||||
#include "pipewire/type.h"
|
#include "pipewire/type.h"
|
||||||
#include "pipewire/work-queue.h"
|
#include "pipewire/work-queue.h"
|
||||||
|
|
||||||
|
#define NAME "node"
|
||||||
|
|
||||||
/** \cond */
|
/** \cond */
|
||||||
struct impl {
|
struct impl {
|
||||||
struct pw_node this;
|
struct pw_node this;
|
||||||
|
|
@ -83,7 +85,7 @@ static void node_deactivate(struct pw_node *this)
|
||||||
struct pw_port *port;
|
struct pw_port *port;
|
||||||
struct pw_link *link;
|
struct pw_link *link;
|
||||||
|
|
||||||
pw_log_debug("node %p: deactivate", this);
|
pw_log_debug(NAME" %p: deactivate", this);
|
||||||
spa_list_for_each(port, &this->input_ports, link) {
|
spa_list_for_each(port, &this->input_ports, link) {
|
||||||
spa_list_for_each(link, &port->links, input_link)
|
spa_list_for_each(link, &port->links, input_link)
|
||||||
pw_link_deactivate(link);
|
pw_link_deactivate(link);
|
||||||
|
|
@ -101,7 +103,7 @@ static void add_node(struct pw_node *this, struct pw_node *driver)
|
||||||
if (this->exported)
|
if (this->exported)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
pw_log_trace("node %p: add to driver %p %p %p", this, driver,
|
pw_log_trace(NAME" %p: add to driver %p %p %p", this, driver,
|
||||||
driver->rt.activation, this->rt.activation);
|
driver->rt.activation, this->rt.activation);
|
||||||
/* signal the driver */
|
/* signal the driver */
|
||||||
this->rt.driver_target.activation = driver->rt.activation;
|
this->rt.driver_target.activation = driver->rt.activation;
|
||||||
|
|
@ -113,7 +115,7 @@ static void add_node(struct pw_node *this, struct pw_node *driver)
|
||||||
spa_list_append(&driver->rt.target_list, &this->rt.target.link);
|
spa_list_append(&driver->rt.target_list, &this->rt.target.link);
|
||||||
rnode = ++this->rt.activation->state[0].required;
|
rnode = ++this->rt.activation->state[0].required;
|
||||||
|
|
||||||
pw_log_trace("node %p: required driver:%d node:%d", this, rdriver, rnode);
|
pw_log_trace(NAME" %p: required driver:%d node:%d", this, rdriver, rnode);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void remove_node(struct pw_node *this)
|
static void remove_node(struct pw_node *this)
|
||||||
|
|
@ -123,7 +125,7 @@ static void remove_node(struct pw_node *this)
|
||||||
if (this->exported)
|
if (this->exported)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
pw_log_trace("node %p: remove from driver %p %p %p",
|
pw_log_trace(NAME" %p: remove from driver %p %p %p",
|
||||||
this, this->rt.driver_target.data,
|
this, this->rt.driver_target.data,
|
||||||
this->rt.driver_target.activation, this->rt.activation);
|
this->rt.driver_target.activation, this->rt.activation);
|
||||||
|
|
||||||
|
|
@ -133,7 +135,7 @@ static void remove_node(struct pw_node *this)
|
||||||
spa_list_remove(&this->rt.target.link);
|
spa_list_remove(&this->rt.target.link);
|
||||||
rnode = --this->rt.activation->state[0].required;
|
rnode = --this->rt.activation->state[0].required;
|
||||||
|
|
||||||
pw_log_trace("node %p: required driver:%d node:%d", this, rdriver, rnode);
|
pw_log_trace(NAME" %p: required driver:%d node:%d", this, rdriver, rnode);
|
||||||
}
|
}
|
||||||
|
|
||||||
static int
|
static int
|
||||||
|
|
@ -153,7 +155,7 @@ static int pause_node(struct pw_node *this)
|
||||||
struct impl *impl = SPA_CONTAINER_OF(this, struct impl, this);
|
struct impl *impl = SPA_CONTAINER_OF(this, struct impl, this);
|
||||||
int res = 0;
|
int res = 0;
|
||||||
|
|
||||||
pw_log_debug("node %p: pause node state:%s", this,
|
pw_log_debug(NAME" %p: pause node state:%s", this,
|
||||||
pw_node_state_as_string(this->info.state));
|
pw_node_state_as_string(this->info.state));
|
||||||
|
|
||||||
if (this->info.state <= PW_NODE_STATE_IDLE && impl->pause_on_idle)
|
if (this->info.state <= PW_NODE_STATE_IDLE && impl->pause_on_idle)
|
||||||
|
|
@ -166,7 +168,7 @@ static int pause_node(struct pw_node *this)
|
||||||
res = spa_node_send_command(this->node,
|
res = spa_node_send_command(this->node,
|
||||||
&SPA_NODE_COMMAND_INIT(SPA_NODE_COMMAND_Pause));
|
&SPA_NODE_COMMAND_INIT(SPA_NODE_COMMAND_Pause));
|
||||||
if (res < 0)
|
if (res < 0)
|
||||||
pw_log_debug("node %p: pause node error %s", this, spa_strerror(res));
|
pw_log_debug(NAME" %p: pause node error %s", this, spa_strerror(res));
|
||||||
|
|
||||||
return res;
|
return res;
|
||||||
}
|
}
|
||||||
|
|
@ -192,7 +194,7 @@ static int start_node(struct pw_node *this)
|
||||||
if (this->info.state >= PW_NODE_STATE_RUNNING)
|
if (this->info.state >= PW_NODE_STATE_RUNNING)
|
||||||
return 0;
|
return 0;
|
||||||
|
|
||||||
pw_log_debug("node %p: start node %d %d %d %d", this, this->n_ready_output_links,
|
pw_log_debug(NAME" %p: start node %d %d %d %d", this, this->n_ready_output_links,
|
||||||
this->n_used_output_links, this->n_ready_input_links,
|
this->n_used_output_links, this->n_ready_input_links,
|
||||||
this->n_used_input_links);
|
this->n_used_input_links);
|
||||||
|
|
||||||
|
|
@ -204,7 +206,7 @@ static int start_node(struct pw_node *this)
|
||||||
&SPA_NODE_COMMAND_INIT(SPA_NODE_COMMAND_Start));
|
&SPA_NODE_COMMAND_INIT(SPA_NODE_COMMAND_Start));
|
||||||
|
|
||||||
if (res < 0)
|
if (res < 0)
|
||||||
pw_log_error("node %p: start node error %d: %s",
|
pw_log_error(NAME" %p: start node error %d: %s",
|
||||||
this, res, spa_strerror(res));
|
this, res, spa_strerror(res));
|
||||||
|
|
||||||
return res;
|
return res;
|
||||||
|
|
@ -248,7 +250,7 @@ static int notify_param(void *data, int seq, uint32_t id,
|
||||||
if (!resource_is_subscribed(resource, id))
|
if (!resource_is_subscribed(resource, id))
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
pw_log_debug("resource %p: notify param %d", resource, id);
|
pw_log_debug(NAME" %p: resource %p notify param %d", node, resource, id);
|
||||||
pw_node_resource_param(resource, seq, id, index, next, param);
|
pw_node_resource_param(resource, seq, id, index, next, param);
|
||||||
}
|
}
|
||||||
return 0;
|
return 0;
|
||||||
|
|
@ -262,7 +264,7 @@ static void emit_params(struct pw_node *node, uint32_t *changed_ids, uint32_t n_
|
||||||
if (node->global == NULL)
|
if (node->global == NULL)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
pw_log_debug("node %p: emit %d params", node, n_changed_ids);
|
pw_log_debug(NAME" %p: emit %d params", node, n_changed_ids);
|
||||||
|
|
||||||
for (i = 0; i < n_changed_ids; i++) {
|
for (i = 0; i < n_changed_ids; i++) {
|
||||||
struct pw_resource *resource;
|
struct pw_resource *resource;
|
||||||
|
|
@ -278,7 +280,7 @@ static void emit_params(struct pw_node *node, uint32_t *changed_ids, uint32_t n_
|
||||||
|
|
||||||
if ((res = pw_node_for_each_param(node, 1, changed_ids[i], 0, UINT32_MAX,
|
if ((res = pw_node_for_each_param(node, 1, changed_ids[i], 0, UINT32_MAX,
|
||||||
NULL, notify_param, node)) < 0) {
|
NULL, notify_param, node)) < 0) {
|
||||||
pw_log_error("node %p: error %d (%s)", node, res, spa_strerror(res));
|
pw_log_error(NAME" %p: error %d (%s)", node, res, spa_strerror(res));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -292,10 +294,10 @@ static void node_update_state(struct pw_node *node, enum pw_node_state state, ch
|
||||||
return;
|
return;
|
||||||
|
|
||||||
if (state == PW_NODE_STATE_ERROR) {
|
if (state == PW_NODE_STATE_ERROR) {
|
||||||
pw_log_error("node %p: update state from %s -> error (%s)", node,
|
pw_log_error(NAME" %p: update state from %s -> error (%s)", node,
|
||||||
pw_node_state_as_string(old), error);
|
pw_node_state_as_string(old), error);
|
||||||
} else {
|
} else {
|
||||||
pw_log_debug("node %p: update state from %s -> %s", node,
|
pw_log_debug(NAME" %p: update state from %s -> %s", node,
|
||||||
pw_node_state_as_string(old), pw_node_state_as_string(state));
|
pw_node_state_as_string(old), pw_node_state_as_string(state));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -322,21 +324,23 @@ static int suspend_node(struct pw_node *this)
|
||||||
int res = 0;
|
int res = 0;
|
||||||
struct pw_port *p;
|
struct pw_port *p;
|
||||||
|
|
||||||
pw_log_debug("node %p: suspend node state:%s", this,
|
pw_log_debug(NAME" %p: suspend node state:%s", this,
|
||||||
pw_node_state_as_string(this->info.state));
|
pw_node_state_as_string(this->info.state));
|
||||||
|
|
||||||
pause_node(this);
|
pause_node(this);
|
||||||
|
|
||||||
spa_list_for_each(p, &this->input_ports, link) {
|
spa_list_for_each(p, &this->input_ports, link) {
|
||||||
if ((res = pw_port_set_param(p, SPA_PARAM_Format, 0, NULL)) < 0)
|
if ((res = pw_port_set_param(p, SPA_PARAM_Format, 0, NULL)) < 0)
|
||||||
pw_log_warn("error unset format input: %s", spa_strerror(res));
|
pw_log_warn(NAME" %p: error unset format input: %s",
|
||||||
|
this, spa_strerror(res));
|
||||||
/* force CONFIGURE in case of async */
|
/* force CONFIGURE in case of async */
|
||||||
p->state = PW_PORT_STATE_CONFIGURE;
|
p->state = PW_PORT_STATE_CONFIGURE;
|
||||||
}
|
}
|
||||||
|
|
||||||
spa_list_for_each(p, &this->output_ports, link) {
|
spa_list_for_each(p, &this->output_ports, link) {
|
||||||
if ((res = pw_port_set_param(p, SPA_PARAM_Format, 0, NULL)) < 0)
|
if ((res = pw_port_set_param(p, SPA_PARAM_Format, 0, NULL)) < 0)
|
||||||
pw_log_warn("error unset format output: %s", spa_strerror(res));
|
pw_log_warn(NAME" %p: error unset format output: %s",
|
||||||
|
this, spa_strerror(res));
|
||||||
/* force CONFIGURE in case of async */
|
/* force CONFIGURE in case of async */
|
||||||
p->state = PW_PORT_STATE_CONFIGURE;
|
p->state = PW_PORT_STATE_CONFIGURE;
|
||||||
}
|
}
|
||||||
|
|
@ -366,7 +370,7 @@ static int reply_param(void *data, int seq, uint32_t id,
|
||||||
uint32_t index, uint32_t next, struct spa_pod *param)
|
uint32_t index, uint32_t next, struct spa_pod *param)
|
||||||
{
|
{
|
||||||
struct resource_data *d = data;
|
struct resource_data *d = data;
|
||||||
pw_log_debug("resource %p: reply param %d", d->resource, seq);
|
pw_log_debug(NAME" %p: resource %p reply param %d", d->node, d->resource, seq);
|
||||||
pw_node_resource_param(d->resource, seq, id, index, next, param);
|
pw_node_resource_param(d->resource, seq, id, index, next, param);
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
@ -380,13 +384,14 @@ static int node_enum_params(void *object, int seq, uint32_t id,
|
||||||
struct pw_client *client = resource->client;
|
struct pw_client *client = resource->client;
|
||||||
int res;
|
int res;
|
||||||
|
|
||||||
pw_log_debug("resource %p: enum params %d %s %u %u", resource, seq,
|
pw_log_debug(NAME" %p: resource %p enum params %d %s %u %u",
|
||||||
|
node, resource, seq,
|
||||||
spa_debug_type_find_name(spa_type_param, id), index, num);
|
spa_debug_type_find_name(spa_type_param, id), index, num);
|
||||||
|
|
||||||
if ((res = pw_node_for_each_param(node, seq, id, index, num,
|
if ((res = pw_node_for_each_param(node, seq, id, index, num,
|
||||||
filter, reply_param, data)) < 0) {
|
filter, reply_param, data)) < 0) {
|
||||||
pw_log_error("resource %p: %d error %d (%s)", resource,
|
pw_log_error(NAME" %p: resource %p %d error %d (%s)", node,
|
||||||
resource->id, res, spa_strerror(res));
|
resource, resource->id, res, spa_strerror(res));
|
||||||
pw_core_resource_errorf(client->core_resource,
|
pw_core_resource_errorf(client->core_resource,
|
||||||
resource->id, seq, res,
|
resource->id, seq, res,
|
||||||
"enum params %s failed",
|
"enum params %s failed",
|
||||||
|
|
@ -406,8 +411,9 @@ static int node_subscribe_params(void *object, uint32_t *ids, uint32_t n_ids)
|
||||||
|
|
||||||
for (i = 0; i < n_ids; i++) {
|
for (i = 0; i < n_ids; i++) {
|
||||||
data->subscribe_ids[i] = ids[i];
|
data->subscribe_ids[i] = ids[i];
|
||||||
pw_log_debug("resource %p: subscribe param %s", resource,
|
pw_log_debug(NAME" %p: resource %p subscribe param %s",
|
||||||
spa_debug_type_find_name(spa_type_param, ids[i]));
|
data->node, resource,
|
||||||
|
spa_debug_type_find_name(spa_type_param, ids[i]));
|
||||||
node_enum_params(resource, 1, ids[i], 0, UINT32_MAX, NULL);
|
node_enum_params(resource, 1, ids[i], 0, UINT32_MAX, NULL);
|
||||||
}
|
}
|
||||||
return 0;
|
return 0;
|
||||||
|
|
@ -417,7 +423,7 @@ static void result_node_sync(void *data, int seq, int res, uint32_t type, const
|
||||||
{
|
{
|
||||||
struct resource_data *d = data;
|
struct resource_data *d = data;
|
||||||
|
|
||||||
pw_log_debug("sync result %d %d (%d/%d)", res, seq, d->seq, d->end);
|
pw_log_debug(NAME" %p: sync result %d %d (%d/%d)", d->node, res, seq, d->seq, d->end);
|
||||||
if (seq == d->end) {
|
if (seq == d->end) {
|
||||||
spa_hook_remove(&d->listener);
|
spa_hook_remove(&d->listener);
|
||||||
d->end = -1;
|
d->end = -1;
|
||||||
|
|
@ -438,14 +444,14 @@ static int node_set_param(void *object, uint32_t id, uint32_t flags,
|
||||||
.result = result_node_sync,
|
.result = result_node_sync,
|
||||||
};
|
};
|
||||||
|
|
||||||
pw_log_debug("resource %p: set param %s %08x", resource,
|
pw_log_debug(NAME" %p: resource %p set param %s %08x", node, resource,
|
||||||
spa_debug_type_find_name(spa_type_param, id), flags);
|
spa_debug_type_find_name(spa_type_param, id), flags);
|
||||||
|
|
||||||
res = spa_node_set_param(node->node, id, flags, param);
|
res = spa_node_set_param(node->node, id, flags, param);
|
||||||
|
|
||||||
if (res < 0) {
|
if (res < 0) {
|
||||||
pw_log_error("resource %p: %d error %d (%s)", resource,
|
pw_log_error(NAME" %p: resource %p %d error %d (%s)", node,
|
||||||
resource->id, res, spa_strerror(res));
|
resource, resource->id, res, spa_strerror(res));
|
||||||
pw_resource_error(resource, res, spa_strerror(res));
|
pw_resource_error(resource, res, spa_strerror(res));
|
||||||
} else if (SPA_RESULT_IS_ASYNC(res)) {
|
} else if (SPA_RESULT_IS_ASYNC(res)) {
|
||||||
pw_client_set_busy(client, true);
|
pw_client_set_busy(client, true);
|
||||||
|
|
@ -508,7 +514,7 @@ global_bind(void *_data, struct pw_client *client, uint32_t permissions,
|
||||||
&data->object_listener,
|
&data->object_listener,
|
||||||
&node_methods, resource);
|
&node_methods, resource);
|
||||||
|
|
||||||
pw_log_debug("node %p: bound to %d", this, resource->id);
|
pw_log_debug(NAME" %p: bound to %d", this, resource->id);
|
||||||
|
|
||||||
spa_list_append(&global->resource_list, &resource->link);
|
spa_list_append(&global->resource_list, &resource->link);
|
||||||
|
|
||||||
|
|
@ -519,7 +525,7 @@ global_bind(void *_data, struct pw_client *client, uint32_t permissions,
|
||||||
return 0;
|
return 0;
|
||||||
|
|
||||||
error_resource:
|
error_resource:
|
||||||
pw_log_error("can't create node resource: %m");
|
pw_log_error(NAME" %p: can't create node resource: %m", this);
|
||||||
return -errno;
|
return -errno;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -546,7 +552,7 @@ int pw_node_register(struct pw_node *this,
|
||||||
struct pw_port *port;
|
struct pw_port *port;
|
||||||
const char *str;
|
const char *str;
|
||||||
|
|
||||||
pw_log_debug("node %p: register", this);
|
pw_log_debug(NAME" %p: register", this);
|
||||||
|
|
||||||
if (this->registered)
|
if (this->registered)
|
||||||
goto error_existed;
|
goto error_existed;
|
||||||
|
|
@ -605,7 +611,7 @@ error_existed:
|
||||||
SPA_EXPORT
|
SPA_EXPORT
|
||||||
int pw_node_initialized(struct pw_node *this)
|
int pw_node_initialized(struct pw_node *this)
|
||||||
{
|
{
|
||||||
pw_log_debug("node %p initialized", this);
|
pw_log_debug(NAME" %p initialized", this);
|
||||||
pw_node_emit_initialized(this);
|
pw_node_emit_initialized(this);
|
||||||
node_update_state(this, PW_NODE_STATE_SUSPENDED, NULL);
|
node_update_state(this, PW_NODE_STATE_SUSPENDED, NULL);
|
||||||
return 0;
|
return 0;
|
||||||
|
|
@ -619,7 +625,7 @@ do_move_nodes(struct spa_loop *loop,
|
||||||
struct pw_node *driver = *(struct pw_node **)data;
|
struct pw_node *driver = *(struct pw_node **)data;
|
||||||
struct pw_node *this = &src->this;
|
struct pw_node *this = &src->this;
|
||||||
|
|
||||||
pw_log_trace("node %p: driver:%p->%p", this, this->driver_node, driver);
|
pw_log_trace(NAME" %p: driver:%p->%p", this, this->driver_node, driver);
|
||||||
|
|
||||||
if (this->source.loop != NULL) {
|
if (this->source.loop != NULL) {
|
||||||
remove_node(this);
|
remove_node(this);
|
||||||
|
|
@ -645,7 +651,7 @@ int pw_node_set_driver(struct pw_node *node, struct pw_node *driver)
|
||||||
return 0;
|
return 0;
|
||||||
|
|
||||||
node->master = node->driver && driver == node;
|
node->master = node->driver && driver == node;
|
||||||
pw_log_info("node %p: driver %p master:%u", node, driver, node->master);
|
pw_log_info(NAME" %p: driver %p master:%u", node, driver, node->master);
|
||||||
|
|
||||||
node->driver_node = driver;
|
node->driver_node = driver;
|
||||||
|
|
||||||
|
|
@ -655,9 +661,9 @@ int pw_node_set_driver(struct pw_node *node, struct pw_node *driver)
|
||||||
SPA_IO_Position,
|
SPA_IO_Position,
|
||||||
&driver->rt.activation->position,
|
&driver->rt.activation->position,
|
||||||
sizeof(struct spa_io_position))) < 0) {
|
sizeof(struct spa_io_position))) < 0) {
|
||||||
pw_log_warn("node %p: set position %s", node, spa_strerror(res));
|
pw_log_warn(NAME" %p: set position %s", node, spa_strerror(res));
|
||||||
} else {
|
} else {
|
||||||
pw_log_trace("node %p: set position %p", node, &driver->rt.activation->position);
|
pw_log_trace(NAME" %p: set position %p", node, &driver->rt.activation->position);
|
||||||
node->rt.position = &driver->rt.activation->position;
|
node->rt.position = &driver->rt.activation->position;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -694,7 +700,7 @@ static void check_properties(struct pw_node *node)
|
||||||
driver = false;
|
driver = false;
|
||||||
|
|
||||||
if (node->driver != driver) {
|
if (node->driver != driver) {
|
||||||
pw_log_info("node %p: driver %d -> %d", node, node->driver, driver);
|
pw_log_info(NAME" %p: driver %d -> %d", node, node->driver, driver);
|
||||||
node->driver = driver;
|
node->driver = driver;
|
||||||
if (node->registered) {
|
if (node->registered) {
|
||||||
if (driver)
|
if (driver)
|
||||||
|
|
@ -706,15 +712,15 @@ static void check_properties(struct pw_node *node)
|
||||||
|
|
||||||
if ((str = pw_properties_get(node->properties, PW_KEY_NODE_LATENCY))) {
|
if ((str = pw_properties_get(node->properties, PW_KEY_NODE_LATENCY))) {
|
||||||
uint32_t num, denom;
|
uint32_t num, denom;
|
||||||
pw_log_info("node %p: latency '%s'", node, str);
|
pw_log_info(NAME" %p: latency '%s'", node, str);
|
||||||
if (sscanf(str, "%u/%u", &num, &denom) == 2 && denom != 0) {
|
if (sscanf(str, "%u/%u", &num, &denom) == 2 && denom != 0) {
|
||||||
node->quantum_size = flp2((num * 48000 / denom));
|
node->quantum_size = flp2((num * 48000 / denom));
|
||||||
pw_log_info("node %p: quantum %d", node, node->quantum_size);
|
pw_log_info(NAME" %p: quantum %d", node, node->quantum_size);
|
||||||
}
|
}
|
||||||
} else
|
} else
|
||||||
node->quantum_size = DEFAULT_QUANTUM;
|
node->quantum_size = DEFAULT_QUANTUM;
|
||||||
|
|
||||||
pw_log_debug("node %p: driver:%d", node, node->driver);
|
pw_log_debug(NAME" %p: driver:%d", node, node->driver);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -726,7 +732,7 @@ static void dump_states(struct pw_node *driver)
|
||||||
struct pw_node_activation *a = t->activation;
|
struct pw_node_activation *a = t->activation;
|
||||||
if (t->node == NULL)
|
if (t->node == NULL)
|
||||||
continue;
|
continue;
|
||||||
pw_log_warn("node %p (%s): pending:%d/%d s:%"PRIu64" a:%"PRIu64" f:%"PRIu64
|
pw_log_warn(NAME" %p (%s): pending:%d/%d s:%"PRIu64" a:%"PRIu64" f:%"PRIu64
|
||||||
" waiting:%"PRIu64" process:%"PRIu64" status:%d",
|
" waiting:%"PRIu64" process:%"PRIu64" status:%d",
|
||||||
t->node, t->node->info.name,
|
t->node, t->node->info.name,
|
||||||
a->state[0].pending, a->state[0].required,
|
a->state[0].pending, a->state[0].required,
|
||||||
|
|
@ -752,14 +758,14 @@ static inline int resume_node(struct pw_node *this, int status)
|
||||||
activation->status = FINISHED;
|
activation->status = FINISHED;
|
||||||
activation->finish_time = nsec;
|
activation->finish_time = nsec;
|
||||||
|
|
||||||
pw_log_trace_fp("node %p: trigger peers", this);
|
pw_log_trace_fp(NAME" %p: trigger peers", this);
|
||||||
|
|
||||||
spa_list_for_each(t, &this->rt.target_list, link) {
|
spa_list_for_each(t, &this->rt.target_list, link) {
|
||||||
struct pw_node_activation_state *state;
|
struct pw_node_activation_state *state;
|
||||||
|
|
||||||
state = &t->activation->state[0];
|
state = &t->activation->state[0];
|
||||||
|
|
||||||
pw_log_trace_fp("node %p: state %p pending %d/%d", t->node, state,
|
pw_log_trace_fp(NAME" %p: state %p pending %d/%d", t->node, state,
|
||||||
state->pending, state->required);
|
state->pending, state->required);
|
||||||
|
|
||||||
if (pw_node_activation_state_dec(state, 1)) {
|
if (pw_node_activation_state_dec(state, 1)) {
|
||||||
|
|
@ -780,7 +786,7 @@ static inline int process_node(void *data)
|
||||||
struct spa_system *data_system = this->core->data_system;
|
struct spa_system *data_system = this->core->data_system;
|
||||||
int status;
|
int status;
|
||||||
|
|
||||||
pw_log_trace_fp("node %p: process", this);
|
pw_log_trace_fp(NAME" %p: process", this);
|
||||||
|
|
||||||
spa_system_clock_gettime(data_system, CLOCK_MONOTONIC, &ts);
|
spa_system_clock_gettime(data_system, CLOCK_MONOTONIC, &ts);
|
||||||
a->status = AWAKE;
|
a->status = AWAKE;
|
||||||
|
|
@ -802,11 +808,11 @@ static inline int process_node(void *data)
|
||||||
a->status = FINISHED;
|
a->status = FINISHED;
|
||||||
a->signal_time = a->finish_time;
|
a->signal_time = a->finish_time;
|
||||||
a->finish_time = SPA_TIMESPEC_TO_NSEC(&ts);
|
a->finish_time = SPA_TIMESPEC_TO_NSEC(&ts);
|
||||||
pw_log_trace_fp("node %p: graph completed wait:%"PRIu64" run:%"PRIu64, this,
|
pw_log_trace_fp(NAME" %p: graph completed wait:%"PRIu64" run:%"PRIu64, this,
|
||||||
a->awake_time - a->signal_time,
|
a->awake_time - a->signal_time,
|
||||||
a->finish_time - a->awake_time);
|
a->finish_time - a->awake_time);
|
||||||
} else if (status == SPA_STATUS_OK) {
|
} else if (status == SPA_STATUS_OK) {
|
||||||
pw_log_trace_fp("node %p: async continue", this);
|
pw_log_trace_fp(NAME" %p: async continue", this);
|
||||||
} else {
|
} else {
|
||||||
resume_node(this, status);
|
resume_node(this, status);
|
||||||
}
|
}
|
||||||
|
|
@ -819,7 +825,7 @@ static void node_on_fd_events(struct spa_source *source)
|
||||||
struct spa_system *data_system = this->core->data_system;
|
struct spa_system *data_system = this->core->data_system;
|
||||||
|
|
||||||
if (source->rmask & (SPA_IO_ERR | SPA_IO_HUP)) {
|
if (source->rmask & (SPA_IO_ERR | SPA_IO_HUP)) {
|
||||||
pw_log_warn("node %p: got socket error %08x", this, source->rmask);
|
pw_log_warn(NAME" %p: got socket error %08x", this, source->rmask);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -827,9 +833,9 @@ static void node_on_fd_events(struct spa_source *source)
|
||||||
uint64_t cmd;
|
uint64_t cmd;
|
||||||
|
|
||||||
if (spa_system_eventfd_read(data_system, this->source.fd, &cmd) < 0 || cmd != 1)
|
if (spa_system_eventfd_read(data_system, this->source.fd, &cmd) < 0 || cmd != 1)
|
||||||
pw_log_warn("node %p: read %"PRIu64" failed %m", this, cmd);
|
pw_log_warn(NAME" %p: read %"PRIu64" failed %m", this, cmd);
|
||||||
|
|
||||||
pw_log_trace_fp("node %p: got process", this);
|
pw_log_trace_fp(NAME" %p: got process", this);
|
||||||
this->rt.target.signal(this->rt.target.data);
|
this->rt.target.signal(this->rt.target.data);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -860,7 +866,7 @@ struct pw_node *pw_node_new(struct pw_core *core,
|
||||||
|
|
||||||
this = &impl->this;
|
this = &impl->this;
|
||||||
this->core = core;
|
this->core = core;
|
||||||
pw_log_debug("node %p: new \"%s\"", this, n);
|
pw_log_debug(NAME" %p: new \"%s\"", this, n);
|
||||||
|
|
||||||
if (user_data_size > 0)
|
if (user_data_size > 0)
|
||||||
this->user_data = SPA_MEMBER(impl, sizeof(struct impl), void);
|
this->user_data = SPA_MEMBER(impl, sizeof(struct impl), void);
|
||||||
|
|
@ -992,7 +998,7 @@ static int update_properties(struct pw_node *node, const struct spa_dict *dict)
|
||||||
|
|
||||||
changed = pw_properties_update(node->properties, dict);
|
changed = pw_properties_update(node->properties, dict);
|
||||||
|
|
||||||
pw_log_debug("node %p: updated %d properties", node, changed);
|
pw_log_debug(NAME" %p: updated %d properties", node, changed);
|
||||||
|
|
||||||
if (changed) {
|
if (changed) {
|
||||||
check_properties(node);
|
check_properties(node);
|
||||||
|
|
@ -1018,7 +1024,7 @@ static void node_info(void *data, const struct spa_node_info *info)
|
||||||
node->info.max_input_ports = info->max_input_ports;
|
node->info.max_input_ports = info->max_input_ports;
|
||||||
node->info.max_output_ports = info->max_output_ports;
|
node->info.max_output_ports = info->max_output_ports;
|
||||||
|
|
||||||
pw_log_debug("node %p: change_mask %08"PRIx64" max_in:%u max_out:%u",
|
pw_log_debug(NAME" %p: change_mask %08"PRIx64" max_in:%u max_out:%u",
|
||||||
node, info->change_mask, info->max_input_ports,
|
node, info->change_mask, info->max_input_ports,
|
||||||
info->max_output_ports);
|
info->max_output_ports);
|
||||||
|
|
||||||
|
|
@ -1058,27 +1064,27 @@ static void node_port_info(void *data, enum spa_direction direction, uint32_t po
|
||||||
|
|
||||||
if (info == NULL) {
|
if (info == NULL) {
|
||||||
if (port) {
|
if (port) {
|
||||||
pw_log_debug("node %p: %s port %d removed", node,
|
pw_log_debug(NAME" %p: %s port %d removed", node,
|
||||||
pw_direction_as_string(direction), port_id);
|
pw_direction_as_string(direction), port_id);
|
||||||
pw_port_destroy(port);
|
pw_port_destroy(port);
|
||||||
} else {
|
} else {
|
||||||
pw_log_warn("node %p: %s port %d unknown", node,
|
pw_log_warn(NAME" %p: %s port %d unknown", node,
|
||||||
pw_direction_as_string(direction), port_id);
|
pw_direction_as_string(direction), port_id);
|
||||||
}
|
}
|
||||||
} else if (port) {
|
} else if (port) {
|
||||||
pw_log_debug("node %p: %s port %d changed", node,
|
pw_log_debug(NAME" %p: %s port %d changed", node,
|
||||||
pw_direction_as_string(direction), port_id);
|
pw_direction_as_string(direction), port_id);
|
||||||
pw_port_update_info(port, info);
|
pw_port_update_info(port, info);
|
||||||
} else {
|
} else {
|
||||||
int res;
|
int res;
|
||||||
|
|
||||||
pw_log_debug("node %p: %s port %d added", node,
|
pw_log_debug(NAME" %p: %s port %d added", node,
|
||||||
pw_direction_as_string(direction), port_id);
|
pw_direction_as_string(direction), port_id);
|
||||||
|
|
||||||
if ((port = pw_port_new(direction, port_id, info,
|
if ((port = pw_port_new(direction, port_id, info,
|
||||||
node->port_user_data_size))) {
|
node->port_user_data_size))) {
|
||||||
if ((res = pw_port_add(port, node)) < 0) {
|
if ((res = pw_port_add(port, node)) < 0) {
|
||||||
pw_log_error("node %p: can't add port %p: %d, %s",
|
pw_log_error(NAME" %p: can't add port %p: %d, %s",
|
||||||
node, port, res, spa_strerror(res));
|
node, port, res, spa_strerror(res));
|
||||||
pw_port_destroy(port);
|
pw_port_destroy(port);
|
||||||
}
|
}
|
||||||
|
|
@ -1091,7 +1097,7 @@ static void node_result(void *data, int seq, int res, uint32_t type, const void
|
||||||
struct pw_node *node = data;
|
struct pw_node *node = data;
|
||||||
struct impl *impl = SPA_CONTAINER_OF(node, struct impl, this);
|
struct impl *impl = SPA_CONTAINER_OF(node, struct impl, this);
|
||||||
|
|
||||||
pw_log_trace("node %p: result seq:%d res:%d type:%u", node, seq, res, type);
|
pw_log_trace(NAME" %p: result seq:%d res:%d type:%u", node, seq, res, type);
|
||||||
impl->last_error = res;
|
impl->last_error = res;
|
||||||
|
|
||||||
if (SPA_RESULT_IS_ASYNC(seq))
|
if (SPA_RESULT_IS_ASYNC(seq))
|
||||||
|
|
@ -1105,7 +1111,7 @@ static void node_event(void *data, const struct spa_event *event)
|
||||||
struct pw_node *node = data;
|
struct pw_node *node = data;
|
||||||
struct impl *impl = SPA_CONTAINER_OF(node, struct impl, this);
|
struct impl *impl = SPA_CONTAINER_OF(node, struct impl, this);
|
||||||
|
|
||||||
pw_log_trace("node %p: event %d", node, SPA_EVENT_TYPE(event));
|
pw_log_trace(NAME" %p: event %d", node, SPA_EVENT_TYPE(event));
|
||||||
|
|
||||||
switch (SPA_NODE_EVENT_ID(event)) {
|
switch (SPA_NODE_EVENT_ID(event)) {
|
||||||
case SPA_NODE_EVENT_Error:
|
case SPA_NODE_EVENT_Error:
|
||||||
|
|
@ -1133,12 +1139,12 @@ static int node_ready(void *data, int status)
|
||||||
struct pw_node_target *t;
|
struct pw_node_target *t;
|
||||||
struct pw_port *p;
|
struct pw_port *p;
|
||||||
|
|
||||||
pw_log_trace_fp("node %p: ready driver:%d exported:%d %p status:%d", node,
|
pw_log_trace_fp(NAME" %p: ready driver:%d exported:%d %p status:%d", node,
|
||||||
node->driver, node->exported, driver, status);
|
node->driver, node->exported, driver, status);
|
||||||
|
|
||||||
if (node == driver) {
|
if (node == driver) {
|
||||||
if (node->rt.activation->state[0].pending != 0) {
|
if (node->rt.activation->state[0].pending != 0) {
|
||||||
pw_log_warn("node %p: graph not finished", node);
|
pw_log_warn(NAME" %p: graph not finished", node);
|
||||||
dump_states(node);
|
dump_states(node);
|
||||||
node->rt.target.signal(node->rt.target.data);
|
node->rt.target.signal(node->rt.target.data);
|
||||||
}
|
}
|
||||||
|
|
@ -1185,10 +1191,10 @@ int pw_node_set_implementation(struct pw_node *node,
|
||||||
{
|
{
|
||||||
int res;
|
int res;
|
||||||
|
|
||||||
pw_log_debug("node %p: implementation %p", node, spa_node);
|
pw_log_debug(NAME" %p: implementation %p", node, spa_node);
|
||||||
|
|
||||||
if (node->node) {
|
if (node->node) {
|
||||||
pw_log_error("node %p: implementation existed %p", node, node->node);
|
pw_log_error(NAME" %p: implementation existed %p", node, node->node);
|
||||||
return -EEXIST;
|
return -EEXIST;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -1200,14 +1206,14 @@ int pw_node_set_implementation(struct pw_node *node,
|
||||||
SPA_IO_Position,
|
SPA_IO_Position,
|
||||||
&node->rt.activation->position,
|
&node->rt.activation->position,
|
||||||
sizeof(struct spa_io_position)) >= 0) {
|
sizeof(struct spa_io_position)) >= 0) {
|
||||||
pw_log_debug("node %p: set position %p", node, &node->rt.activation->position);
|
pw_log_debug(NAME" %p: set position %p", node, &node->rt.activation->position);
|
||||||
node->rt.position = &node->rt.activation->position;
|
node->rt.position = &node->rt.activation->position;
|
||||||
}
|
}
|
||||||
if (spa_node_set_io(node->node,
|
if (spa_node_set_io(node->node,
|
||||||
SPA_IO_Clock,
|
SPA_IO_Clock,
|
||||||
&node->rt.activation->position.clock,
|
&node->rt.activation->position.clock,
|
||||||
sizeof(struct spa_io_clock)) >= 0) {
|
sizeof(struct spa_io_clock)) >= 0) {
|
||||||
pw_log_debug("node %p: set clock %p", node, &node->rt.activation->position.clock);
|
pw_log_debug(NAME" %p: set clock %p", node, &node->rt.activation->position.clock);
|
||||||
node->rt.clock = &node->rt.activation->position.clock;
|
node->rt.clock = &node->rt.activation->position.clock;
|
||||||
}
|
}
|
||||||
return res;
|
return res;
|
||||||
|
|
@ -1245,18 +1251,18 @@ void pw_node_destroy(struct pw_node *node)
|
||||||
|
|
||||||
node->active = false;
|
node->active = false;
|
||||||
|
|
||||||
pw_log_debug("node %p: destroy", impl);
|
pw_log_debug(NAME" %p: destroy", impl);
|
||||||
pw_node_emit_destroy(node);
|
pw_node_emit_destroy(node);
|
||||||
|
|
||||||
suspend_node(node);
|
suspend_node(node);
|
||||||
|
|
||||||
pw_log_debug("node %p: driver node %p", impl, node->driver_node);
|
pw_log_debug(NAME" %p: driver node %p", impl, node->driver_node);
|
||||||
|
|
||||||
/* remove ourself as a slave from the driver node */
|
/* remove ourself as a slave from the driver node */
|
||||||
spa_list_remove(&node->slave_link);
|
spa_list_remove(&node->slave_link);
|
||||||
|
|
||||||
spa_list_consume(slave, &node->slave_list, slave_link) {
|
spa_list_consume(slave, &node->slave_list, slave_link) {
|
||||||
pw_log_debug("node %p: reslave %p", impl, slave);
|
pw_log_debug(NAME" %p: reslave %p", impl, slave);
|
||||||
pw_node_set_driver(slave, NULL);
|
pw_node_set_driver(slave, NULL);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -1271,13 +1277,13 @@ void pw_node_destroy(struct pw_node *node)
|
||||||
spa_node_set_callbacks(node->node, NULL, NULL);
|
spa_node_set_callbacks(node->node, NULL, NULL);
|
||||||
}
|
}
|
||||||
|
|
||||||
pw_log_debug("node %p: unlink ports", node);
|
pw_log_debug(NAME" %p: unlink ports", node);
|
||||||
spa_list_for_each(port, &node->input_ports, link)
|
spa_list_for_each(port, &node->input_ports, link)
|
||||||
pw_port_unlink(port);
|
pw_port_unlink(port);
|
||||||
spa_list_for_each(port, &node->output_ports, link)
|
spa_list_for_each(port, &node->output_ports, link)
|
||||||
pw_port_unlink(port);
|
pw_port_unlink(port);
|
||||||
|
|
||||||
pw_log_debug("node %p: destroy ports", node);
|
pw_log_debug(NAME" %p: destroy ports", node);
|
||||||
spa_list_consume(port, &node->input_ports, link)
|
spa_list_consume(port, &node->input_ports, link)
|
||||||
pw_port_destroy(port);
|
pw_port_destroy(port);
|
||||||
spa_list_consume(port, &node->output_ports, link)
|
spa_list_consume(port, &node->output_ports, link)
|
||||||
|
|
@ -1290,7 +1296,7 @@ void pw_node_destroy(struct pw_node *node)
|
||||||
|
|
||||||
pw_core_recalc_graph(node->core);
|
pw_core_recalc_graph(node->core);
|
||||||
|
|
||||||
pw_log_debug("node %p: free", node);
|
pw_log_debug(NAME" %p: free", node);
|
||||||
pw_node_emit_free(node);
|
pw_node_emit_free(node);
|
||||||
|
|
||||||
pw_memblock_unref(node->activation);
|
pw_memblock_unref(node->activation);
|
||||||
|
|
@ -1374,7 +1380,7 @@ int pw_node_for_each_param(struct pw_node *node,
|
||||||
if (max == 0)
|
if (max == 0)
|
||||||
max = UINT32_MAX;
|
max = UINT32_MAX;
|
||||||
|
|
||||||
pw_log_debug("node %p: params %s %u %u", node,
|
pw_log_debug(NAME" %p: params %s %u %u", node,
|
||||||
spa_debug_type_find_name(spa_type_param, param_id),
|
spa_debug_type_find_name(spa_type_param, param_id),
|
||||||
index, max);
|
index, max);
|
||||||
|
|
||||||
|
|
@ -1419,7 +1425,7 @@ pw_node_find_port(struct pw_node *node, enum pw_direction direction, uint32_t po
|
||||||
port = p;
|
port = p;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
pw_log_debug("node %p: return %s port %d: %p", node,
|
pw_log_debug(NAME" %p: return %s port %d: %p", node,
|
||||||
pw_direction_as_string(direction), port_id, port);
|
pw_direction_as_string(direction), port_id, port);
|
||||||
return port;
|
return port;
|
||||||
}
|
}
|
||||||
|
|
@ -1444,7 +1450,7 @@ uint32_t pw_node_get_free_port_id(struct pw_node *node, enum pw_direction direct
|
||||||
portmap = &node->output_port_map;
|
portmap = &node->output_port_map;
|
||||||
dynamic = SPA_FLAG_CHECK(node->spa_flags, SPA_NODE_FLAG_OUT_DYNAMIC_PORTS);
|
dynamic = SPA_FLAG_CHECK(node->spa_flags, SPA_NODE_FLAG_OUT_DYNAMIC_PORTS);
|
||||||
}
|
}
|
||||||
pw_log_debug("node %p: direction %s n_ports:%u max_ports:%u",
|
pw_log_debug(NAME" %p: direction %s n_ports:%u max_ports:%u",
|
||||||
node, pw_direction_as_string(direction), n_ports, max_ports);
|
node, pw_direction_as_string(direction), n_ports, max_ports);
|
||||||
|
|
||||||
if (!dynamic || n_ports >= max_ports) {
|
if (!dynamic || n_ports >= max_ports) {
|
||||||
|
|
@ -1458,12 +1464,12 @@ uint32_t pw_node_get_free_port_id(struct pw_node *node, enum pw_direction direct
|
||||||
goto error;
|
goto error;
|
||||||
}
|
}
|
||||||
|
|
||||||
pw_log_debug("node %p: free port %d", node, port_id);
|
pw_log_debug(NAME" %p: free port %d", node, port_id);
|
||||||
|
|
||||||
return port_id;
|
return port_id;
|
||||||
|
|
||||||
error:
|
error:
|
||||||
pw_log_warn("node %p: no more port available: %s", node, spa_strerror(res));
|
pw_log_warn(NAME" %p: no more port available: %s", node, spa_strerror(res));
|
||||||
errno = -res;
|
errno = -res;
|
||||||
return SPA_ID_INVALID;
|
return SPA_ID_INVALID;
|
||||||
}
|
}
|
||||||
|
|
@ -1474,7 +1480,7 @@ static void on_state_complete(void *obj, void *data, int res, uint32_t seq)
|
||||||
enum pw_node_state state = SPA_PTR_TO_INT(data);
|
enum pw_node_state state = SPA_PTR_TO_INT(data);
|
||||||
char *error = NULL;
|
char *error = NULL;
|
||||||
|
|
||||||
pw_log_debug("node %p: state complete %d", node, res);
|
pw_log_debug(NAME" %p: state complete %d", node, res);
|
||||||
if (SPA_RESULT_IS_ERROR(res)) {
|
if (SPA_RESULT_IS_ERROR(res)) {
|
||||||
asprintf(&error, "error changing node state: %d", res);
|
asprintf(&error, "error changing node state: %d", res);
|
||||||
state = PW_NODE_STATE_ERROR;
|
state = PW_NODE_STATE_ERROR;
|
||||||
|
|
@ -1486,7 +1492,7 @@ static void node_activate(struct pw_node *this)
|
||||||
{
|
{
|
||||||
struct pw_port *port;
|
struct pw_port *port;
|
||||||
|
|
||||||
pw_log_debug("node %p: activate", this);
|
pw_log_debug(NAME" %p: activate", this);
|
||||||
spa_list_for_each(port, &this->input_ports, link) {
|
spa_list_for_each(port, &this->input_ports, link) {
|
||||||
struct pw_link *link;
|
struct pw_link *link;
|
||||||
spa_list_for_each(link, &port->links, input_link)
|
spa_list_for_each(link, &port->links, input_link)
|
||||||
|
|
@ -1515,7 +1521,7 @@ int pw_node_set_state(struct pw_node *node, enum pw_node_state state)
|
||||||
struct impl *impl = SPA_CONTAINER_OF(node, struct impl, this);
|
struct impl *impl = SPA_CONTAINER_OF(node, struct impl, this);
|
||||||
enum pw_node_state old = node->info.state;
|
enum pw_node_state old = node->info.state;
|
||||||
|
|
||||||
pw_log_debug("node %p: set state %s -> %s, active %d", node,
|
pw_log_debug(NAME" %p: set state %s -> %s, active %d", node,
|
||||||
pw_node_state_as_string(old),
|
pw_node_state_as_string(old),
|
||||||
pw_node_state_as_string(state),
|
pw_node_state_as_string(state),
|
||||||
node->active);
|
node->active);
|
||||||
|
|
@ -1567,7 +1573,7 @@ int pw_node_set_active(struct pw_node *node, bool active)
|
||||||
bool old = node->active;
|
bool old = node->active;
|
||||||
|
|
||||||
if (old != active) {
|
if (old != active) {
|
||||||
pw_log_debug("node %p: %s", node, active ? "activate" : "deactivate");
|
pw_log_debug(NAME" %p: %s", node, active ? "activate" : "deactivate");
|
||||||
|
|
||||||
if (!active)
|
if (!active)
|
||||||
pw_node_set_state(node, PW_NODE_STATE_IDLE);
|
pw_node_set_state(node, PW_NODE_STATE_IDLE);
|
||||||
|
|
|
||||||
|
|
@ -36,6 +36,8 @@
|
||||||
#include "pipewire/port.h"
|
#include "pipewire/port.h"
|
||||||
#include "pipewire/link.h"
|
#include "pipewire/link.h"
|
||||||
|
|
||||||
|
#define NAME "port"
|
||||||
|
|
||||||
/** \cond */
|
/** \cond */
|
||||||
struct impl {
|
struct impl {
|
||||||
struct pw_port this;
|
struct pw_port this;
|
||||||
|
|
@ -101,7 +103,7 @@ void pw_port_update_state(struct pw_port *port, enum pw_port_state state, char *
|
||||||
if (old != state) {
|
if (old != state) {
|
||||||
pw_log(state == PW_PORT_STATE_ERROR ?
|
pw_log(state == PW_PORT_STATE_ERROR ?
|
||||||
SPA_LOG_LEVEL_ERROR : SPA_LOG_LEVEL_DEBUG,
|
SPA_LOG_LEVEL_ERROR : SPA_LOG_LEVEL_DEBUG,
|
||||||
"port %p: state %s -> %s (%s)", port,
|
NAME" %p: state %s -> %s (%s)", port,
|
||||||
port_state_as_string(old), port_state_as_string(state), error);
|
port_state_as_string(old), port_state_as_string(state), error);
|
||||||
|
|
||||||
port->state = state;
|
port->state = state;
|
||||||
|
|
@ -118,9 +120,9 @@ static int tee_process(void *object)
|
||||||
struct pw_port_mix *mix;
|
struct pw_port_mix *mix;
|
||||||
struct spa_io_buffers *io = &this->rt.io;
|
struct spa_io_buffers *io = &this->rt.io;
|
||||||
|
|
||||||
pw_log_trace_fp("port %p: tee input %d %d", this, io->status, io->buffer_id);
|
pw_log_trace_fp(NAME" %p: tee input %d %d", this, io->status, io->buffer_id);
|
||||||
spa_list_for_each(mix, &this->rt.mix_list, rt_link) {
|
spa_list_for_each(mix, &this->rt.mix_list, rt_link) {
|
||||||
pw_log_trace_fp("port %p: port %d %p->%p %d", this,
|
pw_log_trace_fp(NAME" %p: port %d %p->%p %d", this,
|
||||||
mix->port.port_id, io, mix->io, mix->io->buffer_id);
|
mix->port.port_id, io, mix->io, mix->io->buffer_id);
|
||||||
*mix->io = *io;
|
*mix->io = *io;
|
||||||
}
|
}
|
||||||
|
|
@ -134,7 +136,7 @@ static int tee_reuse_buffer(void *object, uint32_t port_id, uint32_t buffer_id)
|
||||||
struct impl *impl = object;
|
struct impl *impl = object;
|
||||||
struct pw_port *this = &impl->this;
|
struct pw_port *this = &impl->this;
|
||||||
|
|
||||||
pw_log_trace_fp("port %p: tee reuse buffer %d %d", this, port_id, buffer_id);
|
pw_log_trace_fp(NAME" %p: tee reuse buffer %d %d", this, port_id, buffer_id);
|
||||||
spa_node_port_reuse_buffer(this->node->node, this->port_id, buffer_id);
|
spa_node_port_reuse_buffer(this->node->node, this->port_id, buffer_id);
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
|
|
@ -157,7 +159,7 @@ static int schedule_mix_input(void *object)
|
||||||
return SPA_STATUS_HAVE_BUFFER | SPA_STATUS_NEED_BUFFER;
|
return SPA_STATUS_HAVE_BUFFER | SPA_STATUS_NEED_BUFFER;
|
||||||
|
|
||||||
spa_list_for_each(mix, &this->rt.mix_list, rt_link) {
|
spa_list_for_each(mix, &this->rt.mix_list, rt_link) {
|
||||||
pw_log_trace_fp("port %p: mix input %d %p->%p %d %d", this,
|
pw_log_trace_fp(NAME" %p: mix input %d %p->%p %d %d", this,
|
||||||
mix->port.port_id, mix->io, io, mix->io->status, mix->io->buffer_id);
|
mix->port.port_id, mix->io, io, mix->io->status, mix->io->buffer_id);
|
||||||
*io = *mix->io;
|
*io = *mix->io;
|
||||||
mix->io->status = SPA_STATUS_NEED_BUFFER;
|
mix->io->status = SPA_STATUS_NEED_BUFFER;
|
||||||
|
|
@ -173,7 +175,7 @@ static int schedule_mix_reuse_buffer(void *object, uint32_t port_id, uint32_t bu
|
||||||
struct pw_port_mix *mix;
|
struct pw_port_mix *mix;
|
||||||
|
|
||||||
spa_list_for_each(mix, &this->rt.mix_list, rt_link) {
|
spa_list_for_each(mix, &this->rt.mix_list, rt_link) {
|
||||||
pw_log_trace_fp("port %p: reuse buffer %d %d", this, port_id, buffer_id);
|
pw_log_trace_fp(NAME" %p: reuse buffer %d %d", this, port_id, buffer_id);
|
||||||
spa_node_port_reuse_buffer(this->node->node, port_id, buffer_id);
|
spa_node_port_reuse_buffer(this->node->node, port_id, buffer_id);
|
||||||
}
|
}
|
||||||
return 0;
|
return 0;
|
||||||
|
|
@ -223,7 +225,7 @@ int pw_port_init_mix(struct pw_port *port, struct pw_port_mix *mix)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
pw_log_debug("port %p: init mix %d %d.%d io %p: (%s)", port,
|
pw_log_debug(NAME" %p: init mix %d %d.%d io %p: (%s)", port,
|
||||||
port->n_mix, port->port_id, mix->port.port_id, mix->io, spa_strerror(res));
|
port->n_mix, port->port_id, mix->port.port_id, mix->io, spa_strerror(res));
|
||||||
|
|
||||||
return res;
|
return res;
|
||||||
|
|
@ -243,7 +245,7 @@ int pw_port_release_mix(struct pw_port *port, struct pw_port_mix *mix)
|
||||||
|
|
||||||
spa_node_remove_port(port->mix, port->direction, port_id);
|
spa_node_remove_port(port->mix, port->direction, port_id);
|
||||||
|
|
||||||
pw_log_debug("port %p: release mix %d %d.%d", port,
|
pw_log_debug(NAME" %p: release mix %d %d.%d", port,
|
||||||
port->n_mix, port->port_id, mix->port.port_id);
|
port->n_mix, port->port_id, mix->port.port_id);
|
||||||
|
|
||||||
return res;
|
return res;
|
||||||
|
|
@ -256,7 +258,7 @@ static int update_properties(struct pw_port *port, const struct spa_dict *dict)
|
||||||
changed = pw_properties_update(port->properties, dict);
|
changed = pw_properties_update(port->properties, dict);
|
||||||
|
|
||||||
if (changed) {
|
if (changed) {
|
||||||
pw_log_debug("port %p: updated %d properties", port, changed);
|
pw_log_debug(NAME" %p: updated %d properties", port, changed);
|
||||||
port->info.props = &port->properties->dict;
|
port->info.props = &port->properties->dict;
|
||||||
port->info.change_mask |= PW_PORT_CHANGE_MASK_PROPS;
|
port->info.change_mask |= PW_PORT_CHANGE_MASK_PROPS;
|
||||||
}
|
}
|
||||||
|
|
@ -285,7 +287,7 @@ static int notify_param(void *data, int seq, uint32_t id,
|
||||||
if (!resource_is_subscribed(resource, id))
|
if (!resource_is_subscribed(resource, id))
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
pw_log_debug("resource %p: notify param %d", resource, id);
|
pw_log_debug(NAME" %p: resource %p notify param %d", port, resource, id);
|
||||||
pw_port_resource_param(resource, seq, id, index, next, param);
|
pw_port_resource_param(resource, seq, id, index, next, param);
|
||||||
}
|
}
|
||||||
return 0;
|
return 0;
|
||||||
|
|
@ -299,7 +301,7 @@ static void emit_params(struct pw_port *port, uint32_t *changed_ids, uint32_t n_
|
||||||
if (port->global == NULL)
|
if (port->global == NULL)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
pw_log_debug("port %p: emit %d params", port, n_changed_ids);
|
pw_log_debug(NAME" %p: emit %d params", port, n_changed_ids);
|
||||||
|
|
||||||
for (i = 0; i < n_changed_ids; i++) {
|
for (i = 0; i < n_changed_ids; i++) {
|
||||||
struct pw_resource *resource;
|
struct pw_resource *resource;
|
||||||
|
|
@ -315,7 +317,7 @@ static void emit_params(struct pw_port *port, uint32_t *changed_ids, uint32_t n_
|
||||||
|
|
||||||
if ((res = pw_port_for_each_param(port, 1, changed_ids[i], 0, UINT32_MAX,
|
if ((res = pw_port_for_each_param(port, 1, changed_ids[i], 0, UINT32_MAX,
|
||||||
NULL, notify_param, port)) < 0) {
|
NULL, notify_param, port)) < 0) {
|
||||||
pw_log_error("port %p: error %d (%s)", port, res, spa_strerror(res));
|
pw_log_error(NAME" %p: error %d (%s)", port, res, spa_strerror(res));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -368,7 +370,7 @@ struct pw_port *pw_port_new(enum pw_direction direction,
|
||||||
return NULL;
|
return NULL;
|
||||||
|
|
||||||
this = &impl->this;
|
this = &impl->this;
|
||||||
pw_log_debug("port %p: new %s %d", this,
|
pw_log_debug(NAME" %p: new %s %d", this,
|
||||||
pw_direction_as_string(direction), port_id);
|
pw_direction_as_string(direction), port_id);
|
||||||
|
|
||||||
if (info && info->change_mask & SPA_PORT_CHANGE_MASK_PROPS && info->props)
|
if (info && info->change_mask & SPA_PORT_CHANGE_MASK_PROPS && info->props)
|
||||||
|
|
@ -433,7 +435,7 @@ struct pw_port *pw_port_new(enum pw_direction direction,
|
||||||
return this;
|
return this;
|
||||||
|
|
||||||
error_no_mem:
|
error_no_mem:
|
||||||
pw_log_warn("port %p: new failed", impl);
|
pw_log_warn(NAME" %p: new failed", impl);
|
||||||
free(impl);
|
free(impl);
|
||||||
errno = -res;
|
errno = -res;
|
||||||
return NULL;
|
return NULL;
|
||||||
|
|
@ -448,7 +450,7 @@ int pw_port_set_mix(struct pw_port *port, struct spa_node *node, uint32_t flags)
|
||||||
node = &impl->mix_node;
|
node = &impl->mix_node;
|
||||||
flags = 0;
|
flags = 0;
|
||||||
}
|
}
|
||||||
pw_log_debug("port %p: mix node %p->%p", port, port->mix, node);
|
pw_log_debug(NAME" %p: mix node %p->%p", port, port->mix, node);
|
||||||
port->mix = node;
|
port->mix = node;
|
||||||
port->mix_flags = flags;
|
port->mix_flags = flags;
|
||||||
return 0;
|
return 0;
|
||||||
|
|
@ -535,7 +537,7 @@ static int check_param_io(void *data, int seq, uint32_t id,
|
||||||
SPA_PARAM_IO_size, SPA_POD_Int(&psize)) < 0)
|
SPA_PARAM_IO_size, SPA_POD_Int(&psize)) < 0)
|
||||||
return 0;
|
return 0;
|
||||||
|
|
||||||
pw_log_debug("port %p: got io %s", port,
|
pw_log_debug(NAME" %p: got io %s", port,
|
||||||
spa_debug_type_find_name(spa_type_io, pid));
|
spa_debug_type_find_name(spa_type_io, pid));
|
||||||
|
|
||||||
switch (pid) {
|
switch (pid) {
|
||||||
|
|
@ -569,7 +571,8 @@ static int reply_param(void *data, int seq, uint32_t id,
|
||||||
{
|
{
|
||||||
struct resource_data *d = data;
|
struct resource_data *d = data;
|
||||||
struct pw_resource *resource = d->resource;
|
struct pw_resource *resource = d->resource;
|
||||||
pw_log_debug("resource %p: reply param %u %u %u", resource, id, index, next);
|
pw_log_debug(NAME" %p: resource %p reply param %u %u %u", d->port,
|
||||||
|
resource, id, index, next);
|
||||||
pw_port_resource_param(resource, seq, id, index, next, param);
|
pw_port_resource_param(resource, seq, id, index, next, param);
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
@ -581,8 +584,10 @@ static int port_enum_params(void *object, int seq, uint32_t id, uint32_t index,
|
||||||
struct resource_data *data = pw_resource_get_user_data(resource);
|
struct resource_data *data = pw_resource_get_user_data(resource);
|
||||||
struct pw_port *port = data->port;
|
struct pw_port *port = data->port;
|
||||||
int res;
|
int res;
|
||||||
pw_log_debug("resource %p: enum params %d %s %u %u", resource, seq,
|
|
||||||
spa_debug_type_find_name(spa_type_param, id), index, num);
|
pw_log_debug(NAME" %p: resource %p enum params %d %s %u %u", port,
|
||||||
|
resource, seq, spa_debug_type_find_name(spa_type_param, id),
|
||||||
|
index, num);
|
||||||
|
|
||||||
if ((res = pw_port_for_each_param(port, seq, id, index, num, filter,
|
if ((res = pw_port_for_each_param(port, seq, id, index, num, filter,
|
||||||
reply_param, data)) < 0)
|
reply_param, data)) < 0)
|
||||||
|
|
@ -602,8 +607,8 @@ static int port_subscribe_params(void *object, uint32_t *ids, uint32_t n_ids)
|
||||||
|
|
||||||
for (i = 0; i < n_ids; i++) {
|
for (i = 0; i < n_ids; i++) {
|
||||||
data->subscribe_ids[i] = ids[i];
|
data->subscribe_ids[i] = ids[i];
|
||||||
pw_log_debug("resource %p: subscribe param %s", resource,
|
pw_log_debug(NAME" %p: resource %p subscribe param %s", data->port,
|
||||||
spa_debug_type_find_name(spa_type_param, ids[i]));
|
resource, spa_debug_type_find_name(spa_type_param, ids[i]));
|
||||||
port_enum_params(resource, 1, ids[i], 0, UINT32_MAX, NULL);
|
port_enum_params(resource, 1, ids[i], 0, UINT32_MAX, NULL);
|
||||||
}
|
}
|
||||||
return 0;
|
return 0;
|
||||||
|
|
@ -642,7 +647,7 @@ global_bind(void *_data, struct pw_client *client, uint32_t permissions,
|
||||||
&data->object_listener,
|
&data->object_listener,
|
||||||
&port_methods, resource);
|
&port_methods, resource);
|
||||||
|
|
||||||
pw_log_debug("port %p: bound to %d", this, resource->id);
|
pw_log_debug(NAME" %p: bound to %d", this, resource->id);
|
||||||
|
|
||||||
spa_list_append(&global->resource_list, &resource->link);
|
spa_list_append(&global->resource_list, &resource->link);
|
||||||
|
|
||||||
|
|
@ -652,7 +657,7 @@ global_bind(void *_data, struct pw_client *client, uint32_t permissions,
|
||||||
return 0;
|
return 0;
|
||||||
|
|
||||||
error_resource:
|
error_resource:
|
||||||
pw_log_error("can't create port resource: %m");
|
pw_log_error(NAME" %p: can't create port resource: %m", this);
|
||||||
return res;
|
return res;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -747,9 +752,9 @@ int pw_port_add(struct pw_port *port, struct pw_node *node)
|
||||||
}
|
}
|
||||||
|
|
||||||
if (control) {
|
if (control) {
|
||||||
pw_log_debug("port %p: setting node control", port);
|
pw_log_debug(NAME" %p: setting node control", port);
|
||||||
} else {
|
} else {
|
||||||
pw_log_debug("port %p: setting node io", port);
|
pw_log_debug(NAME" %p: setting node io", port);
|
||||||
spa_node_port_set_io(node->node,
|
spa_node_port_set_io(node->node,
|
||||||
port->direction, port->port_id,
|
port->direction, port->port_id,
|
||||||
SPA_IO_Buffers,
|
SPA_IO_Buffers,
|
||||||
|
|
@ -761,7 +766,7 @@ int pw_port_add(struct pw_port *port, struct pw_node *node)
|
||||||
&port->rt.io, sizeof(port->rt.io));
|
&port->rt.io, sizeof(port->rt.io));
|
||||||
}
|
}
|
||||||
|
|
||||||
pw_log_debug("port %p: %d add to node %p", port, port_id, node);
|
pw_log_debug(NAME" %p: %d add to node %p", port, port_id, node);
|
||||||
|
|
||||||
spa_list_append(ports, &port->link);
|
spa_list_append(ports, &port->link);
|
||||||
|
|
||||||
|
|
@ -816,14 +821,14 @@ static void pw_port_remove(struct pw_port *port)
|
||||||
if (node == NULL)
|
if (node == NULL)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
pw_log_debug("port %p: remove", port);
|
pw_log_debug(NAME" %p: remove", port);
|
||||||
|
|
||||||
pw_loop_invoke(port->node->data_loop, do_remove_port,
|
pw_loop_invoke(port->node->data_loop, do_remove_port,
|
||||||
SPA_ID_INVALID, NULL, 0, true, port);
|
SPA_ID_INVALID, NULL, 0, true, port);
|
||||||
|
|
||||||
if (SPA_FLAG_CHECK(port->flags, PW_PORT_FLAG_TO_REMOVE)) {
|
if (SPA_FLAG_CHECK(port->flags, PW_PORT_FLAG_TO_REMOVE)) {
|
||||||
if ((res = spa_node_remove_port(node->node, port->direction, port->port_id)) < 0)
|
if ((res = spa_node_remove_port(node->node, port->direction, port->port_id)) < 0)
|
||||||
pw_log_warn("port %p: can't remove: %s", port, spa_strerror(res));
|
pw_log_warn(NAME" %p: can't remove: %s", port, spa_strerror(res));
|
||||||
}
|
}
|
||||||
|
|
||||||
if (port->direction == PW_DIRECTION_INPUT) {
|
if (port->direction == PW_DIRECTION_INPUT) {
|
||||||
|
|
@ -842,11 +847,11 @@ void pw_port_destroy(struct pw_port *port)
|
||||||
{
|
{
|
||||||
struct pw_control *control;
|
struct pw_control *control;
|
||||||
|
|
||||||
pw_log_debug("port %p: destroy", port);
|
pw_log_debug(NAME" %p: destroy", port);
|
||||||
|
|
||||||
pw_port_emit_destroy(port);
|
pw_port_emit_destroy(port);
|
||||||
|
|
||||||
pw_log_debug("port %p: control destroy", port);
|
pw_log_debug(NAME" %p: control destroy", port);
|
||||||
spa_list_consume(control, &port->control_list[0], port_link)
|
spa_list_consume(control, &port->control_list[0], port_link)
|
||||||
pw_control_destroy(control);
|
pw_control_destroy(control);
|
||||||
spa_list_consume(control, &port->control_list[1], port_link)
|
spa_list_consume(control, &port->control_list[1], port_link)
|
||||||
|
|
@ -859,7 +864,7 @@ void pw_port_destroy(struct pw_port *port)
|
||||||
pw_global_destroy(port->global);
|
pw_global_destroy(port->global);
|
||||||
}
|
}
|
||||||
|
|
||||||
pw_log_debug("port %p: free", port);
|
pw_log_debug(NAME" %p: free", port);
|
||||||
pw_port_emit_free(port);
|
pw_port_emit_free(port);
|
||||||
|
|
||||||
free_allocation(&port->allocation);
|
free_allocation(&port->allocation);
|
||||||
|
|
@ -918,7 +923,7 @@ int pw_port_for_each_param(struct pw_port *port,
|
||||||
if (max == 0)
|
if (max == 0)
|
||||||
max = UINT32_MAX;
|
max = UINT32_MAX;
|
||||||
|
|
||||||
pw_log_debug("port %p: params %s %u %u", port,
|
pw_log_debug(NAME" %p: params %s %u %u", port,
|
||||||
spa_debug_type_find_name(spa_type_param, param_id),
|
spa_debug_type_find_name(spa_type_param, param_id),
|
||||||
index, max);
|
index, max);
|
||||||
|
|
||||||
|
|
@ -930,7 +935,7 @@ int pw_port_for_each_param(struct pw_port *port,
|
||||||
filter);
|
filter);
|
||||||
spa_hook_remove(&listener);
|
spa_hook_remove(&listener);
|
||||||
|
|
||||||
pw_log_debug("port %p: res %d: (%s)", port, res, spa_strerror(res));
|
pw_log_debug(NAME" %p: res %d: (%s)", port, res, spa_strerror(res));
|
||||||
return res;
|
return res;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -1008,7 +1013,7 @@ int pw_port_set_param(struct pw_port *port, uint32_t id, uint32_t flags,
|
||||||
int res = 0;
|
int res = 0;
|
||||||
struct pw_node *node = port->node;
|
struct pw_node *node = port->node;
|
||||||
|
|
||||||
pw_log_debug("port %p: %d set param %d %p", port, port->state, id, param);
|
pw_log_debug(NAME" %p: %d set param %d %p", port, port->state, id, param);
|
||||||
|
|
||||||
/* set the parameters on all ports of the mixer node if possible */
|
/* set the parameters on all ports of the mixer node if possible */
|
||||||
{
|
{
|
||||||
|
|
@ -1029,12 +1034,12 @@ int pw_port_set_param(struct pw_port *port, uint32_t id, uint32_t flags,
|
||||||
port->direction, port->port_id,
|
port->direction, port->port_id,
|
||||||
id, flags, param);
|
id, flags, param);
|
||||||
|
|
||||||
pw_log_debug("port %p: %d set param on node %d:%d %s: %d (%s)", port, port->state,
|
pw_log_debug(NAME" %p: %d set param on node %d:%d %s: %d (%s)", port, port->state,
|
||||||
port->direction, port->port_id,
|
port->direction, port->port_id,
|
||||||
spa_debug_type_find_name(spa_type_param, id), res, spa_strerror(res));
|
spa_debug_type_find_name(spa_type_param, id), res, spa_strerror(res));
|
||||||
|
|
||||||
if (id == SPA_PARAM_Format) {
|
if (id == SPA_PARAM_Format) {
|
||||||
pw_log_debug("port %p: %d %p %d", port, port->state, param, res);
|
pw_log_debug(NAME" %p: %d %p %d", port, port->state, param, res);
|
||||||
|
|
||||||
/* setting the format always destroys the negotiated buffers */
|
/* setting the format always destroys the negotiated buffers */
|
||||||
free_allocation(&port->allocation);
|
free_allocation(&port->allocation);
|
||||||
|
|
@ -1056,7 +1061,7 @@ int pw_port_use_buffers(struct pw_port *port, struct pw_port_mix *mix, uint32_t
|
||||||
int res = 0, res2;
|
int res = 0, res2;
|
||||||
struct pw_node *node = port->node;
|
struct pw_node *node = port->node;
|
||||||
|
|
||||||
pw_log_debug("port %p: %d:%d.%d: %d buffers state:%d n_mix:%d", port,
|
pw_log_debug(NAME" %p: %d:%d.%d: %d buffers state:%d n_mix:%d", port,
|
||||||
port->direction, port->port_id, mix->id,
|
port->direction, port->port_id, mix->id,
|
||||||
n_buffers, port->state, port->n_mix);
|
n_buffers, port->state, port->n_mix);
|
||||||
|
|
||||||
|
|
@ -1072,13 +1077,13 @@ int pw_port_use_buffers(struct pw_port *port, struct pw_port_mix *mix, uint32_t
|
||||||
}
|
}
|
||||||
if (port->state == PW_PORT_STATE_READY) {
|
if (port->state == PW_PORT_STATE_READY) {
|
||||||
if (!SPA_FLAG_CHECK(port->mix_flags, PW_PORT_MIX_FLAG_MIX_ONLY)) {
|
if (!SPA_FLAG_CHECK(port->mix_flags, PW_PORT_MIX_FLAG_MIX_ONLY)) {
|
||||||
pw_log_debug("port %p: use buffers on node: %p", port,
|
pw_log_debug(NAME" %p: use buffers on node: %p", port,
|
||||||
node->node);
|
node->node);
|
||||||
res = spa_node_port_use_buffers(node->node,
|
res = spa_node_port_use_buffers(node->node,
|
||||||
port->direction, port->port_id,
|
port->direction, port->port_id,
|
||||||
flags, buffers, n_buffers);
|
flags, buffers, n_buffers);
|
||||||
if (res < 0) {
|
if (res < 0) {
|
||||||
pw_log_error("port %p: use buffers on node: %d (%s)",
|
pw_log_error(NAME" %p: use buffers on node: %d (%s)",
|
||||||
port, res, spa_strerror(res));
|
port, res, spa_strerror(res));
|
||||||
pw_port_update_state(port, PW_PORT_STATE_ERROR,
|
pw_port_update_state(port, PW_PORT_STATE_ERROR,
|
||||||
"can't use buffers on port");
|
"can't use buffers on port");
|
||||||
|
|
@ -1086,7 +1091,7 @@ int pw_port_use_buffers(struct pw_port *port, struct pw_port_mix *mix, uint32_t
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if ((res2 = pw_port_call_use_buffers(port, flags, buffers, n_buffers)) < 0) {
|
if ((res2 = pw_port_call_use_buffers(port, flags, buffers, n_buffers)) < 0) {
|
||||||
pw_log_warn("port %p: implementation alloc failed: %d (%s)",
|
pw_log_warn(NAME" %p: implementation alloc failed: %d (%s)",
|
||||||
port, res2, spa_strerror(res2));
|
port, res2, spa_strerror(res2));
|
||||||
}
|
}
|
||||||
if (n_buffers > 0 && !SPA_RESULT_IS_ASYNC(res))
|
if (n_buffers > 0 && !SPA_RESULT_IS_ASYNC(res))
|
||||||
|
|
@ -1097,7 +1102,7 @@ int pw_port_use_buffers(struct pw_port *port, struct pw_port_mix *mix, uint32_t
|
||||||
mix->port.direction, mix->port.port_id, flags,
|
mix->port.direction, mix->port.port_id, flags,
|
||||||
buffers, n_buffers)) < 0) {
|
buffers, n_buffers)) < 0) {
|
||||||
if (res2 != -ENOTSUP)
|
if (res2 != -ENOTSUP)
|
||||||
pw_log_warn("port %p: mix use buffers failed: %d (%s)",
|
pw_log_warn(NAME" %p: mix use buffers failed: %d (%s)",
|
||||||
port, res2, spa_strerror(res2));
|
port, res2, spa_strerror(res2));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -30,6 +30,8 @@
|
||||||
#include <pipewire/private.h>
|
#include <pipewire/private.h>
|
||||||
#include <pipewire/type.h>
|
#include <pipewire/type.h>
|
||||||
|
|
||||||
|
#define NAME "protocol"
|
||||||
|
|
||||||
/** \cond */
|
/** \cond */
|
||||||
struct impl {
|
struct impl {
|
||||||
struct pw_protocol this;
|
struct pw_protocol this;
|
||||||
|
|
@ -65,7 +67,7 @@ struct pw_protocol *pw_protocol_new(struct pw_core *core,
|
||||||
|
|
||||||
spa_list_append(&core->protocol_list, &protocol->link);
|
spa_list_append(&core->protocol_list, &protocol->link);
|
||||||
|
|
||||||
pw_log_debug("protocol %p: Created protocol %s", protocol, name);
|
pw_log_debug(NAME" %p: Created protocol %s", protocol, name);
|
||||||
|
|
||||||
return protocol;
|
return protocol;
|
||||||
}
|
}
|
||||||
|
|
@ -98,7 +100,7 @@ void pw_protocol_destroy(struct pw_protocol *protocol)
|
||||||
struct pw_protocol_server *server;
|
struct pw_protocol_server *server;
|
||||||
struct pw_protocol_client *client;
|
struct pw_protocol_client *client;
|
||||||
|
|
||||||
pw_log_debug("protocol %p: destroy", protocol);
|
pw_log_debug(NAME" %p: destroy", protocol);
|
||||||
pw_protocol_emit_destroy(protocol);
|
pw_protocol_emit_destroy(protocol);
|
||||||
|
|
||||||
spa_list_remove(&protocol->link);
|
spa_list_remove(&protocol->link);
|
||||||
|
|
@ -141,9 +143,9 @@ pw_protocol_add_marshal(struct pw_protocol *protocol,
|
||||||
|
|
||||||
spa_list_append(&protocol->marshal_list, &impl->link);
|
spa_list_append(&protocol->marshal_list, &impl->link);
|
||||||
|
|
||||||
pw_log_debug("Add marshal %d/%s:%d to protocol %s", marshal->type,
|
pw_log_debug(NAME" %p: Add marshal %d/%s:%d to protocol %s", protocol,
|
||||||
spa_debug_type_find_name(pw_type_info(), marshal->type), marshal->version,
|
marshal->type, spa_debug_type_find_name(pw_type_info(), marshal->type),
|
||||||
protocol->name);
|
marshal->version, protocol->name);
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -37,6 +37,8 @@
|
||||||
|
|
||||||
#include "extensions/protocol-native.h"
|
#include "extensions/protocol-native.h"
|
||||||
|
|
||||||
|
#define NAME "remote"
|
||||||
|
|
||||||
/** \cond */
|
/** \cond */
|
||||||
|
|
||||||
struct remote {
|
struct remote {
|
||||||
|
|
@ -75,7 +77,7 @@ pw_remote_update_state(struct pw_remote *remote, enum pw_remote_state state, con
|
||||||
|
|
||||||
va_start(varargs, fmt);
|
va_start(varargs, fmt);
|
||||||
if (vasprintf(&remote->error, fmt, varargs) < 0) {
|
if (vasprintf(&remote->error, fmt, varargs) < 0) {
|
||||||
pw_log_debug("remote %p: error formating message: %m", remote);
|
pw_log_debug(NAME" %p: error formating message: %m", remote);
|
||||||
remote->error = NULL;
|
remote->error = NULL;
|
||||||
}
|
}
|
||||||
va_end(varargs);
|
va_end(varargs);
|
||||||
|
|
@ -83,11 +85,11 @@ pw_remote_update_state(struct pw_remote *remote, enum pw_remote_state state, con
|
||||||
remote->error = NULL;
|
remote->error = NULL;
|
||||||
}
|
}
|
||||||
if (state == PW_REMOTE_STATE_ERROR) {
|
if (state == PW_REMOTE_STATE_ERROR) {
|
||||||
pw_log_error("remote %p: update state from %s -> %s (%s)", remote,
|
pw_log_error(NAME" %p: update state from %s -> %s (%s)", remote,
|
||||||
pw_remote_state_as_string(old),
|
pw_remote_state_as_string(old),
|
||||||
pw_remote_state_as_string(state), remote->error);
|
pw_remote_state_as_string(state), remote->error);
|
||||||
} else {
|
} else {
|
||||||
pw_log_debug("remote %p: update state from %s -> %s", remote,
|
pw_log_debug(NAME" %p: update state from %s -> %s", remote,
|
||||||
pw_remote_state_as_string(old),
|
pw_remote_state_as_string(old),
|
||||||
pw_remote_state_as_string(state));
|
pw_remote_state_as_string(state));
|
||||||
}
|
}
|
||||||
|
|
@ -101,7 +103,7 @@ pw_remote_update_state(struct pw_remote *remote, enum pw_remote_state state, con
|
||||||
static void core_event_ping(void *data, uint32_t id, int seq)
|
static void core_event_ping(void *data, uint32_t id, int seq)
|
||||||
{
|
{
|
||||||
struct pw_remote *this = data;
|
struct pw_remote *this = data;
|
||||||
pw_log_debug("remote %p: object %u ping %u", this, id, seq);
|
pw_log_debug(NAME" %p: object %u ping %u", this, id, seq);
|
||||||
pw_core_proxy_pong(this->core_proxy, id, seq);
|
pw_core_proxy_pong(this->core_proxy, id, seq);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -110,7 +112,7 @@ static void core_event_done(void *data, uint32_t id, int seq)
|
||||||
struct pw_remote *this = data;
|
struct pw_remote *this = data;
|
||||||
struct pw_proxy *proxy;
|
struct pw_proxy *proxy;
|
||||||
|
|
||||||
pw_log_debug("remote %p: object %u done %d", this, id, seq);
|
pw_log_debug(NAME" %p: object %u done %d", this, id, seq);
|
||||||
|
|
||||||
proxy = pw_map_lookup(&this->objects, id);
|
proxy = pw_map_lookup(&this->objects, id);
|
||||||
if (proxy)
|
if (proxy)
|
||||||
|
|
@ -122,7 +124,7 @@ static void core_event_error(void *data, uint32_t id, int seq, int res, const ch
|
||||||
struct pw_remote *this = data;
|
struct pw_remote *this = data;
|
||||||
struct pw_proxy *proxy;
|
struct pw_proxy *proxy;
|
||||||
|
|
||||||
pw_log_error("remote %p: object error %u: seq:%d %d (%s): %s", this, id, seq,
|
pw_log_error(NAME" %p: object error %u: seq:%d %d (%s): %s", this, id, seq,
|
||||||
res, spa_strerror(res), message);
|
res, spa_strerror(res), message);
|
||||||
|
|
||||||
proxy = pw_map_lookup(&this->objects, id);
|
proxy = pw_map_lookup(&this->objects, id);
|
||||||
|
|
@ -135,7 +137,7 @@ static void core_event_remove_id(void *data, uint32_t id)
|
||||||
struct pw_remote *this = data;
|
struct pw_remote *this = data;
|
||||||
struct pw_proxy *proxy;
|
struct pw_proxy *proxy;
|
||||||
|
|
||||||
pw_log_debug("remote %p: object remove %u", this, id);
|
pw_log_debug(NAME" %p: object remove %u", this, id);
|
||||||
if ((proxy = pw_map_lookup(&this->objects, id)) != NULL) {
|
if ((proxy = pw_map_lookup(&this->objects, id)) != NULL) {
|
||||||
proxy->removed = true;
|
proxy->removed = true;
|
||||||
pw_proxy_destroy(proxy);
|
pw_proxy_destroy(proxy);
|
||||||
|
|
@ -148,11 +150,11 @@ static void core_event_add_mem(void *data, uint32_t id, uint32_t type, int fd, u
|
||||||
struct pw_remote *this = data;
|
struct pw_remote *this = data;
|
||||||
struct pw_memblock *m;
|
struct pw_memblock *m;
|
||||||
|
|
||||||
pw_log_debug("remote %p: add mem %u type:%u fd:%d flags:%u", this, id, type, fd, flags);
|
pw_log_debug(NAME" %p: add mem %u type:%u fd:%d flags:%u", this, id, type, fd, flags);
|
||||||
|
|
||||||
m = pw_mempool_import(this->pool, flags, type, fd);
|
m = pw_mempool_import(this->pool, flags, type, fd);
|
||||||
if (m->id != id) {
|
if (m->id != id) {
|
||||||
pw_log_error("remote %p: invalid mem id %u, expected %u",
|
pw_log_error(NAME" %p: invalid mem id %u, expected %u",
|
||||||
this, id, m->id);
|
this, id, m->id);
|
||||||
pw_memblock_unref(m);
|
pw_memblock_unref(m);
|
||||||
}
|
}
|
||||||
|
|
@ -161,7 +163,7 @@ static void core_event_add_mem(void *data, uint32_t id, uint32_t type, int fd, u
|
||||||
static void core_event_remove_mem(void *data, uint32_t id)
|
static void core_event_remove_mem(void *data, uint32_t id)
|
||||||
{
|
{
|
||||||
struct pw_remote *this = data;
|
struct pw_remote *this = data;
|
||||||
pw_log_debug("remote %p: remove mem %u", this, id);
|
pw_log_debug(NAME" %p: remove mem %u", this, id);
|
||||||
pw_mempool_unref_id(this->pool, id);
|
pw_mempool_unref_id(this->pool, id);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -193,7 +195,7 @@ struct pw_remote *pw_remote_new(struct pw_core *core,
|
||||||
}
|
}
|
||||||
|
|
||||||
this = &impl->this;
|
this = &impl->this;
|
||||||
pw_log_debug("remote %p: new", impl);
|
pw_log_debug(NAME" %p: new", impl);
|
||||||
|
|
||||||
this->core = core;
|
this->core = core;
|
||||||
|
|
||||||
|
|
@ -248,14 +250,14 @@ struct pw_remote *pw_remote_new(struct pw_core *core,
|
||||||
|
|
||||||
error_properties:
|
error_properties:
|
||||||
res = -errno;
|
res = -errno;
|
||||||
pw_log_error("can't create properties: %m");
|
pw_log_error(NAME" %p: can't create properties: %m", this);
|
||||||
goto exit_free;
|
goto exit_free;
|
||||||
error_protocol:
|
error_protocol:
|
||||||
pw_log_error("can't load native protocol: %s", spa_strerror(res));
|
pw_log_error(NAME" %p: can't load native protocol: %s", this, spa_strerror(res));
|
||||||
goto exit_free;
|
goto exit_free;
|
||||||
error_connection:
|
error_connection:
|
||||||
res = -errno;
|
res = -errno;
|
||||||
pw_log_error("can't create new native protocol connection: %m");
|
pw_log_error(NAME" %p: can't create new native protocol connection: %m", this);
|
||||||
goto exit_free;
|
goto exit_free;
|
||||||
|
|
||||||
exit_free:
|
exit_free:
|
||||||
|
|
@ -273,7 +275,7 @@ void pw_remote_destroy(struct pw_remote *remote)
|
||||||
struct remote *impl = SPA_CONTAINER_OF(remote, struct remote, this);
|
struct remote *impl = SPA_CONTAINER_OF(remote, struct remote, this);
|
||||||
struct pw_stream *stream;
|
struct pw_stream *stream;
|
||||||
|
|
||||||
pw_log_debug("remote %p: destroy", remote);
|
pw_log_debug(NAME" %p: destroy", remote);
|
||||||
pw_remote_emit_destroy(remote);
|
pw_remote_emit_destroy(remote);
|
||||||
|
|
||||||
if (remote->state != PW_REMOTE_STATE_UNCONNECTED)
|
if (remote->state != PW_REMOTE_STATE_UNCONNECTED)
|
||||||
|
|
@ -288,7 +290,7 @@ void pw_remote_destroy(struct pw_remote *remote)
|
||||||
|
|
||||||
pw_map_clear(&remote->objects);
|
pw_map_clear(&remote->objects);
|
||||||
|
|
||||||
pw_log_debug("remote %p: free", remote);
|
pw_log_debug(NAME" %p: free", remote);
|
||||||
pw_mempool_destroy(remote->pool);
|
pw_mempool_destroy(remote->pool);
|
||||||
pw_properties_free(remote->properties);
|
pw_properties_free(remote->properties);
|
||||||
free(remote->error);
|
free(remote->error);
|
||||||
|
|
@ -314,7 +316,7 @@ int pw_remote_update_properties(struct pw_remote *remote, const struct spa_dict
|
||||||
|
|
||||||
changed = pw_properties_update(remote->properties, dict);
|
changed = pw_properties_update(remote->properties, dict);
|
||||||
|
|
||||||
pw_log_debug("remote %p: updated %d properties", remote, changed);
|
pw_log_debug(NAME" %p: updated %d properties", remote, changed);
|
||||||
|
|
||||||
if (!changed)
|
if (!changed)
|
||||||
return 0;
|
return 0;
|
||||||
|
|
@ -470,7 +472,7 @@ int pw_remote_disconnect(struct pw_remote *remote)
|
||||||
struct pw_proxy *proxy;
|
struct pw_proxy *proxy;
|
||||||
struct pw_stream *stream, *s2;
|
struct pw_stream *stream, *s2;
|
||||||
|
|
||||||
pw_log_debug("remote %p: disconnect", remote);
|
pw_log_debug(NAME" %p: disconnect", remote);
|
||||||
spa_list_for_each_safe(stream, s2, &remote->stream_list, link)
|
spa_list_for_each_safe(stream, s2, &remote->stream_list, link)
|
||||||
pw_stream_disconnect(stream);
|
pw_stream_disconnect(stream);
|
||||||
|
|
||||||
|
|
@ -517,13 +519,13 @@ struct pw_proxy *pw_remote_export(struct pw_remote *remote,
|
||||||
return proxy;
|
return proxy;
|
||||||
|
|
||||||
error_core_proxy:
|
error_core_proxy:
|
||||||
pw_log_error("no core proxy: %s", spa_strerror(res));
|
pw_log_error(NAME" %p: no core proxy: %s", remote, spa_strerror(res));
|
||||||
goto exit;
|
goto exit;
|
||||||
error_export_type:
|
error_export_type:
|
||||||
pw_log_error("can't export type %d: %s", type, spa_strerror(res));
|
pw_log_error(NAME" %p: can't export type %d: %s", remote, type, spa_strerror(res));
|
||||||
goto exit;
|
goto exit;
|
||||||
error_proxy_failed:
|
error_proxy_failed:
|
||||||
pw_log_error("failed to create proxy: %s", spa_strerror(res));
|
pw_log_error(NAME" %p: failed to create proxy: %s", remote, spa_strerror(res));
|
||||||
goto exit;
|
goto exit;
|
||||||
exit:
|
exit:
|
||||||
errno = -res;
|
errno = -res;
|
||||||
|
|
@ -533,7 +535,7 @@ exit:
|
||||||
SPA_EXPORT
|
SPA_EXPORT
|
||||||
int pw_core_register_export_type(struct pw_core *core, struct pw_export_type *type)
|
int pw_core_register_export_type(struct pw_core *core, struct pw_export_type *type)
|
||||||
{
|
{
|
||||||
pw_log_debug("Add export type %d/%s to core", type->type,
|
pw_log_debug("core %p: Add export type %d/%s to core", core, type->type,
|
||||||
spa_debug_type_find_name(pw_type_info(), type->type));
|
spa_debug_type_find_name(pw_type_info(), type->type));
|
||||||
spa_list_append(&core->export_list, &type->link);
|
spa_list_append(&core->export_list, &type->link);
|
||||||
return 0;
|
return 0;
|
||||||
|
|
|
||||||
|
|
@ -32,6 +32,8 @@
|
||||||
|
|
||||||
#include <spa/debug/types.h>
|
#include <spa/debug/types.h>
|
||||||
|
|
||||||
|
#define NAME "resource"
|
||||||
|
|
||||||
/** \cond */
|
/** \cond */
|
||||||
struct impl {
|
struct impl {
|
||||||
struct pw_resource this;
|
struct pw_resource this;
|
||||||
|
|
@ -66,7 +68,7 @@ struct pw_resource *pw_resource_new(struct pw_client *client,
|
||||||
|
|
||||||
this->marshal = pw_protocol_get_marshal(client->protocol, type);
|
this->marshal = pw_protocol_get_marshal(client->protocol, type);
|
||||||
if (this->marshal == NULL) {
|
if (this->marshal == NULL) {
|
||||||
pw_log_error("resource %p: no marshal for type %d", this, type);
|
pw_log_error(NAME" %p: no marshal for type %d", this, type);
|
||||||
res = -EPROTO;
|
res = -EPROTO;
|
||||||
goto error_clean;
|
goto error_clean;
|
||||||
}
|
}
|
||||||
|
|
@ -78,7 +80,7 @@ struct pw_resource *pw_resource_new(struct pw_client *client,
|
||||||
|
|
||||||
if ((res = pw_map_insert_at(&client->objects, id, this)) < 0) {
|
if ((res = pw_map_insert_at(&client->objects, id, this)) < 0) {
|
||||||
res = -errno;
|
res = -errno;
|
||||||
pw_log_error("resource %p: can't add id %u for client %p: %m",
|
pw_log_error(NAME" %p: can't add id %u for client %p: %m",
|
||||||
this, id, client);
|
this, id, client);
|
||||||
goto error_clean;
|
goto error_clean;
|
||||||
}
|
}
|
||||||
|
|
@ -93,7 +95,7 @@ struct pw_resource *pw_resource_new(struct pw_client *client,
|
||||||
this->marshal->version,
|
this->marshal->version,
|
||||||
this->marshal->event_marshal, this);
|
this->marshal->event_marshal, this);
|
||||||
|
|
||||||
pw_log_debug("resource %p: new %u %s/%d client %p marshal %p",
|
pw_log_debug(NAME" %p: new %u %s/%d client %p marshal %p",
|
||||||
this, id,
|
this, id,
|
||||||
spa_debug_type_find_name(pw_type_info(), type), version,
|
spa_debug_type_find_name(pw_type_info(), type), version,
|
||||||
client, this->marshal);
|
client, this->marshal);
|
||||||
|
|
@ -182,7 +184,7 @@ int pw_resource_ping(struct pw_resource *resource, int seq)
|
||||||
if (client->core_resource != NULL) {
|
if (client->core_resource != NULL) {
|
||||||
pw_core_resource_ping(client->core_resource, resource->id, seq);
|
pw_core_resource_ping(client->core_resource, resource->id, seq);
|
||||||
res = client->send_seq;
|
res = client->send_seq;
|
||||||
pw_log_debug("resource %p: %u seq:%d ping %d", resource, resource->id, seq, res);
|
pw_log_debug(NAME" %p: %u seq:%d ping %d", resource, resource->id, seq, res);
|
||||||
}
|
}
|
||||||
return res;
|
return res;
|
||||||
}
|
}
|
||||||
|
|
@ -205,7 +207,7 @@ void pw_resource_destroy(struct pw_resource *resource)
|
||||||
{
|
{
|
||||||
struct pw_client *client = resource->client;
|
struct pw_client *client = resource->client;
|
||||||
|
|
||||||
pw_log_debug("resource %p: destroy %u", resource, resource->id);
|
pw_log_debug(NAME" %p: destroy %u", resource, resource->id);
|
||||||
pw_resource_emit_destroy(resource);
|
pw_resource_emit_destroy(resource);
|
||||||
|
|
||||||
pw_map_insert_at(&client->objects, resource->id, NULL);
|
pw_map_insert_at(&client->objects, resource->id, NULL);
|
||||||
|
|
@ -214,6 +216,6 @@ void pw_resource_destroy(struct pw_resource *resource)
|
||||||
if (client->core_resource && !resource->removed)
|
if (client->core_resource && !resource->removed)
|
||||||
pw_core_resource_remove_id(client->core_resource, resource->id);
|
pw_core_resource_remove_id(client->core_resource, resource->id);
|
||||||
|
|
||||||
pw_log_debug("resource %p: free", resource);
|
pw_log_debug(NAME" %p: free", resource);
|
||||||
free(resource);
|
free(resource);
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -29,6 +29,8 @@
|
||||||
#include "log.h"
|
#include "log.h"
|
||||||
#include "thread-loop.h"
|
#include "thread-loop.h"
|
||||||
|
|
||||||
|
#define NAME "thread-loop"
|
||||||
|
|
||||||
#define pw_thread_loop_events_emit(o,m,v,...) spa_hook_list_call(&o->listener_list, struct pw_thread_loop_events, m, v, ##__VA_ARGS__)
|
#define pw_thread_loop_events_emit(o,m,v,...) spa_hook_list_call(&o->listener_list, struct pw_thread_loop_events, m, v, ##__VA_ARGS__)
|
||||||
#define pw_thread_loop_events_destroy(o) pw_thread_loop_events_emit(o, destroy, 0)
|
#define pw_thread_loop_events_destroy(o) pw_thread_loop_events_emit(o, destroy, 0)
|
||||||
|
|
||||||
|
|
@ -115,7 +117,7 @@ struct pw_thread_loop *pw_thread_loop_new(struct pw_loop *loop,
|
||||||
if (this == NULL)
|
if (this == NULL)
|
||||||
return NULL;
|
return NULL;
|
||||||
|
|
||||||
pw_log_debug("thread-loop %p: new", this);
|
pw_log_debug(NAME" %p: new", this);
|
||||||
|
|
||||||
this->loop = loop;
|
this->loop = loop;
|
||||||
this->name = name ? strdup(name) : NULL;
|
this->name = name ? strdup(name) : NULL;
|
||||||
|
|
@ -196,16 +198,16 @@ static void *do_loop(void *user_data)
|
||||||
int res;
|
int res;
|
||||||
|
|
||||||
pthread_mutex_lock(&this->lock);
|
pthread_mutex_lock(&this->lock);
|
||||||
pw_log_debug("thread-loop %p: enter thread", this);
|
pw_log_debug(NAME" %p: enter thread", this);
|
||||||
pthread_setname_np(this->thread, this->name ? this->name : "pipewire-thread");
|
pthread_setname_np(this->thread, this->name ? this->name : "pipewire-thread");
|
||||||
pw_loop_enter(this->loop);
|
pw_loop_enter(this->loop);
|
||||||
|
|
||||||
while (this->running) {
|
while (this->running) {
|
||||||
if ((res = pw_loop_iterate(this->loop, -1)) < 0)
|
if ((res = pw_loop_iterate(this->loop, -1)) < 0)
|
||||||
pw_log_warn("thread-loop %p: iterate error %d (%s)",
|
pw_log_warn(NAME" %p: iterate error %d (%s)",
|
||||||
this, res, spa_strerror(res));
|
this, res, spa_strerror(res));
|
||||||
}
|
}
|
||||||
pw_log_debug("thread-loop %p: leave thread", this);
|
pw_log_debug(NAME" %p: leave thread", this);
|
||||||
pw_loop_leave(this->loop);
|
pw_loop_leave(this->loop);
|
||||||
pthread_mutex_unlock(&this->lock);
|
pthread_mutex_unlock(&this->lock);
|
||||||
|
|
||||||
|
|
@ -227,7 +229,7 @@ int pw_thread_loop_start(struct pw_thread_loop *loop)
|
||||||
|
|
||||||
loop->running = true;
|
loop->running = true;
|
||||||
if ((err = pthread_create(&loop->thread, NULL, do_loop, loop)) != 0) {
|
if ((err = pthread_create(&loop->thread, NULL, do_loop, loop)) != 0) {
|
||||||
pw_log_warn("thread-loop %p: can't create thread: %s", loop,
|
pw_log_warn(NAME" %p: can't create thread: %s", loop,
|
||||||
strerror(err));
|
strerror(err));
|
||||||
loop->running = false;
|
loop->running = false;
|
||||||
return -err;
|
return -err;
|
||||||
|
|
@ -245,16 +247,16 @@ int pw_thread_loop_start(struct pw_thread_loop *loop)
|
||||||
SPA_EXPORT
|
SPA_EXPORT
|
||||||
void pw_thread_loop_stop(struct pw_thread_loop *loop)
|
void pw_thread_loop_stop(struct pw_thread_loop *loop)
|
||||||
{
|
{
|
||||||
pw_log_debug("thread-loop: %p stopping", loop);
|
pw_log_debug(NAME": %p stopping", loop);
|
||||||
if (loop->running) {
|
if (loop->running) {
|
||||||
pw_log_debug("thread-loop: %p signal", loop);
|
pw_log_debug(NAME": %p signal", loop);
|
||||||
pw_loop_signal_event(loop->loop, loop->event);
|
pw_loop_signal_event(loop->loop, loop->event);
|
||||||
pw_log_debug("thread-loop: %p join", loop);
|
pw_log_debug(NAME": %p join", loop);
|
||||||
pthread_join(loop->thread, NULL);
|
pthread_join(loop->thread, NULL);
|
||||||
pw_log_debug("thread-loop: %p joined", loop);
|
pw_log_debug(NAME": %p joined", loop);
|
||||||
loop->running = false;
|
loop->running = false;
|
||||||
}
|
}
|
||||||
pw_log_debug("thread-loop: %p stopped", loop);
|
pw_log_debug(NAME": %p stopped", loop);
|
||||||
}
|
}
|
||||||
|
|
||||||
/** Lock the mutex associated with \a loop
|
/** Lock the mutex associated with \a loop
|
||||||
|
|
@ -267,7 +269,7 @@ SPA_EXPORT
|
||||||
void pw_thread_loop_lock(struct pw_thread_loop *loop)
|
void pw_thread_loop_lock(struct pw_thread_loop *loop)
|
||||||
{
|
{
|
||||||
pthread_mutex_lock(&loop->lock);
|
pthread_mutex_lock(&loop->lock);
|
||||||
pw_log_trace("thread-loop: %p", loop);
|
pw_log_trace(NAME": %p", loop);
|
||||||
}
|
}
|
||||||
|
|
||||||
/** Unlock the mutex associated with \a loop
|
/** Unlock the mutex associated with \a loop
|
||||||
|
|
@ -279,7 +281,7 @@ void pw_thread_loop_lock(struct pw_thread_loop *loop)
|
||||||
SPA_EXPORT
|
SPA_EXPORT
|
||||||
void pw_thread_loop_unlock(struct pw_thread_loop *loop)
|
void pw_thread_loop_unlock(struct pw_thread_loop *loop)
|
||||||
{
|
{
|
||||||
pw_log_trace("thread-loop: %p", loop);
|
pw_log_trace(NAME": %p", loop);
|
||||||
pthread_mutex_unlock(&loop->lock);
|
pthread_mutex_unlock(&loop->lock);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -296,7 +298,7 @@ void pw_thread_loop_unlock(struct pw_thread_loop *loop)
|
||||||
SPA_EXPORT
|
SPA_EXPORT
|
||||||
void pw_thread_loop_signal(struct pw_thread_loop *loop, bool wait_for_accept)
|
void pw_thread_loop_signal(struct pw_thread_loop *loop, bool wait_for_accept)
|
||||||
{
|
{
|
||||||
pw_log_trace("thread-loop: %p, waiting:%d accept:%d",
|
pw_log_trace(NAME": %p, waiting:%d accept:%d",
|
||||||
loop, loop->n_waiting, wait_for_accept);
|
loop, loop->n_waiting, wait_for_accept);
|
||||||
if (loop->n_waiting > 0)
|
if (loop->n_waiting > 0)
|
||||||
pthread_cond_broadcast(&loop->cond);
|
pthread_cond_broadcast(&loop->cond);
|
||||||
|
|
@ -318,11 +320,11 @@ void pw_thread_loop_signal(struct pw_thread_loop *loop, bool wait_for_accept)
|
||||||
SPA_EXPORT
|
SPA_EXPORT
|
||||||
void pw_thread_loop_wait(struct pw_thread_loop *loop)
|
void pw_thread_loop_wait(struct pw_thread_loop *loop)
|
||||||
{
|
{
|
||||||
pw_log_trace("thread-loop: %p, waiting %d", loop, loop->n_waiting);
|
pw_log_trace(NAME": %p, waiting %d", loop, loop->n_waiting);
|
||||||
loop->n_waiting++;
|
loop->n_waiting++;
|
||||||
pthread_cond_wait(&loop->cond, &loop->lock);
|
pthread_cond_wait(&loop->cond, &loop->lock);
|
||||||
loop->n_waiting--;
|
loop->n_waiting--;
|
||||||
pw_log_trace("thread-loop: %p, waiting done %d", loop, loop->n_waiting);
|
pw_log_trace(NAME": %p, waiting done %d", loop, loop->n_waiting);
|
||||||
}
|
}
|
||||||
|
|
||||||
/** Wait for the loop thread to call \ref pw_thread_loop_signal()
|
/** Wait for the loop thread to call \ref pw_thread_loop_signal()
|
||||||
|
|
|
||||||
|
|
@ -32,6 +32,8 @@
|
||||||
#include "pipewire/log.h"
|
#include "pipewire/log.h"
|
||||||
#include "pipewire/work-queue.h"
|
#include "pipewire/work-queue.h"
|
||||||
|
|
||||||
|
#define NAME "work-queue"
|
||||||
|
|
||||||
/** \cond */
|
/** \cond */
|
||||||
struct work_item {
|
struct work_item {
|
||||||
void *obj;
|
void *obj;
|
||||||
|
|
@ -62,14 +64,14 @@ static void process_work_queue(void *data, uint64_t count)
|
||||||
|
|
||||||
spa_list_for_each_safe(item, tmp, &this->work_list, link) {
|
spa_list_for_each_safe(item, tmp, &this->work_list, link) {
|
||||||
if (item->seq != SPA_ID_INVALID) {
|
if (item->seq != SPA_ID_INVALID) {
|
||||||
pw_log_debug("work-queue %p: %d waiting for item %p %d", this,
|
pw_log_debug(NAME" %p: %d waiting for item %p %d", this,
|
||||||
this->n_queued, item->obj, item->seq);
|
this->n_queued, item->obj, item->seq);
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (item->res == -EBUSY &&
|
if (item->res == -EBUSY &&
|
||||||
item != spa_list_first(&this->work_list, struct work_item, link)) {
|
item != spa_list_first(&this->work_list, struct work_item, link)) {
|
||||||
pw_log_debug("work-queue %p: %d sync item %p not head", this,
|
pw_log_debug(NAME" %p: %d sync item %p not head", this,
|
||||||
this->n_queued, item->obj);
|
this->n_queued, item->obj);
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
@ -78,7 +80,7 @@ static void process_work_queue(void *data, uint64_t count)
|
||||||
this->n_queued--;
|
this->n_queued--;
|
||||||
|
|
||||||
if (item->func) {
|
if (item->func) {
|
||||||
pw_log_debug("work-queue %p: %d process work item %p %d %d", this,
|
pw_log_debug(NAME" %p: %d process work item %p %d %d", this,
|
||||||
this->n_queued, item->obj, item->seq, item->res);
|
this->n_queued, item->obj, item->seq, item->res);
|
||||||
item->func(item->obj, item->data, item->res, item->id);
|
item->func(item->obj, item->data, item->res, item->id);
|
||||||
}
|
}
|
||||||
|
|
@ -102,7 +104,7 @@ struct pw_work_queue *pw_work_queue_new(struct pw_loop *loop)
|
||||||
if (this == NULL)
|
if (this == NULL)
|
||||||
return NULL;
|
return NULL;
|
||||||
|
|
||||||
pw_log_debug("work-queue %p: new", this);
|
pw_log_debug(NAME" %p: new", this);
|
||||||
|
|
||||||
this->loop = loop;
|
this->loop = loop;
|
||||||
|
|
||||||
|
|
@ -132,12 +134,12 @@ void pw_work_queue_destroy(struct pw_work_queue *queue)
|
||||||
{
|
{
|
||||||
struct work_item *item, *tmp;
|
struct work_item *item, *tmp;
|
||||||
|
|
||||||
pw_log_debug("work-queue %p: destroy", queue);
|
pw_log_debug(NAME" %p: destroy", queue);
|
||||||
|
|
||||||
pw_loop_destroy_source(queue->loop, queue->wakeup);
|
pw_loop_destroy_source(queue->loop, queue->wakeup);
|
||||||
|
|
||||||
spa_list_for_each_safe(item, tmp, &queue->work_list, link) {
|
spa_list_for_each_safe(item, tmp, &queue->work_list, link) {
|
||||||
pw_log_warn("work-queue %p: cancel work item %p %d %d", queue,
|
pw_log_warn(NAME" %p: cancel work item %p %d %d", queue,
|
||||||
item->obj, item->seq, item->res);
|
item->obj, item->seq, item->res);
|
||||||
free(item);
|
free(item);
|
||||||
}
|
}
|
||||||
|
|
@ -179,9 +181,9 @@ pw_work_queue_add(struct pw_work_queue *queue, void *obj, int res, pw_work_func_
|
||||||
if (SPA_RESULT_IS_ASYNC(res)) {
|
if (SPA_RESULT_IS_ASYNC(res)) {
|
||||||
item->seq = SPA_RESULT_ASYNC_SEQ(res);
|
item->seq = SPA_RESULT_ASYNC_SEQ(res);
|
||||||
item->res = res;
|
item->res = res;
|
||||||
pw_log_debug("work-queue %p: defer async %d for object %p", queue, item->seq, obj);
|
pw_log_debug(NAME" %p: defer async %d for object %p", queue, item->seq, obj);
|
||||||
} else if (res == -EBUSY) {
|
} else if (res == -EBUSY) {
|
||||||
pw_log_debug("work-queue %p: wait sync object %p", queue, obj);
|
pw_log_debug(NAME" %p: wait sync object %p", queue, obj);
|
||||||
item->seq = SPA_ID_INVALID;
|
item->seq = SPA_ID_INVALID;
|
||||||
item->res = res;
|
item->res = res;
|
||||||
have_work = true;
|
have_work = true;
|
||||||
|
|
@ -189,7 +191,7 @@ pw_work_queue_add(struct pw_work_queue *queue, void *obj, int res, pw_work_func_
|
||||||
item->seq = SPA_ID_INVALID;
|
item->seq = SPA_ID_INVALID;
|
||||||
item->res = res;
|
item->res = res;
|
||||||
have_work = true;
|
have_work = true;
|
||||||
pw_log_debug("work-queue %p: defer object %p", queue, obj);
|
pw_log_debug(NAME" %p: defer object %p", queue, obj);
|
||||||
}
|
}
|
||||||
spa_list_append(&queue->work_list, &item->link);
|
spa_list_append(&queue->work_list, &item->link);
|
||||||
queue->n_queued++;
|
queue->n_queued++;
|
||||||
|
|
@ -214,7 +216,7 @@ int pw_work_queue_cancel(struct pw_work_queue *queue, void *obj, uint32_t id)
|
||||||
|
|
||||||
spa_list_for_each(item, &queue->work_list, link) {
|
spa_list_for_each(item, &queue->work_list, link) {
|
||||||
if ((id == SPA_ID_INVALID || item->id == id) && (obj == NULL || item->obj == obj)) {
|
if ((id == SPA_ID_INVALID || item->id == id) && (obj == NULL || item->obj == obj)) {
|
||||||
pw_log_debug("work-queue %p: cancel defer %d for object %p", queue,
|
pw_log_debug(NAME" %p: cancel defer %d for object %p", queue,
|
||||||
item->seq, item->obj);
|
item->seq, item->obj);
|
||||||
item->seq = SPA_ID_INVALID;
|
item->seq = SPA_ID_INVALID;
|
||||||
item->func = NULL;
|
item->func = NULL;
|
||||||
|
|
@ -222,7 +224,7 @@ int pw_work_queue_cancel(struct pw_work_queue *queue, void *obj, uint32_t id)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (!have_work) {
|
if (!have_work) {
|
||||||
pw_log_debug("work-queue %p: no defered found for object %p", queue, obj);
|
pw_log_debug(NAME" %p: no defered found for object %p", queue, obj);
|
||||||
return -EINVAL;
|
return -EINVAL;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -245,7 +247,7 @@ int pw_work_queue_complete(struct pw_work_queue *queue, void *obj, uint32_t seq,
|
||||||
|
|
||||||
spa_list_for_each(item, &queue->work_list, link) {
|
spa_list_for_each(item, &queue->work_list, link) {
|
||||||
if (item->obj == obj && item->seq == seq) {
|
if (item->obj == obj && item->seq == seq) {
|
||||||
pw_log_debug("work-queue %p: found defered %d for object %p", queue, seq,
|
pw_log_debug(NAME" %p: found defered %d for object %p", queue, seq,
|
||||||
obj);
|
obj);
|
||||||
item->seq = SPA_ID_INVALID;
|
item->seq = SPA_ID_INVALID;
|
||||||
item->res = res;
|
item->res = res;
|
||||||
|
|
@ -253,7 +255,7 @@ int pw_work_queue_complete(struct pw_work_queue *queue, void *obj, uint32_t seq,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (!have_work) {
|
if (!have_work) {
|
||||||
pw_log_trace("work-queue %p: no defered %d found for object %p", queue, seq, obj);
|
pw_log_trace(NAME" %p: no defered %d found for object %p", queue, seq, obj);
|
||||||
return -EINVAL;
|
return -EINVAL;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue