[MPlayer-cvslog] r23434 - in trunk: command.c m_property.c m_property.h

albeu subversion at mplayerhq.hu
Thu May 31 14:42:02 CEST 2007


Author: albeu
Date: Thu May 31 14:42:02 2007
New Revision: 23434

Log:
Move the time printing code out of the length property.


Modified:
   trunk/command.c
   trunk/m_property.c
   trunk/m_property.h

Modified: trunk/command.c
==============================================================================
--- trunk/command.c	(original)
+++ trunk/command.c	Thu May 31 14:42:02 2007
@@ -283,28 +283,7 @@ static int mp_property_length(m_option_t
 	!(int) (len = demuxer_get_time_length(mpctx->demuxer)))
 	return M_PROPERTY_UNAVAILABLE;
 
-    switch (action) {
-    case M_PROPERTY_PRINT:
-	if (!arg)
-	    return M_PROPERTY_ERROR;
-	else {
-	    int h, m, s = len;
-	    h = s / 3600;
-	    s -= h * 3600;
-	    m = s / 60;
-	    s -= m * 60;
-	    *(char **) arg = malloc(20);
-	    if (h > 0)
-		sprintf(*(char **) arg, "%d:%02d:%02d", h, m, s);
-	    else if (m > 0)
-		sprintf(*(char **) arg, "%d:%02d", m, s);
-	    else
-		sprintf(*(char **) arg, "%d", s);
-	    return M_PROPERTY_OK;
-	}
-	break;
-    }
-    return m_property_double_ro(prop, action, arg, len);
+    return m_property_time_ro(prop, action, arg, len);
 }
 
 /// Demuxer meta data

Modified: trunk/m_property.c
==============================================================================
--- trunk/m_property.c	(original)
+++ trunk/m_property.c	Thu May 31 14:42:02 2007
@@ -318,6 +318,31 @@ int m_property_double_ro(m_option_t* pro
     return M_PROPERTY_NOT_IMPLEMENTED;
 }
 
+int m_property_time_ro(m_option_t* prop,int action,
+                       void* arg,double var) {
+    switch(action) {
+    case M_PROPERTY_PRINT:
+	if (!arg)
+	    return M_PROPERTY_ERROR;
+	else {
+	    int h, m, s = var;
+	    h = s / 3600;
+	    s -= h * 3600;
+	    m = s / 60;
+	    s -= m * 60;
+	    *(char **) arg = malloc(20);
+	    if (h > 0)
+		sprintf(*(char **) arg, "%d:%02d:%02d", h, m, s);
+	    else if (m > 0)
+		sprintf(*(char **) arg, "%d:%02d", m, s);
+	    else
+		sprintf(*(char **) arg, "%d", s);
+	    return M_PROPERTY_OK;
+        }
+    }
+    return m_property_double_ro(prop,action,arg,var);
+}
+
 int m_property_string_ro(m_option_t* prop,int action,void* arg,char* str) {
     switch(action) {
     case M_PROPERTY_GET:

Modified: trunk/m_property.h
==============================================================================
--- trunk/m_property.h	(original)
+++ trunk/m_property.h	Thu May 31 14:42:02 2007
@@ -185,6 +185,10 @@ int m_property_delay(m_option_t* prop,in
 int m_property_double_ro(m_option_t* prop,int action,
                          void* arg,double var);
 
+/// Implement print
+int m_property_time_ro(m_option_t* prop,int action,
+                       void* arg,double var);
+
 /// get/print the string
 int m_property_string_ro(m_option_t* prop,int action,void* arg, char* str);
 



More information about the MPlayer-cvslog mailing list