time string.
* Functions prototyped are implemented in interface/mtime.c.
*****************************************************************************
* Copyright (C) 1996, 1997, 1998, 1999, 2000 VideoLAN
- * $Id: mtime.h,v 1.13 2002/11/11 14:39:11 sam Exp $
+ * $Id: mtime.h,v 1.14 2003/12/02 01:54:30 rocky Exp $
*
* Authors: Vincent Seguin <seguin@via.ecp.fr>
*
*****************************************************************************/
#define MSTRTIME_MAX_SIZE 22
+#define msecstotimestr(psz_buffer, msecs) \
+ secstotimestr( psz_buffer, (msecs / (int) 1000) )
+
/*****************************************************************************
* Prototypes
*****************************************************************************/
VLC_EXPORT( mtime_t, mdate, ( void ) );
VLC_EXPORT( void, mwait, ( mtime_t date ) );
VLC_EXPORT( void, msleep, ( mtime_t delay ) );
+VLC_EXPORT( char *, secstotimestr, ( char *psz_buffer, int secs ) );
* cddax.c : CD digital audio input module for vlc using libcdio
*****************************************************************************
* Copyright (C) 2000,2003 VideoLAN
- * $Id: access.c,v 1.7 2003/12/01 03:34:30 rocky Exp $
+ * $Id: access.c,v 1.8 2003/12/02 01:54:30 rocky Exp $
*
* Authors: Rocky Bernstein <rocky@panix.com>
* Laurent Aimar <fenrir@via.ecp.fr>
}
-static
-char * secs2TimeStr( int64_t i_sec )
-{
- int h = i_sec / 3600;
- int m = ( i_sec / 60 ) % 60;
- int s = i_sec % 60;
- static char buffer[20];
-
- snprintf(buffer, 20, "%d:%2.2d:%2.2d", h, m, s);
- return buffer;
-}
-
#define meta_info_add_str(title, str) \
if ( str ) { \
printf("field %s str %s\n", title, str); \
if( p_cdda->cddb.disc->length > 1000 )
{
int64_t i_sec = (int64_t) p_cdda->cddb.disc->length;
- input_AddInfo( p_cat, _("Duration"), "%s", secs2TimeStr( i_sec ) );
+ char psz_buffer[MSTRTIME_MAX_SIZE];
+ input_AddInfo( p_cat, _("Duration"), "%s",
+ secstotimestr( psz_buffer, i_sec ) );
} else
{
use_cddb = 0;
if (!use_cddb)
{
track_t i_track = p_cdda->i_nb_tracks;
+ char psz_buffer[MSTRTIME_MAX_SIZE];
mtime_t i_duration =
(p_cdda->p_sectors[i_track] - p_cdda->p_sectors[i_track-1])
/ CDIO_CD_FRAMES_PER_SEC;
- input_AddInfo( p_cat, _("Duration"), "%s", secs2TimeStr( i_duration ) );
+ input_AddInfo( p_cat, _("Duration"), "%s",
+ secstotimestr( psz_buffer, i_duration ) );
}
}
case 's':
if (p_cdda->i_cddb_enabled) {
+ char psz_buffer[MSTRTIME_MAX_SIZE];
mtime_t i_duration =
(p_cdda->p_sectors[i_track] - p_cdda->p_sectors[i_track-1])
/ CDIO_CD_FRAMES_PER_SEC;
- add_format_str_info(secs2TimeStr(i_duration));
+ add_format_str_info(secstotimestr( psz_buffer, i_duration ) );
} else goto not_special;
break;
* mkv.cpp : matroska demuxer
*****************************************************************************
* Copyright (C) 2001 VideoLAN
- * $Id: mkv.cpp,v 1.47 2003/11/28 22:23:04 fenrir Exp $
+ * $Id: mkv.cpp,v 1.48 2003/12/02 01:54:30 rocky Exp $
*
* Authors: Laurent Aimar <fenrir@via.ecp.fr>
*
p_cat = input_InfoCategory( p_input, "Matroska" );
if( p_sys->f_duration > 1000.1 )
{
- int64_t i_sec = (int64_t)p_sys->f_duration / 1000;
- int h,m,s;
-
- h = i_sec / 3600;
- m = ( i_sec / 60 ) % 60;
- s = i_sec % 60;
-
- input_AddInfo( p_cat, _("Duration"), "%d:%2.2d:%2.2d" , h, m, s );
+ char psz_buffer[MSTRTIME_MAX_SIZE];
+ input_AddInfo( p_cat, _("Duration"),
+ msecstotimestr( psz_buffer, p_sys->f_duration ) );
}
if( p_sys->psz_title )
* gtk_playlist.c : Interface for the playlist dialog
*****************************************************************************
* Copyright (C) 2001 VideoLAN
- * $Id: playlist.c,v 1.5 2003/11/30 19:42:52 sigmunau Exp $
+ * $Id: playlist.c,v 1.6 2003/12/02 01:54:30 rocky Exp $
*
* Authors: Pierre Baillet <oct@zoy.org>
* Stéphane Borel <stef@via.ecp.fr>
vlc_mutex_lock( &p_playlist->object_lock );
for( i_dummy = p_playlist->i_size ; i_dummy-- ; )
{
- char psz_duration[14];
+ char psz_duration[MSTRTIME_MAX_SIZE];
mtime_t dur = p_playlist->pp_items[i_dummy]->i_duration;
if ( dur != -1 )
{
- sprintf( psz_duration, "%d:%2.2d:%2.2d", (int)(dur / 3600),
- (int)(( dur % 3600 ) / 60), (int)(dur % 60) );
+ secstotimestr( psz_duration, dur );
}
else
{
* Functions are prototyped in mtime.h.
*****************************************************************************
* Copyright (C) 1998-2001 VideoLAN
- * $Id: mtime.c,v 1.36 2003/06/05 11:52:19 gbazin Exp $
+ * $Id: mtime.c,v 1.37 2003/12/02 01:54:30 rocky Exp $
*
* Authors: Vincent Seguin <seguin@via.ecp.fr>
*
/*****************************************************************************
* mstrtime: return a date in a readable format
*****************************************************************************
- * This functions is provided for any interface function which need to print a
- * date. psz_buffer should be a buffer long enough to store the formatted
+ * This function converts a mtime date into a string.
+ * psz_buffer should be a buffer long enough to store the formatted
* date.
*****************************************************************************/
+/**
+ * \brief return a date in a readable format
+ * \param date to be converted
+ * \param psz_buffer should be a buffer at least MSTRTIME_MAX_SIZE characters
+ * \return psz_buffer is returned so this can be used as printf parameter.
+ */
char *mstrtime( char *psz_buffer, mtime_t date )
{
static mtime_t ll1000 = 1000, ll60 = 60, ll24 = 24;
- sprintf( psz_buffer, "%02d:%02d:%02d-%03d.%03d",
+ snprintf( psz_buffer, MSTRTIME_MAX_SIZE, "%02d:%02d:%02d-%03d.%03d",
(int) (date / (ll1000 * ll1000 * ll60 * ll60) % ll24),
(int) (date / (ll1000 * ll1000 * ll60) % ll60),
(int) (date / (ll1000 * ll1000) % ll60),
return( psz_buffer );
}
+/*****************************************************************************
+ * secstotimestr: convert seconds to a time in the format h:mm:ss
+ *****************************************************************************
+ * This function is provided for any interface function which need to print a
+ * time string in the format h:mm:ss
+ * date.
+ *****************************************************************************/
+/**
+ * \brief convert seconds to a time in the format h:mm:ss
+ * \param secs the date to be converted
+ * \param psz_buffer should be a buffer at least MSTRTIME_MAX_SIZE characters
+ * \return psz_buffer is returned so this can be used as printf parameter.
+ */
+char *secstotimestr( char *psz_buffer, int secs )
+{
+ snprintf( psz_buffer, MSTRTIME_MAX_SIZE, "%d:%2.2d:%2.2d",
+ (int) (secs / 3600), (int)(( secs % 3600 ) / 60),
+ (int)(secs % 60) );
+ return( psz_buffer );
+}
+
/*****************************************************************************
* mdate: return high precision date
*****************************************************************************