[MPlayer-dev-eng] [PATCH 5/5] stream_pvr: allow initial latency when opening stream
Reza Arbab
arbab at panix.com
Tue Feb 2 18:21:37 CET 2016
When opening an hdpvr device, there may be a significant delay before
first receiving data, especially at higher bitrates. This can cause
mplayer to assume EOF and exit.
Move the existing device polling code to a static function. Introduce
a new caller with generous 5 second timeout in pvr_stream_open.
Signed-off-by: Reza Arbab <arbab at panix.com>
---
stream/stream_pvr.c | 35 ++++++++++++++++++++++++++---------
1 file changed, 26 insertions(+), 9 deletions(-)
diff --git a/stream/stream_pvr.c b/stream/stream_pvr.c
index 13c2f43..b35ba43 100644
--- a/stream/stream_pvr.c
+++ b/stream/stream_pvr.c
@@ -1597,6 +1597,26 @@ v4l2_display_settings (struct pvr_t *pvr)
return 0;
}
+static int
+poll_device (struct pvr_t *pvr, int timeout)
+{
+ struct pollfd pfds[1];
+ int ret;
+
+ pfds[0].fd = pvr->dev_fd;
+ pfds[0].events = POLLIN | POLLPRI;
+
+ ret = poll (pfds, 1, timeout);
+ if (!ret)
+ {
+ mp_msg (MSGT_OPEN, MSGL_WARN,
+ "%s %dms timeout polling stream device\n",
+ LOG_LEVEL_PVR, timeout);
+ }
+
+ return ret;
+}
+
/* stream layer */
static void
@@ -1614,7 +1634,6 @@ pvr_stream_close (stream_t *stream)
static int
pvr_stream_read (stream_t *stream, char *buffer, int size)
{
- struct pollfd pfds[1];
struct pvr_t *pvr;
int rk, fd, pos;
@@ -1630,15 +1649,9 @@ pvr_stream_read (stream_t *stream, char *buffer, int size)
while (pos < size)
{
- pfds[0].fd = fd;
- pfds[0].events = POLLIN | POLLPRI;
-
- rk = poll (pfds, 1, 500);
- if (!rk) {
- mp_msg (MSGT_OPEN, MSGL_ERR,
- "%s 500ms timeout polling stream device\n", LOG_LEVEL_PVR);
+ rk = poll_device (pvr, 500);
+ if (!rk)
break;
- }
else if (rk < 0)
{
mp_msg (MSGT_OPEN, MSGL_ERR,
@@ -1762,6 +1775,10 @@ pvr_stream_open (stream_t *stream, int mode, void *opts, int *file_format)
goto err_out;
}
+ /* wait for device to begin streaming */
+ if (!poll_device (pvr, 5000))
+ goto err_out;
+
stream->priv = pvr;
stream->type = STREAMTYPE_PVR;
stream->fill_buffer = pvr_stream_read;
--
2.5.0
More information about the MPlayer-dev-eng
mailing list