mirror of
https://gitlab.freedesktop.org/pipewire/pipewire.git
synced 2025-11-06 13:30:01 -05:00
pw_core -> pw_context
The proxy API is the one that we would like to expose for applications and the other API is used internally when implementing modules or factories. The current pw_core object is really a context for all objects so name it that way. It also makes it possible to rename pw_core_proxy to pw_proxy later.
This commit is contained in:
parent
42103a8218
commit
8ea78c2e3f
113 changed files with 905 additions and 906 deletions
|
|
@ -1,7 +1,7 @@
|
|||
test_apps = [
|
||||
'test-array',
|
||||
'test-client',
|
||||
'test-core',
|
||||
'test-context',
|
||||
'test-interfaces',
|
||||
'test-properties',
|
||||
# 'test-remote',
|
||||
|
|
|
|||
|
|
@ -24,7 +24,7 @@
|
|||
|
||||
#include <pipewire/pipewire.h>
|
||||
#include <pipewire/main-loop.h>
|
||||
#include <pipewire/core.h>
|
||||
#include <pipewire/context.h>
|
||||
|
||||
#define TEST_FUNC(a,b,func) \
|
||||
do { \
|
||||
|
|
@ -34,7 +34,7 @@ do { \
|
|||
|
||||
static void test_abi(void)
|
||||
{
|
||||
struct pw_core_events ev;
|
||||
struct pw_context_events ev;
|
||||
struct {
|
||||
uint32_t version;
|
||||
void (*destroy) (void *data);
|
||||
|
|
@ -43,7 +43,7 @@ static void test_abi(void)
|
|||
void (*check_access) (void *data, struct pw_client *client);
|
||||
void (*global_added) (void *data, struct pw_global *global);
|
||||
void (*global_removed) (void *data, struct pw_global *global);
|
||||
} test = { PW_VERSION_CORE_EVENTS, NULL };
|
||||
} test = { PW_VERSION_CONTEXT_EVENTS, NULL };
|
||||
|
||||
TEST_FUNC(ev, test, destroy);
|
||||
TEST_FUNC(ev, test, free);
|
||||
|
|
@ -52,127 +52,127 @@ static void test_abi(void)
|
|||
TEST_FUNC(ev, test, global_added);
|
||||
TEST_FUNC(ev, test, global_removed);
|
||||
|
||||
spa_assert(PW_VERSION_CORE_EVENTS == 0);
|
||||
spa_assert(PW_VERSION_CONTEXT_EVENTS == 0);
|
||||
spa_assert(sizeof(ev) == sizeof(test));
|
||||
}
|
||||
|
||||
static void core_destroy_error(void *data)
|
||||
static void context_destroy_error(void *data)
|
||||
{
|
||||
spa_assert_not_reached();
|
||||
}
|
||||
static void core_free_error(void *data)
|
||||
static void context_free_error(void *data)
|
||||
{
|
||||
spa_assert_not_reached();
|
||||
}
|
||||
static void core_info_changed_error(void *data, const struct pw_core_info *info)
|
||||
static void context_info_changed_error(void *data, const struct pw_core_info *info)
|
||||
{
|
||||
spa_assert_not_reached();
|
||||
}
|
||||
static void core_check_access_error(void *data, struct pw_client *client)
|
||||
static void context_check_access_error(void *data, struct pw_client *client)
|
||||
{
|
||||
spa_assert_not_reached();
|
||||
}
|
||||
static void core_global_added_error(void *data, struct pw_global *global)
|
||||
static void context_global_added_error(void *data, struct pw_global *global)
|
||||
{
|
||||
spa_assert_not_reached();
|
||||
}
|
||||
static void core_global_removed_error(void *data, struct pw_global *global)
|
||||
static void context_global_removed_error(void *data, struct pw_global *global)
|
||||
{
|
||||
spa_assert_not_reached();
|
||||
}
|
||||
|
||||
static const struct pw_core_events core_events_error =
|
||||
static const struct pw_context_events context_events_error =
|
||||
{
|
||||
PW_VERSION_CORE_EVENTS,
|
||||
.destroy = core_destroy_error,
|
||||
.free = core_free_error,
|
||||
.info_changed = core_info_changed_error,
|
||||
.check_access = core_check_access_error,
|
||||
.global_added = core_global_added_error,
|
||||
.global_removed = core_global_removed_error,
|
||||
PW_VERSION_CONTEXT_EVENTS,
|
||||
.destroy = context_destroy_error,
|
||||
.free = context_free_error,
|
||||
.info_changed = context_info_changed_error,
|
||||
.check_access = context_check_access_error,
|
||||
.global_added = context_global_added_error,
|
||||
.global_removed = context_global_removed_error,
|
||||
};
|
||||
|
||||
static int destroy_count = 0;
|
||||
static void core_destroy_count(void *data)
|
||||
static void context_destroy_count(void *data)
|
||||
{
|
||||
destroy_count++;
|
||||
}
|
||||
static int free_count = 0;
|
||||
static void core_free_count(void *data)
|
||||
static void context_free_count(void *data)
|
||||
{
|
||||
free_count++;
|
||||
}
|
||||
static int global_removed_count = 0;
|
||||
static void core_global_removed_count(void *data, struct pw_global *global)
|
||||
static void context_global_removed_count(void *data, struct pw_global *global)
|
||||
{
|
||||
global_removed_count++;
|
||||
}
|
||||
static int core_foreach_count = 0;
|
||||
static int core_foreach(void *data, struct pw_global *global)
|
||||
static int context_foreach_count = 0;
|
||||
static int context_foreach(void *data, struct pw_global *global)
|
||||
{
|
||||
core_foreach_count++;
|
||||
context_foreach_count++;
|
||||
return 0;
|
||||
}
|
||||
static int core_foreach_error(void *data, struct pw_global *global)
|
||||
static int context_foreach_error(void *data, struct pw_global *global)
|
||||
{
|
||||
core_foreach_count++;
|
||||
context_foreach_count++;
|
||||
return -1;
|
||||
}
|
||||
static void test_create(void)
|
||||
{
|
||||
struct pw_main_loop *loop;
|
||||
struct pw_core *core;
|
||||
struct pw_context *context;
|
||||
struct spa_hook listener = { NULL, };
|
||||
struct pw_core_events core_events = core_events_error;
|
||||
struct pw_context_events context_events = context_events_error;
|
||||
struct pw_global *global;
|
||||
int res;
|
||||
|
||||
loop = pw_main_loop_new(NULL);
|
||||
spa_assert(loop != NULL);
|
||||
|
||||
core = pw_core_new(pw_main_loop_get_loop(loop),
|
||||
context = pw_context_new(pw_main_loop_get_loop(loop),
|
||||
pw_properties_new(
|
||||
PW_KEY_CORE_PROFILE_MODULES, "none",
|
||||
NULL), 12);
|
||||
spa_assert(core != NULL);
|
||||
pw_core_add_listener(core, &listener, &core_events, core);
|
||||
spa_assert(context != NULL);
|
||||
pw_context_add_listener(context, &listener, &context_events, context);
|
||||
|
||||
/* check main loop */
|
||||
spa_assert(pw_core_get_main_loop(core) == pw_main_loop_get_loop(loop));
|
||||
spa_assert(pw_context_get_main_loop(context) == pw_main_loop_get_loop(loop));
|
||||
/* check user data */
|
||||
spa_assert(pw_core_get_user_data(core) != NULL);
|
||||
spa_assert(pw_context_get_user_data(context) != NULL);
|
||||
|
||||
/* check info */
|
||||
spa_assert(pw_core_get_info(core) != NULL);
|
||||
spa_assert(pw_context_get_info(context) != NULL);
|
||||
|
||||
/* check global */
|
||||
global = pw_core_get_global(core);
|
||||
global = pw_context_get_global(context);
|
||||
spa_assert(global != NULL);
|
||||
spa_assert(pw_core_find_global(core, 0) == global);
|
||||
spa_assert(pw_global_get_core(global) == core);
|
||||
spa_assert(pw_context_find_global(context, 0) == global);
|
||||
spa_assert(pw_global_get_context(global) == context);
|
||||
spa_assert(pw_global_get_type(global) == PW_TYPE_INTERFACE_Core);
|
||||
spa_assert(pw_global_get_version(global) == PW_VERSION_CORE_PROXY);
|
||||
spa_assert(pw_global_get_id(global) == 0);
|
||||
spa_assert(pw_global_get_object(global) == (void*)core);
|
||||
spa_assert(pw_global_get_object(global) == (void*)context);
|
||||
|
||||
/* iterate globals */
|
||||
spa_assert(core_foreach_count == 0);
|
||||
res = pw_core_for_each_global(core, core_foreach, core);
|
||||
spa_assert(context_foreach_count == 0);
|
||||
res = pw_context_for_each_global(context, context_foreach, context);
|
||||
spa_assert(res == 0);
|
||||
spa_assert(core_foreach_count == 1);
|
||||
res = pw_core_for_each_global(core, core_foreach_error, core);
|
||||
spa_assert(context_foreach_count == 1);
|
||||
res = pw_context_for_each_global(context, context_foreach_error, context);
|
||||
spa_assert(res == -1);
|
||||
spa_assert(core_foreach_count == 2);
|
||||
spa_assert(context_foreach_count == 2);
|
||||
|
||||
/* check destroy */
|
||||
core_events.destroy = core_destroy_count;
|
||||
core_events.free = core_free_count;
|
||||
core_events.global_removed = core_global_removed_count;
|
||||
context_events.destroy = context_destroy_count;
|
||||
context_events.free = context_free_count;
|
||||
context_events.global_removed = context_global_removed_count;
|
||||
|
||||
spa_assert(destroy_count == 0);
|
||||
spa_assert(free_count == 0);
|
||||
spa_assert(global_removed_count == 0);
|
||||
pw_core_destroy(core);
|
||||
pw_context_destroy(context);
|
||||
spa_assert(destroy_count == 1);
|
||||
spa_assert(free_count == 1);
|
||||
spa_assert(global_removed_count == 1);
|
||||
|
|
@ -180,7 +180,7 @@ static void test_create(void)
|
|||
}
|
||||
|
||||
static int info_changed_count = 0;
|
||||
static void core_info_changed_count(void *data, const struct pw_core_info *info)
|
||||
static void context_info_changed_count(void *data, const struct pw_core_info *info)
|
||||
{
|
||||
spa_assert(spa_dict_lookup(info->props, "foo") == NULL);
|
||||
spa_assert(!strcmp(spa_dict_lookup(info->props, "biz"), "buzz"));
|
||||
|
|
@ -191,26 +191,26 @@ static void core_info_changed_count(void *data, const struct pw_core_info *info)
|
|||
static void test_properties(void)
|
||||
{
|
||||
struct pw_main_loop *loop;
|
||||
struct pw_core *core;
|
||||
struct pw_context *context;
|
||||
const struct pw_properties *props;
|
||||
struct spa_hook listener = { NULL, };
|
||||
struct pw_core_events core_events = core_events_error;
|
||||
struct pw_context_events context_events = context_events_error;
|
||||
struct spa_dict_item items[3];
|
||||
|
||||
loop = pw_main_loop_new(NULL);
|
||||
core = pw_core_new(pw_main_loop_get_loop(loop),
|
||||
context = pw_context_new(pw_main_loop_get_loop(loop),
|
||||
pw_properties_new("foo", "bar",
|
||||
"biz", "fuzz",
|
||||
NULL),
|
||||
0);
|
||||
spa_assert(core != NULL);
|
||||
spa_assert(pw_core_get_user_data(core) == NULL);
|
||||
pw_core_add_listener(core, &listener, &core_events, core);
|
||||
spa_assert(context != NULL);
|
||||
spa_assert(pw_context_get_user_data(context) == NULL);
|
||||
pw_context_add_listener(context, &listener, &context_events, context);
|
||||
|
||||
core_events.info_changed = core_info_changed_count;
|
||||
context_events.info_changed = context_info_changed_count;
|
||||
spa_assert(info_changed_count == 0);
|
||||
|
||||
props = pw_core_get_properties(core);
|
||||
props = pw_context_get_properties(context);
|
||||
spa_assert(props != NULL);
|
||||
spa_assert(!strcmp(pw_properties_get(props, "foo"), "bar"));
|
||||
spa_assert(!strcmp(pw_properties_get(props, "biz"), "fuzz"));
|
||||
|
|
@ -222,24 +222,24 @@ static void test_properties(void)
|
|||
items[1] = SPA_DICT_ITEM_INIT("biz", "buzz");
|
||||
/* add buzz */
|
||||
items[2] = SPA_DICT_ITEM_INIT("buzz", "frizz");
|
||||
pw_core_update_properties(core, &SPA_DICT_INIT(items, 3));
|
||||
pw_context_update_properties(context, &SPA_DICT_INIT(items, 3));
|
||||
|
||||
spa_assert(info_changed_count == 1);
|
||||
|
||||
spa_assert(props == pw_core_get_properties(core));
|
||||
spa_assert(props == pw_context_get_properties(context));
|
||||
spa_assert(pw_properties_get(props, "foo") == NULL);
|
||||
spa_assert(!strcmp(pw_properties_get(props, "biz"), "buzz"));
|
||||
spa_assert(!strcmp(pw_properties_get(props, "buzz"), "frizz"));
|
||||
|
||||
spa_hook_remove(&listener);
|
||||
pw_core_destroy(core);
|
||||
pw_context_destroy(context);
|
||||
pw_main_loop_destroy(loop);
|
||||
}
|
||||
|
||||
static void test_support(void)
|
||||
{
|
||||
struct pw_main_loop *loop;
|
||||
struct pw_core *core;
|
||||
struct pw_context *context;
|
||||
const struct spa_support *support;
|
||||
uint32_t n_support;
|
||||
uint32_t types[] = {
|
||||
|
|
@ -255,9 +255,9 @@ static void test_support(void)
|
|||
size_t i;
|
||||
|
||||
loop = pw_main_loop_new(NULL);
|
||||
core = pw_core_new(pw_main_loop_get_loop(loop), NULL, 0);
|
||||
context = pw_context_new(pw_main_loop_get_loop(loop), NULL, 0);
|
||||
|
||||
support = pw_core_get_support(core, &n_support);
|
||||
support = pw_context_get_support(context, &n_support);
|
||||
spa_assert(support != NULL);
|
||||
spa_assert(n_support > 0);
|
||||
|
||||
|
|
@ -265,7 +265,7 @@ static void test_support(void)
|
|||
spa_assert(spa_support_find(support, n_support, types[i]) != NULL);
|
||||
}
|
||||
|
||||
pw_core_destroy(core);
|
||||
pw_context_destroy(context);
|
||||
pw_main_loop_destroy(loop);
|
||||
}
|
||||
|
||||
|
|
@ -133,7 +133,7 @@ static void stream_destroy_count(void *data)
|
|||
static void test_create(void)
|
||||
{
|
||||
struct pw_main_loop *loop;
|
||||
struct pw_core *core;
|
||||
struct pw_context *context;
|
||||
struct pw_core_proxy *core_proxy;
|
||||
struct pw_stream *stream;
|
||||
struct pw_stream_events stream_events = stream_events_error;
|
||||
|
|
@ -142,12 +142,12 @@ static void test_create(void)
|
|||
struct pw_time tm;
|
||||
|
||||
loop = pw_main_loop_new(NULL);
|
||||
core = pw_core_new(pw_main_loop_get_loop(loop),
|
||||
context = pw_context_new(pw_main_loop_get_loop(loop),
|
||||
pw_properties_new(
|
||||
PW_KEY_CORE_DAEMON, "1",
|
||||
NULL), 12);
|
||||
spa_assert(core != NULL);
|
||||
core_proxy = pw_core_connect_self(core, NULL, 0);
|
||||
spa_assert(context != NULL);
|
||||
core_proxy = pw_context_connect_self(context, NULL, 0);
|
||||
spa_assert(core_proxy != NULL);
|
||||
stream = pw_stream_new(core_proxy, "test", NULL);
|
||||
spa_assert(stream != NULL);
|
||||
|
|
@ -178,14 +178,14 @@ static void test_create(void)
|
|||
pw_stream_destroy(stream);
|
||||
spa_assert(destroy_count == 1);
|
||||
|
||||
pw_core_destroy(core);
|
||||
pw_context_destroy(context);
|
||||
pw_main_loop_destroy(loop);
|
||||
}
|
||||
|
||||
static void test_properties(void)
|
||||
{
|
||||
struct pw_main_loop *loop;
|
||||
struct pw_core *core;
|
||||
struct pw_context *context;
|
||||
struct pw_core_proxy *core_proxy;
|
||||
const struct pw_properties *props;
|
||||
struct pw_stream *stream;
|
||||
|
|
@ -194,12 +194,12 @@ static void test_properties(void)
|
|||
struct spa_dict_item items[3];
|
||||
|
||||
loop = pw_main_loop_new(NULL);
|
||||
core = pw_core_new(pw_main_loop_get_loop(loop),
|
||||
context = pw_context_new(pw_main_loop_get_loop(loop),
|
||||
pw_properties_new(
|
||||
PW_KEY_CORE_DAEMON, "1",
|
||||
NULL), 12);
|
||||
spa_assert(core != NULL);
|
||||
core_proxy = pw_core_connect_self(core, NULL, 0);
|
||||
spa_assert(context != NULL);
|
||||
core_proxy = pw_context_connect_self(context, NULL, 0);
|
||||
spa_assert(core_proxy != NULL);
|
||||
stream = pw_stream_new(core_proxy, "test",
|
||||
pw_properties_new("foo", "bar",
|
||||
|
|
@ -230,7 +230,7 @@ static void test_properties(void)
|
|||
/* check destroy */
|
||||
destroy_count = 0;
|
||||
stream_events.destroy = stream_destroy_count;
|
||||
pw_core_destroy(core);
|
||||
pw_context_destroy(context);
|
||||
spa_assert(destroy_count == 1);
|
||||
|
||||
pw_main_loop_destroy(loop);
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue