mirror of
https://gitlab.freedesktop.org/pipewire/pipewire.git
synced 2026-06-02 21:38:58 -04:00
wip check global session object in pw_context_connect
This commit is contained in:
parent
ead3a99fd9
commit
0a31d58e00
8 changed files with 65 additions and 23 deletions
|
|
@ -325,7 +325,6 @@ int endpoint_init(struct endpoint *this,
|
||||||
PW_KEY_NODE_ID,
|
PW_KEY_NODE_ID,
|
||||||
PW_KEY_MEDIA_CLASS,
|
PW_KEY_MEDIA_CLASS,
|
||||||
PW_KEY_SESSION_ID,
|
PW_KEY_SESSION_ID,
|
||||||
PW_KEY_SESSION_SERVICES,
|
|
||||||
PW_KEY_PRIORITY_SESSION,
|
PW_KEY_PRIORITY_SESSION,
|
||||||
PW_KEY_ENDPOINT_NAME,
|
PW_KEY_ENDPOINT_NAME,
|
||||||
PW_KEY_ENDPOINT_CLIENT_ID,
|
PW_KEY_ENDPOINT_CLIENT_ID,
|
||||||
|
|
|
||||||
|
|
@ -283,6 +283,8 @@ int client_session_factory_init(struct pw_impl_module *module)
|
||||||
if (factory == NULL)
|
if (factory == NULL)
|
||||||
return -ENOMEM;
|
return -ENOMEM;
|
||||||
|
|
||||||
|
pw_log_error("create \"client-session\" factory from client-session");
|
||||||
|
|
||||||
data = pw_impl_factory_get_user_data(factory);
|
data = pw_impl_factory_get_user_data(factory);
|
||||||
data->factory = factory;
|
data->factory = factory;
|
||||||
data->module = module;
|
data->module = module;
|
||||||
|
|
|
||||||
|
|
@ -306,6 +306,8 @@ int session_init(struct session *this,
|
||||||
if (!this->global)
|
if (!this->global)
|
||||||
goto no_mem;
|
goto no_mem;
|
||||||
|
|
||||||
|
pw_log_error("create global session object from client-session with id=%u", pw_global_get_id(this->global));
|
||||||
|
|
||||||
pw_properties_setf(this->props, PW_KEY_OBJECT_ID, "%u",
|
pw_properties_setf(this->props, PW_KEY_OBJECT_ID, "%u",
|
||||||
pw_global_get_id(this->global));
|
pw_global_get_id(this->global));
|
||||||
pw_properties_setf(this->props, PW_KEY_OBJECT_SERIAL, "%"PRIu64,
|
pw_properties_setf(this->props, PW_KEY_OBJECT_SERIAL, "%"PRIu64,
|
||||||
|
|
|
||||||
|
|
@ -168,6 +168,8 @@ struct pw_proxy *pw_core_session_export(struct pw_core *core,
|
||||||
user_data_size + sizeof(struct object_data));
|
user_data_size + sizeof(struct object_data));
|
||||||
if (proxy == NULL)
|
if (proxy == NULL)
|
||||||
return NULL;
|
return NULL;
|
||||||
|
|
||||||
|
pw_log_error("created session proxy from proxy-session-manager with proxy id=%u", pw_proxy_get_id(proxy));
|
||||||
|
|
||||||
data = pw_proxy_get_user_data(proxy);
|
data = pw_proxy_get_user_data(proxy);
|
||||||
data = SPA_PTROFF(data, user_data_size, struct object_data);
|
data = SPA_PTROFF(data, user_data_size, struct object_data);
|
||||||
|
|
|
||||||
|
|
@ -556,6 +556,8 @@ int session_factory_init(struct pw_impl_module *module)
|
||||||
sizeof(*data));
|
sizeof(*data));
|
||||||
if (factory == NULL)
|
if (factory == NULL)
|
||||||
return -errno;
|
return -errno;
|
||||||
|
|
||||||
|
pw_log_error("created session factory from module-session-manager");
|
||||||
|
|
||||||
data = pw_impl_factory_get_user_data(factory);
|
data = pw_impl_factory_get_user_data(factory);
|
||||||
data->factory = factory;
|
data->factory = factory;
|
||||||
|
|
|
||||||
|
|
@ -37,7 +37,7 @@
|
||||||
#include "pipewire/private.h"
|
#include "pipewire/private.h"
|
||||||
|
|
||||||
#include "pipewire/extensions/protocol-native.h"
|
#include "pipewire/extensions/protocol-native.h"
|
||||||
#include "pipewire/extensions/session-manager/keys.h"
|
#include "pipewire/extensions/session-manager.h"
|
||||||
|
|
||||||
PW_LOG_TOPIC_EXTERN(log_core);
|
PW_LOG_TOPIC_EXTERN(log_core);
|
||||||
#define PW_LOG_TOPIC_DEFAULT log_core
|
#define PW_LOG_TOPIC_DEFAULT log_core
|
||||||
|
|
@ -297,6 +297,7 @@ struct pw_proxy *pw_core_export(struct pw_core *core,
|
||||||
goto error_proxy_failed;
|
goto error_proxy_failed;
|
||||||
}
|
}
|
||||||
pw_log_debug("%p: export:%s proxy:%p", core, type, proxy);
|
pw_log_debug("%p: export:%s proxy:%p", core, type, proxy);
|
||||||
|
pw_log_error("%p: export:%s proxy:%p", core, type, proxy);
|
||||||
return proxy;
|
return proxy;
|
||||||
|
|
||||||
error_export_type:
|
error_export_type:
|
||||||
|
|
@ -402,44 +403,76 @@ exit_cleanup:
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
SPA_EXPORT
|
static void
|
||||||
void
|
signal_service_added()
|
||||||
pw_context_add_service(struct pw_context *context, const char *service)
|
|
||||||
{
|
{
|
||||||
struct pw_properties *props = pw_context_get_properties (context);
|
|
||||||
const char* old_services = pw_properties_get(props, PW_KEY_SESSION_SERVICES);
|
|
||||||
// TODO: avoid adding duplicates
|
|
||||||
pw_properties_setf(props, PW_KEY_SESSION_SERVICES, "%s test", old_services);
|
|
||||||
pw_log_error("ADDED SERVICE!");
|
|
||||||
pw_log_error("session.services: %s", pw_properties_get(props, PW_KEY_SESSION_SERVICES));
|
|
||||||
pthread_mutex_lock(&service_added_lock);
|
pthread_mutex_lock(&service_added_lock);
|
||||||
pthread_cond_signal(&service_added_cv);
|
pthread_cond_signal(&service_added_cv);
|
||||||
pthread_mutex_unlock(&service_added_lock);
|
pthread_mutex_unlock(&service_added_lock);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// /* [registry_event_global] */
|
||||||
|
// static void registry_event_global(void *_data, uint32_t id,
|
||||||
|
// uint32_t permissions, const char *type,
|
||||||
|
// uint32_t version, const struct spa_dict *props)
|
||||||
|
// {
|
||||||
|
// struct data *data = _data;
|
||||||
|
// if (data->client != NULL)
|
||||||
|
// return;
|
||||||
|
// if (strcmp(type, PW_TYPE_INTERFACE_Client) == 0) {
|
||||||
|
// data->client = pw_registry_bind(data->registry,
|
||||||
|
// id, type, PW_VERSION_CLIENT, 0);
|
||||||
|
// pw_client_add_listener(data->client,
|
||||||
|
// &data->client_listener,
|
||||||
|
// &client_events, data);
|
||||||
|
// }
|
||||||
|
// }
|
||||||
|
// /* [registry_event_global] */
|
||||||
|
|
||||||
|
// static const struct pw_registry_events registry_events = {
|
||||||
|
// PW_VERSION_REGISTRY_EVENTS,
|
||||||
|
// .global = registry_event_global,
|
||||||
|
// };
|
||||||
|
|
||||||
SPA_EXPORT
|
SPA_EXPORT
|
||||||
struct pw_core *
|
struct pw_core *
|
||||||
pw_context_connect(struct pw_context *context, struct pw_properties *properties,
|
pw_context_connect(struct pw_context *context, struct pw_properties *properties,
|
||||||
size_t user_data_size)
|
size_t user_data_size)
|
||||||
{
|
{
|
||||||
struct pw_core *core;
|
struct pw_core *core;
|
||||||
const struct spa_dict_item *session_services;
|
|
||||||
int res;
|
int res;
|
||||||
|
|
||||||
|
pw_log_error("pw_context_connect");
|
||||||
|
|
||||||
core = core_new(context, properties, user_data_size);
|
core = core_new(context, properties, user_data_size);
|
||||||
if (core == NULL)
|
if (core == NULL)
|
||||||
return NULL;
|
return NULL;
|
||||||
|
|
||||||
session_services = spa_dict_lookup_item(&core->properties->dict, PW_KEY_SESSION_SERVICES);
|
// struct pw_registry *registry = pw_core_get_registry(core, PW_VERSION_REGISTRY, 0);
|
||||||
// if the property is present and empty, context creation blocks until services are added
|
// pw_registry_add_listener(registry, &data.registry_listener, ®istry_events, &data);
|
||||||
if (session_services != NULL && !strcmp(session_services->value, ""))
|
|
||||||
|
bool should_block_for_services = false; // TODO
|
||||||
|
if (should_block_for_services)
|
||||||
{
|
{
|
||||||
pw_log_error("pw_context_connect is waiting for session.services to be populated");
|
struct spa_dict_item *services = NULL;
|
||||||
|
struct pw_session_info *info;
|
||||||
|
struct spa_dict *props;
|
||||||
|
struct pw_global *global;
|
||||||
|
uint32_t id = 0; // TODO: how to find id of global for pw_session_info?
|
||||||
|
global = pw_context_find_global(context, id);
|
||||||
|
// TODO: are these the properties of the pw_session_info object?
|
||||||
|
// if not, should we use pw_global_get_object(global), and will this be the pw_session_info object?
|
||||||
|
props = pw_global_get_properties(global);
|
||||||
|
services = spa_dict_lookup_item(props, PW_KEY_SESSION_SERVICES);
|
||||||
pthread_mutex_lock(&service_added_lock);
|
pthread_mutex_lock(&service_added_lock);
|
||||||
pthread_cond_wait(&service_added_cv, &service_added_lock);
|
if (services != NULL && spa_streq(services->value, PW_SESSION_SERVICE_NONE))
|
||||||
|
{
|
||||||
|
pw_log_error("pw_context_connect is waiting for session.services to be populated");
|
||||||
|
pthread_cond_wait(&service_added_cv, &service_added_lock);
|
||||||
|
pw_log_error("pw_context_connect is resuming");
|
||||||
|
pw_log_error(PW_KEY_SESSION_SERVICES": %s", services->value);
|
||||||
|
}
|
||||||
pthread_mutex_unlock(&service_added_lock);
|
pthread_mutex_unlock(&service_added_lock);
|
||||||
pw_log_error("pw_context_connect is resuming");
|
|
||||||
pw_log_error("session.services: %s", session_services->value);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
pw_log_debug("%p: connect", core);
|
pw_log_debug("%p: connect", core);
|
||||||
|
|
|
||||||
|
|
@ -531,10 +531,6 @@ pw_registry_bind(struct pw_registry *registry,
|
||||||
* \{
|
* \{
|
||||||
*/
|
*/
|
||||||
|
|
||||||
void
|
|
||||||
pw_context_add_service(struct pw_context *context,
|
|
||||||
const char *service);
|
|
||||||
|
|
||||||
/** Connect to a PipeWire instance
|
/** Connect to a PipeWire instance
|
||||||
*
|
*
|
||||||
* \param context a \ref pw_context
|
* \param context a \ref pw_context
|
||||||
|
|
|
||||||
|
|
@ -40,6 +40,12 @@ extern "C" {
|
||||||
* \{
|
* \{
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
#define PW_SESSION_SERVICE_NONE ""
|
||||||
|
#define PW_SESSION_SERVICE_AUDIO_IN "audio-in"
|
||||||
|
#define PW_SESSION_SERVICE_AUDIO_OUT "audio-out"
|
||||||
|
#define PW_SESSION_SERVICE_VIDEO_IN "video-in"
|
||||||
|
#define PW_SESSION_SERVICE_VIDEO_OUT "video-out"
|
||||||
|
|
||||||
#define PW_TYPE_INTERFACE_Session PW_TYPE_INFO_INTERFACE_BASE "Session"
|
#define PW_TYPE_INTERFACE_Session PW_TYPE_INFO_INTERFACE_BASE "Session"
|
||||||
#define PW_VERSION_SESSION 0
|
#define PW_VERSION_SESSION 0
|
||||||
struct pw_session;
|
struct pw_session;
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue