[MPlayer-dev-eng] [PATCH v2 4/5] stream_pvr: fix bogus error message on device poll timeout
Reza Arbab
arbab at panix.com
Wed Feb 10 17:19:51 CET 2016
The error check for the call to poll() should actually be for the
subsequent read(). Move it there.
Add a different check for poll(), to correctly report timeout.
Signed-off-by: Reza Arbab <arbab at panix.com>
---
v2:
* Fix error checking on read() in addition to poll().
stream/stream_pvr.c | 23 ++++++++++++++---------
1 file changed, 14 insertions(+), 9 deletions(-)
diff --git a/stream/stream_pvr.c b/stream/stream_pvr.c
index cbf4f17..4657210 100644
--- a/stream/stream_pvr.c
+++ b/stream/stream_pvr.c
@@ -1629,9 +1629,15 @@ pvr_stream_read (stream_t *stream, char *buffer, int size)
pfds[0].fd = fd;
pfds[0].events = POLLIN | POLLPRI;
- rk = size - pos;
+ if (!poll (pfds, 1, 500))
+ {
+ mp_msg (MSGT_OPEN, MSGL_ERR,
+ "%s 500ms timeout polling stream device\n", LOG_LEVEL_PVR);
+ return -1;
+ }
- if (poll (pfds, 1, 500) <= 0)
+ rk = read (fd, &buffer[pos], size-pos);
+ if (rk < 0)
{
mp_msg (MSGT_OPEN, MSGL_ERR,
"%s failed with errno %d when reading %d bytes\n",
@@ -1639,13 +1645,12 @@ pvr_stream_read (stream_t *stream, char *buffer, int size)
break;
}
- rk = read (fd, &buffer[pos], rk);
- if (rk > 0)
- {
- pos += rk;
- mp_msg (MSGT_OPEN, MSGL_DBG3,
- "%s read (%d) bytes\n", LOG_LEVEL_PVR, pos);
- }
+ if (!rk)
+ break;
+
+ pos += rk;
+ mp_msg (MSGT_OPEN, MSGL_DBG3,
+ "%s read (%d) bytes\n", LOG_LEVEL_PVR, pos);
}
if (!pos)
--
2.5.0
More information about the MPlayer-dev-eng
mailing list