mirror of
https://gitlab.freedesktop.org/pulseaudio/pulseaudio.git
synced 2025-11-03 09:01:50 -05:00
merge 'lennart' branch back into trunk.
git-svn-id: file:///home/lennart/svn/public/pulseaudio/trunk@1971 fefdeb5f-60dc-0310-8127-8f9354f1896f
This commit is contained in:
parent
6687dd0131
commit
a67c21f093
294 changed files with 79057 additions and 11614 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);
|
||||
}
|
||||
|
|
@ -98,25 +88,27 @@ static int x11_event_callback(pa_x11_wrapper *w, XEvent *e, void *userdata) {
|
|||
return 1;
|
||||
}
|
||||
|
||||
int pa__init(pa_core *c, pa_module*m) {
|
||||
int pa__init(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(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));
|
||||
u->core = c;
|
||||
m->userdata = u = pa_xnew(struct userdata, 1);
|
||||
u->core = m->core;
|
||||
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));
|
||||
u->x11_client = NULL;
|
||||
|
||||
if (!(u->x11_wrapper = pa_x11_wrapper_get(c, pa_modargs_get_value(ma, "display", NULL))))
|
||||
if (!(u->x11_wrapper = pa_x11_wrapper_get(m->core, pa_modargs_get_value(ma, "display", NULL))))
|
||||
goto fail;
|
||||
|
||||
major = XkbMajorVersion;
|
||||
|
|
@ -130,7 +122,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 +141,21 @@ 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(m);
|
||||
|
||||
return -1;
|
||||
}
|
||||
|
||||
void pa__done(pa_core *c, pa_module*m) {
|
||||
struct userdata *u = m->userdata;
|
||||
assert(c && m && u);
|
||||
void pa__done(pa_module*m) {
|
||||
struct userdata *u;
|
||||
|
||||
pa_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