[vlc-commits] demux/adaptive: Downloader::Run: simplify

Filip Roséen git at videolan.org
Thu May 18 21:09:02 CEST 2017


vlc | branch: master | Filip Roséen <filip at atch.se> | Thu May 18 17:07:32 2017 +0200| [c3932688c7b131e709ab29d3bdbec3ae963462d9] | committer: Jean-Baptiste Kempf

demux/adaptive: Downloader::Run: simplify

There is absolutely no need to lock and unlock the mutex on every
iteration, especially given that one cannot observe this behavior (as
there is nothing at all that guarantees that something can aquire the
lock inbetween those two calls).

There is also no need to check if we are killed twice, once is
sufficient

Signed-off-by: Jean-Baptiste Kempf <jb at videolan.org>

> http://git.videolan.org/gitweb.cgi/vlc.git/?a=commit;h=c3932688c7b131e709ab29d3bdbec3ae963462d9
---

 modules/demux/adaptive/http/Downloader.cpp | 9 +--------
 1 file changed, 1 insertion(+), 8 deletions(-)

diff --git a/modules/demux/adaptive/http/Downloader.cpp b/modules/demux/adaptive/http/Downloader.cpp
index 8d0d20c765..3d7e7c2e2f 100644
--- a/modules/demux/adaptive/http/Downloader.cpp
+++ b/modules/demux/adaptive/http/Downloader.cpp
@@ -89,16 +89,11 @@ void Downloader::DownloadSource(HTTPChunkBufferedSource *source)
 
 void Downloader::Run()
 {
+    vlc_mutex_lock(&lock);
     while(1)
     {
-        vlc_mutex_lock(&lock);
-        if(killed)
-            break;
-
         while(chunks.empty() && !killed)
-        {
             vlc_cond_wait(&waitcond, &lock);
-        }
 
         if(killed)
             break;
@@ -110,8 +105,6 @@ void Downloader::Run()
             if(source->isDone())
                 chunks.pop_front();
         }
-
-        vlc_mutex_unlock(&lock);
     }
     vlc_mutex_unlock(&lock);
 }



More information about the vlc-commits mailing list