summaryrefslogtreecommitdiff
path: root/recipes-multimedia/gstreamer/gstreamer1.0/0006-poll-Add-check-if-can-read-event-API.patch
blob: 9a6cf47025446a9a9e1ab62a47fb065fe5041dff (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
From 6daed66db8a147783acc117b76afa2e779c8c12c Mon Sep 17 00:00:00 2001
From: Song Bing <bing.song@nxp.com>
Date: Thu, 20 Aug 2015 14:57:46 +0800
Subject: [PATCH 6/7] poll: Add check if can read event API

Need check if can read event of buffer for video decoder based on
V4L2 driver. Add the API for it.


Upstream-Status: Pending [https://bugzilla.gnome.org/show_bug.cgi?id=752962]

Signed-off-by: Song Bing bing.song@nxp.com
---
 gst/gstpoll.c | 52 ++++++++++++++++++++++++++++++++++++++++++++++++++++
 gst/gstpoll.h |  1 +
 2 files changed, 53 insertions(+)

diff --git a/gst/gstpoll.c b/gst/gstpoll.c
index fd672ed..084f6f7 100644
--- a/gst/gstpoll.c
+++ b/gst/gstpoll.c
@@ -1242,6 +1242,58 @@ gst_poll_fd_can_read (const GstPoll * set, GstPollFD * fd)
   return res;
 }
 
+static gboolean
+gst_poll_fd_can_read_pri_unlocked (const GstPoll * set, GstPollFD * fd)
+{
+  gboolean res = FALSE;
+  gint idx;
+
+  idx = find_index (set->active_fds, fd);
+  if (idx >= 0) {
+#ifndef G_OS_WIN32
+    struct pollfd *pfd = &g_array_index (set->active_fds, struct pollfd, idx);
+
+    res = (pfd->revents & POLLPRI) != 0;
+#else
+    WinsockFd *wfd = &g_array_index (set->active_fds, WinsockFd, idx);
+
+    res = (wfd->events.lNetworkEvents & FD_ACCEPT) != 0;
+#endif
+  } else {
+    GST_WARNING ("%p: couldn't find fd !", set);
+  }
+  GST_DEBUG ("%p: fd (fd:%d, idx:%d) %d", set, fd->fd, fd->idx, res);
+
+  return res;
+}
+
+/**
+ * gst_poll_fd_can_read_pri:
+ * @set: a file descriptor set.
+ * @fd: a file descriptor.
+ *
+ * Check if @fd in @set has data to be read.
+ *
+ * Returns: %TRUE if the descriptor has data to be read.
+ */
+gboolean
+gst_poll_fd_can_read_pri (const GstPoll * set, GstPollFD * fd)
+{
+  gboolean res = FALSE;
+
+  g_return_val_if_fail (set != NULL, FALSE);
+  g_return_val_if_fail (fd != NULL, FALSE);
+  g_return_val_if_fail (fd->fd >= 0, FALSE);
+
+  g_mutex_lock (&((GstPoll *) set)->lock);
+
+  res = gst_poll_fd_can_read_pri_unlocked (set, fd);
+
+  g_mutex_unlock (&((GstPoll *) set)->lock);
+
+  return res;
+}
+
 /**
  * gst_poll_fd_can_write:
  * @set: a file descriptor set.
diff --git a/gst/gstpoll.h b/gst/gstpoll.h
index ef6dcea..0513648 100644
--- a/gst/gstpoll.h
+++ b/gst/gstpoll.h
@@ -79,6 +79,7 @@ void            gst_poll_fd_ignored       (GstPoll *set, GstPollFD *fd);
 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_read_pri  (const GstPoll *set, GstPollFD *fd);
 gboolean        gst_poll_fd_can_write     (const GstPoll *set, GstPollFD *fd);
 
 gint            gst_poll_wait             (GstPoll *set, GstClockTime timeout);
-- 
1.9.1