diff options
Diffstat (limited to 'src')
-rw-r--r-- | src/Makefile.am | 4 | ||||
-rw-r--r-- | src/g_unix_signal.h | 10 | ||||
-rw-r--r-- | src/interface.c | 4 | ||||
-rw-r--r-- | src/unix_signal.c (renamed from src/g_unix_signal.c) | 50 | ||||
-rw-r--r-- | src/unix_signal.h | 14 |
5 files changed, 43 insertions, 39 deletions
diff --git a/src/Makefile.am b/src/Makefile.am index 690ed8d..6079b35 100644 --- a/src/Makefile.am +++ b/src/Makefile.am @@ -1,8 +1,8 @@ bin_PROGRAMS = pa-sink-ctl -pa_sink_ctl_SOURCES = interface.c pa-sink-ctl.c sink.c sink_input.c g_unix_signal.c +pa_sink_ctl_SOURCES = interface.c pa-sink-ctl.c sink.c sink_input.c unix_signal.c AM_CFLAGS = $(GCC_CFLAGS) AM_CPPFLAGS = $(PULSE_CFLAGS) $(PULSE_MAINLOOP_CFLAGS) $(GLIB_CFLAGS) pa_sink_ctl_LDADD = $(GLIB_LIBS) $(PULSE_LIBS) $(PULSE_MAINLOOP_LIBS) $(CURSES_LIBS) -noinst_HEADERS = interface.h pa-sink-ctl.h sink.h sink_input.h g_unix_signal.h +noinst_HEADERS = interface.h pa-sink-ctl.h sink.h sink_input.h unix_signal.h diff --git a/src/g_unix_signal.h b/src/g_unix_signal.h deleted file mode 100644 index f9d6f8b..0000000 --- a/src/g_unix_signal.h +++ /dev/null @@ -1,10 +0,0 @@ -#ifndef G_UNIX_SIGNAL_H -#define G_UNIX_SIGNAL_H - -#include <glib.h> - -GSource *g_unix_signal_source_new(gint signum); -guint g_unix_signal_add(gint signum, GSourceFunc function, gpointer data); -guint g_unix_signal_add_full(gint priority, gint signum, GSourceFunc function, gpointer data, GDestroyNotify notify); - -#endif /* G_UNIX_SIGNAL_H */ diff --git a/src/interface.c b/src/interface.c index 0513687..83bd3b0 100644 --- a/src/interface.c +++ b/src/interface.c @@ -10,7 +10,7 @@ #include "sink.h" #include "pa-sink-ctl.h" -#include "g_unix_signal.h" +#include "unix_signal.h" #define H_MSG_BOX 3 @@ -379,7 +379,7 @@ interface_init(void) interface_resize(NULL); /* register event handler for resize and input */ - resize_source_id = g_unix_signal_add(SIGWINCH, interface_resize, NULL); + resize_source_id = unix_signal_add(SIGWINCH, interface_resize, NULL); input_channel = g_io_channel_unix_new(STDIN_FILENO); if (!input_channel) exit(EXIT_FAILURE); diff --git a/src/g_unix_signal.c b/src/unix_signal.c index e91df17..7577051 100644 --- a/src/g_unix_signal.c +++ b/src/unix_signal.c @@ -1,26 +1,26 @@ #define _POSIX_SOURCE #include <signal.h> #include <glib.h> -#include "g_unix_signal.h" +#include "unix_signal.h" static GPtrArray *signal_data = NULL; -typedef struct _GUnixSignalData { +typedef struct _UnixSignalData { guint source_id; GMainContext *context; gboolean triggered; gint signum; -} GUnixSignalData; +} UnixSignalData; -typedef struct _GUnixSignalSource { +typedef struct _UnixSignalSource { GSource source; - GUnixSignalData *data; -} GUnixSignalSource; + UnixSignalData *data; +} UnixSignalSource; -static inline GUnixSignalData * -g_unix_signal_data(guint index) +static inline UnixSignalData * +unix_signal_data(guint index) { - return (GUnixSignalData *) g_ptr_array_index(signal_data, index); + return (UnixSignalData *) g_ptr_array_index(signal_data, index); } static void @@ -28,15 +28,15 @@ handler(gint signum) { g_assert(signal_data != NULL); for (guint i = 0; i < signal_data->len; ++i) - if (g_unix_signal_data(i)->signum == signum) - g_unix_signal_data(i)->triggered = TRUE; + if (unix_signal_data(i)->signum == signum) + unix_signal_data(i)->triggered = TRUE; sigaction(signum, &(struct sigaction){handler}, NULL); } static gboolean check(GSource *source) { - GUnixSignalSource *signal_source = (GUnixSignalSource *) source; + UnixSignalSource *signal_source = (UnixSignalSource *) source; return signal_source->data->triggered; } @@ -44,7 +44,7 @@ check(GSource *source) static gboolean prepare(GSource *source, gint *timeout_) { - GUnixSignalSource *signal_source = (GUnixSignalSource*) source; + UnixSignalSource *signal_source = (UnixSignalSource*) source; if (signal_source->data->context == NULL) { g_main_context_ref(signal_source->data->context = g_source_get_context(source)); @@ -59,7 +59,7 @@ prepare(GSource *source, gint *timeout_) static gboolean dispatch(GSource *source, GSourceFunc callback, gpointer user_data) { - GUnixSignalSource *signal_source = (GUnixSignalSource *) source; + UnixSignalSource *signal_source = (UnixSignalSource *) source; signal_source->data->triggered = FALSE; @@ -69,7 +69,7 @@ dispatch(GSource *source, GSourceFunc callback, gpointer user_data) static void finalize(GSource *source) { - GUnixSignalSource *signal_source = (GUnixSignalSource*) source; + UnixSignalSource *signal_source = (UnixSignalSource*) source; sigaction(signal_source->data->signum, &(struct sigaction){NULL}, NULL); g_main_context_unref(signal_source->data->context); @@ -89,11 +89,11 @@ static GSourceFuncs SourceFuncs = }; static void -g_unix_signal_source_init(GSource *source, gint signum) +unix_signal_source_init(GSource *source, gint signum) { - GUnixSignalSource *signal_source = (GUnixSignalSource *) source; + UnixSignalSource *signal_source = (UnixSignalSource *) source; - signal_source->data = g_new(GUnixSignalData, 1); + signal_source->data = g_new(UnixSignalData, 1); signal_source->data->triggered = FALSE; signal_source->data->signum = signum; signal_source->data->context = NULL; @@ -104,21 +104,21 @@ g_unix_signal_source_init(GSource *source, gint signum) } GSource * -g_unix_signal_source_new(gint signum) +unix_signal_source_new(gint signum) { - GSource *source = g_source_new(&SourceFuncs, sizeof(GUnixSignalSource)); + GSource *source = g_source_new(&SourceFuncs, sizeof(UnixSignalSource)); - g_unix_signal_source_init(source, signum); + unix_signal_source_init(source, signum); sigaction(signum, &(struct sigaction){handler}, NULL); return source; } guint -g_unix_signal_add_full(gint priority, gint signum, GSourceFunc function, gpointer data, GDestroyNotify notify) +unix_signal_add_full(gint priority, gint signum, GSourceFunc function, gpointer data, GDestroyNotify notify) { g_return_val_if_fail(function != NULL, 0); - GSource *source = g_unix_signal_source_new(signum); + GSource *source = unix_signal_source_new(signum); guint id; if (priority != G_PRIORITY_DEFAULT) @@ -130,7 +130,7 @@ g_unix_signal_add_full(gint priority, gint signum, GSourceFunc function, gpointe return id; } -guint g_unix_signal_add(gint signum, GSourceFunc function, gpointer data) +guint unix_signal_add(gint signum, GSourceFunc function, gpointer data) { - return g_unix_signal_add_full(G_PRIORITY_DEFAULT, signum, function, data, NULL); + return unix_signal_add_full(G_PRIORITY_DEFAULT, signum, function, data, NULL); } diff --git a/src/unix_signal.h b/src/unix_signal.h new file mode 100644 index 0000000..2e1aab6 --- /dev/null +++ b/src/unix_signal.h @@ -0,0 +1,14 @@ +#ifndef UNIX_SIGNAL_H +#define UNIX_SIGNAL_H + +#include <glib.h> + +GSource * +unix_signal_source_new(gint signum); +guint +unix_signal_add(gint signum, GSourceFunc function, gpointer data); +guint +unix_signal_add_full(gint priority, gint signum, GSourceFunc function, + gpointer data, GDestroyNotify notify); + +#endif /* UNIX_SIGNAL_H */ |