Author: sagamusix
Date: Fri May 3 20:04:50 2024
New Revision: 20697
URL: https://source.openmpt.org/browse/openmpt/?op=revision&rev=20697
Log:
[Fix] xmp-openmpt: For infinite subsong length, don't display a bogus -12:-55 time.
Modified:
trunk/OpenMPT/libopenmpt/xmp-openmpt/xmp-openmpt.cpp
Modified: trunk/OpenMPT/libopenmpt/xmp-openmpt/xmp-openmpt.cpp
==============================================================================
--- trunk/OpenMPT/libopenmpt/xmp-openmpt/xmp-openmpt.cpp Thu May 2 20:04:54 2024 (r20696)
+++ trunk/OpenMPT/libopenmpt/xmp-openmpt/xmp-openmpt.cpp Fri May 3 20:04:50 2024 (r20697)
@@ -20,6 +20,7 @@
#include <cctype>
#include <cstring>
+#include <numeric>
#include <tchar.h>
@@ -234,6 +235,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;
@@ -1278,11 +1282,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() );
}
|