mirror of
https://gitlab.freedesktop.org/pipewire/pipewire.git
synced 2025-11-03 09:01:54 -05:00
pipewire: use newly added function for deferred module destroy
Use the newly introduced `pw_impl_module_schedule_destroy()`
for deferred module destroy in all modules except
module-example-{sink,source}.
This commit is contained in:
parent
a13e7ef091
commit
45bd8532eb
9 changed files with 25 additions and 203 deletions
|
|
@ -151,7 +151,6 @@ struct impl {
|
|||
struct pw_context *context;
|
||||
|
||||
struct pw_impl_module *module;
|
||||
struct pw_work_queue *work;
|
||||
struct spa_hook module_listener;
|
||||
|
||||
uint32_t id;
|
||||
|
|
@ -194,7 +193,6 @@ struct impl {
|
|||
unsigned int sink_ready:1;
|
||||
|
||||
unsigned int do_disconnect:1;
|
||||
unsigned int unloading:1;
|
||||
|
||||
uint32_t max_buffer_size;
|
||||
uint32_t buffer_delay;
|
||||
|
|
@ -203,19 +201,6 @@ struct impl {
|
|||
struct spa_plugin_loader *loader;
|
||||
};
|
||||
|
||||
static void do_unload_module(void *obj, void *data, int res, uint32_t id)
|
||||
{
|
||||
struct impl *impl = data;
|
||||
pw_impl_module_destroy(impl->module);
|
||||
}
|
||||
static void unload_module(struct impl *impl)
|
||||
{
|
||||
if (!impl->unloading) {
|
||||
impl->unloading = true;
|
||||
pw_work_queue_add(impl->work, impl, 0, do_unload_module, impl);
|
||||
}
|
||||
}
|
||||
|
||||
static void process(struct impl *impl)
|
||||
{
|
||||
struct pw_buffer *cout;
|
||||
|
|
@ -774,7 +759,7 @@ static void core_error(void *data, uint32_t id, int seq, int res, const char *me
|
|||
id, seq, res, spa_strerror(res), message);
|
||||
|
||||
if (id == PW_ID_CORE && res == -EPIPE)
|
||||
unload_module(impl);
|
||||
pw_impl_module_schedule_destroy(impl->module);
|
||||
}
|
||||
|
||||
static const struct pw_core_events core_events = {
|
||||
|
|
@ -787,7 +772,7 @@ static void core_destroy(void *d)
|
|||
struct impl *impl = d;
|
||||
spa_hook_remove(&impl->core_listener);
|
||||
impl->core = NULL;
|
||||
unload_module(impl);
|
||||
pw_impl_module_schedule_destroy(impl->module);
|
||||
}
|
||||
|
||||
static const struct pw_proxy_events core_proxy_events = {
|
||||
|
|
@ -812,9 +797,6 @@ static void impl_destroy(struct impl *impl)
|
|||
pw_properties_free(impl->source_props);
|
||||
pw_properties_free(impl->sink_props);
|
||||
|
||||
if (impl->work)
|
||||
pw_work_queue_cancel(impl->work, impl, SPA_ID_INVALID);
|
||||
|
||||
for (i = 0; i < impl->info.channels; i++) {
|
||||
if (impl->rec_buffer[i])
|
||||
free(impl->rec_buffer[i]);
|
||||
|
|
@ -830,7 +812,6 @@ static void impl_destroy(struct impl *impl)
|
|||
static void module_destroy(void *data)
|
||||
{
|
||||
struct impl *impl = data;
|
||||
impl->unloading = true;
|
||||
spa_hook_remove(&impl->module_listener);
|
||||
impl_destroy(impl);
|
||||
}
|
||||
|
|
@ -931,7 +912,6 @@ int pipewire__module_init(struct pw_impl_module *module, const char *args)
|
|||
impl->id = id;
|
||||
impl->module = module;
|
||||
impl->context = context;
|
||||
impl->work = pw_context_get_work_queue(context);
|
||||
|
||||
if (pw_properties_get(props, PW_KEY_NODE_GROUP) == NULL)
|
||||
pw_properties_setf(props, PW_KEY_NODE_GROUP, "echo-cancel-%u", id);
|
||||
|
|
|
|||
|
|
@ -223,7 +223,6 @@ struct impl {
|
|||
struct pw_context *context;
|
||||
|
||||
struct pw_impl_module *module;
|
||||
struct pw_work_queue *work;
|
||||
|
||||
struct spa_hook module_listener;
|
||||
|
||||
|
|
@ -244,26 +243,12 @@ struct impl {
|
|||
struct spa_audio_info_raw playback_info;
|
||||
|
||||
unsigned int do_disconnect:1;
|
||||
unsigned int unloading:1;
|
||||
|
||||
long unsigned rate;
|
||||
|
||||
struct graph graph;
|
||||
};
|
||||
|
||||
static void do_unload_module(void *obj, void *data, int res, uint32_t id)
|
||||
{
|
||||
struct impl *impl = data;
|
||||
pw_impl_module_destroy(impl->module);
|
||||
}
|
||||
static void unload_module(struct impl *impl)
|
||||
{
|
||||
if (!impl->unloading) {
|
||||
impl->unloading = true;
|
||||
pw_work_queue_add(impl->work, impl, 0, do_unload_module, impl);
|
||||
}
|
||||
}
|
||||
|
||||
static void capture_destroy(void *d)
|
||||
{
|
||||
struct impl *impl = d;
|
||||
|
|
@ -1549,7 +1534,7 @@ static void core_error(void *data, uint32_t id, int seq, int res, const char *me
|
|||
id, seq, res, spa_strerror(res), message);
|
||||
|
||||
if (id == PW_ID_CORE && res == -EPIPE)
|
||||
unload_module(impl);
|
||||
pw_impl_module_schedule_destroy(impl->module);
|
||||
}
|
||||
|
||||
static const struct pw_core_events core_events = {
|
||||
|
|
@ -1562,7 +1547,7 @@ static void core_destroy(void *d)
|
|||
struct impl *impl = d;
|
||||
spa_hook_remove(&impl->core_listener);
|
||||
impl->core = NULL;
|
||||
unload_module(impl);
|
||||
pw_impl_module_schedule_destroy(impl->module);
|
||||
}
|
||||
|
||||
static const struct pw_proxy_events core_proxy_events = {
|
||||
|
|
@ -1579,8 +1564,6 @@ static void impl_destroy(struct impl *impl)
|
|||
pw_core_disconnect(impl->core);
|
||||
pw_properties_free(impl->capture_props);
|
||||
pw_properties_free(impl->playback_props);
|
||||
if (impl->work)
|
||||
pw_work_queue_cancel(impl->work, impl, SPA_ID_INVALID);
|
||||
graph_free(&impl->graph);
|
||||
free(impl);
|
||||
}
|
||||
|
|
@ -1588,7 +1571,6 @@ static void impl_destroy(struct impl *impl)
|
|||
static void module_destroy(void *data)
|
||||
{
|
||||
struct impl *impl = data;
|
||||
impl->unloading = true;
|
||||
spa_hook_remove(&impl->module_listener);
|
||||
impl_destroy(impl);
|
||||
}
|
||||
|
|
@ -1688,7 +1670,6 @@ int pipewire__module_init(struct pw_impl_module *module, const char *args)
|
|||
|
||||
impl->module = module;
|
||||
impl->context = context;
|
||||
impl->work = pw_context_get_work_queue(context);
|
||||
|
||||
impl->rate = 48000;
|
||||
impl->graph.impl = impl;
|
||||
|
|
|
|||
|
|
@ -81,7 +81,6 @@ struct impl {
|
|||
struct pw_context *context;
|
||||
|
||||
struct pw_impl_module *module;
|
||||
struct pw_work_queue *work;
|
||||
|
||||
struct spa_hook module_listener;
|
||||
|
||||
|
|
@ -100,22 +99,8 @@ struct impl {
|
|||
struct spa_audio_info_raw playback_info;
|
||||
|
||||
unsigned int do_disconnect:1;
|
||||
unsigned int unloading:1;
|
||||
};
|
||||
|
||||
static void do_unload_module(void *obj, void *data, int res, uint32_t id)
|
||||
{
|
||||
struct impl *impl = data;
|
||||
pw_impl_module_destroy(impl->module);
|
||||
}
|
||||
static void unload_module(struct impl *impl)
|
||||
{
|
||||
if (!impl->unloading) {
|
||||
impl->unloading = true;
|
||||
pw_work_queue_add(impl->work, impl, 0, do_unload_module, impl);
|
||||
}
|
||||
}
|
||||
|
||||
static void capture_destroy(void *d)
|
||||
{
|
||||
struct impl *impl = d;
|
||||
|
|
@ -312,7 +297,7 @@ static void core_error(void *data, uint32_t id, int seq, int res, const char *me
|
|||
id, seq, res, spa_strerror(res), message);
|
||||
|
||||
if (id == PW_ID_CORE && res == -EPIPE)
|
||||
unload_module(impl);
|
||||
pw_impl_module_schedule_destroy(impl->module);
|
||||
}
|
||||
|
||||
static const struct pw_core_events core_events = {
|
||||
|
|
@ -325,7 +310,7 @@ static void core_destroy(void *d)
|
|||
struct impl *impl = d;
|
||||
spa_hook_remove(&impl->core_listener);
|
||||
impl->core = NULL;
|
||||
unload_module(impl);
|
||||
pw_impl_module_schedule_destroy(impl->module);
|
||||
}
|
||||
|
||||
static const struct pw_proxy_events core_proxy_events = {
|
||||
|
|
@ -342,15 +327,12 @@ static void impl_destroy(struct impl *impl)
|
|||
pw_core_disconnect(impl->core);
|
||||
pw_properties_free(impl->capture_props);
|
||||
pw_properties_free(impl->playback_props);
|
||||
if (impl->work)
|
||||
pw_work_queue_cancel(impl->work, impl, SPA_ID_INVALID);
|
||||
free(impl);
|
||||
}
|
||||
|
||||
static void module_destroy(void *data)
|
||||
{
|
||||
struct impl *impl = data;
|
||||
impl->unloading = true;
|
||||
spa_hook_remove(&impl->module_listener);
|
||||
impl_destroy(impl);
|
||||
}
|
||||
|
|
@ -447,7 +429,6 @@ int pipewire__module_init(struct pw_impl_module *module, const char *args)
|
|||
|
||||
impl->module = module;
|
||||
impl->context = context;
|
||||
impl->work = pw_context_get_work_queue(context);
|
||||
|
||||
if (pw_properties_get(props, PW_KEY_NODE_GROUP) == NULL)
|
||||
pw_properties_setf(props, PW_KEY_NODE_GROUP, "loopback-%u", id);
|
||||
|
|
|
|||
|
|
@ -48,6 +48,7 @@
|
|||
|
||||
#include <pipewire/impl.h>
|
||||
#include <pipewire/i18n.h>
|
||||
#include <pipewire/private.h>
|
||||
|
||||
#include <pulse/pulseaudio.h>
|
||||
#include "module-protocol-pulse/format.h"
|
||||
|
|
@ -95,7 +96,6 @@ struct impl {
|
|||
struct pw_properties *props;
|
||||
|
||||
struct pw_impl_module *module;
|
||||
struct pw_work_queue *work;
|
||||
|
||||
struct spa_hook module_listener;
|
||||
|
||||
|
|
@ -121,23 +121,8 @@ struct impl {
|
|||
pa_stream *pa_stream;
|
||||
|
||||
unsigned int do_disconnect:1;
|
||||
unsigned int unloading:1;
|
||||
};
|
||||
|
||||
static void do_unload_module(void *obj, void *data, int res, uint32_t id)
|
||||
{
|
||||
struct impl *impl = data;
|
||||
pw_impl_module_destroy(impl->module);
|
||||
}
|
||||
|
||||
static void unload_module(struct impl *impl)
|
||||
{
|
||||
if (!impl->unloading) {
|
||||
impl->unloading = true;
|
||||
pw_work_queue_add(impl->work, impl, 0, do_unload_module, impl);
|
||||
}
|
||||
}
|
||||
|
||||
static void cork_stream(struct impl *impl, bool cork)
|
||||
{
|
||||
pa_operation *operation;
|
||||
|
|
@ -174,7 +159,7 @@ static void stream_state_changed(void *d, enum pw_stream_state old,
|
|||
switch (state) {
|
||||
case PW_STREAM_STATE_ERROR:
|
||||
case PW_STREAM_STATE_UNCONNECTED:
|
||||
unload_module(impl);
|
||||
pw_impl_module_schedule_destroy(impl->module);
|
||||
break;
|
||||
case PW_STREAM_STATE_PAUSED:
|
||||
cork_stream(impl, true);
|
||||
|
|
@ -613,7 +598,7 @@ static void core_error(void *data, uint32_t id, int seq, int res, const char *me
|
|||
id, seq, res, spa_strerror(res), message);
|
||||
|
||||
if (id == PW_ID_CORE && res == -EPIPE)
|
||||
unload_module(impl);
|
||||
pw_impl_module_schedule_destroy(impl->module);
|
||||
}
|
||||
|
||||
static const struct pw_core_events core_events = {
|
||||
|
|
@ -626,7 +611,7 @@ static void core_destroy(void *d)
|
|||
struct impl *impl = d;
|
||||
spa_hook_remove(&impl->core_listener);
|
||||
impl->core = NULL;
|
||||
unload_module(impl);
|
||||
pw_impl_module_schedule_destroy(impl->module);
|
||||
}
|
||||
|
||||
static const struct pw_proxy_events core_proxy_events = {
|
||||
|
|
@ -655,8 +640,6 @@ static void impl_destroy(struct impl *impl)
|
|||
pw_properties_free(impl->stream_props);
|
||||
pw_properties_free(impl->props);
|
||||
|
||||
if (impl->work)
|
||||
pw_work_queue_cancel(impl->work, impl, SPA_ID_INVALID);
|
||||
free(impl->buffer);
|
||||
free(impl);
|
||||
}
|
||||
|
|
@ -664,7 +647,6 @@ static void impl_destroy(struct impl *impl)
|
|||
static void module_destroy(void *data)
|
||||
{
|
||||
struct impl *impl = data;
|
||||
impl->unloading = true;
|
||||
spa_hook_remove(&impl->module_listener);
|
||||
impl_destroy(impl);
|
||||
}
|
||||
|
|
@ -779,7 +761,6 @@ int pipewire__module_init(struct pw_impl_module *module, const char *args)
|
|||
|
||||
impl->module = module;
|
||||
impl->context = context;
|
||||
impl->work = pw_context_get_work_queue(context);
|
||||
|
||||
spa_ringbuffer_init(&impl->ring);
|
||||
impl->buffer = calloc(1, RINGBUFFER_SIZE);
|
||||
|
|
|
|||
|
|
@ -71,7 +71,6 @@ struct impl {
|
|||
|
||||
struct pw_impl_module *module;
|
||||
struct spa_hook module_listener;
|
||||
struct pw_work_queue *work;
|
||||
|
||||
struct pw_properties *properties;
|
||||
|
||||
|
|
@ -80,8 +79,6 @@ struct impl {
|
|||
AvahiServiceBrowser *sink_browser;
|
||||
|
||||
struct spa_list tunnel_list;
|
||||
|
||||
unsigned int unloading:1;
|
||||
};
|
||||
|
||||
struct tunnel_info {
|
||||
|
|
@ -103,20 +100,6 @@ struct tunnel {
|
|||
|
||||
static int start_client(struct impl *impl);
|
||||
|
||||
static void do_unload_module(void *obj, void *data, int res, uint32_t id)
|
||||
{
|
||||
struct impl *impl = data;
|
||||
pw_impl_module_destroy(impl->module);
|
||||
}
|
||||
|
||||
static void unload_module(struct impl *impl)
|
||||
{
|
||||
if (!impl->unloading) {
|
||||
impl->unloading = true;
|
||||
pw_work_queue_add(impl->work, impl, 0, do_unload_module, impl);
|
||||
}
|
||||
}
|
||||
|
||||
static struct tunnel *make_tunnel(struct impl *impl, const struct tunnel_info *info)
|
||||
{
|
||||
struct tunnel *t;
|
||||
|
|
@ -168,8 +151,6 @@ static void impl_free(struct impl *impl)
|
|||
if (impl->avahi_poll)
|
||||
pw_avahi_poll_free(impl->avahi_poll);
|
||||
pw_properties_free(impl->properties);
|
||||
if (impl->work)
|
||||
pw_work_queue_cancel(impl->work, impl, SPA_ID_INVALID);
|
||||
free(impl);
|
||||
}
|
||||
|
||||
|
|
@ -465,7 +446,7 @@ static void client_callback(AvahiClient *c, AvahiClientState state, void *userda
|
|||
}
|
||||
return;
|
||||
error:
|
||||
unload_module(impl);
|
||||
pw_impl_module_schedule_destroy(impl->module);
|
||||
}
|
||||
|
||||
static int start_client(struct impl *impl)
|
||||
|
|
@ -476,7 +457,7 @@ static int start_client(struct impl *impl)
|
|||
client_callback, impl,
|
||||
&res)) == NULL) {
|
||||
pw_log_error("can't create client: %s", avahi_strerror(res));
|
||||
unload_module(impl);
|
||||
pw_impl_module_schedule_destroy(impl->module);
|
||||
return -EIO;
|
||||
}
|
||||
return 0;
|
||||
|
|
@ -521,8 +502,6 @@ int pipewire__module_init(struct pw_impl_module *module, const char *args)
|
|||
impl->context = context;
|
||||
impl->properties = props;
|
||||
|
||||
impl->work = pw_context_get_work_queue(context);
|
||||
|
||||
pw_impl_module_add_listener(module, &impl->module_listener, &module_events, impl);
|
||||
|
||||
pw_impl_module_update_properties(module, &SPA_DICT_INIT_ARRAY(module_props));
|
||||
|
|
|
|||
|
|
@ -58,6 +58,7 @@
|
|||
|
||||
#include <pipewire/impl.h>
|
||||
#include <pipewire/i18n.h>
|
||||
#include <pipewire/private.h>
|
||||
|
||||
#include "module-raop/rtsp-client.h"
|
||||
|
||||
|
|
@ -134,7 +135,6 @@ struct impl {
|
|||
|
||||
struct pw_impl_module *module;
|
||||
struct pw_loop *loop;
|
||||
struct pw_work_queue *work;
|
||||
|
||||
struct spa_hook module_listener;
|
||||
|
||||
|
|
@ -160,7 +160,6 @@ struct impl {
|
|||
char *password;
|
||||
|
||||
unsigned int do_disconnect:1;
|
||||
unsigned int unloading:1;
|
||||
|
||||
uint8_t key[AES_CHUNK_SIZE]; /* Key for aes-cbc */
|
||||
uint8_t iv[AES_CHUNK_SIZE]; /* Initialization vector for cbc */
|
||||
|
|
@ -196,20 +195,6 @@ struct impl {
|
|||
uint32_t filled;
|
||||
};
|
||||
|
||||
static void do_unload_module(void *obj, void *data, int res, uint32_t id)
|
||||
{
|
||||
struct impl *impl = data;
|
||||
pw_impl_module_destroy(impl->module);
|
||||
}
|
||||
|
||||
static void unload_module(struct impl *impl)
|
||||
{
|
||||
if (!impl->unloading) {
|
||||
impl->unloading = true;
|
||||
pw_work_queue_add(impl->work, impl, 0, do_unload_module, impl);
|
||||
}
|
||||
}
|
||||
|
||||
static void stream_destroy(void *d)
|
||||
{
|
||||
struct impl *impl = d;
|
||||
|
|
@ -1260,7 +1245,7 @@ static void stream_state_changed(void *d, enum pw_stream_state old,
|
|||
switch (state) {
|
||||
case PW_STREAM_STATE_ERROR:
|
||||
case PW_STREAM_STATE_UNCONNECTED:
|
||||
unload_module(impl);
|
||||
pw_impl_module_schedule_destroy(impl->module);
|
||||
break;
|
||||
case PW_STREAM_STATE_PAUSED:
|
||||
rtsp_do_flush(impl);
|
||||
|
|
@ -1394,7 +1379,7 @@ static void core_error(void *data, uint32_t id, int seq, int res, const char *me
|
|||
id, seq, res, spa_strerror(res), message);
|
||||
|
||||
if (id == PW_ID_CORE && res == -EPIPE)
|
||||
unload_module(impl);
|
||||
pw_impl_module_schedule_destroy(impl->module);
|
||||
}
|
||||
|
||||
static const struct pw_core_events core_events = {
|
||||
|
|
@ -1407,7 +1392,7 @@ static void core_destroy(void *d)
|
|||
struct impl *impl = d;
|
||||
spa_hook_remove(&impl->core_listener);
|
||||
impl->core = NULL;
|
||||
unload_module(impl);
|
||||
pw_impl_module_schedule_destroy(impl->module);
|
||||
}
|
||||
|
||||
static const struct pw_proxy_events core_proxy_events = {
|
||||
|
|
@ -1428,15 +1413,12 @@ static void impl_destroy(struct impl *impl)
|
|||
pw_properties_free(impl->stream_props);
|
||||
pw_properties_free(impl->props);
|
||||
free(impl->password);
|
||||
if (impl->work)
|
||||
pw_work_queue_cancel(impl->work, impl, SPA_ID_INVALID);
|
||||
free(impl);
|
||||
}
|
||||
|
||||
static void module_destroy(void *data)
|
||||
{
|
||||
struct impl *impl = data;
|
||||
impl->unloading = true;
|
||||
spa_hook_remove(&impl->module_listener);
|
||||
impl_destroy(impl);
|
||||
}
|
||||
|
|
@ -1587,7 +1569,6 @@ int pipewire__module_init(struct pw_impl_module *module, const char *args)
|
|||
impl->module = module;
|
||||
impl->context = context;
|
||||
impl->loop = pw_context_get_main_loop(context);
|
||||
impl->work = pw_context_get_work_queue(context);
|
||||
|
||||
if (pw_properties_get(props, PW_KEY_NODE_GROUP) == NULL)
|
||||
pw_properties_set(props, PW_KEY_NODE_GROUP, "pipewire.dummy");
|
||||
|
|
|
|||
|
|
@ -96,7 +96,6 @@ PW_LOG_TOPIC_STATIC(mod_topic, "mod." NAME);
|
|||
|
||||
struct module_roc_sink_data {
|
||||
struct pw_impl_module *module;
|
||||
struct pw_work_queue *work;
|
||||
struct spa_hook module_listener;
|
||||
struct pw_properties *props;
|
||||
struct pw_context *module_context;
|
||||
|
|
@ -110,7 +109,6 @@ struct module_roc_sink_data {
|
|||
struct pw_properties *capture_props;
|
||||
|
||||
unsigned int do_disconnect:1;
|
||||
unsigned int unloading:1;
|
||||
|
||||
roc_address local_addr;
|
||||
roc_address remote_source_addr;
|
||||
|
|
@ -124,20 +122,6 @@ struct module_roc_sink_data {
|
|||
int remote_repair_port;
|
||||
};
|
||||
|
||||
static void do_unload_module(void *obj, void *d, int res, uint32_t id)
|
||||
{
|
||||
struct module_roc_sink_data *data = d;
|
||||
pw_impl_module_destroy(data->module);
|
||||
}
|
||||
|
||||
static void unload_module(struct module_roc_sink_data *data)
|
||||
{
|
||||
if (!data->unloading) {
|
||||
data->unloading = true;
|
||||
pw_work_queue_add(data->work, data, 0, do_unload_module, data);
|
||||
}
|
||||
}
|
||||
|
||||
static void stream_destroy(void *d)
|
||||
{
|
||||
struct module_roc_sink_data *data = d;
|
||||
|
|
@ -189,7 +173,7 @@ static void on_core_error(void *d, uint32_t id, int seq, int res, const char *me
|
|||
id, seq, res, spa_strerror(res), message);
|
||||
|
||||
if (id == PW_ID_CORE && res == -EPIPE)
|
||||
unload_module(data);
|
||||
pw_impl_module_schedule_destroy(data->module);
|
||||
}
|
||||
|
||||
static const struct pw_core_events core_events = {
|
||||
|
|
@ -205,7 +189,7 @@ static void on_stream_state_changed(void *d, enum pw_stream_state old,
|
|||
switch (state) {
|
||||
case PW_STREAM_STATE_UNCONNECTED:
|
||||
pw_log_info("stream disconnected, unloading");
|
||||
unload_module(data);
|
||||
pw_impl_module_schedule_destroy(data->module);
|
||||
break;
|
||||
case PW_STREAM_STATE_ERROR:
|
||||
pw_log_error("stream error: %s", error);
|
||||
|
|
@ -227,7 +211,7 @@ static void core_destroy(void *d)
|
|||
struct module_roc_sink_data *data = d;
|
||||
spa_hook_remove(&data->core_listener);
|
||||
data->core = NULL;
|
||||
unload_module(data);
|
||||
pw_impl_module_schedule_destroy(data->module);
|
||||
}
|
||||
|
||||
static const struct pw_proxy_events core_proxy_events = {
|
||||
|
|
@ -244,8 +228,6 @@ static void impl_destroy(struct module_roc_sink_data *data)
|
|||
pw_properties_free(data->capture_props);
|
||||
pw_properties_free(data->props);
|
||||
|
||||
if (data->work)
|
||||
pw_work_queue_cancel(data->work, data, SPA_ID_INVALID);
|
||||
if (data->sender)
|
||||
roc_sender_close(data->sender);
|
||||
if (data->context)
|
||||
|
|
@ -259,7 +241,6 @@ static void impl_destroy(struct module_roc_sink_data *data)
|
|||
static void module_destroy(void *d)
|
||||
{
|
||||
struct module_roc_sink_data *data = d;
|
||||
data->unloading = true;
|
||||
spa_hook_remove(&data->module_listener);
|
||||
impl_destroy(data);
|
||||
}
|
||||
|
|
@ -416,7 +397,6 @@ int pipewire__module_init(struct pw_impl_module *module, const char *args)
|
|||
|
||||
data->module = module;
|
||||
data->module_context = context;
|
||||
data->work = pw_context_get_work_queue(context);
|
||||
|
||||
if ((str = pw_properties_get(props, "sink.name")) != NULL) {
|
||||
pw_properties_set(capture_props, PW_KEY_NODE_NAME, str);
|
||||
|
|
|
|||
|
|
@ -100,7 +100,6 @@ PW_LOG_TOPIC_STATIC(mod_topic, "mod." NAME);
|
|||
|
||||
struct module_roc_source_data {
|
||||
struct pw_impl_module *module;
|
||||
struct pw_work_queue *work;
|
||||
struct spa_hook module_listener;
|
||||
struct pw_properties *props;
|
||||
struct pw_context *module_context;
|
||||
|
|
@ -114,7 +113,6 @@ struct module_roc_source_data {
|
|||
struct pw_properties *playback_props;
|
||||
|
||||
unsigned int do_disconnect:1;
|
||||
unsigned int unloading:1;
|
||||
|
||||
roc_address local_addr;
|
||||
roc_address local_source_addr;
|
||||
|
|
@ -129,20 +127,6 @@ struct module_roc_source_data {
|
|||
int sess_latency_msec;
|
||||
};
|
||||
|
||||
static void do_unload_module(void *obj, void *d, int res, uint32_t id)
|
||||
{
|
||||
struct module_roc_source_data *data = d;
|
||||
pw_impl_module_destroy(data->module);
|
||||
}
|
||||
|
||||
static void unload_module(struct module_roc_source_data *data)
|
||||
{
|
||||
if (!data->unloading) {
|
||||
data->unloading = true;
|
||||
pw_work_queue_add(data->work, data, 0, do_unload_module, data);
|
||||
}
|
||||
}
|
||||
|
||||
static void stream_destroy(void *d)
|
||||
{
|
||||
struct module_roc_source_data *data = d;
|
||||
|
|
@ -202,7 +186,7 @@ static void playback_process(void *data)
|
|||
if (roc_receiver_read(impl->receiver, &frame) != 0) {
|
||||
/* Handle EOF and error */
|
||||
pw_log_error("Failed to read from roc source");
|
||||
unload_module(data);
|
||||
pw_impl_module_schedule_destroy(impl->module);
|
||||
return;
|
||||
}
|
||||
|
||||
|
|
@ -219,7 +203,7 @@ static void on_core_error(void *d, uint32_t id, int seq, int res, const char *me
|
|||
id, seq, res, spa_strerror(res), message);
|
||||
|
||||
if (id == PW_ID_CORE && res == -EPIPE)
|
||||
unload_module(data);
|
||||
pw_impl_module_schedule_destroy(data->module);
|
||||
}
|
||||
|
||||
static const struct pw_core_events core_events = {
|
||||
|
|
@ -235,7 +219,7 @@ static void on_stream_state_changed(void *d, enum pw_stream_state old,
|
|||
switch (state) {
|
||||
case PW_STREAM_STATE_UNCONNECTED:
|
||||
pw_log_info("stream disconnected, unloading");
|
||||
unload_module(data);
|
||||
pw_impl_module_schedule_destroy(data->module);
|
||||
break;
|
||||
case PW_STREAM_STATE_ERROR:
|
||||
pw_log_error("stream error: %s", error);
|
||||
|
|
@ -257,7 +241,7 @@ static void core_destroy(void *d)
|
|||
struct module_roc_source_data *data = d;
|
||||
spa_hook_remove(&data->core_listener);
|
||||
data->core = NULL;
|
||||
unload_module(data);
|
||||
pw_impl_module_schedule_destroy(data->module);
|
||||
}
|
||||
|
||||
static const struct pw_proxy_events core_proxy_events = {
|
||||
|
|
@ -274,8 +258,6 @@ static void impl_destroy(struct module_roc_source_data *data)
|
|||
pw_properties_free(data->playback_props);
|
||||
pw_properties_free(data->props);
|
||||
|
||||
if (data->work)
|
||||
pw_work_queue_cancel(data->work, data, SPA_ID_INVALID);
|
||||
if (data->receiver)
|
||||
roc_receiver_close(data->receiver);
|
||||
if (data->context)
|
||||
|
|
@ -289,7 +271,6 @@ static void impl_destroy(struct module_roc_source_data *data)
|
|||
static void module_destroy(void *d)
|
||||
{
|
||||
struct module_roc_source_data *data = d;
|
||||
data->unloading = true;
|
||||
spa_hook_remove(&data->module_listener);
|
||||
impl_destroy(data);
|
||||
}
|
||||
|
|
@ -461,7 +442,6 @@ int pipewire__module_init(struct pw_impl_module *module, const char *args)
|
|||
|
||||
data->module = module;
|
||||
data->module_context = context;
|
||||
data->work = pw_context_get_work_queue(context);
|
||||
|
||||
if ((str = pw_properties_get(props, "source.name")) != NULL) {
|
||||
pw_properties_set(playback_props, PW_KEY_NODE_NAME, str);
|
||||
|
|
|
|||
|
|
@ -73,7 +73,6 @@ struct impl {
|
|||
|
||||
struct pw_impl_module *module;
|
||||
struct spa_hook module_listener;
|
||||
struct pw_work_queue *work;
|
||||
|
||||
struct pw_properties *properties;
|
||||
|
||||
|
|
@ -83,8 +82,6 @@ struct impl {
|
|||
AvahiServiceBrowser *source_browser;
|
||||
|
||||
struct spa_list tunnel_list;
|
||||
|
||||
unsigned int unloading:1;
|
||||
};
|
||||
|
||||
struct tunnel_info {
|
||||
|
|
@ -106,20 +103,6 @@ struct tunnel {
|
|||
|
||||
static int start_client(struct impl *impl);
|
||||
|
||||
static void do_unload_module(void *obj, void *data, int res, uint32_t id)
|
||||
{
|
||||
struct impl *impl = data;
|
||||
pw_impl_module_destroy(impl->module);
|
||||
}
|
||||
|
||||
static void unload_module(struct impl *impl)
|
||||
{
|
||||
if (!impl->unloading) {
|
||||
impl->unloading = true;
|
||||
pw_work_queue_add(impl->work, impl, 0, do_unload_module, impl);
|
||||
}
|
||||
}
|
||||
|
||||
static struct tunnel *make_tunnel(struct impl *impl, const struct tunnel_info *info)
|
||||
{
|
||||
struct tunnel *t;
|
||||
|
|
@ -173,8 +156,6 @@ static void impl_free(struct impl *impl)
|
|||
if (impl->avahi_poll)
|
||||
pw_avahi_poll_free(impl->avahi_poll);
|
||||
pw_properties_free(impl->properties);
|
||||
if (impl->work)
|
||||
pw_work_queue_cancel(impl->work, impl, SPA_ID_INVALID);
|
||||
free(impl);
|
||||
}
|
||||
|
||||
|
|
@ -483,7 +464,7 @@ static void client_callback(AvahiClient *c, AvahiClientState state, void *userda
|
|||
}
|
||||
return;
|
||||
error:
|
||||
unload_module(impl);
|
||||
pw_impl_module_schedule_destroy(impl->module);
|
||||
}
|
||||
|
||||
static int start_client(struct impl *impl)
|
||||
|
|
@ -494,7 +475,7 @@ static int start_client(struct impl *impl)
|
|||
client_callback, impl,
|
||||
&res)) == NULL) {
|
||||
pw_log_error("can't create client: %s", avahi_strerror(res));
|
||||
unload_module(impl);
|
||||
pw_impl_module_schedule_destroy(impl->module);
|
||||
return -EIO;
|
||||
}
|
||||
return 0;
|
||||
|
|
@ -539,8 +520,6 @@ int pipewire__module_init(struct pw_impl_module *module, const char *args)
|
|||
impl->context = context;
|
||||
impl->properties = props;
|
||||
|
||||
impl->work = pw_context_get_work_queue(context);
|
||||
|
||||
pw_impl_module_add_listener(module, &impl->module_listener, &module_events, impl);
|
||||
|
||||
pw_impl_module_update_properties(module, &SPA_DICT_INIT_ARRAY(module_props));
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue