From: <man...@us...> - 2013-05-11 19:24:45
|
Revision: 2023 http://sourceforge.net/p/modplug/code/2023 Author: manxorist Date: 2013-05-11 19:24:39 +0000 (Sat, 11 May 2013) Log Message: ----------- Merged revision(s) 2022 from branches/manx/gcc-fixes: [Var] Portability and correctness fixes for libopenmpt and openmpt123. ........ Modified Paths: -------------- trunk/OpenMPT/libopenmpt/libopenmpt.hpp trunk/OpenMPT/libopenmpt/libopenmpt_c.cpp trunk/OpenMPT/libopenmpt/libopenmpt_cxx.cpp trunk/OpenMPT/libopenmpt/libopenmpt_impl.hpp trunk/OpenMPT/libopenmpt/libopenmpt_interactive.cpp trunk/OpenMPT/libopenmpt/libopenmpt_stream_callbacks.h trunk/OpenMPT/openmpt123/openmpt123.cpp Property Changed: ---------------- trunk/OpenMPT/ Index: trunk/OpenMPT =================================================================== --- trunk/OpenMPT 2013-05-11 19:22:37 UTC (rev 2022) +++ trunk/OpenMPT 2013-05-11 19:24:39 UTC (rev 2023) Property changes on: trunk/OpenMPT ___________________________________________________________________ Modified: svn:mergeinfo ## -1,4 +1,5 ## /branches/manx/build-speedup:1586-1589 +/branches/manx/gcc-fixes:2022 /branches/manx/header-dependencies-cleanups:1394-1397,1401-1402,1405-1406 /branches/manx/nonglobal-mixer:1715-1841 /branches/manx/profiler:1813 \ No newline at end of property Modified: trunk/OpenMPT/libopenmpt/libopenmpt.hpp =================================================================== --- trunk/OpenMPT/libopenmpt/libopenmpt.hpp 2013-05-11 19:22:37 UTC (rev 2022) +++ trunk/OpenMPT/libopenmpt/libopenmpt.hpp 2013-05-11 19:24:39 UTC (rev 2023) @@ -25,7 +25,12 @@ class LIBOPENMPT_CXX_API exception : public std::exception { public: - exception( const char * text ); + exception( const char * text ) throw(); + virtual ~exception() throw(); +public: + virtual const char * what() const throw(); +private: + const char * const text; }; // class exception LIBOPENMPT_CXX_API std::uint32_t get_library_version(); @@ -69,7 +74,7 @@ class LIBOPENMPT_CXX_API module { - friend interactive_module; + friend class interactive_module; public: Modified: trunk/OpenMPT/libopenmpt/libopenmpt_c.cpp =================================================================== --- trunk/OpenMPT/libopenmpt/libopenmpt_c.cpp 2013-05-11 19:22:37 UTC (rev 2022) +++ trunk/OpenMPT/libopenmpt/libopenmpt_c.cpp 2013-05-11 19:24:39 UTC (rev 2023) @@ -15,6 +15,8 @@ #include "libopenmpt_impl.hpp" +#include <stdexcept> + #include <cmath> #include <cstdlib> #include <cstring> @@ -331,12 +333,12 @@ return 0; } -void openmpt_log_func_default( const char * message, void * user ) { +void openmpt_log_func_default( const char * message, void * /*user*/ ) { fprintf( stderr, "%s\n", message ); fflush( stderr ); } -void openmpt_log_func_silent( const char * message, void * user ) { +void openmpt_log_func_silent( const char * /*message*/, void * /*user*/ ) { return; } @@ -434,7 +436,7 @@ double openmpt_module_seek_seconds( openmpt_module * mod, double seconds ) { try { OPENMPT_INTERFACE_CHECK_SOUNDFILE( mod ); - return mod->impl->get_current_position_seconds(); + return mod->impl->seek_seconds( seconds ); } OPENMPT_INTERFACE_CATCH_TO_LOG; return 0; } Modified: trunk/OpenMPT/libopenmpt/libopenmpt_cxx.cpp =================================================================== --- trunk/OpenMPT/libopenmpt/libopenmpt_cxx.cpp 2013-05-11 19:22:37 UTC (rev 2022) +++ trunk/OpenMPT/libopenmpt/libopenmpt_cxx.cpp 2013-05-11 19:24:39 UTC (rev 2023) @@ -15,15 +15,24 @@ #include "libopenmpt_impl.hpp" #include <algorithm> +#include <stdexcept> //#ifndef NO_LIBOPENMPT_CXX namespace openmpt { -exception::exception( const char * text ) : std::exception( text ) { +exception::exception( const char * text_ ) throw() : text(text_) { return; } +exception::~exception() throw() { + return; +} + +const char * exception::what() const throw() { + return text; +} + std::uint32_t get_library_version() { return openmpt::version::get_library_version(); } Modified: trunk/OpenMPT/libopenmpt/libopenmpt_impl.hpp =================================================================== --- trunk/OpenMPT/libopenmpt/libopenmpt_impl.hpp 2013-05-11 19:22:37 UTC (rev 2022) +++ trunk/OpenMPT/libopenmpt/libopenmpt_impl.hpp 2013-05-11 19:24:39 UTC (rev 2023) @@ -125,8 +125,8 @@ } void apply_mixer_settings( std::int32_t samplerate, int channels, SampleFormat format ) { if ( - m_sndFile.m_MixerSettings.gdwMixingFreq != samplerate || - m_sndFile.m_MixerSettings.gnChannels != channels || + static_cast<std::int32_t>( m_sndFile.m_MixerSettings.gdwMixingFreq ) != samplerate || + static_cast<int>( m_sndFile.m_MixerSettings.gnChannels ) != channels || m_sndFile.m_MixerSettings.m_SampleFormat != format ) { MixerSettings mixersettings = m_sndFile.m_MixerSettings; @@ -249,6 +249,7 @@ case SRCMODE_LINEAR: return module::INTERPOLATION_LINEAR; break; case SRCMODE_SPLINE: return module::INTERPOLATION_SPLINE; break; case SRCMODE_POLYPHASE: return module::INTERPOLATION_POLYPHASE; break; + case SRCMODE_DEFAULT: case SRCMODE_FIRFILTER: { switch ( m_sndFile.m_Resampler.m_Settings.gbWFIRType ) { case WFIR_HANN: return module::INTERPOLATION_FIR_HANN; break; @@ -261,6 +262,9 @@ case WFIR_KAISER4T: return module::INTERPOLATION_FIR_KAISER4T; break; } } break; + case NUM_SRC_MODES: + default: + break; } throw exception("unknown interpolation mode set internally"); } break; @@ -278,7 +282,7 @@ switch ( command ) { case module::RENDER_MASTERGAIN_DB: { float gainFactor = static_cast<float>( std::pow( 10.0f, value * 0.1f * 0.5f ) ); - if ( m_sndFile.m_MixerSettings.m_FinalOutputGain != float_to_fx16( gainFactor ) ) { + if ( static_cast<std::int32_t>( m_sndFile.m_MixerSettings.m_FinalOutputGain ) != float_to_fx16( gainFactor ) ) { MixerSettings settings = m_sndFile.m_MixerSettings; settings.m_FinalOutputGain = float_to_fx16( gainFactor ); m_sndFile.SetMixerSettings( settings ); @@ -286,7 +290,7 @@ } break; case module::RENDER_STEREOSEPARATION_PERCENT: { std::int32_t newvalue = value * 128 / 100; - if ( newvalue != m_sndFile.m_MixerSettings.m_nStereoSeparation ) { + if ( newvalue != static_cast<std::int32_t>( m_sndFile.m_MixerSettings.m_nStereoSeparation ) ) { MixerSettings settings = m_sndFile.m_MixerSettings; settings.gdwMixingFreq = newvalue; m_sndFile.SetMixerSettings( settings ); @@ -299,7 +303,7 @@ set_quality( value ); } break; case module::RENDER_MAXMIXCHANNELS: { - if ( value != m_sndFile.m_MixerSettings.m_nMaxMixChannels ) { + if ( value != static_cast<std::int32_t>( m_sndFile.m_MixerSettings.m_nMaxMixChannels ) ) { MixerSettings settings = m_sndFile.m_MixerSettings; settings.m_nMaxMixChannels = value; m_sndFile.SetMixerSettings( settings ); Modified: trunk/OpenMPT/libopenmpt/libopenmpt_interactive.cpp =================================================================== --- trunk/OpenMPT/libopenmpt/libopenmpt_interactive.cpp 2013-05-11 19:22:37 UTC (rev 2022) +++ trunk/OpenMPT/libopenmpt/libopenmpt_interactive.cpp 2013-05-11 19:24:39 UTC (rev 2023) @@ -5,6 +5,8 @@ #include "libopenmpt_interactive.hpp" #include "libopenmpt_impl.hpp" +#include <stdexcept> + namespace openmpt { class interactive_module_impl : public module_impl { Modified: trunk/OpenMPT/libopenmpt/libopenmpt_stream_callbacks.h =================================================================== --- trunk/OpenMPT/libopenmpt/libopenmpt_stream_callbacks.h 2013-05-11 19:22:37 UTC (rev 2022) +++ trunk/OpenMPT/libopenmpt/libopenmpt_stream_callbacks.h 2013-05-11 19:24:39 UTC (rev 2023) @@ -12,10 +12,15 @@ #include "libopenmpt.h" +#ifdef _MSC_VER #include <io.h> +#endif #include <stdint.h> #include <stdio.h> #include <string.h> +#ifndef _MSC_VER +#include <unistd.h> +#endif #ifdef __cplusplus extern "C" { Modified: trunk/OpenMPT/openmpt123/openmpt123.cpp =================================================================== --- trunk/OpenMPT/openmpt123/openmpt123.cpp 2013-05-11 19:22:37 UTC (rev 2022) +++ trunk/OpenMPT/openmpt123/openmpt123.cpp 2013-05-11 19:24:39 UTC (rev 2023) @@ -20,6 +20,7 @@ #include <vector> #include <cstdint> +#include <cstring> #if defined(_MSC_VER) #include <fcntl.h> @@ -33,25 +34,25 @@ #include <portaudio.h> -struct show_help_exception : public std::exception { +struct show_help_exception { std::string message; show_help_exception( const std::string & msg = "" ) : message(msg) { } }; -struct openmpt123_exception : public std::exception { - openmpt123_exception( const char * text ) : std::exception( text ) { } +struct openmpt123_exception : public openmpt::exception { + openmpt123_exception( const char * text ) throw() : openmpt::exception( text ) { } }; struct silent_exit_exception : public std::exception { - silent_exit_exception() { } + silent_exit_exception() throw() { } }; struct show_version_number_exception : public std::exception { - show_version_number_exception() { } + show_version_number_exception() throw() { } }; -struct portaudio_exception : public std::exception { - portaudio_exception( PaError code ) : std::exception( Pa_GetErrorText( code ) ) { } +struct portaudio_exception : public openmpt::exception { + portaudio_exception( PaError code ) throw() : openmpt::exception( Pa_GetErrorText( code ) ) { } }; struct openmpt123_flags { @@ -196,7 +197,7 @@ if ( verbose ) { portaudio_log_stream = &log; } else { - portaudio_log_stream = nullptr; + portaudio_log_stream = 0; } PaUtil_SetDebugPrintFunction( portaudio_log_function ); log_set = true; @@ -213,13 +214,13 @@ } if ( log_set ) { PaUtil_SetDebugPrintFunction( NULL ); - portaudio_log_stream = nullptr; + portaudio_log_stream = 0; log_set = false; } } }; -std::ostream * portaudio_raii::portaudio_log_stream = nullptr; +std::ostream * portaudio_raii::portaudio_log_stream = 0; class write_buffers_interface { public: @@ -454,8 +455,6 @@ bool use_stdin = ( filename == "-" ); if ( !use_stdin ) { file_stream.open( filename, std::ios::binary ); - } else { - stdin_stream.setf( std::ios::binary ); } std::istream & data_stream = use_stdin ? stdin_stream : file_stream; if ( data_stream.fail() ) { This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <man...@us...> - 2013-05-12 09:50:42
|
Revision: 2049 http://sourceforge.net/p/modplug/code/2049 Author: manxorist Date: 2013-05-12 09:50:36 +0000 (Sun, 12 May 2013) Log Message: ----------- Merged revision(s) 2041-2042 from branches/manx/gcc-fixes: [Ref] Fix gcc warnings in libopenmpt. ........ [Ref] Only use PaUtil_SetDebugPrintFunction() in MSVC builds in openmpt123. ........ Modified Paths: -------------- trunk/OpenMPT/libopenmpt/libopenmpt_cxx.cpp trunk/OpenMPT/libopenmpt/libopenmpt_interactive.cpp trunk/OpenMPT/libopenmpt/libopenmpt_internal.h trunk/OpenMPT/libopenmpt/libopenmpt_stream_callbacks.h trunk/OpenMPT/libopenmpt/libopenmpt_version.cpp trunk/OpenMPT/openmpt123/openmpt123.cpp Property Changed: ---------------- trunk/OpenMPT/ Index: trunk/OpenMPT =================================================================== --- trunk/OpenMPT 2013-05-12 09:47:17 UTC (rev 2048) +++ trunk/OpenMPT 2013-05-12 09:50:36 UTC (rev 2049) Property changes on: trunk/OpenMPT ___________________________________________________________________ Modified: svn:mergeinfo ## -1,5 +1,5 ## /branches/manx/build-speedup:1586-1589 -/branches/manx/gcc-fixes:2022 +/branches/manx/gcc-fixes:2022,2041-2042 /branches/manx/header-dependencies-cleanups:1394-1397,1401-1402,1405-1406 /branches/manx/nonglobal-mixer:1715-1841 /branches/manx/profiler:1813 \ No newline at end of property Modified: trunk/OpenMPT/libopenmpt/libopenmpt_cxx.cpp =================================================================== --- trunk/OpenMPT/libopenmpt/libopenmpt_cxx.cpp 2013-05-12 09:47:17 UTC (rev 2048) +++ trunk/OpenMPT/libopenmpt/libopenmpt_cxx.cpp 2013-05-12 09:50:36 UTC (rev 2049) @@ -99,7 +99,7 @@ impl = new module_impl( data, std::make_shared<std_ostream_log>( log ) ); } -module::module( const char * beg, const char * end, std::ostream & log, const detail::api_version_checker & apicheck ) : impl(0) { +module::module( const char * beg, const char * end, std::ostream & log, const detail::api_version_checker & ) : impl(0) { impl = new module_impl( beg, end - beg, std::make_shared<std_ostream_log>( log ) ); } Modified: trunk/OpenMPT/libopenmpt/libopenmpt_interactive.cpp =================================================================== --- trunk/OpenMPT/libopenmpt/libopenmpt_interactive.cpp 2013-05-12 09:47:17 UTC (rev 2048) +++ trunk/OpenMPT/libopenmpt/libopenmpt_interactive.cpp 2013-05-12 09:50:36 UTC (rev 2049) @@ -98,7 +98,7 @@ delete interactive_impl; interactive_impl = nullptr; } -interactive_module::interactive_module( const interactive_module & ) { +interactive_module::interactive_module( const interactive_module & other ) : module(other) { throw std::runtime_error("openmpt::interactive_module is non-copyable"); } void interactive_module::operator = ( const interactive_module & ) { Modified: trunk/OpenMPT/libopenmpt/libopenmpt_internal.h =================================================================== --- trunk/OpenMPT/libopenmpt/libopenmpt_internal.h 2013-05-12 09:47:17 UTC (rev 2048) +++ trunk/OpenMPT/libopenmpt/libopenmpt_internal.h 2013-05-12 09:50:36 UTC (rev 2049) @@ -60,8 +60,12 @@ #ifdef __cplusplus namespace openmpt { namespace version { +#ifndef NO_WINAMP extern char * in_openmpt_string; +#endif // NO_WINAMP +#ifndef NO_XMPLAY extern const char * xmp_openmpt_string; +#endif // NO_XMPLAY } } // namespace openmpt::version #endif Modified: trunk/OpenMPT/libopenmpt/libopenmpt_stream_callbacks.h =================================================================== --- trunk/OpenMPT/libopenmpt/libopenmpt_stream_callbacks.h 2013-05-12 09:47:17 UTC (rev 2048) +++ trunk/OpenMPT/libopenmpt/libopenmpt_stream_callbacks.h 2013-05-12 09:50:36 UTC (rev 2049) @@ -77,14 +77,14 @@ return retval; } -static openmpt_stream_callbacks openmpt_stream_get_fd_callbacks(void) { +static inline openmpt_stream_callbacks openmpt_stream_get_fd_callbacks(void) { openmpt_stream_callbacks retval; memset( &retval, 0, sizeof( openmpt_stream_callbacks ) ); retval.read = openmpt_stream_fd_read_func; return retval; } -static openmpt_stream_callbacks openmpt_stream_get_file_callbacks(void) { +static inline openmpt_stream_callbacks openmpt_stream_get_file_callbacks(void) { openmpt_stream_callbacks retval; memset( &retval, 0, sizeof( openmpt_stream_callbacks ) ); retval.read = openmpt_stream_file_read_func; Modified: trunk/OpenMPT/libopenmpt/libopenmpt_version.cpp =================================================================== --- trunk/OpenMPT/libopenmpt/libopenmpt_version.cpp 2013-05-12 09:47:17 UTC (rev 2048) +++ trunk/OpenMPT/libopenmpt/libopenmpt_version.cpp 2013-05-12 09:50:36 UTC (rev 2049) @@ -95,9 +95,13 @@ #define OPENMPT_API_VERSION_STRING STRINGIZE(OPENMPT_API_VERSION_MAJOR)"."STRINGIZE(OPENMPT_API_VERSION_MINOR) +#ifndef NO_WINAMP char * in_openmpt_string = "in_openmpt " OPENMPT_API_VERSION_STRING "." STRINGIZE(OPENMPT_VERSION_REVISION); +#endif // NO_WINAMP +#ifndef NO_XMPLAY const char * xmp_openmpt_string = "OpenMPT (" OPENMPT_API_VERSION_STRING "." STRINGIZE(OPENMPT_VERSION_REVISION) ")"; +#endif // NO_XMPLAY } // namespace version Modified: trunk/OpenMPT/openmpt123/openmpt123.cpp =================================================================== --- trunk/OpenMPT/openmpt123/openmpt123.cpp 2013-05-12 09:47:17 UTC (rev 2048) +++ trunk/OpenMPT/openmpt123/openmpt123.cpp 2013-05-12 09:50:36 UTC (rev 2049) @@ -168,7 +168,9 @@ } typedef void (*PaUtilLogCallback ) (const char *log); +#ifdef _MSC_VER extern "C" void PaUtil_SetDebugPrintFunction(PaUtilLogCallback cb); +#endif class portaudio_raii { private: @@ -199,8 +201,10 @@ } else { portaudio_log_stream = 0; } +#ifdef _MSC_VER PaUtil_SetDebugPrintFunction( portaudio_log_function ); log_set = true; +#endif check_portaudio_error( Pa_Initialize() ); portaudio_initialized = true; if ( verbose ) { @@ -213,10 +217,12 @@ portaudio_initialized = false; } if ( log_set ) { +#ifdef _MSC_VER PaUtil_SetDebugPrintFunction( NULL ); - portaudio_log_stream = 0; log_set = false; +#endif } + portaudio_log_stream = 0; } }; This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <man...@us...> - 2013-05-12 10:02:07
|
Revision: 2050 http://sourceforge.net/p/modplug/code/2050 Author: manxorist Date: 2013-05-12 10:02:01 +0000 (Sun, 12 May 2013) Log Message: ----------- [Ref] Simplify openmpt::exception. Modified Paths: -------------- trunk/OpenMPT/libopenmpt/libopenmpt.hpp trunk/OpenMPT/libopenmpt/libopenmpt_c.cpp trunk/OpenMPT/libopenmpt/libopenmpt_cxx.cpp trunk/OpenMPT/libopenmpt/libopenmpt_impl.hpp trunk/OpenMPT/libopenmpt/libopenmpt_version.cpp trunk/OpenMPT/openmpt123/openmpt123.cpp Modified: trunk/OpenMPT/libopenmpt/libopenmpt.hpp =================================================================== --- trunk/OpenMPT/libopenmpt/libopenmpt.hpp 2013-05-12 09:50:36 UTC (rev 2049) +++ trunk/OpenMPT/libopenmpt/libopenmpt.hpp 2013-05-12 10:02:01 UTC (rev 2050) @@ -25,12 +25,10 @@ class LIBOPENMPT_CXX_API exception : public std::exception { public: - exception( const char * text ) throw(); + exception() throw(); virtual ~exception() throw(); public: virtual const char * what() const throw(); -private: - const char * const text; }; // class exception LIBOPENMPT_CXX_API std::uint32_t get_library_version(); Modified: trunk/OpenMPT/libopenmpt/libopenmpt_c.cpp =================================================================== --- trunk/OpenMPT/libopenmpt/libopenmpt_c.cpp 2013-05-12 09:50:36 UTC (rev 2049) +++ trunk/OpenMPT/libopenmpt/libopenmpt_c.cpp 2013-05-12 10:02:01 UTC (rev 2050) @@ -254,7 +254,7 @@ #define OPENMPT_INTERFACE_CHECK_SOUNDFILE( mod ) \ do { \ if ( !(mod) ) { \ - throw openmpt::exception("module * not valid"); \ + throw openmpt::exception_message("module * not valid"); \ } \ } while(0) \ /**/ @@ -262,7 +262,7 @@ #define OPENMPT_INTERFACE_CHECK_POINTER( value ) \ do { \ if ( !(value) ) { \ - throw openmpt::exception("null pointer"); \ + throw openmpt::exception_message("null pointer"); \ } \ } while(0) \ /**/ Modified: trunk/OpenMPT/libopenmpt/libopenmpt_cxx.cpp =================================================================== --- trunk/OpenMPT/libopenmpt/libopenmpt_cxx.cpp 2013-05-12 09:50:36 UTC (rev 2049) +++ trunk/OpenMPT/libopenmpt/libopenmpt_cxx.cpp 2013-05-12 10:02:01 UTC (rev 2050) @@ -21,7 +21,7 @@ namespace openmpt { -exception::exception( const char * text_ ) throw() : text(text_) { +exception::exception() throw() { return; } @@ -30,7 +30,7 @@ } const char * exception::what() const throw() { - return text; + return ""; } std::uint32_t get_library_version() { Modified: trunk/OpenMPT/libopenmpt/libopenmpt_impl.hpp =================================================================== --- trunk/OpenMPT/libopenmpt/libopenmpt_impl.hpp 2013-05-12 09:50:36 UTC (rev 2049) +++ trunk/OpenMPT/libopenmpt/libopenmpt_impl.hpp 2013-05-12 10:02:01 UTC (rev 2050) @@ -41,6 +41,18 @@ } // namespace version +class exception_message : public exception { +public: + exception_message( const char * text_ ) throw() : text(text_) { } + virtual ~exception_message() throw() { } +public: + virtual const char * what() const throw() { + return text; + } +private: + const char * text; +}; // class exception_message + class log_interface : public ILog { protected: log_interface() { @@ -146,7 +158,7 @@ } static void load( CSoundFile & sndFile, FileReader file ) { if ( !sndFile.Create( file, CSoundFile::loadCompleteModule ) ) { - throw openmpt::exception("error loading file"); + throw openmpt::exception_message("error loading file"); } } void load( FileReader file ) { @@ -266,7 +278,7 @@ default: break; } - throw exception("unknown interpolation mode set internally"); + throw openmpt::exception_message("unknown interpolation mode set internally"); } break; case module::RENDER_VOLUMERAMP_IN_SAMPLES: { return m_sndFile.m_MixerSettings.glVolumeRampUpSamples; @@ -274,7 +286,7 @@ case module::RENDER_VOLUMERAMP_OUT_SAMPLES: { return m_sndFile.m_MixerSettings.glVolumeRampDownSamples; } break; - default: throw exception("unknown command"); break; + default: throw openmpt::exception_message("unknown command"); break; } return 0; } @@ -343,12 +355,12 @@ m_sndFile.SetMixerSettings( settings ); } } break; - default: throw exception("unknown command"); break; + default: throw openmpt::exception_message("unknown command"); break; } } std::size_t read( std::int32_t samplerate, std::size_t count, std::int16_t * mono ) { if ( !mono ) { - throw exception("null pointer"); + throw openmpt::exception_message("null pointer"); } apply_mixer_settings( samplerate, 1, SampleFormatInt16 ); m_int16Buffer.resize( count * 1 ); @@ -361,7 +373,7 @@ } std::size_t read( std::int32_t samplerate, std::size_t count, std::int16_t * left, std::int16_t * right ) { if ( !left || !right ) { - throw exception("null pointer"); + throw openmpt::exception_message("null pointer"); } apply_mixer_settings( samplerate, 2, SampleFormatInt16 ); m_int16Buffer.resize( count * 2 ); @@ -375,7 +387,7 @@ } std::size_t read( std::int32_t samplerate, std::size_t count, std::int16_t * left, std::int16_t * right, std::int16_t * back_left, std::int16_t * back_right ) { if ( !left || !right || !back_left || !back_right ) { - throw exception("null pointer"); + throw openmpt::exception_message("null pointer"); } apply_mixer_settings( samplerate, 4, SampleFormatInt16 ); m_int16Buffer.resize( count * 4 ); @@ -391,7 +403,7 @@ } std::size_t read( std::int32_t samplerate, std::size_t count, float * mono ) { if ( !mono ) { - throw exception("null pointer"); + throw openmpt::exception_message("null pointer"); } apply_mixer_settings( samplerate, 1, SampleFormatFloat32 ); m_floatBuffer.resize( count * 1 ); @@ -404,7 +416,7 @@ } std::size_t read( std::int32_t samplerate, std::size_t count, float * left, float * right ) { if ( !left || !right ) { - throw exception("null pointer"); + throw openmpt::exception_message("null pointer"); } apply_mixer_settings( samplerate, 2, SampleFormatFloat32 ); m_floatBuffer.resize( count * 2 ); @@ -418,7 +430,7 @@ } std::size_t read( std::int32_t samplerate, std::size_t count, float * left, float * right, float * back_left, float * back_right ) { if ( !left || !right || !back_left || !back_right ) { - throw exception("null pointer"); + throw openmpt::exception_message("null pointer"); } apply_mixer_settings( samplerate, 4, SampleFormatFloat32 ); m_floatBuffer.resize( count * 4 ); Modified: trunk/OpenMPT/libopenmpt/libopenmpt_version.cpp =================================================================== --- trunk/OpenMPT/libopenmpt/libopenmpt_version.cpp 2013-05-12 09:50:36 UTC (rev 2049) +++ trunk/OpenMPT/libopenmpt/libopenmpt_version.cpp 2013-05-12 10:02:01 UTC (rev 2050) @@ -107,9 +107,18 @@ namespace detail { +class version_mismatch : public openmpt::exception { +public: + version_mismatch() throw() { } + virtual ~version_mismatch() throw() { } + virtual const char * what() const throw() { + return "API and header version mismatch"; + } +}; // class version_mismatch + void version_compatible_or_throw( std::int32_t api_version ) { if ( version::get_version_compatbility( api_version ) < 2 ) { - throw exception( "API and header version mismatch" ); + throw version_mismatch(); } } Modified: trunk/OpenMPT/openmpt123/openmpt123.cpp =================================================================== --- trunk/OpenMPT/openmpt123/openmpt123.cpp 2013-05-12 09:50:36 UTC (rev 2049) +++ trunk/OpenMPT/openmpt123/openmpt123.cpp 2013-05-12 10:02:01 UTC (rev 2050) @@ -40,7 +40,11 @@ }; struct openmpt123_exception : public openmpt::exception { - openmpt123_exception( const char * text ) throw() : openmpt::exception( text ) { } + openmpt123_exception( const char * text_ ) throw() : text(text_) { } + virtual const char * what() const throw() { + return text; + } + const char * text; }; struct silent_exit_exception : public std::exception { @@ -51,8 +55,8 @@ show_version_number_exception() throw() { } }; -struct portaudio_exception : public openmpt::exception { - portaudio_exception( PaError code ) throw() : openmpt::exception( Pa_GetErrorText( code ) ) { } +struct portaudio_exception : public openmpt123_exception { + portaudio_exception( PaError code ) throw() : openmpt123_exception( Pa_GetErrorText( code ) ) { } }; struct openmpt123_flags { This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <man...@us...> - 2013-05-13 20:49:05
|
Revision: 2081 http://sourceforge.net/p/modplug/code/2081 Author: manxorist Date: 2013-05-13 20:48:55 +0000 (Mon, 13 May 2013) Log Message: ----------- [Mod] Change the unit of volume ramping from samples to microseconds in libopenmpt. [Fix] Apply volume ramping settings in winamp and xmplay plugins. Modified Paths: -------------- trunk/OpenMPT/libopenmpt/SettingsForm.h trunk/OpenMPT/libopenmpt/libopenmpt.h trunk/OpenMPT/libopenmpt/libopenmpt.hpp trunk/OpenMPT/libopenmpt/libopenmpt_impl.hpp trunk/OpenMPT/libopenmpt/libopenmpt_settings.h trunk/OpenMPT/libopenmpt/libopenmpt_winamp.cpp trunk/OpenMPT/libopenmpt/libopenmpt_xmplay.cpp trunk/OpenMPT/openmpt123/openmpt123.cpp trunk/OpenMPT/soundlib/MixerSettings.cpp trunk/OpenMPT/soundlib/MixerSettings.h Modified: trunk/OpenMPT/libopenmpt/SettingsForm.h =================================================================== --- trunk/OpenMPT/libopenmpt/SettingsForm.h 2013-05-13 18:21:56 UTC (rev 2080) +++ trunk/OpenMPT/libopenmpt/SettingsForm.h 2013-05-13 20:48:55 UTC (rev 2081) @@ -57,8 +57,8 @@ trackBarStereoSeparation->Value = settings->stereoseparation; - trackBarVolrampin->Value = settings->volrampin; - trackBarVolrampout->Value = settings->volrampout; + trackBarVolrampin->Value = settings->volrampinus; + trackBarVolrampout->Value = settings->volrampoutus; // //TODO: Add the constructor code here @@ -315,28 +315,28 @@ // // trackBarVolrampin // - this->trackBarVolrampin->LargeChange = 16; + this->trackBarVolrampin->LargeChange = 1000; this->trackBarVolrampin->Location = System::Drawing::Point(106, 261); - this->trackBarVolrampin->Maximum = 256; + this->trackBarVolrampin->Maximum = 10000; this->trackBarVolrampin->Name = L"trackBarVolrampin"; this->trackBarVolrampin->Size = System::Drawing::Size(121, 42); this->trackBarVolrampin->TabIndex = 17; - this->trackBarVolrampin->TickFrequency = 16; + this->trackBarVolrampin->TickFrequency = 1000; this->trackBarVolrampin->TickStyle = System::Windows::Forms::TickStyle::Both; - this->trackBarVolrampin->Value = 16; + this->trackBarVolrampin->Value = 363; this->trackBarVolrampin->Scroll += gcnew System::EventHandler(this, &SettingsForm::trackBarVolrampin_Scroll); // // trackBarVolrampout // - this->trackBarVolrampout->LargeChange = 16; + this->trackBarVolrampout->LargeChange = 1000; this->trackBarVolrampout->Location = System::Drawing::Point(106, 309); - this->trackBarVolrampout->Maximum = 256; + this->trackBarVolrampout->Maximum = 10000; this->trackBarVolrampout->Name = L"trackBarVolrampout"; this->trackBarVolrampout->Size = System::Drawing::Size(121, 42); this->trackBarVolrampout->TabIndex = 18; - this->trackBarVolrampout->TickFrequency = 16; + this->trackBarVolrampout->TickFrequency = 1000; this->trackBarVolrampout->TickStyle = System::Windows::Forms::TickStyle::Both; - this->trackBarVolrampout->Value = 42; + this->trackBarVolrampout->Value = 952; this->trackBarVolrampout->Scroll += gcnew System::EventHandler(this, &SettingsForm::trackBarVolrampout_Scroll); // // SettingsForm @@ -419,11 +419,11 @@ settings->changed(); } private: System::Void trackBarVolrampin_Scroll(System::Object^ sender, System::EventArgs^ e) { - settings->volrampin = (int)trackBarVolrampin->Value; + settings->volrampinus = (int)trackBarVolrampin->Value; settings->changed(); } private: System::Void trackBarVolrampout_Scroll(System::Object^ sender, System::EventArgs^ e) { - settings->volrampout = (int)trackBarVolrampout->Value; + settings->volrampoutus = (int)trackBarVolrampout->Value; settings->changed(); } }; Modified: trunk/OpenMPT/libopenmpt/libopenmpt.h =================================================================== --- trunk/OpenMPT/libopenmpt/libopenmpt.h 2013-05-13 18:21:56 UTC (rev 2080) +++ trunk/OpenMPT/libopenmpt/libopenmpt.h 2013-05-13 20:48:55 UTC (rev 2081) @@ -69,8 +69,8 @@ #define OPENMPT_MODULE_RENDER_QUALITY_PERCENT 4 #define OPENMPT_MODULE_RENDER_MAXMIXCHANNELS 5 #define OPENMPT_MODULE_RENDER_INTERPOLATION_MODE 6 -#define OPENMPT_MODULE_RENDER_VOLUMERAMP_IN_SAMPLES 7 -#define OPENMPT_MODULE_RENDER_VOLUMERAMP_OUT_SAMPLES 8 +#define OPENMPT_MODULE_RENDER_VOLUMERAMP_IN_US 7 +#define OPENMPT_MODULE_RENDER_VOLUMERAMP_OUT_US 8 #define OPENMPT_MODULE_RENDER_INTERPOLATION_NEAREST 1 #define OPENMPT_MODULE_RENDER_INTERPOLATION_LINEAR 2 Modified: trunk/OpenMPT/libopenmpt/libopenmpt.hpp =================================================================== --- trunk/OpenMPT/libopenmpt/libopenmpt.hpp 2013-05-13 18:21:56 UTC (rev 2080) +++ trunk/OpenMPT/libopenmpt/libopenmpt.hpp 2013-05-13 20:48:55 UTC (rev 2081) @@ -83,8 +83,8 @@ RENDER_QUALITY_PERCENT = 4, RENDER_MAXMIXCHANNELS = 5, RENDER_INTERPOLATION_MODE = 6, - RENDER_VOLUMERAMP_IN_SAMPLES = 7, - RENDER_VOLUMERAMP_OUT_SAMPLES = 8, + RENDER_VOLUMERAMP_IN_US = 7, + RENDER_VOLUMERAMP_OUT_US = 8, }; enum interpolation_mode { Modified: trunk/OpenMPT/libopenmpt/libopenmpt_impl.hpp =================================================================== --- trunk/OpenMPT/libopenmpt/libopenmpt_impl.hpp 2013-05-13 18:21:56 UTC (rev 2080) +++ trunk/OpenMPT/libopenmpt/libopenmpt_impl.hpp 2013-05-13 20:48:55 UTC (rev 2081) @@ -142,9 +142,13 @@ m_sndFile.m_MixerSettings.m_SampleFormat != format ) { MixerSettings mixersettings = m_sndFile.m_MixerSettings; + std::int32_t volrampin_us = mixersettings.GetVolumeRampUpMicroseconds(); + std::int32_t volrampout_us = mixersettings.GetVolumeRampDownMicroseconds(); mixersettings.gdwMixingFreq = samplerate; mixersettings.gnChannels = channels; mixersettings.m_SampleFormat = format; + mixersettings.SetVolumeRampUpMicroseconds( volrampin_us ); + mixersettings.SetVolumeRampDownMicroseconds( volrampout_us ); m_sndFile.SetMixerSettings( mixersettings ); } } @@ -280,11 +284,11 @@ } throw openmpt::exception_message("unknown interpolation mode set internally"); } break; - case module::RENDER_VOLUMERAMP_IN_SAMPLES: { - return m_sndFile.m_MixerSettings.glVolumeRampUpSamples; + case module::RENDER_VOLUMERAMP_IN_US: { + return m_sndFile.m_MixerSettings.GetVolumeRampUpMicroseconds(); } break; - case module::RENDER_VOLUMERAMP_OUT_SAMPLES: { - return m_sndFile.m_MixerSettings.glVolumeRampDownSamples; + case module::RENDER_VOLUMERAMP_OUT_US: { + return m_sndFile.m_MixerSettings.GetVolumeRampDownMicroseconds(); } break; default: throw openmpt::exception_message("unknown command"); break; } @@ -341,18 +345,18 @@ m_sndFile.SetResamplerSettings( newsettings ); } } break; - case module::RENDER_VOLUMERAMP_IN_SAMPLES: { - if ( m_sndFile.m_MixerSettings.glVolumeRampUpSamples != value ) { - MixerSettings settings = m_sndFile.m_MixerSettings; - settings.glVolumeRampUpSamples = value; - m_sndFile.SetMixerSettings( settings ); + case module::RENDER_VOLUMERAMP_IN_US: { + MixerSettings newsettings = m_sndFile.m_MixerSettings; + newsettings.SetVolumeRampUpMicroseconds( value ); + if ( m_sndFile.m_MixerSettings.glVolumeRampUpSamples != newsettings.glVolumeRampUpSamples ) { + m_sndFile.SetMixerSettings( newsettings ); } } break; - case module::RENDER_VOLUMERAMP_OUT_SAMPLES: { - if ( m_sndFile.m_MixerSettings.glVolumeRampDownSamples != value ) { - MixerSettings settings = m_sndFile.m_MixerSettings; - settings.glVolumeRampDownSamples = value; - m_sndFile.SetMixerSettings( settings ); + case module::RENDER_VOLUMERAMP_OUT_US: { + MixerSettings newsettings = m_sndFile.m_MixerSettings; + newsettings.SetVolumeRampDownMicroseconds( value ); + if ( m_sndFile.m_MixerSettings.glVolumeRampDownSamples != newsettings.glVolumeRampDownSamples ) { + m_sndFile.SetMixerSettings( newsettings ); } } break; default: throw openmpt::exception_message("unknown command"); break; Modified: trunk/OpenMPT/libopenmpt/libopenmpt_settings.h =================================================================== --- trunk/OpenMPT/libopenmpt/libopenmpt_settings.h 2013-05-13 18:21:56 UTC (rev 2080) +++ trunk/OpenMPT/libopenmpt/libopenmpt_settings.h 2013-05-13 20:48:55 UTC (rev 2081) @@ -42,8 +42,8 @@ int repeatcount; int maxmixchannels; int interpolationmode; - int volrampin; - int volrampout; + int volrampinus; + int volrampoutus; void load(); void save(); void edit( HWND parent, const char * title ); @@ -63,8 +63,8 @@ read_setting( "repeatcount", repeatcount ); read_setting( "maxmixchannels", maxmixchannels ); read_setting( "interpolationmode", interpolationmode ); - read_setting( "volrampin", volrampin ); - read_setting( "volrampout", volrampout ); + read_setting( "volrampin_microseconds", volrampinus ); + read_setting( "volrampout_microseconds", volrampoutus ); } inline void settings::save() { @@ -75,8 +75,8 @@ write_setting( "repeatcount", repeatcount ); write_setting( "maxmixchannels", maxmixchannels ); write_setting( "interpolationmode", interpolationmode ); - write_setting( "volrampin", volrampin ); - write_setting( "volrampout", volrampout ); + write_setting( "volrampin_microseconds", volrampinus ); + write_setting( "volrampout_microseconds", volrampoutus ); } inline void settings::edit( HWND parent, const char * title ) { @@ -91,8 +91,8 @@ repeatcount = 0; maxmixchannels = 256; interpolationmode = OPENMPT_MODULE_RENDER_INTERPOLATION_FIR_KAISER4T; - volrampin = 16; - volrampout = 42; + volrampinus = 363; + volrampoutus = 952; } inline settings::~settings() { Modified: trunk/OpenMPT/libopenmpt/libopenmpt_winamp.cpp =================================================================== --- trunk/OpenMPT/libopenmpt/libopenmpt_winamp.cpp 2013-05-13 18:21:56 UTC (rev 2080) +++ trunk/OpenMPT/libopenmpt/libopenmpt_winamp.cpp 2013-05-13 20:48:55 UTC (rev 2081) @@ -121,6 +121,8 @@ self->mod->set_render_param( openmpt::module::RENDER_REPEATCOUNT, self->settings->repeatcount ); self->mod->set_render_param( openmpt::module::RENDER_MAXMIXCHANNELS, self->settings->maxmixchannels ); self->mod->set_render_param( openmpt::module::RENDER_INTERPOLATION_MODE, self->settings->interpolationmode ); + self->mod->set_render_param( openmpt::module::RENDER_VOLUMERAMP_IN_US, self->settings->volrampinus ); + self->mod->set_render_param( openmpt::module::RENDER_VOLUMERAMP_OUT_US, self->settings->volrampoutus ); } self->settings->save(); } Modified: trunk/OpenMPT/libopenmpt/libopenmpt_xmplay.cpp =================================================================== --- trunk/OpenMPT/libopenmpt/libopenmpt_xmplay.cpp 2013-05-13 18:21:56 UTC (rev 2080) +++ trunk/OpenMPT/libopenmpt/libopenmpt_xmplay.cpp 2013-05-13 20:48:55 UTC (rev 2081) @@ -107,6 +107,8 @@ self->mod->set_render_param( openmpt::module::RENDER_REPEATCOUNT, self->settings->repeatcount ); self->mod->set_render_param( openmpt::module::RENDER_MAXMIXCHANNELS, self->settings->maxmixchannels ); self->mod->set_render_param( openmpt::module::RENDER_INTERPOLATION_MODE, self->settings->interpolationmode ); + self->mod->set_render_param( openmpt::module::RENDER_VOLUMERAMP_IN_US, self->settings->volrampinus ); + self->mod->set_render_param( openmpt::module::RENDER_VOLUMERAMP_OUT_US, self->settings->volrampoutus ); } self->settings->save(); } Modified: trunk/OpenMPT/openmpt123/openmpt123.cpp =================================================================== --- trunk/OpenMPT/openmpt123/openmpt123.cpp 2013-05-13 18:21:56 UTC (rev 2080) +++ trunk/OpenMPT/openmpt123/openmpt123.cpp 2013-05-13 20:48:55 UTC (rev 2081) @@ -68,8 +68,8 @@ std::int32_t samplerate; std::int32_t gain; std::int32_t quality; - std::int32_t rampinsamples; - std::int32_t rampoutsamples; + std::int32_t rampinus; + std::int32_t rampoutus; bool quiet; bool verbose; bool show_message; @@ -87,8 +87,8 @@ samplerate = 48000; gain = 0; quality = 100; - rampinsamples = 16; - rampoutsamples = 42; + rampinus = ( 16 * 1000000 + ( 44100 / 2 ) ) / 44100; // openmpt defaults at 44KHz, rounded + rampoutus = ( 42 * 1000000 + ( 44100 / 2 ) ) / 44100; // openmpt defaults at 44KHz, rounded quiet = false; verbose = false; show_message = false; @@ -362,8 +362,8 @@ std::clog << " --repeat n Repeat song n times (-1 means forever) [default: " << openmpt123_flags().repeatcount << "]" << std::endl; std::clog << " --quality n Set rendering quality to n % [default: " << openmpt123_flags().quality << "]" << std::endl; std::clog << " --seek n Seek to n seconds on start [default: " << openmpt123_flags().seek_target << "]" << std::endl; - std::clog << " --volrampin n Use n samples volume ramping on sample begin [default: " << openmpt123_flags().rampinsamples << "]" << std::endl; - std::clog << " --volrampout n Use n samples volume ramping on sample end [default: " << openmpt123_flags().rampoutsamples << "]" << std::endl; + std::clog << " --volrampin n Use n microseconds volume ramping on sample begin [default: " << openmpt123_flags().rampinus << "]" << std::endl; + std::clog << " --volrampout n Use n microseconds volume ramping on sample end [default: " << openmpt123_flags().rampoutus << "]" << std::endl; std::clog << std::endl; std::clog << " -- Interpret further arguments as filenames" << std::endl; std::clog << std::endl; @@ -498,8 +498,8 @@ mod.set_render_param( openmpt::module::RENDER_REPEATCOUNT, flags.repeatcount ); mod.set_render_param( openmpt::module::RENDER_QUALITY_PERCENT, flags.quality ); mod.set_render_param( openmpt::module::RENDER_MASTERGAIN_DB, flags.gain ); - mod.set_render_param( openmpt::module::RENDER_VOLUMERAMP_IN_SAMPLES, flags.rampinsamples ); - mod.set_render_param( openmpt::module::RENDER_VOLUMERAMP_OUT_SAMPLES, flags.rampoutsamples ); + mod.set_render_param( openmpt::module::RENDER_VOLUMERAMP_IN_US, flags.rampinus ); + mod.set_render_param( openmpt::module::RENDER_VOLUMERAMP_OUT_US, flags.rampoutus ); if ( flags.seek_target > 0.0 ) { mod.seek_seconds( flags.seek_target ); @@ -650,11 +650,11 @@ ++i; } else if ( arg == "--volrampin" && nextarg != "" ) { std::istringstream istr( nextarg ); - istr >> flags.rampinsamples; + istr >> flags.rampinus; ++i; } else if ( arg == "--volrampout" && nextarg != "" ) { std::istringstream istr( nextarg ); - istr >> flags.rampoutsamples; + istr >> flags.rampoutus; ++i; } else if ( arg.size() > 0 && arg.substr( 0, 1 ) == "-" ) { throw show_help_exception(); Modified: trunk/OpenMPT/soundlib/MixerSettings.cpp =================================================================== --- trunk/OpenMPT/soundlib/MixerSettings.cpp 2013-05-13 18:21:56 UTC (rev 2080) +++ trunk/OpenMPT/soundlib/MixerSettings.cpp 2013-05-13 20:48:55 UTC (rev 2081) @@ -10,6 +10,7 @@ #include "stdafx.h" #include "MixerSettings.h" #include "Snd_defs.h" +#include "../common/misc_util.h" MixerSettings::MixerSettings() { @@ -36,3 +37,27 @@ #endif } + + +int32 MixerSettings::GetVolumeRampUpMicroseconds() const +{ + return Util::muldivr(glVolumeRampUpSamples, 1000000, gdwMixingFreq); +} + + +int32 MixerSettings::GetVolumeRampDownMicroseconds() const +{ + return Util::muldivr(glVolumeRampDownSamples, 1000000, gdwMixingFreq); +} + + +void MixerSettings::SetVolumeRampUpMicroseconds(int32 rampUpMicroseconds) +{ + glVolumeRampUpSamples = Util::muldivr(rampUpMicroseconds, gdwMixingFreq, 1000000); +} + + +void MixerSettings::SetVolumeRampDownMicroseconds(int32 rampDownMicroseconds) +{ + glVolumeRampDownSamples = Util::muldivr(rampDownMicroseconds, gdwMixingFreq, 1000000); +} Modified: trunk/OpenMPT/soundlib/MixerSettings.h =================================================================== --- trunk/OpenMPT/soundlib/MixerSettings.h 2013-05-13 18:21:56 UTC (rev 2080) +++ trunk/OpenMPT/soundlib/MixerSettings.h 2013-05-13 20:48:55 UTC (rev 2081) @@ -35,6 +35,11 @@ //rewbs.resamplerConf long glVolumeRampUpSamples, glVolumeRampDownSamples; //end rewbs.resamplerConf + + int32 GetVolumeRampUpMicroseconds() const; + int32 GetVolumeRampDownMicroseconds() const; + void SetVolumeRampUpMicroseconds(int32 rampUpMicroseconds); + void SetVolumeRampDownMicroseconds(int32 rampDownMicroseconds); #ifndef MODPLUG_TRACKER DWORD m_FinalOutputGain; // factor multiplied to the final mixer output just before clipping and dithering, fixed point 16.16 This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <man...@us...> - 2013-05-18 14:30:07
|
Revision: 2098 http://sourceforge.net/p/modplug/code/2098 Author: manxorist Date: 2013-05-18 14:29:53 +0000 (Sat, 18 May 2013) Log Message: ----------- Merged revision(s) 2018-2022, 2024-2048, 2043-2048, 2052-2071, 2075-2077, 2080, 2087-2089 from branches/manx/gcc-fixes: [Ref] Various GGC compatibility fixes in common/. ........ [Ref] Do not depend on forward declared enums in common/FlagSet.h ........ [Ref] GCC wont bind references to aligned types to unaligned variables. Make SwapBytesXX argument an unaligned reference. ........ [Ref] GCC REALLY wont bind references to members of packed structures. Hack-around it for now. ........ [Var] Portability and correctness fixes for libopenmpt and openmpt123. ........ [Ref] Add MULTICHAR4_LE_MSVC macro to avoid using multi-character constants. [Ref] Use MULTICHAR4_LE_MSVC in GET_MPTHEADER_sized_member and related functions to avoid characterisation preprocessor operator (#@), which is completely msvc-only. ........ [Ref] Sndfile.h is spelled with an uppercase S. ........ [Ref] Dlsbank.h is spelled with an uppercase D. ........ [Ref] Replace __int16 and __int32 with portable int26 and int32. [Ref] For multi-character constants, use uint32 as container type. ........ [Ref] Add missing #ifdef NEEDS_PRAGMA_PACK ........ [Ref] Add #ifdef _MSC_VER around #pragma warning. ........ [Ref] Fix zlib include path for non WIN32 systems. [Ref] amFile variable was shadowed in load_j2b.cpp. ........ [Ref] Fix include paths in PlugInterface.h. ........ [Ref] ChunkReader.h needs <vector>. [Ref] Fix name lookup for begin() and end() for gcc 4.4 in ChunkReader.h. ........ [Ref] Fix some GCC warnings in tuningbase.h. ........ [Ref] FileReader.h needs misc_util.h for Util::MaxValueOfType<T>. [Ref] Fix some GCC warnings in FileReader.h. ........ [Ref] Work-around gcc braindamage in serialization_utils when taking a reference to a static const class member causes linker errors. ........ [Ref] Add more WIN32 types to typedefs.h. [Ref] Add UNREFERENCED_PARAMETER(x) macro. [Fix] Fix PACKED macro for GCC. ........ [Ref] #define NO_XMPLAY and NO_WINAMP on !WIN32 ........ [Ref] Replace MSVC specific _strnicmp with mpt_strnicmp. ........ [Ref] Add <string.h> and shuffle around code in StringFixer.h to make gcc happy. ........ [Ref] Make tuningcollection.h compile with gcc. ........ [Ref] Fix gcc warnings in libopenmpt. ........ [Ref] Only use PaUtil_SetDebugPrintFunction() in MSVC builds in openmpt123. ........ [Ref] Fix spelling of tuningcollection.h ........ [Ref] patternContainer.h needs <algorithm>. ........ [Ref] Fix GCC warnings in RowVisitor. ........ [Ref] Fix annoying unreferenced parameter warning in Fastmix.cpp. ........ [Ref] modcommand.h needs <cstring> ........ [Ref] Wav.h needs Endianness.h ........ [Ref] Fix spelling of tuningcollection.h ........ [Ref] patternContainer.h needs <algorithm>. ........ [Ref] Fix GCC warnings in RowVisitor. ........ [Ref] Fix annoying unreferenced parameter warning in Fastmix.cpp. ........ [Ref] modcommand.h needs <cstring> ........ [Ref] Wav.h needs Endianness.h ........ [Ref] Add support for svnversion in addition to subwcrev support to version.cpp. ........ [Ref] Do not typedef CHAR twice. ........ [Ref] Add #ifdef _MSC_VER around #pragma warning. ........ [Ref] Make SNDMIXPLUGIN::pPluginData a char* instead of void*, so that deleting it has defined behaviour. ........ [Ref] Fix initialization order warnigns in ModSequence.*. [Ref] Do not require CSoundFile being defined in ModSequence.h (add GetSndFileType() non-inline function in ModSequence.cpp). ........ [Fix] Add missing pragma pack and PACKED for struct S3ISAMPLESTRUCT. ........ [Ref] Use MULTICHAR4_LE_MSVC() macro instead of non-portable multi-character constants. ........ [Ref] Fix some trivial GCC warnings in pattern.h. ........ [Ref] Add a bunch of missing typename in SampleFormatConverters.h. ........ [Ref] String literals are const. ........ [Ref] Replace all FLOAT with float. ........ [Ref] Add missing typenames in Load_wav.cpp. ........ [Ref] GCC gets confused when choosing between a function pointer to ReadTuningMap and a funtion pointer to ReadTuningMap<TUNNUMTYPE, STRSIZETYPE>. Disambiguify by renaming the templated function. ........ [Ref] In CSoundFile::ReadM15, GCC 4.4 gets confused when calling std::max with a parameter being an enum literal of an enum defined in function scope. Move enum definition out of the function to make GCC happy. ........ [Ref] GCC wont bind references to unaligned types (or arrays thereof). Work-around it by using a simple pointer. This probably has to be solved differently in the future. ........ [Ref] Fix initialization order warnings in ITCompression.cpp. [Ref] Add missing typenames in ITCompression.cpp. [Ref] Work-around gcc problem: Taking a reference to a static const class member causes linker errors. [Ref] delete[] void* is undefined. Cast sampleData to uint8* when deleting it. ........ [Ref] Add alternate C implementations for x86 inline asm. ........ [Ref] Use char instead of CHAR for on-disk strings. Rationale: CHAR is signed in WIN32, therefore CHAR is a typedef of std::int8_t (and not char which could be an unsigned type) in typedefs.h on non-win32 systems. std::int8_t itself is a typedef of signed char most of the time. signed char* is not convertable to char* because char is a distinct type. This causes problems for e.g. class StringFixer which expects char arrays or pointers and not signed char. ........ [New] Add a simple very non-portable makefile for building openmpt123 with statically built-in libopenmpt. ........ [Ref] Add #ifdef _MSC_VER around #pragma warning. ........ [Fix] Fix truncation error with 64bit gcc in libopenmpt_stream_callbacks.h by adding another cast. ........ [Ref] Help std::min template argument deduction in cases where size_t is 64bit. ........ [Ref] Workaround reference to static const member problem for a case where this triggers with clang 3.0. [Ref] Move code around in StringFixer.h so name lookup works with clang 3.0. [Mod] Disable loading of wav files for libopenmpt. [Ref] misc_util.h needs <string.h>. ........ [Fix] Fix openmpt123 stdout output with int16 samples. ........ [Ref] Add comment describing pointer/reference dance in Endianness.h ........ [Ref] Trivial MSVC build fixes for gcc-fixes branch. ........ [New] Add build configurations for libopenmpt and openmpt123 for VS2010 x86-64. ........ Modified Paths: -------------- trunk/OpenMPT/common/BuildSettings.h trunk/OpenMPT/common/FlagSet.h trunk/OpenMPT/common/Profiler.cpp trunk/OpenMPT/common/StringFixer.h trunk/OpenMPT/common/misc_util.h trunk/OpenMPT/common/mptString.h trunk/OpenMPT/common/mutex.h trunk/OpenMPT/common/serialization_utils.cpp trunk/OpenMPT/common/serialization_utils.h trunk/OpenMPT/common/typedefs.cpp trunk/OpenMPT/common/typedefs.h trunk/OpenMPT/common/version.cpp trunk/OpenMPT/common/version.h trunk/OpenMPT/include/portaudio/build/msvc/portaudio_openmpt_vs2010.vcxproj trunk/OpenMPT/include/zlib/contrib/vstudio/vc10/zlibstat.vcxproj trunk/OpenMPT/libopenmpt/libopenmpt.sln trunk/OpenMPT/libopenmpt/libopenmpt.vcxproj trunk/OpenMPT/libopenmpt/libopenmpt_stream_callbacks.h trunk/OpenMPT/mptrack/MainFrm.cpp trunk/OpenMPT/mptrack/Mod2wave.cpp trunk/OpenMPT/mptrack/Moddoc.cpp trunk/OpenMPT/mptrack/Moddoc.h trunk/OpenMPT/mptrack/Modedit.cpp trunk/OpenMPT/mptrack/Mpdlgs.cpp trunk/OpenMPT/mptrack/Mpt_midi.cpp trunk/OpenMPT/mptrack/Mptrack.cpp trunk/OpenMPT/mptrack/PSRatioCalc.cpp trunk/OpenMPT/mptrack/PatternGotoDialog.cpp trunk/OpenMPT/mptrack/View_gen.cpp trunk/OpenMPT/mptrack/View_ins.cpp trunk/OpenMPT/mptrack/View_smp.cpp trunk/OpenMPT/mptrack/View_tre.cpp trunk/OpenMPT/mptrack/Vstplug.cpp trunk/OpenMPT/mptrack/dlg_misc.cpp trunk/OpenMPT/mptrack/tagging.cpp trunk/OpenMPT/openmpt123/openmpt123.cpp trunk/OpenMPT/openmpt123/openmpt123.sln trunk/OpenMPT/openmpt123/openmpt123.vcxproj trunk/OpenMPT/sounddsp/DSP.cpp trunk/OpenMPT/sounddsp/EQ.cpp trunk/OpenMPT/sounddsp/Reverb.cpp trunk/OpenMPT/sounddsp/Reverb.h trunk/OpenMPT/soundlib/ChunkReader.h trunk/OpenMPT/soundlib/Dlsbank.cpp trunk/OpenMPT/soundlib/Dlsbank.h trunk/OpenMPT/soundlib/Endianness.h trunk/OpenMPT/soundlib/Fastmix.cpp trunk/OpenMPT/soundlib/FileReader.h trunk/OpenMPT/soundlib/ITCompression.cpp trunk/OpenMPT/soundlib/LOAD_DSM.CPP trunk/OpenMPT/soundlib/Load_ams.cpp trunk/OpenMPT/soundlib/Load_it.cpp trunk/OpenMPT/soundlib/Load_mdl.cpp trunk/OpenMPT/soundlib/Load_mid.cpp trunk/OpenMPT/soundlib/Load_mod.cpp trunk/OpenMPT/soundlib/Load_mt2.cpp trunk/OpenMPT/soundlib/Load_ptm.cpp trunk/OpenMPT/soundlib/Load_stm.cpp trunk/OpenMPT/soundlib/Load_wav.cpp trunk/OpenMPT/soundlib/Load_xm.cpp trunk/OpenMPT/soundlib/Mmcmp.cpp trunk/OpenMPT/soundlib/Mmx_mix.cpp trunk/OpenMPT/soundlib/ModChannel.h trunk/OpenMPT/soundlib/ModSample.cpp trunk/OpenMPT/soundlib/ModSequence.cpp trunk/OpenMPT/soundlib/ModSequence.h trunk/OpenMPT/soundlib/RowVisitor.h trunk/OpenMPT/soundlib/SampleFormatConverters.h trunk/OpenMPT/soundlib/SampleFormats.cpp trunk/OpenMPT/soundlib/Snd_defs.h trunk/OpenMPT/soundlib/Snd_flt.cpp trunk/OpenMPT/soundlib/Snd_fx.cpp trunk/OpenMPT/soundlib/Sndfile.cpp trunk/OpenMPT/soundlib/Sndfile.h trunk/OpenMPT/soundlib/Sndmix.cpp trunk/OpenMPT/soundlib/Tables.cpp trunk/OpenMPT/soundlib/Wav.h trunk/OpenMPT/soundlib/Waveform.cpp trunk/OpenMPT/soundlib/XMTools.cpp trunk/OpenMPT/soundlib/XMTools.h trunk/OpenMPT/soundlib/load_j2b.cpp trunk/OpenMPT/soundlib/modcommand.h trunk/OpenMPT/soundlib/modsmp_ctrl.cpp trunk/OpenMPT/soundlib/pattern.h trunk/OpenMPT/soundlib/patternContainer.cpp trunk/OpenMPT/soundlib/patternContainer.h trunk/OpenMPT/soundlib/plugins/PlugInterface.h trunk/OpenMPT/soundlib/tuningCollection.cpp trunk/OpenMPT/soundlib/tuningbase.h trunk/OpenMPT/soundlib/tuningcollection.h Added Paths: ----------- trunk/OpenMPT/common/svn_version_svnversion/ trunk/OpenMPT/openmpt123/Makefile Property Changed: ---------------- trunk/OpenMPT/ trunk/OpenMPT/include/portaudio/build/msvc/ trunk/OpenMPT/include/zlib/contrib/vstudio/vc10/ trunk/OpenMPT/libopenmpt/ trunk/OpenMPT/openmpt123/ Index: trunk/OpenMPT =================================================================== --- trunk/OpenMPT 2013-05-18 14:20:01 UTC (rev 2097) +++ trunk/OpenMPT 2013-05-18 14:29:53 UTC (rev 2098) Property changes on: trunk/OpenMPT ___________________________________________________________________ Modified: svn:mergeinfo ## -1,5 +1,5 ## /branches/manx/build-speedup:1586-1589 -/branches/manx/gcc-fixes:2022,2041-2042 +/branches/manx/gcc-fixes:2018-2022,2024-2048,2052-2071,2075-2077,2080,2087-2089 /branches/manx/header-dependencies-cleanups:1394-1397,1401-1402,1405-1406 /branches/manx/nonglobal-mixer:1715-1841 /branches/manx/profiler:1813 \ No newline at end of property Modified: trunk/OpenMPT/common/BuildSettings.h =================================================================== --- trunk/OpenMPT/common/BuildSettings.h 2013-05-18 14:20:01 UTC (rev 2097) +++ trunk/OpenMPT/common/BuildSettings.h 2013-05-18 14:29:53 UTC (rev 2098) @@ -25,7 +25,7 @@ #define ENABLE_ASM // inline assembly requires MSVC compiler -#if defined(ENABLE_ASM) && defined(_MSC_VER) +#if defined(ENABLE_ASM) && defined(_MSC_VER) && defined(_M_IX86) // Generate general x86 inline assembly. #define ENABLE_X86 @@ -122,15 +122,19 @@ #define NO_ASIO #define NO_VST #define NO_PORTAUDIO -#if !defined(_WIN32) +#if !defined(_WIN32) || (defined(_WIN32) && !defined(_M_IX86)) #define NO_MO3 #endif #define NO_DSOUND #define NO_FLAC #define NO_MP3_SAMPLES //#define NO_LIBMODPLUG -//#define NO_WINAMP -//#define NO_XMPLAY +#if !defined(_WIN32) || (defined(_WIN32) && !defined(_M_IX86)) +#define NO_WINAMP +#endif +#if !defined(_WIN32) || (defined(_WIN32) && !defined(_M_IX86)) +#define NO_XMPLAY +#endif //#define NO_LIBOPENMPT_C //#define NO_LIBOPENMPT_CXX Modified: trunk/OpenMPT/common/FlagSet.h =================================================================== --- trunk/OpenMPT/common/FlagSet.h 2013-05-18 14:20:01 UTC (rev 2097) +++ trunk/OpenMPT/common/FlagSet.h 2013-05-18 14:29:53 UTC (rev 2098) @@ -161,10 +161,3 @@ inline enum_t &operator &= (enum_t &a, enum_t b) { a = (a & b); return a; } \ inline enum_t &operator |= (enum_t &a, enum_t b) { a = (a | b); return a; } \ inline enum_t operator ~ (enum_t a) { return static_cast<enum_t>(~(+a)); } - -// Declaration of a typesafe flag set enum. -// Usage: FLAGSET(enumName) { foo = 1, bar = 2, ... } -#define FLAGSET(enum_t) \ - enum enum_t; \ - DECLARE_FLAGSET(enum_t) \ - enum enum_t Modified: trunk/OpenMPT/common/Profiler.cpp =================================================================== --- trunk/OpenMPT/common/Profiler.cpp 2013-05-18 14:20:01 UTC (rev 2097) +++ trunk/OpenMPT/common/Profiler.cpp 2013-05-18 14:29:53 UTC (rev 2098) @@ -8,7 +8,7 @@ */ -#include "Stdafx.h" +#include "stdafx.h" #include "Profiler.h" #include <stdlib.h> Modified: trunk/OpenMPT/common/StringFixer.h =================================================================== --- trunk/OpenMPT/common/StringFixer.h 2013-05-18 14:20:01 UTC (rev 2097) +++ trunk/OpenMPT/common/StringFixer.h 2013-05-18 14:29:53 UTC (rev 2098) @@ -11,6 +11,8 @@ #pragma once +#include <string.h> + namespace StringFixer { @@ -63,18 +65,6 @@ // Copy a string from srcBuffer to destBuffer using a given read mode. - // Used for reading strings from files. - // Preferrably use this version of the function, it is safer. - template <ReadWriteMode mode, size_t destSize, size_t srcSize> - void ReadString(char (&destBuffer)[destSize], const char (&srcBuffer)[srcSize]) - //----------------------------------------------------------------------------- - { - STATIC_ASSERT(destSize > 0); - STATIC_ASSERT(srcSize > 0); - ReadString<mode, destSize>(destBuffer, srcBuffer, srcSize); - } - - // Copy a string from srcBuffer to destBuffer using a given read mode. // Used for reading strings from files. // Only use this version of the function if the size of the source buffer is variable. @@ -159,18 +149,18 @@ } - // Copy a string from srcBuffer to destBuffer using a given write mode. - // Used for writing strings to files. + // Used for reading strings from files. // Preferrably use this version of the function, it is safer. template <ReadWriteMode mode, size_t destSize, size_t srcSize> - void WriteString(char (&destBuffer)[destSize], const char (&srcBuffer)[srcSize]) - //------------------------------------------------------------------------------ + void ReadString(char (&destBuffer)[destSize], const char (&srcBuffer)[srcSize]) + //----------------------------------------------------------------------------- { STATIC_ASSERT(destSize > 0); STATIC_ASSERT(srcSize > 0); - WriteString<mode, destSize>(destBuffer, srcBuffer, srcSize); + ReadString<mode, destSize>(destBuffer, srcBuffer, srcSize); } + // Copy a string from srcBuffer to destBuffer using a given write mode. // Used for writing strings to files. // Only use this version of the function if the size of the source buffer is variable. @@ -215,15 +205,19 @@ } } - - // Copy from one fixed size char array to another one. - template <size_t destSize, size_t srcSize> - void Copy(char (&destBuffer)[destSize], const char (&srcBuffer)[srcSize]) - //----------------------------------------------------------------------- + // Copy a string from srcBuffer to destBuffer using a given write mode. + // Used for writing strings to files. + // Preferrably use this version of the function, it is safer. + template <ReadWriteMode mode, size_t destSize, size_t srcSize> + void WriteString(char (&destBuffer)[destSize], const char (&srcBuffer)[srcSize]) + //------------------------------------------------------------------------------ { - CopyN(destBuffer, srcBuffer, srcSize); + STATIC_ASSERT(destSize > 0); + STATIC_ASSERT(srcSize > 0); + WriteString<mode, destSize>(destBuffer, srcBuffer, srcSize); } + // Copy from a char array to a fixed size char array. template <size_t destSize> void CopyN(char (&destBuffer)[destSize], const char *srcBuffer, const size_t srcSize = SIZE_MAX) @@ -233,4 +227,14 @@ strncpy(destBuffer, srcBuffer, copySize); destBuffer[copySize] = '\0'; } + + // Copy from one fixed size char array to another one. + template <size_t destSize, size_t srcSize> + void Copy(char (&destBuffer)[destSize], const char (&srcBuffer)[srcSize]) + //----------------------------------------------------------------------- + { + CopyN(destBuffer, srcBuffer, srcSize); + } + }; + Modified: trunk/OpenMPT/common/misc_util.h =================================================================== --- trunk/OpenMPT/common/misc_util.h 2013-05-18 14:20:01 UTC (rev 2097) +++ trunk/OpenMPT/common/misc_util.h 2013-05-18 14:29:53 UTC (rev 2098) @@ -14,8 +14,11 @@ #include <sstream> #include <string> +#include <cmath> #include <cstdlib> +#include <string.h> + #include "typedefs.h" #ifdef MODPLUG_TRACKER @@ -177,7 +180,7 @@ if(b == 0) return a; a %= b; - } + } while(true); } @@ -253,7 +256,7 @@ *result |= 0x80; } result++; - } while (++bytesUsed < maxLength && value != 0) + } while (++bytesUsed < maxLength && value != 0); return bytesUsed; } Modified: trunk/OpenMPT/common/mptString.h =================================================================== --- trunk/OpenMPT/common/mptString.h 2013-05-18 14:20:01 UTC (rev 2097) +++ trunk/OpenMPT/common/mptString.h 2013-05-18 14:29:53 UTC (rev 2098) @@ -11,6 +11,9 @@ #pragma once #include <string> +#ifdef __GNUC__ +#include <strings.h> // for strcasecmp +#endif namespace mpt { @@ -86,3 +89,13 @@ } return str; } + + +static inline int mpt_strnicmp(const char *a, const char *b, size_t count) +{ + #ifdef _MSC_VER + return _strnicmp(a, b, count); + #else + return strncasecmp(a, b, count); + #endif +} Modified: trunk/OpenMPT/common/mutex.h =================================================================== --- trunk/OpenMPT/common/mutex.h 2013-05-18 14:20:01 UTC (rev 2097) +++ trunk/OpenMPT/common/mutex.h 2013-05-18 14:29:53 UTC (rev 2098) @@ -9,6 +9,8 @@ #pragma once +#ifdef MODPLUG_TRACKER + #define WIN32_LEAN_AND_MEAN #define VC_EXTRALEAN #define NOMINMAX @@ -49,3 +51,5 @@ }; } // namespace Util + +#endif // MODPLUG_TRACKER Modified: trunk/OpenMPT/common/serialization_utils.cpp =================================================================== --- trunk/OpenMPT/common/serialization_utils.cpp 2013-05-18 14:20:01 UTC (rev 2097) +++ trunk/OpenMPT/common/serialization_utils.cpp 2013-05-18 14:29:53 UTC (rev 2098) @@ -10,12 +10,15 @@ #include "stdafx.h" #include "serialization_utils.h" +#include "misc_util.h" #include <algorithm> #include <iterator> // for back_inserter namespace srlztn { +static const uint8 HeaderId_FlagByte = 0; + // Indexing starts from 0. inline bool Testbit(uint8 val, uint8 bitindex) {return ((val & (1 << bitindex)) != 0);} @@ -145,7 +148,7 @@ void WriteItemString(OutStream& oStrm, const char* const pStr, const size_t nSize) //-------------------------------------------------------------------------------- { - uint32 id = (std::min)(nSize, (uint32_max >> 4)) << 4; + uint32 id = std::min<size_t>(nSize, (uint32_max >> 4)) << 4; id |= 12; // 12 == 1100b Binarywrite<uint32>(oStrm, id); id >>= 4; @@ -188,9 +191,7 @@ { int32 val = 0; memcpy(&val, pId, nLength); - char buf[36]; - _itoa(val, buf, 10); - str = buf; + str = Stringify(val); } return str; } @@ -220,29 +221,29 @@ #define SSB_INITIALIZATION_LIST \ + m_Status(SNT_NONE), \ + m_nFixedEntrySize(0), \ + m_fpLogFunc(s_DefaultLogFunc), \ m_Readlogmask(s_DefaultReadLogMask), \ m_Writelogmask(s_DefaultWriteLogMask), \ - m_fpLogFunc(s_DefaultLogFunc), \ - m_nCounter(0), \ - m_nNextReadHint(0), \ + m_posStart(0), \ m_nReadVersion(0), \ - m_nFixedEntrySize(0), \ - m_nIdbytes(IdSizeVariable), \ - m_nReadEntrycount(0), \ m_nMaxReadEntryCount(16000), \ - m_pSubEntry(nullptr), \ m_rposMapBegin(0), \ - m_posStart(0), \ - m_posSubEntryStart(0), \ + m_posMapEnd(0), \ m_posDataBegin(0), \ - m_posMapStart(0), \ m_rposEndofHdrData(0), \ - m_posMapEnd(0), \ + m_nReadEntrycount(0), \ + m_nIdbytes(IdSizeVariable), \ + m_nCounter(0), \ + m_nNextReadHint(0), \ + m_Flags(s_DefaultFlags), \ + m_pSubEntry(nullptr), \ + m_posSubEntryStart(0), \ + m_nMapReserveSize(0), \ m_posEntrycount(0), \ m_posMapPosField(0), \ - m_nMapReserveSize(0), \ - m_Flags(s_DefaultFlags), \ - m_Status(SNT_NONE) + m_posMapStart(0) \ Ssb::Ssb(InStream* pIstrm, OutStream* pOstrm) : @@ -268,8 +269,8 @@ Ssb::Ssb(InStream& iStrm) : + m_pOstrm(nullptr), m_pIstrm(&iStrm), - m_pOstrm(nullptr), SSB_INITIALIZATION_LIST //------------------------------ {} Modified: trunk/OpenMPT/common/serialization_utils.h =================================================================== --- trunk/OpenMPT/common/serialization_utils.h 2013-05-18 14:20:01 UTC (rev 2097) +++ trunk/OpenMPT/common/serialization_utils.h 2013-05-18 14:29:53 UTC (rev 2098) @@ -21,6 +21,7 @@ #include <type_traits> #endif #include <algorithm> +#include <string.h> namespace srlztn //SeRiaLiZaTioN { @@ -122,6 +123,113 @@ }; +template<class T> +inline void Binarywrite(OutStream& oStrm, const T& data) +//------------------------------------------------------ +{ + oStrm.write(reinterpret_cast<const char*>(&data), sizeof(data)); +} + +//Write only given number of bytes from the beginning. +template<class T> +inline void Binarywrite(OutStream& oStrm, const T& data, const Offtype bytecount) +//-------------------------------------------------------------------------- +{ + oStrm.write(reinterpret_cast<const char*>(&data), MIN(bytecount, sizeof(data))); +} + +template <class T> +inline void WriteItem(OutStream& oStrm, const T& data) +//---------------------------------------------------- +{ + #ifdef HAS_TYPE_TRAITS + static_assert(std::is_trivial<T>::value == true, ""); + #endif + Binarywrite(oStrm, data); +} + +void WriteItemString(OutStream& oStrm, const char* const pStr, const size_t nSize); + +template <> +inline void WriteItem<std::string>(OutStream& oStrm, const std::string& str) {WriteItemString(oStrm, str.c_str(), str.length());} + +template <> +inline void WriteItem<LPCSTR>(OutStream& oStrm, const LPCSTR& psz) {WriteItemString(oStrm, psz, strlen(psz));} + + +template<class T> +inline void Binaryread(InStream& iStrm, T& data) +//---------------------------------------------- +{ + iStrm.read(reinterpret_cast<char*>(&data), sizeof(T)); +} + +//Read only given number of bytes to the beginning of data; data bytes are memset to 0 before reading. +template <class T> +inline void Binaryread(InStream& iStrm, T& data, const Offtype bytecount) +//----------------------------------------------------------------------- +{ + #ifdef HAS_TYPE_TRAITS + static_assert(std::is_trivial<T>::value == true, ""); + #endif + memset(&data, 0, sizeof(data)); + iStrm.read(reinterpret_cast<char*>(&data), (std::min)((size_t)bytecount, sizeof(data))); +} + + +template <class T> +inline void ReadItem(InStream& iStrm, T& data, const DataSize nSize) +//------------------------------------------------------------------ +{ + #ifdef HAS_TYPE_TRAITS + static_assert(std::is_trivial<T>::value == true, ""); + #endif + if (nSize == sizeof(T) || nSize == invalidDatasize) + Binaryread(iStrm, data); + else + Binaryread(iStrm, data, nSize); +} + +// Read specialization for float. If data size is 8, read double and assign it to given float. +template <> +inline void ReadItem<float>(InStream& iStrm, float& f, const DataSize nSize) +//-------------------------------------------------------------------------- +{ + if (nSize == 8) + { + double d; + Binaryread(iStrm, d); + f = static_cast<float>(d); + } + else + Binaryread(iStrm, f); +} + +// Read specialization for double. If data size is 4, read float and assign it to given double. +template <> +inline void ReadItem<double>(InStream& iStrm, double& d, const DataSize nSize) +//---------------------------------------------------------------------------- +{ + if (nSize == 4) + { + float f; + Binaryread(iStrm, f); + d = f; + } + else + Binaryread(iStrm, d); +} + +void ReadItemString(InStream& iStrm, std::string& str, const DataSize); + +template <> +inline void ReadItem<std::string>(InStream& iStrm, std::string& str, const DataSize nSize) +//---------------------------------------------------------------------------------------- +{ + ReadItemString(iStrm, str, nSize); +} + + class Ssb //======= { @@ -236,10 +344,6 @@ // Write given string to log if log func is defined. void AddToLog(LPCTSTR psz) {if (m_fpLogFunc) m_fpLogFunc(psz);} - SsbStatus m_Status; - uint32 m_nFixedEntrySize; // Read/write: If > 0, data entries have given fixed size. - fpLogFunc_t m_fpLogFunc; // Pointer to log function. - private: // Reads map to cache. void CacheMap(); @@ -285,13 +389,22 @@ void IncrementWriteCounter(); private: + + OutStream* m_pOstrm; // Write: Pointer to write stream. + InStream* m_pIstrm; // Read: Pointer to read stream. + +public: + + SsbStatus m_Status; + uint32 m_nFixedEntrySize; // Read/write: If > 0, data entries have given fixed size. + fpLogFunc_t m_fpLogFunc; // Pointer to log function. + +private: + SsbStatus m_Readlogmask; // Read: Controls which read messages will be written to log. SsbStatus m_Writelogmask; // Write: Controls which write messages will be written to log. std::vector<char> m_Idarray; // Read: Holds entry ids. - - InStream* m_pIstrm; // Read: Pointer to read stream. - OutStream* m_pOstrm; // Write: Pointer to write stream. Postype m_posStart; // Read/write: Stream position at the beginning of object. std::vector<ReadEntry> mapData; // Read: Contains map information. @@ -316,8 +429,6 @@ Postype m_posMapStart; // Write: Pos of map start. OstrStream m_MapStream; // Write: Map stream. -private: - static const uint8 HeaderId_FlagByte = 0; public: static const uint8 s_DefaultFlagbyte = 0; static int32 s_DefaultReadLogMask; @@ -393,113 +504,7 @@ } -template<class T> -inline void Binarywrite(OutStream& oStrm, const T& data) -//------------------------------------------------------ -{ - oStrm.write(reinterpret_cast<const char*>(&data), sizeof(data)); -} - -//Write only given number of bytes from the beginning. -template<class T> -inline void Binarywrite(OutStream& oStrm, const T& data, const Offtype bytecount) -//-------------------------------------------------------------------------- -{ - oStrm.write(reinterpret_cast<const char*>(&data), MIN(bytecount, sizeof(data))); -} - template <class T> -inline void WriteItem(OutStream& oStrm, const T& data) -//---------------------------------------------------- -{ - #ifdef HAS_TYPE_TRAITS - static_assert(std::is_trivial<T>::value == true, ""); - #endif - Binarywrite(oStrm, data); -} - -void WriteItemString(OutStream& oStrm, const char* const pStr, const size_t nSize); - -template <> -inline void WriteItem<std::string>(OutStream& oStrm, const std::string& str) {WriteItemString(oStrm, str.c_str(), str.length());} - -template <> -inline void WriteItem<LPCSTR>(OutStream& oStrm, const LPCSTR& psz) {WriteItemString(oStrm, psz, strlen(psz));} - -template<class T> -inline void Binaryread(InStream& iStrm, T& data) -//---------------------------------------------- -{ - iStrm.read(reinterpret_cast<char*>(&data), sizeof(T)); -} - -//Read only given number of bytes to the beginning of data; data bytes are memset to 0 before reading. -template <class T> -inline void Binaryread(InStream& iStrm, T& data, const Offtype bytecount) -//----------------------------------------------------------------------- -{ - #ifdef HAS_TYPE_TRAITS - static_assert(std::is_trivial<T>::value == true, ""); - #endif - memset(&data, 0, sizeof(data)); - iStrm.read(reinterpret_cast<char*>(&data), (std::min)((size_t)bytecount, sizeof(data))); -} - - -template <class T> -inline void ReadItem(InStream& iStrm, T& data, const DataSize nSize) -//------------------------------------------------------------------ -{ - #ifdef HAS_TYPE_TRAITS - static_assert(std::is_trivial<T>::value == true, ""); - #endif - if (nSize == sizeof(T) || nSize == invalidDatasize) - Binaryread(iStrm, data); - else - Binaryread(iStrm, data, nSize); -} - -// Read specialization for float. If data size is 8, read double and assign it to given float. -template <> -inline void ReadItem<float>(InStream& iStrm, float& f, const DataSize nSize) -//-------------------------------------------------------------------------- -{ - if (nSize == 8) - { - double d; - Binaryread(iStrm, d); - f = static_cast<float>(d); - } - else - Binaryread(iStrm, f); -} - -// Read specialization for double. If data size is 4, read float and assign it to given double. -template <> -inline void ReadItem<double>(InStream& iStrm, double& d, const DataSize nSize) -//---------------------------------------------------------------------------- -{ - if (nSize == 4) - { - float f; - Binaryread(iStrm, f); - d = f; - } - else - Binaryread(iStrm, d); -} - -void ReadItemString(InStream& iStrm, std::string& str, const DataSize); - -template <> -inline void ReadItem<std::string>(InStream& iStrm, std::string& str, const DataSize nSize) -//---------------------------------------------------------------------------------------- -{ - ReadItemString(iStrm, str, nSize); -} - - -template <class T> struct ArrayWriter //================ { Modified: trunk/OpenMPT/common/typedefs.cpp =================================================================== --- trunk/OpenMPT/common/typedefs.cpp 2013-05-18 14:20:01 UTC (rev 2097) +++ trunk/OpenMPT/common/typedefs.cpp 2013-05-18 14:29:53 UTC (rev 2098) @@ -11,6 +11,7 @@ #include "stdafx.h" #include "typedefs.h" #include <iostream> +#include <cstring> #ifndef MODPLUG_TRACKER @@ -118,7 +119,7 @@ } #endif //LOG_TO_FILE #else // !MODPLUG_TRACKER - std::size_t len = strlen(message); + std::size_t len = std::strlen(message); // remove eol if already present if(len > 0 && message[len-1] == '\n') { Modified: trunk/OpenMPT/common/typedefs.h =================================================================== --- trunk/OpenMPT/common/typedefs.h 2013-05-18 14:20:01 UTC (rev 2097) +++ trunk/OpenMPT/common/typedefs.h 2013-05-18 14:29:53 UTC (rev 2098) @@ -19,6 +19,10 @@ #define MSVC_VER_VC10 1600 #define MSVC_VER_2010 MSVC_VER_VC10 +#define GCC_VERSION (__GNUC__ * 10000 + __GNUC_MINOR__ * 100 + __GNUC_PATCHLEVEL__) + + + #if defined(_MSC_VER) #pragma warning(error : 4309) // Treat "truncation of constant value"-warning as error. #endif @@ -31,9 +35,15 @@ -#if defined(_MSC_VER) && (_MSC_VER < MSVC_VER_2010) +#if defined(_MSC_VER) +#if (_MSC_VER < MSVC_VER_2010) #define nullptr 0 #endif +#elif defined(__GNUC__) +#if GCC_VERSION < 40600 +#define nullptr 0 +#endif +#endif @@ -50,7 +60,7 @@ #define PACKED __declspec(align(1)) #define NEEDS_PRAGMA_PACK #elif defined(__GNUC__) -#define PACKED __attribute__((packed))) __attribute__((aligned(1)))) +#define PACKED __attribute__((packed)) __attribute__((aligned(1))) #endif @@ -225,6 +235,7 @@ // openmpt assumes these type have exact WIN32 semantics #define VOID void +typedef std::int32_t BOOL; typedef std::uint8_t BYTE; typedef std::uint16_t WORD; typedef std::uint32_t DWORD; @@ -233,21 +244,35 @@ typedef std::int16_t SHORT; typedef std::int32_t INT; typedef std::int32_t LONG; +typedef std::int64_t LONGLONG; typedef std::uint8_t UCHAR; typedef std::uint16_t USHORT; typedef std::uint32_t UINT; typedef std::uint32_t ULONG; +typedef std::uint64_t ULONGLONG; typedef VOID * LPVOID; typedef VOID * PVOID; +typedef BYTE * LPBYTE; +typedef WORD * LPWORD; +typedef DWORD * LPDWORD; +typedef INT * LPINT; +typedef LONG * LPLONG; -typedef std::int8_t CHAR; typedef char TCHAR; typedef const char * LPCSTR; typedef char * LPSTR; typedef const char * LPCTSTR; typedef char * LPTSTR; + +// for BOOL +#define TRUE (1) +#define FALSE (0) + #define MPT_TEXT(x) x +// wsprintf is just sprintf, but defined in the WINDOWS API +#define wsprintf sprintf + #endif // _WIN32 @@ -265,8 +290,10 @@ #define snprintf c99_snprintf #endif +#define MULTICHAR4_LE_MSVC(a,b,c,d) static_cast<uint32>( (static_cast<uint8>(a) << 24) | (static_cast<uint8>(b) << 16) | (static_cast<uint8>(c) << 8) | (static_cast<uint8>(d) << 0) ) + //STRINGIZE makes a string of given argument. If used with #defined value, //the string is made of the contents of the defined value. #define HELPER_STRINGIZE(x) #x @@ -305,3 +332,10 @@ // just #undef Log in files, where this Log redefinition causes problems //#undef Log + + + +#ifndef UNREFERENCED_PARAMETER +#define UNREFERENCED_PARAMETER(x) (void)(x) +#endif + Modified: trunk/OpenMPT/common/version.cpp =================================================================== --- trunk/OpenMPT/common/version.cpp 2013-05-18 14:20:01 UTC (rev 2097) +++ trunk/OpenMPT/common/version.cpp 2013-05-18 14:29:53 UTC (rev 2098) @@ -12,6 +12,8 @@ #include <sstream> +#include <cstdlib> + #include "versionNumber.h" #include "svn_version.h" @@ -21,6 +23,65 @@ const char * const str = MPT_VERSION_STR; +static int parse_svnversion_to_revision( std::string svnversion ) +{ + if(svnversion.length() == 0) + { + return 0; + } + if(svnversion.find(":") != std::string::npos) + { + svnversion = svnversion.substr(svnversion.find(":") + 1); + } + if(svnversion.find("M") != std::string::npos) + { + svnversion = svnversion.substr(0, svnversion.find("M")); + } + if(svnversion.find("S") != std::string::npos) + { + svnversion = svnversion.substr(0, svnversion.find("S")); + } + if(svnversion.find("P") != std::string::npos) + { + svnversion = svnversion.substr(0, svnversion.find("P")); + } + return std::strtol(svnversion.c_str(), 0, 10); +} + +static bool parse_svnversion_to_mixed_revisions( std::string svnversion ) +{ + if(svnversion.length() == 0) + { + return false; + } + if(svnversion.find(":") != std::string::npos) + { + return true; + } + if(svnversion.find("S") != std::string::npos) + { + return true; + } + if(svnversion.find("P") != std::string::npos) + { + return true; + } + return false; +} + +static bool parse_svnversion_to_modified( std::string svnversion ) +{ + if(svnversion.length() == 0) + { + return false; + } + if(svnversion.find("M") != std::string::npos) + { + return true; + } + return false; +} + std::string GetOpenMPTVersionStr() { return std::string("OpenMPT ") + std::string(MPT_VERSION_STR); @@ -73,32 +134,54 @@ std::string GetUrl() { - return OPENMPT_VERSION_URL; + #ifdef OPENMPT_VERSION_URL + return OPENMPT_VERSION_URL; + #else + return ""; + #endif } int GetRevision() { - return OPENMPT_VERSION_REVISION; + #if defined(OPENMPT_VERSION_REVISION) + return OPENMPT_VERSION_REVISION; + #elif defined(OPENMPT_VERSION_SVNVERSION) + return parse_svnversion_to_revision(OPENMPT_VERSION_SVNVERSION); + #else + return 0; + #endif } bool IsDirty() { - return OPENMPT_VERSION_DIRTY; + #if defined(OPENMPT_VERSION_DIRTY) + return OPENMPT_VERSION_DIRTY; + #elif defined(OPENMPT_VERSION_SVNVERSION) + return parse_svnversion_to_modified(OPENMPT_VERSION_SVNVERSION); + #else + return false; + #endif } bool HasMixedRevisions() { - return OPENMPT_VERSION_MIXEDREVISIONS; + #if defined(OPENMPT_VERSION_MIXEDREVISIONS) + return OPENMPT_VERSION_MIXEDREVISIONS; + #elif defined(OPENMPT_VERSION_SVNVERSION) + return parse_svnversion_to_mixed_revisions(OPENMPT_VERSION_SVNVERSION); + #else + return false; + #endif } std::string GetStateString() { std::string retval; - if(OPENMPT_VERSION_MIXEDREVISIONS) + if(HasMixedRevisions()) { retval += "+mixed"; } - if(OPENMPT_VERSION_DIRTY) + if(IsDirty()) { retval += "+dirty"; } @@ -137,17 +220,17 @@ std::string GetRevisionString() { - if(OPENMPT_VERSION_REVISION == 0) + if(GetRevision() == 0) { return ""; } std::ostringstream str; - str << "-r" << OPENMPT_VERSION_REVISION; - if(OPENMPT_VERSION_MIXEDREVISIONS) + str << "-r" << GetRevision(); + if(HasMixedRevisions()) { str << "!"; } - if(OPENMPT_VERSION_DIRTY) + if(IsDirty()) { str << "+"; } @@ -167,18 +250,22 @@ std::string GetVersionUrlString() { - if(OPENMPT_VERSION_REVISION == 0) + if(GetRevision() == 0) { return ""; } - std::string url = OPENMPT_VERSION_URL; + #if defined(OPENMPT_VERSION_URL) + std::string url = OPENMPT_VERSION_URL; + #else + std::string url = ""; + #endif std::string baseurl = "https://svn.code.sf.net/p/modplug/code/"; if(url.substr(0, baseurl.length()) == baseurl) { url = url.substr(baseurl.length()); } std::ostringstream str; - str << url << "@" << OPENMPT_VERSION_REVISION << GetStateString(); + str << url << "@" << GetRevision() << GetStateString(); return str.str(); } Modified: trunk/OpenMPT/common/version.h =================================================================== --- trunk/OpenMPT/common/version.h 2013-05-18 14:20:01 UTC (rev 2097) +++ trunk/OpenMPT/common/version.h 2013-05-18 14:29:53 UTC (rev 2098) @@ -16,7 +16,8 @@ //Creates version number from version parts that appears in version string. //For example MAKE_VERSION_NUMERIC(1,17,02,28) gives version number of //version 1.17.02.28. -#define MAKE_VERSION_NUMERIC(v0,v1,v2,v3) ((0x##v0 << 24) | (0x##v1<<16) | (0x##v2<<8) | (0x##v3)) +#define MAKE_VERSION_NUMERIC_HELPER(prefix,v0,v1,v2,v3) ((prefix##v0 << 24) | (prefix##v1<<16) | (prefix##v2<<8) | (prefix##v3)) +#define MAKE_VERSION_NUMERIC(v0,v1,v2,v3) MAKE_VERSION_NUMERIC_HELPER(0x,v0,v1,v2,v3) namespace MptVersion Index: trunk/OpenMPT/include/portaudio/build/msvc =================================================================== --- trunk/OpenMPT/include/portaudio/build/msvc 2013-05-18 14:20:01 UTC (rev 2097) +++ trunk/OpenMPT/include/portaudio/build/msvc 2013-05-18 14:29:53 UTC (rev 2098) Property changes on: trunk/OpenMPT/include/portaudio/build/msvc ___________________________________________________________________ Modified: svn:ignore ## -1,3 +1,4 ## portaudio_openmpt_vs2010.vcxproj.user Win32 *.user +x64 Modified: trunk/OpenMPT/include/portaudio/build/msvc/portaudio_openmpt_vs2010.vcxproj =================================================================== --- trunk/OpenMPT/include/portaudio/build/msvc/portaudio_openmpt_vs2010.vcxproj 2013-05-18 14:20:01 UTC (rev 2097) +++ trunk/OpenMPT/include/portaudio/build/msvc/portaudio_openmpt_vs2010.vcxproj 2013-05-18 14:29:53 UTC (rev 2098) @@ -49,11 +49,11 @@ <UseOfMfc>false</UseOfMfc> </PropertyGroup> <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'" Label="Configuration"> - <ConfigurationType>DynamicLibrary</ConfigurationType> + <ConfigurationType>StaticLibrary</ConfigurationType> <UseOfMfc>false</UseOfMfc> </PropertyGroup> <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'" Label="Configuration"> - <ConfigurationType>DynamicLibrary</ConfigurationType> + <ConfigurationType>StaticLibrary</ConfigurationType> <UseOfMfc>false</UseOfMfc> </PropertyGroup> <Import Project="$(VCTargetsPath)\Microsoft.Cpp.props" /> @@ -186,9 +186,9 @@ <IntrinsicFunctions>true</IntrinsicFunctions> <FavorSizeOrSpeed>Speed</FavorSizeOrSpeed> <AdditionalIncludeDirectories>..\..\src\common;..\..\include;.\;..\..\src\os\win;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories> - <PreprocessorDefinitions>_WIN64;NDEBUG;_USRDLL;PA_ENABLE_DEBUG_OUTPUT;_CRT_SECURE_NO_DEPRECATE;PAWIN_USE_WDMKS_DEVICE_INFO;PA_WDMKS_NO_KSGUID_LIB;PA_USE_ASIO=0;PA_USE_DS=0;PA_USE_WMME=1;PA_USE_WASAPI=1;PA_USE_WDMKS=1;%(PreprocessorDefinitions)</PreprocessorDefinitions> + <PreprocessorDefinitions>_WIN64;NDEBUG;_USRDLL;PA_ENABLE_DEBUG_OUTPUT;_CRT_SECURE_NO_DEPRECATE;PAWIN_USE_WDMKS_DEVICE_INFO;PA_WDMKS_NO_KSGUID_LIB;PA_USE_ASIO=0;PA_USE_DS=0;PA_USE_WMME=1;PA_USE_WASAPI=1;PA_USE_WDMKS=0;%(PreprocessorDefinitions)</PreprocessorDefinitions> <StringPooling>true</StringPooling> - <RuntimeLibrary>MultiThreadedDLL</RuntimeLibrary> + <RuntimeLibrary>MultiThreaded</RuntimeLibrary> <FunctionLevelLinking>true</FunctionLevelLinking> <PrecompiledHeaderOutputFile>$(Platform)\$(Configuration)\portaudio.pch</PrecompiledHeaderOutputFile> <AssemblerListingLocation>$(Platform)\$(Configuration)\</AssemblerListingLocation> @@ -273,7 +273,7 @@ <ClCompile> <Optimization>Disabled</Optimization> <AdditionalIncludeDirectories>..\..\src\common;..\..\include;.\;..\..\src\os\win;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories> - <PreprocessorDefinitions>_WIN64;_DEBUG;_USRDLL;PA_ENABLE_DEBUG_OUTPUT;_CRT_SECURE_NO_DEPRECATE;PAWIN_USE_WDMKS_DEVICE_INFO;PA_WDMKS_NO_KSGUID_LIB;PA_USE_ASIO=0;PA_USE_DS=0;PA_USE_WMME=1;PA_USE_WASAPI=1;PA_USE_WDMKS=1;%(PreprocessorDefinitions)</PreprocessorDefinitions> + <PreprocessorDefinitions>_WIN64;_DEBUG;_USRDLL;PA_ENABLE_DEBUG_OUTPUT;_CRT_SECURE_NO_DEPRECATE;PAWIN_USE_WDMKS_DEVICE_INFO;PA_WDMKS_NO_KSGUID_LIB;PA_USE_ASIO=0;PA_USE_DS=0;PA_USE_WMME=1;PA_USE_WASAPI=1;PA_USE_WDMKS=0;%(PreprocessorDefinitions)</PreprocessorDefinitions> <MinimalRebuild>true</MinimalRebuild> <BasicRuntimeChecks>EnableFastChecks</BasicRuntimeChecks> <RuntimeLibrary>MultiThreadedDebugDLL</RuntimeLibrary> @@ -566,6 +566,8 @@ <PreprocessorDefinitions Condition="'$(Configuration)|$(Platform)'=='Release|x64'">%(PreprocessorDefinitions)</PreprocessorDefinitions> <ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">true</ExcludedFromBuild> <ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">true</ExcludedFromBuild> + <ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">true</ExcludedFromBuild> + <ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Release|x64'">true</ExcludedFromBuild> </ClCompile> <ClCompile Include="..\..\src\hostapi\asio\ASIOSDK\common\asio.cpp"> <AdditionalIncludeDirectories Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">..\..\src\hostapi\asio\ASIOSDK\host;..\..\src\hostapi\asio\ASIOSDK\host\pc;..\..\src\hostapi\asio\ASIOSDK\common;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories> @@ -582,6 +584,8 @@ <PreprocessorDefinitions Condition="'$(Configuration)|$(Platform)'=='Release|x64'">%(PreprocessorDefinitions)</PreprocessorDefinitions> <ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">true</ExcludedFromBuild> <ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">true</ExcludedFromBuild> + <ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">true</ExcludedFromBuild> + <ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Release|x64'">true</ExcludedFromBuild> </ClCompile> <ClCompile Include="..\..\src\hostapi\asio\ASIOSDK\host\asiodrivers.cpp"> <AdditionalIncludeDirectories Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">..\..\src\hostapi\asio\ASIOSDK\host;..\..\src\hostapi\asio\ASIOSDK\host\pc;..\..\src\hostapi\asio\ASIOSDK\common;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories> @@ -598,6 +602,8 @@ <PreprocessorDefinitions Condition="'$(Configuration)|$(Platform)'=='Release|x64'">%(PreprocessorDefinitions)</PreprocessorDefinitions> <ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">true</ExcludedFromBuild> <ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">true</ExcludedFromBuild> + <ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">true</ExcludedFromBuild> + <ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Release|x64'">true</ExcludedFromBuild> </ClCompile> <ClCompile Include="..\..\src\hostapi\asio\ASIOSDK\host\pc\asiolist.cpp"> <AdditionalIncludeDirectories Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">..\..\src\hostapi\asio\ASIOSDK\host;..\..\src\hostapi\asio\ASIOSDK\host\pc;..\..\src\hostapi\asio\ASIOSDK\common;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories> @@ -614,6 +620,8 @@ <PreprocessorDefinitions Condition="'$(Configuration)|$(Platform)'=='Release|x64'">%(PreprocessorDefinitions)</PreprocessorDefinitions> <ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">true</ExcludedFromBuild> <ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">true</ExcludedFromBuild> + <ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">true</ExcludedFromBuild> + <ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Release|x64'">true</ExcludedFromBuild> </ClCompile> <ClCompile Include="..\..\src\hostapi\dsound\pa_win_ds.c"> <AdditionalIncludeDirectories Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories> @@ -661,6 +669,8 @@ <ClCompile Include="..\..\src\hostapi\wdmks\pa_win_wdmks.c"> <ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">true</ExcludedFromBuild> <ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">true</ExcludedFromBuild> + <ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">true</ExcludedFromBuild> + <ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Release|x64'">true</ExcludedFromBuild> </ClCompile> <ClCompile Include="..\..\src\os\win\pa_win_coinitialize.c" /> <ClCompile Include="..\..\src\os\win\pa_win_hostapis.c"> Index: trunk/OpenMPT/include/zlib/contrib/vstudio/vc10 =================================================================== --- trunk/OpenMPT/include/zlib/contrib/vstudio/vc10 2013-05-18 14:20:01 UTC (rev 2097) +++ trunk/OpenMPT/include/zlib/contrib/vstudio/vc10 2013-05-18 14:29:53 UTC (rev 2098) Property changes on: trunk/OpenMPT/include/zlib/contrib/vstudio/vc10 ___________________________________________________________________ Modified: svn:ignore ## -1 +1,2 ## x86 +x64 Modified: trunk/OpenMPT/include/zlib/contrib/vstudio/vc10/zlibstat.vcxproj =================================================================== --- trunk/OpenMPT/include/zlib/contrib/vstudio/vc10/zlibstat.vcxproj 2013-05-18 14:20:01 UTC (rev 2097) +++ trunk/OpenMPT/include/zlib/contrib/vstudio/vc10/zlibstat.vcxproj 2013-05-18 14:29:53 UTC (rev 2098) @@ -308,7 +308,7 @@ <StringPooling>true</StringPooling> <ExceptionHandling> </ExceptionHandling> - <RuntimeLibrary>MultiThreadedDLL</RuntimeLibrary> + <RuntimeLibrary>MultiThreaded</RuntimeLibrary> <BufferSecurityCheck>false</BufferSecurityCheck> <FunctionLevelLinking>true</FunctionLevelLinking> <PrecompiledHeaderOutputFile>$(IntDir)zlibstat.pch</PrecompiledHeaderOutputFile> @@ -369,7 +369,7 @@ <StringPooling>true</StringPooling> <ExceptionHandling> </ExceptionHandling> - <RuntimeLibrary>MultiThreadedDLL</RuntimeLibrary> + <RuntimeLibrary>MultiThreaded</RuntimeLibrary> <BufferSecurityCheck>false</BufferSecurityCheck> <FunctionLevelLinking>true</FunctionLevelLinking> <PrecompiledHeaderOutputFile>$(IntDir)zlibstat.pch</PrecompiledHeaderOutputFile> Index: trunk/OpenMPT/libopenmpt =================================================================== --- trunk/OpenMPT/libopenmpt 2013-05-18 14:20:01 UTC (rev 2097) +++ trunk/OpenMPT/libopenmpt 2013-05-18 14:29:53 UTC (rev 2098) Property changes on: trunk/OpenMPT/libopenmpt ___________________________________________________________________ Modified: svn:ignore ## -14,3 +14,4 ## libopenmpt_settings.vcxproj.user libopenmpt_foobar2000.opensdf libopenmpt_foobar2000.suo +x64 Modified: trunk/OpenMPT/libopenmpt/libopenmpt.sln =================================================================== --- trunk/OpenMPT/libopenmpt/libopenmpt.sln 2013-05-18 14:20:01 UTC (rev 2097) +++ trunk/OpenMPT/libopenmpt/libopenmpt.sln 2013-05-18 14:29:53 UTC (rev 2098) @@ -13,21 +13,33 @@ Global GlobalSection(SolutionConfigurationPlatforms) = preSolution Debug|Win32 = Debug|Win32 + Debug|x64 = Debug|x64 Release|Win32 = Release|Win32 + Release|x64 = Release|x64 EndGlobalSection GlobalSection(ProjectConfigurationPlatforms) = postSolution {812A654D-99BE-4D13-B97F-86332AD3E363}.Debug|Win32.ActiveCfg = Debug|Win32 {812A654D-99BE-4D13-B97F-86332AD3E363}.Debug|Win32.Build.0 = Debug|Win32 + {812A654D-99BE-4D13-B97F-86332AD3E363}.Debug|x64.ActiveCfg = Debug|x64 + {812A654D-99BE-4D13-B97F-86332AD3E363}.Debug|x64.Build.0 = Debug|x64 {812A654D-99BE-4D13-B97F-86332AD3E363}.Release|Win32.ActiveCfg = Release|Win32 {812A654D-99BE-4D13-B97F-86332AD3E363}.Release|Win32.Build.0 = Release|Win32 + {812A654D-99BE-4D13-B97F-86332AD3E363}.Release|x64.ActiveCfg = Release|x64 + {812A654D-99BE-4D13-B97F-86332AD3E363}.Release|x64.Build.0 = Release|x64 {745DEC58-EBB3-47A9-A9B8-4C6627C01BF8}.Debug|Win32.ActiveCfg = Debug|Win32 {745DEC58-EBB3-47A9-A9B8-4C6627C01BF8}.Debug|Win32.Build.0 = Debug|Win32 + {745DEC58-EBB3-47A9-A9B8-4C6627C01BF8}.Debug|x64.ActiveCfg = Debug|x64 + {745DEC58-EBB3-47A9-A9B8-4C6627C01BF8}.Debug|x64.Build.0 = Debug|x64 {745DEC58-EBB3-47A9-A9B8-4C6627C01BF8}.Release|Win32.ActiveCfg = ReleaseWithoutAsm|Win32 {745DEC58-EBB3-47A9-A9B8-4C6627C01BF8}.Release|Win32.Build.0 = ReleaseWithoutAsm|Win32 + {745DEC58-EBB3-47A9-A9B8-4C6627C01BF8}.Release|x64.ActiveCfg = ReleaseWithoutAsm|x64 + {745DEC58-EBB3-47A9-A9B8-4C6627C01BF8}.Release|x64.Build.0 = ReleaseWithoutAsm|x64 {B2B6EE07-F662-496D-980C-FCA7CA144DBC}.Debug|Win32.ActiveCfg = Debug|Win32 {B2B6EE07-F662-496D-980C-FCA7CA144DBC}.Debug|Win32.Build.0 = Debug|Win32 + {B2B6EE07-F662-496D-980C-FCA7CA144DBC}.Debug|x64.ActiveCfg = Debug|Win32 {B2B6EE07-F662-496D-980C-FCA7CA144DBC}.Release|Win32.ActiveCfg = Release|Win32 {B2B6EE07-F662-496D-980C-FCA7CA144DBC}.Release|Win32.Build.0 = Release|Win32 + {B2B6EE07-F662-496D-980C-FCA7CA144DBC}.Release|x64.ActiveCfg = Release|Win32 EndGlobalSection GlobalSection(SolutionProperties) = preSolution HideSolutionNode = FALSE Modified: trunk/OpenMPT/libopenmpt/libopenmpt.vcxproj =================================================================== --- trunk/OpenMPT/libopenmpt/libopenmpt.vcxproj 2013-05-18 14:20:01 UTC (rev 2097) +++ trunk/OpenMPT/libopenmpt/libopenmpt.vcxproj 2013-05-18 14:29:53 UTC (rev 2098) @@ -5,18 +5,34 @@ <Configuration>DebugStatic</Configuration> <Platform>Win32</Platform> </ProjectConfiguration> + <ProjectConfiguration Include="DebugStatic|x64"> + <Configuration>DebugStatic</Configuration> + <Platform>x64</Platform> + </ProjectConfiguration> <ProjectConfiguration Include="Debug|Win32"> <Configuration>Debug</Configuration> <Platform>Win32</Platform> </ProjectConfiguration> + <ProjectConfiguration Include="Debug|x64"> + <Configuration>Debug</Configuration> + <Platform>x64</Platform> + </ProjectConfiguration> <ProjectConfiguration Include="ReleaseStatic|Win32"> <Configuration>ReleaseStatic</Configuration> <Platform>Win32</Platform> </ProjectConfiguration> + <ProjectConfiguration Include="ReleaseStatic|x64"> + <Configuration>ReleaseStatic</Configuration> + <Platform>x64</Platform> + </ProjectConfiguration> <ProjectConfiguration Include="Release|Win32"> <Configuration>Release</Configuration> <Platform>Win32</Platform> </ProjectConfiguration> + <ProjectConfiguration Include="Release|x64"> + <Configuration>Release</Configuration> + <Platform>x64</Platform> + </ProjectConfiguration> </ItemGroup> <PropertyGroup Label="Globals"> <ProjectGuid>{812A654D-99BE-4D13-B97F-86332AD3E363}</ProjectGuid> @@ -28,43 +44,82 @@ <UseDebugLibraries>true</UseDebugLibraries> <CharacterSet>NotSet</CharacterSet> </PropertyGroup> + <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'" Label="Configuration"> + <ConfigurationType>DynamicLibrary</ConfigurationType> + <UseDebugLibraries>true</UseDebugLibraries> + <CharacterSet>NotSet</CharacterSet> + </PropertyGroup> <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='DebugStatic|Win32'" Label="Configuration"> <ConfigurationType>StaticLibrary</ConfigurationType> <UseDebugLibraries>true</UseDebugLibraries> <CharacterSet>NotSet</CharacterSet> </PropertyGroup> + <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='DebugStatic|x64'" Label="Configuration"> + <ConfigurationType>StaticLibrary</ConfigurationType> + <UseDebugLibraries>true</UseDebugLibraries> + <CharacterSet>NotSet</CharacterSet> + </PropertyGroup> <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'" Label="Configuration"> <ConfigurationType>DynamicLibrary</ConfigurationType> <UseDebugLibraries>false</UseDebugLibraries> <WholeProgramOptimization>false</WholeProgramOptimization> <CharacterSet>NotSet</CharacterSet> </PropertyGroup> + <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'" Label="Configuration"> + <ConfigurationType>DynamicLibrary</ConfigurationType> + <UseDebugLibraries>false</UseDebugLibraries> + <WholeProgramOptimization>false</WholeProgramOptimization> + <CharacterSet>NotSet</CharacterSet> + </PropertyGroup> <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='ReleaseStatic|Win32'" Label="Configuration"> <ConfigurationType>StaticLibrary</ConfigurationType> <UseDebugLibraries>false</UseDebugLibraries> <WholeProgramOptimization>false</WholeProgramOptimization> <CharacterSet>NotSet</CharacterSet> </PropertyGroup> + <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='ReleaseStatic|x64'" Label="Configuration"> + <ConfigurationType>StaticLibrary</ConfigurationType> + <UseDebugLibraries>false</UseDebugLibraries> + <WholeProgramOptimization>false</WholeProgramOptimization> + <CharacterSet>NotSet</CharacterSet> + </PropertyGroup> <Import Project="$(VCTargetsPath)\Microsoft.Cpp.props" /> <ImportGroup Label="ExtensionSettings"> </ImportGroup> <ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'"> <Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" /> </ImportGroup> + <ImportGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'" Label="PropertySheets"> + <Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" /> + </ImportGroup> <ImportGroup Condition="'$(Configuration)|$(Platform)'=='DebugStatic|Win32'" Label="PropertySheets"> <Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" /> </ImportGroup> + <ImportGroup Condition="'$(Configuration)|$(Platform)'=='DebugStatic|x64'" Label="PropertySheets"> + <Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" /> + </ImportGroup> <ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Release|Win32'"> <Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" /> </ImportGroup> + <ImportGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'" Label="PropertySheets"> + <Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" /> + </ImportGroup> <ImportGroup Condition="'$(Configuration)|$(Platform)'=='ReleaseStatic|Win32'" Label="PropertySheets"> <Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" /> </ImportGroup> + <ImportGroup Condition="'$(Configuration)|$(Platform)'=='ReleaseStatic|x64'" Label="PropertySheets"> + <Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" /> + </ImportGroup> <PropertyGroup Label="UserMacros" /> <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'"> <OutDir>bin\</OutDir> </PropertyGroup> + <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'"> + <OutDir>bin\</OutDir> + <TargetName>$(ProjectName)64</TargetName> + </PropertyGroup> <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'" /> + <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'" /> <ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'"> <ClCompile> <WarningLevel>Level3</WarningLevel> @@ -86,6 +141,27 @@ </Command> </PostBuildEvent> </ItemDefinitionGroup> + <ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'"> + <ClCompile> + <WarningLevel>Level3</WarningLevel> + <Optimization>Disabled</Optimization> + <AdditionalIncludeDirectories>..;../common;../include;../common/svn_version;../common/svn_version_default</AdditionalIncludeDirectories> + <PreprocessorDefinitions>_WINDLL;LIBOPENMPT_BUILD;LIBOPENMPT_BUILD_DLL;%(PreprocessorDefinitions)</PreprocessorDefinitions> + <RuntimeLibrary>MultiThreadedDebugDLL</RuntimeLibrary> + </ClCompile> + <Link> + <GenerateDebugInformation>true</GenerateDebugInformation> + <ModuleDefinitionFile>xmpin.def</ModuleDefinitionFile> + <DelayLoadDLLs>libopenmpt_settings.dll</DelayLoadDLLs> + </Link> + <PreBuildEvent> + <Command>subwcrev .. ..\common\svn_version\svn_version.template.h ..\common\svn_version\svn_version.h || del ..\common\svn_version\svn_version.h || true</Command> + </PreBuildEvent> + <PostBuildEvent> + <Command> + </Command> + </PostBuildEvent> + </ItemDefinitionGroup> <ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='DebugStatic|Win32'"> <ClCompile> <WarningLevel>Level3</WarningLevel> @@ -104,6 +180,24 @@ <AdditionalOptions>/ignore:4221 %(AdditionalOptions)</AdditionalOptions> </Lib> </ItemDefinitionGroup> + <ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='DebugStatic|x64'"> + <ClCompile> + <WarningLevel>Level3</WarningLevel> + <Optimization>Disabled</Optimization> + <AdditionalIncludeDirectories>..;../common;../include;../common/svn_version;../common/svn_version_default</AdditionalIncludeDirectories> + <PreprocessorDefinitions>LIBOPENMPT_BUILD;%(PreprocessorDefinitions)</PreprocessorDefinitions> + <RuntimeLibrary>MultiThreadedDebugDLL</RuntimeLibrary> + </ClCompile> + <Link> + <GenerateDebugInformation>true</GenerateDebugInformation> + </Link> + <PreBuildEvent> + <Command>subwcrev .. ..\common\svn_version\svn_version.template.h ..\common\svn_version\svn_version.h || del ..\common\svn_version\svn_version.h || true</Command> + </PreBuildEvent> + <Lib> + <AdditionalOptions>/ignore:4221 %(AdditionalOptions)</AdditionalOptions> + </Lib> + </ItemDefinitionGroup> ... [truncated message content] |
From: <man...@us...> - 2013-05-18 18:42:50
|
Revision: 2103 http://sourceforge.net/p/modplug/code/2103 Author: manxorist Date: 2013-05-18 18:42:27 +0000 (Sat, 18 May 2013) Log Message: ----------- [Ref] Build openmpt with VS2010 release builds with warning level 4. Silence some resulting trivial warnings right away. Modified Paths: -------------- trunk/OpenMPT/common/typedefs.cpp trunk/OpenMPT/mptrack/mptrack_10.vcxproj trunk/OpenMPT/sounddsp/DSP.cpp trunk/OpenMPT/soundlib/Mmx_mix.cpp trunk/OpenMPT/unarchiver/unlha.cpp Modified: trunk/OpenMPT/common/typedefs.cpp =================================================================== --- trunk/OpenMPT/common/typedefs.cpp 2013-05-18 18:20:21 UTC (rev 2102) +++ trunk/OpenMPT/common/typedefs.cpp 2013-05-18 18:42:27 UTC (rev 2103) @@ -147,6 +147,12 @@ << std::endl; } #endif // MODPLUG_TRACKER +#else + UNREFERENCED_PARAMETER(file); + UNREFERENCED_PARAMETER(line); + UNREFERENCED_PARAMETER(function); + UNREFERENCED_PARAMETER(format); + UNREFERENCED_PARAMETER(args); #endif } Modified: trunk/OpenMPT/mptrack/mptrack_10.vcxproj =================================================================== --- trunk/OpenMPT/mptrack/mptrack_10.vcxproj 2013-05-18 18:20:21 UTC (rev 2102) +++ trunk/OpenMPT/mptrack/mptrack_10.vcxproj 2013-05-18 18:42:27 UTC (rev 2103) @@ -149,7 +149,7 @@ <AssemblerListingLocation>.\Release/</AssemblerListingLocation> <ObjectFileName>.\Release/</ObjectFileName> <ProgramDataBaseFileName>.\Release/</ProgramDataBaseFileName> - <WarningLevel>Level3</WarningLevel> + <WarningLevel>Level4</WarningLevel> <DebugInformationFormat>ProgramDatabase</DebugInformationFormat> <CompileAs>Default</CompileAs> <ExceptionHandling>Async</ExceptionHandling> @@ -212,7 +212,7 @@ <AssemblerListingLocation>.\ReleaseLTCG/</AssemblerListingLocation> <ObjectFileName>.\ReleaseLTCG/</ObjectFileName> <ProgramDataBaseFileName>.\ReleaseLTCG/</ProgramDataBaseFileName> - <WarningLevel>Level3</WarningLevel> + <WarningLevel>Level4</WarningLevel> <DebugInformationFormat>ProgramDatabase</DebugInformationFormat> <CompileAs>Default</CompileAs> <ExceptionHandling>Async</ExceptionHandling> Modified: trunk/OpenMPT/sounddsp/DSP.cpp =================================================================== --- trunk/OpenMPT/sounddsp/DSP.cpp 2013-05-18 18:20:21 UTC (rev 2102) +++ trunk/OpenMPT/sounddsp/DSP.cpp 2013-05-18 18:42:27 UTC (rev 2103) @@ -14,7 +14,11 @@ #include "../sounddsp/DSP.h" #include <math.h> +#ifdef _MSC_VER +#pragma warning(disable: 4725) // instruction may be inaccurate on some Pentiums +#endif + #ifndef NO_DSP Modified: trunk/OpenMPT/soundlib/Mmx_mix.cpp =================================================================== --- trunk/OpenMPT/soundlib/Mmx_mix.cpp 2013-05-18 18:20:21 UTC (rev 2102) +++ trunk/OpenMPT/soundlib/Mmx_mix.cpp 2013-05-18 18:42:27 UTC (rev 2103) @@ -74,8 +74,8 @@ test edx, (1<<22) // Bit 22: AMD MMX extensions jz Done or fProcessorExtensions, PROCSUPPORT_MMXEX // MMX extensions supported + Done: } -Done: bMMXChecked = true; } return fProcessorExtensions; Modified: trunk/OpenMPT/unarchiver/unlha.cpp =================================================================== --- trunk/OpenMPT/unarchiver/unlha.cpp 2013-05-18 18:20:21 UTC (rev 2102) +++ trunk/OpenMPT/unarchiver/unlha.cpp 2013-05-18 18:42:27 UTC (rev 2103) @@ -15,6 +15,10 @@ #undef USHRT_MAX #undef SHRT_MIN +#ifdef _MSC_VER +#pragma warning(disable: 4244) // conversion from 'type1' to 'type2', possible loss of data +#endif + #include "unlha/lharc.h" #include "unlha/slidehuf.h" #include "unlha/header.cpp" This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <man...@us...> - 2013-05-19 12:29:15
|
Revision: 2118 http://sourceforge.net/p/modplug/code/2118 Author: manxorist Date: 2013-05-19 12:29:06 +0000 (Sun, 19 May 2013) Log Message: ----------- [Ref] First steps towards building a shared library of libopenmpt on linux. Modified Paths: -------------- trunk/OpenMPT/libopenmpt/libopenmpt_config.h trunk/OpenMPT/libopenmpt/libopenmpt_internal.h trunk/OpenMPT/openmpt123/Makefile Modified: trunk/OpenMPT/libopenmpt/libopenmpt_config.h =================================================================== --- trunk/OpenMPT/libopenmpt/libopenmpt_config.h 2013-05-19 12:27:11 UTC (rev 2117) +++ trunk/OpenMPT/libopenmpt/libopenmpt_config.h 2013-05-19 12:29:06 UTC (rev 2118) @@ -10,15 +10,40 @@ #ifndef LIBOPENMPT_CONFIG_H #define LIBOPENMPT_CONFIG_H -#if defined(LIBOPENMPT_USE_DLL) -#define LIBOPENMPT_API __declspec(dllimport) +#if defined(LIBOPENMPT_BUILD_DLL) || defined(LIBOPENMPT_USE_DLL) +#if defined(_MSC_VER) || defined(_WIN32) +#define LIBOPENMPT_DLL_HELPER_EXPORT __declspec(dllexport) +#define LIBOPENMPT_DLL_HELPER_IMPORT __declspec(dllimport) +#define LIBOPENMPT_DLL_HELPER_LOCAL +#elif defined(__GNUC__) +#define LIBOPENMPT_DLL_HELPER_EXPORT __attribute__((visibility("default"))) +#define LIBOPENMPT_DLL_HELPER_IMPORT __attribute__((visibility("default"))) +#define LIBOPENMPT_DLL_HELPER_LOCAL __attribute__((visibility("hidden"))) +#else +#define LIBOPENMPT_DLL_HELPER_EXPORT +#define LIBOPENMPT_DLL_HELPER_IMPORT +#define LIBOPENMPT_DLL_HELPER_LOCAL +#endif +#else +#define LIBOPENMPT_DLL_HELPER_EXPORT +#define LIBOPENMPT_DLL_HELPER_IMPORT +#define LIBOPENMPT_DLL_HELPER_LOCAL +#endif + +#if defined(LIBOPENMPT_BUILD_DLL) +#define LIBOPENMPT_API LIBOPENMPT_DLL_HELPER_EXPORT #ifdef __cplusplus -#define LIBOPENMPT_CXX_API __declspec(dllimport) +#define LIBOPENMPT_CXX_API LIBOPENMPT_DLL_HELPER_EXPORT #endif +#elif defined(LIBOPENMPT_USE_DLL) +#define LIBOPENMPT_API LIBOPENMPT_DLL_HELPER_IMPORT +#ifdef __cplusplus +#define LIBOPENMPT_CXX_API LIBOPENMPT_DLL_HELPER_IMPORT +#endif #else #define LIBOPENMPT_API extern #ifdef __cplusplus -#define LIBOPENMPT_CXX_API +#define LIBOPENMPT_CXX_API #endif #endif @@ -27,7 +52,7 @@ #if defined(_MSC_VER) && !defined(_DLL) #error "C++ interface is disabled if libopenmpt is built as a DLL and the runtime is statically linked. This is not supported by microsoft and cannot possibly work. Ever." #undef LIBOPENMPT_CXX_API -#define LIBOPENMPT_CXX_API +#define LIBOPENMPT_CXX_API LIBOPENMPT_DLL_HELPER_LOCAL #endif #endif #endif Modified: trunk/OpenMPT/libopenmpt/libopenmpt_internal.h =================================================================== --- trunk/OpenMPT/libopenmpt/libopenmpt_internal.h 2013-05-19 12:27:11 UTC (rev 2117) +++ trunk/OpenMPT/libopenmpt/libopenmpt_internal.h 2013-05-19 12:29:06 UTC (rev 2118) @@ -10,34 +10,19 @@ #ifndef LIBOPENMPT_INTERNAL_H #define LIBOPENMPT_INTERNAL_H -/* prevent regular config header from applying settings */ -#define LIBOPENMPT_CONFIG_H +/* disable alpha version warning in internal builds */ +#define LIBOPENMPT_ALPHA_WARNING_SEEN_AND_I_KNOW_WHAT_I_AM_DOING -#if defined(LIBOPENMPT_BUILD_DLL) -#define LIBOPENMPT_API __declspec(dllexport) -#ifdef __cplusplus -#define LIBOPENMPT_CXX_API __declspec(dllexport) -#endif -#elif defined(LIBOPENMPT_USE_DLL) -#define LIBOPENMPT_API __declspec(dllimport) -#ifdef __cplusplus -#define LIBOPENMPT_CXX_API __declspec(dllimport) -#endif -#else -#define LIBOPENMPT_API extern -#ifdef __cplusplus -#define LIBOPENMPT_CXX_API -#endif -#endif +#include "libopenmpt_config.h" #if defined(NO_LIBOPENMPT_C) #undef LIBOPENMPT_API -#define LIBOPENMPT_API +#define LIBOPENMPT_API LIBOPENMPT_DLL_HELPER_LOCAL #endif #if defined(NO_LIBOPENMPT_CXX) #undef LIBOPENMPT_CXX_API -#define LIBOPENMPT_CXX_API +#define LIBOPENMPT_CXX_API LIBOPENMPT_DLL_HELPER_LOCAL #endif #ifdef __cplusplus @@ -48,16 +33,11 @@ #pragma message( "libopenmpt C++ interface is disabled if libopenmpt is built as a DLL and the runtime is statically linked. This is not supported by microsoft and cannot possibly work. Ever." ) #endif #undef LIBOPENMPT_CXX_API -#define LIBOPENMPT_CXX_API +#define LIBOPENMPT_CXX_API LIBOPENMPT_DLL_HELPER_LOCAL #endif #endif #endif -/* disable alpha version warning in internal builds */ -#define LIBOPENMPT_ALPHA_WARNING_SEEN_AND_I_KNOW_WHAT_I_AM_DOING - -#include "libopenmpt_version.h" - #ifdef __cplusplus namespace openmpt { namespace version { #ifndef NO_WINAMP Modified: trunk/OpenMPT/openmpt123/Makefile =================================================================== --- trunk/OpenMPT/openmpt123/Makefile 2013-05-19 12:27:11 UTC (rev 2117) +++ trunk/OpenMPT/openmpt123/Makefile 2013-05-19 12:29:06 UTC (rev 2118) @@ -4,8 +4,8 @@ LD = $(SILENT)g++ CPPFLAGS = -I../common -I.. -CXXFLAGS = -std=gnu++0x -O3 -fno-strict-aliasing -ffast-math -Wall -Wextra -CFLAGS = -std=gnu99 -O3 -fno-strict-aliasing -ffast-math -Wall -Wextra +CXXFLAGS = -std=gnu++0x -O3 -fPIC -fvisibility=hidden -fno-strict-aliasing -ffast-math -Wall -Wextra -Wcast-align +CFLAGS = -std=gnu99 -O3 -fPIC -fvisibility=hidden -fno-strict-aliasing -ffast-math -Wall -Wextra -Wcast-align LDFLAGS = LDLIBS = -lm This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <man...@us...> - 2013-05-19 20:14:04
|
Revision: 2137 http://sourceforge.net/p/modplug/code/2137 Author: manxorist Date: 2013-05-19 20:13:48 +0000 (Sun, 19 May 2013) Log Message: ----------- [Ref] Wrap _MSC_VER and __GNUC__ compiler detection macros into MPT_COMPILER_MSVC and MPT_COMPILER_GCC. Also provide detection macros for clang. This is useful because clang (and icc and probably others as well) try to emulate gcc or msvc and so they also define these respective macros in addition to their own. [Ref] Add MPT_[MSVC|GCC|CLANG]_AT_LEAST and MPT_[MSVC|GCC|CLANG]_BEFORE version test macros. [Ref] Replace all usages of native compiler macros with our own ones (except in openmpt123 (which does not use common/ infrastructure) and except in libopenmpt public header files (which should not depend on other compilcated stuff); Also leave libopenmpt itself alone for now because only libopenmpt_impl.hpp should depend on anything directly from the openmpt source base.). [Ref] Remove dead code in stdafx.cpp while at it. Modified Paths: -------------- trunk/OpenMPT/common/BuildSettings.h trunk/OpenMPT/common/misc_util.h trunk/OpenMPT/common/mptString.cpp trunk/OpenMPT/common/mptString.h trunk/OpenMPT/common/stdafx.cpp trunk/OpenMPT/common/stdafx.h trunk/OpenMPT/common/typedefs.cpp trunk/OpenMPT/common/typedefs.h trunk/OpenMPT/libopenmpt/libopenmpt.vcxproj trunk/OpenMPT/libopenmpt/libopenmpt.vcxproj.filters trunk/OpenMPT/mptrack/Mptrack.cpp trunk/OpenMPT/mptrack/Mptrack.h trunk/OpenMPT/mptrack/mptrack_08.vcproj trunk/OpenMPT/mptrack/mptrack_10.vcxproj trunk/OpenMPT/mptrack/mptrack_10.vcxproj.filters trunk/OpenMPT/sounddsp/DSP.cpp trunk/OpenMPT/soundlib/Endianness.h trunk/OpenMPT/soundlib/Fastmix.cpp trunk/OpenMPT/soundlib/Load_mdl.cpp trunk/OpenMPT/soundlib/Load_ptm.cpp trunk/OpenMPT/soundlib/Load_stm.cpp trunk/OpenMPT/soundlib/ModChannel.h trunk/OpenMPT/soundlib/SampleIO.cpp trunk/OpenMPT/soundlib/Snd_fx.cpp trunk/OpenMPT/soundlib/Sndfile.cpp trunk/OpenMPT/soundlib/Sndfile.h trunk/OpenMPT/soundlib/load_j2b.cpp trunk/OpenMPT/soundlib/tuningbase.h trunk/OpenMPT/unarchiver/unlha.cpp Added Paths: ----------- trunk/OpenMPT/common/CompilerDetect.h Modified: trunk/OpenMPT/common/BuildSettings.h =================================================================== --- trunk/OpenMPT/common/BuildSettings.h 2013-05-19 17:37:45 UTC (rev 2136) +++ trunk/OpenMPT/common/BuildSettings.h 2013-05-19 20:13:48 UTC (rev 2137) @@ -12,6 +12,10 @@ +#include "CompilerDetect.h" + + + // Do not use precompiled headers (prevents include of commonly used headers in stdafx.h) #ifdef MODPLUG_TRACKER //#define NO_PCH @@ -25,7 +29,7 @@ #define ENABLE_ASM // inline assembly requires MSVC compiler -#if defined(ENABLE_ASM) && defined(_MSC_VER) && defined(_M_IX86) +#if defined(ENABLE_ASM) && MPT_COMPILER_MSVC && defined(_M_IX86) // Generate general x86 inline assembly. #define ENABLE_X86 @@ -146,12 +150,12 @@ -#ifdef _MSC_VER +#if MPT_COMPILER_MSVC #define VC_EXTRALEAN // Exclude rarely-used stuff from Windows headers #endif #ifdef _WIN32 -#if defined(_MSC_VER) && (_MSC_VER >= 1600) +#if MPT_COMPILER_MSVC && MPT_MSVC_AT_LEAST(2010,0) #define _WIN32_WINNT 0x0501 // _WIN32_WINNT_WINXP #else #define _WIN32_WINNT 0x0500 // _WIN32_WINNT_WIN2000 @@ -191,7 +195,7 @@ #endif -#ifdef _MSC_VER +#if MPT_COMPILER_MSVC #define _CRT_SECURE_NO_WARNINGS // Define to disable the "This function or variable may be unsafe" warnings. #define _CRT_SECURE_CPP_OVERLOAD_STANDARD_NAMES 1 #define _CRT_SECURE_CPP_OVERLOAD_STANDARD_NAMES_COUNT 1 Added: trunk/OpenMPT/common/CompilerDetect.h =================================================================== --- trunk/OpenMPT/common/CompilerDetect.h (rev 0) +++ trunk/OpenMPT/common/CompilerDetect.h 2013-05-19 20:13:48 UTC (rev 2137) @@ -0,0 +1,76 @@ +/* + * CompilerDetect.h + * ---------------- + * Purpose: Detect current compiler and provide readable version test macros. + * Notes : (currently none) + * Authors: OpenMPT Devs + * The OpenMPT source code is released under the BSD license. Read LICENSE for more details. + */ + + +#pragma once + + + +#define MPT_COMPILER_MAKE_VERSION2(version,sp) ((version) * 100 + (sp)) +#define MPT_COMPILER_MAKE_VERSION3(major,minor,patch) ((major) * 10000 + (minor) * 100 + (patch)) + + + +#if defined(__clang__) + +#define MPT_COMPILER_CLANG 1 +#define MPT_COMPILER_CLANG_VERSION MPT_COMPILER_MAKE_VERSION3(__clang_major__,__clang_minor__,__clang_patchlevel__) +#define MPT_CLANG_AT_LEAST(major,minor,patch) (MPT_COMPILER_CLANG_VERSION >= MPT_COMPILER_MAKE_VERSION3((major),(minor),(patch))) +#define MPT_CLANG_BEFORE(major,minor,patch) (MPT_COMPILER_CLANG_VERSION < MPT_COMPILER_MAKE_VERSION3((major),(minor),(patch))) + +#if MPT_CLANG_BEFORE(3,0,0) +#pragma message "clang version 3.0 required" +#endif + +#elif defined(__GNUC__) + +#define MPT_COMPILER_GCC 1 +#define MPT_COMPILER_GCC_VERSION MPT_COMPILER_MAKE_VERSION3(__GNUC__,__GNUC_MINOR__,__GNUC_PATCHLEVEL__) +#define MPT_GCC_AT_LEAST(major,minor,patch) (MPT_COMPILER_GCC_VERSION >= MPT_COMPILER_MAKE_VERSION3((major),(minor),(patch))) +#define MPT_GCC_BEFORE(major,minor,patch) (MPT_COMPILER_GCC_VERSION < MPT_COMPILER_MAKE_VERSION3((major),(minor),(patch))) + +#if MPT_CLANG_BEFORE(4,4,0) +#pragma message "GCC version 4.4 required" +#endif + +#elif defined(_MSC_VER) + +#define MPT_COMPILER_MSVC 1 +#if (_MSC_VER >= 1600) +#define MPT_COMPILER_MSVC_VERSION MPT_COMPILER_MAKE_VERSION2(2010,0) +#elif (_MSC_VER >= 1500) +#define MPT_COMPILER_MSVC_VERSION MPT_COMPILER_MAKE_VERSION2(2008,0) +#else +#define MPT_COMPILER_MSVC_VERSION MPT_COMPILER_MAKE_VERSION2(2005,0) +#endif +#define MPT_MSVC_AT_LEAST(version,sp) (MPT_COMPILER_MSVC_VERSION >= MPT_COMPILER_MAKE_VERSION2((version),(sp))) +#define MPT_MSVC_BEFORE(version,sp) (MPT_COMPILER_MSVC_VERSION < MPT_COMPILER_MAKE_VERSION2((version),(sp))) + +#if MPT_MSVC_BEFORE(2008,0) +#error "MSVC version 2008 required" +#endif + +#else + +// unsupported compiler +char mpt_unsupported_compiler[-1]; + +#endif + + + +#ifndef MPT_COMPILER_CLANG +#define MPT_COMPILER_CLANG 0 +#endif +#ifndef MPT_COMPILER_GCC +#define MPT_COMPILER_GCC 0 +#endif +#ifndef MPT_COMPILER_MSVC +#define MPT_COMPILER_MSVC 0 +#endif Property changes on: trunk/OpenMPT/common/CompilerDetect.h ___________________________________________________________________ Added: svn:mime-type ## -0,0 +1 ## +text/x-chdr \ No newline at end of property Added: svn:eol-style ## -0,0 +1 ## +native \ No newline at end of property Modified: trunk/OpenMPT/common/misc_util.h =================================================================== --- trunk/OpenMPT/common/misc_util.h 2013-05-19 17:37:45 UTC (rev 2136) +++ trunk/OpenMPT/common/misc_util.h 2013-05-19 20:13:48 UTC (rev 2137) @@ -53,7 +53,7 @@ return static_cast<T>(atof(str)); } -#ifdef _MSC_VER +#if MPT_COMPILER_MSVC #define cxx11_strtoll _strtoi64 #define cxx11_strtoull _strtoui64 #else Modified: trunk/OpenMPT/common/mptString.cpp =================================================================== --- trunk/OpenMPT/common/mptString.cpp 2013-05-19 17:37:45 UTC (rev 2136) +++ trunk/OpenMPT/common/mptString.cpp 2013-05-19 20:13:48 UTC (rev 2137) @@ -19,7 +19,7 @@ // Formats this string, like CString::Format. void String::Format(const CharT* pszFormat, ...) { - #ifdef _MSC_VER + #if MPT_COMPILER_MSVC va_list argList; va_start( argList, pszFormat ); Modified: trunk/OpenMPT/common/mptString.h =================================================================== --- trunk/OpenMPT/common/mptString.h 2013-05-19 17:37:45 UTC (rev 2136) +++ trunk/OpenMPT/common/mptString.h 2013-05-19 20:13:48 UTC (rev 2137) @@ -11,7 +11,7 @@ #pragma once #include <string> -#ifdef __GNUC__ +#if MPT_COMPILER_GCC || MPT_COMPILER_CLANG #include <strings.h> // for strcasecmp #endif @@ -30,7 +30,7 @@ String(const std::string& other) : BaseClass(other) {} // Move constructors and move assignments. - #if (_MSC_VER >= MSVC_VER_2010) + #if defined(MPT_COMPILER_HAS_RVALUE_REF) String(BaseClass&& str) : BaseClass(std::move(str)) {} String(String&& other) : BaseClass(std::move(static_cast<BaseClass&>(other))) {} String& operator=(BaseClass&& str) {BaseClass::operator=(std::move(str)); return *this;} @@ -93,7 +93,7 @@ static inline int mpt_strnicmp(const char *a, const char *b, size_t count) { - #ifdef _MSC_VER + #if MPT_COMPILER_MSVC return _strnicmp(a, b, count); #else return strncasecmp(a, b, count); Modified: trunk/OpenMPT/common/stdafx.cpp =================================================================== --- trunk/OpenMPT/common/stdafx.cpp 2013-05-19 17:37:45 UTC (rev 2136) +++ trunk/OpenMPT/common/stdafx.cpp 2013-05-19 20:13:48 UTC (rev 2137) @@ -11,34 +11,3 @@ #include "stdafx.h" - -/*#if (_MSC_VER == MSVC_VER_2008) - -// Fix for VS2008 SP1 bloatage (http://tedwvc.wordpress.com/2011/04/16/static-mfc-code-bloat-problem-from-vc2010-is-now-in-vc2008-sp1security-fix/): - -// this is our own local copy of the AfxLoadSystemLibraryUsingFullPath function -HMODULE AfxLoadSystemLibraryUsingFullPath(const WCHAR *pszLibrary) -{ - WCHAR wszLoadPath[MAX_PATH+1]; - if (::GetSystemDirectoryW(wszLoadPath, _countof(wszLoadPath)) == 0) - { - return NULL; - } - - if (wszLoadPath[wcslen(wszLoadPath)-1] != L'\\') - { - if (wcscat_s(wszLoadPath, _countof(wszLoadPath), L"\\") != 0) - { - return NULL; - } - } - - if (wcscat_s(wszLoadPath, _countof(wszLoadPath), pszLibrary) != 0) - { - return NULL; - } - - return(::AfxCtxLoadLibraryW(wszLoadPath)); -} - -#endif*/ Modified: trunk/OpenMPT/common/stdafx.h =================================================================== --- trunk/OpenMPT/common/stdafx.h 2013-05-19 17:37:45 UTC (rev 2136) +++ trunk/OpenMPT/common/stdafx.h 2013-05-19 20:13:48 UTC (rev 2137) @@ -27,13 +27,13 @@ #include <windowsx.h> -#ifdef _MSC_VER +#if MPT_COMPILER_MSVC #pragma warning(disable:4201) #endif #include <mmsystem.h> #include <mmreg.h> #include <msacm.h> -#ifdef _MSC_VER +#if MPT_COMPILER_MSVC #pragma warning(default:4201) #endif Modified: trunk/OpenMPT/common/typedefs.cpp =================================================================== --- trunk/OpenMPT/common/typedefs.cpp 2013-05-19 17:37:45 UTC (rev 2136) +++ trunk/OpenMPT/common/typedefs.cpp 2013-05-19 20:13:48 UTC (rev 2137) @@ -57,7 +57,7 @@ #endif -#ifdef _MSC_VER +#if MPT_COMPILER_MSVC int c99_vsnprintf(char *str, size_t size, const char *format, va_list args) { Modified: trunk/OpenMPT/common/typedefs.h =================================================================== --- trunk/OpenMPT/common/typedefs.h 2013-05-19 17:37:45 UTC (rev 2136) +++ trunk/OpenMPT/common/typedefs.h 2013-05-19 20:13:48 UTC (rev 2137) @@ -12,43 +12,42 @@ -// Definitions for MSVC versions to write more understandable conditional-compilation, -// e.g. #if (_MSC_VER > MSVC_VER_2008) instead of #if (_MSC_VER > 1500) -#define MSVC_VER_VC9 1500 -#define MSVC_VER_2008 MSVC_VER_VC9 -#define MSVC_VER_VC10 1600 -#define MSVC_VER_2010 MSVC_VER_VC10 +#if MPT_COMPILER_MSVC +#pragma warning(error : 4309) // Treat "truncation of constant value"-warning as error. +#endif -#define GCC_VERSION (__GNUC__ * 10000 + __GNUC_MINOR__ * 100 + __GNUC_PATCHLEVEL__) - -#if defined(_MSC_VER) -#pragma warning(error : 4309) // Treat "truncation of constant value"-warning as error. +#if MPT_COMPILER_MSVC && MPT_MSVC_AT_LEAST(2010,0) +#define MPT_COMPILER_HAS_RVALUE_REF #endif -#if defined(_MSC_VER) && (_MSC_VER >= MSVC_VER_2010) +#if MPT_COMPILER_MSVC && MPT_MSVC_AT_LEAST(2010,0) #define HAS_TYPE_TRAITS #endif -#if defined(_MSC_VER) -#if (_MSC_VER < MSVC_VER_2010) - #define nullptr 0 +#if MPT_COMPILER_MSVC + +#if MPT_MSVC_BEFORE(2010,0) +#define nullptr 0 #endif -#elif defined(__GNUC__) -#if GCC_VERSION < 40600 + +#elif MPT_COMPILER_GCC + +#if MPT_GCC_BEFORE(4,6,0) #define nullptr 0 #endif + #endif // CountOf macro computes the number of elements in a statically-allocated array. -#ifdef _MSC_VER +#if MPT_COMPILER_MSVC #define CountOf(x) _countof(x) #else #define CountOf(x) (sizeof((x))/sizeof((x)[0])) @@ -56,28 +55,28 @@ -#if defined(_MSC_VER) +#if MPT_COMPILER_MSVC #define PACKED __declspec(align(1)) #define NEEDS_PRAGMA_PACK -#elif defined(__GNUC__) +#elif MPT_COMPILER_GCC || MPT_COMPILER_CLANG #define PACKED __attribute__((packed)) __attribute__((aligned(1))) #endif -#if defined(_MSC_VER) +#if MPT_COMPILER_MSVC #define ALIGN(n) __declspec(align(n)) -#elif defined(__GNUC__) +#elif MPT_COMPILER_GCC || MPT_COMPILER_CLANG #define ALIGN(n) __attribute__((aligned(n))) #endif // Advanced inline attributes -#if defined(_MSC_VER) +#if MPT_COMPILER_MSVC #define forceinline __forceinline #define noinline __declspec(noinline) -#elif defined(__GNUC__) +#elif MPT_COMPILER_GCC || MPT_COMPILER_CLANG #define forceinline __attribute__((always_inline)) inline #define noinline __attribute__((noinline)) #else @@ -89,9 +88,9 @@ // Some functions might be deprecated although they are still in use. // Tag them with "DEPRECATED". -#if defined(_MSC_VER) +#if MPT_COMPILER_MSVC #define DEPRECATED __declspec(deprecated) -#elif defined(__GNUC__) +#elif MPT_COMPILER_GCC || MPT_COMPILER_CLANG #define DEPRECATED __attribute__((deprecated)) #else #define DEPRECATED @@ -110,7 +109,7 @@ #include <memory> -#if defined(_MSC_VER) && (_MSC_VER <= MSVC_VER_2008) +#if MPT_COMPILER_MSVC && MPT_MSVC_BEFORE(2010,0) #define MPT_SHARED_PTR std::tr1::shared_ptr #else #define MPT_SHARED_PTR std::shared_ptr @@ -137,7 +136,7 @@ #endif // Compile time assert. -#if defined(_MSC_VER) && (_MSC_VER < MSVC_VER_2010) +#if MPT_COMPILER_MSVC && MPT_MSVC_BEFORE(2010,0) #define static_assert(expr, msg) typedef char OPENMPT_STATIC_ASSERT[(expr)?1:-1] #endif #define STATIC_ASSERT(expr) static_assert((expr), "compile time assertion failed: " #expr) @@ -145,7 +144,7 @@ #include <cstdarg> -#ifdef _MSC_VER +#if MPT_COMPILER_MSVC #ifndef va_copy #define va_copy(dst, src) do { (dst) = (src); } while (0) #endif @@ -153,7 +152,7 @@ -#if defined(_MSC_VER) && (_MSC_VER <= MSVC_VER_2008) +#if MPT_COMPILER_MSVC && MPT_MSVC_BEFORE(2010,0) typedef __int8 int8; typedef __int16 int16; @@ -284,7 +283,7 @@ #include <cstdio> #include <stdio.h> -#ifdef _MSC_VER +#if MPT_COMPILER_MSVC int c99_vsnprintf(char *str, size_t size, const char *format, va_list args); int c99_snprintf(char *str, size_t size, const char *format, ...); #define snprintf c99_snprintf Modified: trunk/OpenMPT/libopenmpt/libopenmpt.vcxproj =================================================================== --- trunk/OpenMPT/libopenmpt/libopenmpt.vcxproj 2013-05-19 17:37:45 UTC (rev 2136) +++ trunk/OpenMPT/libopenmpt/libopenmpt.vcxproj 2013-05-19 20:13:48 UTC (rev 2137) @@ -319,6 +319,7 @@ <ItemGroup> <ClInclude Include="..\common\AudioCriticalSection.h" /> <ClInclude Include="..\common\BuildSettings.h" /> + <ClInclude Include="..\common\CompilerDetect.h" /> <ClInclude Include="..\common\FlagSet.h" /> <ClInclude Include="..\common\misc_util.h" /> <ClInclude Include="..\common\mptString.h" /> Modified: trunk/OpenMPT/libopenmpt/libopenmpt.vcxproj.filters =================================================================== --- trunk/OpenMPT/libopenmpt/libopenmpt.vcxproj.filters 2013-05-19 17:37:45 UTC (rev 2136) +++ trunk/OpenMPT/libopenmpt/libopenmpt.vcxproj.filters 2013-05-19 20:13:48 UTC (rev 2137) @@ -207,6 +207,9 @@ <ClInclude Include="libopenmpt_stream_callbacks.h"> <Filter>Header Files</Filter> </ClInclude> + <ClInclude Include="..\common\CompilerDetect.h"> + <Filter>Header Files\common</Filter> + </ClInclude> </ItemGroup> <ItemGroup> <ClCompile Include="..\common\AudioCriticalSection.cpp"> Modified: trunk/OpenMPT/mptrack/Mptrack.cpp =================================================================== --- trunk/OpenMPT/mptrack/Mptrack.cpp 2013-05-19 17:37:45 UTC (rev 2136) +++ trunk/OpenMPT/mptrack/Mptrack.cpp 2013-05-19 20:13:48 UTC (rev 2137) @@ -58,14 +58,14 @@ CModDocTemplate(UINT nIDResource, CRuntimeClass* pDocClass, CRuntimeClass* pFrameClass, CRuntimeClass* pViewClass): CMultiDocTemplate(nIDResource, pDocClass, pFrameClass, pViewClass) {} - #if (_MSC_VER < MSVC_VER_2010) + #if MPT_COMPILER_MSVC && MPT_MSVC_BEFORE(2010,0) virtual CDocument* OpenDocumentFile(LPCTSTR path, BOOL makeVisible = TRUE); #else virtual CDocument* OpenDocumentFile(LPCTSTR path, BOOL addToMru = TRUE, BOOL makeVisible = TRUE); #endif }; -#if (_MSC_VER < MSVC_VER_2010) +#if MPT_COMPILER_MSVC && MPT_MSVC_BEFORE(2010,0) CDocument *CModDocTemplate::OpenDocumentFile(LPCTSTR path, BOOL makeVisible) #else CDocument *CModDocTemplate::OpenDocumentFile(LPCTSTR path, BOOL addToMru, BOOL makeVisible) @@ -87,7 +87,7 @@ } } - #if (_MSC_VER < MSVC_VER_2010) + #if MPT_COMPILER_MSVC && MPT_MSVC_BEFORE(2010,0) CDocument *pDoc = CMultiDocTemplate::OpenDocumentFile(path, makeVisible); #else CDocument *pDoc = CMultiDocTemplate::OpenDocumentFile(path, addToMru, makeVisible); @@ -617,7 +617,7 @@ CTrackApp::CTrackApp() //-------------------- { - #ifdef _MSC_VER + #if MPT_COMPILER_MSVC _CrtSetDebugFillThreshold(0); // Disable buffer filling in secure enhanced CRT functions. #endif Modified: trunk/OpenMPT/mptrack/Mptrack.h =================================================================== --- trunk/OpenMPT/mptrack/Mptrack.h 2013-05-19 17:37:45 UTC (rev 2136) +++ trunk/OpenMPT/mptrack/Mptrack.h 2013-05-19 20:13:48 UTC (rev 2137) @@ -98,7 +98,7 @@ static MEMORYSTATUS gMemStatus; static std::vector<CDLSBank *> gpDLSBanks; -#if (_MSC_VER < MSVC_VER_2010) +#if MPT_COMPILER_MSVC && MPT_MSVC_BEFORE(2010,0) virtual CDocument* OpenDocumentFile(LPCTSTR lpszFileName, BOOL bAddToMRU = TRUE) { CDocument* pDoc = CWinApp::OpenDocumentFile(lpszFileName); Modified: trunk/OpenMPT/mptrack/mptrack_08.vcproj =================================================================== --- trunk/OpenMPT/mptrack/mptrack_08.vcproj 2013-05-19 17:37:45 UTC (rev 2136) +++ trunk/OpenMPT/mptrack/mptrack_08.vcproj 2013-05-19 20:13:48 UTC (rev 2137) @@ -841,6 +841,10 @@ > </File> <File + RelativePath="..\common\CompilerDetect.h" + > + </File> + <File RelativePath=".\ChildFrm.h" > </File> Modified: trunk/OpenMPT/mptrack/mptrack_10.vcxproj =================================================================== --- trunk/OpenMPT/mptrack/mptrack_10.vcxproj 2013-05-19 17:37:45 UTC (rev 2136) +++ trunk/OpenMPT/mptrack/mptrack_10.vcxproj 2013-05-19 20:13:48 UTC (rev 2137) @@ -508,6 +508,7 @@ <ItemGroup> <ClInclude Include="..\common\AudioCriticalSection.h" /> <ClInclude Include="..\common\BuildSettings.h" /> + <ClInclude Include="..\common\CompilerDetect.h" /> <ClInclude Include="..\common\FlagSet.h" /> <ClInclude Include="..\common\Logging.h" /> <ClInclude Include="..\common\misc_util.h" /> Modified: trunk/OpenMPT/mptrack/mptrack_10.vcxproj.filters =================================================================== --- trunk/OpenMPT/mptrack/mptrack_10.vcxproj.filters 2013-05-19 17:37:45 UTC (rev 2136) +++ trunk/OpenMPT/mptrack/mptrack_10.vcxproj.filters 2013-05-19 20:13:48 UTC (rev 2137) @@ -915,6 +915,9 @@ <ClInclude Include="..\common\versionNumber.h"> <Filter>Header Files\common</Filter> </ClInclude> + <ClInclude Include="..\common\CompilerDetect.h"> + <Filter>Header Files\common</Filter> + </ClInclude> </ItemGroup> <ItemGroup> <None Include="res\bitmap1.bmp"> Modified: trunk/OpenMPT/sounddsp/DSP.cpp =================================================================== --- trunk/OpenMPT/sounddsp/DSP.cpp 2013-05-19 17:37:45 UTC (rev 2136) +++ trunk/OpenMPT/sounddsp/DSP.cpp 2013-05-19 20:13:48 UTC (rev 2137) @@ -14,7 +14,7 @@ #include "../sounddsp/DSP.h" #include <math.h> -#ifdef _MSC_VER +#if MPT_COMPILER_MSVC #pragma warning(disable: 4725) // instruction may be inaccurate on some Pentiums #endif Modified: trunk/OpenMPT/soundlib/Endianness.h =================================================================== --- trunk/OpenMPT/soundlib/Endianness.h 2013-05-19 17:37:45 UTC (rev 2136) +++ trunk/OpenMPT/soundlib/Endianness.h 2013-05-19 20:13:48 UTC (rev 2137) @@ -19,11 +19,11 @@ // endian architecture or value x in format of current architecture to little endian // format. -#ifdef __GNUC__ -#if GCC_VERSION >= 40300 +#if MPT_COMPILER_GCC +#if MPT_GCC_AT_LEAST(4,3,0) #define bswap32 __builtin_bswap32 #endif -#elif defined(_MSC_VER) +#elif MPT_COMPILER_MSVC #include <intrin.h> #define bswap16 _byteswap_ushort #define bswap32 _byteswap_ulong Modified: trunk/OpenMPT/soundlib/Fastmix.cpp =================================================================== --- trunk/OpenMPT/soundlib/Fastmix.cpp 2013-05-19 17:37:45 UTC (rev 2136) +++ trunk/OpenMPT/soundlib/Fastmix.cpp 2013-05-19 20:13:48 UTC (rev 2137) @@ -1814,11 +1814,6 @@ } -#ifdef _MSC_VER -#pragma warning (disable:4100) -#endif - - #ifdef ENABLE_X86 static DWORD X86_Convert32To8(LPVOID lp16, int *pBuffer, DWORD lSampleCount) //-------------------------------------------------------------------------- @@ -2113,7 +2108,7 @@ ////////////////////////////////////////////////////////////////////////// // Noise Shaping (Dither) -#ifdef _MSC_VER +#if MPT_COMPILER_MSVC #pragma warning(disable:4731) // ebp modified #endif Modified: trunk/OpenMPT/soundlib/Load_mdl.cpp =================================================================== --- trunk/OpenMPT/soundlib/Load_mdl.cpp 2013-05-19 17:37:45 UTC (rev 2136) +++ trunk/OpenMPT/soundlib/Load_mdl.cpp 2013-05-19 20:13:48 UTC (rev 2137) @@ -14,7 +14,7 @@ //#define MDL_LOG -#ifdef _MSC_VER +#if MPT_COMPILER_MSVC #pragma warning(disable:4244) //"conversion from 'type1' to 'type2', possible loss of data" #endif Modified: trunk/OpenMPT/soundlib/Load_ptm.cpp =================================================================== --- trunk/OpenMPT/soundlib/Load_ptm.cpp 2013-05-19 17:37:45 UTC (rev 2136) +++ trunk/OpenMPT/soundlib/Load_ptm.cpp 2013-05-19 20:13:48 UTC (rev 2137) @@ -13,7 +13,7 @@ #include "stdafx.h" #include "Loaders.h" -#ifdef _MSC_VER +#if MPT_COMPILER_MSVC #pragma warning(disable:4244) //"conversion from 'type1' to 'type2', possible loss of data" #endif Modified: trunk/OpenMPT/soundlib/Load_stm.cpp =================================================================== --- trunk/OpenMPT/soundlib/Load_stm.cpp 2013-05-19 17:37:45 UTC (rev 2136) +++ trunk/OpenMPT/soundlib/Load_stm.cpp 2013-05-19 20:13:48 UTC (rev 2137) @@ -12,7 +12,7 @@ #include "stdafx.h" #include "Loaders.h" -#ifdef _MSC_VER +#if MPT_COMPILER_MSVC #pragma warning(disable:4244) //"conversion from 'type1' to 'type2', possible loss of data" #endif Modified: trunk/OpenMPT/soundlib/ModChannel.h =================================================================== --- trunk/OpenMPT/soundlib/ModChannel.h 2013-05-19 17:37:45 UTC (rev 2136) +++ trunk/OpenMPT/soundlib/ModChannel.h 2013-05-19 20:13:48 UTC (rev 2137) @@ -12,7 +12,7 @@ class CSoundFile; -#ifdef _MSC_VER +#if MPT_COMPILER_MSVC #pragma warning(disable:4324) //structure was padded due to __declspec(align()) #endif @@ -204,6 +204,6 @@ } }; -#ifdef _MSC_VER +#if MPT_COMPILER_MSVC #pragma warning(default:4324) //structure was padded due to __declspec(align()) #endif Modified: trunk/OpenMPT/soundlib/SampleIO.cpp =================================================================== --- trunk/OpenMPT/soundlib/SampleIO.cpp 2013-05-19 17:37:45 UTC (rev 2136) +++ trunk/OpenMPT/soundlib/SampleIO.cpp 2013-05-19 20:13:48 UTC (rev 2137) @@ -23,7 +23,7 @@ extern int DMFUnpack(LPBYTE psample, const uint8 *ibuf, const uint8 *ibufmax, uint32 maxlen); -#if defined(__GNUC__) +#if MPT_COMPILER_GCC #pragma GCC diagnostic push #pragma GCC diagnostic ignored "-Wswitch" #endif @@ -397,7 +397,7 @@ return bytesRead; } -#if defined(__GNUC__) +#if MPT_COMPILER_GCC #pragma GCC diagnostic pop #endif Modified: trunk/OpenMPT/soundlib/Snd_fx.cpp =================================================================== --- trunk/OpenMPT/soundlib/Snd_fx.cpp 2013-05-19 17:37:45 UTC (rev 2136) +++ trunk/OpenMPT/soundlib/Snd_fx.cpp 2013-05-19 20:13:48 UTC (rev 2137) @@ -22,7 +22,7 @@ #include "tuning.h" #include "Tables.h" -#ifdef _MSC_VER +#if MPT_COMPILER_MSVC #pragma warning(disable:4244) #endif Modified: trunk/OpenMPT/soundlib/Sndfile.cpp =================================================================== --- trunk/OpenMPT/soundlib/Sndfile.cpp 2013-05-19 17:37:45 UTC (rev 2136) +++ trunk/OpenMPT/soundlib/Sndfile.cpp 2013-05-19 20:13:48 UTC (rev 2137) @@ -384,7 +384,7 @@ CTuningCollection* CSoundFile::s_pTuningsSharedLocal(0); #endif -#ifdef _MSC_VER +#if MPT_COMPILER_MSVC #pragma warning(disable : 4355) // "'this' : used in base member initializer list" #endif CSoundFile::CSoundFile() : @@ -397,7 +397,7 @@ #endif visitedSongRows(*this), m_pCustomLog(nullptr) -#ifdef _MSC_VER +#if MPT_COMPILER_MSVC #pragma warning(default : 4355) // "'this' : used in base member initializer list" #endif //---------------------- Modified: trunk/OpenMPT/soundlib/Sndfile.h =================================================================== --- trunk/OpenMPT/soundlib/Sndfile.h 2013-05-19 17:37:45 UTC (rev 2136) +++ trunk/OpenMPT/soundlib/Sndfile.h 2013-05-19 20:13:48 UTC (rev 2137) @@ -788,7 +788,7 @@ }; -#ifdef _MSC_VER +#if MPT_COMPILER_MSVC #pragma warning(default : 4324) //structure was padded due to __declspec(align()) #endif Modified: trunk/OpenMPT/soundlib/load_j2b.cpp =================================================================== --- trunk/OpenMPT/soundlib/load_j2b.cpp 2013-05-19 17:37:45 UTC (rev 2136) +++ trunk/OpenMPT/soundlib/load_j2b.cpp 2013-05-19 20:13:48 UTC (rev 2137) @@ -14,7 +14,7 @@ #include "stdafx.h" #include "Loaders.h" #include "ChunkReader.h" -#ifdef _MSC_VER +#if MPT_COMPILER_MSVC #ifndef ZLIB_WINAPI #define ZLIB_WINAPI #endif // ZLIB_WINAPI Modified: trunk/OpenMPT/soundlib/tuningbase.h =================================================================== --- trunk/OpenMPT/soundlib/tuningbase.h 2013-05-19 17:37:45 UTC (rev 2136) +++ trunk/OpenMPT/soundlib/tuningbase.h 2013-05-19 20:13:48 UTC (rev 2137) @@ -37,11 +37,7 @@ namespace srlztn {class Ssb;}; -#ifdef _MSC_VER -#pragma warning(disable:4100) //"unreferenced formal parameter" -#endif - #ifdef BUILD_TUNINGBASE_AS_TEMPLATE #define CLASSTEMPLATEDEC template<class TNOTEINDEXTYPE = int16, class TUNOTEINDEXTYPE = uint16, class TRATIOTYPE = float32, class TSTEPINDEXTYPE = int32, class TUSTEPINDEXTYPE = uint32> #define TEMPLATEDEC template<class A, class B, class C, class D, class E> @@ -318,10 +314,6 @@ static void DefaultMessageHandler(const char*, const char*) {} }; -#ifdef _MSC_VER -#pragma warning(default:4100) //"unreferenced formal parameter" -#endif - #define NOTEINDEXTYPE_MIN (std::numeric_limits<NOTEINDEXTYPE>::min)() #define NOTEINDEXTYPE_MAX (std::numeric_limits<NOTEINDEXTYPE>::max)() #define UNOTEINDEXTYPE_MAX (std::numeric_limits<UNOTEINDEXTYPE>::max)() Modified: trunk/OpenMPT/unarchiver/unlha.cpp =================================================================== --- trunk/OpenMPT/unarchiver/unlha.cpp 2013-05-19 17:37:45 UTC (rev 2136) +++ trunk/OpenMPT/unarchiver/unlha.cpp 2013-05-19 20:13:48 UTC (rev 2137) @@ -15,7 +15,7 @@ #undef USHRT_MAX #undef SHRT_MIN -#ifdef _MSC_VER +#if MPT_COMPILER_MSVC #pragma warning(disable: 4244) // conversion from 'type1' to 'type2', possible loss of data #endif This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <sag...@us...> - 2013-05-20 16:37:36
|
Revision: 2148 http://sourceforge.net/p/modplug/code/2148 Author: saga-games Date: 2013-05-20 16:37:28 +0000 (Mon, 20 May 2013) Log Message: ----------- [Imp] Sample frequency is now 28.4 fixed point internally. Modified Paths: -------------- trunk/OpenMPT/mptrack/View_smp.cpp trunk/OpenMPT/soundlib/Snd_defs.h trunk/OpenMPT/soundlib/Snd_fx.cpp trunk/OpenMPT/soundlib/Sndmix.cpp Modified: trunk/OpenMPT/mptrack/View_smp.cpp =================================================================== --- trunk/OpenMPT/mptrack/View_smp.cpp 2013-05-20 13:39:23 UTC (rev 2147) +++ trunk/OpenMPT/mptrack/View_smp.cpp 2013-05-20 16:37:28 UTC (rev 2148) @@ -2041,9 +2041,9 @@ BeginWaitCursor(); if ((pModDoc) && (m_nSample <= pModDoc->GetNumSamples())) { - CSoundFile *pSndFile = pModDoc->GetSoundFile(); - ModSample &sample = pSndFile->GetSample(m_nSample); - if ((sample.uFlags & CHN_16BIT) && (sample.pSample) && (sample.nLength)) + CSoundFile &sndFile = pModDoc->GetrSoundFile(); + ModSample &sample = sndFile.GetSample(m_nSample); + if(sample.uFlags[CHN_16BIT] && sample.pSample != nullptr && sample.nLength != 0) { pModDoc->GetSampleUndo().PrepareUndo(m_nSample, sundo_replace); @@ -2056,9 +2056,9 @@ p[i] = (signed char) ((*((short int *)(p+i*2))) / 256); } sample.uFlags.reset(CHN_16BIT); - for (UINT j=0; j<MAX_CHANNELS; j++) if (pSndFile->Chn[j].pSample == sample.pSample) + for (UINT j=0; j<MAX_CHANNELS; j++) if (sndFile.Chn[j].pSample == sample.pSample) { - pSndFile->Chn[j].dwFlags.reset(CHN_16BIT); + sndFile.Chn[j].dwFlags.reset(CHN_16BIT); } cs.Leave(); @@ -2152,12 +2152,12 @@ //nothing loaded or invalid sample slot. if(!pModDoc || m_nSample > pModDoc->GetNumSamples()) return; - CSoundFile *pSndFile = pModDoc->GetSoundFile(); - ModSample &sample = pSndFile->GetSample(m_nSample); + CSoundFile &sndFile = pModDoc->GetrSoundFile(); + ModSample &sample = sndFile.GetSample(m_nSample); if(m_dwBeginSel == m_dwEndSel) { - // Trim around loop points if there's no selection (http://forum.openmpt.org/index.php?topic=2258.0) + // Trim around loop points if there's no selection m_dwBeginSel = sample.nLoopStart; m_dwEndSel = sample.nLoopEnd; } @@ -2231,7 +2231,6 @@ } else { - CHAR s[64]; if (m_dwStatus & SMPSTATUS_KEYDOWN) pModDoc->NoteOff(note, true); else @@ -2244,15 +2243,13 @@ pModDoc->PlayNote(note, 0, m_nSample, false, -1, loopstart, loopend, CHANNELINDEX_INVALID, nStartPos); m_dwStatus |= SMPSTATUS_KEYDOWN; - s[0] = 0; - if(ModCommand::IsNote((ModCommand::NOTE)note)) - { - CSoundFile *pSndFile = pModDoc->GetSoundFile(); - ModSample &sample = pSndFile->GetSample(m_nSample); - uint32 freq = pSndFile->GetFreqFromPeriod(pSndFile->GetPeriodFromNote(note + (pSndFile->GetType() == MOD_TYPE_XM ? sample.RelativeTone : 0), sample.nFineTune, sample.nC5Speed), sample.nC5Speed, 0); - wsprintf(s, "%s (%d Hz)", szDefaultNoteNames[note - 1], freq); - } + CSoundFile &sndFile = pModDoc->GetrSoundFile(); + ModSample &sample = sndFile.GetSample(m_nSample); + uint32 freq = sndFile.GetFreqFromPeriod(pSndFile->GetPeriodFromNote(note + (pSndFile->GetType() == MOD_TYPE_XM ? sample.RelativeTone : 0), sample.nFineTune, sample.nC5Speed), sample.nC5Speed, 0); + + CHAR s[32]; + wsprintf(s, "%s (%d.%d Hz)", szDefaultNoteNames[note - 1], freq >> FREQ_FRACBITS, Util::muldiv(freq & ((1 << FREQ_FRACBITS) - 1), 100, 1 << FREQ_FRACBITS)); pMainFrm->SetInfoText(s); } } Modified: trunk/OpenMPT/soundlib/Snd_defs.h =================================================================== --- trunk/OpenMPT/soundlib/Snd_defs.h 2013-05-20 13:39:23 UTC (rev 2147) +++ trunk/OpenMPT/soundlib/Snd_defs.h 2013-05-20 16:37:28 UTC (rev 2148) @@ -62,6 +62,8 @@ #define MIN_PERIOD 0x0020 // Note: Period is an Amiga metric that is inverse to frequency. #define MAX_PERIOD 0xFFFF // Periods in MPT are 4 times as fine as Amiga periods because of extra fine frequency slides. +#define FREQ_FRACBITS 4 // Number of fractional bits in return value of CSoundFile::GetFreqFromPeriod() + // String lengths (including trailing null char) #define MAX_SAMPLENAME 32 // also affects module name! #define MAX_SAMPLEFILENAME 22 Modified: trunk/OpenMPT/soundlib/Snd_fx.cpp =================================================================== --- trunk/OpenMPT/soundlib/Snd_fx.cpp 2013-05-20 13:39:23 UTC (rev 2147) +++ trunk/OpenMPT/soundlib/Snd_fx.cpp 2013-05-20 16:37:28 UTC (rev 2148) @@ -4681,13 +4681,14 @@ } +// Converts period value to sample frequency. Return value is fixed point, with FREQ_FRACBITS fractional bits. UINT CSoundFile::GetFreqFromPeriod(UINT period, UINT nC5Speed, int nPeriodFrac) const //----------------------------------------------------------------------------------- { if (!period) return 0; if (GetType() & (MOD_TYPE_MED|MOD_TYPE_MOD|MOD_TYPE_DIGI|MOD_TYPE_MTM|MOD_TYPE_669|MOD_TYPE_AMF0)) { - return (3546895L*4) / period; + return ((3546895L * 4) << FREQ_FRACBITS) / period; } else if (GetType() == MOD_TYPE_XM) { if(m_SongFlags[SONG_LINEARSLIDES]) @@ -4703,20 +4704,20 @@ uint32 div = ((9216u + 767u - (period & 0xFFFF)) / 768); octave = ((12 - div) & 0x1F) % 29u; } - return XMLinearTable[period % 768] >> octave; + return (XMLinearTable[period % 768] << FREQ_FRACBITS) >> octave; } else { - return 8363 * 1712L / period; + return ((8363 * 1712L) << FREQ_FRACBITS) / period; } } else { if(m_SongFlags[SONG_LINEARSLIDES]) { if (!nC5Speed) nC5Speed = 8363; - return Util::muldiv(nC5Speed, 1712L << 8, (period << 8)+nPeriodFrac); + return Util::muldiv(nC5Speed, (1712L << 8) << FREQ_FRACBITS, (period << 8) + nPeriodFrac); } else { - return Util::muldiv(8363, 1712L << 8, (period << 8)+nPeriodFrac); + return Util::muldiv(8363, (1712L << 8) << FREQ_FRACBITS, (period << 8) + nPeriodFrac); } } } Modified: trunk/OpenMPT/soundlib/Sndmix.cpp =================================================================== --- trunk/OpenMPT/soundlib/Sndmix.cpp 2013-05-20 13:39:23 UTC (rev 2147) +++ trunk/OpenMPT/soundlib/Sndmix.cpp 2013-05-20 16:37:28 UTC (rev 2148) @@ -1761,7 +1761,7 @@ { if(IsCompatibleMode(TRK_IMPULSETRACKER)) { - // In IT and FT2 compatible mode, envelope position indices are shifted by one for proper envelope pausing, + // In IT compatible mode, envelope position indices are shifted by one for proper envelope pausing, // so we have to update the position before we actually process the envelopes. // When using MPT behaviour, we get the envelope position for the next tick while we are still calculating the current tick, // which then results in wrong position information when the envelope is paused on the next row. @@ -1882,7 +1882,7 @@ // In this case: GetType() == MOD_TYPE_MPT and using custom tunings. if(pChn->m_CalculateFreq || (pChn->m_ReCalculateFreqOnFirstTick && m_nTickCount == 0)) { - pChn->m_Freq = Util::Round<UINT>(pChn->nC5Speed * vibratoFactor * pIns->pTuning->GetRatio(pChn->nNote - NOTE_MIDDLEC + arpeggioSteps, pChn->nFineTune+pChn->m_PortamentoFineSteps)); + pChn->m_Freq = Util::Round<uint32>((pChn->nC5Speed << FREQ_FRACBITS) * vibratoFactor * pIns->pTuning->GetRatio(pChn->nNote - NOTE_MIDDLEC + arpeggioSteps, pChn->nFineTune+pChn->m_PortamentoFineSteps)); if(!pChn->m_CalculateFreq) pChn->m_ReCalculateFreqOnFirstTick = false; else @@ -1906,7 +1906,7 @@ pChn->nCalcVolume = 0; } - int32 ninc = Util::muldiv(freq, 0x10000, m_MixerSettings.gdwMixingFreq); + int32 ninc = Util::muldiv(freq, 0x10000, m_MixerSettings.gdwMixingFreq << FREQ_FRACBITS); if ((ninc >= 0xFFB0) && (ninc <= 0x10090)) ninc = 0x10000; if (m_nFreqFactor != 128) ninc = (ninc * m_nFreqFactor) >> 7; Limit(ninc, 3, 0xFF0000); This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <man...@us...> - 2013-05-20 16:39:29
|
Revision: 2149 http://sourceforge.net/p/modplug/code/2149 Author: manxorist Date: 2013-05-20 16:39:22 +0000 (Mon, 20 May 2013) Log Message: ----------- [Ref] Remove c99_snprintf and c99_vsnprintf which confusingly were not 100% c99 compliant. Replace the one single usage site and always zero-terminate strings by hand there. [Fix] Fix 64bit warning in libopenmpt_modplug. [Ref] Silence stupid 64bit warning in ITTools.cpp. Modified Paths: -------------- trunk/OpenMPT/common/mptString.h trunk/OpenMPT/common/typedefs.cpp trunk/OpenMPT/common/typedefs.h trunk/OpenMPT/libopenmpt/libopenmpt_modplug.c trunk/OpenMPT/soundlib/ITTools.cpp Modified: trunk/OpenMPT/common/mptString.h =================================================================== --- trunk/OpenMPT/common/mptString.h 2013-05-20 16:37:28 UTC (rev 2148) +++ trunk/OpenMPT/common/mptString.h 2013-05-20 16:39:22 UTC (rev 2149) @@ -11,6 +11,8 @@ #pragma once #include <string> +#include <cstdio> +#include <stdio.h> #if MPT_COMPILER_GCC || MPT_COMPILER_CLANG #include <strings.h> // for strcasecmp #endif @@ -99,3 +101,9 @@ return strncasecmp(a, b, count); #endif } + + +#if MPT_COMPILER_MSVC +#define snprintf _snprintf +#endif + Modified: trunk/OpenMPT/common/typedefs.cpp =================================================================== --- trunk/OpenMPT/common/typedefs.cpp 2013-05-20 16:37:28 UTC (rev 2148) +++ trunk/OpenMPT/common/typedefs.cpp 2013-05-20 16:39:22 UTC (rev 2149) @@ -57,36 +57,6 @@ #endif -#if MPT_COMPILER_MSVC - -int c99_vsnprintf(char *str, size_t size, const char *format, va_list args) -{ - int ret; - va_list ap; - va_copy(ap, args); - ret = _vsnprintf(str, size, format, ap); - va_end(ap); - if ( ret < 0 ) { - str[size - 1] = '\0'; - ret = size; - } - return ret; -} - - -int c99_snprintf(char *str, size_t size, const char *format, ...) -{ - int ret; - va_list ap; - va_start( ap, format ); - ret = c99_vsnprintf(str, size, format, ap); - va_end( ap ); - return ret; -} - -#endif - - static const std::size_t LOGBUF_SIZE = 1024; static void DoLog(const char *file, int line, const char *function, const char *format, va_list args) @@ -97,6 +67,7 @@ va_list va; va_copy(va, args); vsnprintf(message, LOGBUF_SIZE, format, va); + message[LOGBUF_SIZE - 1] = '\0'; va_end(va); #if defined(MODPLUG_TRACKER) char buf2[LOGBUF_SIZE]; @@ -104,6 +75,7 @@ if(file || function) { snprintf(buf2, LOGBUF_SIZE, "%s(%i): %s", file?file:"", line, message); + buf2[LOGBUF_SIZE - 1] = '\0'; verbose_message = buf2; } else { Modified: trunk/OpenMPT/common/typedefs.h =================================================================== --- trunk/OpenMPT/common/typedefs.h 2013-05-20 16:37:28 UTC (rev 2148) +++ trunk/OpenMPT/common/typedefs.h 2013-05-20 16:39:22 UTC (rev 2149) @@ -281,14 +281,6 @@ //To mark string that should be translated in case of multilingual version. #define GetStrI18N(x) (x) -#include <cstdio> -#include <stdio.h> -#if MPT_COMPILER_MSVC -int c99_vsnprintf(char *str, size_t size, const char *format, va_list args); -int c99_snprintf(char *str, size_t size, const char *format, ...); -#define snprintf c99_snprintf -#endif - #define MULTICHAR4_LE_MSVC(a,b,c,d) static_cast<uint32>( (static_cast<uint8>(a) << 24) | (static_cast<uint8>(b) << 16) | (static_cast<uint8>(c) << 8) | (static_cast<uint8>(d) << 0) ) Modified: trunk/OpenMPT/libopenmpt/libopenmpt_modplug.c =================================================================== --- trunk/OpenMPT/libopenmpt/libopenmpt_modplug.c 2013-05-20 16:37:28 UTC (rev 2148) +++ trunk/OpenMPT/libopenmpt/libopenmpt_modplug.c 2013-05-20 16:39:22 UTC (rev 2149) @@ -29,6 +29,7 @@ #define LIBOPENMPT_MODPLUG_API #endif +#include <limits.h> #include <math.h> #include <memory.h> #include <stdio.h> @@ -235,11 +236,11 @@ frames = BUFFER_COUNT; } if(file->settings.mChannels==1){ - rendered = openmpt_module_read_mono(file->mod,file->settings.mFrequency,frames,&file->buf[frames*0]); + rendered = (int)openmpt_module_read_mono(file->mod,file->settings.mFrequency,frames,&file->buf[frames*0]); }else if(file->settings.mChannels==2){ - rendered = openmpt_module_read_stereo(file->mod,file->settings.mFrequency,frames,&file->buf[frames*0],&file->buf[frames*1]); + rendered = (int)openmpt_module_read_stereo(file->mod,file->settings.mFrequency,frames,&file->buf[frames*0],&file->buf[frames*1]); }else if(file->settings.mChannels==4){ - rendered = openmpt_module_read_quad(file->mod,file->settings.mFrequency,frames,&file->buf[frames*0],&file->buf[frames*1],&file->buf[frames*2],&file->buf[frames*3]); + rendered = (int)openmpt_module_read_quad(file->mod,file->settings.mFrequency,frames,&file->buf[frames*0],&file->buf[frames*1],&file->buf[frames*2],&file->buf[frames*3]); }else{ return 0; } @@ -486,6 +487,7 @@ { const char* str; unsigned int retval; + size_t tmpretval; if(!file) return 0; str = openmpt_module_get_sample_name(file->mod,qual-1); if(!str){ @@ -494,10 +496,14 @@ } return 0; } + tmpretval = strlen(str); + if(tmpretval>=INT_MAX){ + tmpretval = INT_MAX-1; + } + retval = (int)tmpretval; if(buff){ - strcpy(buff,str); + strncpy(buff,str,retval+1); } - retval = strlen(str); openmpt_free_string(str); return retval; } @@ -506,6 +512,7 @@ { const char* str; unsigned int retval; + size_t tmpretval; if(!file) return 0; str = openmpt_module_get_instrument_name(file->mod,qual-1); if(!str){ @@ -514,10 +521,14 @@ } return 0; } + tmpretval = strlen(str); + if(tmpretval>=INT_MAX){ + tmpretval = INT_MAX-1; + } + retval = (int)tmpretval; if(buff){ - strcpy(buff,str); + strncpy(buff,str,retval+1); } - retval = strlen(str); openmpt_free_string(str); return retval; } Modified: trunk/OpenMPT/soundlib/ITTools.cpp =================================================================== --- trunk/OpenMPT/soundlib/ITTools.cpp 2013-05-20 16:37:28 UTC (rev 2148) +++ trunk/OpenMPT/soundlib/ITTools.cpp 2013-05-20 16:39:22 UTC (rev 2149) @@ -177,7 +177,7 @@ mptIns.VolEnv.nNodes = 25; // Volume Envelope Data - for(size_t i = 0; i < 25; i++) + for(uint32 i = 0; i < 25; i++) { if((mptIns.VolEnv.Ticks[i] = nodes[i * 2]) == 0xFF) { This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <man...@us...> - 2013-05-21 14:37:50
|
Revision: 2158 http://sourceforge.net/p/modplug/code/2158 Author: manxorist Date: 2013-05-21 14:37:42 +0000 (Tue, 21 May 2013) Log Message: ----------- [Ref] Rename back_left and back_right to rear_left and rear_right in libopenmpt API. Modified Paths: -------------- trunk/OpenMPT/libopenmpt/libopenmpt.h trunk/OpenMPT/libopenmpt/libopenmpt.hpp trunk/OpenMPT/libopenmpt/libopenmpt_c.cpp trunk/OpenMPT/libopenmpt/libopenmpt_cxx.cpp trunk/OpenMPT/libopenmpt/libopenmpt_impl.hpp trunk/OpenMPT/openmpt123/openmpt123.cpp Modified: trunk/OpenMPT/libopenmpt/libopenmpt.h =================================================================== --- trunk/OpenMPT/libopenmpt/libopenmpt.h 2013-05-20 20:17:49 UTC (rev 2157) +++ trunk/OpenMPT/libopenmpt/libopenmpt.h 2013-05-21 14:37:42 UTC (rev 2158) @@ -101,10 +101,10 @@ LIBOPENMPT_API size_t openmpt_module_read_mono( openmpt_module * mod, int32_t samplerate, size_t count, int16_t * mono ); LIBOPENMPT_API size_t openmpt_module_read_stereo( openmpt_module * mod, int32_t samplerate, size_t count, int16_t * left, int16_t * right ); -LIBOPENMPT_API size_t openmpt_module_read_quad( openmpt_module * mod, int32_t samplerate, size_t count, int16_t * left, int16_t * right, int16_t * back_left, int16_t * back_right ); +LIBOPENMPT_API size_t openmpt_module_read_quad( openmpt_module * mod, int32_t samplerate, size_t count, int16_t * left, int16_t * right, int16_t * rear_left, int16_t * rear_right ); LIBOPENMPT_API size_t openmpt_module_read_float_mono( openmpt_module * mod, int32_t samplerate, size_t count, float * mono ); LIBOPENMPT_API size_t openmpt_module_read_float_stereo( openmpt_module * mod, int32_t samplerate, size_t count, float * left, float * right ); -LIBOPENMPT_API size_t openmpt_module_read_float_quad( openmpt_module * mod, int32_t samplerate, size_t count, float * left, float * right, float * back_left, float * back_right ); +LIBOPENMPT_API size_t openmpt_module_read_float_quad( openmpt_module * mod, int32_t samplerate, size_t count, float * left, float * right, float * rear_left, float * rear_right ); LIBOPENMPT_API double openmpt_module_get_current_position_seconds( openmpt_module * mod ); Modified: trunk/OpenMPT/libopenmpt/libopenmpt.hpp =================================================================== --- trunk/OpenMPT/libopenmpt/libopenmpt.hpp 2013-05-20 20:17:49 UTC (rev 2157) +++ trunk/OpenMPT/libopenmpt/libopenmpt.hpp 2013-05-21 14:37:42 UTC (rev 2158) @@ -142,10 +142,10 @@ std::size_t read( std::int32_t samplerate, std::size_t count, std::int16_t * mono ); std::size_t read( std::int32_t samplerate, std::size_t count, std::int16_t * left, std::int16_t * right ); - std::size_t read( std::int32_t samplerate, std::size_t count, std::int16_t * left, std::int16_t * right, std::int16_t * back_left, std::int16_t * back_right ); + std::size_t read( std::int32_t samplerate, std::size_t count, std::int16_t * left, std::int16_t * right, std::int16_t * rear_left, std::int16_t * rear_right ); std::size_t read( std::int32_t samplerate, std::size_t count, float * mono ); std::size_t read( std::int32_t samplerate, std::size_t count, float * left, float * right ); - std::size_t read( std::int32_t samplerate, std::size_t count, float * left, float * right, float * back_left, float * back_right ); + std::size_t read( std::int32_t samplerate, std::size_t count, float * left, float * right, float * rear_left, float * rear_right ); double get_current_position_seconds() const; Modified: trunk/OpenMPT/libopenmpt/libopenmpt_c.cpp =================================================================== --- trunk/OpenMPT/libopenmpt/libopenmpt_c.cpp 2013-05-20 20:17:49 UTC (rev 2157) +++ trunk/OpenMPT/libopenmpt/libopenmpt_c.cpp 2013-05-21 14:37:42 UTC (rev 2158) @@ -455,10 +455,10 @@ } OPENMPT_INTERFACE_CATCH_TO_LOG; return 0; } -size_t openmpt_module_read_quad( openmpt_module * mod, int32_t samplerate, size_t count, int16_t * left, int16_t * right, int16_t * back_left, int16_t * back_right ) { +size_t openmpt_module_read_quad( openmpt_module * mod, int32_t samplerate, size_t count, int16_t * left, int16_t * right, int16_t * rear_left, int16_t * rear_right ) { try { OPENMPT_INTERFACE_CHECK_SOUNDFILE( mod ); - return mod->impl->read( samplerate, count, left, right, back_left, back_right ); + return mod->impl->read( samplerate, count, left, right, rear_left, rear_right ); } OPENMPT_INTERFACE_CATCH_TO_LOG; return 0; } @@ -476,10 +476,10 @@ } OPENMPT_INTERFACE_CATCH_TO_LOG; return 0; } -size_t openmpt_module_read_float_quad( openmpt_module * mod, int32_t samplerate, size_t count, float * left, float * right, float * back_left, float * back_right ) { +size_t openmpt_module_read_float_quad( openmpt_module * mod, int32_t samplerate, size_t count, float * left, float * right, float * rear_left, float * rear_right ) { try { OPENMPT_INTERFACE_CHECK_SOUNDFILE( mod ); - return mod->impl->read( samplerate, count, left, right, back_left, back_right ); + return mod->impl->read( samplerate, count, left, right, rear_left, rear_right ); } OPENMPT_INTERFACE_CATCH_TO_LOG; return 0; } Modified: trunk/OpenMPT/libopenmpt/libopenmpt_cxx.cpp =================================================================== --- trunk/OpenMPT/libopenmpt/libopenmpt_cxx.cpp 2013-05-20 20:17:49 UTC (rev 2157) +++ trunk/OpenMPT/libopenmpt/libopenmpt_cxx.cpp 2013-05-21 14:37:42 UTC (rev 2158) @@ -138,8 +138,8 @@ std::size_t module::read( std::int32_t samplerate, std::size_t count, std::int16_t * left, std::int16_t * right ) { return impl->read( samplerate, count, left, right ); } -std::size_t module::read( std::int32_t samplerate, std::size_t count, std::int16_t * left, std::int16_t * right, std::int16_t * back_left, std::int16_t * back_right ) { - return impl->read( samplerate, count, left, right, back_left, back_right ); +std::size_t module::read( std::int32_t samplerate, std::size_t count, std::int16_t * left, std::int16_t * right, std::int16_t * rear_left, std::int16_t * rear_right ) { + return impl->read( samplerate, count, left, right, rear_left, rear_right ); } std::size_t module::read( std::int32_t samplerate, std::size_t count, float * mono ) { return impl->read( samplerate, count, mono ); @@ -147,8 +147,8 @@ std::size_t module::read( std::int32_t samplerate, std::size_t count, float * left, float * right ) { return impl->read( samplerate, count, left, right ); } -std::size_t module::read( std::int32_t samplerate, std::size_t count, float * left, float * right, float * back_left, float * back_right ) { - return impl->read( samplerate, count, left, right, back_left, back_right ); +std::size_t module::read( std::int32_t samplerate, std::size_t count, float * left, float * right, float * rear_left, float * rear_right ) { + return impl->read( samplerate, count, left, right, rear_left, rear_right ); } double module::get_current_position_seconds() const { Modified: trunk/OpenMPT/libopenmpt/libopenmpt_impl.hpp =================================================================== --- trunk/OpenMPT/libopenmpt/libopenmpt_impl.hpp 2013-05-20 20:17:49 UTC (rev 2157) +++ trunk/OpenMPT/libopenmpt/libopenmpt_impl.hpp 2013-05-21 14:37:42 UTC (rev 2158) @@ -400,8 +400,8 @@ m_currentPositionSeconds += static_cast<double>( count ) / static_cast<double>( samplerate ); return count; } - std::size_t read( std::int32_t samplerate, std::size_t count, std::int16_t * left, std::int16_t * right, std::int16_t * back_left, std::int16_t * back_right ) { - if ( !left || !right || !back_left || !back_right ) { + std::size_t read( std::int32_t samplerate, std::size_t count, std::int16_t * left, std::int16_t * right, std::int16_t * rear_left, std::int16_t * rear_right ) { + if ( !left || !right || !rear_left || !rear_right ) { throw openmpt::exception_message("null pointer"); } apply_mixer_settings( samplerate, 4, SampleFormatInt16 ); @@ -410,8 +410,8 @@ for ( std::size_t i = 0; i < count; ++i ) { left[i] = m_int16Buffer[i*4+0]; right[i] = m_int16Buffer[i*4+1]; - back_left[i] = m_int16Buffer[i*4+2]; - back_right[i] = m_int16Buffer[i*4+3]; + rear_left[i] = m_int16Buffer[i*4+2]; + rear_right[i] = m_int16Buffer[i*4+3]; } m_currentPositionSeconds += static_cast<double>( count ) / static_cast<double>( samplerate ); return count; @@ -443,8 +443,8 @@ m_currentPositionSeconds += static_cast<double>( count ) / static_cast<double>( samplerate ); return count; } - std::size_t read( std::int32_t samplerate, std::size_t count, float * left, float * right, float * back_left, float * back_right ) { - if ( !left || !right || !back_left || !back_right ) { + std::size_t read( std::int32_t samplerate, std::size_t count, float * left, float * right, float * rear_left, float * rear_right ) { + if ( !left || !right || !rear_left || !rear_right ) { throw openmpt::exception_message("null pointer"); } apply_mixer_settings( samplerate, 4, SampleFormatFloat32 ); @@ -453,8 +453,8 @@ for ( std::size_t i = 0; i < count; ++i ) { left[i] = m_floatBuffer[i*4+0]; right[i] = m_floatBuffer[i*4+1]; - back_left[i] = m_floatBuffer[i*4+2]; - back_right[i] = m_floatBuffer[i*4+3]; + rear_left[i] = m_floatBuffer[i*4+2]; + rear_right[i] = m_floatBuffer[i*4+3]; } m_currentPositionSeconds += static_cast<double>( count ) / static_cast<double>( samplerate ); return count; Modified: trunk/OpenMPT/openmpt123/openmpt123.cpp =================================================================== --- trunk/OpenMPT/openmpt123/openmpt123.cpp 2013-05-20 20:17:49 UTC (rev 2157) +++ trunk/OpenMPT/openmpt123/openmpt123.cpp 2013-05-21 14:37:42 UTC (rev 2158) @@ -420,13 +420,13 @@ std::vector<Tsample> left( bufsize ); std::vector<Tsample> right( bufsize ); - std::vector<Tsample> back_left( bufsize ); - std::vector<Tsample> back_right( bufsize ); + std::vector<Tsample> rear_left( bufsize ); + std::vector<Tsample> rear_right( bufsize ); std::vector<Tsample*> buffers( 4 ) ; buffers[0] = left.data(); buffers[1] = right.data(); - buffers[2] = back_left.data(); - buffers[3] = back_right.data(); + buffers[2] = rear_left.data(); + buffers[3] = rear_right.data(); buffers.resize( flags.channels ); while ( true ) { @@ -436,7 +436,7 @@ switch ( flags.channels ) { case 1: count = mod.read( flags.samplerate, bufsize, left.data() ); break; case 2: count = mod.read( flags.samplerate, bufsize, left.data(), right.data() ); break; - case 4: count = mod.read( flags.samplerate, bufsize, left.data(), right.data(), back_left.data(), back_right.data() ); break; + case 4: count = mod.read( flags.samplerate, bufsize, left.data(), right.data(), rear_left.data(), rear_right.data() ); break; } if ( count == 0 ) { This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <man...@us...> - 2013-05-21 14:46:18
|
Revision: 2160 http://sourceforge.net/p/modplug/code/2160 Author: manxorist Date: 2013-05-21 14:46:11 +0000 (Tue, 21 May 2013) Log Message: ----------- [Mod] Change unit of MASTERGAIN render_param in libopenmpt from decibel to millibel. [Ref] Clarify render_param names in libeopenmpt API. [Ref] Cleanup libopenmpt_settings. Remove libopenmpt_settings_dialog.*. [Mod] Properly CamelCase registry keys for in_openmpt and xmp-openmpt. [Fix] class openmpt::exception_message has to be exported from shared libraries so that type_info lookup does not crash. Modified Paths: -------------- trunk/OpenMPT/libopenmpt/SettingsForm.h trunk/OpenMPT/libopenmpt/libopenmpt.h trunk/OpenMPT/libopenmpt/libopenmpt.hpp trunk/OpenMPT/libopenmpt/libopenmpt_impl.hpp trunk/OpenMPT/libopenmpt/libopenmpt_modplug.c trunk/OpenMPT/libopenmpt/libopenmpt_settings.cpp trunk/OpenMPT/libopenmpt/libopenmpt_settings.h trunk/OpenMPT/libopenmpt/libopenmpt_settings.vcxproj trunk/OpenMPT/libopenmpt/libopenmpt_settings.vcxproj.filters trunk/OpenMPT/libopenmpt/libopenmpt_winamp.cpp trunk/OpenMPT/libopenmpt/libopenmpt_xmplay.cpp trunk/OpenMPT/openmpt123/openmpt123.cpp Removed Paths: ------------- trunk/OpenMPT/libopenmpt/libopenmpt_settings_dialog.cpp trunk/OpenMPT/libopenmpt/libopenmpt_settings_dialog.h Modified: trunk/OpenMPT/libopenmpt/SettingsForm.h =================================================================== --- trunk/OpenMPT/libopenmpt/SettingsForm.h 2013-05-21 14:38:33 UTC (rev 2159) +++ trunk/OpenMPT/libopenmpt/SettingsForm.h 2013-05-21 14:46:11 UTC (rev 2160) @@ -47,7 +47,7 @@ comboBoxSamplerate->Enabled = settings->with_outputformat; comboBoxChannels->Enabled = settings->with_outputformat; - trackBarGain->Value = settings->mastergain; + trackBarGain->Value = settings->mastergain_millibel; trackBarMaxPolyphony->Value = settings->maxmixchannels; @@ -197,13 +197,15 @@ // // trackBarGain // - this->trackBarGain->LargeChange = 3; + this->trackBarGain->LargeChange = 300; this->trackBarGain->Location = System::Drawing::Point(106, 63); - this->trackBarGain->Maximum = 12; - this->trackBarGain->Minimum = -12; + this->trackBarGain->Maximum = 1200; + this->trackBarGain->Minimum = -1200; this->trackBarGain->Name = L"trackBarGain"; this->trackBarGain->Size = System::Drawing::Size(121, 42); + this->trackBarGain->SmallChange = 100; this->trackBarGain->TabIndex = 6; + this->trackBarGain->TickFrequency = 100; this->trackBarGain->TickStyle = System::Windows::Forms::TickStyle::Both; this->trackBarGain->Scroll += gcnew System::EventHandler(this, &SettingsForm::trackBarGain_Scroll); // @@ -399,7 +401,7 @@ settings->changed(); } private: System::Void trackBarGain_Scroll(System::Object^ sender, System::EventArgs^ e) { - settings->mastergain = (int)trackBarGain->Value; + settings->mastergain_millibel = (int)trackBarGain->Value; settings->changed(); } private: System::Void comboBoxInterpolation_SelectedIndexChanged(System::Object^ sender, System::EventArgs^ e) { Modified: trunk/OpenMPT/libopenmpt/libopenmpt.h =================================================================== --- trunk/OpenMPT/libopenmpt/libopenmpt.h 2013-05-21 14:38:33 UTC (rev 2159) +++ trunk/OpenMPT/libopenmpt/libopenmpt.h 2013-05-21 14:46:11 UTC (rev 2160) @@ -63,14 +63,14 @@ LIBOPENMPT_API void openmpt_module_destroy( openmpt_module * mod ); -#define OPENMPT_MODULE_RENDER_MASTERGAIN_DB 1 -#define OPENMPT_MODULE_RENDER_STEREOSEPARATION_PERCENT 2 -#define OPENMPT_MODULE_RENDER_REPEATCOUNT 3 -#define OPENMPT_MODULE_RENDER_QUALITY_PERCENT 4 -#define OPENMPT_MODULE_RENDER_MAXMIXCHANNELS 5 -#define OPENMPT_MODULE_RENDER_INTERPOLATION_MODE 6 -#define OPENMPT_MODULE_RENDER_VOLUMERAMP_IN_US 7 -#define OPENMPT_MODULE_RENDER_VOLUMERAMP_OUT_US 8 +#define OPENMPT_MODULE_RENDER_MASTERGAIN_MILLIBEL 1 +#define OPENMPT_MODULE_RENDER_STEREOSEPARATION_PERCENT 2 +#define OPENMPT_MODULE_RENDER_REPEATCOUNT 3 +#define OPENMPT_MODULE_RENDER_QUALITY_PERCENT 4 +#define OPENMPT_MODULE_RENDER_MAXMIXCHANNELS 5 +#define OPENMPT_MODULE_RENDER_INTERPOLATION_MODE 6 +#define OPENMPT_MODULE_RENDER_VOLUMERAMP_IN_MICROSECONDS 7 +#define OPENMPT_MODULE_RENDER_VOLUMERAMP_OUT_MICROSECONDS 8 #define OPENMPT_MODULE_RENDER_INTERPOLATION_NEAREST 1 #define OPENMPT_MODULE_RENDER_INTERPOLATION_LINEAR 2 Modified: trunk/OpenMPT/libopenmpt/libopenmpt.hpp =================================================================== --- trunk/OpenMPT/libopenmpt/libopenmpt.hpp 2013-05-21 14:38:33 UTC (rev 2159) +++ trunk/OpenMPT/libopenmpt/libopenmpt.hpp 2013-05-21 14:46:11 UTC (rev 2160) @@ -77,14 +77,14 @@ public: enum render_param { - RENDER_MASTERGAIN_DB = 1, - RENDER_STEREOSEPARATION_PERCENT = 2, - RENDER_REPEATCOUNT = 3, - RENDER_QUALITY_PERCENT = 4, - RENDER_MAXMIXCHANNELS = 5, - RENDER_INTERPOLATION_MODE = 6, - RENDER_VOLUMERAMP_IN_US = 7, - RENDER_VOLUMERAMP_OUT_US = 8, + RENDER_MASTERGAIN_MILLIBEL = 1, + RENDER_STEREOSEPARATION_PERCENT = 2, + RENDER_REPEATCOUNT = 3, + RENDER_QUALITY_PERCENT = 4, + RENDER_MAXMIXCHANNELS = 5, + RENDER_INTERPOLATION_MODE = 6, + RENDER_VOLUMERAMP_IN_MICROSECONDS = 7, + RENDER_VOLUMERAMP_OUT_MICROSECONDS = 8, }; enum interpolation_mode { Modified: trunk/OpenMPT/libopenmpt/libopenmpt_impl.hpp =================================================================== --- trunk/OpenMPT/libopenmpt/libopenmpt_impl.hpp 2013-05-21 14:38:33 UTC (rev 2159) +++ trunk/OpenMPT/libopenmpt/libopenmpt_impl.hpp 2013-05-21 14:46:11 UTC (rev 2160) @@ -41,7 +41,8 @@ } // namespace version -class exception_message : public exception { +// has to be exported for type_info lookup to work +class LIBOPENMPT_CXX_API exception_message : public exception { public: exception_message( const char * text_ ) throw() : text(text_) { } virtual ~exception_message() throw() { } @@ -256,8 +257,8 @@ public: std::int32_t get_render_param( int command ) const { switch ( command ) { - case module::RENDER_MASTERGAIN_DB: { - return static_cast<std::int32_t>( 10.0f * 2.0f * std::log10( fx16_to_float( m_sndFile.m_MixerSettings.m_FinalOutputGain ) ) ); + case module::RENDER_MASTERGAIN_MILLIBEL: { + return static_cast<std::int32_t>( 1000.0f * 2.0f * std::log10( fx16_to_float( m_sndFile.m_MixerSettings.m_FinalOutputGain ) ) ); } break; case module::RENDER_STEREOSEPARATION_PERCENT: { return m_sndFile.m_MixerSettings.m_nStereoSeparation * 100 / 128; @@ -295,10 +296,10 @@ } throw openmpt::exception_message("unknown interpolation mode set internally"); } break; - case module::RENDER_VOLUMERAMP_IN_US: { + case module::RENDER_VOLUMERAMP_IN_MICROSECONDS: { return m_sndFile.m_MixerSettings.GetVolumeRampUpMicroseconds(); } break; - case module::RENDER_VOLUMERAMP_OUT_US: { + case module::RENDER_VOLUMERAMP_OUT_MICROSECONDS: { return m_sndFile.m_MixerSettings.GetVolumeRampDownMicroseconds(); } break; default: throw openmpt::exception_message("unknown command"); break; @@ -307,8 +308,8 @@ } void set_render_param( int command, std::int32_t value ) { switch ( command ) { - case module::RENDER_MASTERGAIN_DB: { - float gainFactor = static_cast<float>( std::pow( 10.0f, value * 0.1f * 0.5f ) ); + case module::RENDER_MASTERGAIN_MILLIBEL: { + float gainFactor = static_cast<float>( std::pow( 10.0f, value * 0.001f * 0.5f ) ); if ( static_cast<std::int32_t>( m_sndFile.m_MixerSettings.m_FinalOutputGain ) != float_to_fx16( gainFactor ) ) { MixerSettings settings = m_sndFile.m_MixerSettings; settings.m_FinalOutputGain = float_to_fx16( gainFactor ); @@ -356,14 +357,14 @@ m_sndFile.SetResamplerSettings( newsettings ); } } break; - case module::RENDER_VOLUMERAMP_IN_US: { + case module::RENDER_VOLUMERAMP_IN_MICROSECONDS: { MixerSettings newsettings = m_sndFile.m_MixerSettings; newsettings.SetVolumeRampUpMicroseconds( value ); if ( m_sndFile.m_MixerSettings.glVolumeRampUpSamples != newsettings.glVolumeRampUpSamples ) { m_sndFile.SetMixerSettings( newsettings ); } } break; - case module::RENDER_VOLUMERAMP_OUT_US: { + case module::RENDER_VOLUMERAMP_OUT_MICROSECONDS: { MixerSettings newsettings = m_sndFile.m_MixerSettings; newsettings.SetVolumeRampDownMicroseconds( value ); if ( m_sndFile.m_MixerSettings.glVolumeRampDownSamples != newsettings.glVolumeRampDownSamples ) { Modified: trunk/OpenMPT/libopenmpt/libopenmpt_modplug.c =================================================================== --- trunk/OpenMPT/libopenmpt/libopenmpt_modplug.c 2013-05-21 14:38:33 UTC (rev 2159) +++ trunk/OpenMPT/libopenmpt/libopenmpt_modplug.c 2013-05-21 14:46:11 UTC (rev 2160) @@ -329,14 +329,14 @@ int32_t val; if(!file) return 0; val = 0; - if(!openmpt_module_get_render_param(file->mod,OPENMPT_MODULE_RENDER_MASTERGAIN_DB,&val)) return 128; - return (unsigned int)(128.0*pow(10.0,val*0.05)); + if(!openmpt_module_get_render_param(file->mod,OPENMPT_MODULE_RENDER_MASTERGAIN_MILLIBEL,&val)) return 128; + return (unsigned int)(128.0*pow(10.0,val*0.0005)); } LIBOPENMPT_MODPLUG_API void ModPlug_SetMasterVolume(ModPlugFile* file,unsigned int cvol) { if(!file) return; - openmpt_module_set_render_param(file->mod,OPENMPT_MODULE_RENDER_MASTERGAIN_DB,(int32_t)(20.0*log10(cvol/128.0))); + openmpt_module_set_render_param(file->mod,OPENMPT_MODULE_RENDER_MASTERGAIN_MILLIBEL,(int32_t)(2000.0*log10(cvol/128.0))); } LIBOPENMPT_MODPLUG_API int ModPlug_GetCurrentSpeed(ModPlugFile* file) Modified: trunk/OpenMPT/libopenmpt/libopenmpt_settings.cpp =================================================================== --- trunk/OpenMPT/libopenmpt/libopenmpt_settings.cpp 2013-05-21 14:38:33 UTC (rev 2159) +++ trunk/OpenMPT/libopenmpt/libopenmpt_settings.cpp 2013-05-21 14:46:11 UTC (rev 2160) @@ -7,9 +7,11 @@ * The OpenMPT source code is released under the BSD license. Read LICENSE for more details. */ +#include "libopenmpt_internal.h" + #define LIBOPENMPT_BUILD_SETTINGS_DLL #include "libopenmpt_settings.h" -#include "libopenmpt_settings_dialog.h" +#include "SettingsForm.h" namespace openmpt { @@ -21,4 +23,29 @@ return; } +void registry_settings::read_setting( const char * key, int & val ) { + System::String ^ net_root = "HKEY_CURRENT_USER\\Software\\libopenmpt\\"; + System::String ^ net_path = gcnew System::String( subkey ); + System::String ^ net_key = gcnew System::String( key ); + System::Object ^ retval = Microsoft::Win32::Registry::GetValue( System::String::Concat( net_root, net_path ), net_key, val ); + if ( retval == nullptr ) { + return; + } else { + val = (int)retval; + } +} + +void registry_settings::write_setting( const char * key, int val ) { + System::String ^ net_root = "HKEY_CURRENT_USER\\Software\\libopenmpt\\"; + System::String ^ net_path = gcnew System::String( subkey ); + System::String ^ net_key = gcnew System::String( key ); + Microsoft::Win32::Registry::SetValue( System::String::Concat( net_root, net_path ), net_key, val ); +} + +void registry_settings::edit_settings( HWND parent, const char * title ) { + libopenmpt::SettingsForm ^ form = gcnew libopenmpt::SettingsForm( title, this ); + System::Windows::Forms::IWin32Window ^w = System::Windows::Forms::Control::FromHandle((System::IntPtr)parent); + form->Show(w); +} + } // namespace openmpt Modified: trunk/OpenMPT/libopenmpt/libopenmpt_settings.h =================================================================== --- trunk/OpenMPT/libopenmpt/libopenmpt_settings.h 2013-05-21 14:38:33 UTC (rev 2159) +++ trunk/OpenMPT/libopenmpt/libopenmpt_settings.h 2013-05-21 14:46:11 UTC (rev 2160) @@ -37,7 +37,7 @@ bool with_outputformat; int samplerate; int channels; - int mastergain; + int mastergain_millibel; int stereoseparation; int repeatcount; int maxmixchannels; @@ -56,27 +56,27 @@ }; inline void settings::load() { - read_setting( "samplerate", samplerate ); - read_setting( "channels", channels ); - read_setting( "mastergain", mastergain ); - read_setting( "stereoseparation", stereoseparation ); - read_setting( "repeatcount", repeatcount ); - read_setting( "maxmixchannels", maxmixchannels ); - read_setting( "interpolationmode", interpolationmode ); - read_setting( "volrampin_microseconds", volrampinus ); - read_setting( "volrampout_microseconds", volrampoutus ); + read_setting( "Samplerate_Hz", samplerate ); + read_setting( "Channels", channels ); + read_setting( "MasterGain_milliBel", mastergain_millibel ); + read_setting( "SeteroSeparation_Percent", stereoseparation ); + read_setting( "RepeatCount", repeatcount ); + read_setting( "MixerChannels", maxmixchannels ); + read_setting( "InterpolationMode", interpolationmode ); + read_setting( "VolumeRampingIn_microseconds", volrampinus ); + read_setting( "VolumeRampingOut_microseconds", volrampoutus ); } inline void settings::save() { - write_setting( "samplerate", samplerate ); - write_setting( "channels", channels ); - write_setting( "mastergain", mastergain ); - write_setting( "stereoseparation", stereoseparation ); - write_setting( "repeatcount", repeatcount ); - write_setting( "maxmixchannels", maxmixchannels ); - write_setting( "interpolationmode", interpolationmode ); - write_setting( "volrampin_microseconds", volrampinus ); - write_setting( "volrampout_microseconds", volrampoutus ); + write_setting( "Samplerate_Hz", samplerate ); + write_setting( "Channels", channels ); + write_setting( "MasterGain_milliBel", mastergain_millibel ); + write_setting( "SeteroSeparation_Percent", stereoseparation ); + write_setting( "RepeatCount", repeatcount ); + write_setting( "MixerChannels", maxmixchannels ); + write_setting( "InterpolationMode", interpolationmode ); + write_setting( "VolumeRampingIn_microseconds", volrampinus ); + write_setting( "VolumeRampingOut_microseconds", volrampoutus ); } inline void settings::edit( HWND parent, const char * title ) { @@ -86,7 +86,7 @@ inline settings::settings( bool with_outputformat_ ) : with_outputformat(with_outputformat_) { samplerate = 48000; channels = 2; - mastergain = 0; + mastergain_millibel = 0; stereoseparation = 100; repeatcount = 0; maxmixchannels = 256; Modified: trunk/OpenMPT/libopenmpt/libopenmpt_settings.vcxproj =================================================================== --- trunk/OpenMPT/libopenmpt/libopenmpt_settings.vcxproj 2013-05-21 14:38:33 UTC (rev 2159) +++ trunk/OpenMPT/libopenmpt/libopenmpt_settings.vcxproj 2013-05-21 14:46:11 UTC (rev 2160) @@ -66,15 +66,11 @@ </Link> </ItemDefinitionGroup> <ItemGroup> - <ClCompile Include="libopenmpt_settings.cpp" /> - <ClCompile Include="libopenmpt_settings_dialog.cpp"> + <ClCompile Include="libopenmpt_settings.cpp"> <CompileAsManaged Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">true</CompileAsManaged> <CompileAsManaged Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">true</CompileAsManaged> <ExceptionHandling Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">Async</ExceptionHandling> <ExceptionHandling Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">Async</ExceptionHandling> - <DebugInformationFormat Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">ProgramDatabase</DebugInformationFormat> - <MinimalRebuild Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">false</MinimalRebuild> - <BasicRuntimeChecks Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">Default</BasicRuntimeChecks> </ClCompile> <ClCompile Include="SettingsForm.cpp"> <CompileAsManaged Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">true</CompileAsManaged> @@ -93,7 +89,6 @@ </ItemGroup> <ItemGroup> <ClInclude Include="libopenmpt_settings.h" /> - <ClInclude Include="libopenmpt_settings_dialog.h" /> <ClInclude Include="SettingsForm.h"> <FileType>CppForm</FileType> </ClInclude> Modified: trunk/OpenMPT/libopenmpt/libopenmpt_settings.vcxproj.filters =================================================================== --- trunk/OpenMPT/libopenmpt/libopenmpt_settings.vcxproj.filters 2013-05-21 14:38:33 UTC (rev 2159) +++ trunk/OpenMPT/libopenmpt/libopenmpt_settings.vcxproj.filters 2013-05-21 14:46:11 UTC (rev 2160) @@ -18,9 +18,6 @@ <ClCompile Include="libopenmpt_settings.cpp"> <Filter>Source Files</Filter> </ClCompile> - <ClCompile Include="libopenmpt_settings_dialog.cpp"> - <Filter>Source Files</Filter> - </ClCompile> <ClCompile Include="SettingsForm.cpp"> <Filter>Source Files</Filter> </ClCompile> @@ -29,9 +26,6 @@ <ClInclude Include="libopenmpt_settings.h"> <Filter>Header Files</Filter> </ClInclude> - <ClInclude Include="libopenmpt_settings_dialog.h"> - <Filter>Header Files</Filter> - </ClInclude> <ClInclude Include="SettingsForm.h"> <Filter>Header Files</Filter> </ClInclude> Deleted: trunk/OpenMPT/libopenmpt/libopenmpt_settings_dialog.cpp =================================================================== --- trunk/OpenMPT/libopenmpt/libopenmpt_settings_dialog.cpp 2013-05-21 14:38:33 UTC (rev 2159) +++ trunk/OpenMPT/libopenmpt/libopenmpt_settings_dialog.cpp 2013-05-21 14:46:11 UTC (rev 2160) @@ -1,35 +0,0 @@ - -#include "libopenmpt_internal.h" - -#define LIBOPENMPT_BUILD_SETTINGS_DLL -#include "libopenmpt_settings_dialog.h" -#include "SettingsForm.h" - -namespace openmpt { - -void registry_settings::read_setting( const char * key, int & val ) { - System::String ^ net_root = "HKEY_CURRENT_USER\\Software\\libopenmpt\\"; - System::String ^ net_path = gcnew System::String( subkey ); - System::String ^ net_key = gcnew System::String( key ); - System::Object ^ retval = Microsoft::Win32::Registry::GetValue( System::String::Concat( net_root, net_path ), net_key, val ); - if ( retval == nullptr ) { - return; - } else { - val = (int)retval; - } -} - -void registry_settings::write_setting( const char * key, int val ) { - System::String ^ net_root = "HKEY_CURRENT_USER\\Software\\libopenmpt\\"; - System::String ^ net_path = gcnew System::String( subkey ); - System::String ^ net_key = gcnew System::String( key ); - Microsoft::Win32::Registry::SetValue( System::String::Concat( net_root, net_path ), net_key, val ); -} - -void registry_settings::edit_settings( HWND parent, const char * title ) { - libopenmpt::SettingsForm ^ form = gcnew libopenmpt::SettingsForm( title, this ); - System::Windows::Forms::IWin32Window ^w = System::Windows::Forms::Control::FromHandle((System::IntPtr)parent); - form->Show(w); -} - -} // namespace openmpt Deleted: trunk/OpenMPT/libopenmpt/libopenmpt_settings_dialog.h =================================================================== --- trunk/OpenMPT/libopenmpt/libopenmpt_settings_dialog.h 2013-05-21 14:38:33 UTC (rev 2159) +++ trunk/OpenMPT/libopenmpt/libopenmpt_settings_dialog.h 2013-05-21 14:46:11 UTC (rev 2160) @@ -1,10 +0,0 @@ - -#pragma once - -#include "libopenmpt_settings.h" - -namespace openmpt { - -void edit_settings( settings * s, HWND parent, const char * title ); - -} Modified: trunk/OpenMPT/libopenmpt/libopenmpt_winamp.cpp =================================================================== --- trunk/OpenMPT/libopenmpt/libopenmpt_winamp.cpp 2013-05-21 14:38:33 UTC (rev 2159) +++ trunk/OpenMPT/libopenmpt/libopenmpt_winamp.cpp 2013-05-21 14:46:11 UTC (rev 2160) @@ -116,13 +116,13 @@ static void apply_options() { if ( self->mod ) { - self->mod->set_render_param( openmpt::module::RENDER_MASTERGAIN_DB, self->settings->mastergain ); + self->mod->set_render_param( openmpt::module::RENDER_MASTERGAIN_MILLIBEL, self->settings->mastergain_millibel ); self->mod->set_render_param( openmpt::module::RENDER_STEREOSEPARATION_PERCENT, self->settings->stereoseparation ); self->mod->set_render_param( openmpt::module::RENDER_REPEATCOUNT, self->settings->repeatcount ); self->mod->set_render_param( openmpt::module::RENDER_MAXMIXCHANNELS, self->settings->maxmixchannels ); self->mod->set_render_param( openmpt::module::RENDER_INTERPOLATION_MODE, self->settings->interpolationmode ); - self->mod->set_render_param( openmpt::module::RENDER_VOLUMERAMP_IN_US, self->settings->volrampinus ); - self->mod->set_render_param( openmpt::module::RENDER_VOLUMERAMP_OUT_US, self->settings->volrampoutus ); + self->mod->set_render_param( openmpt::module::RENDER_VOLUMERAMP_IN_MICROSECONDS, self->settings->volrampinus ); + self->mod->set_render_param( openmpt::module::RENDER_VOLUMERAMP_OUT_MICROSECONDS, self->settings->volrampoutus ); } self->settings->save(); } Modified: trunk/OpenMPT/libopenmpt/libopenmpt_xmplay.cpp =================================================================== --- trunk/OpenMPT/libopenmpt/libopenmpt_xmplay.cpp 2013-05-21 14:38:33 UTC (rev 2159) +++ trunk/OpenMPT/libopenmpt/libopenmpt_xmplay.cpp 2013-05-21 14:46:11 UTC (rev 2160) @@ -102,13 +102,13 @@ static void apply_options() { if ( self->mod ) { - self->mod->set_render_param( openmpt::module::RENDER_MASTERGAIN_DB, self->settings->mastergain ); + self->mod->set_render_param( openmpt::module::RENDER_MASTERGAIN_MILLIBEL, self->settings->mastergain_millibel ); self->mod->set_render_param( openmpt::module::RENDER_STEREOSEPARATION_PERCENT, self->settings->stereoseparation ); self->mod->set_render_param( openmpt::module::RENDER_REPEATCOUNT, self->settings->repeatcount ); self->mod->set_render_param( openmpt::module::RENDER_MAXMIXCHANNELS, self->settings->maxmixchannels ); self->mod->set_render_param( openmpt::module::RENDER_INTERPOLATION_MODE, self->settings->interpolationmode ); - self->mod->set_render_param( openmpt::module::RENDER_VOLUMERAMP_IN_US, self->settings->volrampinus ); - self->mod->set_render_param( openmpt::module::RENDER_VOLUMERAMP_OUT_US, self->settings->volrampoutus ); + self->mod->set_render_param( openmpt::module::RENDER_VOLUMERAMP_IN_MICROSECONDS, self->settings->volrampinus ); + self->mod->set_render_param( openmpt::module::RENDER_VOLUMERAMP_OUT_MICROSECONDS, self->settings->volrampoutus ); } self->settings->save(); } Modified: trunk/OpenMPT/openmpt123/openmpt123.cpp =================================================================== --- trunk/OpenMPT/openmpt123/openmpt123.cpp 2013-05-21 14:38:33 UTC (rev 2159) +++ trunk/OpenMPT/openmpt123/openmpt123.cpp 2013-05-21 14:46:11 UTC (rev 2160) @@ -125,7 +125,7 @@ s << "Buffer: " << flags.buffer << std::endl; s << "Repeat count: " << flags.repeatcount << std::endl; s << "Sample rate: " << flags.samplerate << std::endl; - s << "Gain: " << flags.gain << std::endl; + s << "Gain: " << flags.gain / 100.0 << std::endl; s << "Quality: " << flags.quality << std::endl; s << "Seek target: " << flags.seek_target << std::endl; s << "Float: " << flags.use_float << std::endl; @@ -367,7 +367,7 @@ std::clog << " --[no]-float Output 32bit floating point instead of 16bit integer [default: " << openmpt123_flags().use_float << "]" << std::endl; std::clog << " --buffer n Set output buffer size to n ms [default: " << openmpt123_flags().buffer << "]," << std::endl; std::clog << " --samplerate n Set samplerate to n Hz [default: " << openmpt123_flags().samplerate << "]" << std::endl; - std::clog << " --gain n Set output gain to n dB [default: " << openmpt123_flags().gain << "]" << std::endl; + std::clog << " --gain n Set output gain to n dB [default: " << openmpt123_flags().gain / 100.0 << "]" << std::endl; std::clog << " --repeat n Repeat song n times (-1 means forever) [default: " << openmpt123_flags().repeatcount << "]" << std::endl; std::clog << " --quality n Set rendering quality to n % [default: " << openmpt123_flags().quality << "]" << std::endl; std::clog << " --seek n Seek to n seconds on start [default: " << openmpt123_flags().seek_target << "]" << std::endl; @@ -506,9 +506,9 @@ mod.set_render_param( openmpt::module::RENDER_REPEATCOUNT, flags.repeatcount ); mod.set_render_param( openmpt::module::RENDER_QUALITY_PERCENT, flags.quality ); - mod.set_render_param( openmpt::module::RENDER_MASTERGAIN_DB, flags.gain ); - mod.set_render_param( openmpt::module::RENDER_VOLUMERAMP_IN_US, flags.rampinus ); - mod.set_render_param( openmpt::module::RENDER_VOLUMERAMP_OUT_US, flags.rampoutus ); + mod.set_render_param( openmpt::module::RENDER_MASTERGAIN_MILLIBEL, flags.gain ); + mod.set_render_param( openmpt::module::RENDER_VOLUMERAMP_IN_MICROSECONDS, flags.rampinus ); + mod.set_render_param( openmpt::module::RENDER_VOLUMERAMP_OUT_MICROSECONDS, flags.rampoutus ); if ( flags.seek_target > 0.0 ) { mod.seek_seconds( flags.seek_target ); @@ -643,7 +643,9 @@ ++i; } else if ( arg == "--gain" && nextarg != "" ) { std::istringstream istr( nextarg ); - istr >> flags.gain; + double gain = 0.0; + istr >> gain; + flags.gain = static_cast<std::int32_t>( gain * 100.0 ); ++i; } else if ( arg == "--repeat" && nextarg != "" ) { std::istringstream istr( nextarg ); This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <man...@us...> - 2013-05-21 20:08:28
|
Revision: 2162 http://sourceforge.net/p/modplug/code/2162 Author: manxorist Date: 2013-05-21 20:08:19 +0000 (Tue, 21 May 2013) Log Message: ----------- [Ref] Rename mpt::String to mpt::string. [Ref] Shrink mpt::string to the needed bare minimum (operator const char*()). Move Format function out of the class and make it return a std::string. [Ref] When not building MODPLUG_TRACKER, mpt::string can now be a simple typedef of std::string. [Ref] Move function in mptString.h into namespace mpt::String. [Ref] Reduce mpt::string usage all over the place down to just 2 usage sites. Those 2 would require adding a ton of .c_str() in mptrack/ to remove. Leave that for later. Modified Paths: -------------- trunk/OpenMPT/common/mptString.cpp trunk/OpenMPT/common/mptString.h trunk/OpenMPT/common/version.cpp trunk/OpenMPT/common/version.h trunk/OpenMPT/mptrack/Ctrl_pat.cpp trunk/OpenMPT/mptrack/Draw_pat.cpp trunk/OpenMPT/mptrack/MIDIMapping.cpp trunk/OpenMPT/mptrack/MIDIMappingDialog.cpp trunk/OpenMPT/mptrack/MPTHacks.cpp trunk/OpenMPT/mptrack/Moddoc.cpp trunk/OpenMPT/mptrack/Mptrack.cpp trunk/OpenMPT/mptrack/TrackerSettings.cpp trunk/OpenMPT/mptrack/TuningDialog.cpp trunk/OpenMPT/mptrack/Vstplug.cpp trunk/OpenMPT/mptrack/dlg_misc.cpp trunk/OpenMPT/mptrack/test/test.cpp trunk/OpenMPT/mptrack/view_com.cpp trunk/OpenMPT/soundlib/LOAD_DBM.CPP trunk/OpenMPT/soundlib/Load_ams.cpp trunk/OpenMPT/soundlib/Load_digi.cpp trunk/OpenMPT/soundlib/Load_gdm.cpp trunk/OpenMPT/soundlib/Load_it.cpp trunk/OpenMPT/soundlib/Load_itp.cpp trunk/OpenMPT/soundlib/Load_med.cpp trunk/OpenMPT/soundlib/Load_mt2.cpp trunk/OpenMPT/soundlib/Load_mtm.cpp trunk/OpenMPT/soundlib/Load_ptm.cpp trunk/OpenMPT/soundlib/Load_s3m.cpp trunk/OpenMPT/soundlib/Load_stm.cpp trunk/OpenMPT/soundlib/Load_xm.cpp trunk/OpenMPT/soundlib/ModSequence.cpp trunk/OpenMPT/soundlib/ModSequence.h trunk/OpenMPT/soundlib/Sndfile.cpp trunk/OpenMPT/soundlib/Sndfile.h trunk/OpenMPT/soundlib/pattern.cpp trunk/OpenMPT/soundlib/pattern.h trunk/OpenMPT/soundlib/plugins/PlugInterface.h trunk/OpenMPT/soundlib/tuningcollection.h Modified: trunk/OpenMPT/common/mptString.cpp =================================================================== --- trunk/OpenMPT/common/mptString.cpp 2013-05-21 15:10:38 UTC (rev 2161) +++ trunk/OpenMPT/common/mptString.cpp 2013-05-21 20:08:19 UTC (rev 2162) @@ -14,25 +14,22 @@ #include <cstdarg> -namespace mpt { +namespace mpt { namespace String { -// Formats this string, like CString::Format. -void String::Format(const CharT* pszFormat, ...) + +std::string Format(const char *format, ...) { #if MPT_COMPILER_MSVC va_list argList; - va_start( argList, pszFormat ); + va_start(argList, format); // Count the needed array size. - const size_t nCount = _vscprintf(pszFormat, argList); // null character not included. - resize(nCount + 1); // + 1 is for null terminator. + const size_t nCount = _vscprintf(format, argList); // null character not included. + std::vector<char> buf(nCount + 1); // + 1 is for null terminator. + vsprintf_s(&(buf[0]), buf.size(), format, argList); - // Hack: directly modify the std::string's string. - // In C++11 std::string is guaranteed to be contiguous. - const int nCount2 = vsprintf_s(&*begin(), size(), pszFormat, argList); - resize(nCount2); // Removes the null character that vsprintf_s adds. - - va_end( argList ); + va_end(argList); + return &(buf[0]); #else va_list argList; va_start(argList, pszFormat); @@ -42,34 +39,9 @@ va_start(argList, pszFormat); vsnprintf(&(temp[0]), size + 1, pszFormat, argList); va_end(argList); - assign(&(temp[0])); + return &(temp[0]); #endif } -// Remove whitespaces at start of string -void String::LTrim() -{ - size_type pos = find_first_not_of(" \n\r\t"); - if(pos != npos) - erase(begin(), begin() + pos); -} - - -// Remove whitespaces at end of string -void String::RTrim() -{ - size_type pos = find_last_not_of(" \n\r\t"); - if(pos != npos) - erase(begin() + pos + 1, end()); -} - - -// Remove whitespaces at start and end of string -void String::Trim() -{ - LTrim(); - RTrim(); -} - -} // namespace mpt +} } // namespace mpt::String Modified: trunk/OpenMPT/common/mptString.h =================================================================== --- trunk/OpenMPT/common/mptString.h 2013-05-21 15:10:38 UTC (rev 2161) +++ trunk/OpenMPT/common/mptString.h 2013-05-21 20:08:19 UTC (rev 2162) @@ -23,71 +23,68 @@ #define MPT_PRINTF_FUNC(formatstringindex,varargsindex) #endif + namespace mpt { - // Quick and incomplete string class to be used as a replacement for - // CString and std::string in soundlib. - class String : public std::string + + +#ifdef MODPLUG_TRACKER + // std::string compatible class that is convertible to const char* (and thus CString). + // This eases interfacing CSoundFile from MFC code in some cases. + // The goal is to remove this sometime in the future. + class string : public std::string { public: - typedef std::string BaseClass; - typedef char CharT; + string() {} + string(const char *psz) : std::string(psz) {} + string(const std::string &other) : std::string(other) {} + string& operator=(const char *psz) { std::string::operator=(psz); return *this; } + operator const char *() const { return c_str(); } // To allow easy assignment to CString in GUI side. + }; +#else + typedef std::string string; +#endif - String() {} - String(const CharT* psz) : BaseClass(psz) {} - String(const std::string& other) : BaseClass(other) {} - // Move constructors and move assignments. - #if defined(MPT_COMPILER_HAS_RVALUE_REF) - String(BaseClass&& str) : BaseClass(std::move(str)) {} - String(String&& other) : BaseClass(std::move(static_cast<BaseClass&>(other))) {} - String& operator=(BaseClass&& str) {BaseClass::operator=(std::move(str)); return *this;} - String& operator=(String&& other) {BaseClass::operator=(std::move(static_cast<BaseClass&>(other))); return *this;} - #endif +namespace String +{ - String& operator=(const CharT* psz) {BaseClass::operator=(psz); return *this;} - #ifdef _MFC_VER - String(const CString& str) {(*this) = str.GetString();} - String& operator=(const CString& str) {return operator=(str.GetString());} - #endif // _MFC_VER +std::string MPT_PRINTF_FUNC(1,2) Format(const char * format, ...); - // To allow easy assignment to CString in GUI side. - operator const CharT*() const {return c_str();} - // Set the string to psz, copy at most nCount characters - void SetString(const CharT* psz, const size_t nCount) - { - clear(); - Append(psz, nCount); - } +// Remove whitespace at start of string +static inline std::string LTrim(std::string str, const std::string &whitespace = " \n\r\t") +{ + std::string::size_type pos = str.find_first_not_of(whitespace); + if(pos != std::string::npos) + { + str.erase(str.begin(), str.begin() + pos); + } + return str; +} - // Appends given string to this. Stops after 'nCount' chars if null terminator - // hasn't been encountered before that. - void Append(const CharT* psz, const size_t nCount) {append(psz, nCount);} - // Difference between Append and AppendChars is that latter can be used to add - // potentially non-null terminated char array. - template <size_t N> - void AppendChars(const CharT (&arr)[N]) - { - append(arr, arr + N); - } +// Remove whitespace at end of string +static inline std::string RTrim(std::string str, const std::string &whitespace = " \n\r\t") +{ + std::string::size_type pos = str.find_last_not_of(whitespace); + if(pos != std::string::npos) + { + str.erase(str.begin() + pos + 1, str.end()); + } + return str; +} - // Formats this string, like CString::Format. - void MPT_PRINTF_FUNC(2,3) Format(const CharT* pszFormat, ...); - // Remove whitespaces at start of string - void LTrim(); - // Remove whitespaces at end of string - void RTrim(); - // Remove whitespaces at start and end of string - void Trim(); - }; +// Remove whitespace at start and end of string +static inline std::string Trim(std::string str, const std::string &whitespace = " \n\r\t") +{ + return RTrim(LTrim(str, whitespace), whitespace); } -inline std::string string_replace(std::string str, const std::string &oldStr, const std::string &newStr) +static inline std::string Replace(std::string str, const std::string &oldStr, const std::string &newStr) { std::size_t pos = 0; while((pos = str.find(oldStr, pos)) != std::string::npos) @@ -99,6 +96,12 @@ } +} // namespace String + + +} // namespace mpt + + static inline int mpt_strnicmp(const char *a, const char *b, size_t count) { #if MPT_COMPILER_MSVC Modified: trunk/OpenMPT/common/version.cpp =================================================================== --- trunk/OpenMPT/common/version.cpp 2013-05-21 15:10:38 UTC (rev 2161) +++ trunk/OpenMPT/common/version.cpp 2013-05-21 20:08:19 UTC (rev 2162) @@ -87,30 +87,29 @@ return std::string("OpenMPT ") + std::string(MPT_VERSION_STR); } -VersionNum ToNum(const char *const s) +VersionNum ToNum(const std::string &s_) { + const char *s = s_.c_str(); int v1, v2, v3, v4; sscanf(s, "%x.%x.%x.%x", &v1, &v2, &v3, &v4); return ((v1 << 24) | (v2 << 16) | (v3 << 8) | v4); } -mpt::String ToStr(const VersionNum v) +std::string ToStr(const VersionNum v) { - mpt::String strVersion; if(v == 0) { // Unknown version - strVersion = "Unknown"; + return "Unknown"; } else if((v & 0xFFFF) == 0) { // Only parts of the version number are known (e.g. when reading the version from the IT or S3M file header) - strVersion.Format("%X.%02X", (v >> 24) & 0xFF, (v >> 16) & 0xFF); + return mpt::String::Format("%X.%02X", (v >> 24) & 0xFF, (v >> 16) & 0xFF); } else { // Full version info available - strVersion.Format("%X.%02X.%02X.%02X", (v >> 24) & 0xFF, (v >> 16) & 0xFF, (v >> 8) & 0xFF, (v) & 0xFF); + return mpt::String::Format("%X.%02X.%02X.%02X", (v >> 24) & 0xFF, (v >> 16) & 0xFF, (v >> 8) & 0xFF, (v) & 0xFF); } - return strVersion; } VersionNum RemoveBuildNumber(const VersionNum num) Modified: trunk/OpenMPT/common/version.h =================================================================== --- trunk/OpenMPT/common/version.h 2013-05-21 15:10:38 UTC (rev 2161) +++ trunk/OpenMPT/common/version.h 2013-05-21 20:08:19 UTC (rev 2162) @@ -32,10 +32,10 @@ std::string GetOpenMPTVersionStr(); // e.g. "OpenMPT 1.17.02.08" // Returns numerical version value from given version string. - VersionNum ToNum(const char *const s); + VersionNum ToNum(const std::string &s); // Returns version string from given numerical version value. - mpt::String ToStr(const VersionNum v); + std::string ToStr(const VersionNum v); // Return a version without build number (the last number in the version). // The current versioning scheme uses this number only for test builds, and it should be 00 for official builds, Modified: trunk/OpenMPT/mptrack/Ctrl_pat.cpp =================================================================== --- trunk/OpenMPT/mptrack/Ctrl_pat.cpp 2013-05-21 15:10:38 UTC (rev 2161) +++ trunk/OpenMPT/mptrack/Ctrl_pat.cpp 2013-05-21 20:08:19 UTC (rev 2162) @@ -1097,7 +1097,7 @@ GetDlgItemText(IDC_EDIT_SEQUENCE_NAME, str); if (str != m_sndFile.Order.m_sName) { - m_sndFile.Order.m_sName = str; + m_sndFile.Order.m_sName = str.GetString(); m_modDoc.SetModified(); m_modDoc.UpdateAllViews(NULL, (m_sndFile.Order.GetCurrentSequenceIndex() << HINT_SHIFT_SEQUENCE) | HINT_SEQNAMES, this); } Modified: trunk/OpenMPT/mptrack/Draw_pat.cpp =================================================================== --- trunk/OpenMPT/mptrack/Draw_pat.cpp 2013-05-21 15:10:38 UTC (rev 2161) +++ trunk/OpenMPT/mptrack/Draw_pat.cpp 2013-05-21 20:08:19 UTC (rev 2162) @@ -1644,7 +1644,7 @@ if(m->instr > 0 && m->instr <= MAX_MIXPLUGINS) { CHAR sztmp[128] = ""; - StringFixer::CopyN(sztmp, pSndFile->m_MixPlugins[m->instr - 1].GetParamName(m->GetValueVolCol())); + StringFixer::CopyN(sztmp, pSndFile->m_MixPlugins[m->instr - 1].GetParamName(m->GetValueVolCol()).c_str()); if (sztmp[0]) wsprintf(s, "%d: %s", m->GetValueVolCol(), sztmp); } } else Modified: trunk/OpenMPT/mptrack/MIDIMapping.cpp =================================================================== --- trunk/OpenMPT/mptrack/MIDIMapping.cpp 2013-05-21 15:10:38 UTC (rev 2161) +++ trunk/OpenMPT/mptrack/MIDIMapping.cpp 2013-05-21 20:08:19 UTC (rev 2162) @@ -17,13 +17,11 @@ std::string CMIDIMappingDirective::ToString() const //------------------------------------------------- { - mpt::String str; char flags[4] = "000"; if(m_Active) flags[0] = '1'; if(m_CaptureMIDI) flags[1] = '1'; if(m_AllowPatternEdit) flags[2] = '1'; - str.Format("%s:%d:%x:%d:%d:%d", flags, (int)GetChannel(), (int)GetEvent(), (int)GetController(), (int)m_PluginIndex, m_Parameter); - return str; + return mpt::String::Format("%s:%d:%x:%d:%d:%d", flags, (int)GetChannel(), (int)GetEvent(), (int)GetController(), (int)m_PluginIndex, m_Parameter); } Modified: trunk/OpenMPT/mptrack/MIDIMappingDialog.cpp =================================================================== --- trunk/OpenMPT/mptrack/MIDIMappingDialog.cpp 2013-05-21 15:10:38 UTC (rev 2161) +++ trunk/OpenMPT/mptrack/MIDIMappingDialog.cpp 2013-05-21 20:08:19 UTC (rev 2162) @@ -349,7 +349,7 @@ str.AppendChar('.'); //Param name - str.Insert(80, m_rSndFile.m_MixPlugins[plugindex-1].GetParamName(s.GetParamIndex())); + str.Insert(80, m_rSndFile.m_MixPlugins[plugindex-1].GetParamName(s.GetParamIndex()).c_str()); } else str.Insert(55, "No plugin"); Modified: trunk/OpenMPT/mptrack/MPTHacks.cpp =================================================================== --- trunk/OpenMPT/mptrack/MPTHacks.cpp 2013-05-21 15:10:38 UTC (rev 2161) +++ trunk/OpenMPT/mptrack/MPTHacks.cpp 2013-05-21 20:08:19 UTC (rev 2162) @@ -124,7 +124,6 @@ } bool foundHacks = false, foundHere = false; - mpt::String message; ClearLog(); // Check for plugins @@ -183,8 +182,7 @@ // Pattern count if(m_SndFile.Patterns.GetNumPatterns() > originalSpecs->patternsMax) { - message.Format("Found too many patterns (%d allowed)", originalSpecs->patternsMax); - AddToLog(message); + AddToLog(mpt::String::Format("Found too many patterns (%d allowed)", originalSpecs->patternsMax)); foundHacks = true; // REQUIRES (INTELLIGENT) AUTOFIX } @@ -222,8 +220,7 @@ } if(foundHere) { - message.Format("Found incompatible pattern lengths (must be between %d and %d rows)", originalSpecs->patternRowsMin, originalSpecs->patternRowsMax); - AddToLog(message); + AddToLog(mpt::String::Format("Found incompatible pattern lengths (must be between %d and %d rows)", originalSpecs->patternRowsMin, originalSpecs->patternRowsMax)); } // Check for invalid pattern commands @@ -252,8 +249,7 @@ // Check for too many channels if(m_SndFile.GetNumChannels() > originalSpecs->channelsMax || m_SndFile.GetNumChannels() < originalSpecs->channelsMin) { - message.Format("Found incompatible channel count (must be between %d and %d channels)", originalSpecs->channelsMin, originalSpecs->channelsMax); - AddToLog(message); + AddToLog(mpt::String::Format("Found incompatible channel count (must be between %d and %d channels)", originalSpecs->channelsMin, originalSpecs->channelsMax)); foundHacks = true; if(autofix) { @@ -283,8 +279,7 @@ // Check for too many samples if(m_SndFile.GetNumSamples() > originalSpecs->samplesMax) { - message.Format("Found too many samples (%d allowed)", originalSpecs->samplesMax); - AddToLog(message); + AddToLog(mpt::String::Format("Found too many samples (%d allowed)", originalSpecs->samplesMax)); foundHacks = true; // REQUIRES (INTELLIGENT) AUTOFIX } @@ -312,8 +307,7 @@ // Check for too many instruments if(m_SndFile.GetNumInstruments() > originalSpecs->instrumentsMax) { - message.Format("Found too many instruments (%d allowed)", originalSpecs->instrumentsMax); - AddToLog(message); + AddToLog(mpt::String::Format("Found too many instruments (%d allowed)", originalSpecs->instrumentsMax)); foundHacks = true; // REQUIRES (INTELLIGENT) AUTOFIX } @@ -363,8 +357,7 @@ // Check for too many orders if(m_SndFile.Order.GetLengthTailTrimmed() > originalSpecs->ordersMax) { - message.Format("Found too many orders (%d allowed)", originalSpecs->ordersMax); - AddToLog(message); + AddToLog(mpt::String::Format("Found too many orders (%d allowed)", originalSpecs->ordersMax)); foundHacks = true; // REQUIRES (INTELLIGENT) AUTOFIX } @@ -372,8 +365,7 @@ // Check for invalid default tempo if(m_SndFile.m_nDefaultTempo > originalSpecs->tempoMax || m_SndFile.m_nDefaultTempo < originalSpecs->tempoMin) { - message.Format("Found incompatible default tempo (must be between %d and %d)", originalSpecs->tempoMin, originalSpecs->tempoMax); - AddToLog(message); + AddToLog(mpt::String::Format("Found incompatible default tempo (must be between %d and %d)", originalSpecs->tempoMin, originalSpecs->tempoMax)); foundHacks = true; if(autofix) m_SndFile.m_nDefaultTempo = CLAMP(m_SndFile.m_nDefaultTempo, originalSpecs->tempoMin, originalSpecs->tempoMax); @@ -382,8 +374,7 @@ // Check for invalid default speed if(m_SndFile.m_nDefaultSpeed > originalSpecs->speedMax || m_SndFile.m_nDefaultSpeed < originalSpecs->speedMin) { - message.Format("Found incompatible default speed (must be between %d and %d)", originalSpecs->speedMin, originalSpecs->speedMax); - AddToLog(message); + AddToLog(mpt::String::Format("Found incompatible default speed (must be between %d and %d)", originalSpecs->speedMin, originalSpecs->speedMax)); foundHacks = true; if(autofix) m_SndFile.m_nDefaultSpeed = CLAMP(m_SndFile.m_nDefaultSpeed, originalSpecs->speedMin, originalSpecs->speedMax); Modified: trunk/OpenMPT/mptrack/Moddoc.cpp =================================================================== --- trunk/OpenMPT/mptrack/Moddoc.cpp 2013-05-21 15:10:38 UTC (rev 2161) +++ trunk/OpenMPT/mptrack/Moddoc.cpp 2013-05-21 20:08:19 UTC (rev 2162) @@ -428,7 +428,7 @@ { char s[256]; wsprintf(s, "Warning: this song was last saved with a more recent version of OpenMPT.\r\nSong saved with: v%s. Current version: v%s.\r\n", - (LPCTSTR)MptVersion::ToStr(m_SndFile.m_dwLastSavedWithVersion), + MptVersion::ToStr(m_SndFile.m_dwLastSavedWithVersion).c_str(), MptVersion::str); Reporting::Notification(s); } @@ -543,9 +543,9 @@ const bool xi = !_stricmp(&m_SndFile.m_szInstrumentPath[instr][len - 2], "xi"); if(iti || (!xi && m_SndFile.GetType() & (MOD_TYPE_IT | MOD_TYPE_MPT))) - success = m_SndFile.SaveITIInstrument(instr + 1, m_SndFile.m_szInstrumentPath[instr], false); + success = m_SndFile.SaveITIInstrument(instr + 1, m_SndFile.m_szInstrumentPath[instr].c_str(), false); else - success = m_SndFile.SaveXIInstrument(instr + 1, m_SndFile.m_szInstrumentPath[instr]); + success = m_SndFile.SaveXIInstrument(instr + 1, m_SndFile.m_szInstrumentPath[instr].c_str()); if(success) m_bsInstrumentModified.reset(instr); Modified: trunk/OpenMPT/mptrack/Mptrack.cpp =================================================================== --- trunk/OpenMPT/mptrack/Mptrack.cpp 2013-05-21 15:10:38 UTC (rev 2161) +++ trunk/OpenMPT/mptrack/Mptrack.cpp 2013-05-21 20:08:19 UTC (rev 2162) @@ -1520,9 +1520,9 @@ m_bmp.LoadBitmap(MAKEINTRESOURCE(IDB_MPTRACK)); SetDlgItemText(IDC_EDIT2, CString("Build Date: ") + MptVersion::GetBuildDateString().c_str()); SetDlgItemText(IDC_EDIT3, CString("OpenMPT ") + MptVersion::GetVersionStringExtended().c_str()); - m_heContact.SetWindowText( string_replace(MptVersion::GetContactString(), "\n", "\r\n" ).c_str()); + m_heContact.SetWindowText(mpt::String::Replace(MptVersion::GetContactString(), "\n", "\r\n" ).c_str()); m_static.SubclassDlgItem(IDC_CREDITS,this); - m_static.SetCredits((string_replace(MptVersion::GetFullCreditsString(), "\n", "|") + "||||||").c_str()); + m_static.SetCredits((mpt::String::Replace(MptVersion::GetFullCreditsString(), "\n", "|") + "||||||").c_str()); m_static.SetSpeed(DISPLAY_SLOW); m_static.SetColor(BACKGROUND_COLOR, RGB(138, 165, 219)); // Background Colour m_static.SetTransparent(); // Set parts of bitmaps with RGB(192,192,192) transparent Modified: trunk/OpenMPT/mptrack/TrackerSettings.cpp =================================================================== --- trunk/OpenMPT/mptrack/TrackerSettings.cpp 2013-05-21 15:10:38 UTC (rev 2161) +++ trunk/OpenMPT/mptrack/TrackerSettings.cpp 2013-05-21 20:08:19 UTC (rev 2162) @@ -261,7 +261,7 @@ { MptVersion::VersionNum vIniVersion; - vIniVersion = gcsPreviousVersion = MptVersion::ToNum(CMainFrame::GetPrivateProfileCString("Version", "Version", "", iniFile)); + vIniVersion = gcsPreviousVersion = MptVersion::ToNum(CMainFrame::GetPrivateProfileCString("Version", "Version", "", iniFile).GetString()); if(vIniVersion == 0) vIniVersion = MptVersion::num; @@ -532,7 +532,7 @@ // Default mod type when using the "New" button const MODTYPE oldDefault = defaultModType; - defaultModType = CModSpecifications::ExtensionToType(mpt::String(CMainFrame::GetPrivateProfileCString("Misc", "DefaultModType", CSoundFile::GetModSpecifications(defaultModType).fileExtension, iniFile))); + defaultModType = CModSpecifications::ExtensionToType(CMainFrame::GetPrivateProfileCString("Misc", "DefaultModType", CSoundFile::GetModSpecifications(defaultModType).fileExtension, iniFile).GetString()); if(defaultModType == MOD_TYPE_NONE) { defaultModType = oldDefault; Modified: trunk/OpenMPT/mptrack/TuningDialog.cpp =================================================================== --- trunk/OpenMPT/mptrack/TuningDialog.cpp 2013-05-21 15:10:38 UTC (rev 2161) +++ trunk/OpenMPT/mptrack/TuningDialog.cpp 2013-05-21 20:08:19 UTC (rev 2162) @@ -769,7 +769,7 @@ // a separate collection - no possibility to // directly replace some collection. CTuningCollection* pNewTCol = new CTuningCollection; - pNewTCol->SetSavefilePath(files.filenames[counter].c_str()); + pNewTCol->SetSavefilePath(files.filenames[counter]); if (pNewTCol->Deserialize()) { delete pNewTCol; pNewTCol = 0; Modified: trunk/OpenMPT/mptrack/Vstplug.cpp =================================================================== --- trunk/OpenMPT/mptrack/Vstplug.cpp 2013-05-21 15:10:38 UTC (rev 2161) +++ trunk/OpenMPT/mptrack/Vstplug.cpp 2013-05-21 20:08:19 UTC (rev 2162) @@ -3477,15 +3477,15 @@ #endif // NO_VST -mpt::String SNDMIXPLUGIN::GetParamName(PlugParamIndex index) const +std::string SNDMIXPLUGIN::GetParamName(PlugParamIndex index) const //------------------------------------------------------------ { CVstPlugin *vstPlug = dynamic_cast<CVstPlugin *>(pMixPlugin); if(vstPlug != nullptr) { - return vstPlug->GetParamName(index); + return vstPlug->GetParamName(index).GetString(); } else { - return mpt::String(); + return std::string(); } } \ No newline at end of file Modified: trunk/OpenMPT/mptrack/dlg_misc.cpp =================================================================== --- trunk/OpenMPT/mptrack/dlg_misc.cpp 2013-05-21 15:10:38 UTC (rev 2161) +++ trunk/OpenMPT/mptrack/dlg_misc.cpp 2013-05-21 20:08:19 UTC (rev 2162) @@ -163,7 +163,7 @@ CString CModTypeDlg::FormatVersionNumber(DWORD version) //----------------------------------------------------- { - return CString(MptVersion::ToStr(version)) + (MptVersion::IsTestBuild(version) ? " (test build)" : ""); + return std::string(MptVersion::ToStr(version) + (MptVersion::IsTestBuild(version) ? " (test build)" : "")).c_str(); } Modified: trunk/OpenMPT/mptrack/test/test.cpp =================================================================== --- trunk/OpenMPT/mptrack/test/test.cpp 2013-05-21 15:10:38 UTC (rev 2161) +++ trunk/OpenMPT/mptrack/test/test.cpp 2013-05-21 20:08:19 UTC (rev 2162) @@ -166,11 +166,11 @@ throw std::runtime_error("VerQueryValue() returned false"); } - CString version = szVer; + std::string version = szVer; delete[] pVersionInfo; //version string should be like: 1,17,2,38 Change ',' to '.' to get format 1.17.2.38 - version.Replace(',', '.'); + version = mpt::String::Replace(version, ",", "."); VERIFY_EQUAL( version, MptVersion::str ); VERIFY_EQUAL( MptVersion::ToNum(version), MptVersion::num ); Modified: trunk/OpenMPT/mptrack/view_com.cpp =================================================================== --- trunk/OpenMPT/mptrack/view_com.cpp 2013-05-21 15:10:38 UTC (rev 2161) +++ trunk/OpenMPT/mptrack/view_com.cpp 2013-05-21 20:08:19 UTC (rev 2162) @@ -428,7 +428,7 @@ case INSLIST_PATH: if (pIns) { - strncpy(s, pSndFile->m_szInstrumentPath[iIns], _MAX_PATH); + strncpy(s, pSndFile->m_szInstrumentPath[iIns].c_str(), _MAX_PATH); s[_MAX_PATH] = 0; } break; Modified: trunk/OpenMPT/soundlib/LOAD_DBM.CPP =================================================================== --- trunk/OpenMPT/soundlib/LOAD_DBM.CPP 2013-05-21 15:10:38 UTC (rev 2161) +++ trunk/OpenMPT/soundlib/LOAD_DBM.CPP 2013-05-21 20:08:19 UTC (rev 2162) @@ -223,7 +223,7 @@ nPatterns = BigEndianW(pfh->patterns); m_nType = MOD_TYPE_DBM; m_nChannels = CLAMP(BigEndianW(pfh->channels), 1, MAX_BASECHANNELS); // note: MAX_BASECHANNELS is currently 127, but DBM supports up to 128 channels. - madeWithTracker.Format("Digi Booster %x.%x", pfh->trkVerHi, pfh->trkVerLo); + madeWithTracker = mpt::String::Format("Digi Booster %x.%x", pfh->trkVerHi, pfh->trkVerLo); if(pfh->songname[0]) { Modified: trunk/OpenMPT/soundlib/Load_ams.cpp =================================================================== --- trunk/OpenMPT/soundlib/Load_ams.cpp 2013-05-21 15:10:38 UTC (rev 2161) +++ trunk/OpenMPT/soundlib/Load_ams.cpp 2013-05-21 20:08:19 UTC (rev 2162) @@ -403,7 +403,7 @@ m_nSamples = fileHeader.numSamps; SetModFlag(MSF_COMPATIBLE_PLAY, true); SetupMODPanning(true); - madeWithTracker.Format("Extreme's tracker %d.%d", fileHeader.versionHigh, fileHeader.versionLow); + madeWithTracker = mpt::String::Format("Extreme's tracker %d.%d", fileHeader.versionHigh, fileHeader.versionLow); vector<bool> packSample(fileHeader.numSamps); @@ -778,7 +778,7 @@ m_nChannels = 32; SetModFlag(MSF_COMPATIBLE_PLAY, true); SetupMODPanning(true); - madeWithTracker.Format("Velvet Studio %d.%d", fileHeader.format >> 4, fileHeader.format & 0x0F); + madeWithTracker = mpt::String::Format("Velvet Studio %d.%d", fileHeader.format >> 4, fileHeader.format & 0x0F); // Instruments vector<SAMPLEINDEX> firstSample; // First sample of instrument Modified: trunk/OpenMPT/soundlib/Load_digi.cpp =================================================================== --- trunk/OpenMPT/soundlib/Load_digi.cpp 2013-05-21 15:10:38 UTC (rev 2161) +++ trunk/OpenMPT/soundlib/Load_digi.cpp 2013-05-21 20:08:19 UTC (rev 2162) @@ -116,7 +116,7 @@ m_nChannels = fileHeader.numChannels; m_nSamples = 31; m_nSamplePreAmp = 256 / m_nChannels; - madeWithTracker.Format("Digi Booster %d.%d", fileHeader.versionInt >> 4, fileHeader.versionInt & 0x0F); + madeWithTracker = mpt::String::Format("Digi Booster %d.%d", fileHeader.versionInt >> 4, fileHeader.versionInt & 0x0F); Order.ReadFromArray(fileHeader.orders, fileHeader.lastOrdIndex + 1); Modified: trunk/OpenMPT/soundlib/Load_gdm.cpp =================================================================== --- trunk/OpenMPT/soundlib/Load_gdm.cpp 2013-05-21 15:10:38 UTC (rev 2161) +++ trunk/OpenMPT/soundlib/Load_gdm.cpp 2013-05-21 20:08:19 UTC (rev 2162) @@ -158,7 +158,7 @@ InitializeGlobals(); m_nType = gdmFormatOrigin[fileHeader.originalFormat]; - madeWithTracker.Format("BWSB 2GDM %d.%d (converted from %s)", fileHeader.trackerMajorVer, fileHeader.formatMinorVer, ModTypeToTracker(GetType()).c_str()); + madeWithTracker = mpt::String::Format("BWSB 2GDM %d.%d (converted from %s)", fileHeader.trackerMajorVer, fileHeader.formatMinorVer, ModTypeToTracker(GetType()).c_str()); // Song name StringFixer::ReadString<StringFixer::maybeNullTerminated>(m_szNames[0], fileHeader.songTitle); Modified: trunk/OpenMPT/soundlib/Load_it.cpp =================================================================== --- trunk/OpenMPT/soundlib/Load_it.cpp 2013-05-21 15:10:38 UTC (rev 2161) +++ trunk/OpenMPT/soundlib/Load_it.cpp 2013-05-21 20:08:19 UTC (rev 2162) @@ -284,11 +284,11 @@ // Get version of Schism Tracker that was used to create an IT/S3M file. -mpt::String CSoundFile::GetSchismTrackerVersion(uint16 cwtv) +std::string CSoundFile::GetSchismTrackerVersion(uint16 cwtv) //---------------------------------------------------------- { cwtv &= 0xFFF; - mpt::String version; + std::string version; if(cwtv > 0x050) { tm epoch, *verTime; @@ -297,12 +297,12 @@ time_t versionSec = ((cwtv - 0x050) * 86400) + mktime(&epoch); if((verTime = localtime(&versionSec)) != nullptr) { - version.Format("Schism Tracker %04d-%02d-%02d", + version = mpt::String::Format("Schism Tracker %04d-%02d-%02d", verTime->tm_year + 1900, verTime->tm_mon + 1, verTime->tm_mday); } } else { - version.Format("Schism Tracker 0.%x", cwtv & 0xFF); + version = mpt::String::Format("Schism Tracker 0.%x", cwtv & 0xFF); } return version; } @@ -695,9 +695,7 @@ if(numPats != patPos.size()) { // Hack: Notify user here if file contains more patterns than what can be read. - mpt::String str; - str.Format(str_PatternSetTruncationNote, patPos.size(), numPats); - AddToLog(str); + AddToLog(mpt::String::Format(str_PatternSetTruncationNote, patPos.size(), numPats)); } // Checking for number of used channels, which is not explicitely specified in the file. @@ -770,9 +768,7 @@ // Empty 64-row pattern if(Patterns.Insert(pat, 64)) { - mpt::String s; - s.Format("Allocating patterns failed starting from pattern %u", pat); - AddToLog(s); + AddToLog(mpt::String::Format("Allocating patterns failed starting from pattern %u", pat)); break; } // Now (after the Insert() call), we can read the pattern name. @@ -973,10 +969,10 @@ // Patched update of IT 2.14 (0x0215 - 0x0217 == p1 - p3) // p4 (as found on modland) adds the ITVSOUND driver, but doesn't seem to change // anything as far as file saving is concerned. - madeWithTracker.Format("Impulse Tracker 2.14p%d", fileHeader.cwtv - 0x0214); + madeWithTracker = mpt::String::Format("Impulse Tracker 2.14p%d", fileHeader.cwtv - 0x0214); } else { - madeWithTracker.Format("Impulse Tracker %d.%02x", (fileHeader.cwtv & 0x0F00) >> 8, (fileHeader.cwtv & 0xFF)); + madeWithTracker = mpt::String::Format("Impulse Tracker %d.%02x", (fileHeader.cwtv & 0x0F00) >> 8, (fileHeader.cwtv & 0xFF)); } } break; @@ -984,10 +980,10 @@ madeWithTracker = GetSchismTrackerVersion(fileHeader.cwtv); break; case 6: - madeWithTracker.Format("BeRoTracker %x.%x"); + madeWithTracker = mpt::String::Format("BeRoTracker %x.%x"); break; case 7: - madeWithTracker.Format("ITMCK %d.%d.%d", (fileHeader.cwtv >> 8) & 0x0F, (fileHeader.cwtv >> 4) & 0x0F, fileHeader.cwtv & 0x0F); + madeWithTracker = mpt::String::Format("ITMCK %d.%d.%d", (fileHeader.cwtv >> 8) & 0x0F, (fileHeader.cwtv >> 4) & 0x0F, fileHeader.cwtv & 0x0F); break; } } @@ -1539,9 +1535,7 @@ buf[len++] = 0; if(patinfo[0] > uint16_max - len) { - mpt::String str; - str.Format("%s (%s %u)", str_tooMuchPatternData, str_pattern, pat); - AddToLog(str); + AddToLog(mpt::String::Format("%s (%s %u)", str_tooMuchPatternData, str_pattern, pat)); break; } else { Modified: trunk/OpenMPT/soundlib/Load_itp.cpp =================================================================== --- trunk/OpenMPT/soundlib/Load_itp.cpp 2013-05-21 15:10:38 UTC (rev 2161) +++ trunk/OpenMPT/soundlib/Load_itp.cpp 2013-05-21 20:08:19 UTC (rev 2162) @@ -214,7 +214,7 @@ for(INSTRUMENTINDEX ins = 0; ins < GetNumInstruments(); ins++) { - if(m_szInstrumentPath[ins].empty() || !f.Open(m_szInstrumentPath[ins])) continue; + if(m_szInstrumentPath[ins].empty() || !f.Open(m_szInstrumentPath[ins].c_str())) continue; size = f.GetLength(); LPBYTE lpFile = f.Lock(size); @@ -388,7 +388,7 @@ { char path[_MAX_PATH]; MemsetZero(path); - strncpy(path, m_szInstrumentPath[i], _MAX_PATH); + strncpy(path, m_szInstrumentPath[i].c_str(), _MAX_PATH); fwrite(path, 1, _MAX_PATH, f); } Modified: trunk/OpenMPT/soundlib/Load_med.cpp =================================================================== --- trunk/OpenMPT/soundlib/Load_med.cpp 2013-05-21 15:10:38 UTC (rev 2161) +++ trunk/OpenMPT/soundlib/Load_med.cpp 2013-05-21 20:08:19 UTC (rev 2162) @@ -547,7 +547,7 @@ InitializeChannels(); // Setup channel pan positions and volume SetupMODPanning(true); - madeWithTracker.Format("OctaMED (MMD%c)", version); + madeWithTracker = mpt::String::Format("OctaMED (MMD%c)", version); m_nType = MOD_TYPE_MED; m_nSamplePreAmp = 32; Modified: trunk/OpenMPT/soundlib/Load_mt2.cpp =================================================================== --- trunk/OpenMPT/soundlib/Load_mt2.cpp 2013-05-21 15:10:38 UTC (rev 2161) +++ trunk/OpenMPT/soundlib/Load_mt2.cpp 2013-05-21 20:08:19 UTC (rev 2162) @@ -240,7 +240,7 @@ InitializeGlobals(); InitializeChannels(); - madeWithTracker.AppendChars(pfh->szTrackerName); + madeWithTracker.append(pfh->szTrackerName, CountOf(pfh->szTrackerName)); m_nType = MOD_TYPE_MT2; m_nChannels = pfh->wChannels; m_nRestartPos = pfh->wRestart; Modified: trunk/OpenMPT/soundlib/Load_mtm.cpp =================================================================== --- trunk/OpenMPT/soundlib/Load_mtm.cpp 2013-05-21 15:10:38 UTC (rev 2161) +++ trunk/OpenMPT/soundlib/Load_mtm.cpp 2013-05-21 20:08:19 UTC (rev 2162) @@ -123,7 +123,7 @@ m_nType = MOD_TYPE_MTM; m_nSamples = fileHeader.numSamples; m_nChannels = fileHeader.numChannels; - madeWithTracker.Format("MultiTracker %d.%d", fileHeader.version >> 4, fileHeader.version & 0x0F); + madeWithTracker = mpt::String::Format("MultiTracker %d.%d", fileHeader.version >> 4, fileHeader.version & 0x0F); // Reading instruments for(SAMPLEINDEX smp = 1; smp <= GetNumSamples(); smp++) Modified: trunk/OpenMPT/soundlib/Load_ptm.cpp =================================================================== --- trunk/OpenMPT/soundlib/Load_ptm.cpp 2013-05-21 15:10:38 UTC (rev 2161) +++ trunk/OpenMPT/soundlib/Load_ptm.cpp 2013-05-21 20:08:19 UTC (rev 2162) @@ -104,7 +104,7 @@ StringFixer::ReadString<StringFixer::maybeNullTerminated>(m_szNames[0], pfh.songname); InitializeGlobals(); - madeWithTracker.Format("PolyTracker %d.%d", pfh.version_hi, pfh.version_lo); + madeWithTracker = mpt::String::Format("PolyTracker %d.%d", pfh.version_hi, pfh.version_lo); m_nType = MOD_TYPE_PTM; m_nChannels = pfh.nchannels; m_nSamples = MIN(pfh.nsamples, MAX_SAMPLES - 1); Modified: trunk/OpenMPT/soundlib/Load_s3m.cpp =================================================================== --- trunk/OpenMPT/soundlib/Load_s3m.cpp 2013-05-21 15:10:38 UTC (rev 2161) +++ trunk/OpenMPT/soundlib/Load_s3m.cpp 2013-05-21 20:08:19 UTC (rev 2162) @@ -450,7 +450,7 @@ // ST3 ignored Zxx commands, so if we find that a file was made with ST3, we should erase all MIDI macros. bool keepMidiMacros = false; - mpt::String trackerName; + const char *trackerFormatStr = nullptr; switch(fileHeader.cwtv & S3MFileHeader::trackerMask) { case S3MFileHeader::trkScreamTracker: @@ -458,43 +458,46 @@ { // MPT 1.16 and older versions of OpenMPT - Simply keep default (filter) MIDI macros m_dwLastSavedWithVersion = MAKE_VERSION_NUMERIC(1, 16, 00, 00); - trackerName = "ModPlug Tracker / OpenMPT"; + madeWithTracker = "ModPlug Tracker / OpenMPT"; keepMidiMacros = true; } else if(fileHeader.special == 0 && fileHeader.ultraClicks == 0 && fileHeader.flags == 0 && fileHeader.usePanningTable == 0) { - trackerName = "Velvet Studio"; + madeWithTracker = "Velvet Studio"; } else { - trackerName = "Scream Tracker %d.%02x"; + trackerFormatStr = "Scream Tracker %d.%02x"; } break; case S3MFileHeader::trkImagoOrpheus: - trackerName = "Imago Orpheus %d.%02x"; + trackerFormatStr = "Imago Orpheus %d.%02x"; break; case S3MFileHeader::trkImpulseTracker: if(fileHeader.cwtv <= S3MFileHeader::trkIT2_14) - trackerName = "Impulse Tracker %d.%02x"; + trackerFormatStr = "Impulse Tracker %d.%02x"; else - trackerName.Format("Impulse Tracker 2.14p%d", fileHeader.cwtv - S3MFileHeader::trkIT2_14); + madeWithTracker = mpt::String::Format("Impulse Tracker 2.14p%d", fileHeader.cwtv - S3MFileHeader::trkIT2_14); break; case S3MFileHeader::trkSchismTracker: if(fileHeader.cwtv == S3MFileHeader::trkBeRoTrackerOld) - trackerName = "BeRoTracker"; + madeWithTracker = "BeRoTracker"; else - trackerName = GetSchismTrackerVersion(fileHeader.cwtv); + madeWithTracker = GetSchismTrackerVersion(fileHeader.cwtv); break; case S3MFileHeader::trkOpenMPT: - trackerName = "OpenMPT %d.%02x"; + trackerFormatStr = "OpenMPT %d.%02x"; m_dwLastSavedWithVersion = (fileHeader.cwtv & S3MFileHeader::versionMask) << 16; break; case S3MFileHeader::trkBeRoTracker: - trackerName = "BeRoTracker"; + madeWithTracker = "BeRoTracker"; break; case S3MFileHeader::trkCreamTracker: - trackerName = "CreamTracker"; + madeWithTracker = "CreamTracker"; break; } - madeWithTracker.Format(trackerName, (fileHeader.cwtv & 0xF00) >> 8, (fileHeader.cwtv & 0xFF)); + if(trackerFormatStr) + { + madeWithTracker = mpt::String::Format(trackerFormatStr, (fileHeader.cwtv & 0xF00) >> 8, (fileHeader.cwtv & 0xFF)); + } if((fileHeader.cwtv & S3MFileHeader::trackerMask) > S3MFileHeader::trkScreamTracker) { Modified: trunk/OpenMPT/soundlib/Load_stm.cpp =================================================================== --- trunk/OpenMPT/soundlib/Load_stm.cpp 2013-05-21 15:10:38 UTC (rev 2161) +++ trunk/OpenMPT/soundlib/Load_stm.cpp 2013-05-21 20:08:19 UTC (rev 2162) @@ -136,7 +136,7 @@ // Read STM header InitializeGlobals(); - madeWithTracker.Format("Scream Tracker %d.%02x", fileHeader.verMajor, fileHeader.verMinor); + madeWithTracker = mpt::String::Format("Scream Tracker %d.%02x", fileHeader.verMajor, fileHeader.verMinor); m_nType = MOD_TYPE_STM; m_nSamples = 31; m_nChannels = 4; Modified: trunk/OpenMPT/soundlib/Load_xm.cpp =================================================================== --- trunk/OpenMPT/soundlib/Load_xm.cpp 2013-05-21 15:10:38 UTC (rev 2161) +++ trunk/OpenMPT/soundlib/Load_xm.cpp 2013-05-21 20:08:19 UTC (rev 2162) @@ -302,8 +302,9 @@ { // Something else! madeWith = verUnknown |verConfirmed; - madeWithTracker.AppendChars(fileHeader.trackerName); - madeWithTracker.RTrim(); + + madeWithTracker.append(fileHeader.trackerName, CountOf(fileHeader.trackerName)); + madeWithTracker = mpt::String::RTrim(madeWithTracker); } StringFixer::ReadString<StringFixer::spacePadded>(m_szNames[0], fileHeader.songName); @@ -846,8 +847,7 @@ // Reaching the limits of file format? if(len > uint16_max) { - mpt::String str; str.Format("%s (%s %u)", str_tooMuchPatternData, str_pattern, pat); - AddToLog(str); + AddToLog(mpt::String::Format("%s (%s %u)", str_tooMuchPatternData, str_pattern, pat)); len = uint16_max; } Modified: trunk/OpenMPT/soundlib/ModSequence.cpp =================================================================== --- trunk/OpenMPT/soundlib/ModSequence.cpp 2013-05-21 15:10:38 UTC (rev 2161) +++ trunk/OpenMPT/soundlib/ModSequence.cpp 2013-05-21 20:08:19 UTC (rev 2162) @@ -767,8 +767,7 @@ srlztn::Binaryread<uint16>(iStrm, size); if(size > ModSpecs::mptm.ordersMax) { - mpt::String str; str.Format(str_SequenceTruncationNote, size, ModSpecs::mptm.ordersMax); - seq.m_sndFile.AddToLog(str); + seq.m_sndFile.AddToLog(mpt::String::Format(str_SequenceTruncationNote, size, ModSpecs::mptm.ordersMax)); size = ModSpecs::mptm.ordersMax; } seq.resize(MAX(size, MAX_ORDERS)); @@ -803,7 +802,7 @@ { srlztn::Ssb ssb(oStrm); ssb.BeginWrite(FileIdSequence, MptVersion::num); - ssb.WriteItem((const char*)seq.m_sName, "n"); + ssb.WriteItem(seq.m_sName.c_str(), "n"); const uint16 nLength = seq.GetLengthTailTrimmed(); ssb.WriteItem<uint16>(nLength, "l"); ssb.WriteItem(seq.m_pArray, "a", 1, srlztn::ArrayWriter<uint16>(nLength)); Modified: trunk/OpenMPT/soundlib/ModSequence.h =================================================================== --- trunk/OpenMPT/soundlib/ModSequence.h 2013-05-21 15:10:38 UTC (rev 2161) +++ trunk/OpenMPT/soundlib/ModSequence.h 2013-05-21 20:08:19 UTC (rev 2162) @@ -124,7 +124,7 @@ const_iterator end() const {return m_pArray + m_nSize;} public: - mpt::String m_sName; // Sequence name. + mpt::string m_sName; // Sequence name. protected: CSoundFile &m_sndFile; // Pointer to associated CSoundFile. Modified: trunk/OpenMPT/soundlib/Sndfile.cpp =================================================================== --- trunk/OpenMPT/soundlib/Sndfile.cpp 2013-05-21 15:10:38 UTC (rev 2161) +++ trunk/OpenMPT/soundlib/Sndfile.cpp 2013-05-21 20:08:19 UTC (rev 2162) @@ -1569,9 +1569,7 @@ } // Load local tunings. - mpt::String sPath; - sPath.Format("%slocal_tunings%s", TrackerSettings::Instance().GetDefaultDirectory(DIR_TUNING), CTuningCollection::s_FileExtension); - s_pTuningsSharedLocal->SetSavefilePath(sPath); + s_pTuningsSharedLocal->SetSavefilePath(mpt::String::Format("%slocal_tunings%s", TrackerSettings::Instance().GetDefaultDirectory(DIR_TUNING), CTuningCollection::s_FileExtension)); s_pTuningsSharedLocal->Deserialize(); // Enabling adding/removing of tunings for standard collection Modified: trunk/OpenMPT/soundlib/Sndfile.h =================================================================== --- trunk/OpenMPT/soundlib/Sndfile.h 2013-05-21 15:10:38 UTC (rev 2161) +++ trunk/OpenMPT/soundlib/Sndfile.h 2013-05-21 20:08:19 UTC (rev 2162) @@ -389,11 +389,11 @@ public: // Song message SongMessage songMessage; - mpt::String madeWithTracker; + std::string madeWithTracker; // -> CODE#0023 // -> DESC="IT project files (.itp)" - mpt::String m_szInstrumentPath[MAX_INSTRUMENTS]; + std::string m_szInstrumentPath[MAX_INSTRUMENTS]; // -! NEW_FEATURE#0023 bool m_bIsRendering; @@ -556,7 +556,7 @@ void LoadExtendedSongProperties(const MODTYPE modtype, FileReader &file, bool* pInterpretMptMade = nullptr); static size_t LoadModularInstrumentData(FileReader &file, ModInstrument &ins); - mpt::String GetSchismTrackerVersion(uint16 cwtv); + std::string GetSchismTrackerVersion(uint16 cwtv); // Reads extended instrument properties(XM/IT/MPTM). // If no errors occur and song extension tag is found, returns pointer to the beginning Modified: trunk/OpenMPT/soundlib/pattern.cpp =================================================================== --- trunk/OpenMPT/soundlib/pattern.cpp 2013-05-21 15:10:38 UTC (rev 2161) +++ trunk/OpenMPT/soundlib/pattern.cpp 2013-05-21 20:08:19 UTC (rev 2162) @@ -217,7 +217,7 @@ { return false; } - m_PatternName.SetString(newName, strnlen(newName, maxChars)); + m_PatternName.assign(newName, strnlen(newName, maxChars)); return true; } @@ -229,7 +229,7 @@ { return false; } - strncpy(buffer, m_PatternName, maxChars - 1); + strncpy(buffer, m_PatternName.c_str(), maxChars - 1); buffer[maxChars - 1] = '\0'; return true; } Modified: trunk/OpenMPT/soundlib/pattern.h =================================================================== --- trunk/OpenMPT/soundlib/pattern.h 2013-05-21 15:10:38 UTC (rev 2161) +++ trunk/OpenMPT/soundlib/pattern.h 2013-05-21 20:08:19 UTC (rev 2162) @@ -102,7 +102,7 @@ return GetName(buffer, bufferSize); } bool GetName(char *buffer, size_t maxChars) const; - const mpt::String& GetName() const { return m_PatternName; }; + mpt::string GetName() const { return m_PatternName; }; // Double number of rows bool Expand(); @@ -146,7 +146,7 @@ ROWINDEX m_Rows; ROWINDEX m_RowsPerBeat; // patterns-specific time signature. if != 0, this is implicitely set. ROWINDEX m_RowsPerMeasure; // dito - mpt::String m_PatternName; + std::string m_PatternName; CPatternContainer& m_rPatternContainer; //END: DATA }; Modified: trunk/OpenMPT/soundlib/plugins/PlugInterface.h =================================================================== --- trunk/OpenMPT/soundlib/plugins/PlugInterface.h 2013-05-21 15:10:38 UTC (rev 2161) +++ trunk/OpenMPT/soundlib/plugins/PlugInterface.h 2013-05-21 20:08:19 UTC (rev 2162) @@ -160,7 +160,7 @@ { return Info.szName; } const char *GetLibraryName() const { return Info.szLibraryName; } - mpt::String GetParamName(PlugParamIndex index) const; + std::string GetParamName(PlugParamIndex index) const; // Check if a plugin is loaded into this slot (also returns true if the plugin in this slot has not been found) bool IsValidPlugin() const { return (Info.dwPluginId1 | Info.dwPluginId2) != 0; }; Modified: trunk/OpenMPT/soundlib/tuningcollection.h =================================================================== --- trunk/OpenMPT/soundlib/tuningcollection.h 2013-05-21 15:10:38 UTC (rev 2161) +++ trunk/OpenMPT/soundlib/tuningcollection.h 2013-05-21 20:08:19 UTC (rev 2162) @@ -94,7 +94,7 @@ const string& GetName() const {return m_Name;} - void SetSavefilePath(LPCTSTR psz) {m_SavefilePath = psz;} + void SetSavefilePath(const std::string &psz) {m_SavefilePath = psz;} const string& GetSaveFilePath() const {return m_SavefilePath;} string GetVersionString() const {return Stringify(static_cast<int>(s_SerializationVersion));} This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <man...@us...> - 2013-05-21 21:18:41
|
Revision: 2164 http://sourceforge.net/p/modplug/code/2164 Author: manxorist Date: 2013-05-21 21:18:34 +0000 (Tue, 21 May 2013) Log Message: ----------- [Ref] Use std::string for GetTitle() and SetTitle() in CSoundFile. Modified Paths: -------------- trunk/OpenMPT/mptrack/CloseMainDialog.cpp trunk/OpenMPT/mptrack/Ctrl_gen.cpp trunk/OpenMPT/mptrack/mod2midi.cpp trunk/OpenMPT/soundlib/Sndfile.cpp trunk/OpenMPT/soundlib/Sndfile.h Modified: trunk/OpenMPT/mptrack/CloseMainDialog.cpp =================================================================== --- trunk/OpenMPT/mptrack/CloseMainDialog.cpp 2013-05-21 20:20:37 UTC (rev 2163) +++ trunk/OpenMPT/mptrack/CloseMainDialog.cpp 2013-05-21 21:18:34 UTC (rev 2164) @@ -37,7 +37,7 @@ //------------------------------------------------------------------------- { const CString &path = (!fullPath || pModDoc->GetPathName().IsEmpty()) ? pModDoc->GetTitle() : pModDoc->GetPathName(); - return pModDoc->GetrSoundFile().GetTitle() + CString(" (") + path + CString(")"); + return CString(pModDoc->GetrSoundFile().GetTitle().c_str()) + CString(" (") + path + CString(")"); } Modified: trunk/OpenMPT/mptrack/Ctrl_gen.cpp =================================================================== --- trunk/OpenMPT/mptrack/Ctrl_gen.cpp 2013-05-21 20:20:37 UTC (rev 2163) +++ trunk/OpenMPT/mptrack/Ctrl_gen.cpp 2013-05-21 21:18:34 UTC (rev 2164) @@ -325,7 +325,7 @@ CString title; m_EditTitle.GetWindowText(title); - if(m_sndFile.SetTitle(title, title.GetLength())) + if(m_sndFile.SetTitle(title.GetString())) { m_EditTitle.SetModify(FALSE); m_modDoc.SetModified(); Modified: trunk/OpenMPT/mptrack/mod2midi.cpp =================================================================== --- trunk/OpenMPT/mptrack/mod2midi.cpp 2013-05-21 20:20:37 UTC (rev 2163) +++ trunk/OpenMPT/mptrack/mod2midi.cpp 2013-05-21 21:18:34 UTC (rev 2164) @@ -394,13 +394,13 @@ f.Write(&mthd, sizeof(mthd)); // Add Song Name on track 0 - const CHAR *modTitle = m_pSndFile->GetTitle(); + const std::string modTitle = m_pSndFile->GetTitle(); if (modTitle[0]) { tmp[0] = 0; tmp[1] = 0xff; tmp[2] = 0x01; Tracks[0].Write(tmp, 3); - Tracks[0].WriteLen(strlen(modTitle)); - Tracks[0].Write(modTitle, strlen(modTitle)); + Tracks[0].WriteLen(modTitle.length()); + Tracks[0].Write(modTitle.c_str(), modTitle.length()); } // Add Song comments on track 0 Modified: trunk/OpenMPT/soundlib/Sndfile.cpp =================================================================== --- trunk/OpenMPT/soundlib/Sndfile.cpp 2013-05-21 20:20:37 UTC (rev 2163) +++ trunk/OpenMPT/soundlib/Sndfile.cpp 2013-05-21 21:18:34 UTC (rev 2164) @@ -1663,12 +1663,12 @@ } -bool CSoundFile::SetTitle(const char *titleCandidate, size_t strSize) -//------------------------------------------------------------------- +bool CSoundFile::SetTitle(const std::string & newTitle) +//----------------------------------------------------- { - if(strcmp(m_szNames[0], titleCandidate)) + if(m_szNames[0] != newTitle) { - StringFixer::CopyN(m_szNames[0], titleCandidate, strSize); + StringFixer::CopyN(m_szNames[0], &newTitle[0], newTitle.length()); return true; } return false; Modified: trunk/OpenMPT/soundlib/Sndfile.h =================================================================== --- trunk/OpenMPT/soundlib/Sndfile.h 2013-05-21 20:20:37 UTC (rev 2163) +++ trunk/OpenMPT/soundlib/Sndfile.h 2013-05-21 21:18:34 UTC (rev 2164) @@ -192,9 +192,6 @@ class CSoundFile //============== { -public: - //Return true if title was changed. - bool SetTitle(const char*, size_t strSize); public: //Misc void ChangeModTypeTo(const MODTYPE& newType); @@ -464,7 +461,8 @@ void DontLoopPattern(PATTERNINDEX nPat, ROWINDEX nRow = 0); //rewbs.playSongFromCursor void SetCurrentPos(UINT nPos); void SetCurrentOrder(ORDERINDEX nOrder); - LPCSTR GetTitle() const { return m_szNames[0]; } + std::string GetTitle() const { return m_szNames[0]; } + bool SetTitle(const std::string &newTitle); // Return true if title was changed. LPCTSTR GetSampleName(UINT nSample) const; const char *GetInstrumentName(INSTRUMENTINDEX nInstr) const; UINT GetMusicSpeed() const { return m_nMusicSpeed; } This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <man...@us...> - 2013-05-21 23:01:06
|
Revision: 2168 http://sourceforge.net/p/modplug/code/2168 Author: manxorist Date: 2013-05-21 23:01:00 +0000 (Tue, 21 May 2013) Log Message: ----------- [Ref] Remove all usages of win32 specific wsprintf in soundlib/ and common/. For non-plugin builds, libopenmpt does not need to link against user32.dll anymore. Modified Paths: -------------- trunk/OpenMPT/common/Profiler.cpp trunk/OpenMPT/common/serialization_utils.cpp trunk/OpenMPT/common/typedefs.h trunk/OpenMPT/soundlib/Dlsbank.cpp trunk/OpenMPT/soundlib/ModSequence.cpp trunk/OpenMPT/soundlib/load_j2b.cpp Modified: trunk/OpenMPT/common/Profiler.cpp =================================================================== --- trunk/OpenMPT/common/Profiler.cpp 2013-05-21 22:56:04 UTC (rev 2167) +++ trunk/OpenMPT/common/Profiler.cpp 2013-05-21 23:01:00 UTC (rev 2168) @@ -110,9 +110,7 @@ case Profiler::Audio: cat = "Audio"; break; case Profiler::Notify: cat = "Notify"; break; } - char dummy[128]; - sprintf(dummy, "%6.3f", (stats.usage * 100.0)); - ret += cat + " " + std::string(stats.profile.Name) + ": " + std::string(dummy) + "%\r\n"; + ret += cat + " " + std::string(stats.profile.Name) + ": " + mpt::String::Format("%6.3f", (stats.usage * 100.0)) + "%\r\n"; } } ret += "\r\n"; Modified: trunk/OpenMPT/common/serialization_utils.cpp =================================================================== --- trunk/OpenMPT/common/serialization_utils.cpp 2013-05-21 22:56:04 UTC (rev 2167) +++ trunk/OpenMPT/common/serialization_utils.cpp 2013-05-21 23:01:00 UTC (rev 2168) @@ -296,15 +296,13 @@ if ((m_Readlogmask & SNT_PROGRESS) != 0 && m_fpLogFunc) { - TCHAR buffer[256]; - wsprintf(buffer, + m_fpLogFunc( tstrReadProgress, nNum, (pRe && pRe->nIdLength < 30 && m_Idarray.size() > 0) ? IdToString(&m_Idarray[pRe->nIdpos], pRe->nIdLength).c_str() : "", (pRe) ? pRe->rposStart : 0, (pRe && pRe->nSize != invalidDatasize) ? Stringify(pRe->nSize).c_str() : "", ""); - m_fpLogFunc(buffer); } } @@ -318,9 +316,7 @@ { if (nIdSize < 30) { - TCHAR buffer[256]; - wsprintf(buffer, tstrWriteProgress, nEntryNum, IdToString(pId, nIdSize).c_str(), rposStart, nBytecount); - m_fpLogFunc(buffer); + m_fpLogFunc(tstrWriteProgress, nEntryNum, IdToString(pId, nIdSize).c_str(), rposStart, nBytecount); } } } Modified: trunk/OpenMPT/common/typedefs.h =================================================================== --- trunk/OpenMPT/common/typedefs.h 2013-05-21 22:56:04 UTC (rev 2167) +++ trunk/OpenMPT/common/typedefs.h 2013-05-21 23:01:00 UTC (rev 2168) @@ -269,9 +269,6 @@ #define MPT_TEXT(x) x -// wsprintf is just sprintf, but defined in the WINDOWS API -#define wsprintf sprintf - #endif // _WIN32 Modified: trunk/OpenMPT/soundlib/Dlsbank.cpp =================================================================== --- trunk/OpenMPT/soundlib/Dlsbank.cpp 2013-05-21 22:56:04 UTC (rev 2167) +++ trunk/OpenMPT/soundlib/Dlsbank.cpp 2013-05-21 23:01:00 UTC (rev 2168) @@ -1722,7 +1722,7 @@ if ((key >= 24) && (key <= 84)) lstrcpy(s, szMidiPercussionNames[key-24]); if (pDlsIns->szName[0]) { - wsprintf(&s[strlen(s)], " (%s", pDlsIns->szName); + sprintf(&s[strlen(s)], " (%s", pDlsIns->szName); int n = strlen(s); while ((n) && (s[n-1] == ' ')) { Modified: trunk/OpenMPT/soundlib/ModSequence.cpp =================================================================== --- trunk/OpenMPT/soundlib/ModSequence.cpp 2013-05-21 22:56:04 UTC (rev 2167) +++ trunk/OpenMPT/soundlib/ModSequence.cpp 2013-05-21 23:01:00 UTC (rev 2168) @@ -582,7 +582,6 @@ if(GetNumSequences() <= 1) return false; - char s[256]; SetSequence(0); resize(GetLengthTailTrimmed()); SEQUENCEINDEX removedSequences = 0; // sequence count @@ -602,8 +601,7 @@ const ORDERINDEX nFirstOrder = GetLengthTailTrimmed() + 1; // +1 for separator item if(nFirstOrder + GetSequence(1).GetLengthTailTrimmed() > m_sndFile.GetModSpecifications().ordersMax) { - wsprintf(s, "WARNING: Cannot merge Sequence %d (too long!)", removedSequences); - m_sndFile.AddToLog(s); + m_sndFile.AddToLog(mpt::String::Format("WARNING: Cannot merge Sequence %d (too long!)", removedSequences)); RemoveSequence(1); continue; } @@ -638,8 +636,7 @@ } else { // cannot create new pattern: notify the user - wsprintf(s, "CONFLICT: Pattern break commands in Pattern %d might be broken since it has been used in several sequences!", nPat); - m_sndFile.AddToLog(s); + m_sndFile.AddToLog(mpt::String::Format("CONFLICT: Pattern break commands in Pattern %d might be broken since it has been used in several sequences!", nPat)); } } m->param = static_cast<BYTE>(m->param + nFirstOrder); Modified: trunk/OpenMPT/soundlib/load_j2b.cpp =================================================================== --- trunk/OpenMPT/soundlib/load_j2b.cpp 2013-05-21 22:56:04 UTC (rev 2167) +++ trunk/OpenMPT/soundlib/load_j2b.cpp 2013-05-21 23:01:00 UTC (rev 2168) @@ -647,9 +647,7 @@ } else { #ifdef DEBUG - CHAR s[64]; - wsprintf(s, "J2B: Unknown command: 0x%X, param 0x%X", m.command, m.param); - Log(s); + Log("J2B: Unknown command: 0x%X, param 0x%X", m.command, m.param); #endif // DEBUG m.command = CMD_NONE; } This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <man...@us...> - 2013-05-21 23:42:47
|
Revision: 2169 http://sourceforge.net/p/modplug/code/2169 Author: manxorist Date: 2013-05-21 23:42:33 +0000 (Tue, 21 May 2013) Log Message: ----------- [Ref] Move stuff from namespace StringFixer into namespace mpt::String. (Just rename things, this changeset does nothing else) Modified Paths: -------------- trunk/OpenMPT/common/StringFixer.h trunk/OpenMPT/mptrack/AbstractVstEditor.cpp trunk/OpenMPT/mptrack/CleanupSong.cpp trunk/OpenMPT/mptrack/Ctrl_ins.cpp trunk/OpenMPT/mptrack/Ctrl_pat.cpp trunk/OpenMPT/mptrack/Ctrl_smp.cpp trunk/OpenMPT/mptrack/Draw_pat.cpp trunk/OpenMPT/mptrack/MIDIMacroDialog.cpp trunk/OpenMPT/mptrack/Moddoc.cpp trunk/OpenMPT/mptrack/Modedit.cpp trunk/OpenMPT/mptrack/Mptrack.cpp trunk/OpenMPT/mptrack/SelectPluginDialog.cpp trunk/OpenMPT/mptrack/TrackerSettings.cpp trunk/OpenMPT/mptrack/Undo.cpp trunk/OpenMPT/mptrack/View_gen.cpp trunk/OpenMPT/mptrack/View_tre.cpp trunk/OpenMPT/mptrack/VstPresets.cpp trunk/OpenMPT/mptrack/Vstplug.cpp trunk/OpenMPT/mptrack/Vstplug.h trunk/OpenMPT/mptrack/dlg_misc.cpp trunk/OpenMPT/mptrack/mod2midi.cpp trunk/OpenMPT/mptrack/test/test.cpp trunk/OpenMPT/mptrack/view_com.cpp trunk/OpenMPT/soundlib/Dlsbank.cpp trunk/OpenMPT/soundlib/FileReader.h trunk/OpenMPT/soundlib/ITTools.cpp trunk/OpenMPT/soundlib/LOAD_AMF.CPP trunk/OpenMPT/soundlib/LOAD_DBM.CPP trunk/OpenMPT/soundlib/LOAD_DMF.CPP trunk/OpenMPT/soundlib/LOAD_DSM.CPP trunk/OpenMPT/soundlib/Load_669.cpp trunk/OpenMPT/soundlib/Load_ams.cpp trunk/OpenMPT/soundlib/Load_digi.cpp trunk/OpenMPT/soundlib/Load_far.cpp trunk/OpenMPT/soundlib/Load_gdm.cpp trunk/OpenMPT/soundlib/Load_imf.cpp trunk/OpenMPT/soundlib/Load_it.cpp trunk/OpenMPT/soundlib/Load_itp.cpp trunk/OpenMPT/soundlib/Load_mdl.cpp trunk/OpenMPT/soundlib/Load_med.cpp trunk/OpenMPT/soundlib/Load_mod.cpp trunk/OpenMPT/soundlib/Load_mt2.cpp trunk/OpenMPT/soundlib/Load_mtm.cpp trunk/OpenMPT/soundlib/Load_okt.cpp trunk/OpenMPT/soundlib/Load_psm.cpp trunk/OpenMPT/soundlib/Load_ptm.cpp trunk/OpenMPT/soundlib/Load_s3m.cpp trunk/OpenMPT/soundlib/Load_stm.cpp trunk/OpenMPT/soundlib/Load_ult.cpp trunk/OpenMPT/soundlib/Load_umx.cpp trunk/OpenMPT/soundlib/Load_xm.cpp trunk/OpenMPT/soundlib/MIDIMacros.cpp trunk/OpenMPT/soundlib/SampleFormats.cpp trunk/OpenMPT/soundlib/Sndfile.cpp trunk/OpenMPT/soundlib/WAVTools.cpp trunk/OpenMPT/soundlib/XMTools.cpp trunk/OpenMPT/soundlib/load_j2b.cpp Modified: trunk/OpenMPT/common/StringFixer.h =================================================================== --- trunk/OpenMPT/common/StringFixer.h 2013-05-21 23:01:00 UTC (rev 2168) +++ trunk/OpenMPT/common/StringFixer.h 2013-05-21 23:42:33 UTC (rev 2169) @@ -13,7 +13,7 @@ #include <string.h> -namespace StringFixer +namespace mpt { namespace String { // Sets last character to null in given char array. @@ -69,7 +69,7 @@ // Used for reading strings from files. // Only use this version of the function if the size of the source buffer is variable. template <ReadWriteMode mode, size_t destSize> - void ReadString(char (&destBuffer)[destSize], const char *srcBuffer, const size_t srcSize) + void Read(char (&destBuffer)[destSize], const char *srcBuffer, const size_t srcSize) //---------------------------------------------------------------------------------------- { STATIC_ASSERT(destSize > 0); @@ -152,12 +152,12 @@ // Used for reading strings from files. // Preferrably use this version of the function, it is safer. template <ReadWriteMode mode, size_t destSize, size_t srcSize> - void ReadString(char (&destBuffer)[destSize], const char (&srcBuffer)[srcSize]) + void Read(char (&destBuffer)[destSize], const char (&srcBuffer)[srcSize]) //----------------------------------------------------------------------------- { STATIC_ASSERT(destSize > 0); STATIC_ASSERT(srcSize > 0); - ReadString<mode, destSize>(destBuffer, srcBuffer, srcSize); + Read<mode, destSize>(destBuffer, srcBuffer, srcSize); } @@ -165,7 +165,7 @@ // Used for writing strings to files. // Only use this version of the function if the size of the source buffer is variable. template <ReadWriteMode mode, size_t destSize> - void WriteString(char (&destBuffer)[destSize], const char *srcBuffer, const size_t srcSize) + void Write(char (&destBuffer)[destSize], const char *srcBuffer, const size_t srcSize) //----------------------------------------------------------------------------------------- { STATIC_ASSERT(destSize > 0); @@ -209,12 +209,12 @@ // Used for writing strings to files. // Preferrably use this version of the function, it is safer. template <ReadWriteMode mode, size_t destSize, size_t srcSize> - void WriteString(char (&destBuffer)[destSize], const char (&srcBuffer)[srcSize]) + void Write(char (&destBuffer)[destSize], const char (&srcBuffer)[srcSize]) //------------------------------------------------------------------------------ { STATIC_ASSERT(destSize > 0); STATIC_ASSERT(srcSize > 0); - WriteString<mode, destSize>(destBuffer, srcBuffer, srcSize); + Write<mode, destSize>(destBuffer, srcBuffer, srcSize); } @@ -236,5 +236,6 @@ CopyN(destBuffer, srcBuffer, srcSize); } -}; +} } // namespace mpt::String + Modified: trunk/OpenMPT/mptrack/AbstractVstEditor.cpp =================================================================== --- trunk/OpenMPT/mptrack/AbstractVstEditor.cpp 2013-05-21 23:01:00 UTC (rev 2168) +++ trunk/OpenMPT/mptrack/AbstractVstEditor.cpp 2013-05-21 23:42:33 UTC (rev 2169) @@ -864,7 +864,7 @@ m_nInstrument = nIns; _snprintf(pIns->name, CountOf(pIns->name) - 1, _T("%d: %s"), m_VstPlugin.GetSlot() + 1, sndFile.m_MixPlugins[m_VstPlugin.GetSlot()].GetName()); - StringFixer::CopyN(pIns->filename, sndFile.m_MixPlugins[m_VstPlugin.GetSlot()].GetLibraryName()); + mpt::String::CopyN(pIns->filename, sndFile.m_MixPlugins[m_VstPlugin.GetSlot()].GetLibraryName()); pIns->nMixPlug = (PLUGINDEX)m_VstPlugin.GetSlot() + 1; pIns->nMidiChannel = 1; // People will forget to change this anyway, so the following lines can lead to some bad surprises after re-opening the module. Modified: trunk/OpenMPT/mptrack/CleanupSong.cpp =================================================================== --- trunk/OpenMPT/mptrack/CleanupSong.cpp 2013-05-21 23:01:00 UTC (rev 2168) +++ trunk/OpenMPT/mptrack/CleanupSong.cpp 2013-05-21 23:42:33 UTC (rev 2169) @@ -328,7 +328,7 @@ { //strncpy_s(pTTTA->szText, sizeof(pTTTA->szText), strTipText, // strTipText.GetLength() + 1); - StringFixer::CopyN(pTTTA->szText, strTipText); + mpt::String::CopyN(pTTTA->szText, strTipText); } else { Modified: trunk/OpenMPT/mptrack/Ctrl_ins.cpp =================================================================== --- trunk/OpenMPT/mptrack/Ctrl_ins.cpp 2013-05-21 23:01:00 UTC (rev 2168) +++ trunk/OpenMPT/mptrack/Ctrl_ins.cpp 2013-05-21 23:42:33 UTC (rev 2169) @@ -1446,12 +1446,12 @@ if (!pIns->name[0] && m_sndFile.GetModSpecifications().instrNameLengthMax > 0) { - StringFixer::CopyN(pIns->name, szName, m_sndFile.GetModSpecifications().instrNameLengthMax); + mpt::String::CopyN(pIns->name, szName, m_sndFile.GetModSpecifications().instrNameLengthMax); } if (!pIns->filename[0] && m_sndFile.GetModSpecifications().instrFilenameLengthMax > 0) { strcat(szName, szExt); - StringFixer::CopyN(pIns->filename, szName, m_sndFile.GetModSpecifications().instrFilenameLengthMax); + mpt::String::CopyN(pIns->filename, szName, m_sndFile.GetModSpecifications().instrFilenameLengthMax); } SetCurrentInstrument(m_nInstrument); @@ -1730,10 +1730,10 @@ if (!pIns) return; if (pIns->filename[0]) { - StringFixer::Copy(szFileName, pIns->filename); + mpt::String::Copy(szFileName, pIns->filename); } else { - StringFixer::Copy(szFileName, pIns->name); + mpt::String::Copy(szFileName, pIns->name); } SanitizeFilename(szFileName); @@ -1807,7 +1807,7 @@ ModInstrument *pIns = m_sndFile.Instruments[m_nInstrument]; if ((pIns) && (strncmp(s, pIns->name, MAX_INSTRUMENTNAME))) { - StringFixer::Copy(pIns->name, s); + mpt::String::Copy(pIns->name, s); SetInstrumentModified(true); } } Modified: trunk/OpenMPT/mptrack/Ctrl_pat.cpp =================================================================== --- trunk/OpenMPT/mptrack/Ctrl_pat.cpp 2013-05-21 23:01:00 UTC (rev 2168) +++ trunk/OpenMPT/mptrack/Ctrl_pat.cpp 2013-05-21 23:42:33 UTC (rev 2169) @@ -1076,7 +1076,7 @@ CHAR s[MAX_PATTERNNAME]; m_EditPatName.GetWindowText(s, CountOf(s)); - StringFixer::SetNullTerminator(s); + mpt::String::SetNullTerminator(s); if(m_sndFile.Patterns[nPat].GetName() != s) { Modified: trunk/OpenMPT/mptrack/Ctrl_smp.cpp =================================================================== --- trunk/OpenMPT/mptrack/Ctrl_smp.cpp 2013-05-21 23:01:00 UTC (rev 2168) +++ trunk/OpenMPT/mptrack/Ctrl_smp.cpp 2013-05-21 23:42:33 UTC (rev 2169) @@ -658,10 +658,10 @@ wsprintf(s, "%d-bit %s, len: %d", sample.GetElementarySampleSize() * 8, (sample.uFlags & CHN_STEREO) ? "stereo" : "mono", sample.nLength); SetDlgItemText(IDC_TEXT5, s); // Name - StringFixer::Copy(s, m_sndFile.m_szNames[m_nSample]); + mpt::String::Copy(s, m_sndFile.m_szNames[m_nSample]); SetDlgItemText(IDC_SAMPLE_NAME, s); // File Name - StringFixer::Copy(s, sample.filename); + mpt::String::Copy(s, sample.filename); if (m_sndFile.GetType() & (MOD_TYPE_MOD | MOD_TYPE_XM)) s[0] = 0; SetDlgItemText(IDC_SAMPLE_FILENAME, s); // Volume @@ -836,10 +836,10 @@ { // S3M/IT szFullFilename[31] = 0; - if (!m_sndFile.m_szNames[m_nSample][0]) StringFixer::Copy(m_sndFile.m_szNames[m_nSample], szFullFilename); + if (!m_sndFile.m_szNames[m_nSample][0]) mpt::String::Copy(m_sndFile.m_szNames[m_nSample], szFullFilename); if (strlen(szFullFilename) < 9) strcat(szFullFilename, szExt); } - StringFixer::Copy(sample.filename, szFullFilename); + mpt::String::Copy(sample.filename, szFullFilename); } if ((m_sndFile.GetType() & MOD_TYPE_XM) && (!(sample.uFlags & CHN_PANNING))) { @@ -1011,11 +1011,11 @@ } if(m_sndFile.GetType() & (MOD_TYPE_S3M|MOD_TYPE_IT|MOD_TYPE_MPT)) { - StringFixer::Copy(szFileName, m_sndFile.GetSample(m_nSample).filename); + mpt::String::Copy(szFileName, m_sndFile.GetSample(m_nSample).filename); } if(!szFileName[0]) { - StringFixer::Copy(szFileName, m_sndFile.m_szNames[m_nSample]); + mpt::String::Copy(szFileName, m_sndFile.m_szNames[m_nSample]); } if(!szFileName[0]) strcpy(szFileName, "untitled"); if(strlen(szFileName) >= 5 && !_strcmpi(szFileName + strlen(szFileName) - 5, ".flac")) @@ -1036,7 +1036,7 @@ sPath += ".wav"; _splitpath(sPath, NULL, NULL, szFileName, NULL); } - StringFixer::SetNullTerminator(szFileName); + mpt::String::SetNullTerminator(szFileName); SanitizeFilename(szFileName); CString format = CMainFrame::GetPrivateProfileCString("Sample Editor", "DefaultFormat", defaultFLAC ? "flac" : "wav", theApp.GetConfigFileName()); @@ -2331,7 +2331,7 @@ s[31] = 0; if (strncmp(s, m_sndFile.m_szNames[m_nSample], MAX_SAMPLENAME)) { - StringFixer::Copy(m_sndFile.m_szNames[m_nSample], s); + mpt::String::Copy(m_sndFile.m_szNames[m_nSample], s); m_modDoc.UpdateAllViews(NULL, (m_nSample << HINT_SHIFT_SMP) | (HINT_SMPNAMES|HINT_SAMPLEINFO), this); m_modDoc.UpdateAllViews(NULL, HINT_INSNAMES, this); m_modDoc.SetModified(); @@ -2347,11 +2347,11 @@ if(IsLocked()) return; s[0] = 0; m_EditFileName.GetWindowText(s, sizeof(s)); - StringFixer::SetNullTerminator(s); + mpt::String::SetNullTerminator(s); if (strncmp(s, m_sndFile.GetSample(m_nSample).filename, MAX_SAMPLEFILENAME)) { - StringFixer::Copy(m_sndFile.GetSample(m_nSample).filename, s); + mpt::String::Copy(m_sndFile.GetSample(m_nSample).filename, s); m_modDoc.UpdateAllViews(NULL, (m_nSample << HINT_SHIFT_SMP) | HINT_SAMPLEINFO, this); if (m_sndFile.m_nType & (MOD_TYPE_S3M|MOD_TYPE_IT|MOD_TYPE_MPT)) m_modDoc.SetModified(); } Modified: trunk/OpenMPT/mptrack/Draw_pat.cpp =================================================================== --- trunk/OpenMPT/mptrack/Draw_pat.cpp 2013-05-21 23:01:00 UTC (rev 2168) +++ trunk/OpenMPT/mptrack/Draw_pat.cpp 2013-05-21 23:42:33 UTC (rev 2169) @@ -1599,7 +1599,7 @@ // display plugin name. if(m->instr <= MAX_MIXPLUGINS) { - StringFixer::CopyN(sztmp, pSndFile->m_MixPlugins[m->instr - 1].GetName()); + mpt::String::CopyN(sztmp, pSndFile->m_MixPlugins[m->instr - 1].GetName()); } } else { @@ -1609,7 +1609,7 @@ if ((m->instr <= pSndFile->GetNumInstruments()) && (pSndFile->Instruments[m->instr])) { ModInstrument *pIns = pSndFile->Instruments[m->instr]; - StringFixer::Copy(sztmp, pIns->name); + mpt::String::Copy(sztmp, pIns->name); if ((m->note) && (m->note <= NOTE_MAX)) { const SAMPLEINDEX nsmp = pIns->Keyboard[m->note - 1]; @@ -1626,12 +1626,12 @@ { if (m->instr <= pSndFile->GetNumSamples()) { - StringFixer::Copy(sztmp, pSndFile->m_szNames[m->instr]); + mpt::String::Copy(sztmp, pSndFile->m_szNames[m->instr]); } } } - StringFixer::SetNullTerminator(sztmp); + mpt::String::SetNullTerminator(sztmp); if (sztmp[0]) wsprintf(s, "%d: %s", m->instr, sztmp); } break; @@ -1644,7 +1644,7 @@ if(m->instr > 0 && m->instr <= MAX_MIXPLUGINS) { CHAR sztmp[128] = ""; - StringFixer::CopyN(sztmp, pSndFile->m_MixPlugins[m->instr - 1].GetParamName(m->GetValueVolCol()).c_str()); + mpt::String::CopyN(sztmp, pSndFile->m_MixPlugins[m->instr - 1].GetParamName(m->GetValueVolCol()).c_str()); if (sztmp[0]) wsprintf(s, "%d: %s", m->GetValueVolCol(), sztmp); } } else Modified: trunk/OpenMPT/mptrack/MIDIMacroDialog.cpp =================================================================== --- trunk/OpenMPT/mptrack/MIDIMacroDialog.cpp 2013-05-21 23:01:00 UTC (rev 2168) +++ trunk/OpenMPT/mptrack/MIDIMacroDialog.cpp 2013-05-21 23:42:33 UTC (rev 2169) @@ -210,7 +210,7 @@ { ToggleBoxes(sfx_preset, sfx); memcpy(s, m_MidiCfg.szMidiSFXExt[sfx], MACRO_LENGTH); - StringFixer::SetNullTerminator(s); + mpt::String::SetNullTerminator(s); m_EditSFx.SetWindowText(s); } @@ -218,7 +218,7 @@ if(zxx < 0x80) { memcpy(s, m_MidiCfg.szMidiZXXExt[zxx], MACRO_LENGTH); - StringFixer::SetNullTerminator(s); + mpt::String::SetNullTerminator(s); m_EditZxx.SetWindowText(s); } UpdateMacroList(); @@ -322,7 +322,7 @@ char s[MACRO_LENGTH]; MemsetZero(s); m_EditSFx.GetWindowText(s, MACRO_LENGTH); - StringFixer::SetNullTerminator(s); + mpt::String::SetNullTerminator(s); memcpy(m_MidiCfg.szMidiSFXExt[sfx], s, MACRO_LENGTH); int sfx_preset = m_MidiCfg.GetParameteredMacroType(sfx); @@ -345,7 +345,7 @@ char s[MACRO_LENGTH]; MemsetZero(s); m_EditZxx.GetWindowText(s, MACRO_LENGTH); - StringFixer::SetNullTerminator(s); + mpt::String::SetNullTerminator(s); memcpy(m_MidiCfg.szMidiZXXExt[zxx], s, MACRO_LENGTH); m_CbnZxxPreset.SetCurSel(m_MidiCfg.GetFixedMacroType()); } Modified: trunk/OpenMPT/mptrack/Moddoc.cpp =================================================================== --- trunk/OpenMPT/mptrack/Moddoc.cpp 2013-05-21 23:01:00 UTC (rev 2168) +++ trunk/OpenMPT/mptrack/Moddoc.cpp 2013-05-21 23:42:33 UTC (rev 2169) @@ -284,7 +284,7 @@ pIns = m_SndFile.Instruments[nIns]; // Reset pIns because ExtractInstrument may delete the previous value. if ((dwKey >= 24) && (dwKey < 100)) { - StringFixer::CopyN(pIns->name, szMidiPercussionNames[dwKey - 24]); + mpt::String::CopyN(pIns->name, szMidiPercussionNames[dwKey - 24]); } bEmbedded = TRUE; } @@ -326,7 +326,7 @@ pIns = m_SndFile.Instruments[nIns]; // Reset pIns because ExtractInstrument may delete the previous value. if ((dwKey >= 24) && (dwKey < 24+61)) { - StringFixer::CopyN(pIns->name, szMidiPercussionNames[dwKey-24]); + mpt::String::CopyN(pIns->name, szMidiPercussionNames[dwKey-24]); } } } @@ -347,17 +347,17 @@ _splitpath(pszMidiMapName, NULL, NULL, szName, szExt); strncat(szName, szExt, sizeof(szName)); pIns = m_SndFile.Instruments[nIns]; - if (!pIns->filename[0]) StringFixer::Copy(pIns->filename, szName); + if (!pIns->filename[0]) mpt::String::Copy(pIns->filename, szName); if (!pIns->name[0]) { if (nMidiCode < 128) { - StringFixer::CopyN(pIns->name, szMidiProgramNames[nMidiCode]); + mpt::String::CopyN(pIns->name, szMidiProgramNames[nMidiCode]); } else { UINT nKey = nMidiCode & 0x7F; if (nKey >= 24) - StringFixer::CopyN(pIns->name, szMidiPercussionNames[nKey - 24]); + mpt::String::CopyN(pIns->name, szMidiPercussionNames[nKey - 24]); } } } @@ -2874,13 +2874,13 @@ //---------------------------- { // Song title - StringFixer::FixNullString(m_SndFile.m_szNames[0]); + mpt::String::FixNullString(m_SndFile.m_szNames[0]); // Sample names + filenames for(SAMPLEINDEX nSmp = 1; nSmp <= m_SndFile.GetNumSamples(); nSmp++) { - StringFixer::FixNullString(m_SndFile.m_szNames[nSmp]); - StringFixer::FixNullString(m_SndFile.GetSample(nSmp).filename); + mpt::String::FixNullString(m_SndFile.m_szNames[nSmp]); + mpt::String::FixNullString(m_SndFile.GetSample(nSmp).filename); } // Instrument names @@ -2888,15 +2888,15 @@ { if(m_SndFile.Instruments[nIns] != nullptr) { - StringFixer::FixNullString(m_SndFile.Instruments[nIns]->name); - StringFixer::FixNullString(m_SndFile.Instruments[nIns]->filename); + mpt::String::FixNullString(m_SndFile.Instruments[nIns]->name); + mpt::String::FixNullString(m_SndFile.Instruments[nIns]->filename); } } // Channel names for(CHANNELINDEX nChn = 0; nChn < m_SndFile.GetNumChannels(); nChn++) { - StringFixer::FixNullString(m_SndFile.ChnSettings[nChn].szName); + mpt::String::FixNullString(m_SndFile.ChnSettings[nChn].szName); } // Macros Modified: trunk/OpenMPT/mptrack/Modedit.cpp =================================================================== --- trunk/OpenMPT/mptrack/Modedit.cpp 2013-05-21 23:01:00 UTC (rev 2168) +++ trunk/OpenMPT/mptrack/Modedit.cpp 2013-05-21 23:42:33 UTC (rev 2169) @@ -530,7 +530,7 @@ } InitializeInstrument(instrument); - StringFixer::Copy(instrument->name, m_SndFile.m_szNames[smp]); + mpt::String::Copy(instrument->name, m_SndFile.m_szNames[smp]); MuteInstrument(smp, muted); } Modified: trunk/OpenMPT/mptrack/Mptrack.cpp =================================================================== --- trunk/OpenMPT/mptrack/Mptrack.cpp 2013-05-21 23:01:00 UTC (rev 2168) +++ trunk/OpenMPT/mptrack/Mptrack.cpp 2013-05-21 23:42:33 UTC (rev 2169) @@ -157,7 +157,7 @@ CHAR s[_MAX_PATH], *pszCmd, *pszData; int len; - StringFixer::CopyN(s, lpszCommand); + mpt::String::CopyN(s, lpszCommand); len = strlen(s) - 1; while ((len > 0) && (strchr("(){}[]\'\" ", s[len]))) s[len--] = 0; pszCmd = s; @@ -699,7 +699,7 @@ { if(GetModuleFileName(NULL, m_szExePath, CountOf(m_szExePath))) { - StringFixer::SetNullTerminator(m_szExePath); + mpt::String::SetNullTerminator(m_szExePath); TCHAR szDrive[_MAX_DRIVE] = "", szDir[_MAX_PATH] = ""; _splitpath(m_szExePath, szDrive, szDir, NULL, NULL); strcpy(m_szExePath, szDrive); @@ -2321,7 +2321,7 @@ const size_t nStrLength = nLength - 1; // "usable" length, i.e. not including the null char. TCHAR szExePath[nLength], szTempPath[nLength]; _tcsncpy(szExePath, GetAppDirPath(), nStrLength); - StringFixer::SetNullTerminator(szExePath); + mpt::String::SetNullTerminator(szExePath); if(!_tcsncicmp(szExePath, szPath, _tcslen(szExePath))) { @@ -2335,7 +2335,7 @@ _tcsncpy(szTempPath, &szPath[2], nStrLength); // "\Somepath" _tcscpy(szPath, szTempPath); } - StringFixer::SetNullTerminator(szPath); + mpt::String::SetNullTerminator(szPath); } @@ -2355,7 +2355,7 @@ const size_t nStrLength = nLength - 1; // "usable" length, i.e. not including the null char. TCHAR szExePath[nLength], szTempPath[nLength] = _T(""); _tcsncpy(szExePath, GetAppDirPath(), nStrLength); - StringFixer::SetNullTerminator(szExePath); + mpt::String::SetNullTerminator(szExePath); if(!_tcsncicmp(szPath, _T("\\"), 1) && _tcsncicmp(szPath, _T("\\\\"), 2)) { @@ -2373,7 +2373,7 @@ } _tcscpy(szPath, szTempPath); } - StringFixer::SetNullTerminator(szPath); + mpt::String::SetNullTerminator(szPath); } void CTrackApp::RemoveMruItem(const int nItem) Modified: trunk/OpenMPT/mptrack/SelectPluginDialog.cpp =================================================================== --- trunk/OpenMPT/mptrack/SelectPluginDialog.cpp 2013-05-21 23:01:00 UTC (rev 2168) +++ trunk/OpenMPT/mptrack/SelectPluginDialog.cpp 2013-05-21 23:42:33 UTC (rev 2169) @@ -148,8 +148,8 @@ break; } - StringFixer::Copy(m_pPlugin->Info.szName, pFactory->szLibraryName); - StringFixer::Copy(m_pPlugin->Info.szLibraryName, pFactory->szLibraryName); + mpt::String::Copy(m_pPlugin->Info.szName, pFactory->szLibraryName); + mpt::String::Copy(m_pPlugin->Info.szLibraryName, pFactory->szLibraryName); cs.Leave(); @@ -165,7 +165,7 @@ if ((p->GetDefaultEffectName(s)) && (s[0])) { s[31] = 0; - StringFixer::Copy(m_pPlugin->Info.szName, s); + mpt::String::Copy(m_pPlugin->Info.szName, s); } } } Modified: trunk/OpenMPT/mptrack/TrackerSettings.cpp =================================================================== --- trunk/OpenMPT/mptrack/TrackerSettings.cpp 2013-05-21 23:01:00 UTC (rev 2168) +++ trunk/OpenMPT/mptrack/TrackerSettings.cpp 2013-05-21 23:42:33 UTC (rev 2169) @@ -231,14 +231,14 @@ CHAR snam[8]; wsprintf(snam, "SF%X", isfx); GetPrivateProfileString("Zxx Macros", snam, macros.szMidiSFXExt[isfx], macros.szMidiSFXExt[isfx], CountOf(macros.szMidiSFXExt[isfx]), iniFile); - StringFixer::SetNullTerminator(macros.szMidiSFXExt[isfx]); + mpt::String::SetNullTerminator(macros.szMidiSFXExt[isfx]); } for(int izxx = 0; izxx < 128; izxx++) { CHAR snam[8]; wsprintf(snam, "Z%02X", izxx | 0x80); GetPrivateProfileString("Zxx Macros", snam, macros.szMidiZXXExt[izxx], macros.szMidiZXXExt[izxx], CountOf(macros.szMidiZXXExt[izxx]), iniFile); - StringFixer::SetNullTerminator(macros.szMidiZXXExt[izxx]); + mpt::String::SetNullTerminator(macros.szMidiZXXExt[izxx]); } // Fix old nasty broken (non-standard) MIDI configs in INI file. if(storedVersion >= "1.17" && storedVersion < "1.20") @@ -504,11 +504,11 @@ GetPrivateProfileStruct("Effects", "EQ_User2", &CEQSetupDlg::gUserPresets[1], sizeof(EQPreset), iniFile); GetPrivateProfileStruct("Effects", "EQ_User3", &CEQSetupDlg::gUserPresets[2], sizeof(EQPreset), iniFile); GetPrivateProfileStruct("Effects", "EQ_User4", &CEQSetupDlg::gUserPresets[3], sizeof(EQPreset), iniFile); - StringFixer::SetNullTerminator(m_EqSettings.szName); - StringFixer::SetNullTerminator(CEQSetupDlg::gUserPresets[0].szName); - StringFixer::SetNullTerminator(CEQSetupDlg::gUserPresets[1].szName); - StringFixer::SetNullTerminator(CEQSetupDlg::gUserPresets[2].szName); - StringFixer::SetNullTerminator(CEQSetupDlg::gUserPresets[3].szName); + mpt::String::SetNullTerminator(m_EqSettings.szName); + mpt::String::SetNullTerminator(CEQSetupDlg::gUserPresets[0].szName); + mpt::String::SetNullTerminator(CEQSetupDlg::gUserPresets[1].szName); + mpt::String::SetNullTerminator(CEQSetupDlg::gUserPresets[2].szName); + mpt::String::SetNullTerminator(CEQSetupDlg::gUserPresets[3].szName); #endif @@ -556,7 +556,7 @@ if (pEqSettings->Gains[i] > 32) pEqSettings->Gains[i] = 16; if ((pEqSettings->Freqs[i] < 100) || (pEqSettings->Freqs[i] > 10000)) pEqSettings->Freqs[i] = CEQSetupDlg::gEQPresets[0].Freqs[i]; } - StringFixer::SetNullTerminator(pEqSettings->szName); + mpt::String::SetNullTerminator(pEqSettings->szName); } Modified: trunk/OpenMPT/mptrack/Undo.cpp =================================================================== --- trunk/OpenMPT/mptrack/Undo.cpp 2013-05-21 23:01:00 UTC (rev 2168) +++ trunk/OpenMPT/mptrack/Undo.cpp 2013-05-21 23:42:33 UTC (rev 2169) @@ -281,7 +281,7 @@ // Save old sample header undo.OldSample = oldSample; - StringFixer::Copy(undo.oldName, sndFile.m_szNames[smp]); + mpt::String::Copy(undo.oldName, sndFile.m_szNames[smp]); undo.changeType = changeType; if(changeType == sundo_replace) Modified: trunk/OpenMPT/mptrack/View_gen.cpp =================================================================== --- trunk/OpenMPT/mptrack/View_gen.cpp 2013-05-21 23:01:00 UTC (rev 2168) +++ trunk/OpenMPT/mptrack/View_gen.cpp 2013-05-21 23:42:33 UTC (rev 2169) @@ -886,10 +886,10 @@ CSoundFile *pSndFile = pModDoc->GetSoundFile(); GetDlgItemText(IDC_EDIT13, s, 32); - StringFixer::SetNullTerminator(s); + mpt::String::SetNullTerminator(s); if (strcmp(s, pSndFile->m_MixPlugins[m_nCurrentPlugin].GetName())) { - StringFixer::Copy(pSndFile->m_MixPlugins[m_nCurrentPlugin].Info.szName, s); + mpt::String::Copy(pSndFile->m_MixPlugins[m_nCurrentPlugin].Info.szName, s); if(pSndFile->GetModSpecifications().supportsPlugins) pModDoc->SetModified(); pModDoc->UpdateAllViews(NULL, HINT_MODCHANNELS | (m_nActiveTab << HINT_SHIFT_CHNTAB)); Modified: trunk/OpenMPT/mptrack/View_tre.cpp =================================================================== --- trunk/OpenMPT/mptrack/View_tre.cpp 2013-05-21 23:01:00 UTC (rev 2168) +++ trunk/OpenMPT/mptrack/View_tre.cpp 2013-05-21 23:42:33 UTC (rev 2169) @@ -448,11 +448,11 @@ { _splitpath(lpMidiLib->MidiMap[iPerc|0x80], NULL, NULL, szName, szExt); strncat(s, ": ", sizeof(s)); - StringFixer::SetNullTerminator(s); + mpt::String::SetNullTerminator(s); strncat(s, szName, sizeof(s)); - StringFixer::SetNullTerminator(s); + mpt::String::SetNullTerminator(s); strncat(s, szExt, sizeof(s)); - StringFixer::SetNullTerminator(s); + mpt::String::SetNullTerminator(s); if (szName[0]) dwImage = IMAGE_SAMPLES; } if (!m_tiPerc[iPerc]) @@ -1324,7 +1324,7 @@ { // Preview sample / instrument in module char szName[16]; - StringFixer::CopyN(szName, GetItemText(hItem)); + mpt::String::CopyN(szName, GetItemText(hItem)); const size_t n = ConvertStrTo<size_t>(szName); CMainFrame *pMainFrm = CMainFrame::GetMainFrame(); if (pMainFrm && m_SongFile) @@ -1621,7 +1621,7 @@ ModInstrument *pIns = m_SongFile->Instruments[iIns]; if(pIns) { - StringFixer::Copy(szPath, pIns->name); + mpt::String::Copy(szPath, pIns->name); wsprintf(s, "%3d: %s", iIns, szPath); ModTreeBuildTVIParam(tvis, s, IMAGE_INSTRUMENTS); InsertItem(&tvis); @@ -1998,7 +1998,7 @@ if (m_szSongName[0]) { CHAR s[32]; - StringFixer::CopyN(s, GetItemText(m_hItemDrag)); + mpt::String::CopyN(s, GetItemText(m_hItemDrag)); UINT n = 0; if (s[0] >= '0') n += (s[0] - '0'); if ((s[1] >= '0') && (s[1] <= '9')) n = n*10 + (s[1] - '0'); @@ -3616,7 +3616,7 @@ case MODITEM_SAMPLE: if(modItemID <= sndFile.GetNumSamples() && strcmp(sndFile.m_szNames[modItemID], info->item.pszText)) { - StringFixer::CopyN(sndFile.m_szNames[modItemID], info->item.pszText, modSpecs.sampleNameLengthMax); + mpt::String::CopyN(sndFile.m_szNames[modItemID], info->item.pszText, modSpecs.sampleNameLengthMax); modDoc->SetModified(); modDoc->UpdateAllViews(NULL, (UINT(modItemID) << HINT_SHIFT_SMP) | HINT_SMPNAMES | HINT_SAMPLEDATA | HINT_SAMPLEINFO); } @@ -3625,7 +3625,7 @@ case MODITEM_INSTRUMENT: if(modItemID <= sndFile.GetNumInstruments() && sndFile.Instruments[modItemID] != nullptr && strcmp(sndFile.Instruments[modItemID]->name, info->item.pszText)) { - StringFixer::CopyN(sndFile.Instruments[modItemID]->name, info->item.pszText, modSpecs.instrNameLengthMax); + mpt::String::CopyN(sndFile.Instruments[modItemID]->name, info->item.pszText, modSpecs.instrNameLengthMax); modDoc->SetModified(); modDoc->UpdateAllViews(NULL, (UINT(modItemID) << HINT_SHIFT_INS) | HINT_ENVELOPE | HINT_INSTRUMENT); } Modified: trunk/OpenMPT/mptrack/VstPresets.cpp =================================================================== --- trunk/OpenMPT/mptrack/VstPresets.cpp 2013-05-21 23:01:00 UTC (rev 2168) +++ trunk/OpenMPT/mptrack/VstPresets.cpp 2013-05-21 23:42:33 UTC (rev 2169) @@ -65,7 +65,7 @@ // Program PlugParamIndex numParams = file.ReadUint32BE(); char prgName[28]; - file.ReadString<StringFixer::maybeNullTerminated>(prgName, 28); + file.ReadString<mpt::String::maybeNullTerminated>(prgName, 28); plugin.Dispatch(effSetProgramName, 0, 0, prgName, 0.0f); if(header.fxMagic == fMagic) Modified: trunk/OpenMPT/mptrack/Vstplug.cpp =================================================================== --- trunk/OpenMPT/mptrack/Vstplug.cpp 2013-05-21 23:01:00 UTC (rev 2168) +++ trunk/OpenMPT/mptrack/Vstplug.cpp 2013-05-21 23:42:33 UTC (rev 2169) @@ -51,7 +51,7 @@ //---------------------------------------------- { char fn[_MAX_PATH]; - StringFixer::Copy(fn, s); + mpt::String::Copy(fn, s); int f; for(f = 0; fn[f] != 0; f++) fn[f] = toupper(fn[f]); return LittleEndian(crc32(0, (BYTE *)fn, f)); @@ -162,11 +162,11 @@ p->dwPluginId1 = kDmoMagic; p->dwPluginId2 = clsid.Data1; p->category = VSTPluginLib::catDMO; - StringFixer::Copy(p->szLibraryName, s); + mpt::String::Copy(p->szLibraryName, s); StringFromGUID2(clsid, w, 100); WideCharToMultiByte(CP_ACP, 0, w, -1, p->szDllPath, sizeof(p->szDllPath), nullptr, nullptr); - StringFixer::SetNullTerminator(p->szDllPath); + mpt::String::SetNullTerminator(p->szDllPath); #ifdef DMO_LOG if (theApp.IsDebug()) Log("Found \"%s\" clsid=%s\n", p->szLibraryName, p->szDllPath); #endif @@ -304,7 +304,7 @@ { // Get path from cache file GetPrivateProfileString(cacheSection, IDs, "", szPath, CountOf(szPath), cacheFile); - StringFixer::SetNullTerminator(szPath); + mpt::String::SetNullTerminator(szPath); theApp.RelativePathToAbsolute(szPath); if ((szPath[0]) && (!lstrcmpi(szPath, pszDllPath))) @@ -438,7 +438,7 @@ { theApp.AbsolutePathToRelative(szPath); } - StringFixer::SetNullTerminator(szPath); + mpt::String::SetNullTerminator(szPath); WritePrivateProfileString(cacheSection, IDs, szPath, cacheFile); CMainFrame::WritePrivateProfileCString(cacheSection, IDs, pszDllPath, cacheFile); @@ -551,10 +551,10 @@ { // Try finding the plugin DLL in the plugin directory instead. CHAR s[_MAX_PATH]; - StringFixer::CopyN(s, TrackerSettings::Instance().GetDefaultDirectory(DIR_PLUGINS)); + mpt::String::CopyN(s, TrackerSettings::Instance().GetDefaultDirectory(DIR_PLUGINS)); if(!s[0]) { - StringFixer::CopyN(s, theApp.GetAppDirPath()); + mpt::String::CopyN(s, theApp.GetAppDirPath()); } size_t len = strlen(s); if((len > 0) && (s[len - 1] != '\\') && (s[len - 1] != '/')) @@ -564,7 +564,7 @@ strncat(s, mixPlugin.GetLibraryName(), CountOf(s)); strncat(s, ".dll", CountOf(s)); - StringFixer::SetNullTerminator(s); + mpt::String::SetNullTerminator(s); pFound = AddPlugin(s); if (!pFound) @@ -1185,7 +1185,7 @@ char szInitPath[_MAX_PATH] = { '\0' }; if(fileSel->initialPath) { - StringFixer::CopyN(szInitPath, fileSel->initialPath); + mpt::String::CopyN(szInitPath, fileSel->initialPath); } char szBuffer[_MAX_PATH]; @@ -1622,7 +1622,7 @@ char rawname[MAX(kVstMaxProgNameLen + 1, 256)] = ""; // kVstMaxProgNameLen is 24... Dispatch(effGetProgramName, 0, 0, rawname, 0); SanitizeFilename(rawname); - StringFixer::SetNullTerminator(rawname); + mpt::String::SetNullTerminator(rawname); FileDlgResult files = CTrackApp::ShowOpenSaveFileDialog(false, "fxp", rawname, "VST Plugin Programs (*.fxp)|*.fxp|" "VST Plugin Banks (*.fxb)|*.fxb||", @@ -1767,7 +1767,7 @@ SetCurrentProgram(curProg); } } - StringFixer::SetNullTerminator(rawname); + mpt::String::SetNullTerminator(rawname); // Let's start counting at 1 for the program name (as most MIDI hardware / software does) index++; @@ -1853,7 +1853,7 @@ if(m_Effect.numParams > 0 && param < m_Effect.numParams) { Dispatch(opcode, param, 0, s, 0); - StringFixer::SetNullTerminator(s); + mpt::String::SetNullTerminator(s); } return CString(s); } @@ -1868,7 +1868,7 @@ MemsetZero(properties.label); if(Dispatch(effGetParameterProperties, param, 0, &properties, 0.0f) == 1) { - StringFixer::SetNullTerminator(properties.label); + mpt::String::SetNullTerminator(properties.label); paramName = properties.label; } else { Modified: trunk/OpenMPT/mptrack/Vstplug.h =================================================================== --- trunk/OpenMPT/mptrack/Vstplug.h 2013-05-21 23:01:00 UTC (rev 2168) +++ trunk/OpenMPT/mptrack/Vstplug.h 2013-05-21 23:42:33 UTC (rev 2169) @@ -78,7 +78,7 @@ category = catUnknown; if(dllPath != nullptr) { - StringFixer::CopyN(szDllPath, dllPath); + mpt::String::CopyN(szDllPath, dllPath); } } Modified: trunk/OpenMPT/mptrack/dlg_misc.cpp =================================================================== --- trunk/OpenMPT/mptrack/dlg_misc.cpp 2013-05-21 23:01:00 UTC (rev 2168) +++ trunk/OpenMPT/mptrack/dlg_misc.cpp 2013-05-21 23:42:33 UTC (rev 2169) @@ -447,7 +447,7 @@ //strncpy_s(pTTTA->szText, sizeof(pTTTA->szText), strTipText, // strTipText.GetLength() + 1); // 80 chars max?! - StringFixer::CopyN(pTTTA->szText, strTipText); + mpt::String::CopyN(pTTTA->szText, strTipText); } else { ::MultiByteToWideChar(CP_ACP , 0, strTipText, strTipText.GetLength() + 1, Modified: trunk/OpenMPT/mptrack/mod2midi.cpp =================================================================== --- trunk/OpenMPT/mptrack/mod2midi.cpp 2013-05-21 23:01:00 UTC (rev 2168) +++ trunk/OpenMPT/mptrack/mod2midi.cpp 2013-05-21 23:42:33 UTC (rev 2169) @@ -417,7 +417,7 @@ for (CHANNELINDEX iInit = 0; iInit < m_pSndFile->GetNumChannels(); iInit++) { DYNMIDITRACK &track = Tracks[iInit]; - StringFixer::Copy(s, m_pSndFile->ChnSettings[iInit].szName); + mpt::String::Copy(s, m_pSndFile->ChnSettings[iInit].szName); track.nMidiChannel = iInit & 7; if (s[0]) { Modified: trunk/OpenMPT/mptrack/test/test.cpp =================================================================== --- trunk/OpenMPT/mptrack/test/test.cpp 2013-05-21 23:01:00 UTC (rev 2168) +++ trunk/OpenMPT/mptrack/test/test.cpp 2013-05-21 23:42:33 UTC (rev 2169) @@ -1087,13 +1087,13 @@ char dst2[3]; // Destination buffer, smaller than source buffer #define ReadTest(mode, dst, src, expectedResult) \ - StringFixer::ReadString<StringFixer::##mode>(dst, src); \ + mpt::String::Read<mpt::String::##mode>(dst, src); \ VERIFY_EQUAL_NONCONT(strncmp(dst, expectedResult, CountOf(dst)), 0); /* Ensure that the strings are identical */ \ for(size_t i = strlen(dst); i < CountOf(dst); i++) \ VERIFY_EQUAL_NONCONT(dst[i], '\0'); /* Ensure that rest of the buffer is completely nulled */ #define WriteTest(mode, dst, src, expectedResult) \ - StringFixer::WriteString<StringFixer::##mode>(dst, src); \ + mpt::String::Write<mpt::String::##mode>(dst, src); \ VERIFY_EQUAL_NONCONT(strncmp(dst, expectedResult, CountOf(dst)), 0); /* Ensure that the strings are identical */ \ for(size_t i = strlen(dst); i < CountOf(dst); i++) \ VERIFY_EQUAL_NONCONT(dst[i], '\0'); /* Ensure that rest of the buffer is completely nulled */ @@ -1187,9 +1187,9 @@ /////////////////////////////// // Test FixNullString() - StringFixer::FixNullString(src1); - StringFixer::FixNullString(src2); - StringFixer::FixNullString(src3); + mpt::String::FixNullString(src1); + mpt::String::FixNullString(src2); + mpt::String::FixNullString(src3); VERIFY_EQUAL_NONCONT(strncmp(src1, "X ", CountOf(src1)), 0); VERIFY_EQUAL_NONCONT(strncmp(src2, "XYZ", CountOf(src2)), 0); VERIFY_EQUAL_NONCONT(strncmp(src3, "XYZ", CountOf(src3)), 0); Modified: trunk/OpenMPT/mptrack/view_com.cpp =================================================================== --- trunk/OpenMPT/mptrack/view_com.cpp 2013-05-21 23:01:00 UTC (rev 2168) +++ trunk/OpenMPT/mptrack/view_com.cpp 2013-05-21 23:42:33 UTC (rev 2169) @@ -275,7 +275,7 @@ switch(iCol) { case SMPLIST_SAMPLENAME: - StringFixer::Copy(s, pSndFile->m_szNames[iSmp + 1]); + mpt::String::Copy(s, pSndFile->m_szNames[iSmp + 1]); break; case SMPLIST_SAMPLENO: wsprintf(s, "%02d", iSmp + 1); @@ -375,7 +375,7 @@ switch(iCol) { case INSLIST_INSTRUMENTNAME: - if (pIns) StringFixer::Copy(s, pIns->name); + if (pIns) mpt::String::Copy(s, pIns->name); break; case INSLIST_INSTRUMENTNO: wsprintf(s, "%02d", iIns+1); @@ -527,7 +527,7 @@ { if(iItem < pSndFile->GetNumSamples()) { - StringFixer::CopyN(pSndFile->m_szNames[iItem + 1], lvItem.pszText); + mpt::String::CopyN(pSndFile->m_szNames[iItem + 1], lvItem.pszText); pModDoc->UpdateAllViews(this, ((iItem + 1) << HINT_SHIFT_SMP) | (HINT_SMPNAMES | HINT_SAMPLEINFO), this); pModDoc->SetModified(); } @@ -536,7 +536,7 @@ if((iItem < pSndFile->GetNumInstruments()) && (pSndFile->Instruments[iItem + 1])) { ModInstrument *pIns = pSndFile->Instruments[iItem + 1]; - StringFixer::CopyN(pIns->name, lvItem.pszText); + mpt::String::CopyN(pIns->name, lvItem.pszText); pModDoc->UpdateAllViews(this, ((iItem + 1) << HINT_SHIFT_INS) | (HINT_INSNAMES | HINT_INSTRUMENT), this); pModDoc->SetModified(); } Modified: trunk/OpenMPT/soundlib/Dlsbank.cpp =================================================================== --- trunk/OpenMPT/soundlib/Dlsbank.cpp 2013-05-21 23:01:00 UTC (rev 2168) +++ trunk/OpenMPT/soundlib/Dlsbank.cpp 2013-05-21 23:42:33 UTC (rev 2169) @@ -923,7 +923,7 @@ SFSAMPLE *p = (SFSAMPLE *)(pchunk+1); for (UINT i=0; i<m_nSamplesEx; i++, pDlsSmp++, p++) { - StringFixer::Copy(pDlsSmp->szName, p->achSampleName); + mpt::String::Copy(pDlsSmp->szName, p->achSampleName); pDlsSmp->dwLen = 0; pDlsSmp->dwSampleRate = p->dwSampleRate; pDlsSmp->byOriginalPitch = p->byOriginalPitch; @@ -1731,10 +1731,10 @@ } lstrcat(s, ")"); } - StringFixer::Copy(pIns->name, s); + mpt::String::Copy(pIns->name, s); } else { - StringFixer::Copy(pIns->name, pDlsIns->szName); + mpt::String::Copy(pIns->name, pDlsIns->szName); } int nTranspose = 0; if (pDlsIns->ulBank & F_INSTRUMENT_DRUMS) Modified: trunk/OpenMPT/soundlib/FileReader.h =================================================================== --- trunk/OpenMPT/soundlib/FileReader.h 2013-05-21 23:01:00 UTC (rev 2168) +++ trunk/OpenMPT/soundlib/FileReader.h 2013-05-21 23:42:33 UTC (rev 2169) @@ -758,12 +758,12 @@ // Read a string of length srcSize into fixed-length char array destBuffer using a given read mode. // The file cursor is advanced by "srcSize" bytes. - template<StringFixer::ReadWriteMode mode, off_t destSize> + template<mpt::String::ReadWriteMode mode, off_t destSize> bool ReadString(char (&destBuffer)[destSize], const off_t srcSize) { if(CanRead(srcSize)) { - StringFixer::ReadString<mode, destSize>(destBuffer, DataContainer().GetPartialRawData(streamPos, srcSize), srcSize); + mpt::String::Read<mode, destSize>(destBuffer, DataContainer().GetPartialRawData(streamPos, srcSize), srcSize); streamPos += srcSize; return true; } else Modified: trunk/OpenMPT/soundlib/ITTools.cpp =================================================================== --- trunk/OpenMPT/soundlib/ITTools.cpp 2013-05-21 23:01:00 UTC (rev 2168) +++ trunk/OpenMPT/soundlib/ITTools.cpp 2013-05-21 23:42:33 UTC (rev 2169) @@ -134,8 +134,8 @@ return; } - StringFixer::ReadString<StringFixer::spacePadded>(mptIns.name, name); - StringFixer::ReadString<StringFixer::nullTerminated>(mptIns.filename, filename); + mpt::String::Read<mpt::String::spacePadded>(mptIns.name, name); + mpt::String::Read<mpt::String::nullTerminated>(mptIns.filename, filename); // Volume / Panning mptIns.nFadeOut = fadeout << 6; @@ -214,8 +214,8 @@ id = ITInstrument::magic; trkvers = 0x0214; - StringFixer::WriteString<StringFixer::nullTerminated>(filename, mptIns.filename); - StringFixer::WriteString<StringFixer::nullTerminated>(name, mptIns.name); + mpt::String::Write<mpt::String::nullTerminated>(filename, mptIns.filename); + mpt::String::Write<mpt::String::nullTerminated>(name, mptIns.name); // Volume / Panning fadeout = static_cast<uint16>(MIN(mptIns.nFadeOut >> 5, 256)); @@ -295,8 +295,8 @@ return 0; } - StringFixer::ReadString<StringFixer::spacePadded>(mptIns.name, name); - StringFixer::ReadString<StringFixer::nullTerminated>(mptIns.filename, filename); + mpt::String::Read<mpt::String::spacePadded>(mptIns.name, name); + mpt::String::Read<mpt::String::nullTerminated>(mptIns.filename, filename); // Volume / Panning mptIns.nFadeOut = fadeout << 5; @@ -476,8 +476,8 @@ // Header id = ITSample::magic; - StringFixer::WriteString<StringFixer::nullTerminated>(filename, mptSmp.filename); - //StringFixer::WriteString<StringFixer::nullTerminated>(name, m_szNames[nsmp]); + mpt::String::Write<mpt::String::nullTerminated>(filename, mptSmp.filename); + //mpt::String::Write<mpt::String::nullTerminated>(name, m_szNames[nsmp]); // Volume / Panning gvl = static_cast<uint8>(mptSmp.nGlobalVol); @@ -552,7 +552,7 @@ } mptSmp.Initialize(MOD_TYPE_IT); - StringFixer::ReadString<StringFixer::nullTerminated>(mptSmp.filename, filename); + mpt::String::Read<mpt::String::nullTerminated>(mptSmp.filename, filename); // Volume / Panning mptSmp.nVolume = vol * 4; Modified: trunk/OpenMPT/soundlib/LOAD_AMF.CPP =================================================================== --- trunk/OpenMPT/soundlib/LOAD_AMF.CPP 2013-05-21 23:01:00 UTC (rev 2168) +++ trunk/OpenMPT/soundlib/LOAD_AMF.CPP 2013-05-21 23:42:33 UTC (rev 2169) @@ -138,7 +138,7 @@ AsylumSampleHeader sampleHeader; file.ReadConvertEndianness(sampleHeader); sampleHeader.ConvertToMPT(Samples[smp]); - StringFixer::ReadString<StringFixer::maybeNullTerminated>(m_szNames[smp], sampleHeader.name); + mpt::String::Read<mpt::String::maybeNullTerminated>(m_szNames[smp], sampleHeader.name); } file.Skip((64 - fileHeader.numSamples) * sizeof(AsylumSampleHeader)); @@ -385,7 +385,7 @@ m_nChannels = fileHeader.numChannels; m_nSamples = fileHeader.numSamples; - StringFixer::ReadString<StringFixer::maybeNullTerminated>(m_szNames[0], fileHeader.title); + mpt::String::Read<mpt::String::maybeNullTerminated>(m_szNames[0], fileHeader.title); if(fileHeader.version < 10) { @@ -463,8 +463,8 @@ sample.Initialize(); uint8 type = file.ReadUint8(); - file.ReadString<StringFixer::maybeNullTerminated>(m_szNames[smp], 32); - file.ReadString<StringFixer::nullTerminated>(sample.filename, 13); + file.ReadString<mpt::String::maybeNullTerminated>(m_szNames[smp], 32); + file.ReadString<mpt::String::nullTerminated>(sample.filename, 13); samplePos[smp - 1] = file.ReadUint32LE(); if(fileHeader.version < 10) { Modified: trunk/OpenMPT/soundlib/LOAD_DBM.CPP =================================================================== --- trunk/OpenMPT/soundlib/LOAD_DBM.CPP 2013-05-21 23:01:00 UTC (rev 2168) +++ trunk/OpenMPT/soundlib/LOAD_DBM.CPP 2013-05-21 23:42:33 UTC (rev 2169) @@ -227,10 +227,10 @@ if(pfh->songname[0]) { - StringFixer::ReadString<StringFixer::maybeNullTerminated>(m_szNames[0], pfh->songname); + mpt::String::Read<mpt::String::maybeNullTerminated>(m_szNames[0], pfh->songname); } else { - StringFixer::ReadString<StringFixer::maybeNullTerminated>(m_szNames[0], pfh->songname2); + mpt::String::Read<mpt::String::maybeNullTerminated>(m_szNames[0], pfh->songname2); } @@ -274,10 +274,10 @@ break; } - StringFixer::ReadString<StringFixer::maybeNullTerminated>(pIns->name, pih->name); + mpt::String::Read<mpt::String::maybeNullTerminated>(pIns->name, pih->name); if (psmp) { - StringFixer::ReadString<StringFixer::maybeNullTerminated>(m_szNames[nsmp], pih->name); + mpt::String::Read<mpt::String::maybeNullTerminated>(m_szNames[nsmp], pih->name); } pIns->nFadeOut = 1024; // ??? Modified: trunk/OpenMPT/soundlib/LOAD_DMF.CPP =================================================================== --- trunk/OpenMPT/soundlib/LOAD_DMF.CPP 2013-05-21 23:01:00 UTC (rev 2168) +++ trunk/OpenMPT/soundlib/LOAD_DMF.CPP 2013-05-21 23:42:33 UTC (rev 2169) @@ -975,7 +975,7 @@ } InitializeGlobals(); - StringFixer::ReadString<StringFixer::spacePadded>(m_szNames[0], fileHeader.songname); + mpt::String::Read<mpt::String::spacePadded>(m_szNames[0], fileHeader.songname); #ifdef MODPLUG_TRACKER if(GetpModDoc() != nullptr) @@ -1067,7 +1067,7 @@ for(SAMPLEINDEX smp = 1; smp <= GetNumSamples(); smp++) { - chunk.ReadString<StringFixer::spacePadded>(m_szNames[smp], chunk.ReadUint8()); + chunk.ReadString<mpt::String::spacePadded>(m_szNames[smp], chunk.ReadUint8()); DMFSampleHeader sampleHeader; ModSample &sample = Samples[smp]; chunk.ReadConvertEndianness(sampleHeader); @@ -1076,7 +1076,7 @@ if(fileHeader.version >= 8) { // Read library name in version 8 files - chunk.ReadString<StringFixer::spacePadded>(sample.filename, 8); + chunk.ReadString<mpt::String::spacePadded>(sample.filename, 8); } // We don't care for the checksum of the sample data... Modified: trunk/OpenMPT/soundlib/LOAD_DSM.CPP =================================================================== --- trunk/OpenMPT/soundlib/LOAD_DSM.CPP 2013-05-21 23:01:00 UTC (rev 2168) +++ trunk/OpenMPT/soundlib/LOAD_DSM.CPP 2013-05-21 23:42:33 UTC (rev 2169) @@ -146,7 +146,7 @@ } } - StringFixer::ReadString<StringFixer::maybeNullTerminated>(m_szNames[0], psong->songname); + mpt::String::Read<mpt::String::maybeNullTerminated>(m_szNames[0], psong->songname); nPat = 0; nSmp = 1; @@ -244,8 +244,8 @@ ModSample &sample = Samples[nSmp]; sample.Initialize(); - StringFixer::ReadString<StringFixer::maybeNullTerminated>(m_szNames[nSmp], pSmp->samplename); - StringFixer::ReadString<StringFixer::nullTerminated>(sample.filename, pSmp->filename); + mpt::String::Read<mpt::String::maybeNullTerminated>(m_szNames[nSmp], pSmp->samplename); + mpt::String::Read<mpt::String::nullTerminated>(sample.filename, pSmp->filename); sample.nC5Speed = pSmp->c2spd; sample.uFlags.set(CHN_LOOP, (pSmp->flags & 1) != 0); Modified: trunk/OpenMPT/soundlib/Load_669.cpp =================================================================== --- trunk/OpenMPT/soundlib/Load_669.cpp 2013-05-21 23:01:00 UTC (rev 2168) +++ trunk/OpenMPT/soundlib/Load_669.cpp 2013-05-21 23:42:33 UTC (rev 2169) @@ -130,11 +130,11 @@ return false; } sampleHeader.ConvertToMPT(Samples[smp]); - StringFixer::ReadString<StringFixer::maybeNullTerminated>(m_szNames[smp], sampleHeader.filename); + mpt::String::Read<mpt::String::maybeNullTerminated>(m_szNames[smp], sampleHeader.filename); } // Copy first song message line into song title - StringFixer::ReadString<StringFixer::spacePadded>(m_szNames[0], fileHeader.songMessage, 36); + mpt::String::Read<mpt::String::spacePadded>(m_szNames[0], fileHeader.songMessage, 36); // Song Message songMessage.ReadFixedLineLength(fileHeader.songMessage, 108, 36, 0); Modified: trunk/OpenMPT/soundlib/Load_ams.cpp =================================================================== --- trunk/OpenMPT/soundlib/Load_ams.cpp 2013-05-21 23:01:00 UTC (rev 2168) +++ trunk/OpenMPT/soundlib/Load_ams.cpp 2013-05-21 23:42:33 UTC (rev 2169) @@ -43,7 +43,7 @@ //---------------------------------------------------------------- { const size_t length = file.ReadUint8(); - return file.ReadString<StringFixer::spacePadded>(destBuffer, length); + return file.ReadString<mpt::String::spacePadded>(destBuffer, length); } Modified: trunk/OpenMPT/soundlib/Load_digi.cpp =================================================================== --- trunk/OpenMPT/soundlib/Load_digi.cpp 2013-05-21 23:01:00 UTC (rev 2168) +++ trunk/OpenMPT/soundlib/Load_digi.cpp 2013-05-21 23:42:33 UTC (rev 2169) @@ -139,10 +139,10 @@ } // Read song + sample names - file.ReadString<StringFixer::maybeNullTerminated>(m_szNames[0], 32); + file.ReadString<mpt::String::maybeNullTerminated>(m_szNames[0], 32); for(SAMPLEINDEX smp = 1; smp <= 31; smp++) { - file.ReadString<StringFixer::maybeNullTerminated>(m_szNames[smp], 30); + file.ReadString<mpt::String::maybeNullTerminated>(m_szNames[smp], 30); } for(PATTERNINDEX pat = 0; pat <= fileHeader.lastPatIndex; pat++) Modified: trunk/OpenMPT/soundlib/Load_far.cpp =================================================================== --- trunk/OpenMPT/soundlib/Load_far.cpp 2013-05-21 23:01:00 UTC (rev 2168) +++ trunk/OpenMPT/soundlib/Load_far.cpp 2013-05-21 23:42:33 UTC (rev 2169) @@ -158,7 +158,7 @@ m_nDefaultTempo = 80; m_nDefaultGlobalVolume = MAX_GLOBAL_VOLUME; - StringFixer::ReadString<StringFixer::maybeNullTerminated>(m_szNames[0], fileHeader.songName); + mpt::String::Read<mpt::String::maybeNullTerminated>(m_szNames[0], fileHeader.songName); // Read channel settings for(CHANNELINDEX chn = 0; chn < 16; chn++) @@ -313,7 +313,7 @@ m_nSamples = smp + 1; ModSample &sample = Samples[m_nSamples]; - StringFixer::ReadString<StringFixer::nullTerminated>(m_szNames[m_nSamples], sampleHeader.name); + mpt::String::Read<mpt::String::nullTerminated>(m_szNames[m_nSamples], sampleHeader.name); sampleHeader.ConvertToMPT(sample); sampleHeader.GetSampleFormat().ReadSample(sample, file); } Modified: trunk/OpenMPT/soundlib/Load_gdm.cpp =================================================================== --- trunk/OpenMPT/soundlib/Load_gdm.cpp 2013-05-21 23:01:00 UTC (rev 2168) +++ trunk/OpenMPT/soundlib/Load_gdm.cpp 2013-05-21 23:42:33 UTC (rev 2169) @@ -161,7 +161,7 @@ madeWithTracker = mpt::String::Format("BWSB 2GDM %d.%d (converted from %s)", fileHeader.trackerMajorVer, fileHeader.formatMinorVer, ModTypeToTracker(GetType()).c_str()); // Song name - StringFixer::ReadString<StringFixer::maybeNullTerminated>(m_szNames[0], fileHeader.songTitle); + mpt::String::Read<mpt::String::maybeNullTerminated>(m_szNames[0], fileHeader.songTitle); // Read channel pan map... 0...15 = channel panning, 16 = surround channel, 255 = channel does not exist m_nChannels = 32; @@ -209,8 +209,8 @@ break; } - StringFixer::ReadString<StringFixer::maybeNullTerminated>(m_szNames[smp], gdmSample.name); - StringFixer::ReadString<StringFixer::maybeNullTerminated>(Samples[smp].filename, gdmSample.fileName); + mpt::String::Read<mpt::String::maybeNullTerminated>(m_szNames[smp], gdmSample.name); + mpt::String::Read<mpt::String::maybeNullTerminated>(Samples[smp].filename, gdmSample.fileName); Samples[smp].nC5Speed = gdmSample.c4Hertz; Samples[smp].nGlobalVol = 256; // Not supported in this format Modified: trunk/OpenMPT/soundlib/Load_imf.cpp =================================================================== --- trunk/OpenMPT/soundlib/Load_imf.cpp 2013-05-21 23:01:00 UTC (rev 2168) +++ trunk/OpenMPT/soundlib/Load_imf.cpp 2013-05-21 23:42:33 UTC (rev 2169) @@ -136,7 +136,7 @@ // Convert an IMFInstrument to OpenMPT's internal instrument representation. void ConvertToMPT(ModInstrument &mptIns, SAMPLEINDEX firstSample) const { - StringFixer::ReadString<StringFixer::nullTerminated>(mptIns.name, name); + mpt::String::Read<mpt::String::nullTerminated>(mptIns.name, name); if(smpNum) { @@ -207,7 +207,7 @@ void ConvertToMPT(ModSample &mptSmp) const { mptSmp.Initialize(); - StringFixer::ReadString<StringFixer::nullTerminated>(mptSmp.filename, filename); + mpt::String::Read<mpt::String::nullTerminated>(mptSmp.filename, filename); mptSmp.nLength = length; mptSmp.nLoopStart = loopStart; @@ -413,7 +413,7 @@ ChnSettings[chn].Reset(); ChnSettings[chn].nPan = fileHeader.channels[chn].panning * 256 / 255; - StringFixer::ReadString<StringFixer::nullTerminated>(ChnSettings[chn].szName, fileHeader.channels[chn].name); + mpt::String::Read<mpt::String::nullTerminated>(ChnSettings[chn].szName, fileHeader.channels[chn].name); // TODO: reverb/chorus? switch(fileHeader.channels[chn].status) @@ -461,7 +461,7 @@ SetModFlag(MSF_COMPATIBLE_PLAY, true); // Song Name - StringFixer::ReadString<StringFixer::nullTerminated>(m_szNames[0], fileHeader.title); + mpt::String::Read<mpt::String::nullTerminated>(m_szNames[0], fileHeader.title); m_SongFlags = (fileHeader.flags & IMFFileHeader::linearSlides) ? SONG_LINEARSLIDES : SongFlags(0); m_nDefaultSpeed = fileHeader.tempo; Modified: trunk/OpenMPT/soundlib/Load_it.cpp =================================================================== --- trunk/OpenMPT/soundlib/Load_it.cpp 2013-05-21 23:01:00 UTC (rev 2168) +++ trunk/OpenMPT/soundlib/Load_it.cpp 2013-05-21 23:42:33 UTC (rev 2169) @@ -278,7 +278,7 @@ //-------------------------------------------------------------- { char name[MAX_PATTERNNAME] = ""; - file.ReadString<StringFixer::maybeNullTerminated>(name, MAX_PATTERNNAME); + file.ReadString<mpt::String::maybeNullTerminated>(name, MAX_PATTERNNAME); pattern.SetName(name); } @@ -438,7 +438,7 @@ m_SongFlags.set(SONG_EMBEDMIDICFG, (fileHeader.flags & ITFileHeader::reqEmbeddedMIDIConfig) || (fileHeader.special & ITFileHeader::embedMIDIConfiguration)); m_SongFlags.set(SONG_EXFILTERRANGE, (fileHeader.flags & ITFileHeader::extendedFilterRange) != 0); - StringFixer::ReadString<StringFixer::spacePadded>(m_szNames[0], fileHeader.songname); + mpt::String::Read<mpt::String::spacePadded>(m_szNames[0], fileHeader.songname); // Global Volume m_nDefaultGlobalVolume = fileHeader.globalvol << 1; @@ -599,7 +599,7 @@ for(CHANNELINDEX i = 0; i < readChns; i++) { - chnNames.ReadString<StringFixer::maybeNullTerminated>(ChnSettings[i].szName, MAX_CHANNELNAME); + chnNames.ReadString<mpt::String::maybeNullTerminated>(ChnSettings[i].szName, MAX_CHANNELNAME); } } @@ -661,7 +661,7 @@ { size_t sampleOffset = sampleHeader.ConvertToMPT(Samples[i + 1]); - StringFixer::ReadString<StringFixer::spacePadded>(m_szNames[i + 1], sampleHeader.name); + mpt::String::Read<mpt::String::spacePadded>(m_szNames[i + 1], sampleHeader.name); if((loadFlags & loadSampleData) && file.Seek(sampleOffset)) { @@ -1117,7 +1117,7 @@ MemsetZero(itHeader); dwChnNamLen = 0; itHeader.id = ITFileHeader::itMagic; - StringFixer::WriteString<StringFixer::nullTerminated>(itHeader.songname, m_szNames[0]); + mpt::String::Write<mpt::String::nullTerminated>(itHeader.songname, m_szNames[0]); itHeader.highlight_minor = (uint8)std::min(m_nDefaultRowsPerBeat, ROWINDEX(uint8_max)); itHeader.highlight_major = (uint8)std::min(m_nDefaultRowsPerMeasure, ROWINDEX(uint8_max)); @@ -1562,7 +1562,7 @@ // Old MPT will only consider the IT2.15 compression flag if the header version also indicates IT2.15. itss.ConvertToIT(Samples[nsmp], GetType(), compress, itHeader.cmwt >= 0x215); - StringFixer::WriteString<StringFixer::nullTerminated>(itss.name, m_szNames[nsmp]); + mpt::String::Write<mpt::String::nullTerminated>(itss.name, m_szNames[nsmp]); itss.samplepointer = dwPos; itss.ConvertEndianness(); @@ -1771,8 +1771,8 @@ { // MPT's standard plugin data. Size not specified in file.. grrr.. chunk.ReadConvertEndianness(m_MixPlugins[plug].Info); - StringFixer::SetNullTerminator(m_MixPlugins[plug].Info.szName); - StringFixer::SetNullTerminator(m_MixPlugins[plug].Info.szLibraryName); + mpt::String::SetNullTerminator(m_MixPlugins[plug].Info.szName); + mpt::String::SetNullTerminator(m_MixPlugins[plug].Info.szLibraryName); //data for VST setchunk? size lies just after standard plugin data. FileReader pluginDataChunk = chunk.GetChunk(chunk.ReadUint32LE()); Modified: trunk/OpenMPT/soundlib/Load_itp.cpp =================================================================== --- trunk/OpenMPT/soundlib/Load_itp.cpp 2013-05-21 23:01:00 UTC (rev 2168) +++ trunk/OpenMPT/soundlib/Load_itp.cpp 2013-05-21 23:42:33 UTC (rev 2169) @@ -31,7 +31,7 @@ bool ReadITPString(char (&destBuffer)[destSize], FileReader &file) //---------------------------------------------------------------- { - return file.ReadString<StringFixer::maybeNullTerminated>(destBuffer, file.ReadUint32LE()); + return file.ReadString<mpt::String::maybeNullTerminated>(destBuffer, file.ReadUint32LE()); } @@ -92,7 +92,7 @@ ChnSettings[chn].nPan = static_cast<uint16>(file.ReadUint32LE()); ChnSettings[chn].dwFlags = static_cast<ChannelFlags>(file.ReadUint32LE()); ChnSettings[chn].nVolume = static_cast<uint16>(file.ReadUint32LE()); - file.ReadString<StringFixer::maybeNullTerminated>(ChnSettings[chn].szName, size); + file.ReadString<mpt::String::maybeNullTerminated>(ChnSettings[chn].szName, size); } // Song mix plugins @@ -123,7 +123,7 @@ for(INSTRUMENTINDEX ins = 0; ins < GetNumInstruments(); ins++) { char path[_MAX_PATH]; - file.ReadString<StringFixer::maybeNullTerminated>(path, size); + file.ReadString<mpt::String::maybeNullTerminated>(path, size); m_szInstrumentPath[ins] = path; } @@ -160,7 +160,7 @@ if(pat < numNamedPats) { char patName[MAX_PATTERNNAME]; - pattNames.ReadString<StringFixer::maybeNullTerminated>(patName, patNameLen); + pattNames.ReadString<mpt::String::maybeNullTerminated>(patName, patNameLen); Patterns[pat].SetName(patName); } @@ -199,7 +199,7 @@ if(realSample >= 1 && realSample < MAX_SAMPLES && sampleHeader.id == ITSample::magic) { sampleHeader.ConvertToMPT(Samples[realSample]); - StringFixer::ReadString<StringFixer::nullTerminated>(m_szNames[realSample], sampleHeader.name); + mpt::String::Read<mpt::String::nullTerminated>(m_szNames[realSample], sampleHeader.name); // Read sample data sampleHeader.GetSampleFormat().ReadSample(Samples[realSample], file); @@ -473,7 +473,7 @@ ITSample itss; itss.ConvertToIT(Samples[nsmp], GetType(), false, false); - StringFixer::WriteString<StringFixer::nullTerminated>(itss.name, m_szNames[nsmp]); + mpt::String::Write<mpt::String::nullTerminated>(itss.name, m_szNames[nsmp]); id = nsmp; fwrite(&id, 1, sizeof(id), f); Modified: trunk/OpenMPT/soundlib/Load_mdl.cpp =================================================================== --- trunk/OpenMPT/soundlib/Load_mdl.cpp 2013-05-21 23:01:00 UTC (rev 2168) +++ trunk/OpenMPT/soundlib/Load_mdl.cpp 2013-05-21 23:42:33 UTC (rev 2169) @@ -338,7 +338,7 @@ Log("infoblock: %d bytes\n", blocklen); #endif pmib = (MDLInfoBlock *)(lpStream+dwMemPos); - StringFixer::ReadString<StringFixer::maybeNullTerminated>(m_szNames[0], pmib->songname); + mpt::String::Read<mpt::String::maybeNullTerminated>(m_szNames[0], pmib->songname); norders = pmib->norders; if (norders > MAX_ORDERS) norders = MAX_ORDERS; @@ -439,7 +439,7 @@ } // I give up. better rewrite this crap (or take SchismTracker's MDL loader). - StringFixer::ReadString<StringFixer::maybeNullTerminated>(pIns->name, reinterpret_cast<const char *>(lpStream + dwPos + 2), 32); + mpt::String::Read<mpt::String::maybeNullTerminated>(pIns->name, reinterpret_cast<const char *>(lpStream + dwPos + 2), 32); for (j=0; j<lpStream[dwPos+1]; j++) { @@ -531,8 +531,8 @@ } ModSample &sample = Samples[info->sampleIndex]; - StringFixer::ReadString<StringFixer::maybeNullTerminated>(m_szNames[info->sampleIndex], info->name); - StringFixer::ReadString<StringFixer::maybeNullTerminated>(sample.filename, info->filename); + mpt::String::Read<mpt::String::maybeNullTerminated>(m_szNames[info->sampleIndex], info->name); + mpt::String::Read<mpt::String::maybeNullTerminated>(sample.filename, info->filename); if(pmsh->version > 0) { Modified: trunk/OpenMPT/soundlib/Load_med.cpp =================================================================== --- trunk/OpenMPT/soundlib/Load_med.cpp 2013-05-21 23:01:00 UTC (rev 2168) +++ trunk/OpenMPT/soundlib/Loa... [truncated message content] |
From: <man...@us...> - 2013-05-22 15:56:27
|
Revision: 2170 http://sourceforge.net/p/modplug/code/2170 Author: manxorist Date: 2013-05-22 15:56:18 +0000 (Wed, 22 May 2013) Log Message: ----------- [Ref] Add saturate_cast<T>(Tsrc) add start using it. Modified Paths: -------------- trunk/OpenMPT/common/misc_util.h trunk/OpenMPT/mptrack/test/test.cpp trunk/OpenMPT/soundlib/ITTools.cpp trunk/OpenMPT/soundlib/XMTools.cpp Modified: trunk/OpenMPT/common/misc_util.h =================================================================== --- trunk/OpenMPT/common/misc_util.h 2013-05-21 23:42:33 UTC (rev 2169) +++ trunk/OpenMPT/common/misc_util.h 2013-05-22 15:56:18 UTC (rev 2170) @@ -94,6 +94,50 @@ } +namespace mpt { + +// Saturate the value of src to the domain of Tdst +template <typename Tdst, typename Tsrc> +inline Tdst saturate_cast(Tsrc src) +//------------------------------------- +{ + // This code tries not only to obviously avoid overflows but also to avoid signed/unsigned comparison warnings and type truncation warnings (which in fact would be safe here) by explicit casting. + STATIC_ASSERT(std::numeric_limits<Tdst>::is_integer); + STATIC_ASSERT(std::numeric_limits<Tsrc>::is_integer); + if(std::numeric_limits<Tdst>::is_signed && std::numeric_limits<Tsrc>::is_signed) + { + if(sizeof(Tdst) >= sizeof(Tsrc)) + { + return static_cast<Tdst>(src); + } + return static_cast<Tdst>(std::max<Tsrc>(std::numeric_limits<Tdst>::min(), std::min<Tsrc>(src, std::numeric_limits<Tdst>::max()))); + } else if(!std::numeric_limits<Tdst>::is_signed && !std::numeric_limits<Tsrc>::is_signed) + { + if(sizeof(Tdst) >= sizeof(Tsrc)) + { + return static_cast<Tdst>(src); + } + return static_cast<Tdst>(std::min<Tsrc>(src, std::numeric_limits<Tdst>::max())); + } else if(std::numeric_limits<Tdst>::is_signed && !std::numeric_limits<Tsrc>::is_signed) + { + if(sizeof(Tdst) >= sizeof(Tsrc)) + { + return static_cast<Tdst>(std::min<Tsrc>(src, static_cast<Tsrc>(std::numeric_limits<Tdst>::max()))); + } + return static_cast<Tdst>(std::max<Tsrc>(std::numeric_limits<Tdst>::min(), std::min<Tsrc>(src, std::numeric_limits<Tdst>::max()))); + } else // Tdst unsigned, Tsrc signed + { + if(sizeof(Tdst) >= sizeof(Tsrc)) + { + return static_cast<Tdst>(std::max<Tsrc>(0, src)); + } + return static_cast<Tdst>(std::max<Tsrc>(0, std::min<Tsrc>(src, std::numeric_limits<Tdst>::max()))); + } +} + +} // namespace mpt + + // Limits 'val' to given range. If 'val' is less than 'lowerLimit', 'val' is set to value 'lowerLimit'. // Similarly if 'val' is greater than 'upperLimit', 'val' is set to value 'upperLimit'. // If 'lowerLimit' > 'upperLimit', 'val' won't be modified. @@ -133,7 +177,7 @@ #define CLAMP(number, low, high) MIN(high, MAX(low, number)) #endif - + #ifdef MODPLUG_TRACKER LPCCH LoadResource(LPCTSTR lpName, LPCTSTR lpType, LPCCH& pData, size_t& nSize, HGLOBAL& hglob); std::string GetErrorMessage(DWORD nErrorCode); Modified: trunk/OpenMPT/mptrack/test/test.cpp =================================================================== --- trunk/OpenMPT/mptrack/test/test.cpp 2013-05-21 23:42:33 UTC (rev 2169) +++ trunk/OpenMPT/mptrack/test/test.cpp 2013-05-22 15:56:18 UTC (rev 2170) @@ -255,6 +255,38 @@ VERIFY_EQUAL( Util::Round<int8>(110.1), 110 ); VERIFY_EQUAL( Util::Round<int8>(-110.1), -110 ); + // trivials + VERIFY_EQUAL( mpt::saturate_cast<int>(-1), -1 ); + VERIFY_EQUAL( mpt::saturate_cast<int>(0), 0 ); + VERIFY_EQUAL( mpt::saturate_cast<int>(1), 1 ); + VERIFY_EQUAL( mpt::saturate_cast<int>(std::numeric_limits<int>::min()), std::numeric_limits<int>::min() ); + VERIFY_EQUAL( mpt::saturate_cast<int>(std::numeric_limits<int>::max()), std::numeric_limits<int>::max() ); + + // signed / unsigned + VERIFY_EQUAL( mpt::saturate_cast<int16>(std::numeric_limits<uint16>::min()), std::numeric_limits<uint16>::min() ); + VERIFY_EQUAL( mpt::saturate_cast<int16>(std::numeric_limits<uint16>::max()), std::numeric_limits<int16>::max() ); + VERIFY_EQUAL( mpt::saturate_cast<int32>(std::numeric_limits<uint32>::min()), std::numeric_limits<uint32>::min() ); + VERIFY_EQUAL( mpt::saturate_cast<int32>(std::numeric_limits<uint32>::max()), std::numeric_limits<int32>::max() ); + VERIFY_EQUAL( mpt::saturate_cast<int64>(std::numeric_limits<uint64>::min()), std::numeric_limits<uint64>::min() ); + VERIFY_EQUAL( mpt::saturate_cast<int64>(std::numeric_limits<uint64>::max()), std::numeric_limits<int64>::max() ); + VERIFY_EQUAL( mpt::saturate_cast<uint16>(std::numeric_limits<int16>::min()), std::numeric_limits<uint16>::min() ); + VERIFY_EQUAL( mpt::saturate_cast<uint16>(std::numeric_limits<int16>::max()), std::numeric_limits<int16>::max() ); + VERIFY_EQUAL( mpt::saturate_cast<uint32>(std::numeric_limits<int32>::min()), std::numeric_limits<uint32>::min() ); + VERIFY_EQUAL( mpt::saturate_cast<uint32>(std::numeric_limits<int32>::max()), std::numeric_limits<int32>::max() ); + VERIFY_EQUAL( mpt::saturate_cast<uint64>(std::numeric_limits<int64>::min()), std::numeric_limits<uint64>::min() ); + VERIFY_EQUAL( mpt::saturate_cast<uint64>(std::numeric_limits<int64>::max()), std::numeric_limits<int64>::max() ); + + // overflow + VERIFY_EQUAL( mpt::saturate_cast<int16>(std::numeric_limits<int16>::min() - 1), std::numeric_limits<int16>::min() ); + VERIFY_EQUAL( mpt::saturate_cast<int16>(std::numeric_limits<int16>::max() + 1), std::numeric_limits<int16>::max() ); + VERIFY_EQUAL( mpt::saturate_cast<int32>(std::numeric_limits<int32>::min() - int64(1)), std::numeric_limits<int32>::min() ); + VERIFY_EQUAL( mpt::saturate_cast<int32>(std::numeric_limits<int32>::max() + int64(1)), std::numeric_limits<int32>::max() ); + + VERIFY_EQUAL( mpt::saturate_cast<uint16>(std::numeric_limits<int16>::min() - 1), std::numeric_limits<uint16>::min() ); + VERIFY_EQUAL( mpt::saturate_cast<uint16>(std::numeric_limits<int16>::max() + 1), (uint16)std::numeric_limits<int16>::max() + 1 ); + VERIFY_EQUAL( mpt::saturate_cast<uint32>(std::numeric_limits<int32>::min() - int64(1)), std::numeric_limits<uint32>::min() ); + VERIFY_EQUAL( mpt::saturate_cast<uint32>(std::numeric_limits<int32>::max() + int64(1)), (uint32)std::numeric_limits<int32>::max() + 1 ); + // These should fail to compile //Util::Round<std::string>(1.0); //Util::Round<int64>(1.0); Modified: trunk/OpenMPT/soundlib/ITTools.cpp =================================================================== --- trunk/OpenMPT/soundlib/ITTools.cpp 2013-05-21 23:42:33 UTC (rev 2169) +++ trunk/OpenMPT/soundlib/ITTools.cpp 2013-05-22 15:56:18 UTC (rev 2170) @@ -521,11 +521,11 @@ C5Speed = mptSmp.nC5Speed ? mptSmp.nC5Speed : 8363; // Size and loops - length = std::min(mptSmp.nLength, (SmpLength)uint32_max); - loopbegin = std::min(mptSmp.nLoopStart, (SmpLength)uint32_max); - loopend = std::min(mptSmp.nLoopEnd, (SmpLength)uint32_max); - susloopbegin = std::min(mptSmp.nSustainStart, (SmpLength)uint32_max); - susloopend = std::min(mptSmp.nSustainEnd, (SmpLength)uint32_max); + length = mpt::saturate_cast<uint32>(mptSmp.nLength); + loopbegin = mpt::saturate_cast<uint32>(mptSmp.nLoopStart); + loopend = mpt::saturate_cast<uint32>(mptSmp.nLoopEnd); + susloopbegin = mpt::saturate_cast<uint32>(mptSmp.nSustainStart); + susloopend = mpt::saturate_cast<uint32>(mptSmp.nSustainEnd); // Auto Vibrato settings static const uint8 autovibxm2it[8] = { 0, 2, 4, 1, 3, 0, 0, 0 }; // OpenMPT VibratoType -> IT Vibrato Modified: trunk/OpenMPT/soundlib/XMTools.cpp =================================================================== --- trunk/OpenMPT/soundlib/XMTools.cpp 2013-05-21 23:42:33 UTC (rev 2169) +++ trunk/OpenMPT/soundlib/XMTools.cpp 2013-05-22 15:56:18 UTC (rev 2170) @@ -392,9 +392,9 @@ } // Sample Length and Loops - length = std::min(mptSmp.nLength, (SmpLength)uint32_max); - loopStart = std::min(mptSmp.nLoopStart, (SmpLength)uint32_max); - loopLength = std::min(mptSmp.nLoopEnd - mptSmp.nLoopStart, (SmpLength)uint32_max); + length = mpt::saturate_cast<uint32>(mptSmp.nLength); + loopStart = mpt::saturate_cast<uint32>(mptSmp.nLoopStart); + loopLength = mpt::saturate_cast<uint32>(mptSmp.nLoopEnd - mptSmp.nLoopStart); if(mptSmp.uFlags[CHN_16BIT]) { This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <man...@us...> - 2013-05-23 14:43:18
|
Revision: 2177 http://sourceforge.net/p/modplug/code/2177 Author: manxorist Date: 2013-05-23 14:43:05 +0000 (Thu, 23 May 2013) Log Message: ----------- [Ref] Various fixes regarding interactions of ENABLE_ASM, ENABLE_X86 and NO_REVERB build settings. [Ref] Also disable more code if !ENABLE_ASM. [Fix] Make EQ compile in all cases. Modified Paths: -------------- trunk/OpenMPT/common/BuildSettings.h trunk/OpenMPT/mptrack/Mpdlgs.cpp trunk/OpenMPT/mptrack/Mptrack.cpp trunk/OpenMPT/mptrack/View_smp.cpp trunk/OpenMPT/sounddsp/EQ.cpp trunk/OpenMPT/soundlib/Fastmix.cpp trunk/OpenMPT/soundlib/Mmx_mix.cpp trunk/OpenMPT/soundlib/Snd_defs.h trunk/OpenMPT/soundlib/Sndfile.cpp trunk/OpenMPT/soundlib/Sndfile.h Modified: trunk/OpenMPT/common/BuildSettings.h =================================================================== --- trunk/OpenMPT/common/BuildSettings.h 2013-05-22 23:51:36 UTC (rev 2176) +++ trunk/OpenMPT/common/BuildSettings.h 2013-05-23 14:43:05 UTC (rev 2177) @@ -150,6 +150,14 @@ +// fixing stuff up + +#if !defined(ENABLE_MMX) && !defined(NO_REVERB) +#define NO_REVERB // reverb requires mmx +#endif + + + #if MPT_COMPILER_MSVC #define VC_EXTRALEAN // Exclude rarely-used stuff from Windows headers #endif Modified: trunk/OpenMPT/mptrack/Mpdlgs.cpp =================================================================== --- trunk/OpenMPT/mptrack/Mpdlgs.cpp 2013-05-22 23:51:36 UTC (rev 2176) +++ trunk/OpenMPT/mptrack/Mpdlgs.cpp 2013-05-23 14:43:05 UTC (rev 2177) @@ -125,10 +125,11 @@ CPropertyPage::OnInitDialog(); if(TrackerSettings::Instance().m_MixerSettings.MixerFlags & SNDMIX_SOFTPANNING) CheckDlgButton(IDC_CHECK2, MF_CHECKED); - if(TrackerSettings::Instance().m_MixerSettings.MixerFlags & SNDMIX_ENABLEMMX) CheckDlgButton(IDC_CHECK3, MF_CHECKED); if(m_SoundDeviceFlags & SNDDEV_OPTIONS_EXCLUSIVE) CheckDlgButton(IDC_CHECK4, MF_CHECKED); if(m_SoundDeviceFlags & SNDDEV_OPTIONS_BOOSTTHREADPRIORITY) CheckDlgButton(IDC_CHECK5, MF_CHECKED); // Multimedia extensions +#ifdef ENABLE_ASM + if(TrackerSettings::Instance().m_MixerSettings.MixerFlags & SNDMIX_ENABLEMMX) CheckDlgButton(IDC_CHECK3, MF_CHECKED); ::EnableWindow(::GetDlgItem(m_hWnd, IDC_CHECK3), (CSoundFile::GetSysInfo() & PROCSUPPORT_MMX) ? TRUE : FALSE); if(CSoundFile::GetSysInfo() & PROCSUPPORT_SSE) { @@ -137,6 +138,9 @@ { SetDlgItemText(IDC_CHECK3, _T("Enable 3DNow! acceleration")); } +#else + ::ShowWindow(::GetDlgItem(m_hWnd, IDC_CHECK3), SW_HIDE); +#endif // Sampling Rate UpdateSampleRates(m_nSoundDevice); @@ -441,8 +445,10 @@ void COptionsSoundcard::OnOK() //---------------------------- { +#ifdef ENABLE_ASM + if(IsDlgButtonChecked(IDC_CHECK3)) TrackerSettings::Instance().m_MixerSettings.MixerFlags |= SNDMIX_ENABLEMMX; else TrackerSettings::Instance().m_MixerSettings.MixerFlags &= ~SNDMIX_ENABLEMMX; +#endif if(IsDlgButtonChecked(IDC_CHECK2)) TrackerSettings::Instance().m_MixerSettings.MixerFlags |= SNDMIX_SOFTPANNING; else TrackerSettings::Instance().m_MixerSettings.MixerFlags &= ~SNDMIX_SOFTPANNING; - if(IsDlgButtonChecked(IDC_CHECK3)) TrackerSettings::Instance().m_MixerSettings.MixerFlags |= SNDMIX_ENABLEMMX; else TrackerSettings::Instance().m_MixerSettings.MixerFlags &= ~SNDMIX_ENABLEMMX; m_SoundDeviceFlags = 0; if(IsDlgButtonChecked(IDC_CHECK4)) m_SoundDeviceFlags |= SNDDEV_OPTIONS_EXCLUSIVE; if(IsDlgButtonChecked(IDC_CHECK5)) m_SoundDeviceFlags |= SNDDEV_OPTIONS_BOOSTTHREADPRIORITY; @@ -787,7 +793,9 @@ if (IsDlgButtonChecked(IDC_CHECK4)) dwQuality |= SNDDSP_SURROUND; if (IsDlgButtonChecked(IDC_CHECK5)) dwQuality |= SNDDSP_NOISEREDUCTION; #endif +#ifndef NO_REVERB if (IsDlgButtonChecked(IDC_CHECK6)) dwQuality |= SNDDSP_REVERB; +#endif dwSrcMode = m_CbnResampling.GetCurSel(); #ifndef NO_DSP Modified: trunk/OpenMPT/mptrack/Mptrack.cpp =================================================================== --- trunk/OpenMPT/mptrack/Mptrack.cpp 2013-05-22 23:51:36 UTC (rev 2176) +++ trunk/OpenMPT/mptrack/Mptrack.cpp 2013-05-23 14:43:05 UTC (rev 2177) @@ -867,6 +867,8 @@ AddDocTemplate(m_pModTemplate); // Initialize Audio +#ifdef ENABLE_ASM + // rough heuristic to select less cpu consuming defaults for old CPUs DWORD sysinfo = CSoundFile::GetSysInfo(); if(sysinfo & PROCSUPPORT_MMX) { @@ -877,6 +879,10 @@ { TrackerSettings::Instance().m_ResamplerSettings.SrcMode = SRCMODE_POLYPHASE; } +#else + // just use a sane default + TrackerSettings::Instance().m_ResamplerSettings.SrcMode = SRCMODE_POLYPHASE; +#endif // Load Midi Library if (m_szConfigFileName[0]) ImportMidiConfig(m_szConfigFileName); Modified: trunk/OpenMPT/mptrack/View_smp.cpp =================================================================== --- trunk/OpenMPT/mptrack/View_smp.cpp 2013-05-22 23:51:36 UTC (rev 2176) +++ trunk/OpenMPT/mptrack/View_smp.cpp 2013-05-23 14:43:05 UTC (rev 2177) @@ -673,7 +673,9 @@ int32 y0 = 0, xmax, poshi; uint64 posincr, posfrac; +#ifdef ENABLE_ASM DWORD sysinfo = CSoundFile::GetSysInfo(); +#endif if (len <= 0) return; smplsize = (uFlags & CHN_16BIT) ? 2 : 1; Modified: trunk/OpenMPT/sounddsp/EQ.cpp =================================================================== --- trunk/OpenMPT/sounddsp/EQ.cpp 2013-05-22 23:51:36 UTC (rev 2176) +++ trunk/OpenMPT/sounddsp/EQ.cpp 2013-05-23 14:43:05 UTC (rev 2177) @@ -17,14 +17,22 @@ #define EQ_BANDWIDTH 2.0 #define EQ_ZERO 0.000001 +extern void C_StereoMixToFloat(const int *pSrc, float *pOut1, float *pOut2, UINT nCount, const float _i2fc); +extern void C_FloatToStereoMix(const float *pIn1, const float *pIn2, int *pOut, UINT nCount, const float _f2ic); +extern void C_MonoMixToFloat(const int *pSrc, float *pOut, UINT nCount, const float _i2fc); +extern void C_FloatToMonoMix(const float *pIn, int *pOut, UINT nCount, const float _f2ic); + +#ifdef ENABLE_X86 extern void X86_StereoMixToFloat(const int *pSrc, float *pOut1, float *pOut2, UINT nCount, const float _i2fc); extern void X86_FloatToStereoMix(const float *pIn1, const float *pIn2, int *pOut, UINT nCount, const float _f2ic); extern void X86_MonoMixToFloat(const int *pSrc, float *pOut, UINT nCount, const float _i2fc); extern void X86_FloatToMonoMix(const float *pIn, int *pOut, UINT nCount, const float _f2ic); +#endif #ifdef ENABLE_SSE extern void SSE_MonoMixToFloat(const int *pSrc, float *pOut, UINT nCount, const float _i2fc); #endif + #ifdef ENABLE_3DNOW extern void AMD_MonoMixToFloat(const int *pSrc, float *pOut, UINT nCount, const float _i2fc); extern void AMD_FloatToMonoMix(const float *pIn, int *pOut, UINT nCount, const float _f2ic); @@ -325,19 +333,27 @@ void CEQ::ProcessMono(int *pbuffer, float *MixFloatBuffer, UINT nCount, CSoundFilePlayConfig &config) -//---------------------------------------------------------------------------------------------------- +//--------------------------------------------------------------------------------------------------- { +#ifdef ENABLE_X86 X86_MonoMixToFloat(pbuffer, MixFloatBuffer, nCount, config.getIntToFloat()); +#else + C_MonoMixToFloat(pbuffer, MixFloatBuffer, nCount, config.getIntToFloat()); +#endif for (UINT b=0; b<MAX_EQ_BANDS; b++) { if ((gEQ[b].bEnable) && (gEQ[b].Gain != 1.0f)) EQFilter(&gEQ[b], MixFloatBuffer, nCount); } +#ifdef ENABLE_X86 X86_FloatToMonoMix(MixFloatBuffer, pbuffer, nCount, config.getFloatToInt()); +#else + C_FloatToMonoMix(MixFloatBuffer, pbuffer, nCount, config.getFloatToInt()); +#endif } void CEQ::ProcessStereo(int *pbuffer, float *MixFloatBuffer, UINT nCount, CSoundFilePlayConfig &config, DWORD SoundSetupFlags, DWORD SysInfoFlags) -//------------------------------------------------------------------------------------------------------------------------------------------------- +//------------------------------------------------------------------------------------------------------------------------------------------------ { #ifdef ENABLE_SSE @@ -388,7 +404,15 @@ #endif // ENABLE_3DNOW { + + UNREFERENCED_PARAMETER(SoundSetupFlags); + UNREFERENCED_PARAMETER(SysInfoFlags); + +#ifdef ENABLE_X86 X86_StereoMixToFloat(pbuffer, MixFloatBuffer, MixFloatBuffer+MIXBUFFERSIZE, nCount, config.getIntToFloat()); +#else + C_StereoMixToFloat(pbuffer, MixFloatBuffer, MixFloatBuffer+MIXBUFFERSIZE, nCount, config.getIntToFloat()); +#endif for (UINT bl=0; bl<MAX_EQ_BANDS; bl++) { @@ -399,7 +423,12 @@ if ((gEQ[br].bEnable) && (gEQ[br].Gain != 1.0f)) EQFilter(&gEQ[br], MixFloatBuffer+MIXBUFFERSIZE, nCount); } +#ifdef ENABLE_X86 X86_FloatToStereoMix(MixFloatBuffer, MixFloatBuffer+MIXBUFFERSIZE, pbuffer, nCount, config.getFloatToInt()); +#else + C_FloatToStereoMix(MixFloatBuffer, MixFloatBuffer+MIXBUFFERSIZE, pbuffer, nCount, config.getFloatToInt()); +#endif + } } Modified: trunk/OpenMPT/soundlib/Fastmix.cpp =================================================================== --- trunk/OpenMPT/soundlib/Fastmix.cpp 2013-05-22 23:51:36 UTC (rev 2176) +++ trunk/OpenMPT/soundlib/Fastmix.cpp 2013-05-23 14:43:05 UTC (rev 2177) @@ -1754,6 +1754,7 @@ VOID CSoundFile::StereoMixToFloat(const int *pSrc, float *pOut1, float *pOut2, UINT nCount) //----------------------------------------------------------------------------------------- { +#ifdef ENABLE_ASM if(m_MixerSettings.MixerFlags & SNDMIX_ENABLEMMX) { #ifdef ENABLE_SSE @@ -1771,17 +1772,19 @@ } #endif // ENABLE_3DNOW } +#endif // ENABLE_ASM #ifdef ENABLE_X86 X86_StereoMixToFloat(pSrc, pOut1, pOut2, nCount, m_PlayConfig.getIntToFloat()); -#else +#else // !ENABLE_X86 C_StereoMixToFloat(pSrc, pOut1, pOut2, nCount, m_PlayConfig.getIntToFloat()); -#endif +#endif // ENABLE_X86 } VOID CSoundFile::FloatToStereoMix(const float *pIn1, const float *pIn2, int *pOut, UINT nCount) //--------------------------------------------------------------------------------------------- { +#ifdef ENABLE_ASM if(m_MixerSettings.MixerFlags & SNDMIX_ENABLEMMX) { #ifdef ENABLE_3DNOW @@ -1792,11 +1795,12 @@ } #endif // ENABLE_3DNOW } +#endif // ENABLE_ASM #ifdef ENABLE_X86 X86_FloatToStereoMix(pIn1, pIn2, pOut, nCount, m_PlayConfig.getFloatToInt()); -#else +#else // !ENABLE_X86 C_FloatToStereoMix(pIn1, pIn2, pOut, nCount, m_PlayConfig.getFloatToInt()); -#endif +#endif // ENABLE_X86 } Modified: trunk/OpenMPT/soundlib/Mmx_mix.cpp =================================================================== --- trunk/OpenMPT/soundlib/Mmx_mix.cpp 2013-05-22 23:51:36 UTC (rev 2176) +++ trunk/OpenMPT/soundlib/Mmx_mix.cpp 2013-05-23 14:43:05 UTC (rev 2177) @@ -24,6 +24,7 @@ #include "Sndfile.h" +#ifdef ENABLE_ASM DWORD CSoundFile::GetSysInfo() //---------------------------- { @@ -83,6 +84,7 @@ return 0; #endif } +#endif //////////////////////////////////////////////////////////////////////////////////// Modified: trunk/OpenMPT/soundlib/Snd_defs.h =================================================================== --- trunk/OpenMPT/soundlib/Snd_defs.h 2013-05-22 23:51:36 UTC (rev 2176) +++ trunk/OpenMPT/soundlib/Snd_defs.h 2013-05-23 14:43:05 UTC (rev 2177) @@ -242,11 +242,13 @@ #define DNA_NOTEFADE 2 +#ifdef ENABLE_ASM #define PROCSUPPORT_CPUID 0x01 #define PROCSUPPORT_MMX 0x02 // Processor supports MMX instructions #define PROCSUPPORT_MMXEX 0x04 // Processor supports AMD MMX extensions #define PROCSUPPORT_3DNOW 0x08 // Processor supports AMD 3DNow! instructions #define PROCSUPPORT_SSE 0x10 // Processor supports SSE instructions +#endif // Module flags @@ -294,14 +296,19 @@ #define SNDDSP_MEGABASS 0x02 // bass expansion #define SNDDSP_SURROUND 0x08 // surround mix #endif // NO_DSP +#ifndef NO_REVERB #define SNDDSP_REVERB 0x20 // apply reverb +#endif // NO_REVERB #ifndef NO_EQ #define SNDDSP_EQ 0x80 // apply EQ #endif // NO_EQ #define SNDMIX_SOFTPANNING 0x10 // soft panning mode (this is forced with mixmode RC3 and later) + // Misc Flags (can safely be turned on or off) +#ifdef ENABLE_ASM #define SNDMIX_ENABLEMMX 0x08 // use MMX-accelerated code +#endif //#define SNDMIX_NOBACKWARDJUMPS 0x40000 // stop when jumping back in the order (currently unused as it seems) #define SNDMIX_MAXDEFAULTPAN 0x80000 // Used by the MOD loader (currently unused) Modified: trunk/OpenMPT/soundlib/Sndfile.cpp =================================================================== --- trunk/OpenMPT/soundlib/Sndfile.cpp 2013-05-22 23:51:36 UTC (rev 2176) +++ trunk/OpenMPT/soundlib/Sndfile.cpp 2013-05-23 14:43:05 UTC (rev 2177) @@ -402,7 +402,11 @@ #endif //---------------------- { +#ifdef ENABLE_ASM gdwSysInfo = GetSysInfo(); +#else + gdwSysInfo = 0; +#endif MemsetZero(MixSoundBuffer); MemsetZero(MixRearBuffer); #ifndef NO_REVERB @@ -887,7 +891,9 @@ void CSoundFile::SetDspEffects(DWORD DSPMask) //------------------------------------------- { +#ifdef ENABLE_ASM if(!(GetSysInfo() & PROCSUPPORT_MMX)) DSPMask &= ~SNDDSP_REVERB; +#endif m_MixerSettings.DSPMask = DSPMask; InitPlayer(FALSE); } Modified: trunk/OpenMPT/soundlib/Sndfile.h =================================================================== --- trunk/OpenMPT/soundlib/Sndfile.h 2013-05-22 23:51:36 UTC (rev 2176) +++ trunk/OpenMPT/soundlib/Sndfile.h 2013-05-23 14:43:05 UTC (rev 2177) @@ -594,7 +594,9 @@ void InitPlayer(BOOL bReset=FALSE); void SetDspEffects(DWORD DSPMask); DWORD GetSampleRate() { return m_MixerSettings.gdwMixingFreq; } +#ifdef ENABLE_ASM static DWORD GetSysInfo(); +#endif #ifndef NO_EQ void SetEQGains(const UINT *pGains, UINT nBands, const UINT *pFreqs=NULL, BOOL bReset=FALSE) { m_EQ.SetEQGains(pGains, nBands, pFreqs, bReset, m_MixerSettings.gdwMixingFreq); } // 0=-12dB, 32=+12dB #endif // NO_EQ This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <man...@us...> - 2013-05-24 20:22:20
|
Revision: 2183 http://sourceforge.net/p/modplug/code/2183 Author: manxorist Date: 2013-05-24 20:22:12 +0000 (Fri, 24 May 2013) Log Message: ----------- [Mod] "Enable SSE acceleration" enabled/disabled sse (or 3dnow) inline asm exactly in two places: float<->int conversions and the equalizer. Other codepaths in OpenMPT ignored this settings probably since forever. Also, SSE acceleration of course did get automatically disabled if the CPU does not support these instructions. Remove the user visiable option alltogether and always use SSE when the CPU supports it. [Ref] Rename SysInfo to ProcSupport which describes its semantics way better. [Ref] Move the procsupport flags out of CSoundFile into a global variable in mmx_mix.cpp. Initialize it once at program startup. Also, disable use of inline asm in libopenmpt to get better test exposure of the C implementations on WIN32. [Ref] Move all these float<->int conversion functiosn into mmx_mix.cpp and export exacly one wrapper from there. [Ref] Do some related cleanups. Modified Paths: -------------- trunk/OpenMPT/common/BuildSettings.h trunk/OpenMPT/mptrack/Mpdlgs.cpp trunk/OpenMPT/mptrack/Mptrack.cpp trunk/OpenMPT/mptrack/View_smp.cpp trunk/OpenMPT/mptrack/Vstplug.cpp trunk/OpenMPT/mptrack/mptrack.rc trunk/OpenMPT/sounddsp/EQ.cpp trunk/OpenMPT/sounddsp/EQ.h trunk/OpenMPT/soundlib/Fastmix.cpp trunk/OpenMPT/soundlib/Mmx_mix.cpp trunk/OpenMPT/soundlib/Snd_defs.h trunk/OpenMPT/soundlib/Sndfile.cpp trunk/OpenMPT/soundlib/Sndfile.h trunk/OpenMPT/soundlib/Sndmix.cpp Modified: trunk/OpenMPT/common/BuildSettings.h =================================================================== --- trunk/OpenMPT/common/BuildSettings.h 2013-05-24 20:01:34 UTC (rev 2182) +++ trunk/OpenMPT/common/BuildSettings.h 2013-05-24 20:22:12 UTC (rev 2183) @@ -16,18 +16,25 @@ -// Do not use precompiled headers (prevents include of commonly used headers in stdafx.h) #ifdef MODPLUG_TRACKER + //#define NO_PCH + +// Use inline assembly at all +#define ENABLE_ASM + #else + +// Do not use precompiled headers (prevents include of commonly used headers in stdafx.h) #define NO_PCH + +// Do not use inline asm in library builds. There is just about no codepath which would use it anyway. +//#define ENABLE_ASM + #endif -// Use inline assembly at all -#define ENABLE_ASM - // inline assembly requires MSVC compiler #if defined(ENABLE_ASM) && MPT_COMPILER_MSVC && defined(_M_IX86) Modified: trunk/OpenMPT/mptrack/Mpdlgs.cpp =================================================================== --- trunk/OpenMPT/mptrack/Mpdlgs.cpp 2013-05-24 20:01:34 UTC (rev 2182) +++ trunk/OpenMPT/mptrack/Mpdlgs.cpp 2013-05-24 20:22:12 UTC (rev 2183) @@ -127,20 +127,6 @@ if(TrackerSettings::Instance().m_MixerSettings.MixerFlags & SNDMIX_SOFTPANNING) CheckDlgButton(IDC_CHECK2, MF_CHECKED); if(m_SoundDeviceFlags & SNDDEV_OPTIONS_EXCLUSIVE) CheckDlgButton(IDC_CHECK4, MF_CHECKED); if(m_SoundDeviceFlags & SNDDEV_OPTIONS_BOOSTTHREADPRIORITY) CheckDlgButton(IDC_CHECK5, MF_CHECKED); - // Multimedia extensions -#ifdef ENABLE_ASM - if(TrackerSettings::Instance().m_MixerSettings.MixerFlags & SNDMIX_ENABLEMMX) CheckDlgButton(IDC_CHECK3, MF_CHECKED); - ::EnableWindow(::GetDlgItem(m_hWnd, IDC_CHECK3), (CSoundFile::GetSysInfo() & PROCSUPPORT_MMX) ? TRUE : FALSE); - if(CSoundFile::GetSysInfo() & PROCSUPPORT_SSE) - { - SetDlgItemText(IDC_CHECK3, _T("Enable SSE acceleration")); - } else if (CSoundFile::GetSysInfo() & PROCSUPPORT_3DNOW) - { - SetDlgItemText(IDC_CHECK3, _T("Enable 3DNow! acceleration")); - } -#else - ::ShowWindow(::GetDlgItem(m_hWnd, IDC_CHECK3), SW_HIDE); -#endif // Sampling Rate UpdateSampleRates(m_nSoundDevice); @@ -445,9 +431,6 @@ void COptionsSoundcard::OnOK() //---------------------------- { -#ifdef ENABLE_ASM - if(IsDlgButtonChecked(IDC_CHECK3)) TrackerSettings::Instance().m_MixerSettings.MixerFlags |= SNDMIX_ENABLEMMX; else TrackerSettings::Instance().m_MixerSettings.MixerFlags &= ~SNDMIX_ENABLEMMX; -#endif if(IsDlgButtonChecked(IDC_CHECK2)) TrackerSettings::Instance().m_MixerSettings.MixerFlags |= SNDMIX_SOFTPANNING; else TrackerSettings::Instance().m_MixerSettings.MixerFlags &= ~SNDMIX_SOFTPANNING; m_SoundDeviceFlags = 0; if(IsDlgButtonChecked(IDC_CHECK4)) m_SoundDeviceFlags |= SNDDEV_OPTIONS_EXCLUSIVE; @@ -643,7 +626,7 @@ } } m_CbnReverbPreset.SetCurSel(nSel); - if (!(CSoundFile::GetSysInfo() & PROCSUPPORT_MMX)) + if(!(GetProcSupport() & PROCSUPPORT_MMX)) { ::EnableWindow(::GetDlgItem(m_hWnd, IDC_CHECK6), FALSE); m_SbReverbDepth.EnableWindow(FALSE); Modified: trunk/OpenMPT/mptrack/Mptrack.cpp =================================================================== --- trunk/OpenMPT/mptrack/Mptrack.cpp 2013-05-24 20:01:34 UTC (rev 2182) +++ trunk/OpenMPT/mptrack/Mptrack.cpp 2013-05-24 20:22:12 UTC (rev 2183) @@ -868,14 +868,13 @@ // Initialize Audio #ifdef ENABLE_ASM + InitProcSupport(); // rough heuristic to select less cpu consuming defaults for old CPUs - DWORD sysinfo = CSoundFile::GetSysInfo(); - if(sysinfo & PROCSUPPORT_MMX) + if(GetProcSupport() & PROCSUPPORT_MMX) { - TrackerSettings::Instance().m_MixerSettings.MixerFlags |= SNDMIX_ENABLEMMX; TrackerSettings::Instance().m_ResamplerSettings.SrcMode = SRCMODE_SPLINE; } - if(sysinfo & PROCSUPPORT_MMXEX) + if(GetProcSupport() & PROCSUPPORT_MMXEX) { TrackerSettings::Instance().m_ResamplerSettings.SrcMode = SRCMODE_POLYPHASE; } Modified: trunk/OpenMPT/mptrack/View_smp.cpp =================================================================== --- trunk/OpenMPT/mptrack/View_smp.cpp 2013-05-24 20:01:34 UTC (rev 2182) +++ trunk/OpenMPT/mptrack/View_smp.cpp 2013-05-24 20:22:12 UTC (rev 2183) @@ -673,10 +673,6 @@ int32 y0 = 0, xmax, poshi; uint64 posincr, posfrac; -#ifdef ENABLE_ASM - DWORD sysinfo = CSoundFile::GetSysInfo(); -#endif - if (len <= 0) return; smplsize = (uFlags & CHN_16BIT) ? 2 : 1; if (uFlags & CHN_STEREO) smplsize *= 2; @@ -720,7 +716,7 @@ smin = 32767; smax = -32768; #ifdef ENABLE_MMX - if (sysinfo & PROCSUPPORT_MMXEX) + if(GetProcSupport() & PROCSUPPORT_MMXEX) { mmxex_findminmax16(p, scanlen, smplsize, &smin, &smax); } else @@ -743,7 +739,7 @@ smin = 127; smax = -128; #ifdef ENABLE_MMX - if (sysinfo & PROCSUPPORT_MMXEX) + if(GetProcSupport() & PROCSUPPORT_MMXEX) { mmxex_findminmax8(p, scanlen, smplsize, &smin, &smax); } else Modified: trunk/OpenMPT/mptrack/Vstplug.cpp =================================================================== --- trunk/OpenMPT/mptrack/Vstplug.cpp 2013-05-24 20:01:34 UTC (rev 2182) +++ trunk/OpenMPT/mptrack/Vstplug.cpp 2013-05-24 20:22:12 UTC (rev 2183) @@ -3415,7 +3415,7 @@ #ifdef ENABLE_MMX #ifdef ENABLE_SSE - if(CSoundFile::GetSysInfo() & PROCSUPPORT_SSE) + if(GetProcSupport() & PROCSUPPORT_SSE) { SSEInterleaveFloatToInt16(inputs[0], inputs[1], samples); m_pMediaProcess->Process(samples * 2 * sizeof(int16), reinterpret_cast<BYTE *>(m_pMixBuffer), m_DataTime, DMO_INPLACE_NORMAL); Modified: trunk/OpenMPT/mptrack/mptrack.rc =================================================================== --- trunk/OpenMPT/mptrack/mptrack.rc 2013-05-24 20:01:34 UTC (rev 2182) +++ trunk/OpenMPT/mptrack/mptrack.rc 2013-05-24 20:22:12 UTC (rev 2183) @@ -1267,7 +1267,6 @@ LTEXT "Max. Polyphony:",IDC_STATIC,12,102,57,12,SS_CENTERIMAGE COMBOBOX IDC_COMBO4,78,102,72,88,CBS_DROPDOWNLIST | WS_TABSTOP CONTROL "Soft Panning",IDC_CHECK2,"Button",BS_AUTOCHECKBOX | WS_TABSTOP,12,138,78,12 - CONTROL "Enable MMX Acceleration",IDC_CHECK3,"Button",BS_AUTOCHECKBOX | WS_TABSTOP,96,138,156,12 LTEXT "Stereo Separation:",IDC_STATIC,12,157,62,8 LTEXT "100%",IDC_TEXT1,80,157,20,8 RTEXT "Low",IDC_STATIC,22,168,15,14,SS_CENTERIMAGE Modified: trunk/OpenMPT/sounddsp/EQ.cpp =================================================================== --- trunk/OpenMPT/sounddsp/EQ.cpp 2013-05-24 20:01:34 UTC (rev 2182) +++ trunk/OpenMPT/sounddsp/EQ.cpp 2013-05-24 20:22:12 UTC (rev 2183) @@ -17,31 +17,8 @@ #define EQ_BANDWIDTH 2.0 #define EQ_ZERO 0.000001 -extern void C_StereoMixToFloat(const int *pSrc, float *pOut1, float *pOut2, UINT nCount, const float _i2fc); -extern void C_FloatToStereoMix(const float *pIn1, const float *pIn2, int *pOut, UINT nCount, const float _f2ic); -extern void C_MonoMixToFloat(const int *pSrc, float *pOut, UINT nCount, const float _i2fc); -extern void C_FloatToMonoMix(const float *pIn, int *pOut, UINT nCount, const float _f2ic); -#ifdef ENABLE_X86 -extern void X86_StereoMixToFloat(const int *pSrc, float *pOut1, float *pOut2, UINT nCount, const float _i2fc); -extern void X86_FloatToStereoMix(const float *pIn1, const float *pIn2, int *pOut, UINT nCount, const float _f2ic); -extern void X86_MonoMixToFloat(const int *pSrc, float *pOut, UINT nCount, const float _i2fc); -extern void X86_FloatToMonoMix(const float *pIn, int *pOut, UINT nCount, const float _f2ic); -#endif -#ifdef ENABLE_SSE -extern void SSE_MonoMixToFloat(const int *pSrc, float *pOut, UINT nCount, const float _i2fc); -#endif - -#ifdef ENABLE_3DNOW -extern void AMD_MonoMixToFloat(const int *pSrc, float *pOut, UINT nCount, const float _i2fc); -extern void AMD_FloatToMonoMix(const float *pIn, int *pOut, UINT nCount, const float _f2ic); -#endif - - - - - static const UINT gEqLinearToDB[33] = { 16, 19, 22, 25, 28, 31, 34, 37, @@ -335,25 +312,17 @@ void CEQ::ProcessMono(int *pbuffer, float *MixFloatBuffer, UINT nCount, CSoundFilePlayConfig &config) //--------------------------------------------------------------------------------------------------- { -#ifdef ENABLE_X86 - X86_MonoMixToFloat(pbuffer, MixFloatBuffer, nCount, config.getIntToFloat()); -#else - C_MonoMixToFloat(pbuffer, MixFloatBuffer, nCount, config.getIntToFloat()); -#endif + MonoMixToFloat(pbuffer, MixFloatBuffer, nCount, config.getIntToFloat()); for (UINT b=0; b<MAX_EQ_BANDS; b++) { if ((gEQ[b].bEnable) && (gEQ[b].Gain != 1.0f)) EQFilter(&gEQ[b], MixFloatBuffer, nCount); } -#ifdef ENABLE_X86 - X86_FloatToMonoMix(MixFloatBuffer, pbuffer, nCount, config.getFloatToInt()); -#else - C_FloatToMonoMix(MixFloatBuffer, pbuffer, nCount, config.getFloatToInt()); -#endif + FloatToMonoMix(MixFloatBuffer, pbuffer, nCount, config.getFloatToInt()); } -void CEQ::ProcessStereo(int *pbuffer, float *MixFloatBuffer, UINT nCount, CSoundFilePlayConfig &config, DWORD SoundSetupFlags, DWORD SysInfoFlags) -//------------------------------------------------------------------------------------------------------------------------------------------------ +void CEQ::ProcessStereo(int *pbuffer, float *MixFloatBuffer, UINT nCount, CSoundFilePlayConfig &config) +//----------------------------------------------------------------------------------------------------- { #ifdef ENABLE_SSE @@ -361,10 +330,10 @@ // Still allow the check, because the user can turn this on/off - if ((SysInfoFlags & PROCSUPPORT_SSE) && (SoundSetupFlags & SNDMIX_ENABLEMMX)) + if(GetProcSupport() & PROCSUPPORT_SSE) { int sse_state, sse_eqstate; - SSE_MonoMixToFloat(pbuffer, MixFloatBuffer, nCount*2, config.getIntToFloat()); + MonoMixToFloat(pbuffer, MixFloatBuffer, nCount*2, config.getIntToFloat()); _asm stmxcsr sse_state; sse_eqstate = sse_state | 0xFF80; @@ -376,7 +345,7 @@ } _asm ldmxcsr sse_state; - X86_FloatToMonoMix(MixFloatBuffer, pbuffer, nCount*2, config.getFloatToInt()); + FloatToMonoMix(MixFloatBuffer, pbuffer, nCount*2, config.getFloatToInt()); } else @@ -387,9 +356,9 @@ // We still perform the MMX check because the user can enable/disable this - if ((SysInfoFlags & PROCSUPPORT_3DNOW) && (SoundSetupFlags & SNDMIX_ENABLEMMX)) + if(GetProcSupport() & PROCSUPPORT_3DNOW) { - AMD_MonoMixToFloat(pbuffer, MixFloatBuffer, nCount*2, config.getIntToFloat()); + MonoMixToFloat(pbuffer, MixFloatBuffer, nCount*2, config.getIntToFloat()); for (UINT b=0; b<MAX_EQ_BANDS; b++) { @@ -398,21 +367,14 @@ AMD_StereoEQ(&gEQ[b], &gEQ[b+MAX_EQ_BANDS], MixFloatBuffer, nCount); } - AMD_FloatToMonoMix(MixFloatBuffer, pbuffer, nCount*2, config.getFloatToInt()); + FloatToMonoMix(MixFloatBuffer, pbuffer, nCount*2, config.getFloatToInt()); } else #endif // ENABLE_3DNOW { - UNREFERENCED_PARAMETER(SoundSetupFlags); - UNREFERENCED_PARAMETER(SysInfoFlags); - -#ifdef ENABLE_X86 - X86_StereoMixToFloat(pbuffer, MixFloatBuffer, MixFloatBuffer+MIXBUFFERSIZE, nCount, config.getIntToFloat()); -#else - C_StereoMixToFloat(pbuffer, MixFloatBuffer, MixFloatBuffer+MIXBUFFERSIZE, nCount, config.getIntToFloat()); -#endif + StereoMixToFloat(pbuffer, MixFloatBuffer, MixFloatBuffer+MIXBUFFERSIZE, nCount, config.getIntToFloat()); for (UINT bl=0; bl<MAX_EQ_BANDS; bl++) { @@ -423,11 +385,7 @@ if ((gEQ[br].bEnable) && (gEQ[br].Gain != 1.0f)) EQFilter(&gEQ[br], MixFloatBuffer+MIXBUFFERSIZE, nCount); } -#ifdef ENABLE_X86 - X86_FloatToStereoMix(MixFloatBuffer, MixFloatBuffer+MIXBUFFERSIZE, pbuffer, nCount, config.getFloatToInt()); -#else - C_FloatToStereoMix(MixFloatBuffer, MixFloatBuffer+MIXBUFFERSIZE, pbuffer, nCount, config.getFloatToInt()); -#endif + FloatToStereoMix(MixFloatBuffer, MixFloatBuffer+MIXBUFFERSIZE, pbuffer, nCount, config.getFloatToInt()); } } Modified: trunk/OpenMPT/sounddsp/EQ.h =================================================================== --- trunk/OpenMPT/sounddsp/EQ.h 2013-05-24 20:01:34 UTC (rev 2182) +++ trunk/OpenMPT/sounddsp/EQ.h 2013-05-24 20:22:12 UTC (rev 2183) @@ -44,7 +44,7 @@ ~CEQ() {} public: void Initialize(BOOL bReset, DWORD MixingFreq); - void ProcessStereo(int *pbuffer, float *MixFloatBuffer, UINT nCount, CSoundFilePlayConfig &config, DWORD SoundSetupFlags, DWORD SysInfoFlags); + void ProcessStereo(int *pbuffer, float *MixFloatBuffer, UINT nCount, CSoundFilePlayConfig &config); void ProcessMono(int *pbuffer, float *MixFloatBuffer, UINT nCount, CSoundFilePlayConfig &config); void SetEQGains(const UINT *pGains, UINT nGains, const UINT *pFreqs, BOOL bReset, DWORD MixingFreq); }; Modified: trunk/OpenMPT/soundlib/Fastmix.cpp =================================================================== --- trunk/OpenMPT/soundlib/Fastmix.cpp 2013-05-24 20:01:34 UTC (rev 2182) +++ trunk/OpenMPT/soundlib/Fastmix.cpp 2013-05-24 20:22:12 UTC (rev 2183) @@ -460,29 +460,12 @@ ///////////////////////////////////////////////////// // -extern void X86_StereoMixToFloat(const int *pSrc, float *pOut1, float *pOut2, UINT nCount, const float _i2fc); -extern void X86_FloatToStereoMix(const float *pIn1, const float *pIn2, int *pOut, UINT nCount, const float _f2ic); -extern void C_StereoMixToFloat(const int *pSrc, float *pOut1, float *pOut2, UINT nCount, const float _i2fc); -extern void C_FloatToStereoMix(const float *pIn1, const float *pIn2, int *pOut, UINT nCount, const float _f2ic); void InitMixBuffer(int *pBuffer, UINT nSamples); void EndChannelOfs(ModChannel *pChannel, int *pBuffer, UINT nSamples); void StereoFill(int *pBuffer, UINT nSamples, LPLONG lpROfs, LPLONG lpLOfs); -#ifdef ENABLE_3DNOW -extern void AMD_StereoMixToFloat(const int *pSrc, float *pOut1, float *pOut2, UINT nCount, const float _i2fc); -extern void AMD_FloatToStereoMix(const float *pIn1, const float *pIn2, int *pOut, UINT nCount, const float _f2ic); -extern void AMD_MonoMixToFloat(const int *pSrc, float *pOut, UINT nCount, const float _i2fc); -extern void AMD_FloatToMonoMix(const float *pIn, int *pOut, UINT nCount, const float _f2ic); -#endif - -#ifdef ENABLE_SSE -extern void SSE_StereoMixToFloat(const int *pSrc, float *pOut1, float *pOut2, UINT nCount, const float _i2fc); -extern void SSE_MonoMixToFloat(const int *pSrc, float *pOut, UINT nCount, const float _i2fc); -#endif - - ///////////////////////////////////////////////////// // Mono samples functions @@ -1502,9 +1485,9 @@ pbuffer = MixSoundBuffer; #ifndef NO_REVERB #ifdef ENABLE_MMX - if((m_MixerSettings.DSPMask & SNDDSP_REVERB) && (gdwSysInfo & PROCSUPPORT_MMX) && !pChannel->dwFlags[CHN_NOREVERB]) + if((m_MixerSettings.DSPMask & SNDDSP_REVERB) && (GetProcSupport() & PROCSUPPORT_MMX) && !pChannel->dwFlags[CHN_NOREVERB]) pbuffer = MixReverbBuffer; - if(pChannel->dwFlags[CHN_REVERB] && (gdwSysInfo & PROCSUPPORT_MMX)) + if(pChannel->dwFlags[CHN_REVERB] && (GetProcSupport() & PROCSUPPORT_MMX)) pbuffer = MixReverbBuffer; #endif #endif @@ -1745,66 +1728,11 @@ FloatToStereoMix(pMixL, pMixR, MixSoundBuffer, nCount); } + ////////////////////////////////////////////////////////////////////////////////////////// -// -// Float <-> Int conversion -// -VOID CSoundFile::StereoMixToFloat(const int *pSrc, float *pOut1, float *pOut2, UINT nCount) -//----------------------------------------------------------------------------------------- -{ -#ifdef ENABLE_ASM - if(m_MixerSettings.MixerFlags & SNDMIX_ENABLEMMX) - { -#ifdef ENABLE_SSE - if(gdwSysInfo & PROCSUPPORT_SSE) - { - SSE_StereoMixToFloat(pSrc, pOut1, pOut2, nCount, m_PlayConfig.getIntToFloat()); - return; - } -#endif // ENABLE_SSE -#ifdef ENABLE_3DNOW - if(gdwSysInfo & PROCSUPPORT_3DNOW) - { - AMD_StereoMixToFloat(pSrc, pOut1, pOut2, nCount, m_PlayConfig.getIntToFloat()); - return; - } -#endif // ENABLE_3DNOW - } -#endif // ENABLE_ASM #ifdef ENABLE_X86 - X86_StereoMixToFloat(pSrc, pOut1, pOut2, nCount, m_PlayConfig.getIntToFloat()); -#else // !ENABLE_X86 - C_StereoMixToFloat(pSrc, pOut1, pOut2, nCount, m_PlayConfig.getIntToFloat()); -#endif // ENABLE_X86 -} - - -VOID CSoundFile::FloatToStereoMix(const float *pIn1, const float *pIn2, int *pOut, UINT nCount) -//--------------------------------------------------------------------------------------------- -{ -#ifdef ENABLE_ASM - if(m_MixerSettings.MixerFlags & SNDMIX_ENABLEMMX) - { -#ifdef ENABLE_3DNOW - if(gdwSysInfo & PROCSUPPORT_3DNOW) - { - AMD_FloatToStereoMix(pIn1, pIn2, pOut, nCount, m_PlayConfig.getFloatToInt()); - return; - } -#endif // ENABLE_3DNOW - } -#endif // ENABLE_ASM -#ifdef ENABLE_X86 - X86_FloatToStereoMix(pIn1, pIn2, pOut, nCount, m_PlayConfig.getFloatToInt()); -#else // !ENABLE_X86 - C_FloatToStereoMix(pIn1, pIn2, pOut, nCount, m_PlayConfig.getFloatToInt()); -#endif // ENABLE_X86 -} - - -#ifdef ENABLE_X86 static DWORD X86_Convert32To8(LPVOID lp16, int *pBuffer, DWORD lSampleCount) //-------------------------------------------------------------------------- { Modified: trunk/OpenMPT/soundlib/Mmx_mix.cpp =================================================================== --- trunk/OpenMPT/soundlib/Mmx_mix.cpp 2013-05-24 20:01:34 UTC (rev 2182) +++ trunk/OpenMPT/soundlib/Mmx_mix.cpp 2013-05-24 20:22:12 UTC (rev 2183) @@ -25,15 +25,14 @@ #ifdef ENABLE_ASM -DWORD CSoundFile::GetSysInfo() -//---------------------------- + +static uint32 gdwSysInfo = 0; + +void InitProcSupport() +//-------------------- { #ifdef ENABLE_X86 static unsigned int fProcessorExtensions = 0; - static bool bMMXChecked = false; - - if (!bMMXChecked) - { _asm { pushfd // Store original EFLAGS on stack @@ -77,13 +76,16 @@ or fProcessorExtensions, PROCSUPPORT_MMXEX // MMX extensions supported Done: } - bMMXChecked = true; - } - return fProcessorExtensions; -#else - return 0; + gdwSysInfo = fProcessorExtensions; #endif } + +uint32 GetProcSupport() +//--------------------- +{ + return gdwSysInfo; +} + #endif @@ -93,8 +95,8 @@ #ifdef ENABLE_3DNOW // Convert integer mix to floating-point -void AMD_StereoMixToFloat(const int *pSrc, float *pOut1, float *pOut2, UINT nCount, const float _i2fc) -//---------------------------------------------------------------------------------------------------- +static void AMD_StereoMixToFloat(const int *pSrc, float *pOut1, float *pOut2, UINT nCount, const float _i2fc) +//----------------------------------------------------------------------------------------------------------- { _asm { movd mm0, _i2fc @@ -126,8 +128,8 @@ } } -void AMD_FloatToStereoMix(const float *pIn1, const float *pIn2, int *pOut, UINT nCount, const float _f2ic) -//-------------------------------------------------------------------------------------------------------- +static void AMD_FloatToStereoMix(const float *pIn1, const float *pIn2, int *pOut, UINT nCount, const float _f2ic) +//--------------------------------------------------------------------------------------------------------------- { _asm { movd mm0, _f2ic @@ -161,8 +163,8 @@ } -void AMD_FloatToMonoMix(const float *pIn, int *pOut, UINT nCount, const float _f2ic) -//---------------------------------------------------------------------------------- +static void AMD_FloatToMonoMix(const float *pIn, int *pOut, UINT nCount, const float _f2ic) +//----------------------------------------------------------------------------------------- { _asm { movd mm0, _f2ic @@ -191,8 +193,8 @@ } -void AMD_MonoMixToFloat(const int *pSrc, float *pOut, UINT nCount, const float _i2fc) -//----------------------------------------------------------------------------------- +static void AMD_MonoMixToFloat(const int *pSrc, float *pOut, UINT nCount, const float _i2fc) +//------------------------------------------------------------------------------------------ { _asm { movd mm0, _i2fc @@ -227,8 +229,8 @@ #ifdef ENABLE_SSE -void SSE_StereoMixToFloat(const int *pSrc, float *pOut1, float *pOut2, UINT nCount, const float _i2fc) -//---------------------------------------------------------------------------------------------------- +static void SSE_StereoMixToFloat(const int *pSrc, float *pOut1, float *pOut2, UINT nCount, const float _i2fc) +//----------------------------------------------------------------------------------------------------------- { _asm { movss xmm0, _i2fc @@ -258,8 +260,8 @@ } -void SSE_MonoMixToFloat(const int *pSrc, float *pOut, UINT nCount, const float _i2fc) -//----------------------------------------------------------------------------------- +static void SSE_MonoMixToFloat(const int *pSrc, float *pOut, UINT nCount, const float _i2fc) +//------------------------------------------------------------------------------------------ { _asm { movss xmm0, _i2fc @@ -284,17 +286,16 @@ } } -#endif +#endif // ENABLE_SSE +#ifdef ENABLE_X86 - // Convert floating-point mix to integer -#ifdef ENABLE_X86 -void X86_FloatToStereoMix(const float *pIn1, const float *pIn2, int *pOut, UINT nCount, const float _f2ic) -//-------------------------------------------------------------------------------------------------------- +static void X86_FloatToStereoMix(const float *pIn1, const float *pIn2, int *pOut, UINT nCount, const float _f2ic) +//--------------------------------------------------------------------------------------------------------------- { _asm { mov esi, pIn1 @@ -317,24 +318,12 @@ fstp st(0) } } -#endif -void C_FloatToStereoMix(const float *pIn1, const float *pIn2, int *pOut, UINT nCount, const float _f2ic) -//------------------------------------------------------------------------------------------------------ -{ - for(UINT i=0; i<nCount; ++i) - { - *pOut++ = (int)(*pIn1++ * _f2ic); - *pOut++ = (int)(*pIn2++ * _f2ic); - } -} - // Convert integer mix to floating-point -#ifdef ENABLE_X86 -void X86_StereoMixToFloat(const int *pSrc, float *pOut1, float *pOut2, UINT nCount, const float _i2fc) -//---------------------------------------------------------------------------------------------------- +static void X86_StereoMixToFloat(const int *pSrc, float *pOut1, float *pOut2, UINT nCount, const float _i2fc) +//----------------------------------------------------------------------------------------------------------- { _asm { mov esi, pSrc @@ -357,22 +346,10 @@ fstp st(0) } } -#endif -void C_StereoMixToFloat(const int *pSrc, float *pOut1, float *pOut2, UINT nCount, const float _i2fc) -//-------------------------------------------------------------------------------------------------- -{ - for(UINT i=0; i<nCount; ++i) - { - *pOut1++ = *pSrc++ * _i2fc; - *pOut2++ = *pSrc++ * _i2fc; - } -} - -#ifdef ENABLE_X86 -void X86_FloatToMonoMix(const float *pIn, int *pOut, UINT nCount, const float _f2ic) -//---------------------------------------------------------------------------------- +static void X86_FloatToMonoMix(const float *pIn, int *pOut, UINT nCount, const float _f2ic) +//----------------------------------------------------------------------------------------- { _asm { mov edx, pIn @@ -391,21 +368,10 @@ fstp st(0) } } -#endif -void C_FloatToMonoMix(const float *pIn, int *pOut, UINT nCount, const float _f2ic) -//-------------------------------------------------------------------------------- -{ - for(UINT i=0; i<nCount; ++i) - { - *pOut++ = (int)(*pIn++ * _f2ic); - } -} - -#ifdef ENABLE_X86 -void X86_MonoMixToFloat(const int *pSrc, float *pOut, UINT nCount, const float _i2fc) -//----------------------------------------------------------------------------------- +static void X86_MonoMixToFloat(const int *pSrc, float *pOut, UINT nCount, const float _i2fc) +//------------------------------------------------------------------------------------------ { _asm { mov edx, pOut @@ -424,13 +390,144 @@ fstp st(0) } } -#endif -void C_MonoMixToFloat(const int *pSrc, float *pOut, UINT nCount, const float _i2fc) -//--------------------------------------------------------------------------------- +#endif // ENABLE_X86 + + + +static void C_FloatToStereoMix(const float *pIn1, const float *pIn2, int *pOut, UINT nCount, const float _f2ic) +//------------------------------------------------------------------------------------------------------------- { for(UINT i=0; i<nCount; ++i) { + *pOut++ = (int)(*pIn1++ * _f2ic); + *pOut++ = (int)(*pIn2++ * _f2ic); + } +} + + +static void C_StereoMixToFloat(const int *pSrc, float *pOut1, float *pOut2, UINT nCount, const float _i2fc) +//--------------------------------------------------------------------------------------------------------- +{ + for(UINT i=0; i<nCount; ++i) + { + *pOut1++ = *pSrc++ * _i2fc; + *pOut2++ = *pSrc++ * _i2fc; + } +} + + +static void C_FloatToMonoMix(const float *pIn, int *pOut, UINT nCount, const float _f2ic) +//--------------------------------------------------------------------------------------- +{ + for(UINT i=0; i<nCount; ++i) + { + *pOut++ = (int)(*pIn++ * _f2ic); + } +} + + +static void C_MonoMixToFloat(const int *pSrc, float *pOut, UINT nCount, const float _i2fc) +//---------------------------------------------------------------------------------------- +{ + for(UINT i=0; i<nCount; ++i) + { *pOut++ = *pSrc++ * _i2fc; } } + + + +void StereoMixToFloat(const int *pSrc, float *pOut1, float *pOut2, UINT nCount, const float _i2fc) +{ + + #ifdef ENABLE_SSE + if(gdwSysInfo & PROCSUPPORT_SSE) + { + SSE_StereoMixToFloat(pSrc, pOut1, pOut2, nCount, _i2fc); + return; + } + #endif // ENABLE_SSE + #ifdef ENABLE_3DNOW + if(gdwSysInfo & PROCSUPPORT_3DNOW) + { + AMD_StereoMixToFloat(pSrc, pOut1, pOut2, nCount, _i2fc); + return; + } + #endif // ENABLE_3DNOW + + #ifdef ENABLE_X86 + X86_StereoMixToFloat(pSrc, pOut1, pOut2, nCount, _i2fc); + #else // !ENABLE_X86 + C_StereoMixToFloat(pSrc, pOut1, pOut2, nCount, _i2fc); + #endif // ENABLE_X86 + +} + + +void FloatToStereoMix(const float *pIn1, const float *pIn2, int *pOut, UINT nCount, const float _f2ic) +{ + + #ifdef ENABLE_3DNOW + if(gdwSysInfo & PROCSUPPORT_3DNOW) + { + AMD_FloatToStereoMix(pIn1, pIn2, pOut, nCount, _f2ic); + return; + } + #endif // ENABLE_3DNOW + + #ifdef ENABLE_X86 + X86_FloatToStereoMix(pIn1, pIn2, pOut, nCount, _f2ic); + #else // !ENABLE_X86 + C_FloatToStereoMix(pIn1, pIn2, pOut, nCount, _f2ic); + #endif // ENABLE_X86 + +} + + +void MonoMixToFloat(const int *pSrc, float *pOut, UINT nCount, const float _i2fc) +{ + + #ifdef ENABLE_SSE + if(gdwSysInfo & PROCSUPPORT_SSE) + { + SSE_MonoMixToFloat(pSrc, pOut, nCount, _i2fc); + return; + } + #endif // ENABLE_SSE + #ifdef ENABLE_3DNOW + if(gdwSysInfo & PROCSUPPORT_3DNOW) + { + AMD_MonoMixToFloat(pSrc, pOut, nCount, _i2fc); + return; + } + #endif // ENABLE_3DNOW + + #ifdef ENABLE_X86 + X86_MonoMixToFloat(pSrc, pOut, nCount, _i2fc); + #else // !ENABLE_X86 + C_MonoMixToFloat(pSrc, pOut, nCount, _i2fc); + #endif // ENABLE_X86 + +} + + +void FloatToMonoMix(const float *pIn, int *pOut, UINT nCount, const float _f2ic) +{ + + #ifdef ENABLE_3DNOW + if(gdwSysInfo & PROCSUPPORT_3DNOW) + { + AMD_FloatToMonoMix(pIn, pOut, nCount, _f2ic); + return; + } + #endif // ENABLE_3DNOW + + #ifdef ENABLE_X86 + X86_FloatToMonoMix(pIn, pOut, nCount, _f2ic); + #else // !ENABLE_X86 + C_FloatToMonoMix(pIn, pOut, nCount, _f2ic); + #endif // ENABLE_X86 + +} + Modified: trunk/OpenMPT/soundlib/Snd_defs.h =================================================================== --- trunk/OpenMPT/soundlib/Snd_defs.h 2013-05-24 20:01:34 UTC (rev 2182) +++ trunk/OpenMPT/soundlib/Snd_defs.h 2013-05-24 20:22:12 UTC (rev 2183) @@ -306,10 +306,6 @@ #define SNDMIX_SOFTPANNING 0x10 // soft panning mode (this is forced with mixmode RC3 and later) // Misc Flags (can safely be turned on or off) -#ifdef ENABLE_ASM -#define SNDMIX_ENABLEMMX 0x08 // use MMX-accelerated code -#endif - //#define SNDMIX_NOBACKWARDJUMPS 0x40000 // stop when jumping back in the order (currently unused as it seems) #define SNDMIX_MAXDEFAULTPAN 0x80000 // Used by the MOD loader (currently unused) #define SNDMIX_MUTECHNMODE 0x100000 // Notes are not played on muted channels Modified: trunk/OpenMPT/soundlib/Sndfile.cpp =================================================================== --- trunk/OpenMPT/soundlib/Sndfile.cpp 2013-05-24 20:01:34 UTC (rev 2182) +++ trunk/OpenMPT/soundlib/Sndfile.cpp 2013-05-24 20:22:12 UTC (rev 2183) @@ -402,11 +402,6 @@ #endif //---------------------- { -#ifdef ENABLE_ASM - gdwSysInfo = GetSysInfo(); -#else - gdwSysInfo = 0; -#endif MemsetZero(MixSoundBuffer); MemsetZero(MixRearBuffer); #ifndef NO_REVERB @@ -893,7 +888,7 @@ { #ifdef ENABLE_ASM #ifndef NO_REVERB - if(!(GetSysInfo() & PROCSUPPORT_MMX)) DSPMask &= ~SNDDSP_REVERB; + if(!(GetProcSupport() & PROCSUPPORT_MMX)) DSPMask &= ~SNDDSP_REVERB; #endif #endif m_MixerSettings.DSPMask = DSPMask; Modified: trunk/OpenMPT/soundlib/Sndfile.h =================================================================== --- trunk/OpenMPT/soundlib/Sndfile.h 2013-05-24 20:01:34 UTC (rev 2182) +++ trunk/OpenMPT/soundlib/Sndfile.h 2013-05-24 20:22:12 UTC (rev 2183) @@ -184,10 +184,23 @@ #endif // MODPLUG_TRACKER +#ifdef ENABLE_ASM +void InitProcSupport(); +uint32 GetProcSupport(); +#endif + + +void StereoMixToFloat(const int *pSrc, float *pOut1, float *pOut2, UINT nCount, const float _i2fc); +void FloatToStereoMix(const float *pIn1, const float *pIn2, int *pOut, UINT nCount, const float _f2ic); +void MonoMixToFloat(const int *pSrc, float *pOut, UINT nCount, const float _i2fc); +void FloatToMonoMix(const float *pIn, int *pOut, UINT nCount, const float _f2ic); + + #if MPT_COMPILER_MSVC #pragma warning(disable:4324) //structure was padded due to __declspec(align()) #endif + //============== class CSoundFile //============== @@ -271,9 +284,6 @@ FlagSet<ModSpecificFlag, uint16> m_ModFlags; private: - DWORD gdwSysInfo; - -private: // Front Mix Buffer (Also room for interleaved rear mix) int MixSoundBuffer[MIXBUFFERSIZE * 4]; int MixRearBuffer[MIXBUFFERSIZE * 2]; @@ -594,17 +604,18 @@ void InitPlayer(BOOL bReset=FALSE); void SetDspEffects(DWORD DSPMask); DWORD GetSampleRate() { return m_MixerSettings.gdwMixingFreq; } -#ifdef ENABLE_ASM - static DWORD GetSysInfo(); -#endif #ifndef NO_EQ void SetEQGains(const UINT *pGains, UINT nBands, const UINT *pFreqs=NULL, BOOL bReset=FALSE) { m_EQ.SetEQGains(pGains, nBands, pFreqs, bReset, m_MixerSettings.gdwMixingFreq); } // 0=-12dB, 32=+12dB #endif // NO_EQ // Float <-> Int conversion routines - /*static */VOID StereoMixToFloat(const int *pSrc, float *pOut1, float *pOut2, UINT nCount); - /*static */VOID FloatToStereoMix(const float *pIn1, const float *pIn2, int *pOut, UINT nCount); - /*static */VOID MonoMixToFloat(const int *pSrc, float *pOut, UINT nCount); - /*static */VOID FloatToMonoMix(const float *pIn, int *pOut, UINT nCount); + forceinline void StereoMixToFloat(const int *pSrc, float *pOut1, float *pOut2, UINT nCount) + { + ::StereoMixToFloat(pSrc, pOut1, pOut2, nCount, m_PlayConfig.getIntToFloat()); + } + forceinline void FloatToStereoMix(const float *pIn1, const float *pIn2, int *pOut, UINT nCount) + { + ::FloatToStereoMix(pIn1, pIn2, pOut, nCount, m_PlayConfig.getFloatToInt()); + } public: BOOL ReadNote(); Modified: trunk/OpenMPT/soundlib/Sndmix.cpp =================================================================== --- trunk/OpenMPT/soundlib/Sndmix.cpp 2013-05-24 20:01:34 UTC (rev 2182) +++ trunk/OpenMPT/soundlib/Sndmix.cpp 2013-05-24 20:22:12 UTC (rev 2183) @@ -272,7 +272,7 @@ m_nMixStat += CreateStereoMix(lCount); #ifndef NO_REVERB - m_Reverb.Process(MixSoundBuffer, MixReverbBuffer, lCount, gdwSysInfo); + m_Reverb.Process(MixSoundBuffer, MixReverbBuffer, lCount, GetProcSupport()); #endif // NO_REVERB if (nMaxPlugins) ProcessPlugins(lCount); @@ -287,7 +287,7 @@ m_nMixStat += CreateStereoMix(lCount); #ifndef NO_REVERB - m_Reverb.Process(MixSoundBuffer, MixReverbBuffer, lCount, gdwSysInfo); + m_Reverb.Process(MixSoundBuffer, MixReverbBuffer, lCount, GetProcSupport()); #endif // NO_REVERB if (nMaxPlugins) ProcessPlugins(lCount); @@ -309,7 +309,7 @@ if (m_MixerSettings.DSPMask & SNDDSP_EQ) { if (m_MixerSettings.gnChannels >= 2) - m_EQ.ProcessStereo(MixSoundBuffer, MixFloatBuffer, lCount, m_PlayConfig, m_MixerSettings.MixerFlags, gdwSysInfo); + m_EQ.ProcessStereo(MixSoundBuffer, MixFloatBuffer, lCount, m_PlayConfig); else m_EQ.ProcessMono(MixSoundBuffer, MixFloatBuffer, lCount, m_PlayConfig); } This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <man...@us...> - 2013-05-25 10:40:40
|
Revision: 2187 http://sourceforge.net/p/modplug/code/2187 Author: manxorist Date: 2013-05-25 10:40:31 +0000 (Sat, 25 May 2013) Log Message: ----------- [Ref] CMIDIMapper should be inside #ifdef MODPLUG_TRACKER. Modified Paths: -------------- trunk/OpenMPT/mptrack/test/test.cpp trunk/OpenMPT/soundlib/Load_it.cpp Modified: trunk/OpenMPT/mptrack/test/test.cpp =================================================================== --- trunk/OpenMPT/mptrack/test/test.cpp 2013-05-25 09:20:49 UTC (rev 2186) +++ trunk/OpenMPT/mptrack/test/test.cpp 2013-05-25 10:40:31 UTC (rev 2187) @@ -786,6 +786,7 @@ VERIFY_EQUAL_NONCONT(plug.IsMasterEffect(), true); VERIFY_EQUAL_NONCONT(plug.GetGain(), 11); +#ifdef MODPLUG_TRACKER // MIDI Mapping VERIFY_EQUAL_NONCONT(sndFile.GetMIDIMapper().GetCount(), 1); const CMIDIMappingDirective &mapping = sndFile.GetMIDIMapper().GetDirective(0); @@ -798,6 +799,7 @@ VERIFY_EQUAL_NONCONT(mapping.GetParamIndex(), 0); VERIFY_EQUAL_NONCONT(mapping.GetEvent(), MIDIEvents::evControllerChange); VERIFY_EQUAL_NONCONT(mapping.GetController(), MIDIEvents::MIDICC_ModulationWheel_Coarse); +#endif } Modified: trunk/OpenMPT/soundlib/Load_it.cpp =================================================================== --- trunk/OpenMPT/soundlib/Load_it.cpp 2013-05-25 09:20:49 UTC (rev 2186) +++ trunk/OpenMPT/soundlib/Load_it.cpp 2013-05-25 10:40:31 UTC (rev 2187) @@ -2039,6 +2039,7 @@ fwrite(&m_ModFlags, 1, size, f); } +#ifdef MODPLUG_TRACKER //MIMA, MIDI mapping directives if(GetMIDIMapper().GetCount() > 0) { @@ -2056,6 +2057,7 @@ GetMIDIMapper().Serialize(f); } } +#endif return; This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <man...@us...> - 2013-05-25 12:33:26
|
Revision: 2191 http://sourceforge.net/p/modplug/code/2191 Author: manxorist Date: 2013-05-25 12:33:18 +0000 (Sat, 25 May 2013) Log Message: ----------- [Ref] Move test suite out of mptrack subdiretory. The goal is to make it usable with libopenmpt. Modified Paths: -------------- trunk/OpenMPT/common/BuildSettings.h trunk/OpenMPT/mptrack/Mptrack.cpp trunk/OpenMPT/mptrack/mptrack_08.vcproj trunk/OpenMPT/mptrack/mptrack_10.vcxproj trunk/OpenMPT/mptrack/mptrack_10.vcxproj.filters trunk/OpenMPT/test/test.cpp trunk/OpenMPT/test/test.h Added Paths: ----------- trunk/OpenMPT/test/ Removed Paths: ------------- trunk/OpenMPT/mptrack/test/ Modified: trunk/OpenMPT/common/BuildSettings.h =================================================================== --- trunk/OpenMPT/common/BuildSettings.h 2013-05-25 12:08:42 UTC (rev 2190) +++ trunk/OpenMPT/common/BuildSettings.h 2013-05-25 12:33:18 UTC (rev 2191) @@ -60,6 +60,11 @@ #elif defined(MODPLUG_TRACKER) +// Enable built-in test suite. +#ifdef _DEBUG +#define ENABLE_TESTS +#endif + // Disable any file saving functionality (not really useful except for the player library) //#define MODPLUG_NO_FILESAVE @@ -122,6 +127,7 @@ #elif defined(LIBOPENMPT_BUILD) +#define ENABLE_TESTS #define MODPLUG_NO_FILESAVE //#define NO_LOGGING #define NO_ARCHIVE_SUPPORT Modified: trunk/OpenMPT/mptrack/Mptrack.cpp =================================================================== --- trunk/OpenMPT/mptrack/Mptrack.cpp 2013-05-25 12:08:42 UTC (rev 2190) +++ trunk/OpenMPT/mptrack/Mptrack.cpp 2013-05-25 12:33:18 UTC (rev 2191) @@ -21,7 +21,7 @@ #include "hyperEdit.h" #include "commctrl.h" #include "../common/version.h" -#include "test/test.h" +#include "../test/test.h" #include <afxadv.h> #include <shlwapi.h> #include "UpdateCheck.h" Modified: trunk/OpenMPT/mptrack/mptrack_08.vcproj =================================================================== --- trunk/OpenMPT/mptrack/mptrack_08.vcproj 2013-05-25 12:08:42 UTC (rev 2190) +++ trunk/OpenMPT/mptrack/mptrack_08.vcproj 2013-05-25 12:33:18 UTC (rev 2191) @@ -1301,11 +1301,11 @@ Name="test" > <File - RelativePath=".\test\test.cpp" + RelativePath="..\test\test.cpp" > </File> <File - RelativePath=".\test\test.h" + RelativePath="..\test\test.h" > </File> </Filter> Modified: trunk/OpenMPT/mptrack/mptrack_10.vcxproj =================================================================== --- trunk/OpenMPT/mptrack/mptrack_10.vcxproj 2013-05-25 12:08:42 UTC (rev 2190) +++ trunk/OpenMPT/mptrack/mptrack_10.vcxproj 2013-05-25 12:33:18 UTC (rev 2191) @@ -299,6 +299,7 @@ <ClCompile Include="..\soundlib\WAVTools.cpp" /> <ClCompile Include="..\soundlib\WindowedFIR.cpp" /> <ClCompile Include="..\soundlib\XMTools.cpp" /> + <ClCompile Include="..\test\test.cpp" /> <ClCompile Include="..\unarchiver\unarchiver.cpp" /> <ClCompile Include="..\unarchiver\ungzip.cpp" /> <ClCompile Include="..\unarchiver\unlha.cpp" /> @@ -461,7 +462,6 @@ <ClCompile Include="TrackerSettings.cpp" /> <ClCompile Include="TuningDialog.cpp" /> <ClCompile Include="tuningRatioMapWnd.cpp" /> - <ClCompile Include="test\test.cpp" /> <ClCompile Include="..\soundlib\Load_669.cpp" /> <ClCompile Include="..\Soundlib\load_amf.cpp" /> <ClCompile Include="..\soundlib\Load_ams.cpp" /> @@ -563,6 +563,7 @@ <ClInclude Include="..\soundlib\WAVTools.h" /> <ClInclude Include="..\soundlib\WindowedFIR.h" /> <ClInclude Include="..\soundlib\XMTools.h" /> + <ClInclude Include="..\test\test.h" /> <ClInclude Include="..\unarchiver\unarchiver.h" /> <ClInclude Include="..\unarchiver\ungzip.h" /> <ClInclude Include="..\unarchiver\unlha.h" /> @@ -640,7 +641,6 @@ <ClInclude Include="TrackerSettings.h" /> <ClInclude Include="TuningDialog.h" /> <ClInclude Include="tuningRatioMapWnd.h" /> - <ClInclude Include="test\test.h" /> <ClInclude Include="..\soundlib\Loaders.h" /> <ClInclude Include="Undo.h" /> <ClInclude Include="UpdateCheck.h" /> Modified: trunk/OpenMPT/mptrack/mptrack_10.vcxproj.filters =================================================================== --- trunk/OpenMPT/mptrack/mptrack_10.vcxproj.filters 2013-05-25 12:08:42 UTC (rev 2190) +++ trunk/OpenMPT/mptrack/mptrack_10.vcxproj.filters 2013-05-25 12:33:18 UTC (rev 2191) @@ -85,9 +85,6 @@ <ClCompile Include="..\soundlib\load_dbm.cpp"> <Filter>Source Files\soundlib\Module Loaders</Filter> </ClCompile> - <ClCompile Include="test\test.cpp"> - <Filter>test</Filter> - </ClCompile> <ClCompile Include="ChannelManagerDlg.cpp"> <Filter>Source Files\mptrack\Dialogs</Filter> </ClCompile> @@ -511,6 +508,9 @@ <ClCompile Include="..\unarchiver\unrar\UNPOLD.CPP"> <Filter>Source Files\unarchiver\unrar</Filter> </ClCompile> + <ClCompile Include="..\test\test.cpp"> + <Filter>test</Filter> + </ClCompile> </ItemGroup> <ItemGroup> <ClInclude Include="..\soundlib\Loaders.h"> @@ -525,9 +525,6 @@ <ClInclude Include="..\soundlib\tuningcollection.h"> <Filter>Header Files\soundlib\Tuning</Filter> </ClInclude> - <ClInclude Include="test\test.h"> - <Filter>test</Filter> - </ClInclude> <ClInclude Include="ChannelManagerDlg.h"> <Filter>Header Files\mptrack\Dialogs</Filter> </ClInclude> @@ -918,6 +915,9 @@ <ClInclude Include="..\common\CompilerDetect.h"> <Filter>Header Files\common</Filter> </ClInclude> + <ClInclude Include="..\test\test.h"> + <Filter>test</Filter> + </ClInclude> </ItemGroup> <ItemGroup> <None Include="res\bitmap1.bmp"> Modified: trunk/OpenMPT/test/test.cpp =================================================================== --- trunk/OpenMPT/mptrack/test/test.cpp 2013-05-25 12:08:42 UTC (rev 2190) +++ trunk/OpenMPT/test/test.cpp 2013-05-25 12:33:18 UTC (rev 2191) @@ -15,16 +15,17 @@ #ifdef ENABLE_TESTS -#include "../mptrack.h" -#include "../moddoc.h" -#include "../MainFrm.h" -#include "../../common/version.h" -#include "../../soundlib/MIDIEvents.h" -#include "../../soundlib/MIDIMacros.h" -#include "../../common/misc_util.h" -#include "../../common/StringFixer.h" -#include "../../common/serialization_utils.h" -#include "../../soundlib/SampleFormatConverters.h" +#include "../common/version.h" +#include "../common/misc_util.h" +#include "../common/StringFixer.h" +#include "../common/serialization_utils.h" +#include "../soundlib/Sndfile.h" +#include "../soundlib/MIDIEvents.h" +#include "../soundlib/MIDIMacros.h" +#include "../soundlib/SampleFormatConverters.h" +#include "../mptrack/mptrack.h" +#include "../mptrack/moddoc.h" +#include "../mptrack/MainFrm.h" #include <limits> #include <istream> #include <ostream> @@ -938,7 +939,7 @@ if(theFile.Mid(theFile.GetLength() - 6, 5) != "Debug") return; theFile.Delete(theFile.GetLength() - 6, 6); - theFile.Append("test/test."); + theFile.Append("../test/test."); // Test MPTM file loading { Modified: trunk/OpenMPT/test/test.h =================================================================== --- trunk/OpenMPT/mptrack/test/test.h 2013-05-25 12:08:42 UTC (rev 2190) +++ trunk/OpenMPT/test/test.h 2013-05-25 12:33:18 UTC (rev 2191) @@ -11,10 +11,6 @@ #pragma once -#ifdef _DEBUG - #define ENABLE_TESTS -#endif - namespace MptTest { void DoTests(); This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <man...@us...> - 2013-05-26 14:01:31
|
Revision: 2192 http://sourceforge.net/p/modplug/code/2192 Author: manxorist Date: 2013-05-26 14:01:19 +0000 (Sun, 26 May 2013) Log Message: ----------- [Ref] Make almost all tests usable without building the tracker GUI. [Ref] Build libopenmpt with testsuite. [New] Add --runtests switch to openmpt123. Modified Paths: -------------- trunk/OpenMPT/common/BuildSettings.h trunk/OpenMPT/libopenmpt/libopenmpt.cpp trunk/OpenMPT/libopenmpt/libopenmpt.vcxproj trunk/OpenMPT/libopenmpt/libopenmpt.vcxproj.filters trunk/OpenMPT/libopenmpt/libopenmpt_internal.h trunk/OpenMPT/openmpt123/openmpt123.cpp trunk/OpenMPT/test/test.cpp trunk/OpenMPT/test/test.h Modified: trunk/OpenMPT/common/BuildSettings.h =================================================================== --- trunk/OpenMPT/common/BuildSettings.h 2013-05-25 12:33:18 UTC (rev 2191) +++ trunk/OpenMPT/common/BuildSettings.h 2013-05-26 14:01:19 UTC (rev 2192) @@ -169,8 +169,12 @@ #define NO_REVERB // reverb requires mmx #endif +#if defined(ENABLE_TESTS) && defined(MODPLUG_NO_FILESAVE) +#undef MODPLUG_NO_FILESAVE // tests require file saving +#endif + #if MPT_COMPILER_MSVC #define VC_EXTRALEAN // Exclude rarely-used stuff from Windows headers #endif Modified: trunk/OpenMPT/libopenmpt/libopenmpt.cpp =================================================================== --- trunk/OpenMPT/libopenmpt/libopenmpt.cpp 2013-05-25 12:33:18 UTC (rev 2191) +++ trunk/OpenMPT/libopenmpt/libopenmpt.cpp 2013-05-26 14:01:19 UTC (rev 2192) @@ -13,6 +13,18 @@ #include "libopenmpt.hpp" #include "libopenmpt.h" +namespace MptTest { + void DoTests(); +} // namespace MptTest + +namespace openmpt { + +void run_tests() { + MptTest::DoTests(); +} + +} // namespace openmpt + #if defined( LIBOPENMPT_BUILD_DLL ) #if defined( _WIN32 ) Modified: trunk/OpenMPT/libopenmpt/libopenmpt.vcxproj =================================================================== --- trunk/OpenMPT/libopenmpt/libopenmpt.vcxproj 2013-05-25 12:33:18 UTC (rev 2191) +++ trunk/OpenMPT/libopenmpt/libopenmpt.vcxproj 2013-05-26 14:01:19 UTC (rev 2192) @@ -368,6 +368,7 @@ <ClInclude Include="..\soundlib\WAVTools.h" /> <ClInclude Include="..\soundlib\WindowedFIR.h" /> <ClInclude Include="..\soundlib\XMTools.h" /> + <ClInclude Include="..\test\test.h" /> <ClInclude Include="libopenmpt.h" /> <ClInclude Include="libopenmpt.hpp" /> <ClInclude Include="libopenmpt_config.h" /> @@ -451,6 +452,7 @@ <ClCompile Include="..\soundlib\WAVTools.cpp" /> <ClCompile Include="..\soundlib\WindowedFIR.cpp" /> <ClCompile Include="..\soundlib\XMTools.cpp" /> + <ClCompile Include="..\test\test.cpp" /> <ClCompile Include="libopenmpt.cpp" /> <ClCompile Include="libopenmpt_c.cpp" /> <ClCompile Include="libopenmpt_cxx.cpp" /> Modified: trunk/OpenMPT/libopenmpt/libopenmpt.vcxproj.filters =================================================================== --- trunk/OpenMPT/libopenmpt/libopenmpt.vcxproj.filters 2013-05-25 12:33:18 UTC (rev 2191) +++ trunk/OpenMPT/libopenmpt/libopenmpt.vcxproj.filters 2013-05-26 14:01:19 UTC (rev 2192) @@ -28,6 +28,12 @@ <Filter Include="Header Files\settings"> <UniqueIdentifier>{77dd8b6d-d0f5-4545-b820-f8989b6f841a}</UniqueIdentifier> </Filter> + <Filter Include="Header Files\test"> + <UniqueIdentifier>{d7ef920e-4335-4ea9-96f3-e4721d61b5b5}</UniqueIdentifier> + </Filter> + <Filter Include="Source Files\test"> + <UniqueIdentifier>{7e476eee-06d3-440e-89c1-29c78a21daa9}</UniqueIdentifier> + </Filter> </ItemGroup> <ItemGroup> <ClInclude Include="..\common\AudioCriticalSection.h"> @@ -210,6 +216,9 @@ <ClInclude Include="..\common\CompilerDetect.h"> <Filter>Header Files\common</Filter> </ClInclude> + <ClInclude Include="..\test\test.h"> + <Filter>Header Files\test</Filter> + </ClInclude> </ItemGroup> <ItemGroup> <ClCompile Include="..\common\AudioCriticalSection.cpp"> @@ -455,5 +464,8 @@ <ClCompile Include="..\soundlib\Load_digi.cpp"> <Filter>Source Files\soundlib</Filter> </ClCompile> + <ClCompile Include="..\test\test.cpp"> + <Filter>Source Files\test</Filter> + </ClCompile> </ItemGroup> </Project> \ No newline at end of file Modified: trunk/OpenMPT/libopenmpt/libopenmpt_internal.h =================================================================== --- trunk/OpenMPT/libopenmpt/libopenmpt_internal.h 2013-05-25 12:33:18 UTC (rev 2191) +++ trunk/OpenMPT/libopenmpt/libopenmpt_internal.h 2013-05-26 14:01:19 UTC (rev 2192) @@ -39,6 +39,12 @@ #endif #ifdef __cplusplus +namespace openmpt { +LIBOPENMPT_CXX_API void run_tests(); +} // namespace openmpt +#endif + +#ifdef __cplusplus namespace openmpt { namespace version { #ifndef NO_WINAMP extern char * in_openmpt_string; Modified: trunk/OpenMPT/openmpt123/openmpt123.cpp =================================================================== --- trunk/OpenMPT/openmpt123/openmpt123.cpp 2013-05-25 12:33:18 UTC (rev 2191) +++ trunk/OpenMPT/openmpt123/openmpt123.cpp 2013-05-26 14:01:19 UTC (rev 2192) @@ -62,6 +62,7 @@ }; struct openmpt123_flags { + bool run_tests; bool modplug123; int device; std::int32_t channels; @@ -81,6 +82,7 @@ bool use_stdout; std::vector<std::string> filenames; openmpt123_flags() { + run_tests = false; modplug123 = false; device = -1; channels = 2; @@ -676,6 +678,8 @@ std::istringstream istr( nextarg ); istr >> flags.rampoutus; ++i; + } else if ( arg == "--runtests" ) { + flags.run_tests = true; } else if ( arg.size() > 0 && arg.substr( 0, 1 ) == "-" ) { throw show_help_exception(); } @@ -714,6 +718,10 @@ s << openmpt::string::get( openmpt::string::credits ); } +namespace openmpt { +LIBOPENMPT_CXX_API void run_tests(); +} // namespace openmpt + int main( int argc, char * argv [] ) { openmpt123_flags flags; @@ -731,6 +739,19 @@ flags = parse_openmpt123( args ); } + + if ( flags.run_tests ) { + try { + openmpt::run_tests(); + } catch ( std::exception & e ) { + std::cerr << "FAIL: " << e.what() << std::endl; + return -1; + } catch ( ... ) { + std::cerr << "FAIL" << std::endl; + return -1; + } + return 0; + } if ( args.size() <= 1 ) { throw show_help_exception( "", false ); Modified: trunk/OpenMPT/test/test.cpp =================================================================== --- trunk/OpenMPT/test/test.cpp 2013-05-25 12:33:18 UTC (rev 2191) +++ trunk/OpenMPT/test/test.cpp 2013-05-26 14:01:19 UTC (rev 2192) @@ -20,62 +20,178 @@ #include "../common/StringFixer.h" #include "../common/serialization_utils.h" #include "../soundlib/Sndfile.h" +#include "../soundlib/FileReader.h" #include "../soundlib/MIDIEvents.h" #include "../soundlib/MIDIMacros.h" #include "../soundlib/SampleFormatConverters.h" +#ifdef MODPLUG_TRACKER #include "../mptrack/mptrack.h" #include "../mptrack/moddoc.h" #include "../mptrack/MainFrm.h" +#endif // MODPLUG_TRACKER +#ifndef MODPLUG_TRACKER +#include <fstream> +#endif // !MODPLUG_TRACKER #include <limits> +#ifndef MODPLUG_TRACKER +#include <memory> +#include <iostream> +#endif // !MODPLUG_TRACKER #include <istream> #include <ostream> #include <sstream> #ifdef _DEBUG +#if MPT_COMPILER_MSVC && defined(_MFC_VER) #define new DEBUG_NEW #endif +#endif +#ifndef _T +#define _T MPT_TEXT +#endif + namespace MptTest { + + +#ifdef THIS_FILE +#undef THIS_FILE +#endif +#define THIS_FILE "test/test.cpp" // __FILE__ + + + +#ifdef MODPLUG_TRACKER + +#define MULTI_TEST_TRY try { +#define MULTI_TEST_CATCH } catch ( std::exception & e) { \ + Reporting::Error((std::string() + "Test \"" + func_description + "\" threw an exception, message: " + e.what()).c_str(), (std::string() + "Test \"" + func_description + "\": Exception was thrown").c_str()); \ + } catch ( ... ) { \ + Reporting::Error((std::string() + "Test \"" + func_description + "\" threw an unknown exception.").c_str(), (std::string() + "Test \"" + func_description + "\": Exception was thrown").c_str()); \ + } +#define TEST_TRY { +#define TEST_CATCH } +#define TEST_OK() do{UNREFERENCED_PARAMETER(ok_description);}while(0) +#define TEST_FAIL() Reporting::Error(mpt::String::Format("File: %s\nLine: " STRINGIZE(__LINE__) "\n\n" "%s", THIS_FILE, fail_description).c_str(), "VERIFY_EQUAL failed") +#define TEST_FAIL_STOP() throw std::runtime_error(mpt::String::Format("File: %s\nLine: " STRINGIZE(__LINE__) "\n\n %s", THIS_FILE, fail_description)) + +#else // !MODPLUG_TRACKER + +static std::string remove_newlines(std::string str) +{ + return mpt::String::Replace(mpt::String::Replace(str, "\n", " "), "\r", " "); +} + +static void show_fail(const char * const file, const int line, const char * const description, bool exception = false, const char * const exception_text = nullptr) +{ + if(!exception) + { + std::cerr << "FAIL: " << file << "(" << line << ") : " << remove_newlines(description) << std::endl; + } else if(exception_text && std::string(exception_text).empty()) + { + std::cerr << "FAIL: " << file << "(" << line << ") : " << remove_newlines(description) << " EXCEPTION!" << std::endl; + } else + { + std::cerr << "FAIL: " << file << "(" << line << ") : " << remove_newlines(description) << " EXCEPTION: " << exception << std::endl; + } +} + +static void show_ok(const char * const file, const int line, const char * const description) +{ +#if 1 + std::cerr << "OK: " << file << "(" << line << ") : " << remove_newlines(description) << std::endl; +#else + UNREFERENCED_PARAMETER(file); + UNREFERENCED_PARAMETER(line); + UNREFERENCED_PARAMETER(description); +#endif +} + +#define MULTI_TEST_TRY try { +#define MULTI_TEST_CATCH } catch ( std::exception & e) { \ + show_fail(THIS_FILE, __LINE__, func_description, true, e.what()); \ + } catch ( ... ) { \ + show_fail(THIS_FILE, __LINE__, func_description, true); \ + } +#define TEST_TRY try { +#define TEST_CATCH } catch ( std::exception & e ) { \ + show_fail(THIS_FILE, __LINE__, fail_description, true, e.what()); \ + throw; \ + } catch ( ... ) { \ + show_fail(THIS_FILE, __LINE__, fail_description, true); \ + throw; \ + } +#define TEST_OK() show_ok(THIS_FILE, __LINE__, ok_description) +#define TEST_FAIL() show_fail(THIS_FILE, __LINE__, fail_description) +#define TEST_FAIL_STOP() do { show_fail(THIS_FILE, __LINE__, fail_description); throw std::runtime_error("Test failed."); } while(0) + +#endif // MODPLUG_TRACKER + + + //Verify that given parameters are 'equal'(show error message if not). //The exact meaning of equality is not specified; for now using operator!=. //The macro is active in both 'debug' and 'release' build. #define VERIFY_EQUAL(x,y) \ +do{ \ + const char * const ok_description = #x " == " #y ; \ + const char * const fail_description = "VERIFY_EQUAL failed when comparing\n" #x "\nand\n" #y ; \ + TEST_TRY \ if((x) != (y)) \ { \ - CString str; \ - str.Format("File: " STRINGIZE(__FILE__) "\nLine: " STRINGIZE(__LINE__) "\n\nVERIFY_EQUAL failed when comparing\n" #x "\nand\n" #y); \ - Reporting::Error(str, "VERIFY_EQUAL failed"); \ - } + TEST_FAIL(); \ + } else \ + { \ + TEST_OK(); \ + } \ + TEST_CATCH \ +}while(0) + // Like VERIFY_EQUAL, but throws exception if comparison fails. #define VERIFY_EQUAL_NONCONT(x,y) \ +do{ \ + const char * const ok_description = #x " == " #y ; \ + const char * const fail_description = "VERIFY_EQUAL failed when comparing\n" #x "\nand\n" #y ; \ + TEST_TRY \ if((x) != (y)) \ { \ - CString str; \ - str.Format("File: " STRINGIZE(__FILE__) "\nLine: " STRINGIZE(__LINE__) "\n\nVERIFY_EQUAL failed when comparing\n" #x "\nand\n" #y); \ - std::string stdstr = str; \ - throw std::runtime_error(stdstr); \ - } + TEST_FAIL_STOP(); \ + } else \ + { \ + TEST_OK(); \ + } \ + TEST_CATCH \ +}while(0) -#define DO_TEST(func) \ -try \ -{ \ - func(); \ -} \ -catch(const std::exception& e) \ -{ \ - Reporting::Error(CString("Test \"" STRINGIZE(func) "\" threw an exception, message: ") + e.what(), "Test \"" STRINGIZE(func) "\": Exception was thrown"); \ -} \ -catch(...) \ -{ \ - Reporting::Error(CString("Test \"" STRINGIZE(func) "\" threw an unknown exception."), "Test \"" STRINGIZE(func) "\": Exception was thrown"); \ -} - +// Like VERIFY_EQUAL_NONCONT, but do not show message if test succeeds +#define VERIFY_EQUAL_QUIET_NONCONT(x,y) \ +do{ \ + const char * const fail_description = "VERIFY_EQUAL failed when comparing\n" #x "\nand\n" #y ; \ + TEST_TRY \ + if((x) != (y)) \ + { \ + TEST_FAIL_STOP(); \ + } \ + TEST_CATCH \ +}while(0) + +#define DO_TEST(func) \ +do{ \ + const char * func_description = #func ; \ + MULTI_TEST_TRY \ + func(); \ + MULTI_TEST_CATCH \ +}while(0) + + + + void TestVersion(); void TestTypes(); void TestLoadSaveFile(); @@ -102,7 +218,6 @@ DO_TEST(TestPCnoteSerialization); DO_TEST(TestLoadSaveFile); - Log(TEXT("Tests were run\n")); } @@ -134,6 +249,7 @@ STATIC_ASSERT( MAKE_VERSION_NUMERIC(01,17,03,00) >> 8 == 0x011703 ); } +#ifdef MODPLUG_TRACKER //Verify that the version obtained from the executable file is the same as //defined in MptVersion. { @@ -178,6 +294,7 @@ VERIFY_EQUAL( version, MptVersion::str ); VERIFY_EQUAL( MptVersion::ToNum(version), MptVersion::num ); } +#endif } @@ -353,10 +470,12 @@ // Check if our test file was loaded correctly. -void TestLoadXMFile(const CModDoc *pModDoc) -//----------------------------------------- +void TestLoadXMFile(const CSoundFile &sndFile) +//-------------------------------------------- { - const CSoundFile &sndFile = pModDoc->GetrSoundFile(); +#ifdef MODPLUG_TRACKER + const CModDoc *pModDoc = sndFile.GetpModDoc(); +#endif // MODPLUG_TRACKER // Global Variables VERIFY_EQUAL_NONCONT(strcmp(sndFile.m_szNames[0], "Test Module"), 0); @@ -396,9 +515,11 @@ VERIFY_EQUAL_NONCONT(strcmp(sndFile.m_szNames[1], "Pulse Sample"), 0); VERIFY_EQUAL_NONCONT(strcmp(sndFile.m_szNames[2], "Empty Sample"), 0); VERIFY_EQUAL_NONCONT(strcmp(sndFile.m_szNames[3], "Unassigned Sample"), 0); +#ifdef MODPLUG_TRACKER VERIFY_EQUAL_NONCONT(pModDoc->FindSampleParent(1), 1); VERIFY_EQUAL_NONCONT(pModDoc->FindSampleParent(2), 1); VERIFY_EQUAL_NONCONT(pModDoc->FindSampleParent(3), INSTRUMENTINDEX_INVALID); +#endif // MODPLUG_TRACKER const ModSample &sample = sndFile.GetSample(1); VERIFY_EQUAL_NONCONT(sample.GetBytesPerSample(), 1); VERIFY_EQUAL_NONCONT(sample.GetNumChannels(), 1); @@ -548,10 +669,12 @@ // Check if our test file was loaded correctly. -void TestLoadMPTMFile(const CModDoc *pModDoc) -//------------------------------------------- +void TestLoadMPTMFile(const CSoundFile &sndFile) +//---------------------------------------------- { - const CSoundFile &sndFile = pModDoc->GetrSoundFile(); +#ifdef MODPLUG_TRACKER + const CModDoc *pModDoc = sndFile.GetpModDoc(); +#endif // MODPLUG_TRACKER // Global Variables VERIFY_EQUAL_NONCONT(strcmp(sndFile.m_szNames[0], "Test Module_____________X"), 0); @@ -573,6 +696,7 @@ VERIFY_EQUAL_NONCONT(sndFile.m_dwCreatedWithVersion, MAKE_VERSION_NUMERIC(1, 19, 02, 05)); VERIFY_EQUAL_NONCONT(sndFile.m_nRestartPos, 1); +#ifdef MODPLUG_TRACKER // Edit history VERIFY_EQUAL_NONCONT(pModDoc->GetFileHistory().size() > 0, true); const FileHistory &fh = pModDoc->GetFileHistory().at(0); @@ -583,6 +707,7 @@ VERIFY_EQUAL_NONCONT(fh.loadDate.tm_min, 8); VERIFY_EQUAL_NONCONT(fh.loadDate.tm_sec, 32); VERIFY_EQUAL_NONCONT((uint32)((double)fh.openTime / HISTORY_TIMER_PRECISION), 31); +#endif // MODPLUG_TRACKER // Macros VERIFY_EQUAL_NONCONT(sndFile.m_MidiCfg.GetParameteredMacroType(0), sfx_reso); @@ -806,10 +931,9 @@ // Check if our test file was loaded correctly. -void TestLoadS3MFile(const CModDoc *pModDoc, bool resaved) -//-------------------------------------------------------- +void TestLoadS3MFile(const CSoundFile &sndFile, bool resaved) +//----------------------------------------------------------- { - const CSoundFile &sndFile = pModDoc->GetrSoundFile(); // Global Variables VERIFY_EQUAL_NONCONT(strcmp(sndFile.m_szNames[0], "S3M_Test__________________X"), 0); @@ -930,79 +1054,196 @@ } -// Test file loading and saving -void TestLoadSaveFile() -//--------------------- + +#ifdef MODPLUG_TRACKER + +static bool ShouldRunTests() { CString theFile = theApp.GetAppDirPath(); // Only run the tests when we're in the project directory structure. - if(theFile.Mid(theFile.GetLength() - 6, 5) != "Debug") - return; + return theFile.Mid(theFile.GetLength() - 6, 5) == "Debug"; +} + +static std::string GetTestFilenameBase() +{ + CString theFile = theApp.GetAppDirPath(); theFile.Delete(theFile.GetLength() - 6, 6); theFile.Append("../test/test."); + return theFile.GetString(); +} +typedef CModDoc *TSoundFileContainer; + +static CSoundFile &GetrSoundFile(TSoundFileContainer &sndFile) +{ + return sndFile->GetrSoundFile(); +} + +static TSoundFileContainer CreateSoundFileContainer(const std::string filename) +{ + CModDoc *pModDoc = (CModDoc *)theApp.OpenDocumentFile(filename.c_str(), FALSE); + return pModDoc; +} + +static void DestroySoundFileContainer(TSoundFileContainer &sndFile) +{ + sndFile->OnCloseDocument(); +} + +static void SaveIT(const TSoundFileContainer &sndFile, const std::string &filename) +{ + sndFile->DoSave(filename.c_str()); + // Saving the file puts it in the MRU list... + theApp.RemoveMruItem(0); +} + +static void SaveXM(const TSoundFileContainer &sndFile, const std::string &filename) +{ + sndFile->DoSave(filename.c_str()); + // Saving the file puts it in the MRU list... + theApp.RemoveMruItem(0); +} + +static void SaveS3M(const TSoundFileContainer &sndFile, const std::string &filename) +{ + sndFile->DoSave(filename.c_str()); + // Saving the file puts it in the MRU list... + theApp.RemoveMruItem(0); +} + +#else + +static bool ShouldRunTests() +{ + return true; +} + +static std::string GetTestFilenameBase() +{ + return "../test/test."; +} + +typedef std::shared_ptr<CSoundFile> TSoundFileContainer; + +static CSoundFile &GetrSoundFile(TSoundFileContainer &sndFile) +{ + return *sndFile.get(); +} + +static TSoundFileContainer CreateSoundFileContainer(const std::string &filename) +{ + std::ifstream stream(filename, std::ios::binary); + FileReader file(&stream); + std::shared_ptr<CSoundFile> pSndFile(new CSoundFile()); + pSndFile->Create(file, CSoundFile::loadCompleteModule); + return pSndFile; +} + +static void DestroySoundFileContainer(TSoundFileContainer &sndFile) +{ + return; +} + +static void SaveIT(const TSoundFileContainer &sndFile, const std::string &filename) +{ + sndFile->SaveIT(filename.c_str(), false); +} + +static void SaveXM(const TSoundFileContainer &sndFile, const std::string &filename) +{ + sndFile->SaveXM(filename.c_str(), false); +} + +static void SaveS3M(const TSoundFileContainer &sndFile, const std::string &filename) +{ + sndFile->SaveS3M(filename.c_str()); +} + +#endif + + + +// Test file loading and saving +void TestLoadSaveFile() +//--------------------- +{ + if(!ShouldRunTests()) + { + return; + } + std::string filenameBase = GetTestFilenameBase(); + // Test MPTM file loading { - CModDoc *pModDoc = (CModDoc *)theApp.OpenDocumentFile(theFile + "mptm", FALSE); - TestLoadMPTMFile(pModDoc); + TSoundFileContainer sndFileContainer = CreateSoundFileContainer(filenameBase + "mptm"); + TestLoadMPTMFile(GetrSoundFile(sndFileContainer)); + // Test file saving - pModDoc->DoSave(theFile + "saved.mptm"); - pModDoc->OnCloseDocument(); + SaveIT(sndFileContainer, filenameBase + "saved.mptm"); - // Saving the file puts it in the MRU list... - theApp.RemoveMruItem(0); + DestroySoundFileContainer(sndFileContainer); + } - // Reload the saved file and test if everything is still working correctly. - pModDoc = (CModDoc *)theApp.OpenDocumentFile(theFile + "saved.mptm", FALSE); - TestLoadMPTMFile(pModDoc); - pModDoc->OnCloseDocument(); + // Reload the saved file and test if everything is still working correctly. + { + TSoundFileContainer sndFileContainer = CreateSoundFileContainer(filenameBase + "saved.mptm"); + TestLoadMPTMFile(GetrSoundFile(sndFileContainer)); + + DestroySoundFileContainer(sndFileContainer); } // Test XM file loading { - CModDoc *pModDoc = (CModDoc *)theApp.OpenDocumentFile(theFile + "xm", FALSE); - TestLoadXMFile(pModDoc); + TSoundFileContainer sndFileContainer = CreateSoundFileContainer(filenameBase + "xm"); + TestLoadXMFile(GetrSoundFile(sndFileContainer)); + // In OpenMPT 1.20 (up to revision 1459), there was a bug in the XM saver // that would create broken XMs if the sample map contained samples that // were only referenced below C-1 or above B-8 (such samples should not // be written). Let's insert a sample there and check if re-loading the // file still works. - pModDoc->GetSoundFile()->m_nSamples++; - pModDoc->GetSoundFile()->Instruments[1]->Keyboard[110] = pModDoc->GetSoundFile()->GetNumSamples(); + GetrSoundFile(sndFileContainer).m_nSamples++; + GetrSoundFile(sndFileContainer).Instruments[1]->Keyboard[110] = GetrSoundFile(sndFileContainer).GetNumSamples(); // Test file saving - pModDoc->DoSave(theFile + "saved.xm"); - pModDoc->OnCloseDocument(); + SaveXM(sndFileContainer, filenameBase + "saved.xm"); - // Saving the file puts it in the MRU list... - theApp.RemoveMruItem(0); + DestroySoundFileContainer(sndFileContainer); + } - // Reload the saved file and test if everything is still working correctly. - pModDoc = (CModDoc *)theApp.OpenDocumentFile(theFile + "saved.xm", FALSE); - TestLoadXMFile(pModDoc); - pModDoc->OnCloseDocument(); + // Reload the saved file and test if everything is still working correctly. + { + TSoundFileContainer sndFileContainer = CreateSoundFileContainer(filenameBase + "saved.xm"); + + TestLoadXMFile(GetrSoundFile(sndFileContainer)); + + DestroySoundFileContainer(sndFileContainer); } // Test S3M file loading { - CModDoc *pModDoc = (CModDoc *)theApp.OpenDocumentFile(theFile + "s3m", FALSE); - TestLoadS3MFile(pModDoc, false); + TSoundFileContainer sndFileContainer = CreateSoundFileContainer(filenameBase + "s3m"); + + TestLoadS3MFile(GetrSoundFile(sndFileContainer), false); // Test file saving - pModDoc->DoSave(theFile + "saved.s3m"); - pModDoc->OnCloseDocument(); + SaveS3M(sndFileContainer, filenameBase + "saved.s3m"); - // Saving the file puts it in the MRU list... - theApp.RemoveMruItem(0); + DestroySoundFileContainer(sndFileContainer); + } - // Reload the saved file and test if everything is still working correctly. - pModDoc = (CModDoc *)theApp.OpenDocumentFile(theFile + "saved.s3m", FALSE); - TestLoadS3MFile(pModDoc, true); - pModDoc->OnCloseDocument(); + // Reload the saved file and test if everything is still working correctly. + { + TSoundFileContainer sndFileContainer = CreateSoundFileContainer(filenameBase + "saved.s3m"); + + TestLoadS3MFile(GetrSoundFile(sndFileContainer), true); + + DestroySoundFileContainer(sndFileContainer); } + } double Rand01() {return rand() / double(RAND_MAX);} @@ -1041,6 +1282,7 @@ void TestPCnoteSerialization() //---------------------------- { +#ifdef MODPLUG_TRACKER theApp.OnFileNewMPT(); CMainFrame* pMainFrm = CMainFrame::GetMainFrame(); if(pMainFrm == nullptr) @@ -1050,9 +1292,18 @@ throw(std::runtime_error("pModdoc is nullptr")); CSoundFile &sndFile = pModDoc->GetrSoundFile(); +#else + FileReader file; + std::shared_ptr<CSoundFile> pSndFile(new CSoundFile()); + CSoundFile &sndFile = *pSndFile.get(); +#endif +#ifdef MODPLUG_TRACKER // Set maximum number of channels. pModDoc->ReArrangeChannels(std::vector<CHANNELINDEX>(ModSpecs::mptm.channelsMax , 0)); +#else + // todo: set number of channels +#endif sndFile.Patterns.Remove(0); sndFile.Patterns.Insert(0, ModSpecs::mptm.patternRowsMin); @@ -1108,8 +1359,11 @@ } VERIFY_EQUAL( bPatternDataMatch, true); } - + +#ifdef MODPLUG_TRACKER pModDoc->OnCloseDocument(); +#endif + } @@ -1265,9 +1519,9 @@ for(size_t i = 0; i < 256; i++) { delta += static_cast<int8>(i); - VERIFY_EQUAL_NONCONT(signed8[i], static_cast<int8>(i)); - VERIFY_EQUAL_NONCONT(unsigned8[i], static_cast<uint8>(i + 0x80u)); - VERIFY_EQUAL_NONCONT(delta8[i], static_cast<int8>(delta)); + VERIFY_EQUAL_QUIET_NONCONT(signed8[i], static_cast<int8>(i)); + VERIFY_EQUAL_QUIET_NONCONT(unsigned8[i], static_cast<uint8>(i + 0x80u)); + VERIFY_EQUAL_QUIET_NONCONT(delta8[i], static_cast<int8>(delta)); } } @@ -1295,9 +1549,9 @@ for(size_t i = 0; i < 65536; i++) { delta += static_cast<int16>(i); - VERIFY_EQUAL_NONCONT(signed16[i], static_cast<int16>(i)); - VERIFY_EQUAL_NONCONT(unsigned16[i], static_cast<uint16>(i + 0x8000u)); - VERIFY_EQUAL_NONCONT(delta16[i], static_cast<int16>(delta)); + VERIFY_EQUAL_QUIET_NONCONT(signed16[i], static_cast<int16>(i)); + VERIFY_EQUAL_QUIET_NONCONT(unsigned16[i], static_cast<uint16>(i + 0x8000u)); + VERIFY_EQUAL_QUIET_NONCONT(delta16[i], static_cast<int16>(delta)); } // Big Endian @@ -1316,9 +1570,9 @@ for(size_t i = 0; i < 65536; i++) { delta += static_cast<int16>(i); - VERIFY_EQUAL_NONCONT(signed16[i], static_cast<int16>(i)); - VERIFY_EQUAL_NONCONT(unsigned16[i], static_cast<uint16>(i + 0x8000u)); - VERIFY_EQUAL_NONCONT(delta16[i], static_cast<int16>(delta)); + VERIFY_EQUAL_QUIET_NONCONT(signed16[i], static_cast<int16>(i)); + VERIFY_EQUAL_QUIET_NONCONT(unsigned16[i], static_cast<uint16>(i + 0x8000u)); + VERIFY_EQUAL_QUIET_NONCONT(delta16[i], static_cast<int16>(delta)); } } @@ -1347,9 +1601,9 @@ int16 normValue = static_cast<const int16 *>(sample.pSample)[i]; if(abs(normValue - static_cast<int16>(i - 0x8000u)) > 1) { - VERIFY_EQUAL_NONCONT(true, false); + VERIFY_EQUAL_QUIET_NONCONT(true, false); } - VERIFY_EQUAL_NONCONT(truncated16[i], static_cast<int16>(i)); + VERIFY_EQUAL_QUIET_NONCONT(truncated16[i], static_cast<int16>(i)); } } @@ -1381,11 +1635,11 @@ int16 normValue = static_cast<const int16 *>(sample.pSample)[i]; if(abs(normValue - static_cast<int16>(i- 0x8000u)) > 1) { - VERIFY_EQUAL_NONCONT(true, false); + VERIFY_EQUAL_QUIET_NONCONT(true, false); } if(abs(truncated16[i] - static_cast<int16>((i - 0x8000u) / 2)) > 1) { - VERIFY_EQUAL_NONCONT(true, false); + VERIFY_EQUAL_QUIET_NONCONT(true, false); } } } @@ -1407,14 +1661,14 @@ } -}; //Namespace MptTest +} // namespace MptTest #else //Case: ENABLE_TESTS is not defined. namespace MptTest { void DoTests() {} -}; +} #endif Modified: trunk/OpenMPT/test/test.h =================================================================== --- trunk/OpenMPT/test/test.h 2013-05-25 12:33:18 UTC (rev 2191) +++ trunk/OpenMPT/test/test.h 2013-05-26 14:01:19 UTC (rev 2192) @@ -14,4 +14,4 @@ namespace MptTest { void DoTests(); -}; +} // namespace MptTest This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <man...@us...> - 2013-05-26 14:15:00
|
Revision: 2193 http://sourceforge.net/p/modplug/code/2193 Author: manxorist Date: 2013-05-26 14:14:54 +0000 (Sun, 26 May 2013) Log Message: ----------- [Fix] Make testsuite compile with GCC. Modified Paths: -------------- trunk/OpenMPT/openmpt123/Makefile trunk/OpenMPT/test/test.cpp Modified: trunk/OpenMPT/openmpt123/Makefile =================================================================== --- trunk/OpenMPT/openmpt123/Makefile 2013-05-26 14:01:19 UTC (rev 2192) +++ trunk/OpenMPT/openmpt123/Makefile 2013-05-26 14:14:54 UTC (rev 2193) @@ -45,6 +45,7 @@ LIBOPENMPT_SOURCES += \ $(SOUNDLIB_SOURCES) \ + $(wildcard ../test/*.cpp) \ ../libopenmpt/libopenmpt.cpp \ ../libopenmpt/libopenmpt_c.cpp \ ../libopenmpt/libopenmpt_cxx.cpp \ Modified: trunk/OpenMPT/test/test.cpp =================================================================== --- trunk/OpenMPT/test/test.cpp 2013-05-26 14:01:19 UTC (rev 2192) +++ trunk/OpenMPT/test/test.cpp 2013-05-26 14:14:54 UTC (rev 2193) @@ -40,6 +40,7 @@ #include <istream> #include <ostream> #include <sstream> +#include <stdexcept> #ifdef _DEBUG #if MPT_COMPILER_MSVC && defined(_MFC_VER) @@ -1139,7 +1140,7 @@ return pSndFile; } -static void DestroySoundFileContainer(TSoundFileContainer &sndFile) +static void DestroySoundFileContainer(TSoundFileContainer & /* sndFile */ ) { return; } @@ -1378,13 +1379,13 @@ char dst2[3]; // Destination buffer, smaller than source buffer #define ReadTest(mode, dst, src, expectedResult) \ - mpt::String::Read<mpt::String::##mode>(dst, src); \ + mpt::String::Read<mpt::String:: mode >(dst, src); \ VERIFY_EQUAL_NONCONT(strncmp(dst, expectedResult, CountOf(dst)), 0); /* Ensure that the strings are identical */ \ for(size_t i = strlen(dst); i < CountOf(dst); i++) \ VERIFY_EQUAL_NONCONT(dst[i], '\0'); /* Ensure that rest of the buffer is completely nulled */ #define WriteTest(mode, dst, src, expectedResult) \ - mpt::String::Write<mpt::String::##mode>(dst, src); \ + mpt::String::Write<mpt::String:: mode >(dst, src); \ VERIFY_EQUAL_NONCONT(strncmp(dst, expectedResult, CountOf(dst)), 0); /* Ensure that the strings are identical */ \ for(size_t i = strlen(dst); i < CountOf(dst); i++) \ VERIFY_EQUAL_NONCONT(dst[i], '\0'); /* Ensure that rest of the buffer is completely nulled */ @@ -1657,7 +1658,7 @@ } delete[] sourceBuf; - delete[] targetBuf; + delete[] static_cast<uint8*>(targetBuf); } This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <man...@us...> - 2013-05-30 16:15:12
|
Revision: 2230 http://sourceforge.net/p/modplug/code/2230 Author: manxorist Date: 2013-05-30 16:15:05 +0000 (Thu, 30 May 2013) Log Message: ----------- [Fix] mpt::String::RTrim, mpt::String::LTrim and mpt::String::Trim would not remove whitespace at all if the string contained only whitespace. Fix it. Modified Paths: -------------- trunk/OpenMPT/common/mptString.h trunk/OpenMPT/test/test.cpp Modified: trunk/OpenMPT/common/mptString.h =================================================================== --- trunk/OpenMPT/common/mptString.h 2013-05-29 21:17:57 UTC (rev 2229) +++ trunk/OpenMPT/common/mptString.h 2013-05-30 16:15:05 UTC (rev 2230) @@ -60,6 +60,9 @@ if(pos != std::string::npos) { str.erase(str.begin(), str.begin() + pos); + } else if(pos == std::string::npos && str.length() > 0 && str.find_last_of(whitespace) == str.length() - 1) + { + return std::string(); } return str; } @@ -72,6 +75,9 @@ if(pos != std::string::npos) { str.erase(str.begin() + pos + 1, str.end()); + } else if(pos == std::string::npos && str.length() > 0 && str.find_first_of(whitespace) == 0) + { + return std::string(); } return str; } Modified: trunk/OpenMPT/test/test.cpp =================================================================== --- trunk/OpenMPT/test/test.cpp 2013-05-29 21:17:57 UTC (rev 2229) +++ trunk/OpenMPT/test/test.cpp 2013-05-30 16:15:05 UTC (rev 2230) @@ -415,7 +415,11 @@ VERIFY_EQUAL( mpt::saturate_cast<uint16>(std::numeric_limits<int16>::max() + 1), (uint16)std::numeric_limits<int16>::max() + 1 ); VERIFY_EQUAL( mpt::saturate_cast<uint32>(std::numeric_limits<int32>::min() - int64(1)), std::numeric_limits<uint32>::min() ); VERIFY_EQUAL( mpt::saturate_cast<uint32>(std::numeric_limits<int32>::max() + int64(1)), (uint32)std::numeric_limits<int32>::max() + 1 ); - + + VERIFY_EQUAL( mpt::String::LTrim(" "), "" ); + VERIFY_EQUAL( mpt::String::RTrim(" "), "" ); + VERIFY_EQUAL( mpt::String::Trim(" "), "" ); + // These should fail to compile //Util::Round<std::string>(1.0); //Util::Round<int64>(1.0); This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <sag...@us...> - 2013-05-30 18:09:03
|
Revision: 2233 http://sourceforge.net/p/modplug/code/2233 Author: saga-games Date: 2013-05-30 18:08:56 +0000 (Thu, 30 May 2013) Log Message: ----------- [Fix] Sample Editor: Fixed crash when trying to trigger a note > B-9. [Fix] Fixed theoretically possible crash when converting periods to frequencies in XM files. Modified Paths: -------------- trunk/OpenMPT/mptrack/View_smp.cpp trunk/OpenMPT/soundlib/Snd_fx.cpp Modified: trunk/OpenMPT/mptrack/View_smp.cpp =================================================================== --- trunk/OpenMPT/mptrack/View_smp.cpp 2013-05-30 16:18:16 UTC (rev 2232) +++ trunk/OpenMPT/mptrack/View_smp.cpp 2013-05-30 18:08:56 UTC (rev 2233) @@ -2226,8 +2226,7 @@ if (note >= NOTE_MIN_SPECIAL) { pModDoc->NoteOff(0, (note == NOTE_NOTECUT)); - } - else + } else if(ModCommand::IsNote((ModCommand::NOTE)note)) { if (m_dwStatus & SMPSTATUS_KEYDOWN) pModDoc->NoteOff(note, true); Modified: trunk/OpenMPT/soundlib/Snd_fx.cpp =================================================================== --- trunk/OpenMPT/soundlib/Snd_fx.cpp 2013-05-30 16:18:16 UTC (rev 2232) +++ trunk/OpenMPT/soundlib/Snd_fx.cpp 2013-05-30 18:08:56 UTC (rev 2233) @@ -4713,6 +4713,7 @@ return (XMLinearTable[period % 768] << FREQ_FRACBITS) >> octave; } else { + if(!period) period = 1; return ((8363 * 1712L) << FREQ_FRACBITS) / period; } } else This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |