Browse Source

ticks: use a vlc_tick_t with secstotimestr()

This is what it's always used with. No need for lossy conversions to int.
pull/127/head
Steve Lhomme 5 years ago
committed by Jean-Baptiste Kempf
parent
commit
a59cb66257
  1. 4
      include/vlc_tick.h
  2. 6
      modules/access/dvb/scan.c
  3. 2
      modules/control/cli/playlist.c
  4. 6
      modules/gui/macosx/extensions/NSString+Helpers.m
  5. 2
      modules/gui/macosx/windows/video/VLCFSPanelController.m
  6. 4
      modules/gui/ncurses.c
  7. 7
      src/misc/mtime.c
  8. 4
      src/player/osd.c
  9. 2
      src/player/title.c

4
include/vlc_tick.h

@ -208,11 +208,11 @@ struct timespec timespec_from_vlc_tick(vlc_tick_t date);
* This function is provided for any interface function which need to print a * This function is provided for any interface function which need to print a
* time string in the format h:mm:ss * time string in the format h:mm:ss
* date. * date.
* \param secs the date to be converted * \param ticks the time to be converted
* \param psz_buffer should be a buffer at least MSTRTIME_MAX_SIZE characters * \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. * \return psz_buffer is returned so this can be used as printf parameter.
*/ */
VLC_API char * secstotimestr( char *psz_buffer, int32_t secs ); VLC_API char * secstotimestr( char *psz_buffer, vlc_tick_t ticks );
/** /**
* \defgroup date Timestamps, error-free * \defgroup date Timestamps, error-free

6
modules/access/dvb/scan.c

@ -817,7 +817,7 @@ static int scan_Next( scan_t *p_scan, scan_tuner_config_t *p_cfg )
const char *psz_fmt = _("%.1f MHz (%d services)\n~%s remaining"); const char *psz_fmt = _("%.1f MHz (%d services)\n~%s remaining");
if( i_eta >= 0 ) if( i_eta >= 0 )
msg_Info( p_scan->p_obj, "Scan ETA %s | %f", secstotimestr( psz_eta, i_eta/1000000 ), f_position * 100 ); msg_Info( p_scan->p_obj, "Scan ETA %s | %f", secstotimestr( psz_eta, i_eta ), f_position * 100 );
if( p_scan->p_dialog_id == NULL ) if( p_scan->p_dialog_id == NULL )
{ {
@ -827,7 +827,7 @@ static int scan_Next( scan_t *p_scan, scan_tuner_config_t *p_cfg )
_("Scanning DVB"), psz_fmt, _("Scanning DVB"), psz_fmt,
(double)p_cfg->i_frequency / 1000000, (double)p_cfg->i_frequency / 1000000,
i_total_services, i_total_services,
secstotimestr( psz_eta, i_eta/1000000 ) ); secstotimestr( psz_eta, i_eta ) );
} }
else else
{ {
@ -835,7 +835,7 @@ static int scan_Next( scan_t *p_scan, scan_tuner_config_t *p_cfg )
f_position, psz_fmt, f_position, psz_fmt,
(double)p_cfg->i_frequency / 1000000, (double)p_cfg->i_frequency / 1000000,
i_total_services, i_total_services,
secstotimestr( psz_eta, i_eta/1000000 ) ); secstotimestr( psz_eta, i_eta ) );
} }
return VLC_SUCCESS; return VLC_SUCCESS;

2
modules/control/cli/playlist.c

@ -154,7 +154,7 @@ static void print_playlist(struct cli_client *cl, vlc_playlist_t *playlist)
if (len != INPUT_DURATION_INDEFINITE && len != VLC_TICK_INVALID) if (len != INPUT_DURATION_INDEFINITE && len != VLC_TICK_INVALID)
{ {
char buf[MSTRTIME_MAX_SIZE]; char buf[MSTRTIME_MAX_SIZE];
secstotimestr(buf, SEC_FROM_VLC_TICK(len)); secstotimestr(buf, len);
cli_printf(cl, "| %c%zu %s (%s)", selected, i, item->psz_name, buf); cli_printf(cl, "| %c%zu %s (%s)", selected, i, item->psz_name, buf);
} }
else else

6
modules/gui/macosx/extensions/NSString+Helpers.m

@ -59,10 +59,10 @@ NSString *const kVLCMediaUnknown = @"Unknown";
vlc_tick_t remaining = (duration > time) ? (duration - time) : 0; vlc_tick_t remaining = (duration > time) ? (duration - time) : 0;
return [NSString stringWithFormat:@"-%s", return [NSString stringWithFormat:@"-%s",
secstotimestr(psz_time, (int)SEC_FROM_VLC_TICK(remaining))]; secstotimestr(psz_time, remaining)];
} else { } else {
return [NSString stringWithUTF8String: return [NSString stringWithUTF8String:
secstotimestr(psz_time, (int)SEC_FROM_VLC_TICK(time))]; secstotimestr(psz_time, time)];
} }
} }
@ -70,7 +70,7 @@ NSString *const kVLCMediaUnknown = @"Unknown";
{ {
char psz_time[MSTRTIME_MAX_SIZE]; char psz_time[MSTRTIME_MAX_SIZE];
return [NSString stringWithUTF8String: return [NSString stringWithUTF8String:
secstotimestr(psz_time, (int)SEC_FROM_VLC_TICK(time))]; secstotimestr(psz_time, time)];
} }
+ (instancetype)stringWithTime:(long long int)time + (instancetype)stringWithTime:(long long int)time

2
modules/gui/macosx/windows/video/VLCFSPanelController.m

@ -345,7 +345,7 @@ static NSString *kAssociatedFullscreenRect = @"VLCFullscreenAssociatedWindowRect
/* Update current position (left field) */ /* Update current position (left field) */
char psz_time[MSTRTIME_MAX_SIZE]; char psz_time[MSTRTIME_MAX_SIZE];
NSString *playbackPosition = toNSStr(secstotimestr(psz_time, (int)SEC_FROM_VLC_TICK(time))); NSString *playbackPosition = toNSStr(secstotimestr(psz_time, time));
[_elapsedTime setStringValue:playbackPosition]; [_elapsedTime setStringValue:playbackPosition];
} }

4
modules/gui/ncurses.c

@ -967,8 +967,8 @@ static int DrawStatus(intf_thread_t *intf)
/* Fall-through */ /* Fall-through */
default: default:
secstotimestr(buf1, SEC_FROM_VLC_TICK(vlc_player_GetTime(player))); secstotimestr(buf1, vlc_player_GetTime(player));
secstotimestr(buf2, SEC_FROM_VLC_TICK(vlc_player_GetLength(player))); secstotimestr(buf2, vlc_player_GetLength(player));
mvnprintw(y++, 0, COLS, _(" Position : %s/%s"), buf1, buf2); mvnprintw(y++, 0, COLS, _(" Position : %s/%s"), buf1, buf2);

7
src/misc/mtime.c

@ -38,15 +38,16 @@
#include <time.h> #include <time.h>
#include <stdlib.h> #include <stdlib.h>
char *secstotimestr( char *psz_buffer, int32_t i_seconds ) char *secstotimestr( char *psz_buffer, vlc_tick_t ticks )
{ {
if( unlikely(i_seconds < 0) ) if( unlikely(ticks < 0) )
{ {
secstotimestr( psz_buffer + 1, -i_seconds ); secstotimestr( psz_buffer + 1, -ticks );
*psz_buffer = '-'; *psz_buffer = '-';
return psz_buffer; return psz_buffer;
} }
int i_seconds = SEC_FROM_VLC_TICK(ticks);
div_t d; div_t d;
d = div( i_seconds, 60 ); d = div( i_seconds, 60 );

4
src/player/osd.c

@ -142,11 +142,11 @@ vlc_player_osd_Position(vlc_player_t *player,
} }
char time_text[MSTRTIME_MAX_SIZE]; char time_text[MSTRTIME_MAX_SIZE];
secstotimestr(time_text, SEC_FROM_VLC_TICK(time)); secstotimestr(time_text, time);
if (input->length != VLC_TICK_INVALID) if (input->length != VLC_TICK_INVALID)
{ {
char len_text[MSTRTIME_MAX_SIZE]; char len_text[MSTRTIME_MAX_SIZE];
secstotimestr(len_text, SEC_FROM_VLC_TICK(input->length)); secstotimestr(len_text, input->length);
vouts_osd_Message(vouts, count, "%s / %s", time_text, len_text); vouts_osd_Message(vouts, count, "%s / %s", time_text, len_text);
} }
else else

2
src/player/title.c

@ -65,7 +65,7 @@ input_title_GetName(const struct input_title_t *input_title, int idx,
if (input_title->i_length > 0) if (input_title->i_length > 0)
{ {
strcpy(length_str, " ["); strcpy(length_str, " [");
secstotimestr(&length_str[2], SEC_FROM_VLC_TICK(input_title->i_length)); secstotimestr(&length_str[2], input_title->i_length);
strcat(length_str, "]"); strcat(length_str, "]");
} }
else else

Loading…
Cancel
Save