[vlc-commits] [Git][videolan/vlc][master] 3 commits: ticks: use a vlc_tick_t with secstotimestr()
Jean-Baptiste Kempf (@jbk)
gitlab at videolan.org
Sun Aug 22 11:20:33 UTC 2021
Jean-Baptiste Kempf pushed to branch master at VideoLAN / VLC
Commits:
a59cb662 by Steve Lhomme at 2021-08-22T06:53:45+00:00
ticks: use a vlc_tick_t with secstotimestr()
This is what it's always used with. No need for lossy conversions to int.
- - - - -
3475f8e9 by Steve Lhomme at 2021-08-22T06:53:45+00:00
ticks: rename secstotimestr() to vlc_tick_to_str()
- - - - -
c800f8bd by Steve Lhomme at 2021-08-22T06:53:45+00:00
dvb: scan: call vlc_tick_to_str() once for the same value
- - - - -
11 changed files:
- include/vlc_tick.h
- modules/access/dvb/scan.c
- modules/control/cli/playlist.c
- modules/gui/macosx/extensions/NSString+Helpers.m
- modules/gui/macosx/windows/video/VLCFSPanelController.m
- modules/gui/ncurses.c
- src/check_symbols
- src/libvlccore.sym
- src/misc/mtime.c
- src/player/osd.c
- src/player/title.c
Changes:
=====================================
include/vlc_tick.h
=====================================
@@ -190,10 +190,10 @@ struct timespec timespec_from_vlc_tick(vlc_tick_t date);
/*****************************************************************************
- * MSTRTIME_MAX_SIZE: maximum possible size of secstotimestr
+ * MSTRTIME_MAX_SIZE: maximum possible size of vlc_tick_to_str
*****************************************************************************
* This values is the maximal possible size of the string returned by the
- * secstotimestr() function, including '-' and the final '\0'. It should be
+ * vlc_tick_to_str() function, including '-' and the final '\0'. It should be
* used to allocate the buffer.
*****************************************************************************/
#define MSTRTIME_MAX_SIZE 22
@@ -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
* time string in the format h:mm:ss
* 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
* \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 * vlc_tick_to_str( char *psz_buffer, vlc_tick_t ticks );
/**
* \defgroup date Timestamps, error-free
=====================================
modules/access/dvb/scan.c
=====================================
@@ -654,7 +654,7 @@ static int Scan_Next_DVBT( const scan_parameter_t *p_params, scan_enumeration_t
const int i_offset_count = 5;
const int i_mhz = 1000000;
- /* We will probe the whole band divided in all bandwidth possibility trying
+ /* We will probe the whole band divided in all bandwidth possibility trying
* i_offset_count offset around the position
*/
for( ;; p_spectrum->i_index++ )
@@ -815,9 +815,10 @@ static int scan_Next( scan_t *p_scan, scan_tuner_config_t *p_cfg )
const vlc_tick_t i_eta = f_position > 0.005 ? (vlc_tick_now() - p_scan->i_time_start) * ( 1.0 / f_position - 1.0 ) : -1;
char psz_eta[MSTRTIME_MAX_SIZE];
const char *psz_fmt = _("%.1f MHz (%d services)\n~%s remaining");
+ vlc_tick_to_str( psz_eta, i_eta );
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", psz_eta, f_position * 100 );
if( p_scan->p_dialog_id == NULL )
{
@@ -827,7 +828,7 @@ static int scan_Next( scan_t *p_scan, scan_tuner_config_t *p_cfg )
_("Scanning DVB"), psz_fmt,
(double)p_cfg->i_frequency / 1000000,
i_total_services,
- secstotimestr( psz_eta, i_eta/1000000 ) );
+ psz_eta);
}
else
{
@@ -835,7 +836,7 @@ static int scan_Next( scan_t *p_scan, scan_tuner_config_t *p_cfg )
f_position, psz_fmt,
(double)p_cfg->i_frequency / 1000000,
i_total_services,
- secstotimestr( psz_eta, i_eta/1000000 ) );
+ psz_eta );
}
return VLC_SUCCESS;
=====================================
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)
{
char buf[MSTRTIME_MAX_SIZE];
- secstotimestr(buf, SEC_FROM_VLC_TICK(len));
+ vlc_tick_to_str(buf, len);
cli_printf(cl, "| %c%zu %s (%s)", selected, i, item->psz_name, buf);
}
else
=====================================
modules/gui/macosx/extensions/NSString+Helpers.m
=====================================
@@ -59,10 +59,10 @@ NSString *const kVLCMediaUnknown = @"Unknown";
vlc_tick_t remaining = (duration > time) ? (duration - time) : 0;
return [NSString stringWithFormat:@"-%s",
- secstotimestr(psz_time, (int)SEC_FROM_VLC_TICK(remaining))];
+ vlc_tick_to_str(psz_time, remaining)];
} else {
return [NSString stringWithUTF8String:
- secstotimestr(psz_time, (int)SEC_FROM_VLC_TICK(time))];
+ vlc_tick_to_str(psz_time, time)];
}
}
@@ -70,7 +70,7 @@ NSString *const kVLCMediaUnknown = @"Unknown";
{
char psz_time[MSTRTIME_MAX_SIZE];
return [NSString stringWithUTF8String:
- secstotimestr(psz_time, (int)SEC_FROM_VLC_TICK(time))];
+ vlc_tick_to_str(psz_time, time)];
}
+ (instancetype)stringWithTime:(long long int)time
=====================================
modules/gui/macosx/windows/video/VLCFSPanelController.m
=====================================
@@ -345,7 +345,7 @@ static NSString *kAssociatedFullscreenRect = @"VLCFullscreenAssociatedWindowRect
/* Update current position (left field) */
char psz_time[MSTRTIME_MAX_SIZE];
- NSString *playbackPosition = toNSStr(secstotimestr(psz_time, (int)SEC_FROM_VLC_TICK(time)));
+ NSString *playbackPosition = toNSStr(vlc_tick_to_str(psz_time, time));
[_elapsedTime setStringValue:playbackPosition];
}
=====================================
modules/gui/ncurses.c
=====================================
@@ -967,8 +967,8 @@ static int DrawStatus(intf_thread_t *intf)
/* Fall-through */
default:
- secstotimestr(buf1, SEC_FROM_VLC_TICK(vlc_player_GetTime(player)));
- secstotimestr(buf2, SEC_FROM_VLC_TICK(vlc_player_GetLength(player)));
+ vlc_tick_to_str(buf1, vlc_player_GetTime(player));
+ vlc_tick_to_str(buf2, vlc_player_GetLength(player));
mvnprintw(y++, 0, COLS, _(" Position : %s/%s"), buf1, buf2);
=====================================
src/check_symbols
=====================================
@@ -23,7 +23,7 @@ cat libvlccore.sym | grep -v \
-e '^date_' -e '^plane_' \
-e '^us_' -e '^utf8_' -e '^xml_' \
-e '^[A-Z][a-z]*Charset$' \
- -e '^NTPtime64$' -e '^secstotimestr$' \
+ -e '^NTPtime64$' \
&& exit 1
echo "None found."
=====================================
src/libvlccore.sym
=====================================
@@ -250,6 +250,7 @@ vlc_uri_compose
vlc_uri_resolve
vlc_uri_fixup
vlc_tick_now
+vlc_tick_to_str
module_config_free
module_config_get
module_find
@@ -324,7 +325,6 @@ picture_pool_Wait
picture_Reset
picture_Setup
plane_CopyPixels
-secstotimestr
sout_AccessOutControl
sout_AccessOutDelete
sout_AccessOutNew
=====================================
src/misc/mtime.c
=====================================
@@ -38,15 +38,16 @@
#include <time.h>
#include <stdlib.h>
-char *secstotimestr( char *psz_buffer, int32_t i_seconds )
+char *vlc_tick_to_str( char *psz_buffer, vlc_tick_t ticks )
{
- if( unlikely(i_seconds < 0) )
+ if( unlikely(ticks < 0) )
{
- secstotimestr( psz_buffer + 1, -i_seconds );
+ vlc_tick_to_str( psz_buffer + 1, -ticks );
*psz_buffer = '-';
return psz_buffer;
}
+ int i_seconds = SEC_FROM_VLC_TICK(ticks);
div_t d;
d = div( i_seconds, 60 );
=====================================
src/player/osd.c
=====================================
@@ -142,11 +142,11 @@ vlc_player_osd_Position(vlc_player_t *player,
}
char time_text[MSTRTIME_MAX_SIZE];
- secstotimestr(time_text, SEC_FROM_VLC_TICK(time));
+ vlc_tick_to_str(time_text, time);
if (input->length != VLC_TICK_INVALID)
{
char len_text[MSTRTIME_MAX_SIZE];
- secstotimestr(len_text, SEC_FROM_VLC_TICK(input->length));
+ vlc_tick_to_str(len_text, input->length);
vouts_osd_Message(vouts, count, "%s / %s", time_text, len_text);
}
else
=====================================
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)
{
strcpy(length_str, " [");
- secstotimestr(&length_str[2], SEC_FROM_VLC_TICK(input_title->i_length));
+ vlc_tick_to_str(&length_str[2], input_title->i_length);
strcat(length_str, "]");
}
else
View it on GitLab: https://code.videolan.org/videolan/vlc/-/compare/a7e5e0a900771ae460bbd1dfa9dd1ec5cd8bd408...c800f8bdb78d95fa8d35fadb1ba0fbba8627de15
--
View it on GitLab: https://code.videolan.org/videolan/vlc/-/compare/a7e5e0a900771ae460bbd1dfa9dd1ec5cd8bd408...c800f8bdb78d95fa8d35fadb1ba0fbba8627de15
You're receiving this email because of your account on code.videolan.org.
More information about the vlc-commits
mailing list