avformat/segment: simplify localtime* use

Signed-off-by: Michael Niedermayer <michaelni@gmx.at>
This commit is contained in:
Michael Niedermayer 2014-07-07 22:29:02 +02:00
parent 8cda23f341
commit b8d017adba

View File

@ -669,13 +669,6 @@ fail:
return ret; return ret;
} }
#if !HAVE_LOCALTIME_R
static void localtime_r(const time_t *t, struct tm *tm)
{
*tm = *localtime(t);
}
#endif
static int seg_write_packet(AVFormatContext *s, AVPacket *pkt) static int seg_write_packet(AVFormatContext *s, AVPacket *pkt)
{ {
SegmentContext *seg = s->priv_data; SegmentContext *seg = s->priv_data;
@ -697,7 +690,11 @@ static int seg_write_packet(AVFormatContext *s, AVPacket *pkt)
} else { } else {
if (seg->use_clocktime) { if (seg->use_clocktime) {
gettimeofday(&now, NULL); gettimeofday(&now, NULL);
#if HAVE_LOCALTIME_R
localtime_r(&now.tv_sec, &ti); localtime_r(&now.tv_sec, &ti);
#else
ti = *localtime(&now.tv_sec);
#endif
usecs = (int64_t)(ti.tm_hour*3600 + ti.tm_min*60 + ti.tm_sec) * 1000000 + now.tv_usec; usecs = (int64_t)(ti.tm_hour*3600 + ti.tm_min*60 + ti.tm_sec) * 1000000 + now.tv_usec;
wrapped_val = usecs % seg->time; wrapped_val = usecs % seg->time;
if (seg->last_cut != usecs && wrapped_val < seg->last_val) { if (seg->last_cut != usecs && wrapped_val < seg->last_val) {