summaryrefslogtreecommitdiff
path: root/gst/gstpoll.h
diff options
context:
space:
mode:
authorWim Taymans <wim.taymans@gmail.com>2008-02-27 18:00:04 +0000
committerWim Taymans <wim.taymans@gmail.com>2008-02-27 18:00:04 +0000
commitd37ee60f479bc5f7e6ddf2506110ea807c689ef2 (patch)
tree6fac469d567b792ff9b072c6caa85cfd963c65af /gst/gstpoll.h
parentef4fb687a97965a518ad17cd83405dd28f088d27 (diff)
configure.ac: Add checks for poll, ppoll and pselect.
Original commit message from CVS: * configure.ac: Add checks for poll, ppoll and pselect. * docs/gst/gstreamer-docs.sgml: * docs/gst/gstreamer-sections.txt: Add docs for GstPoll. * gst/Makefile.am: * gst/gst.h: * gst/gstpoll.c: (find_index), (selectable_fds), (pollable_timeout), (choose_mode), (pollfd_to_fd_set), (fd_set_to_pollfd), (gst_poll_new), (gst_poll_free), (gst_poll_set_mode), (gst_poll_get_mode), (gst_poll_add_fd_unlocked), (gst_poll_add_fd), (gst_poll_remove_fd), (gst_poll_fd_ctl_write), (gst_poll_fd_ctl_read_unlocked), (gst_poll_fd_ctl_read), (gst_poll_fd_has_closed), (gst_poll_fd_has_error), (gst_poll_fd_can_read_unlocked), (gst_poll_fd_can_read), (gst_poll_fd_can_write), (gst_poll_wait), (gst_poll_set_controllable), (gst_poll_restart), (gst_poll_set_flushing): * gst/gstpoll.h: Add generic poll abstraction. We ideally don't want to have this in core here but in glib intead... This code will be used in various network elements and ultimately for the nanosecond precision monotonic clock (that's why it's here in core). It'll allow us to implement cancelable socket operations for windows too. * tests/check/Makefile.am: * tests/check/gst/gstpoll.c: (test_poll_wait), (GST_START_TEST), (delayed_stop), (delayed_restart), (delayed_flush), (delayed_control), (gst_poll_suite): Add GstPoll unit test.
Diffstat (limited to 'gst/gstpoll.h')
-rw-r--r--gst/gstpoll.h97
1 files changed, 97 insertions, 0 deletions
diff --git a/gst/gstpoll.h b/gst/gstpoll.h
new file mode 100644
index 000000000..2325181e3
--- /dev/null
+++ b/gst/gstpoll.h
@@ -0,0 +1,97 @@
+/* GStreamer
+ * Copyright (C) 1999 Erik Walthinsen <omega@cse.ogi.edu>
+ * Copyright (C) 2004 Wim Taymans <wim.taymans@gmail.com>
+ * Copyright (C) 2007 Peter Kjellerstedt <pkj@axis.com>
+ *
+ * gstpoll.h: File descriptor set
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Library General Public
+ * License as published by the Free Software Foundation; either
+ * version 2 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Library General Public License for more details.
+ *
+ * You should have received a copy of the GNU Library General Public
+ * License along with this library; if not, write to the
+ * Free Software Foundation, Inc., 59 Temple Place - Suite 330,
+ * Boston, MA 02111-1307, USA.
+ */
+
+#ifndef __GST_POLL_H__
+#define __GST_POLL_H__
+
+#include <glib.h>
+#include <glib-object.h>
+
+#include <gst/gstclock.h>
+
+G_BEGIN_DECLS
+
+/**
+ * GstPoll:
+ *
+ * A set of file descriptors.
+ */
+typedef struct _GstPoll GstPoll;
+
+/**
+ * GstPollFD:
+ * @fd: a file descriptor
+ *
+ * A file descriptor object.
+ */
+typedef struct {
+ int fd;
+
+ /*< private >*/
+ gint idx;
+} GstPollFD;
+
+/**
+ * GstPollMode:
+ * @GST_POLL_MODE_AUTO: choose method automatically
+ * @GST_POLL_MODE_SELECT: use select() when waiting
+ * @GST_POLL_MODE_PSELECT: use pselect() when waiting
+ * @GST_POLL_MODE_POLL: use poll() when waiting
+ * @GST_POLL_MODE_PPOLL: use ppoll() when waiting
+ *
+ * Which method to use when waiting for a set of file descriptors.
+ */
+typedef enum {
+ GST_POLL_MODE_AUTO,
+ GST_POLL_MODE_SELECT,
+ GST_POLL_MODE_PSELECT,
+ GST_POLL_MODE_POLL,
+ GST_POLL_MODE_PPOLL
+} GstPollMode;
+
+GstPoll* gst_poll_new (GstPollMode mode, gboolean controllable);
+void gst_poll_free (GstPoll *set);
+
+void gst_poll_set_mode (GstPoll *set, GstPollMode mode);
+GstPollMode gst_poll_get_mode (const GstPoll *set);
+
+gboolean gst_poll_add_fd (GstPoll *set, GstPollFD *fd);
+gboolean gst_poll_remove_fd (GstPoll *set, GstPollFD *fd);
+
+gboolean gst_poll_fd_ctl_write (GstPoll *set, GstPollFD *fd, gboolean active);
+gboolean gst_poll_fd_ctl_read (GstPoll *set, GstPollFD *fd, gboolean active);
+
+gboolean gst_poll_fd_has_closed (const GstPoll *set, GstPollFD *fd);
+gboolean gst_poll_fd_has_error (const GstPoll *set, GstPollFD *fd);
+gboolean gst_poll_fd_can_read (const GstPoll *set, GstPollFD *fd);
+gboolean gst_poll_fd_can_write (const GstPoll *set, GstPollFD *fd);
+
+gint gst_poll_wait (GstPoll *set, GstClockTime timeout);
+
+gboolean gst_poll_set_controllable (GstPoll *set, gboolean controllable);
+void gst_poll_restart (GstPoll *set);
+void gst_poll_set_flushing (GstPoll *set, gboolean flushing);
+
+G_END_DECLS
+
+#endif /* __GST_POLL_H__ */