[vlc-devel] [PATCH] MMS stream pausing

Rémi Denis-Courmont rdenis at simphalempin.com
Sun Jun 15 09:34:11 CEST 2008


Le vendredi 13 juin 2008 21:46:02 bl4, vous avez écrit :
> Rémi Denis-Courmont wrote:
> > Le vendredi 13 juin 2008 02:23:00 bl4, vous avez écrit :
> >> +    while (!p_thread->b_die) {
> >> +        if (p_thread->b_paused) {
> >> +            if (!p_thread->last_ping_time) {
> >> +                p_thread->last_ping_time = time(NULL);
> >> +            } else if (time(NULL) > p_thread->last_ping_time + 10) {
> >> +                mms_CommandSend( p_access, 0x1b, 0, 0, NULL, 0 );
> >> +                p_thread->last_ping_time = time(NULL);
> >
> > Looks suspiciously lock-free?
>
> What exactly should be locked here?

Anything that is accessed by multiple threads need to be synched. Apparently, 
that's the case for b_paused and definitely for b_die.

If last_ping_time is only used within this function, it would be clearer to 
put it on the stack, though not mandatory.

> I'm not very familiar with threads, 
> it looks to me that b_paused is the only thing shared between threads
> and no race condition occurs. Maybe it's possible that b_paused is read
> and written at the same time, should access to b_paused be locked then?

> I looked at other modules which use threads but I can't figure it out.

IIRC, the screensaver plugin has an example how to do this sort of things.

-- 
Rémi Denis-Courmont
http://www.remlab.net/



More information about the vlc-devel mailing list