[vlc-devel] [PATCH 3/3] chromecast: add an experimental sout module that connects to a ChromeCast device and streams using the HTTP access output

Rémi Denis-Courmont remi at remlab.net
Fri Sep 12 09:24:25 CEST 2014


Le 2014-09-12 06:29, Hugo Beauzee-Luyssen a écrit :
>>> +    // Lock the sout thread until we have sent the media loading 
>>> command to the Chromecast.
>>> +    vlc_mutex_lock(&p_sys->loadCommandMutex);
>
> I'd suggest you use the vlc_mutex_locker RAII helper.
> Same goes for all mutex locks.

No, that would actually be _wrong_ here. The mutex would be released 
after msleep().

>
>>> +    const mtime_t deadline = mdate() + 6 * CLOCK_FREQ;
>>> +    int i_ret = vlc_cond_timedwait(&p_sys->loadCommandCond, 
>>> &p_sys->loadCommandMutex, deadline);
>>> +    if (i_ret == ETIMEDOUT)
>>> +    {
>>> +        msg_Err(p_stream, "Timeout reached before sending the 
>>> media loading command");
>>> +        vlc_mutex_unlock(&p_sys->loadCommandMutex);
>>> +        vlc_cancel(p_sys->chromecastThread);
>>> +        vlc_join(p_sys->chromecastThread, NULL);
>>> +        clean(p_sys);
>>> +        return VLC_EGENERIC;
>>> +    }
>>> +    vlc_mutex_unlock(&p_sys->loadCommandMutex);
>>> +
>>> +    /* Even uglier: sleep more to let to the Chromecast initiate 
>>> the connection
>>> +     * to the http server. */
>>> +    msleep(2 * CLOCK_FREQ);

-- 
Rémi Denis-Courmont



More information about the vlc-devel mailing list