[vlc-devel] [PATCH] playlist: prevent playing an invalid playlist indefinitely

Zhao Zhili wantlamy at gmail.com
Thu Feb 25 05:19:23 CET 2016


Thank you for your review, I did some tests for the two cases.

Firstly, I created a 67 milliseconds TS file. It cost about 250 ms in a
loop.

vlc --loop out.ts 2>&1 |grep "playlist error"
[0000000001fcb3b8] core playlist error: --- 7269653 ms
[0000000001fcb3b8] core playlist error: --- 263 ms
[0000000001fcb3b8] core playlist error: --- 246 ms
[0000000001fcb3b8] core playlist error: --- 247 ms
[0000000001fcb3b8] core playlist error: --- 278 ms
[0000000001fcb3b8] core playlist error: --- 263 ms

I think it is reasonable to assume that even for a shorter beep sound (mid
format) it will cost more than 100 ms in a loop.

On the other hand, it cost less than 10 ms to pass an invalid item, about
5ms on average (of couse this depends on how fast the computer is). So for
one thunsand of items it cost about 5 seconds. If you put a lot items in a
playlist, you should afford that. Wait a few seconds is better than freeze
the UI for a very long time and have to force close the window.

So is it acceptable for
+            if( mdate() - i_time < 50000 ) // 50 ms
or another reasonable value?

On Thu, Feb 25, 2016 at 4:02 AM, Rémi Denis-Courmont <remi at remlab.net>
wrote:

> Le 2016-02-24 07:16, Zhao Zhili a écrit :
>
>> ---
>>  src/playlist/thread.c | 14 ++++++++++++++
>>  1 file changed, 14 insertions(+)
>>
>> diff --git a/src/playlist/thread.c b/src/playlist/thread.c
>> index a348479..21bb090 100644
>> --- a/src/playlist/thread.c
>> +++ b/src/playlist/thread.c
>> @@ -498,6 +498,8 @@ static void *Thread ( void *data )
>>              continue;
>>          }
>>
>> +        int count = 0;
>> +        mtime_t i_time = 0;
>>          while( !p_sys->killed && Next( p_playlist ) )
>>          {   /* Playlist in running state */
>>              assert(p_sys->p_input != NULL);
>> @@ -505,6 +507,18 @@ static void *Thread ( void *data )
>>              do
>>                  LoopInput( p_playlist );
>>              while( p_sys->p_input != NULL );
>> +
>> +            /* prevent playing an invalid playlist
>> indefinitely */
>> +            if( mdate() - i_time < 500000 )
>> +            {
>> +                count++;
>> +                if( count > p_playlist->current.i_size
>> )
>> +                    break;
>> +            }
>>
>
> On the one hand, there could be just one valid item of a few hundred
> milliseconds in the playlist (e.g. alarm sound). On the other hand, there
> could be thousands of items in the playlist all invalid.
>
> This patch breaks the first use case, and fails to fix the second one.
>
>
> +            else
>> +                count = 0;
>> +
>> +            i_time = mdate();
>>          }
>>
>>          msg_Dbg( p_playlist, "nothing to play" );
>>
>
> --
> Rémi Denis-Courmont
> http://www.remlab.net/
> _______________________________________________
> vlc-devel mailing list
> To unsubscribe or modify your subscription options:
> https://mailman.videolan.org/listinfo/vlc-devel
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mailman.videolan.org/pipermail/vlc-devel/attachments/20160225/00034ed6/attachment.html>


More information about the vlc-devel mailing list