[vlc-commits] access: bluray: refactor fake es_out

Francois Cartegnie git at videolan.org
Tue Oct 30 18:12:21 CET 2018


vlc/vlc-3.0 | branch: master | Francois Cartegnie <fcvlcdev at free.fr> | Tue May  8 15:24:17 2018 +0200| [5a0b134d91793b0fea37d1ab965e2e23c5f72714] | committer: Francois Cartegnie

access: bluray: refactor fake es_out

(cherry picked from commit 8853abc0267232b052575cfb6ad4850da864655b)

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

 modules/access/bluray.c | 60 ++++++++++++++++++++++++++++++++-----------------
 1 file changed, 40 insertions(+), 20 deletions(-)

diff --git a/modules/access/bluray.c b/modules/access/bluray.c
index 8b6ecbd140..69eab57696 100644
--- a/modules/access/bluray.c
+++ b/modules/access/bluray.c
@@ -264,7 +264,7 @@ static const char *DemuxGetLanguageCode( demux_t *p_demux, const char *psz_var )
 /*****************************************************************************
  * Local prototypes
  *****************************************************************************/
-static es_out_t *esOutNew(demux_t *p_demux);
+static es_out_t *esOutNew(vlc_object_t*, es_out_t *, void *);
 
 static int   blurayControl(demux_t *, int, va_list);
 static int   blurayDemux(demux_t *);
@@ -837,7 +837,7 @@ static int blurayOpen(vlc_object_t *object)
     }
 
     vlc_array_init(&p_sys->es);
-    p_sys->p_out = esOutNew(p_demux);
+    p_sys->p_out = esOutNew(VLC_OBJECT(p_demux), p_demux->out, p_demux);
     if (unlikely(p_sys->p_out == NULL))
         goto error;
 
@@ -920,8 +920,11 @@ static void blurayClose(vlc_object_t *object)
  * Elementary streams handling
  *****************************************************************************/
 
-struct es_out_sys_t {
-    demux_t *p_demux;
+struct es_out_sys_t
+{
+    es_out_t *p_dst_out;
+    vlc_object_t *p_obj;
+    void *priv;
 };
 
 typedef struct  fmt_es_pair {
@@ -1000,7 +1003,8 @@ static int blurayEsPid(demux_sys_t *p_sys, int es_type, int i_es_idx)
 
 static es_out_id_t *esOutAdd(es_out_t *p_out, const es_format_t *p_fmt)
 {
-    demux_t *p_demux = p_out->p_sys->p_demux;
+    es_out_sys_t *es_out_sys = p_out->p_sys;
+    demux_t *p_demux = es_out_sys->priv;
     demux_sys_t *p_sys = p_demux->p_sys;
     es_format_t fmt;
     bool b_select = false;
@@ -1028,9 +1032,11 @@ static es_out_id_t *esOutAdd(es_out_t *p_out, const es_format_t *p_fmt)
         }
         setStreamLang(p_sys, &fmt);
         break ;
+    default:
+        break ;
     }
 
-    es_out_id_t *p_es = es_out_Add(p_demux->out, &fmt);
+    es_out_id_t *p_es = es_out_Add(es_out_sys->p_dst_out, &fmt);
     if (p_fmt->i_id >= 0) {
         /* Ensure we are not overriding anything */
         int idx = findEsPairIndex(p_sys, p_fmt->i_id);
@@ -1058,36 +1064,47 @@ static es_out_id_t *esOutAdd(es_out_t *p_out, const es_format_t *p_fmt)
 
 static int esOutSend(es_out_t *p_out, es_out_id_t *p_es, block_t *p_block)
 {
-    return es_out_Send(p_out->p_sys->p_demux->out, p_es, p_block);
+    es_out_sys_t *es_out_sys = p_out->p_sys;
+
+    return es_out_Send(es_out_sys->p_dst_out, p_es, p_block);
 }
 
 static void esOutDel(es_out_t *p_out, es_out_id_t *p_es)
 {
-    int idx = findEsPairIndexByEs(p_out->p_sys->p_demux->p_sys, p_es);
+    es_out_sys_t *es_out_sys = p_out->p_sys;
+    demux_t *p_demux = es_out_sys->priv;
+    demux_sys_t *p_sys = p_demux->p_sys;
+
+    int idx = findEsPairIndexByEs(p_sys, p_es);
     if (idx >= 0) {
-        free(vlc_array_item_at_index(&p_out->p_sys->p_demux->p_sys->es, idx));
-        vlc_array_remove(&p_out->p_sys->p_demux->p_sys->es, idx);
+        free(vlc_array_item_at_index(&p_sys->es, idx));
+        vlc_array_remove(&p_sys->es, idx);
     }
-    es_out_Del(p_out->p_sys->p_demux->out, p_es);
+    es_out_Del(es_out_sys->p_dst_out, p_es);
 }
 
 static int esOutControl(es_out_t *p_out, int i_query, va_list args)
 {
-    return es_out_vaControl(p_out->p_sys->p_demux->out, i_query, args);
+    es_out_sys_t *es_out_sys = p_out->p_sys;
+
+    return es_out_vaControl(es_out_sys->p_dst_out, i_query, args);
 }
 
 static void esOutDestroy(es_out_t *p_out)
 {
-    for (size_t i = 0; i < vlc_array_count(&p_out->p_sys->p_demux->p_sys->es); ++i)
-        free(vlc_array_item_at_index(&p_out->p_sys->p_demux->p_sys->es, i));
-    vlc_array_clear(&p_out->p_sys->p_demux->p_sys->es);
+    es_out_sys_t *es_out_sys = p_out->p_sys;
+    demux_t *p_demux = es_out_sys->priv;
+    demux_sys_t *p_sys = p_demux->p_sys;
+
+    for (size_t i = 0; i < vlc_array_count(&p_sys->es); ++i)
+        free(vlc_array_item_at_index(&p_sys->es, i));
+    vlc_array_clear(&p_sys->es);
     free(p_out->p_sys);
     free(p_out);
 }
 
-static es_out_t *esOutNew(demux_t *p_demux)
+static es_out_t *esOutNew(vlc_object_t *p_obj, es_out_t *p_dst_out, void *priv)
 {
-    assert(vlc_array_count(&p_demux->p_sys->es) == 0);
     es_out_t    *p_out = malloc(sizeof(*p_out));
     if (unlikely(p_out == NULL))
         return NULL;
@@ -1098,12 +1115,15 @@ static es_out_t *esOutNew(demux_t *p_demux)
     p_out->pf_destroy   = esOutDestroy;
     p_out->pf_send      = esOutSend;
 
-    p_out->p_sys = malloc(sizeof(*p_out->p_sys));
-    if (unlikely(p_out->p_sys == NULL)) {
+    es_out_sys_t *es_out_sys = malloc(sizeof(*es_out_sys));
+    if (unlikely(es_out_sys == NULL)) {
         free(p_out);
         return NULL;
     }
-    p_out->p_sys->p_demux = p_demux;
+    p_out->p_sys = es_out_sys;
+    es_out_sys->p_dst_out = p_dst_out;
+    es_out_sys->p_obj = p_obj;
+    es_out_sys->priv = priv;
     return p_out;
 }
 



More information about the vlc-commits mailing list