[vlc-devel] [PATCH 1/2] demux: adaptive: avoid using a bool telling if the thread is not created

Steve Lhomme robux4 at ycbcr.xyz
Tue Feb 11 13:16:37 CET 2020


On 2020-02-11 13:09, Rémi Denis-Courmont wrote:
> Hi,
> 
> You could change vlc_thread_t to a pointer type on all platforms.
> 
> You could even make vlc_join(NULL, ...) a no-op to simplify error paths.
> 
> But this requires changing some of the platform code first.

That sounds like a lot of changes for not much benefit.

> Le 11 février 2020 11:01:05 GMT+02:00, Steve Lhomme <robux4 at ycbcr.xyz> a 
> écrit :
> 
>     We already have a variable to store it.
>     ------------------------------------------------------------------------
>       modules/demux/adaptive/PlaylistManager.cpp | 18 ++++++++++--------
>       modules/demux/adaptive/PlaylistManager.h   |  1 -
>       2 files changed, 10 insertions(+), 9 deletions(-)
> 
>     diff --git a/modules/demux/adaptive/PlaylistManager.cpp b/modules/demux/adaptive/PlaylistManager.cpp
>     index a8bce7aca19..62c697e1432 100644
>     --- a/modules/demux/adaptive/PlaylistManager.cpp
>     +++ b/modules/demux/adaptive/PlaylistManager.cpp
>     @@ -62,7 +62,7 @@ PlaylistManager::PlaylistManager( demux_t *p_demux_,
>           currentPeriod = playlist->getFirstPeriod();
>           resources = res;
>           failedupdates = 0;
>     -    b_thread = false;
>     +    thread = nullptr;
>           b_buffering = false;
>           b_canceled = false;
>           nextPlaylistupdate = 0;
>     @@ -159,13 +159,15 @@ bool PlaylistManager::init()
>       
>       bool PlaylistManager::start()
>       {
>     -    if(b_thread)
>     +    if (thread != nullptr)
>               return false;
>       
>     -    b_thread = !vlc_clone(&thread, managerThread,
>     -                          static_cast<void *>(this), VLC_THREAD_PRIORITY_INPUT);
>     -    if(!b_thread)
>     +    if (!vlc_clone(&thread, managerThread,
>     +                   static_cast<void *>(this), VLC_THREAD_PRIORITY_INPUT))
>     +    {
>     +        thread = nullptr;
>               return false;
>     +    }
>       
>           setBufferingRunState(true);
>       
>     @@ -174,12 +176,12 @@ bool PlaylistManager::start()
>       
>       bool PlaylistManager::started() const
>       {
>     -    return b_thread;
>     +    return thread != nullptr;
>       }
>       
>       void PlaylistManager::stop()
>       {
>     -    if(b_thread)
>     +    if(thread != nullptr)
>           {
>               vlc_mutex_lock(&lock);
>               b_canceled = true;
>     @@ -187,7 +189,7 @@ void PlaylistManager::stop()
>               vlc_mutex_unlock(&lock);
>       
>               vlc_join(thread, NULL);
>     -        b_thread = false;
>     +        thread = nullptr;
>           }
>       }
>       
>     diff --git a/modules/demux/adaptive/PlaylistManager.h b/modules/demux/adaptive/PlaylistManager.h
>     index 55ceacde7c9..501200f9b7a 100644
>     --- a/modules/demux/adaptive/PlaylistManager.h
>     +++ b/modules/demux/adaptive/PlaylistManager.h
>     @@ -132,7 +132,6 @@ namespace adaptive
>                   static void * managerThread(void *);
>                   vlc_mutex_t  lock;
>                   vlc_thread_t thread;
>     -            bool         b_thread;
>                   vlc_cond_t   waitcond;
>                   bool         b_buffering;
>                   bool         b_canceled;
> 
> 
> -- 
> Envoyé de mon appareil Android avec Courriel K-9 Mail. Veuillez excuser 
> ma brièveté.
> 
> _______________________________________________
> vlc-devel mailing list
> To unsubscribe or modify your subscription options:
> https://mailman.videolan.org/listinfo/vlc-devel
> 


More information about the vlc-devel mailing list