[vlc-devel] [PATCH 41/48] hls: Reworking seeking.

Hugo Beauzée-Luyssen beauze.h at gmail.com
Mon Jan 9 16:16:50 CET 2012


Segment download is already handled in GetSegment.
This fixes a deadlock and removes some useless code.
---
 modules/stream_filter/httplive.c |   40 +------------------------------------
 1 files changed, 2 insertions(+), 38 deletions(-)

diff --git a/modules/stream_filter/httplive.c b/modules/stream_filter/httplive.c
index b8bc4c9..894ebd4 100644
--- a/modules/stream_filter/httplive.c
+++ b/modules/stream_filter/httplive.c
@@ -120,7 +120,6 @@ struct stream_sys_t
     {
         int         stream;     /* current hls_stream  */
         int         segment;    /* current segment for downloading */
-        int         seek;       /* segment requested by seek (default -1) */
         vlc_mutex_t lock_wait;  /* protect segment download counter */
         vlc_cond_t  wait;       /* some condition to wait on */
     } download;
@@ -1934,7 +1933,6 @@ static int OpenWithPlaylist(stream_t *s, const char *m3u8_playlist)
     p_sys->download.stream = current;
     p_sys->playback.stream = current;
     p_sys->playback.time = 0;
-    p_sys->download.seek = -1;
 
     vlc_mutex_init(&p_sys->download.lock_wait);
     vlc_cond_init(&p_sys->download.wait);
@@ -2476,49 +2474,15 @@ static int segment_Seek(stream_t *s, const uint64_t pos)
 
         /* Wake up download thread */
         vlc_mutex_lock(&p_sys->download.lock_wait);
-        int seek_to_segment = p_sys->download.seek = p_sys->playback.segment;
+        p_sys->download.segment = p_sys->playback.segment;
         vlc_cond_signal(&p_sys->download.wait);
         vlc_mutex_unlock(&p_sys->download.lock_wait);
 
-        /* Wait for download to be finished */
-
-        vlc_mutex_lock(&p_sys->download.lock_wait);
-        msg_Info(s, "seek to segment %d", p_sys->playback.segment);
-        while (((p_sys->download.seek != -1) ||
-                (p_sys->download.segment - p_sys->playback.segment < 3)) &&
-                (p_sys->download.segment < (count - 6)))
-        {
-            int i;
-            /* Download like Prefetch(), 3 segments in advance */
-            for (i = 0; i < 3; i++)
-            {
-                segment_t *segment = segment_GetSegment(hls, seek_to_segment + i);
-                if (segment == NULL)
-                    goto end;
-                vlc_mutex_lock(&segment->lock);
-                if (segment->data == NULL)
-                {
-                    /* The data is not ready, break, to sleep a little */
-                    vlc_mutex_unlock(&segment->lock);
-                    break;
-                }
-                vlc_mutex_unlock(&segment->lock);
-            }
-            if (i == 3)
-                goto end;
-
-            vlc_cond_wait(&p_sys->download.wait, &p_sys->download.lock_wait);
-            if (!vlc_object_alive(s) || s->b_error || p_sys->b_quit)
-                break;
-        }
-end:
-        vlc_mutex_unlock(&p_sys->download.lock_wait);
-
         return VLC_SUCCESS;
     }
     vlc_mutex_unlock(&hls->lock);
 
-    return b_found ? VLC_SUCCESS : VLC_EGENERIC;
+    return VLC_EGENERIC;
 }
 
 static int Control(stream_t *s, int i_query, va_list args)
-- 
1.7.8.3




More information about the vlc-devel mailing list