mirror of
https://gitlab.freedesktop.org/pipewire/pipewire.git
synced 2025-11-02 09:01:50 -05:00
avoid including private.h
Expose some more methods to make it possible to build without including the private.h header, especially in modules.
This commit is contained in:
parent
8e6a5a1714
commit
df519ee3b3
43 changed files with 349 additions and 372 deletions
|
|
@ -26,7 +26,7 @@
|
|||
#include <stdbool.h>
|
||||
#include <string.h>
|
||||
|
||||
#include <pipewire/pipewire.h>
|
||||
#include <pipewire/impl.h>
|
||||
#include <extensions/session-manager.h>
|
||||
|
||||
#include <spa/pod/filter.h>
|
||||
|
|
@ -34,13 +34,10 @@
|
|||
#include "session.h"
|
||||
#include "client-session.h"
|
||||
|
||||
#include <pipewire/private.h>
|
||||
|
||||
#define NAME "session"
|
||||
|
||||
struct resource_data {
|
||||
struct session *session;
|
||||
struct spa_hook resource_listener;
|
||||
struct spa_hook object_listener;
|
||||
uint32_t n_subscribe_ids;
|
||||
uint32_t subscribe_ids[32];
|
||||
|
|
@ -104,7 +101,7 @@ static int session_subscribe_params (void *object, uint32_t *ids, uint32_t n_ids
|
|||
for (i = 0; i < n_ids; i++) {
|
||||
data->subscribe_ids[i] = ids[i];
|
||||
pw_log_debug(NAME" %p: resource %d subscribe param %u",
|
||||
data->session, resource->id, ids[i]);
|
||||
data->session, pw_resource_get_id(resource), ids[i]);
|
||||
session_enum_params(resource, 1, ids[i], 0, UINT32_MAX, NULL);
|
||||
}
|
||||
return 0;
|
||||
|
|
@ -130,30 +127,54 @@ static const struct pw_session_methods methods = {
|
|||
.set_param = session_set_param,
|
||||
};
|
||||
|
||||
struct emit_param_data {
|
||||
struct session *this;
|
||||
struct spa_pod *param;
|
||||
uint32_t id;
|
||||
uint32_t index;
|
||||
uint32_t next;
|
||||
};
|
||||
|
||||
static int emit_param(void *_data, struct pw_resource *resource)
|
||||
{
|
||||
struct emit_param_data *d = _data;
|
||||
struct resource_data *data;
|
||||
uint32_t i;
|
||||
|
||||
data = pw_resource_get_user_data(resource);
|
||||
for (i = 0; i < data->n_subscribe_ids; i++) {
|
||||
if (data->subscribe_ids[i] == d->id) {
|
||||
pw_session_resource_param(resource, 1,
|
||||
d->id, d->index, d->next, d->param);
|
||||
}
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
static void session_notify_subscribed(struct session *this,
|
||||
uint32_t index, uint32_t next)
|
||||
{
|
||||
struct pw_global *global = this->global;
|
||||
struct pw_resource *resource;
|
||||
struct resource_data *data;
|
||||
struct emit_param_data data;
|
||||
struct spa_pod *param = this->params[index];
|
||||
uint32_t id;
|
||||
uint32_t i;
|
||||
|
||||
if (!param || !spa_pod_is_object (param))
|
||||
return;
|
||||
|
||||
id = SPA_POD_OBJECT_ID (param);
|
||||
data.this = this;
|
||||
data.param = param;
|
||||
data.id = SPA_POD_OBJECT_ID (param);
|
||||
data.index = index;
|
||||
data.next = next;
|
||||
|
||||
spa_list_for_each(resource, &global->resource_list, link) {
|
||||
data = pw_resource_get_user_data(resource);
|
||||
for (i = 0; i < data->n_subscribe_ids; i++) {
|
||||
if (data->subscribe_ids[i] == id) {
|
||||
pw_session_resource_param(resource, 1, id,
|
||||
index, next, param);
|
||||
}
|
||||
}
|
||||
}
|
||||
pw_global_for_each_resource(global, emit_param, &data);
|
||||
}
|
||||
|
||||
static int emit_info(void *data, struct pw_resource *resource)
|
||||
{
|
||||
struct session *this = data;
|
||||
pw_session_resource_info(resource, &this->info);
|
||||
return 0;
|
||||
}
|
||||
|
||||
int session_update(struct session *this,
|
||||
|
|
@ -184,8 +205,6 @@ int session_update(struct session *this,
|
|||
}
|
||||
|
||||
if (change_mask & PW_CLIENT_SESSION_UPDATE_INFO) {
|
||||
struct pw_resource *resource;
|
||||
|
||||
if (info->change_mask & PW_SESSION_CHANGE_MASK_PROPS)
|
||||
pw_properties_update(this->props, info->props);
|
||||
|
||||
|
|
@ -203,9 +222,7 @@ int session_update(struct session *this,
|
|||
}
|
||||
|
||||
this->info.change_mask = info->change_mask;
|
||||
spa_list_for_each(resource, &this->global->resource_list, link) {
|
||||
pw_session_resource_info(resource, &this->info);
|
||||
}
|
||||
pw_global_for_each_resource(this->global, emit_info, this);
|
||||
this->info.change_mask = 0;
|
||||
}
|
||||
|
||||
|
|
@ -218,17 +235,6 @@ int session_update(struct session *this,
|
|||
return -ENOMEM;
|
||||
}
|
||||
|
||||
static void session_unbind(void *data)
|
||||
{
|
||||
struct pw_resource *resource = data;
|
||||
spa_list_remove(&resource->link);
|
||||
}
|
||||
|
||||
static const struct pw_resource_events resource_events = {
|
||||
PW_VERSION_RESOURCE_EVENTS,
|
||||
.destroy = session_unbind,
|
||||
};
|
||||
|
||||
static int session_bind(void *_data, struct pw_impl_client *client,
|
||||
uint32_t permissions, uint32_t version, uint32_t id)
|
||||
{
|
||||
|
|
@ -237,20 +243,19 @@ static int session_bind(void *_data, struct pw_impl_client *client,
|
|||
struct pw_resource *resource;
|
||||
struct resource_data *data;
|
||||
|
||||
resource = pw_resource_new(client, id, permissions, global->type, version, sizeof(*data));
|
||||
resource = pw_resource_new(client, id, permissions,
|
||||
pw_global_get_type(global), version, sizeof(*data));
|
||||
if (resource == NULL)
|
||||
goto no_mem;
|
||||
|
||||
data = pw_resource_get_user_data(resource);
|
||||
data->session = this;
|
||||
pw_resource_add_listener(resource, &data->resource_listener,
|
||||
&resource_events, resource);
|
||||
|
||||
pw_resource_add_object_listener(resource, &data->object_listener,
|
||||
&methods, resource);
|
||||
|
||||
pw_log_debug(NAME" %p: bound to %d", this, resource->id);
|
||||
|
||||
spa_list_append(&global->resource_list, &resource->link);
|
||||
pw_log_debug(NAME" %p: bound to %d", this, pw_resource_get_id(resource));
|
||||
pw_global_add_resource(global, resource);
|
||||
|
||||
this->info.change_mask = PW_SESSION_CHANGE_MASK_ALL;
|
||||
pw_session_resource_info(resource, &this->info);
|
||||
|
|
@ -294,13 +299,14 @@ int session_init(struct session *this,
|
|||
if (!this->global)
|
||||
goto no_mem;
|
||||
|
||||
pw_properties_setf(this->props, PW_KEY_OBJECT_ID, "%u", this->global->id);
|
||||
pw_properties_setf(this->props, PW_KEY_OBJECT_ID, "%u",
|
||||
pw_global_get_id(this->global));
|
||||
|
||||
this->info.version = PW_VERSION_SESSION_INFO;
|
||||
this->info.id = this->global->id;
|
||||
this->info.id = pw_global_get_id(this->global);
|
||||
this->info.props = &this->props->dict;
|
||||
|
||||
pw_resource_set_bound_id(client_sess->resource, this->global->id);
|
||||
pw_resource_set_bound_id(client_sess->resource, this->info.id);
|
||||
|
||||
return pw_global_register(this->global);
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue