dvb_dev_get_fd(): return fd of local devices
PATCH 1/1 dvb_dev_get_fd(): return fd of local devices
This makes it possible to poll a local device.
Getting the fd is preferrable to adding a dvb_dev_poll() function, because we can poll several fds together in an event-based program.
This is not implemented for remote devices, as polling a remote fd does not make sense.
We could instead return the socket to know when to expect messages from the remote device, but the current implementation in dvb-dev-remote.c already runs a thread to receive remote messages as soon as possible.
---
Note, after reading README, I did not bump the library version.
Comments welcome
lib/include/libdvbv5/dvb-dev.h | 12 ++++++++++++ lib/libdvbv5/dvb-dev-local.c | 6 ++++++ lib/libdvbv5/dvb-dev-priv.h | 1 + lib/libdvbv5/dvb-dev.c | 11 +++++++++++ 4 files changed, 30 insertions(+)
lib/include/libdvbv5/dvb-dev.h +12 -0
@@ -289,6 +289,18 @@ struct dvb_open_descriptor *dvb_dev_open(struct dvb_device *dvb,*/ void dvb_dev_close (struct dvb_open_descriptor *open_dev); +/** +* @brief returns fd from a local device +* This will not work for remote devices. +* @ingroup dvb_device +* +* @param open_dev Points to the struct dvb_open_descriptor +* +* @return On success, returns the fd. +* Returns -1 on error. +*/ +int dvb_dev_get_fd (struct dvb_open_descriptor *open_dev); +/** * @brief read from a dvb demux or dvr file * @ingroup dvb_device
lib/libdvbv5/dvb-dev-local.c +6 -0
@@ -775,6 +775,11 @@ static void dvb_dev_local_free(struct dvb_device_priv *dvb)free (priv); } +static int dvb_local_get_fd (struct dvb_open_descriptor *open_dev) +{ +return open_dev->fd; +} +/* Initialize for local usage */ void dvb_dev_local_init (struct dvb_device_priv *dvb) {
@@ -788,6 +793,7 @@ void dvb_dev_local_init(struct dvb_device_priv *dvb) ops->stop_monitor = dvb_local_stop_monitor; ops->open = dvb_local_open; ops->close = dvb_local_close; + ops->get_fd = dvb_local_get_fd; ops->dmx_stop = dvb_local_dmx_stop; ops->set_bufsize = dvb_local_set_bufsize;
lib/libdvbv5/dvb-dev-priv.h +1 -0
@@ -72,6 +72,7 @@ struct dvb_dev_ops {int (*fe_get_stats)(struct dvb_v5_fe_parms *p);void (*free)(struct dvb_device_priv *dvb); +int (*get_fd)(struct dvb_open_descriptor *dvb); };struct dvb_device_priv {
lib/libdvbv5/dvb-dev.c +11 -0
@@ -218,6 +218,17 @@ struct dvb_open_descriptor *dvb_dev_open(struct dvb_device *d,return ops->open (dvb, sysname, flags); } +int dvb_dev_get_fd (struct dvb_open_descriptor *open_dev) +{ +struct dvb_device_priv *dvb = (void *)open_dev; +struct dvb_dev_ops *ops = &dvb->ops; + +if (!ops->get_fd) +return -1 ; + +return ops->get_fd (open_dev); +} +void dvb_dev_close (struct dvb_open_descriptor *open_dev) {struct dvb_device_priv *dvb = open_dev->dvb;
Signature · 1 line
2.14.1
PATCH v2 1/1 dvb_dev_get_fd(): return fd of local devices
This makes it possible to poll a local device.
Getting the fd is preferrable to adding a dvb_dev_poll() function, because we can poll several fds together in an event-based program.
This is not implemented for remote devices, as polling a remote fd does not make sense.
We could instead return the socket to know when to expect messages from the remote device, but the current implementation in dvb-dev-remote.c already runs a thread to receive remote messages as soon as possible.
---
v2: get the private dvb_device_priv correctly
lib/include/libdvbv5/dvb-dev.h | 12 ++++++++++++ lib/libdvbv5/dvb-dev-local.c | 6 ++++++ lib/libdvbv5/dvb-dev-priv.h | 1 + lib/libdvbv5/dvb-dev.c | 11 +++++++++++ 4 files changed, 30 insertions(+)
lib/include/libdvbv5/dvb-dev.h +12 -0
@@ -289,6 +289,18 @@ struct dvb_open_descriptor *dvb_dev_open(struct dvb_device *dvb,*/ void dvb_dev_close (struct dvb_open_descriptor *open_dev); +/** +* @brief returns fd from a local device +* This will not work for remote devices. +* @ingroup dvb_device +* +* @param open_dev Points to the struct dvb_open_descriptor +* +* @return On success, returns the fd. +* Returns -1 on error. +*/ +int dvb_dev_get_fd (struct dvb_open_descriptor *open_dev); +/** * @brief read from a dvb demux or dvr file * @ingroup dvb_device
lib/libdvbv5/dvb-dev-local.c +6 -0
@@ -775,6 +775,11 @@ static void dvb_dev_local_free(struct dvb_device_priv *dvb)free (priv); } +static int dvb_local_get_fd (struct dvb_open_descriptor *open_dev) +{ +return open_dev->fd; +} +/* Initialize for local usage */ void dvb_dev_local_init (struct dvb_device_priv *dvb) {
@@ -788,6 +793,7 @@ void dvb_dev_local_init(struct dvb_device_priv *dvb) ops->stop_monitor = dvb_local_stop_monitor; ops->open = dvb_local_open; ops->close = dvb_local_close; + ops->get_fd = dvb_local_get_fd; ops->dmx_stop = dvb_local_dmx_stop; ops->set_bufsize = dvb_local_set_bufsize;
lib/libdvbv5/dvb-dev-priv.h +1 -0
@@ -72,6 +72,7 @@ struct dvb_dev_ops {int (*fe_get_stats)(struct dvb_v5_fe_parms *p);void (*free)(struct dvb_device_priv *dvb); +int (*get_fd)(struct dvb_open_descriptor *dvb); };struct dvb_device_priv {
lib/libdvbv5/dvb-dev.c +11 -0
@@ -218,6 +218,17 @@ struct dvb_open_descriptor *dvb_dev_open(struct dvb_device *d,return ops->open (dvb, sysname, flags); } +int dvb_dev_get_fd (struct dvb_open_descriptor *open_dev) +{ +struct dvb_device_priv *dvb = open_dev->dvb; +struct dvb_dev_ops *ops = &dvb->ops; + +if (!ops->get_fd) +return -1 ; + +return ops->get_fd (open_dev); +} +void dvb_dev_close (struct dvb_open_descriptor *open_dev) {struct dvb_device_priv *dvb = open_dev->dvb;
Signature · 1 line
2.14.1
Em Wed, 15 Nov 2017 11:47:11 +0100
Rafaël Carré <[email protected]> escreveu:
Quoted 10 lines
This makes it possible to poll a local device.
Getting the fd is preferrable to adding advb_dev_poll()function, because we can poll several fds together in an event-based program.This is not implemented for remote devices, as polling a remote fd does not make sense.
We could instead return the socket to know when to expect messages from the remote device, but the current implementation indvb-dev-remote.calready runs a thread to receive remote messages as soon as possible.
Patch looks OK.
Just a SOB (signed-off-by) is missing.
Quoted 83 lines
---
Note, after reading README, I did not bump the library version.
Comments welcome
lib/include/libdvbv5/dvb-dev.h | 12 ++++++++++++ lib/libdvbv5/dvb-dev-local.c | 6 ++++++ lib/libdvbv5/dvb-dev-priv.h | 1 + lib/libdvbv5/dvb-dev.c | 11 +++++++++++ 4 files changed, 30 insertions(+)lib/include/libdvbv5/dvb-dev.h +12
-0@@ -289,6 +289,18 @@ struct dvb_open_descriptor *dvb_dev_open(struct dvb_device *dvb,*/ void dvb_dev_close (struct dvb_open_descriptor *open_dev); +/** +* @brief returns fd from a local device +* This will not work for remote devices. +* @ingroup dvb_device +* +* @param open_dev Points to the struct dvb_open_descriptor +* +* @return On success, returns the fd. +* Returns -1 on error. +*/ +int dvb_dev_get_fd (struct dvb_open_descriptor *open_dev); +/** * @brief read from a dvb demux or dvr file * @ingroup dvb_device lib/libdvbv5/dvb-dev-local.c +6
-0@@ -775,6 +775,11 @@ static void dvb_dev_local_free(struct dvb_device_priv *dvb)free (priv); } +static int dvb_local_get_fd (struct dvb_open_descriptor *open_dev) +{ +return open_dev->fd; +} +/* Initialize for local usage */ void dvb_dev_local_init (struct dvb_device_priv *dvb) {@@ -788,6 +793,7 @@ void dvb_dev_local_init(struct dvb_device_priv *dvb) ops->stop_monitor = dvb_local_stop_monitor; ops->open = dvb_local_open; ops->close = dvb_local_close; + ops->get_fd = dvb_local_get_fd; ops->dmx_stop = dvb_local_dmx_stop; ops->set_bufsize = dvb_local_set_bufsize;lib/libdvbv5/dvb-dev-priv.h +1
-0@@ -72,6 +72,7 @@ struct dvb_dev_ops {int (*fe_get_stats)(struct dvb_v5_fe_parms *p);void (*free)(struct dvb_device_priv *dvb); +int (*get_fd)(struct dvb_open_descriptor *dvb); };struct dvb_device_priv {lib/libdvbv5/dvb-dev.c +4
-0@@ -218,6 +218,17 @@ struct dvb_open_descriptor *dvb_dev_open(struct dvb_device *d,return ops->open (dvb, sysname, flags); } +int dvb_dev_get_fd (struct dvb_open_descriptor *open_dev) +{ +struct dvb_device_priv *dvb = (void *)open_dev; +struct dvb_dev_ops *ops = &dvb->ops;
lib/libdvbv5/dvb-dev.c struct dvb_open_descriptor *dvb_dev_open(struct dvb_device *d, · line 234
Quoted 10 lines
lib/libdvbv5/dvb-dev.c +7
-0+ +if (!ops->get_fd) +return -1 ; + +return ops->get_fd (open_dev); +} +void dvb_dev_close (struct dvb_open_descriptor *open_dev) {struct dvb_device_priv *dvb = open_dev->dvb;
Thanks,
Mauro
Em Wed, 15 Nov 2017 15:25:39 +0100
Rafaël Carré <[email protected]> escreveu:
Quoted 10 lines
This makes it possible to poll a local device.
Getting the fd is preferrable to adding advb_dev_poll()function, because we can poll several fds together in an event-based program.This is not implemented for remote devices, as polling a remote fd does not make sense.
We could instead return the socket to know when to expect messages from the remote device, but the current implementation indvb-dev-remote.calready runs a thread to receive remote messages as soon as possible.
SOB?
Quoted 80 lines
---
v2: get the privatedvb_device_privcorrectlylib/include/libdvbv5/dvb-dev.h | 12 ++++++++++++ lib/libdvbv5/dvb-dev-local.c | 6 ++++++ lib/libdvbv5/dvb-dev-priv.h | 1 + lib/libdvbv5/dvb-dev.c | 11 +++++++++++ 4 files changed, 30 insertions(+)lib/include/libdvbv5/dvb-dev.h +12
-0@@ -289,6 +289,18 @@ struct dvb_open_descriptor *dvb_dev_open(struct dvb_device *dvb,*/ void dvb_dev_close (struct dvb_open_descriptor *open_dev); +/** +* @brief returns fd from a local device +* This will not work for remote devices. +* @ingroup dvb_device +* +* @param open_dev Points to the struct dvb_open_descriptor +* +* @return On success, returns the fd. +* Returns -1 on error. +*/ +int dvb_dev_get_fd (struct dvb_open_descriptor *open_dev); +/** * @brief read from a dvb demux or dvr file * @ingroup dvb_device lib/libdvbv5/dvb-dev-local.c +6
-0@@ -775,6 +775,11 @@ static void dvb_dev_local_free(struct dvb_device_priv *dvb)free (priv); } +static int dvb_local_get_fd (struct dvb_open_descriptor *open_dev) +{ +return open_dev->fd; +} +/* Initialize for local usage */ void dvb_dev_local_init (struct dvb_device_priv *dvb) {@@ -788,6 +793,7 @@ void dvb_dev_local_init(struct dvb_device_priv *dvb) ops->stop_monitor = dvb_local_stop_monitor; ops->open = dvb_local_open; ops->close = dvb_local_close; + ops->get_fd = dvb_local_get_fd; ops->dmx_stop = dvb_local_dmx_stop; ops->set_bufsize = dvb_local_set_bufsize;lib/libdvbv5/dvb-dev-priv.h +1
-0@@ -72,6 +72,7 @@ struct dvb_dev_ops {int (*fe_get_stats)(struct dvb_v5_fe_parms *p);void (*free)(struct dvb_device_priv *dvb); +int (*get_fd)(struct dvb_open_descriptor *dvb); };struct dvb_device_priv {lib/libdvbv5/dvb-dev.c +4
-0@@ -218,6 +218,17 @@ struct dvb_open_descriptor *dvb_dev_open(struct dvb_device *d,return ops->open (dvb, sysname, flags); } +int dvb_dev_get_fd (struct dvb_open_descriptor *open_dev) +{ +struct dvb_device_priv *dvb = open_dev->dvb; +struct dvb_dev_ops *ops = &dvb->ops;
lib/libdvbv5/dvb-dev.c struct dvb_open_descriptor *dvb_dev_open(struct dvb_device *d, · line 234
Quoted 10 lines
lib/libdvbv5/dvb-dev.c +7
-0+ +if (!ops->get_fd) +return -1 ; + +return ops->get_fd (open_dev); +} +void dvb_dev_close (struct dvb_open_descriptor *open_dev) {struct dvb_device_priv *dvb = open_dev->dvb;
Thanks,
Mauro
Quoted 91 lines · Rafaël Carré
This makes it possible to poll a local device.
Getting the fd is preferrable to adding advb_dev_poll()function, because we can poll several fds together in an event-based program.This is not implemented for remote devices, as polling a remote fd does not make sense.
We could instead return the socket to know when to expect messages from the remote device, but the current implementation indvb-dev-remote.calready runs a thread to receive remote messages as soon as possible.
---
v2: get the privatedvb_device_privcorrectlylib/include/libdvbv5/dvb-dev.h | 12 ++++++++++++ lib/libdvbv5/dvb-dev-local.c | 6 ++++++ lib/libdvbv5/dvb-dev-priv.h | 1 + lib/libdvbv5/dvb-dev.c | 11 +++++++++++ 4 files changed, 30 insertions(+)lib/include/libdvbv5/dvb-dev.h +12
-0@@ -289,6 +289,18 @@ struct dvb_open_descriptor *dvb_dev_open(struct dvb_device *dvb,*/ void dvb_dev_close (struct dvb_open_descriptor *open_dev); +/** +* @brief returns fd from a local device +* This will not work for remote devices. +* @ingroup dvb_device +* +* @param open_dev Points to the struct dvb_open_descriptor +* +* @return On success, returns the fd. +* Returns -1 on error. +*/ +int dvb_dev_get_fd (struct dvb_open_descriptor *open_dev); +/** * @brief read from a dvb demux or dvr file * @ingroup dvb_device lib/libdvbv5/dvb-dev-local.c +6
-0@@ -775,6 +775,11 @@ static void dvb_dev_local_free(struct dvb_device_priv *dvb)free (priv); } +static int dvb_local_get_fd (struct dvb_open_descriptor *open_dev) +{ +return open_dev->fd; +} +/* Initialize for local usage */ void dvb_dev_local_init (struct dvb_device_priv *dvb) {@@ -788,6 +793,7 @@ void dvb_dev_local_init(struct dvb_device_priv *dvb) ops->stop_monitor = dvb_local_stop_monitor; ops->open = dvb_local_open; ops->close = dvb_local_close; + ops->get_fd = dvb_local_get_fd; ops->dmx_stop = dvb_local_dmx_stop; ops->set_bufsize = dvb_local_set_bufsize;lib/libdvbv5/dvb-dev-priv.h +1
-0@@ -72,6 +72,7 @@ struct dvb_dev_ops {int (*fe_get_stats)(struct dvb_v5_fe_parms *p);void (*free)(struct dvb_device_priv *dvb); +int (*get_fd)(struct dvb_open_descriptor *dvb); };struct dvb_device_priv {lib/libdvbv5/dvb-dev.c +4
-0@@ -218,6 +218,17 @@ struct dvb_open_descriptor *dvb_dev_open(struct dvb_device *d,return ops->open (dvb, sysname, flags); } +int dvb_dev_get_fd (struct dvb_open_descriptor *open_dev) +{ +struct dvb_device_priv *dvb = open_dev->dvb; +struct dvb_dev_ops *ops = &dvb->ops;
lib/libdvbv5/dvb-dev.c struct dvb_open_descriptor *dvb_dev_open(struct dvb_device *d, · line 234
Quoted 10 lines
lib/libdvbv5/dvb-dev.c +7
-0+ +if (!ops->get_fd) +return -1 ; + +return ops->get_fd (open_dev); +} +void dvb_dev_close (struct dvb_open_descriptor *open_dev) {struct dvb_device_priv *dvb = open_dev->dvb;