[pulseaudio-commits] r2377 - in /branches/glitch-free/src/pulse: mainloop-signal.c mainloop-signal.h
svnmailer-noreply at 0pointer.de
svnmailer-noreply at 0pointer.de
Tue May 6 18:34:55 PDT 2008
Author: lennart
Date: Wed May 7 03:34:54 2008
New Revision: 2377
URL: http://0pointer.de/cgi-bin/viewcvs.cgi?rev=2377&root=pulseaudio&view=rev
Log:
define callback function types; allow pa_signal_done() to be called even without prior pa_signal_init()
Modified:
branches/glitch-free/src/pulse/mainloop-signal.c
branches/glitch-free/src/pulse/mainloop-signal.h
Modified: branches/glitch-free/src/pulse/mainloop-signal.c
URL: http://0pointer.de/cgi-bin/viewcvs.cgi/branches/glitch-free/src/pulse/mainloop-signal.c?rev=2377&root=pulseaudio&r1=2376&r2=2377&view=diff
==============================================================================
--- branches/glitch-free/src/pulse/mainloop-signal.c (original)
+++ branches/glitch-free/src/pulse/mainloop-signal.c Wed May 7 03:34:54 2008
@@ -3,7 +3,7 @@
/***
This file is part of PulseAudio.
- Copyright 2004-2006 Lennart Poettering
+ Copyright 2004-2008 Lennart Poettering
Copyright 2006 Pierre Ossman <ossman at cendio.se> for Cendio AB
PulseAudio is free software; you can redistribute it and/or modify
@@ -55,9 +55,9 @@
#else
void (*saved_handler)(int sig);
#endif
- void (*callback) (pa_mainloop_api*a, pa_signal_event *e, int sig, void *userdata);
void *userdata;
- void (*destroy_callback) (pa_mainloop_api*a, pa_signal_event*e, void *userdata);
+ pa_signal_cb_t callback;
+ pa_signal_destroy_cb_t destroy_callback;
pa_signal_event *previous, *next;
};
@@ -74,6 +74,7 @@
#ifndef HAVE_SIGACTION
signal(sig, signal_handler);
#endif
+
pa_write(signal_pipe[1], &sig, sizeof(sig), NULL);
errno = saved_errno;
@@ -142,23 +143,21 @@
}
void pa_signal_done(void) {
- pa_assert(api);
- pa_assert(signal_pipe[0] >= 0);
- pa_assert(signal_pipe[1] >= 0);
- pa_assert(io_event);
-
while (signals)
pa_signal_free(signals);
- api->io_free(io_event);
- io_event = NULL;
+ if (io_event) {
+ pa_assert(api);
+ api->io_free(io_event);
+ io_event = NULL;
+ }
pa_close_pipe(signal_pipe);
api = NULL;
}
-pa_signal_event* pa_signal_new(int sig, void (*_callback) (pa_mainloop_api *api, pa_signal_event*e, int sig, void *userdata), void *userdata) {
+pa_signal_event* pa_signal_new(int sig, pa_signal_cb_t _callback, void *userdata) {
pa_signal_event *e = NULL;
#ifdef HAVE_SIGACTION
@@ -223,7 +222,7 @@
pa_xfree(e);
}
-void pa_signal_set_destroy(pa_signal_event *e, void (*_callback) (pa_mainloop_api *api, pa_signal_event*e, void *userdata)) {
+void pa_signal_set_destroy(pa_signal_event *e, pa_signal_destroy_cb_t _callback) {
pa_assert(e);
e->destroy_callback = _callback;
Modified: branches/glitch-free/src/pulse/mainloop-signal.h
URL: http://0pointer.de/cgi-bin/viewcvs.cgi/branches/glitch-free/src/pulse/mainloop-signal.h?rev=2377&root=pulseaudio&r1=2376&r2=2377&view=diff
==============================================================================
--- branches/glitch-free/src/pulse/mainloop-signal.h (original)
+++ branches/glitch-free/src/pulse/mainloop-signal.h Wed May 7 03:34:54 2008
@@ -6,7 +6,7 @@
/***
This file is part of PulseAudio.
- Copyright 2004-2006 Lennart Poettering
+ Copyright 2004-2008 Lennart Poettering
Copyright 2006 Pierre Ossman <ossman at cendio.se> for Cendio AB
PulseAudio is free software; you can redistribute it and/or modify
@@ -39,23 +39,27 @@
* signals. However, you may hook signal support into an abstract main loop via the routines defined herein.
*/
+/** An opaque UNIX signal event source object */
+typedef struct pa_signal_event pa_signal_event;
+
+typedef void (*pa_signal_cb_t) (pa_mainloop_api *api, pa_signal_event*e, int sig, void *userdata);
+
+typedef void (*pa_signal_destroy_cb_t) (pa_mainloop_api *api, pa_signal_event*e, void *userdata);
+
/** Initialize the UNIX signal subsystem and bind it to the specified main loop */
int pa_signal_init(pa_mainloop_api *api);
/** Cleanup the signal subsystem */
void pa_signal_done(void);
-/** An opaque UNIX signal event source object */
-typedef struct pa_signal_event pa_signal_event;
-
/** Create a new UNIX signal event source object */
-pa_signal_event* pa_signal_new(int sig, void (*callback) (pa_mainloop_api *api, pa_signal_event*e, int sig, void *userdata), void *userdata);
+pa_signal_event* pa_signal_new(int sig, pa_signal_cb_t callback, void *userdata);
/** Free a UNIX signal event source object */
void pa_signal_free(pa_signal_event *e);
/** Set a function that is called when the signal event source is destroyed. Use this to free the userdata argument if required */
-void pa_signal_set_destroy(pa_signal_event *e, void (*callback) (pa_mainloop_api *api, pa_signal_event*e, void *userdata));
+void pa_signal_set_destroy(pa_signal_event *e, pa_signal_destroy_cb_t callback);
PA_C_DECL_END
More information about the pulseaudio-commits
mailing list