Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
V
vlc
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Redmine
Redmine
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Operations
Operations
Metrics
Environments
Analytics
Analytics
CI / CD
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
videolan
vlc
Commits
6da08521
Commit
6da08521
authored
Dec 02, 2003
by
Rocky Bernstein
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Add secstotimestr and msecstotimestr to convert (milli)seconds to a
time string.
parent
59173c65
Changes
5
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
52 additions
and
34 deletions
+52
-34
include/mtime.h
include/mtime.h
+5
-1
modules/access/cdda/access.c
modules/access/cdda/access.c
+9
-16
modules/demux/mkv.cpp
modules/demux/mkv.cpp
+4
-9
modules/gui/gtk/playlist.c
modules/gui/gtk/playlist.c
+3
-4
src/misc/mtime.c
src/misc/mtime.c
+31
-4
No files found.
include/mtime.h
View file @
6da08521
...
...
@@ -9,7 +9,7 @@
* Functions prototyped are implemented in interface/mtime.c.
*****************************************************************************
* Copyright (C) 1996, 1997, 1998, 1999, 2000 VideoLAN
* $Id: mtime.h,v 1.1
3 2002/11/11 14:39:11 sam
Exp $
* $Id: mtime.h,v 1.1
4 2003/12/02 01:54:30 rocky
Exp $
*
* Authors: Vincent Seguin <seguin@via.ecp.fr>
*
...
...
@@ -47,6 +47,9 @@
*****************************************************************************/
#define MSTRTIME_MAX_SIZE 22
#define msecstotimestr(psz_buffer, msecs) \
secstotimestr( psz_buffer, (msecs / (int) 1000) )
/*****************************************************************************
* Prototypes
*****************************************************************************/
...
...
@@ -54,4 +57,5 @@ VLC_EXPORT( char *, mstrtime, ( char *psz_buffer, mtime_t date ) );
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
)
);
modules/access/cdda/access.c
View file @
6da08521
...
...
@@ -2,7 +2,7 @@
* 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:3
4:30 rocky Exp $
* $Id: access.c,v 1.
8 2003/12/02 01:5
4:30 rocky Exp $
*
* Authors: Rocky Bernstein <rocky@panix.com>
* Laurent Aimar <fenrir@via.ecp.fr>
...
...
@@ -518,18 +518,6 @@ static void CDDASeek( input_thread_t * p_input, off_t i_off )
}
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); \
...
...
@@ -551,7 +539,9 @@ static void InformationCreate( input_thread_t *p_input )
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
;
...
...
@@ -585,11 +575,13 @@ static void InformationCreate( input_thread_t *p_input )
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
)
);
}
}
...
...
@@ -829,10 +821,11 @@ CDDAFormatStr(const input_thread_t *p_input, cdda_data_t *p_cdda,
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
(
secs
2TimeStr
(
i_duration
)
);
add_format_str_info
(
secs
totimestr
(
psz_buffer
,
i_duration
)
);
}
else
goto
not_special
;
break
;
...
...
modules/demux/mkv.cpp
View file @
6da08521
...
...
@@ -2,7 +2,7 @@
* mkv.cpp : matroska demuxer
*****************************************************************************
* Copyright (C) 2001 VideoLAN
* $Id: mkv.cpp,v 1.4
7 2003/11/28 22:23:04 fenrir
Exp $
* $Id: mkv.cpp,v 1.4
8 2003/12/02 01:54:30 rocky
Exp $
*
* Authors: Laurent Aimar <fenrir@via.ecp.fr>
*
...
...
@@ -2171,14 +2171,9 @@ static void InformationsCreate( input_thread_t *p_input )
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
)
...
...
modules/gui/gtk/playlist.c
View file @
6da08521
...
...
@@ -2,7 +2,7 @@
* 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>
* Stphane Borel <stef@via.ecp.fr>
...
...
@@ -694,12 +694,11 @@ void GtkRebuildCList( GtkCList * p_clist, playlist_t * p_playlist )
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
{
...
...
src/misc/mtime.c
View file @
6da08521
...
...
@@ -3,7 +3,7 @@
* Functions are prototyped in mtime.h.
*****************************************************************************
* Copyright (C) 1998-2001 VideoLAN
* $Id: mtime.c,v 1.3
6 2003/06/05 11:52:19 gbazin
Exp $
* $Id: mtime.c,v 1.3
7 2003/12/02 01:54:30 rocky
Exp $
*
* Authors: Vincent Seguin <seguin@via.ecp.fr>
*
...
...
@@ -67,15 +67,21 @@ int nanosleep(struct timespec *, struct timespec *);
/*****************************************************************************
* mstrtime: return a date in a readable format
*****************************************************************************
* This function
s 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
;
s
printf
(
psz_buffer
,
"%02d:%02d:%02d-%03d.%03d"
,
s
nprintf
(
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
),
...
...
@@ -84,6 +90,27 @@ char *mstrtime( char *psz_buffer, mtime_t date )
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
*****************************************************************************
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment