Commit 431e5dfa authored by Rémi Denis-Courmont's avatar Rémi Denis-Courmont

RTP: fail when object is killed

parent 627acb55
...@@ -42,21 +42,20 @@ ...@@ -42,21 +42,20 @@
* @param fd datagram file descriptor * @param fd datagram file descriptor
* @return a block or NULL on fatal error (socket dead) * @return a block or NULL on fatal error (socket dead)
*/ */
static block_t *rtp_dgram_recv (int fd) static block_t *rtp_dgram_recv (vlc_object_t *obj, int fd)
{ {
block_t *block = block_Alloc (0xffff); block_t *block = block_Alloc (0xffff);
ssize_t len; ssize_t len;
do do
{ {
struct pollfd ufd = { .fd = fd, .events = POLLIN, };
block_cleanup_push (block); block_cleanup_push (block);
poll (&ufd, 1, -1); len = net_Read (obj, fd, NULL,
len = recv (fd, block->p_buffer, block->i_buffer, 0); block->p_buffer, block->i_buffer, false);
vlc_cleanup_pop (); vlc_cleanup_pop ();
if ((len <= 0) && (ufd.revents & POLLHUP)) if (((len <= 0) && poll (&(struct pollfd){ .fd = fd, }, 1, 0))
|| !vlc_object_alive (obj))
{ /* POLLHUP -> permanent (DCCP) socket error */ { /* POLLHUP -> permanent (DCCP) socket error */
block_Release (block); block_Release (block);
return NULL; return NULL;
...@@ -73,19 +72,15 @@ static block_t *rtp_dgram_recv (int fd) ...@@ -73,19 +72,15 @@ static block_t *rtp_dgram_recv (int fd)
* @param fd stream file descriptor * @param fd stream file descriptor
* @return a block or NULL in case of fatal error * @return a block or NULL in case of fatal error
*/ */
static block_t *rtp_stream_recv (int fd) static block_t *rtp_stream_recv (vlc_object_t *obj, int fd)
{ {
ssize_t len = 0; ssize_t len = 0;
struct pollfd ufd = { .fd = fd, .events = POLLIN, };
uint8_t hdr[2]; /* frame header */ uint8_t hdr[2]; /* frame header */
/* Receives the RTP frame header */ /* Receives the RTP frame header */
do do
{ {
ssize_t val; ssize_t val = net_Read (obj, fd, NULL, hdr + len, 2 - len, false);
poll (&ufd, 1, -1);
val = recv (fd, hdr + len, 2 - len, 0);
if (val <= 0) if (val <= 0)
return NULL; return NULL;
len += val; len += val;
...@@ -100,8 +95,8 @@ static block_t *rtp_stream_recv (int fd) ...@@ -100,8 +95,8 @@ static block_t *rtp_stream_recv (int fd)
ssize_t val; ssize_t val;
block_cleanup_push (block); block_cleanup_push (block);
poll (&ufd, 1, -1); val = net_Read (obj, fd, NULL,
val = recv (fd, block->p_buffer + i, block->i_buffer - i, 0); block->p_buffer + i, block->i_buffer - i, false);
vlc_cleanup_pop (); vlc_cleanup_pop ();
if (val <= 0) if (val <= 0)
...@@ -123,8 +118,8 @@ static block_t *rtp_recv (demux_t *demux) ...@@ -123,8 +118,8 @@ static block_t *rtp_recv (demux_t *demux)
for (block_t *block;; block_Release (block)) for (block_t *block;; block_Release (block))
{ {
block = p_sys->framed_rtp block = p_sys->framed_rtp
? rtp_stream_recv (p_sys->fd) ? rtp_stream_recv (VLC_OBJECT (demux), p_sys->fd)
: rtp_dgram_recv (p_sys->fd); : rtp_dgram_recv (VLC_OBJECT (demux), p_sys->fd);
if (block == NULL) if (block == NULL)
{ {
msg_Err (demux, "RTP flow stopped"); msg_Err (demux, "RTP flow stopped");
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment