[vlc-commits] dtv: add timeout parameter to dvb_read()
Rémi Denis-Courmont
git at videolan.org
Tue Apr 12 19:33:05 CEST 2016
vlc | branch: master | Rémi Denis-Courmont <remi at remlab.net> | Tue Apr 12 18:38:00 2016 +0300| [3e49c97bd1e536e148d93d892af4c2d37c9e2686] | committer: Rémi Denis-Courmont
dtv: add timeout parameter to dvb_read()
> http://git.videolan.org/gitweb.cgi/vlc.git/?a=commit;h=3e49c97bd1e536e148d93d892af4c2d37c9e2686
---
modules/access/dtv/access.c | 2 +-
modules/access/dtv/bdagraph.cpp | 15 +++++++++------
modules/access/dtv/bdagraph.hpp | 4 ++--
modules/access/dtv/dtv.h | 2 +-
modules/access/dtv/linux.c | 7 +++++--
5 files changed, 18 insertions(+), 12 deletions(-)
diff --git a/modules/access/dtv/access.c b/modules/access/dtv/access.c
index a370536..1d9cc51 100644
--- a/modules/access/dtv/access.c
+++ b/modules/access/dtv/access.c
@@ -509,7 +509,7 @@ static block_t *Read (access_t *access)
return NULL;
access_sys_t *sys = access->p_sys;
- ssize_t val = dvb_read (sys->dev, block->p_buffer, BUFSIZE);
+ ssize_t val = dvb_read (sys->dev, block->p_buffer, BUFSIZE, -1);
if (val <= 0)
{
diff --git a/modules/access/dtv/bdagraph.cpp b/modules/access/dtv/bdagraph.cpp
index 5284ac5..4d31213 100644
--- a/modules/access/dtv/bdagraph.cpp
+++ b/modules/access/dtv/bdagraph.cpp
@@ -153,9 +153,9 @@ void dvb_close (dvb_device_t *d)
delete d;
}
-ssize_t dvb_read (dvb_device_t *d, void *buf, size_t len)
+ssize_t dvb_read (dvb_device_t *d, void *buf, size_t len, int ms)
{
- return d->module->Pop(buf, len);
+ return d->module->Pop(buf, len, ms);
}
int dvb_add_pid (dvb_device_t *, uint16_t)
@@ -309,11 +309,14 @@ void BDAOutput::Push( block_t *p_block )
vlc_cond_signal( &wait );
}
-ssize_t BDAOutput::Pop(void *buf, size_t len)
+ssize_t BDAOutput::Pop(void *buf, size_t len, int ms)
{
+ if( ms < 0 )
+ ms = 250;
+
vlc_mutex_locker l( &lock );
- mtime_t i_deadline = mdate() + 250 * 1000;
+ mtime_t i_deadline = mdate() + ms * 1000;
while( !p_first )
{
if( vlc_cond_timedwait( &wait, &lock, i_deadline ) )
@@ -3015,9 +3018,9 @@ HRESULT BDAGraph::Start()
/*****************************************************************************
* Pop the stream of data
*****************************************************************************/
-ssize_t BDAGraph::Pop(void *buf, size_t len)
+ssize_t BDAGraph::Pop(void *buf, size_t len, int ms)
{
- return output.Pop(buf, len);
+ return output.Pop(buf, len, ms);
}
/******************************************************************************
diff --git a/modules/access/dtv/bdagraph.hpp b/modules/access/dtv/bdagraph.hpp
index 1b8969b..ccd02c5 100644
--- a/modules/access/dtv/bdagraph.hpp
+++ b/modules/access/dtv/bdagraph.hpp
@@ -70,7 +70,7 @@ public:
~BDAOutput();
void Push( block_t * );
- ssize_t Pop(void *, size_t);
+ ssize_t Pop(void *, size_t, int);
void Empty();
private:
@@ -103,7 +103,7 @@ public:
int SetDVBS(long, long, uint32_t, int, char, long, long, long);
/* */
- ssize_t Pop(void *, size_t);
+ ssize_t Pop(void *, size_t, int);
private:
/* ISampleGrabberCB methods */
diff --git a/modules/access/dtv/dtv.h b/modules/access/dtv/dtv.h
index b940bf1..d4f7f23 100644
--- a/modules/access/dtv/dtv.h
+++ b/modules/access/dtv/dtv.h
@@ -46,7 +46,7 @@ typedef struct dvb_device dvb_device_t;
dvb_device_t *dvb_open (vlc_object_t *obj);
void dvb_close (dvb_device_t *);
-ssize_t dvb_read (dvb_device_t *, void *, size_t);
+ssize_t dvb_read (dvb_device_t *, void *, size_t, int);
int dvb_add_pid (dvb_device_t *, uint16_t);
void dvb_remove_pid (dvb_device_t *, uint16_t);
diff --git a/modules/access/dtv/linux.c b/modules/access/dtv/linux.c
index db139c8..bf3e84c 100644
--- a/modules/access/dtv/linux.c
+++ b/modules/access/dtv/linux.c
@@ -323,7 +323,7 @@ static void dvb_frontend_status(vlc_object_t *obj, fe_status_t s)
* Reads TS data from the tuner.
* @return number of bytes read, 0 on EOF, -1 if no data (yet).
*/
-ssize_t dvb_read (dvb_device_t *d, void *buf, size_t len)
+ssize_t dvb_read (dvb_device_t *d, void *buf, size_t len, int ms)
{
struct pollfd ufd[2];
int n;
@@ -344,7 +344,10 @@ ssize_t dvb_read (dvb_device_t *d, void *buf, size_t len)
else
n = 1;
- if (vlc_poll_i11e (ufd, n, -1) < 0)
+ n = vlc_poll_i11e (ufd, n, ms);
+ if (n == 0)
+ errno = EAGAIN;
+ if (n <= 0)
return -1;
if (d->frontend != -1 && ufd[1].revents)
More information about the vlc-commits
mailing list