[vlc-commits] cache: add common shortcut for cache_block and cache_read

Rémi Denis-Courmont git at videolan.org
Sat Mar 31 17:02:23 CEST 2018


vlc | branch: master | Rémi Denis-Courmont <remi at remlab.net> | Sat Mar 31 16:19:45 2018 +0300| [4b3c0f4984be63c55fd1423cedec69e5a581925e] | committer: Rémi Denis-Courmont

cache: add common shortcut for cache_block and cache_read

So either of them can be enabled regardless of the underyling stream
type.

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

 modules/stream_filter/cache_block.c | 4 ++++
 modules/stream_filter/cache_read.c  | 4 ++++
 2 files changed, 8 insertions(+)

diff --git a/modules/stream_filter/cache_block.c b/modules/stream_filter/cache_block.c
index ef2b0e4d4d..e5b29a0055 100644
--- a/modules/stream_filter/cache_block.c
+++ b/modules/stream_filter/cache_block.c
@@ -255,6 +255,9 @@ static int Open(vlc_object_t *obj)
 {
     stream_t *s = (stream_t *)obj;
 
+    if (s->s->pf_block == NULL)
+        return VLC_EGENERIC;
+
     stream_sys_t *sys = malloc(sizeof (*sys));
     if (unlikely(sys == NULL))
         return VLC_ENOMEM;
@@ -297,6 +300,7 @@ vlc_module_begin()
     set_category(CAT_INPUT)
     set_subcategory(SUBCAT_INPUT_STREAM_FILTER)
     set_capability("stream_filter", 0)
+    add_shortcut("cache")
 
     set_description(N_("Block stream cache"))
     set_callbacks(Open, Close)
diff --git a/modules/stream_filter/cache_read.c b/modules/stream_filter/cache_read.c
index 2cf9cb9003..4025120c8b 100644
--- a/modules/stream_filter/cache_read.c
+++ b/modules/stream_filter/cache_read.c
@@ -491,6 +491,9 @@ static int Open(vlc_object_t *obj)
 {
     stream_t *s = (stream_t *)obj;
 
+    if (s->s->pf_read == NULL)
+        return VLC_EGENERIC;
+
     stream_sys_t *sys = malloc(sizeof (*sys));
     if (unlikely(sys == NULL))
         return VLC_ENOMEM;
@@ -564,6 +567,7 @@ vlc_module_begin()
     set_category(CAT_INPUT)
     set_subcategory(SUBCAT_INPUT_STREAM_FILTER)
     set_capability("stream_filter", 0)
+    add_shortcut("cache")
 
     set_description(N_("Byte stream cache"))
     set_callbacks(Open, Close)



More information about the vlc-commits mailing list