[vlc-devel] [PATCH v4 1/3] access: srt: introduce srt input module

Justin Kim justin.kim at collabora.com
Fri Aug 25 09:23:12 CEST 2017


On 24/08/2017 5:26 AM, Rémi Denis-Courmont wrote:
> Le keskiviikkona 16. elokuuta 2017, 5.10.17 EEST Justin Kim a écrit :
>> +static block_t *BlockSRT(stream_t *p_stream, bool *restrict eof)
>> +{
>> +    stream_sys_t *p_sys = p_stream->p_sys;
>> +
>> +    block_t *pkt = block_Alloc( p_sys->i_chunk_size );
>> +
>> +    if (unlikely(pkt == NULL))
>> +    {
>> +        return NULL;
>> +    }
>> +
>> +    SRTSOCKET ready[2];
>> +    if ( srt_epoll_wait( p_sys->i_poll_id, 0, 0, ready, &(int) { 2 }, -1,
>> 0, 0, 0, 0 ) == -1 )
>> +    {
>> +        msg_Err( p_stream, "%s", srt_getlasterror_str() );
>> +        goto skip;
>> +    }
>> +
>> +    int stat = srt_recvmsg( p_sys->sock, (char *)pkt->p_buffer,
>> p_sys->i_chunk_size ); +
>> +    if ( stat == SRT_ERROR )
>> +    {
>> +        msg_Err( p_stream, "%s", srt_getlasterror_str() );
>> +        goto skip;
>> +    }
> 
> What happens if no packets are received? poll waits forever? What happens if
> the user tries to stop the stream then?

Thanks for good catching. 'srt_epoll_wait' can be cancelled only by 
'srt_close' when it waits infinitely. So I added a routine to give a 
chance to return by timeout. Please review my 5th patches.

> 
>> +
>> +    pkt->i_buffer = stat;
>> +    return pkt;
>> +
>> +skip:
>> +   *eof = true;
>> +    block_Release(pkt);
>> +    return NULL;
>> +}
> 


More information about the vlc-devel mailing list