summaryrefslogtreecommitdiffstats
path: root/src/modules/module-mmkbd-evdev.c
diff options
context:
space:
mode:
authorLennart Poettering <lennart@poettering.net>2007-08-10 14:28:39 +0000
committerLennart Poettering <lennart@poettering.net>2007-08-10 14:28:39 +0000
commitffa170807086e959ce7cd9b21fb0c29b104b222b (patch)
treef1361aa0b1a54e9545a1de5398cbf1cf17c4b4cb /src/modules/module-mmkbd-evdev.c
parente621071bf1a4f82ce5eba36917e67048ac0c59ef (diff)
* drop redundant pa_core argument from module initialization functions
* make pa__done() implementations optional * a couple of modernizations * wrap lt_dlsym() at a single place * allow passing of an "api" argument to the HAL module, to choose whether OSS devices or ALSA devices should be picked up * optimize fd closing a little on linux in the forked gconf helper * save a little memory in the xsmp module git-svn-id: file:///home/lennart/svn/public/pulseaudio/branches/lennart@1615 fefdeb5f-60dc-0310-8127-8f9354f1896f
Diffstat (limited to 'src/modules/module-mmkbd-evdev.c')
-rw-r--r--src/modules/module-mmkbd-evdev.c34
1 files changed, 18 insertions, 16 deletions
diff --git a/src/modules/module-mmkbd-evdev.c b/src/modules/module-mmkbd-evdev.c
index 919b399d..03394c0a 100644
--- a/src/modules/module-mmkbd-evdev.c
+++ b/src/modules/module-mmkbd-evdev.c
@@ -26,7 +26,6 @@
#endif
#include <stdio.h>
-#include <assert.h>
#include <unistd.h>
#include <string.h>
#include <stdlib.h>
@@ -80,11 +79,12 @@ struct userdata {
static void io_callback(pa_mainloop_api *io, PA_GCC_UNUSED pa_io_event *e, PA_GCC_UNUSED int fd, pa_io_event_flags_t events, void*userdata) {
struct userdata *u = userdata;
- assert(io);
- assert(u);
+
+ pa_assert(io);
+ pa_assert(u);
if (events & (PA_IO_EVENT_HANGUP|PA_IO_EVENT_ERROR)) {
- pa_log("lost connection to evdev device.");
+ pa_log("Lost connection to evdev device.");
goto fail;
}
@@ -92,14 +92,14 @@ static void io_callback(pa_mainloop_api *io, PA_GCC_UNUSED pa_io_event *e, PA_GC
struct input_event ev;
if (pa_loop_read(u->fd, &ev, sizeof(ev), &u->fd_type) <= 0) {
- pa_log("failed to read from event device: %s", pa_cstrerror(errno));
+ pa_log("Failed to read from event device: %s", pa_cstrerror(errno));
goto fail;
}
if (ev.type == EV_KEY && (ev.value == 1 || ev.value == 2)) {
enum { INVALID, UP, DOWN, MUTE_TOGGLE } volchange = INVALID;
- pa_log_debug("key code=%u, value=%u", ev.code, ev.value);
+ pa_log_debug("Key code=%u, value=%u", ev.code, ev.value);
switch (ev.code) {
case KEY_VOLUMEDOWN: volchange = DOWN; break;
@@ -111,7 +111,7 @@ static void io_callback(pa_mainloop_api *io, PA_GCC_UNUSED pa_io_event *e, PA_GC
pa_sink *s;
if (!(s = pa_namereg_get(u->module->core, u->sink_name, PA_NAMEREG_SINK, 1)))
- pa_log("failed to get sink '%s'", u->sink_name);
+ pa_log("Failed to get sink '%s'", u->sink_name);
else {
int i;
pa_cvolume cv = *pa_sink_get_volume(s);
@@ -165,21 +165,23 @@ fail:
#define test_bit(bit, array) (array[bit/8] & (1<<(bit%8)))
-int pa__init(pa_core *c, pa_module*m) {
+int pa__init(pa_module*m) {
+
pa_modargs *ma = NULL;
struct userdata *u;
int version;
struct _input_id input_id;
char name[256];
uint8_t evtype_bitmask[EV_MAX/8 + 1];
- assert(c && m);
+
+ pa_assert(m);
if (!(ma = pa_modargs_new(m->argument, valid_modargs))) {
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->module = m;
u->io = NULL;
u->sink_name = pa_xstrdup(pa_modargs_get_value(ma, "sink", NULL));
@@ -221,11 +223,11 @@ int pa__init(pa_core *c, pa_module*m) {
}
if (!test_bit(EV_KEY, evtype_bitmask)) {
- pa_log("device has no keys.");
+ pa_log("Device has no keys.");
goto fail;
}
- u->io = c->mainloop->io_new(c->mainloop, u->fd, PA_IO_EVENT_INPUT|PA_IO_EVENT_HANGUP, io_callback, u);
+ u->io = m->core->mainloop->io_new(m->core->mainloop, u->fd, PA_IO_EVENT_INPUT|PA_IO_EVENT_HANGUP, io_callback, u);
pa_modargs_free(ma);
@@ -236,14 +238,14 @@ fail:
if (ma)
pa_modargs_free(ma);
- pa__done(c, m);
+ pa__done(m);
return -1;
}
-void pa__done(pa_core *c, pa_module*m) {
+void pa__done(pa_module*m) {
struct userdata *u;
- assert(c);
- assert(m);
+
+ pa_assert(m);
if (!(u = m->userdata))
return;