[vlc-commits] prefetch: simplify w/o cancellation

Rémi Denis-Courmont git at videolan.org
Sun Apr 12 10:28:53 CEST 2020


vlc | branch: master | Rémi Denis-Courmont <remi at remlab.net> | Sun Apr 12 10:26:38 2020 +0300| [7b96ceb3b9ed33a662d0e6f1027a0c73db1b18db] | committer: Rémi Denis-Courmont

prefetch: simplify w/o cancellation

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

 modules/stream_filter/prefetch.c | 20 +++++++++-----------
 1 file changed, 9 insertions(+), 11 deletions(-)

diff --git a/modules/stream_filter/prefetch.c b/modules/stream_filter/prefetch.c
index 3a28b9f770..0eca28b52e 100644
--- a/modules/stream_filter/prefetch.c
+++ b/modules/stream_filter/prefetch.c
@@ -81,7 +81,6 @@ typedef struct
 static ssize_t ThreadRead(stream_t *stream, void *buf, size_t length)
 {
     stream_sys_t *sys = stream->p_sys;
-    int canc = vlc_savecancel();
 
     vlc_mutex_unlock(&sys->lock);
     assert(length > 0);
@@ -89,14 +88,12 @@ static ssize_t ThreadRead(stream_t *stream, void *buf, size_t length)
     ssize_t val = vlc_stream_ReadPartial(stream->s, buf, length);
 
     vlc_mutex_lock(&sys->lock);
-    vlc_restorecancel(canc);
     return val;
 }
 
 static int ThreadSeek(stream_t *stream, uint64_t seek_offset)
 {
     stream_sys_t *sys = stream->p_sys;
-    int canc = vlc_savecancel();
 
     vlc_mutex_unlock(&sys->lock);
 
@@ -105,7 +102,6 @@ static int ThreadSeek(stream_t *stream, uint64_t seek_offset)
         msg_Err(stream, "cannot seek (to offset %"PRIu64")", seek_offset);
 
     vlc_mutex_lock(&sys->lock);
-    vlc_restorecancel(canc);
 
     return (val == VLC_SUCCESS) ? 0 : -1;
 }
@@ -113,7 +109,6 @@ static int ThreadSeek(stream_t *stream, uint64_t seek_offset)
 static int ThreadControl(stream_t *stream, int query, ...)
 {
     stream_sys_t *sys = stream->p_sys;
-    int canc = vlc_savecancel();
 
     vlc_mutex_unlock(&sys->lock);
 
@@ -125,7 +120,6 @@ static int ThreadControl(stream_t *stream, int query, ...)
     va_end(ap);
 
     vlc_mutex_lock(&sys->lock);
-    vlc_restorecancel(canc);
     return ret;
 }
 
@@ -138,8 +132,7 @@ static void *Thread(void *data)
     vlc_interrupt_set(sys->interrupt);
 
     vlc_mutex_lock(&sys->lock);
-    mutex_cleanup_push(&sys->lock);
-    for (;;)
+    while (!vlc_killed())
     {
         struct stream_ctrl *ctrl = sys->controls;
 
@@ -266,8 +259,10 @@ static void *Thread(void *data)
         //        sys->buffer_size);
         vlc_cond_signal(&sys->wait_data);
     }
-    vlc_assert_unreachable();
-    vlc_cleanup_pop();
+
+    sys->error = true;
+    vlc_cond_signal(&sys->wait_data);
+    vlc_mutex_unlock(&sys->lock);
     return NULL;
 }
 
@@ -520,8 +515,11 @@ static void Close (vlc_object_t *obj)
     stream_t *stream = (stream_t *)obj;
     stream_sys_t *sys = stream->p_sys;
 
-    vlc_cancel(sys->thread);
+    vlc_mutex_lock(&sys->lock);
     vlc_interrupt_kill(sys->interrupt);
+    vlc_cond_signal(&sys->wait_space);
+    vlc_mutex_unlock(&sys->lock);
+
     vlc_join(sys->thread, NULL);
     vlc_interrupt_destroy(sys->interrupt);
 



More information about the vlc-commits mailing list