From: <sv...@op...> - 2024-05-03 18:05:23
|
Author: sagamusix Date: Fri May 3 20:05:16 2024 New Revision: 20698 URL: https://source.openmpt.org/browse/openmpt/?op=revision&rev=20698 Log: Merged revision(s) 20697 from trunk/OpenMPT: [Fix] xmp-openmpt: For infinite subsong length, don't display a bogus -12:-55 time. ........ Modified: branches/OpenMPT-1.31/ (props changed) branches/OpenMPT-1.31/libopenmpt/xmp-openmpt/xmp-openmpt.cpp Modified: branches/OpenMPT-1.31/libopenmpt/xmp-openmpt/xmp-openmpt.cpp ============================================================================== --- branches/OpenMPT-1.31/libopenmpt/xmp-openmpt/xmp-openmpt.cpp Fri May 3 20:04:50 2024 (r20697) +++ branches/OpenMPT-1.31/libopenmpt/xmp-openmpt/xmp-openmpt.cpp Fri May 3 20:05:16 2024 (r20698) @@ -20,6 +20,7 @@ #include <cctype> #include <cstring> +#include <numeric> #include <tchar.h> @@ -244,6 +245,9 @@ } static std::string seconds_to_string( double time ) { + if ( !std::isnormal( time ) ) { + return "?"; + } std::int64_t time_ms = static_cast<std::int64_t>( time * 1000 ); std::int64_t seconds = ( time_ms / 1000 ) % 60; std::int64_t minutes = ( time_ms / ( 1000 * 60 ) ) % 60; @@ -1250,11 +1254,7 @@ } static DWORD WINAPI openmpt_GetSubSongs( float * length ) { - double tmp = 0.0; - for ( auto sub_length : self->subsong_lengths ) { - tmp += sub_length; - } - *length = static_cast<float>( tmp ); + *length = static_cast<float>( std::accumulate( self->subsong_lengths.cbegin(), self->subsong_lengths.cend(), 0.0 ) ); return static_cast<DWORD>( self->subsong_lengths.size() ); } |