comparison command.c @ 23416:ae4237717601

Move the time printing code out of the length property.
author albeu
date Thu, 31 May 2007 12:42:02 +0000
parents f6c225ffe60d
children a829005cbcd5
comparison
equal deleted inserted replaced
23415:0f0803d6544a 23416:ae4237717601
281 281
282 if (!mpctx->demuxer || 282 if (!mpctx->demuxer ||
283 !(int) (len = demuxer_get_time_length(mpctx->demuxer))) 283 !(int) (len = demuxer_get_time_length(mpctx->demuxer)))
284 return M_PROPERTY_UNAVAILABLE; 284 return M_PROPERTY_UNAVAILABLE;
285 285
286 switch (action) { 286 return m_property_time_ro(prop, action, arg, len);
287 case M_PROPERTY_PRINT:
288 if (!arg)
289 return M_PROPERTY_ERROR;
290 else {
291 int h, m, s = len;
292 h = s / 3600;
293 s -= h * 3600;
294 m = s / 60;
295 s -= m * 60;
296 *(char **) arg = malloc(20);
297 if (h > 0)
298 sprintf(*(char **) arg, "%d:%02d:%02d", h, m, s);
299 else if (m > 0)
300 sprintf(*(char **) arg, "%d:%02d", m, s);
301 else
302 sprintf(*(char **) arg, "%d", s);
303 return M_PROPERTY_OK;
304 }
305 break;
306 }
307 return m_property_double_ro(prop, action, arg, len);
308 } 287 }
309 288
310 /// Demuxer meta data 289 /// Demuxer meta data
311 static int mp_property_metadata(m_option_t * prop, int action, void *arg, 290 static int mp_property_metadata(m_option_t * prop, int action, void *arg,
312 MPContext * mpctx) { 291 MPContext * mpctx) {