[vlc-commits] ram: handle FindPrefix() failure and simplify

Rémi Denis-Courmont git at videolan.org
Mon Jul 25 23:44:46 CEST 2016


vlc | branch: master | Rémi Denis-Courmont <remi at remlab.net> | Tue Jul 26 00:01:03 2016 +0300| [4f33b9b3a2557eb41375b8572173d7116ff8e590] | committer: Rémi Denis-Courmont

ram: handle FindPrefix() failure and simplify

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

 modules/demux/playlist/playlist.c |  2 +-
 modules/demux/playlist/playlist.h |  1 -
 modules/demux/playlist/ram.c      | 28 +++++++++-------------------
 3 files changed, 10 insertions(+), 21 deletions(-)

diff --git a/modules/demux/playlist/playlist.c b/modules/demux/playlist/playlist.c
index b5cfbdb..cd08ee4 100644
--- a/modules/demux/playlist/playlist.c
+++ b/modules/demux/playlist/playlist.c
@@ -104,7 +104,7 @@ vlc_module_begin ()
         set_description( N_("RAM playlist import") )
         add_shortcut( "playlist", "ram-open" )
         set_capability( "demux", 10 )
-        set_callbacks( Import_RAM, Close_RAM )
+        set_callbacks( Import_RAM, NULL )
     add_submodule ()
         set_description( N_("PLS playlist import") )
         add_shortcut( "playlist", "pls-open" )
diff --git a/modules/demux/playlist/playlist.h b/modules/demux/playlist/playlist.h
index eb366e5..da5e81d 100644
--- a/modules/demux/playlist/playlist.h
+++ b/modules/demux/playlist/playlist.h
@@ -36,7 +36,6 @@ int Import_M3U ( vlc_object_t * );
 void Close_M3U ( vlc_object_t * );
 
 int Import_RAM ( vlc_object_t * );
-void Close_RAM ( vlc_object_t * );
 
 int Import_PLS ( vlc_object_t * );
 
diff --git a/modules/demux/playlist/ram.c b/modules/demux/playlist/ram.c
index c85fcba..68999d8 100644
--- a/modules/demux/playlist/ram.c
+++ b/modules/demux/playlist/ram.c
@@ -56,11 +56,6 @@ http://service.real.com/help/library/guides/realone/IntroGuide/HTML/htmfiles/ram
 
 #include "playlist.h"
 
-struct demux_sys_t
-{
-    char *psz_prefix;
-};
-
 /*****************************************************************************
  * Local prototypes
  *****************************************************************************/
@@ -92,24 +87,14 @@ int Import_RAM( vlc_object_t *p_this )
         return VLC_EGENERIC;
     }
 
-    STANDARD_DEMUX_INIT_MSG( "found valid RAM playlist" );
-    p_demux->p_sys->psz_prefix = FindPrefix( p_demux );
+    msg_Dbg( p_demux, "found valid RAM playlist" );
+    p_demux->pf_demux = Demux;
+    p_demux->pf_control = Control;
 
     return VLC_SUCCESS;
 }
 
 /**
- * Frees up memory on module close
- * @param p_this: this demux object
- */
-void Close_RAM( vlc_object_t *p_this )
-{
-    demux_t *p_demux = (demux_t *)p_this;
-    free( p_demux->p_sys->psz_prefix );
-    free( p_demux->p_sys );
-}
-
-/**
  * Skips blanks in a given buffer
  * @param s: input string
  * @param i_strlen: length of the buffer
@@ -214,6 +199,10 @@ static int ParseTime( const char *s, size_t i_strlen)
  */
 static int Demux( demux_t *p_demux )
 {
+    char *psz_prefix = FindPrefix( p_demux );
+    if( unlikely(psz_prefix == NULL) )
+        return VLC_DEMUXER_EOF;
+
     char       *psz_line;
     char       *psz_artist = NULL, *psz_album = NULL, *psz_genre = NULL, *psz_year = NULL;
     char       *psz_author = NULL, *psz_title = NULL, *psz_copyright = NULL, *psz_cdnum = NULL, *psz_comments = NULL;
@@ -246,7 +235,7 @@ static int Demux( demux_t *p_demux )
             char *psz_param, *psz_value;
 
             /* Get the MRL from the file. Note that this might contain parameters of form ?param1=value1&param2=value2 in a RAM file */
-            psz_mrl = ProcessMRL( psz_parse, p_demux->p_sys->psz_prefix );
+            psz_mrl = ProcessMRL( psz_parse, psz_prefix );
 
             b_cleanup = true;
             if ( !psz_mrl ) goto error;
@@ -391,6 +380,7 @@ static int Demux( demux_t *p_demux )
     input_item_node_PostAndDelete( p_subitems );
     vlc_gc_decref(p_current_input);
     var_Destroy( p_demux, "m3u-extvlcopt" );
+    free(psz_prefix);
     return 0; /* Needed for correct operation of go back */
 }
 



More information about the vlc-commits mailing list