mirror of
https://gitlab.freedesktop.org/pipewire/pipewire.git
synced 2025-10-31 22:25:38 -04:00
pipewire: expose pw_impl_module_schedule_destroy()
And then remove the custom code in the example sink/source.
This commit is contained in:
parent
164e343dbf
commit
ca1b32393d
4 changed files with 9 additions and 46 deletions
|
|
@ -126,7 +126,6 @@ struct impl {
|
||||||
struct pw_properties *props;
|
struct pw_properties *props;
|
||||||
|
|
||||||
struct pw_impl_module *module;
|
struct pw_impl_module *module;
|
||||||
struct pw_work_queue *work;
|
|
||||||
|
|
||||||
struct spa_hook module_listener;
|
struct spa_hook module_listener;
|
||||||
|
|
||||||
|
|
@ -141,23 +140,8 @@ struct impl {
|
||||||
uint32_t frame_size;
|
uint32_t frame_size;
|
||||||
|
|
||||||
unsigned int do_disconnect:1;
|
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 stream_destroy(void *d)
|
static void stream_destroy(void *d)
|
||||||
{
|
{
|
||||||
struct impl *impl = d;
|
struct impl *impl = d;
|
||||||
|
|
@ -172,7 +156,7 @@ static void stream_state_changed(void *d, enum pw_stream_state old,
|
||||||
switch (state) {
|
switch (state) {
|
||||||
case PW_STREAM_STATE_ERROR:
|
case PW_STREAM_STATE_ERROR:
|
||||||
case PW_STREAM_STATE_UNCONNECTED:
|
case PW_STREAM_STATE_UNCONNECTED:
|
||||||
unload_module(impl);
|
pw_impl_module_schedule_destroy(impl->module);
|
||||||
break;
|
break;
|
||||||
case PW_STREAM_STATE_PAUSED:
|
case PW_STREAM_STATE_PAUSED:
|
||||||
case PW_STREAM_STATE_STREAMING:
|
case PW_STREAM_STATE_STREAMING:
|
||||||
|
|
@ -257,7 +241,7 @@ static void core_error(void *data, uint32_t id, int seq, int res, const char *me
|
||||||
id, seq, res, spa_strerror(res), message);
|
id, seq, res, spa_strerror(res), message);
|
||||||
|
|
||||||
if (id == PW_ID_CORE && res == -EPIPE)
|
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 = {
|
static const struct pw_core_events core_events = {
|
||||||
|
|
@ -270,7 +254,7 @@ static void core_destroy(void *d)
|
||||||
struct impl *impl = d;
|
struct impl *impl = d;
|
||||||
spa_hook_remove(&impl->core_listener);
|
spa_hook_remove(&impl->core_listener);
|
||||||
impl->core = NULL;
|
impl->core = NULL;
|
||||||
unload_module(impl);
|
pw_impl_module_schedule_destroy(impl->module);
|
||||||
}
|
}
|
||||||
|
|
||||||
static const struct pw_proxy_events core_proxy_events = {
|
static const struct pw_proxy_events core_proxy_events = {
|
||||||
|
|
@ -287,15 +271,12 @@ static void impl_destroy(struct impl *impl)
|
||||||
pw_properties_free(impl->stream_props);
|
pw_properties_free(impl->stream_props);
|
||||||
pw_properties_free(impl->props);
|
pw_properties_free(impl->props);
|
||||||
|
|
||||||
if (impl->work)
|
|
||||||
pw_work_queue_cancel(impl->work, impl, SPA_ID_INVALID);
|
|
||||||
free(impl);
|
free(impl);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void module_destroy(void *data)
|
static void module_destroy(void *data)
|
||||||
{
|
{
|
||||||
struct impl *impl = data;
|
struct impl *impl = data;
|
||||||
impl->unloading = true;
|
|
||||||
spa_hook_remove(&impl->module_listener);
|
spa_hook_remove(&impl->module_listener);
|
||||||
impl_destroy(impl);
|
impl_destroy(impl);
|
||||||
}
|
}
|
||||||
|
|
@ -444,7 +425,6 @@ int pipewire__module_init(struct pw_impl_module *module, const char *args)
|
||||||
|
|
||||||
impl->module = module;
|
impl->module = module;
|
||||||
impl->context = context;
|
impl->context = context;
|
||||||
impl->work = pw_context_get_work_queue(context);
|
|
||||||
|
|
||||||
if (pw_properties_get(props, PW_KEY_NODE_VIRTUAL) == NULL)
|
if (pw_properties_get(props, PW_KEY_NODE_VIRTUAL) == NULL)
|
||||||
pw_properties_set(props, PW_KEY_NODE_VIRTUAL, "true");
|
pw_properties_set(props, PW_KEY_NODE_VIRTUAL, "true");
|
||||||
|
|
|
||||||
|
|
@ -126,7 +126,6 @@ struct impl {
|
||||||
struct pw_properties *props;
|
struct pw_properties *props;
|
||||||
|
|
||||||
struct pw_impl_module *module;
|
struct pw_impl_module *module;
|
||||||
struct pw_work_queue *work;
|
|
||||||
|
|
||||||
struct spa_hook module_listener;
|
struct spa_hook module_listener;
|
||||||
|
|
||||||
|
|
@ -144,20 +143,6 @@ struct impl {
|
||||||
unsigned int unloading: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 stream_destroy(void *d)
|
static void stream_destroy(void *d)
|
||||||
{
|
{
|
||||||
struct impl *impl = d;
|
struct impl *impl = d;
|
||||||
|
|
@ -172,7 +157,7 @@ static void stream_state_changed(void *d, enum pw_stream_state old,
|
||||||
switch (state) {
|
switch (state) {
|
||||||
case PW_STREAM_STATE_ERROR:
|
case PW_STREAM_STATE_ERROR:
|
||||||
case PW_STREAM_STATE_UNCONNECTED:
|
case PW_STREAM_STATE_UNCONNECTED:
|
||||||
unload_module(impl);
|
pw_impl_module_schedule_destroy(impl->module);
|
||||||
break;
|
break;
|
||||||
case PW_STREAM_STATE_PAUSED:
|
case PW_STREAM_STATE_PAUSED:
|
||||||
case PW_STREAM_STATE_STREAMING:
|
case PW_STREAM_STATE_STREAMING:
|
||||||
|
|
@ -261,7 +246,7 @@ static void core_error(void *data, uint32_t id, int seq, int res, const char *me
|
||||||
id, seq, res, spa_strerror(res), message);
|
id, seq, res, spa_strerror(res), message);
|
||||||
|
|
||||||
if (id == PW_ID_CORE && res == -EPIPE)
|
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 = {
|
static const struct pw_core_events core_events = {
|
||||||
|
|
@ -274,7 +259,7 @@ static void core_destroy(void *d)
|
||||||
struct impl *impl = d;
|
struct impl *impl = d;
|
||||||
spa_hook_remove(&impl->core_listener);
|
spa_hook_remove(&impl->core_listener);
|
||||||
impl->core = NULL;
|
impl->core = NULL;
|
||||||
unload_module(impl);
|
pw_impl_module_schedule_destroy(impl->module);
|
||||||
}
|
}
|
||||||
|
|
||||||
static const struct pw_proxy_events core_proxy_events = {
|
static const struct pw_proxy_events core_proxy_events = {
|
||||||
|
|
@ -291,8 +276,6 @@ static void impl_destroy(struct impl *impl)
|
||||||
pw_properties_free(impl->stream_props);
|
pw_properties_free(impl->stream_props);
|
||||||
pw_properties_free(impl->props);
|
pw_properties_free(impl->props);
|
||||||
|
|
||||||
if (impl->work)
|
|
||||||
pw_work_queue_cancel(impl->work, impl, SPA_ID_INVALID);
|
|
||||||
free(impl);
|
free(impl);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -448,7 +431,6 @@ int pipewire__module_init(struct pw_impl_module *module, const char *args)
|
||||||
|
|
||||||
impl->module = module;
|
impl->module = module;
|
||||||
impl->context = context;
|
impl->context = context;
|
||||||
impl->work = pw_context_get_work_queue(context);
|
|
||||||
|
|
||||||
if (pw_properties_get(props, PW_KEY_NODE_VIRTUAL) == NULL)
|
if (pw_properties_get(props, PW_KEY_NODE_VIRTUAL) == NULL)
|
||||||
pw_properties_set(props, PW_KEY_NODE_VIRTUAL, "true");
|
pw_properties_set(props, PW_KEY_NODE_VIRTUAL, "true");
|
||||||
|
|
|
||||||
|
|
@ -106,6 +106,9 @@ void pw_impl_module_add_listener(struct pw_impl_module *module,
|
||||||
/** Destroy a module */
|
/** Destroy a module */
|
||||||
void pw_impl_module_destroy(struct pw_impl_module *module);
|
void pw_impl_module_destroy(struct pw_impl_module *module);
|
||||||
|
|
||||||
|
/** Schedule a destroy later on the main thread */
|
||||||
|
void pw_impl_module_schedule_destroy(struct pw_impl_module *module);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* \}
|
* \}
|
||||||
*/
|
*/
|
||||||
|
|
|
||||||
|
|
@ -1299,8 +1299,6 @@ void pw_settings_init(struct pw_context *context);
|
||||||
int pw_settings_expose(struct pw_context *context);
|
int pw_settings_expose(struct pw_context *context);
|
||||||
void pw_settings_clean(struct pw_context *context);
|
void pw_settings_clean(struct pw_context *context);
|
||||||
|
|
||||||
void pw_impl_module_schedule_destroy(struct pw_impl_module *module);
|
|
||||||
|
|
||||||
pthread_attr_t *pw_thread_fill_attr(const struct spa_dict *props, pthread_attr_t *attr);
|
pthread_attr_t *pw_thread_fill_attr(const struct spa_dict *props, pthread_attr_t *attr);
|
||||||
|
|
||||||
/** \endcond */
|
/** \endcond */
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue