summary | shortlog | log | commit | commitdiff | tree
raw | patch | inline | side by side (parent: 7136e43)
raw | patch | inline | side by side (parent: 7136e43)
author | Max Kellermann <max.kellermann@gmail.com> | |
Sun, 19 Mar 2017 09:50:09 +0000 (10:50 +0100) | ||
committer | Max Kellermann <max.kellermann@gmail.com> | |
Sun, 19 Mar 2017 09:50:09 +0000 (10:50 +0100) |
src/lirc.c | patch | blob | history | |
src/lirc.h | patch | blob | history | |
src/main.c | patch | blob | history |
diff --git a/src/lirc.c b/src/lirc.c
index 86447408276a9f68be6f3145d3f6dfc3912a3ad3..58b2cd7b0138afaf0f7d606d06730b3504394a33 100644 (file)
--- a/src/lirc.c
+++ b/src/lirc.c
#include <lirc/lirc_client.h>
-static struct lirc_config *lc = NULL;
-
-int ncmpc_lirc_open()
-{
- char prog[] = "ncmpc";
- int lirc_socket = 0;
-
- if ((lirc_socket = lirc_init(prog, 0)) == -1)
- return -1;
-
- if (lirc_readconfig(NULL, &lc, NULL)) {
- lirc_deinit();
- return -1;
- }
-
- return lirc_socket;
-}
+#include <glib.h>
-void ncmpc_lirc_close()
-{
- if (lc)
- lirc_freeconfig(lc);
- lirc_deinit();
-}
+static struct lirc_config *lc = NULL;
-gboolean
+static gboolean
lirc_event(gcc_unused GIOChannel *source,
gcc_unused GIOCondition condition, gcc_unused gpointer data)
{
end_input_event();
return TRUE;
}
+
+void
+ncmpc_lirc_open()
+{
+ char prog[] = "ncmpc";
+ int lirc_socket = 0;
+
+ if ((lirc_socket = lirc_init(prog, 0)) == -1)
+ return;
+
+ if (lirc_readconfig(NULL, &lc, NULL)) {
+ lirc_deinit();
+ return;
+ }
+
+ GIOChannel *channel = g_io_channel_unix_new(lirc_socket);
+ g_io_add_watch(channel, G_IO_IN, lirc_event, NULL);
+ g_io_channel_unref(channel);
+}
+
+void ncmpc_lirc_close()
+{
+ if (lc)
+ lirc_freeconfig(lc);
+ lirc_deinit();
+}
diff --git a/src/lirc.h b/src/lirc.h
index 0c7955c0d8078eae5de516b137b75c422e7a152f..1d7650b559c4cd0518d717926f531d01125607e9 100644 (file)
--- a/src/lirc.h
+++ b/src/lirc.h
#ifndef LIRC_H
#define LIRC_H
-#include "command.h"
-#include <glib.h>
-
-int ncmpc_lirc_open(void);
+void
+ncmpc_lirc_open(void);
void ncmpc_lirc_close(void);
-gboolean
-lirc_event(GIOChannel *source, GIOCondition condition, gpointer data);
-
#endif
diff --git a/src/main.c b/src/main.c
index c20dd6d2a127134908764096ff42028f5cdcf725..fd6cd7be5ae9363f443beb0a031a24c1761029d5 100644 (file)
--- a/src/main.c
+++ b/src/main.c
#ifdef ENABLE_LIRC
/* watch out for lirc input */
- int lirc_socket = ncmpc_lirc_open();
- if (lirc_socket >= 0) {
- GIOChannel *lirc_channel = g_io_channel_unix_new(lirc_socket);
- g_io_add_watch(lirc_channel, G_IO_IN, lirc_event, NULL);
- g_io_channel_unref(lirc_channel);
- }
+ ncmpc_lirc_open();
#endif
#ifndef WIN32