[MPlayer-dev-eng] [PATCH] EDL fix harcoded translatable messages

Reynaldo H. Verdejo Pinochet reynaldo at opendot.cl
Wed Sep 15 01:07:23 CEST 2004


On Tue, Sep 14, 2004 at 12:25:58PM +0200, Diego Biurrun wrote:
> Please read what I just sent to dev-eng about splitting up patches and
> follow the advice I give there.  I'm currently too lazy to handle this
> split-up patch, besides, I could not resist to pick some more nits, so
> the patch is refused for now, sorry.
> 
> Please send in an updated version, I'll apply.
> 
Ok, noprob

Here is the patch on 1 file.

details:

1.- incorporates sugestions from Attila regarding doxy comments
2.- fixes a missed free() on edl code (spoted by Attila)
3.- incorporates your comments on translatable english strings
4.- incorporates an spanish translation as you and Attila sugested

Best regards

  Reynaldo

ps: still wanting write access ;)
-------------- next part --------------
--- edl.c	2004-08-27 20:46:05.000000000 -0400
+++ ../my_main/edl.c	2004-09-14 00:41:34.000000000 -0400
@@ -3,9 +3,18 @@
 #include "config.h"
 #include "mp_msg.h"
 #include "edl.h"
+#include "help_mp.h"
 
 #ifdef USE_EDL
 
+/** 
+ *  we cant do -edl and -edlout at the same time
+ *  so we check that here.
+ *  
+ *  \return EDL_ERROR on error and 1 otherwise
+ *  \brief Makes sure edl has been called correctly
+ */
+
 int edl_check_mode(void)
 {
     if (edl_filename && edl_output_filename)
@@ -16,6 +25,13 @@
     return (1);
 }
 
+/** Calculates the total amount edl_records we will need
+ *  to hold the edl operations queue, we need one edl_record
+ *  for each SKIP and two for each MUTE.
+ *  \return total amount of needed edl entries, EDL_ERROR when can't read file
+ *  \brief counts needed edl entries
+ */
+
 int edl_count_entries(void)
 {
     FILE *fd = NULL;
@@ -29,8 +45,7 @@
     {
         if ((fd = fopen(edl_filename, "r")) == NULL)
         {
-            mp_msg(MSGT_CPLAYER, MSGL_WARN,
-                   "Invalid EDL file, cant open '%s' for reading!\n",
+            mp_msg(MSGT_CPLAYER, MSGL_WARN, MSGTR_EdlCantOpenForRead,
                    edl_filename);
             return (EDL_ERROR);
         } else
@@ -46,8 +61,7 @@
                         entries += 2;
                 } else
                 {
-                    mp_msg(MSGT_CPLAYER, MSGL_WARN,
-                           "Invalid EDL line: %s\n", line);
+                    mp_msg(MSGT_CPLAYER, MSGL_WARN, MSGTR_EdlNOValidLine, line);
                     return (EDL_ERROR);
                 }
 
@@ -61,6 +75,11 @@
     return (entries);
 }
 
+/** parses edl_filename to fill edl operations queue
+ *  \return No of edl records stored or EDL_ERROR when can't read from file
+ *  \brief fills edl operations queue.
+ */
+
 int edl_parse_file(edl_record_ptr edl_records)
 {
     FILE *fd;
@@ -84,9 +103,8 @@
                 if ((sscanf(line, "%f %f %d", &start, &stop, &action))
                     != 3)
                 {
-                    mp_msg(MSGT_CPLAYER, MSGL_WARN,
-                           "Badly formated EDL line [%d]. Discarding!\n",
-                           lineCount + 1, line);
+                    mp_msg(MSGT_CPLAYER, MSGL_WARN, MSGTR_EdlBadlyFormattedLine,
+                           lineCount + 1);
                     continue;
                 } else
                 {
@@ -94,22 +112,19 @@
                     {
                         if (start <= (next_edl_record - 1)->stop_sec)
                         {
-                            mp_msg(MSGT_CPLAYER, MSGL_WARN,
-                                   "Invalid EDL line [%d]: %s",
-                                   lineCount, line);
-                            mp_msg(MSGT_CPLAYER, MSGL_WARN,
-                                   "Last stop position was [%f]; next start is [%f]. Entries must be in chronological order and cannot overlap. Discarding!\n",
+                            mp_msg(MSGT_CPLAYER, MSGL_WARN, 
+                                   MSGTR_EdlNOValidLine, line);
+                            mp_msg(MSGT_CPLAYER, MSGL_WARN, 
+                                   MSGTR_EdlBadLineOverlap,
                                    (next_edl_record - 1)->stop_sec, start);
                             continue;
                         }
                     }
                     if (stop <= start)
                     {
-                        mp_msg(MSGT_CPLAYER, MSGL_WARN,
-                               "Invalid EDL line [%d]: %s", lineCount,
+                        mp_msg(MSGT_CPLAYER, MSGL_WARN, MSGTR_EdlNOValidLine,
                                line);
-                        mp_msg(MSGT_CPLAYER, MSGL_WARN,
-                               "Stop time must follow start time. Discarding!\n");
+                        mp_msg(MSGT_CPLAYER, MSGL_WARN, MSGTR_EdlBadLineBadStop);
                         continue;
                     }
                     next_edl_record->action = action;
--- mplayer.c	2004-09-09 15:24:12.000000000 -0400
+++ ../my_main/mplayer.c	2004-09-12 22:18:28.000000000 -0400
@@ -349,13 +349,13 @@
 #endif
 
 #ifdef USE_EDL
-edl_record_ptr edl_records = NULL; // EDL entries memory area
-edl_record_ptr next_edl_record = NULL; // only for traversing edl_records
-int edl_memory_slots = 0; // No of EDL entries (1 for skip + 2 for each mute)
-int edl_operations = 0; // No of EDL operations, skip + mute
-short edl_decision = 0; // 1 when an EDL operation has been made
-FILE* edl_fd = NULL; // fd to write to when in -edlout mode
-int edl_mute_count = 0; // even number when mute has been matched mute/unmute
+edl_record_ptr edl_records = NULL; /// EDL entries memory area
+edl_record_ptr next_edl_record = NULL; /// only for traversing edl_records
+int edl_memory_slots = 0; /// No of EDL entries (1 for skip + 2 for each mute)
+int edl_operations = 0; /// No of EDL operations, skip + mute
+short edl_decision = 0; /// 1 when an EDL operation has been made
+FILE* edl_fd = NULL; /// fd to write to when in -edlout mode
+int edl_mute_count = 0; /// even number when mute has been matched mute/unmute
 #endif
 
 static unsigned int inited_flags=0;
@@ -477,6 +477,9 @@
 
   current_module="exit_player";
 
+#ifdef USE_EDL
+  if(edl_records != NULL) free(edl_records); // free mem allocated for edl
+#endif
   if(how) mp_msg(MSGT_CPLAYER,MSGL_INFO,MSGTR_ExitingHow,mp_gettext(how));
   mp_msg(MSGT_CPLAYER,MSGL_DBG2,"max framesize was %d bytes\n",max_framesize);
 
@@ -976,13 +979,8 @@
 #ifdef USE_EDL
 if (edl_check_mode() == EDL_ERROR && edl_filename)
 {
-    mp_msg(MSGT_CPLAYER, MSGL_WARN,
-           "Cant use -edl and -edlout at the same time\n");
-    mp_msg(MSGT_CPLAYER, MSGL_WARN, "Not using EDL at all!!!\n");
-    edl_filename = NULL;
-    edl_output_filename = NULL;
-    edl_records = NULL;
-    next_edl_record = edl_records;
+    mp_msg(MSGT_CPLAYER, MSGL_ERR, MSGTR_EdlCantUseBothModes);
+    exit_player(NULL);
 } else if (edl_filename)
 {
     edl_memory_slots = edl_count_entries();
@@ -991,20 +989,18 @@
         edl_records = calloc(edl_memory_slots, sizeof(struct edl_record));
         if (edl_records == NULL)
         {
-            mp_msg(MSGT_CPLAYER, MSGL_FATAL,
-                   "Cant allocate enough memory to hold EDL data, exiting!\n");
+            mp_msg(MSGT_CPLAYER, MSGL_FATAL, MSGTR_EdlOutOfMem);
             exit_player(NULL);	    
         } else
         {
             if ((edl_operations = edl_parse_file(edl_records)) > 0)
             {
-                mp_msg(MSGT_CPLAYER, MSGL_INFO, "Readed %d EDL actions\n",
+                mp_msg(MSGT_CPLAYER, MSGL_INFO, MSGTR_EdlRecordsNo, 
                        edl_operations);
             } else
             {
 
-                mp_msg(MSGT_CPLAYER, MSGL_INFO,
-                       "There are no EDL actions to take care of\n");
+                mp_msg(MSGT_CPLAYER, MSGL_INFO, MSGTR_EdlQueueEmpty);
             }
         }
     }
@@ -1015,11 +1011,9 @@
 {
     if ((edl_fd = fopen(edl_output_filename, "w")) == NULL)
     {
-        mp_msg(MSGT_CPLAYER, MSGL_WARN, 
-	       "Error opening file [%s] for writing!\n",
+        mp_msg(MSGT_CPLAYER, MSGL_ERR, MSGTR_EdlCantOpenForWrite,
                edl_output_filename);
-        edl_output_filename = NULL;
-        next_edl_record = edl_records;
+        exit_player(NULL);
     }
 }
 #endif
@@ -2464,7 +2458,7 @@
 #ifdef USE_EDL
  if( next_edl_record ) { // Are we (still?) doing EDL?
   if ( !sh_video ) {
-    mp_msg( MSGT_CPLAYER, MSGL_ERR, "Cannot use edit list without video. EDL disabled.\n" );
+    mp_msg( MSGT_CPLAYER, MSGL_ERR, MSGTR_EdlNOsh_video );
     next_edl_record->next = NULL;
   } else {
    if( sh_video->pts >= next_edl_record->start_sec ) {
@@ -3521,7 +3515,7 @@
   }
 #ifdef USE_EDL
 /*
- * We Saw a seek, have to rewind the edl operations stak
+ * We saw a seek, have to rewind the edl operations stak
  * and find the next edl action to take care off
  */
 
--- ./help/help_mp-en.h	2004-09-07 23:51:37.000000000 -0400
+++ ../my_main/help/help_mp-en.h	2004-09-14 00:50:51.000000000 -0400
@@ -159,6 +159,18 @@
 "  DOCS/HTML/en/bugreports.html and follow the instructions there. We can't and\n"\
 "  won't help unless you provide this information when reporting a possible bug.\n"
 
+#define MSGTR_EdlCantUseBothModes "Can't use -edl and -edlout at the same time.\n"
+#define MSGTR_EdlOutOfMem "Can't allocate enough memory to hold edl data.\n"
+#define MSGTR_EdlRecordsNo "Read %d EDL actions\n"
+#define MSGTR_EdlQueueEmpty "There are no EDL actions to take care of.\n"
+#define MSGTR_EdlCantOpenForWrite "Error opening file [%s] for writing.\n"
+#define MSGTR_EdlCantOpenForRead "Can't open EDL file [%s] for reading.\n"
+#define MSGTR_EdlNOsh_video "Cannot use EDL without video, disabling.\n"
+#define MSGTR_EdlNOValidLine "Invalid EDL line: %s\n"
+#define MSGTR_EdlBadlyFormattedLine "Badly formatted EDL line [%d] Discarding.\n"
+#define MSGTR_EdlBadLineOverlap "Last stop position was [%f]; next start is "\
+"[%f]. Entries must be in chronological order, cannot overlap. Discarding.\n"
+#define MSGTR_EdlBadLineBadStop "Stop time has to be after start time.\n"
 
 // mencoder.c:
 
--- ./help/help_mp-es.h	2004-09-07 23:51:37.000000000 -0400
+++ ../my_main/help/help_mp-es.h	2004-09-13 19:49:31.000000000 -0400
@@ -163,6 +163,21 @@
 "  se encuentran. No podemos y no lo ayudaremos a menos que nos provea esa\n"\
 "  informaci?n cuando este reportando alg?n posible defecto.\n"
 
+#define MSGTR_EdlCantUseBothModes "Imposible usar -edl y -edlout al mismo tiempo.\n"
+#define MSGTR_EdlOutOfMem "No hay memoria suficiente para almacenar los datos edl.\n"
+#define MSGTR_EdlRecordsNo "Leidas %d acciones EDL.\n"
+#define MSGTR_EdlQueueEmpty "No hay acciones EDL de las que ocuparse.\n"
+#define MSGTR_EdlCantOpenForWrite "Error tratando de escribir en [%s].\n"
+#define MSGTR_EdlCantOpenForRead "Error tratando de leer desde [%s].\n"
+#define MSGTR_EdlNOsh_video "Imposible usar EDL sin video.\n"
+#define MSGTR_EdlNOValidLine "Linea EDL inv?lida: %s\n"
+#define MSGTR_EdlBadlyFormattedLine "Ignorando linea EDL mal formateada [%d].\n"
+#define MSGTR_EdlBadLineOverlap "Ultima posici?n de parada fue [%f]; pr?xima "\
+"posici?n de partida es [%f]. Las operaciones deben estar en orden cronol?gico"\
+", sin sobreponerse, ignorando.\n"
+#define MSGTR_EdlBadLineBadStop "La posici?n de parada debe ser posterior a la"\
+" posici?n de partida.\n"
+
 // mencoder.c:
 
 #define MSGTR_UsingPass3ControllFile "Usando el archivo de control pass3: %s\n"
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 189 bytes
Desc: Digital signature
URL: <http://lists.mplayerhq.hu/pipermail/mplayer-dev-eng/attachments/20040914/aa8319d2/attachment.pgp>


More information about the MPlayer-dev-eng mailing list