[polypaudio-commits] r733 - in /trunk/src/polyp: mainloop.c mainloop.h
svnmailer-noreply at 0pointer.de
svnmailer-noreply at 0pointer.de
Sun Apr 16 09:46:27 PDT 2006
Author: lennart
Date: Sun Apr 16 18:46:26 2006
New Revision: 733
URL: http://0pointer.de/cgi-bin/viewcvs.cgi?rev=733&root=polypaudio&view=rev
Log:
add new API to replace the poll() function used by the main loop implementation
Modified:
trunk/src/polyp/mainloop.c
trunk/src/polyp/mainloop.h
Modified: trunk/src/polyp/mainloop.c
URL: http://0pointer.de/cgi-bin/viewcvs.cgi/trunk/src/polyp/mainloop.c?rev=733&root=polypaudio&r1=732&r2=733&view=diff
==============================================================================
--- trunk/src/polyp/mainloop.c (original)
+++ trunk/src/polyp/mainloop.c Sun Apr 16 18:46:26 2006
@@ -101,6 +101,9 @@
STATE_POLLED,
STATE_QUIT
} state;
+
+ pa_poll_func poll_func;
+ void *poll_func_userdata;
};
/* IO events */
@@ -355,6 +358,9 @@
m->deferred_pending = 0;
m->state = STATE_PASSIVE;
+
+ m->poll_func = NULL;
+ m->poll_func_userdata = NULL;
return m;
}
@@ -665,7 +671,10 @@
if (m->deferred_pending)
r = 0;
else {
- r = poll(m->pollfds, m->n_pollfds, m->prepared_timeout);
+ if (m->poll_func)
+ r = m->poll_func(m->pollfds, m->n_pollfds, m->prepared_timeout, m->poll_func_userdata);
+ else
+ r = poll(m->pollfds, m->n_pollfds, m->prepared_timeout);
if (r < 0) {
if (errno == EINTR)
@@ -767,6 +776,14 @@
return &m->api;
}
+void pa_mainloop_set_poll_func(pa_mainloop *m, pa_poll_func poll_func, void *userdata) {
+ assert(m);
+
+ m->poll_func = poll_func;
+ m->poll_func_userdata = userdata;
+}
+
+
#if 0
void pa_mainloop_dump(pa_mainloop *m) {
assert(m);
Modified: trunk/src/polyp/mainloop.h
URL: http://0pointer.de/cgi-bin/viewcvs.cgi/trunk/src/polyp/mainloop.h?rev=733&root=polypaudio&r1=732&r2=733&view=diff
==============================================================================
--- trunk/src/polyp/mainloop.h (original)
+++ trunk/src/polyp/mainloop.h Sun Apr 16 18:46:26 2006
@@ -70,6 +70,8 @@
* defined in \ref mainloop-api.h. This implementation is thread safe
* as long as you access the main loop object from a single thread only.*/
+#include <sys/poll.h>
+
/** An opaque main loop object */
typedef struct pa_mainloop pa_mainloop;
@@ -114,6 +116,12 @@
/** Interrupt a running poll (for threaded systems) */
void pa_mainloop_wakeup(pa_mainloop *m);
+/** Generic prototype of a poll() like function */
+typedef int (*pa_poll_func)(struct pollfd *ufds, nfds_t nfds, int timeout, void*userdata);
+
+/** Change the poll() implementation */
+void pa_mainloop_set_poll_func(pa_mainloop *m, pa_poll_func poll_func, void *userdata);
+
PA_C_DECL_END
#endif
More information about the pulseaudio-commits
mailing list