mirror of
https://gitlab.freedesktop.org/pulseaudio/pulseaudio.git
synced 2025-11-06 13:29:56 -05:00
modernize
git-svn-id: file:///home/lennart/svn/public/pulseaudio/branches/lennart@1609 fefdeb5f-60dc-0310-8127-8f9354f1896f
This commit is contained in:
parent
3dfdb21759
commit
583167722e
1 changed files with 24 additions and 24 deletions
|
|
@ -26,7 +26,6 @@
|
|||
#endif
|
||||
|
||||
#include <stdio.h>
|
||||
#include <assert.h>
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
|
||||
|
|
@ -67,30 +66,21 @@ static const char* const valid_modargs[] = {
|
|||
NULL
|
||||
};
|
||||
|
||||
static int ring_bell(struct userdata *u, int percent) {
|
||||
pa_sink *s;
|
||||
assert(u);
|
||||
|
||||
if (!(s = pa_namereg_get(u->core, u->sink_name, PA_NAMEREG_SINK, 1))) {
|
||||
pa_log("Invalid sink: %s", u->sink_name);
|
||||
return -1;
|
||||
}
|
||||
|
||||
pa_scache_play_item(u->core, u->scache_item, s, (percent*PA_VOLUME_NORM)/100);
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int x11_event_callback(pa_x11_wrapper *w, XEvent *e, void *userdata) {
|
||||
XkbBellNotifyEvent *bne;
|
||||
struct userdata *u = userdata;
|
||||
assert(w && e && u && u->x11_wrapper == w);
|
||||
|
||||
pa_assert(w);
|
||||
pa_assert(e);
|
||||
pa_assert(u);
|
||||
pa_assert(u->x11_wrapper == w);
|
||||
|
||||
if (((XkbEvent*) e)->any.xkb_type != XkbBellNotify)
|
||||
return 0;
|
||||
|
||||
bne = (XkbBellNotifyEvent*) e;
|
||||
|
||||
if (ring_bell(u, bne->percent) < 0) {
|
||||
if (pa_scache_play_item_by_name(u->core, u->scache_item, u->sink_name, (bne->percent*PA_VOLUME_NORM)/100, 1) < 0) {
|
||||
pa_log_info("Ringing bell failed, reverting to X11 device bell.");
|
||||
XkbForceDeviceBell(pa_x11_wrapper_get_display(w), bne->device, bne->bell_class, bne->bell_id, bne->percent);
|
||||
}
|
||||
|
|
@ -99,18 +89,21 @@ static int x11_event_callback(pa_x11_wrapper *w, XEvent *e, void *userdata) {
|
|||
}
|
||||
|
||||
int pa__init(pa_core *c, pa_module*m) {
|
||||
|
||||
struct userdata *u = NULL;
|
||||
pa_modargs *ma = NULL;
|
||||
int major, minor;
|
||||
unsigned int auto_ctrls, auto_values;
|
||||
assert(c && m);
|
||||
|
||||
pa_assert(c);
|
||||
pa_assert(m);
|
||||
|
||||
if (!(ma = pa_modargs_new(m->argument, valid_modargs))) {
|
||||
pa_log("failed to parse module arguments");
|
||||
pa_log("Failed to parse module arguments");
|
||||
goto fail;
|
||||
}
|
||||
|
||||
m->userdata = u = pa_xmalloc(sizeof(struct userdata));
|
||||
m->userdata = u = pa_xnew(struct userdata, 1);
|
||||
u->core = c;
|
||||
u->scache_item = pa_xstrdup(pa_modargs_get_value(ma, "sample", "x11-bell"));
|
||||
u->sink_name = pa_xstrdup(pa_modargs_get_value(ma, "sink", NULL));
|
||||
|
|
@ -130,7 +123,6 @@ int pa__init(pa_core *c, pa_module*m) {
|
|||
major = XkbMajorVersion;
|
||||
minor = XkbMinorVersion;
|
||||
|
||||
|
||||
if (!XkbQueryExtension(pa_x11_wrapper_get_display(u->x11_wrapper), NULL, &u->xkb_event_base, NULL, &major, &minor)) {
|
||||
pa_log("XkbQueryExtension() failed");
|
||||
goto fail;
|
||||
|
|
@ -150,14 +142,22 @@ int pa__init(pa_core *c, pa_module*m) {
|
|||
fail:
|
||||
if (ma)
|
||||
pa_modargs_free(ma);
|
||||
if (m->userdata)
|
||||
pa__done(c, m);
|
||||
|
||||
pa__done(c, m);
|
||||
|
||||
return -1;
|
||||
}
|
||||
|
||||
void pa__done(pa_core *c, pa_module*m) {
|
||||
struct userdata *u = m->userdata;
|
||||
assert(c && m && u);
|
||||
struct userdata *u;
|
||||
|
||||
assert(c);
|
||||
assert(m);
|
||||
|
||||
if (!m->userdata)
|
||||
return;
|
||||
|
||||
u = m->userdata;
|
||||
|
||||
pa_xfree(u->scache_item);
|
||||
pa_xfree(u->sink_name);
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue