From 15e133afb9772673cd14d39b310002afe37594a4 Mon Sep 17 00:00:00 2001 From: Vitaly Novichkov Date: Sun, 25 Mar 2018 00:38:26 +0300 Subject: [PATCH] ADLMIDI & OPNMIDI: Little clean and MSVC warnings muting --- src/sound/adlmidi/adlmidi.cpp | 21 ++++++--------------- src/sound/adlmidi/adlmidi_private.hpp | 8 +++++++- src/sound/opnmidi/opnmidi_private.hpp | 8 +++++++- 3 files changed, 20 insertions(+), 17 deletions(-) diff --git a/src/sound/adlmidi/adlmidi.cpp b/src/sound/adlmidi/adlmidi.cpp index 3b2143641..586cb901e 100644 --- a/src/sound/adlmidi/adlmidi.cpp +++ b/src/sound/adlmidi/adlmidi.cpp @@ -107,13 +107,9 @@ ADLMIDI_EXPORT int adl_setBank(ADL_MIDIPlayer *device, int bank) MIDIplay *play = reinterpret_cast(device->adl_midiPlayer); if(static_cast(bankno) >= NumBanks) { - #ifndef __WATCOMC__ - std::stringstream s; - s << "bank number may only be 0.." << (NumBanks - 1) << ".\n"; - play->setErrorString(s.str()); - #else - play->setErrorString("Selected embedded bank is not exists!\n"); - #endif + char errBuf[150]; + std::snprintf(errBuf, 150, "Embedded bank number may only be 0..%u!\n", (NumBanks - 1)); + play->setErrorString(errBuf); return -1; } @@ -142,14 +138,9 @@ ADLMIDI_EXPORT int adl_setNumFourOpsChn(ADL_MIDIPlayer *device, int ops4) MIDIplay *play = reinterpret_cast(device->adl_midiPlayer); if((unsigned int)ops4 > 6 * play->m_setup.NumCards) { - #ifndef __WATCOMC__ - std::stringstream s; - s << "number of four-op channels may only be 0.." << (6 * (play->m_setup.NumCards)) << " when " << play->m_setup.NumCards << " OPL3 cards are used.\n"; - play->setErrorString(s.str()); - #else - play->setErrorString("number of four-op channels may not be more than 6 channels per each OPL3 chip!\n"); - #endif - + char errBuff[250]; + std::snprintf(errBuff, 250, "number of four-op channels may only be 0..%u when %u OPL3 cards are used.\n", (6 * (play->m_setup.NumCards)), play->m_setup.NumCards); + play->setErrorString(errBuff); return -1; } diff --git a/src/sound/adlmidi/adlmidi_private.hpp b/src/sound/adlmidi/adlmidi_private.hpp index 8b2bf19da..8f0c6579f 100644 --- a/src/sound/adlmidi/adlmidi_private.hpp +++ b/src/sound/adlmidi/adlmidi_private.hpp @@ -75,7 +75,6 @@ typedef int32_t ssize_t; #include #include #include -#include //#ifdef __WATCOMC__ //#include //TODO: Implemnet a workaround for OpenWatcom to fix a crash while using those containers //#include @@ -105,6 +104,13 @@ typedef int32_t ssize_t; #include #include +#ifdef _MSC_VER +#pragma warning(disable:4319) +#pragma warning(disable:4267) +#pragma warning(disable:4244) +#pragma warning(disable:4146) +#endif + #include "fraction.hpp" #ifndef ADLMIDI_HW_OPL diff --git a/src/sound/opnmidi/opnmidi_private.hpp b/src/sound/opnmidi/opnmidi_private.hpp index a41216f1b..fa32fbdc6 100644 --- a/src/sound/opnmidi/opnmidi_private.hpp +++ b/src/sound/opnmidi/opnmidi_private.hpp @@ -56,7 +56,6 @@ typedef __int32 ssize_t; #include #include #include -#include #include #include #include @@ -78,6 +77,13 @@ typedef __int32 ssize_t; #include #include +#ifdef _MSC_VER +#pragma warning(disable:4319) +#pragma warning(disable:4267) +#pragma warning(disable:4244) +#pragma warning(disable:4146) +#endif + #include "fraction.hpp" #ifdef OPNMIDI_USE_LEGACY_EMULATOR #include "Ym2612_ChipEmu.h"