wireplumber/tests/common/test-server.h

46 lines
1.1 KiB
C
Raw Normal View History

/* WirePlumber
*
* Copyright © 2019 Collabora Ltd.
* @author George Kiagiadakis <george.kiagiadakis@collabora.com>
*
* SPDX-License-Identifier: MIT
*/
#include <pipewire/pipewire.h>
2020-01-09 12:39:45 -05:00
#include <pipewire/impl.h>
typedef struct {
gchar *name;
struct pw_thread_loop *thread_loop;
2020-01-09 12:39:45 -05:00
struct pw_context *context;
} WpTestServer;
static inline void
wp_test_server_setup (WpTestServer *self)
{
struct pw_properties *properties;
self->name = g_strdup_printf ("wp-test-server-%d-%d", getpid(),
g_random_int ());
properties = pw_properties_new(
PW_KEY_CORE_DAEMON, "1",
PW_KEY_CORE_NAME, self->name,
NULL);
2020-01-09 12:39:45 -05:00
self->thread_loop = pw_thread_loop_new ("wp-test-server", NULL);
self->context = pw_context_new (pw_thread_loop_get_loop (self->thread_loop), properties, 0);
2020-01-09 12:39:45 -05:00
pw_context_load_module (self->context, "libpipewire-module-access", NULL, NULL);
pw_thread_loop_start (self->thread_loop);
}
static inline void
wp_test_server_teardown (WpTestServer *self)
{
pw_thread_loop_stop (self->thread_loop);
2020-01-09 12:39:45 -05:00
pw_context_destroy (self->context);
pw_thread_loop_destroy (self->thread_loop);
g_free (self->name);
}