mirror of
https://gitlab.freedesktop.org/pipewire/pipewire.git
synced 2025-11-04 13:30:12 -05:00
pulse-server: implement module-x11-bell
Just load the x11-bell module into the pulse server. See #1668
This commit is contained in:
parent
5c894c2283
commit
373432a4e7
4 changed files with 148 additions and 0 deletions
|
|
@ -261,6 +261,7 @@ pipewire_module_protocol_pulse_sources = [
|
||||||
'module-protocol-pulse/modules/module-switch-on-connect.c',
|
'module-protocol-pulse/modules/module-switch-on-connect.c',
|
||||||
'module-protocol-pulse/modules/module-tunnel-sink.c',
|
'module-protocol-pulse/modules/module-tunnel-sink.c',
|
||||||
'module-protocol-pulse/modules/module-tunnel-source.c',
|
'module-protocol-pulse/modules/module-tunnel-source.c',
|
||||||
|
'module-protocol-pulse/modules/module-x11-bell.c',
|
||||||
'module-protocol-pulse/modules/module-zeroconf-discover.c',
|
'module-protocol-pulse/modules/module-zeroconf-discover.c',
|
||||||
]
|
]
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -270,6 +270,7 @@ static const struct module_info module_list[] = {
|
||||||
#endif
|
#endif
|
||||||
{ "module-roc-sink", create_module_roc_sink, },
|
{ "module-roc-sink", create_module_roc_sink, },
|
||||||
{ "module-roc-source", create_module_roc_source, },
|
{ "module-roc-source", create_module_roc_source, },
|
||||||
|
{ "module-x11-bell", create_module_x11_bell, },
|
||||||
};
|
};
|
||||||
|
|
||||||
static const struct module_info *find_module_info(const char *name)
|
static const struct module_info *find_module_info(const char *name)
|
||||||
|
|
|
||||||
145
src/modules/module-protocol-pulse/modules/module-x11-bell.c
Normal file
145
src/modules/module-protocol-pulse/modules/module-x11-bell.c
Normal file
|
|
@ -0,0 +1,145 @@
|
||||||
|
/* PipeWire
|
||||||
|
*
|
||||||
|
* Copyright © 2022 Wim Taymans <wim.taymans@gmail.com>
|
||||||
|
*
|
||||||
|
* Permission is hereby granted, free of charge, to any person obtaining a
|
||||||
|
* copy of this software and associated documentation files (the "Software"),
|
||||||
|
* to deal in the Software without restriction, including without limitation
|
||||||
|
* the rights to use, copy, modify, merge, publish, distribute, sublicense,
|
||||||
|
* and/or sell copies of the Software, and to permit persons to whom the
|
||||||
|
* Software is furnished to do so, subject to the following conditions:
|
||||||
|
*
|
||||||
|
* The above copyright notice and this permission notice (including the next
|
||||||
|
* paragraph) shall be included in all copies or substantial portions of the
|
||||||
|
* Software.
|
||||||
|
*
|
||||||
|
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||||
|
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||||
|
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
|
||||||
|
* THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||||
|
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
|
||||||
|
* FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
|
||||||
|
* DEALINGS IN THE SOFTWARE.
|
||||||
|
*/
|
||||||
|
|
||||||
|
#include <pipewire/pipewire.h>
|
||||||
|
|
||||||
|
#include "../module.h"
|
||||||
|
|
||||||
|
#define NAME "x11-bell"
|
||||||
|
|
||||||
|
PW_LOG_TOPIC_STATIC(mod_topic, "mod." NAME);
|
||||||
|
#define PW_LOG_TOPIC_DEFAULT mod_topic
|
||||||
|
|
||||||
|
struct module_x11_bell_data {
|
||||||
|
struct module *module;
|
||||||
|
|
||||||
|
struct pw_impl_module *mod;
|
||||||
|
struct spa_hook mod_listener;
|
||||||
|
};
|
||||||
|
|
||||||
|
static void module_destroy(void *data)
|
||||||
|
{
|
||||||
|
struct module_x11_bell_data *d = data;
|
||||||
|
spa_hook_remove(&d->mod_listener);
|
||||||
|
d->mod = NULL;
|
||||||
|
module_schedule_unload(d->module);
|
||||||
|
}
|
||||||
|
|
||||||
|
static const struct pw_impl_module_events module_events = {
|
||||||
|
PW_VERSION_IMPL_MODULE_EVENTS,
|
||||||
|
.destroy = module_destroy
|
||||||
|
};
|
||||||
|
|
||||||
|
static int module_x11_bell_load(struct client *client, struct module *module)
|
||||||
|
{
|
||||||
|
struct module_x11_bell_data *data = module->user_data;
|
||||||
|
FILE *f;
|
||||||
|
char *args;
|
||||||
|
const char *str;
|
||||||
|
size_t size;
|
||||||
|
|
||||||
|
f = open_memstream(&args, &size);
|
||||||
|
fprintf(f, "{");
|
||||||
|
if ((str = pw_properties_get(module->props, "sink")) != NULL)
|
||||||
|
fprintf(f, " sink.name = \"%s\"", str);
|
||||||
|
if ((str = pw_properties_get(module->props, "sample")) != NULL)
|
||||||
|
fprintf(f, " sample.name = \"%s\"", str);
|
||||||
|
if ((str = pw_properties_get(module->props, "display")) != NULL)
|
||||||
|
fprintf(f, " x11.display = \"%s\"", str);
|
||||||
|
if ((str = pw_properties_get(module->props, "xauthority")) != NULL)
|
||||||
|
fprintf(f, " x11.xauthority = \"%s\"", str);
|
||||||
|
fprintf(f, " }");
|
||||||
|
fclose(f);
|
||||||
|
|
||||||
|
data->mod = pw_context_load_module(module->impl->context,
|
||||||
|
"libpipewire-module-x11-bell",
|
||||||
|
args, NULL);
|
||||||
|
free(args);
|
||||||
|
|
||||||
|
if (data->mod == NULL)
|
||||||
|
return -errno;
|
||||||
|
|
||||||
|
pw_impl_module_add_listener(data->mod,
|
||||||
|
&data->mod_listener,
|
||||||
|
&module_events, data);
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
static int module_x11_bell_unload(struct client *client, struct module *module)
|
||||||
|
{
|
||||||
|
struct module_x11_bell_data *d = module->user_data;
|
||||||
|
|
||||||
|
if (d->mod) {
|
||||||
|
spa_hook_remove(&d->mod_listener);
|
||||||
|
pw_impl_module_destroy(d->mod);
|
||||||
|
d->mod = NULL;
|
||||||
|
}
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
static const struct module_methods module_x11_bell_methods = {
|
||||||
|
VERSION_MODULE_METHODS,
|
||||||
|
.load = module_x11_bell_load,
|
||||||
|
.unload = module_x11_bell_unload,
|
||||||
|
};
|
||||||
|
|
||||||
|
static const struct spa_dict_item module_x11_bell_info[] = {
|
||||||
|
{ PW_KEY_MODULE_AUTHOR, "Wim Taymans <wim.taymans@gmail.com>" },
|
||||||
|
{ PW_KEY_MODULE_DESCRIPTION, "X11 bell interceptor" },
|
||||||
|
{ PW_KEY_MODULE_USAGE, "sink=<sink to connect to> "
|
||||||
|
"sample=<the sample to play> "
|
||||||
|
"display=<X11 display> "
|
||||||
|
"xauthority=<X11 Authority>" },
|
||||||
|
{ PW_KEY_MODULE_VERSION, PACKAGE_VERSION },
|
||||||
|
};
|
||||||
|
|
||||||
|
struct module *create_module_x11_bell(struct impl *impl, const char *argument)
|
||||||
|
{
|
||||||
|
struct module *module;
|
||||||
|
struct pw_properties *props = NULL;
|
||||||
|
int res;
|
||||||
|
|
||||||
|
PW_LOG_TOPIC_INIT(mod_topic);
|
||||||
|
|
||||||
|
props = pw_properties_new_dict(&SPA_DICT_INIT_ARRAY(module_x11_bell_info));
|
||||||
|
if (props == NULL) {
|
||||||
|
res = -EINVAL;
|
||||||
|
goto out;
|
||||||
|
}
|
||||||
|
if (argument)
|
||||||
|
module_args_add_props(props, argument);
|
||||||
|
|
||||||
|
module = module_new(impl, &module_x11_bell_methods, sizeof(struct module_x11_bell_data));
|
||||||
|
if (module == NULL) {
|
||||||
|
res = -errno;
|
||||||
|
goto out;
|
||||||
|
}
|
||||||
|
module->props = props;
|
||||||
|
|
||||||
|
return module;
|
||||||
|
out:
|
||||||
|
pw_properties_free(props);
|
||||||
|
errno = -res;
|
||||||
|
return NULL;
|
||||||
|
}
|
||||||
|
|
@ -48,5 +48,6 @@ struct module *create_module_zeroconf_discover(struct impl *impl, const char *ar
|
||||||
struct module *create_module_zeroconf_publish(struct impl *impl, const char *argument);
|
struct module *create_module_zeroconf_publish(struct impl *impl, const char *argument);
|
||||||
struct module *create_module_roc_sink(struct impl *impl, const char *argument);
|
struct module *create_module_roc_sink(struct impl *impl, const char *argument);
|
||||||
struct module *create_module_roc_source(struct impl *impl, const char *argument);
|
struct module *create_module_roc_source(struct impl *impl, const char *argument);
|
||||||
|
struct module *create_module_x11_bell(struct impl *impl, const char *argument);
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue