]> git.sesse.net Git - vlc/blobdiff - modules/video_filter/marq.c
playlist: use playlist_TogglePause() directly, fix minor races
[vlc] / modules / video_filter / marq.c
index 1420456f4e7b0225cac75d36751d4797eba28088..9618c7cf21bdbbca838af4c37795757218074d1d 100644 (file)
@@ -1,26 +1,26 @@
 /*****************************************************************************
  * marq.c : marquee display video plugin for vlc
  *****************************************************************************
- * Copyright (C) 2003-2008 the VideoLAN team
+ * Copyright (C) 2003-2008 VLC authors and VideoLAN
  * $Id$
  *
  * Authors: Mark Moriarty
  *          Sigmund Augdal Helberg <dnumgis@videolan.org>
  *          Antoine Cellerier <dionoea . videolan \ org>
  *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 2 of the License, or
+ * This program is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as published by
+ * the Free Software Foundation; either version 2.1 of the License, or
  * (at your option) any later version.
  *
  * This program is distributed in the hope that it will be useful,
  * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
- * GNU General Public License for more details.
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License for more details.
  *
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston MA 02110-1301, USA.
+ * You should have received a copy of the GNU Lesser General Public License
+ * along with this program; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin Street, Fifth Floor, Boston MA 02110-1301, USA.
  *****************************************************************************/
 
 /*****************************************************************************
 # include "config.h"
 #endif
 
+#include <errno.h>
+
 #include <vlc_common.h>
 #include <vlc_plugin.h>
-
 #include <vlc_filter.h>
 #include <vlc_block.h>
 #include <vlc_fs.h>
-
 #include <vlc_strings.h>
 
 /*****************************************************************************
@@ -47,7 +47,7 @@ static int  CreateFilter ( vlc_object_t * );
 static void DestroyFilter( vlc_object_t * );
 static subpicture_t *Filter( filter_t *, mtime_t );
 
-static char *ReadFile( filter_t *, const char * );
+static char *MarqueeReadFile( filter_t *, const char * );
 static int MarqueeCallback( vlc_object_t *p_this, char const *psz_var,
                             vlc_value_t oldval, vlc_value_t newval,
                             void *p_data );
@@ -88,19 +88,8 @@ struct filter_sys_t
 #define MSG_LONGTEXT N_( \
     "Marquee text to display. " \
     "(Available format strings: " \
-    "Time related: %Y = year, %m = month, %d = day, %H = hour, " \
-    "%M = minute, %S = second, ... " \
-    "Meta data related: $a = artist, $b = album, $c = copyright, " \
-    "$d = description, $e = encoded by, $g = genre, " \
-    "$l = language, $n = track num, $p = now playing, " \
-    "$r = rating, $s = subtitles language, $t = title, "\
-    "$u = url, $A = date, " \
-    "$B = audio bitrate (in kb/s), $C = chapter," \
-    "$D = duration, $F = full name with path, $I = title, "\
-    "$L = time left, " \
-    "$N = name, $O = audio language, $P = position (in %), $R = rate, " \
-    "$S = audio sample rate (in kHz), " \
-    "$T = time, $U = publisher, $V = volume, $_ = new line) ")
+    "%Y = year, %m = month, %d = day, %H = hour, " \
+    "%M = minute, %S = second, ...)" )
 #define FILE_TEXT N_("Text file")
 #define FILE_LONGTEXT N_("File to read the marquee text from.")
 #define POSX_TEXT N_("X offset")
@@ -186,7 +175,7 @@ vlc_module_end ()
 
 static const char *const ppsz_filter_options[] = {
     "marquee", "x", "y", "position", "color", "size", "timeout", "refresh",
-    "opacity",
+    "opacity","file",
     NULL
 };
 
@@ -283,7 +272,7 @@ static subpicture_t *Filter( filter_t *p_filter, mtime_t date )
 
     if( p_sys->filepath != NULL )
     {
-        char *fmt = ReadFile( p_filter, p_sys->filepath );
+        char *fmt = MarqueeReadFile( p_filter, p_sys->filepath );
         if( fmt != NULL )
         {
             free( p_sys->format );
@@ -291,7 +280,7 @@ static subpicture_t *Filter( filter_t *p_filter, mtime_t date )
         }
     }
 
-    char *msg = str_format( p_filter, p_sys->format ? p_sys->format : "" );
+    char *msg = str_format_time( p_sys->format ? p_sys->format : "" );
     if( unlikely( msg == NULL ) )
         goto out;
     if( p_sys->message != NULL && !strcmp( msg, p_sys->message ) )
@@ -314,7 +303,7 @@ static subpicture_t *Filter( filter_t *p_filter, mtime_t date )
     p_spu->p_region = subpicture_region_New( &fmt );
     if( !p_spu->p_region )
     {
-        p_filter->pf_sub_buffer_del( p_filter, p_spu );
+        subpicture_Delete( p_spu );
         p_spu = NULL;
         goto out;
     }
@@ -348,12 +337,12 @@ out:
     return p_spu;
 }
 
-static char *ReadFile( filter_t *obj, const char *path )
+static char *MarqueeReadFile( filter_t *obj, const char *path )
 {
     FILE *stream = vlc_fopen( path, "rt" );
     if( stream == NULL )
     {
-        msg_Err( obj, "cannot open %s: %m", path );
+        msg_Err( obj, "cannot open %s: %s", path, vlc_strerror_c(errno) );
         return NULL;
     }
 
@@ -362,7 +351,7 @@ static char *ReadFile( filter_t *obj, const char *path )
     ssize_t len = getline( &line, &(size_t){ 0 }, stream );
     if( len == -1 )
     {
-        msg_Err( obj, "cannot read %s: %m", path );
+        msg_Err( obj, "cannot read %s: %s", path, vlc_strerror_c(errno) );
         clearerr( stream );
         line = NULL;
     }