Web lists-archives.com

[MPlayer-dev-eng] [PATCH 4/5] stream_pvr: fix bogus error message on device poll timeout




The message being logged is invalid when poll returns 0.

Signed-off-by: Reza Arbab <arbab@xxxxxxxxx>
---
 stream/stream_pvr.c | 12 ++++++++----
 1 file changed, 8 insertions(+), 4 deletions(-)

diff --git a/stream/stream_pvr.c b/stream/stream_pvr.c
index e709e69..13c2f43 100644
--- a/stream/stream_pvr.c
+++ b/stream/stream_pvr.c
@@ -1633,9 +1633,13 @@ 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) <= 0)
+    rk = poll (pfds, 1, 500);
+    if (!rk) {
+      mp_msg (MSGT_OPEN, MSGL_ERR,
+              "%s 500ms timeout polling stream device\n", LOG_LEVEL_PVR);
+      break;
+    }
+    else if (rk < 0)
     {
       mp_msg (MSGT_OPEN, MSGL_ERR,
               "%s failed with errno %d when reading %d bytes\n",
@@ -1643,7 +1647,7 @@ pvr_stream_read (stream_t *stream, char *buffer, int size)
       break;
     }
 
-    rk = read (fd, &buffer[pos], rk);
+    rk = read (fd, &buffer[pos], size-pos);
     if (rk > 0)
     {
       pos += rk;
-- 
2.5.0

_______________________________________________
MPlayer-dev-eng mailing list
MPlayer-dev-eng@xxxxxxxxxxxx
https://lists.mplayerhq.hu/mailman/listinfo/mplayer-dev-eng