|
From: <man...@us...> - 2013-10-11 12:48:52
|
Revision: 2867
http://sourceforge.net/p/modplug/code/2867
Author: manxorist
Date: 2013-10-11 12:48:46 +0000 (Fri, 11 Oct 2013)
Log Message:
-----------
[Fix] openmpt123: Fix building with miniz on unix.
Modified Paths:
--------------
trunk/OpenMPT/common/BuildSettings.h
trunk/OpenMPT/openmpt123/Makefile
Property Changed:
----------------
trunk/OpenMPT/include/miniz/
Modified: trunk/OpenMPT/common/BuildSettings.h
===================================================================
--- trunk/OpenMPT/common/BuildSettings.h 2013-10-11 12:36:01 UTC (rev 2866)
+++ trunk/OpenMPT/common/BuildSettings.h 2013-10-11 12:48:46 UTC (rev 2867)
@@ -156,8 +156,10 @@
#define NO_DSOUND
#define NO_FLAC
#if !defined(MPT_WITH_ZLIB)
+#ifndef NO_ZLIB
#define NO_ZLIB
#endif
+#endif
//#define NO_MINIZ
#define NO_MP3_SAMPLES
//#define NO_LIBMODPLUG
Index: trunk/OpenMPT/include/miniz
===================================================================
--- trunk/OpenMPT/include/miniz 2013-10-11 12:36:01 UTC (rev 2866)
+++ trunk/OpenMPT/include/miniz 2013-10-11 12:48:46 UTC (rev 2867)
Property changes on: trunk/OpenMPT/include/miniz
___________________________________________________________________
Added: svn:ignore
## -0,0 +1,2 ##
+*.d
+*.o
Modified: trunk/OpenMPT/openmpt123/Makefile
===================================================================
--- trunk/OpenMPT/openmpt123/Makefile 2013-10-11 12:36:01 UTC (rev 2866)
+++ trunk/OpenMPT/openmpt123/Makefile 2013-10-11 12:48:46 UTC (rev 2867)
@@ -200,10 +200,10 @@
../libopenmpt/libopenmpt_version.cpp \
ifeq ($(NO_ZLIB),1)
-LIBOPENMPT_CXX_SOURCES += ../miniz/miniz.c
+LIBOPENMPT_C_SOURCES += ../include/miniz/miniz.c
endif
-LIBOPENMPT_OBJECTS = $(LIBOPENMPT_CXX_SOURCES:.cpp=.o)
+LIBOPENMPT_OBJECTS += $(LIBOPENMPT_CXX_SOURCES:.cpp=.o) $(LIBOPENMPT_C_SOURCES:.c=.o)
LIBOPENMPT_DEPENDS = $(LIBOPENMPT_OBJECTS:.o=.d)
ALL_OBJECTS += $(LIBOPENMPT_OBJECTS)
ALL_DEPENDS += $(LIBOPENMPT_DEPENDS)
@@ -227,15 +227,18 @@
ifeq ($(DYNLINK),1)
OPENMPT123_CXX_SOURCES += \
$(wildcard ../openmpt123/*.cpp) \
-
+
else
OPENMPT123_CXX_SOURCES += \
$(LIBOPENMPT_CXX_SOURCES) \
$(wildcard ../openmpt123/*.cpp) \
-
+
+OPENMPT123_C_SOURCES += \
+ $(LIBOPENMPT_C_SOURCES) \
+
endif
-OPENMPT123_OBJECTS += $(OPENMPT123_CXX_SOURCES:.cpp=.o)
+OPENMPT123_OBJECTS += $(OPENMPT123_CXX_SOURCES:.cpp=.o) $(OPENMPT123_C_SOURCES:.c=.o)
OPENMPT123_DEPENDS = $(OPENMPT123_OBJECTS:.o=.d)
ALL_OBJECTS += $(OPENMPT123_OBJECTS)
ALL_DEPENDS += $(OPENMPT123_DEPENDS)
@@ -249,10 +252,13 @@
LIBOPENMPTTEST_CXX_SOURCES += \
$(LIBOPENMPT_CXX_SOURCES) \
../libopenmpt/libopenmpt_test.cpp \
-
+
+LIBOPENMPTTEST_C_SOURCES += \
+ $(LIBOPENMPT_C_SOURCES) \
+
endif
-LIBOPENMPTTEST_OBJECTS += $(LIBOPENMPTTEST_CXX_SOURCES:.cpp=.o)
+LIBOPENMPTTEST_OBJECTS += $(LIBOPENMPTTEST_CXX_SOURCES:.cpp=.o) $(LIBOPENMPTTEST_C_SOURCES:.c=.o)
LIBOPENMPTTEST_DEPENDS = $(LIBOPENMPTEST_OBJECTS:.o=.d)
ALL_OBJECTS += $(LIBOPENMPTTEST_OBJECTS)
ALL_DEPENDS += $(LIBOPENMPTTEST_DEPENDS)
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <man...@us...> - 2013-10-13 06:49:55
|
Revision: 2880
http://sourceforge.net/p/modplug/code/2880
Author: manxorist
Date: 2013-10-13 06:49:47 +0000 (Sun, 13 Oct 2013)
Log Message:
-----------
[Ref] sounddev: Make SoundDevice type and index more type-safe and remove old macros.
[Ref] sounddev: Some related small refactorings.
Modified Paths:
--------------
trunk/OpenMPT/mptrack/MainFrm.cpp
trunk/OpenMPT/mptrack/Mainfrm.h
trunk/OpenMPT/mptrack/Mpdlgs.cpp
trunk/OpenMPT/mptrack/Mpdlgs.h
trunk/OpenMPT/mptrack/TrackerSettings.cpp
trunk/OpenMPT/mptrack/TrackerSettings.h
trunk/OpenMPT/sounddev/SoundDevice.cpp
trunk/OpenMPT/sounddev/SoundDevice.h
trunk/OpenMPT/sounddev/SoundDeviceASIO.cpp
trunk/OpenMPT/sounddev/SoundDeviceASIO.h
trunk/OpenMPT/sounddev/SoundDeviceDirectSound.cpp
trunk/OpenMPT/sounddev/SoundDeviceDirectSound.h
trunk/OpenMPT/sounddev/SoundDevicePortAudio.cpp
trunk/OpenMPT/sounddev/SoundDevicePortAudio.h
trunk/OpenMPT/sounddev/SoundDeviceWaveout.cpp
trunk/OpenMPT/sounddev/SoundDeviceWaveout.h
trunk/OpenMPT/sounddev/SoundDevices.h
Modified: trunk/OpenMPT/mptrack/MainFrm.cpp
===================================================================
--- trunk/OpenMPT/mptrack/MainFrm.cpp 2013-10-13 06:29:24 UTC (rev 2879)
+++ trunk/OpenMPT/mptrack/MainFrm.cpp 2013-10-13 06:49:47 UTC (rev 2880)
@@ -247,14 +247,14 @@
if(!theApp.GetSoundDevicesManager()->FindDeviceInfo(TrackerSettings::Instance().m_nWaveDevice))
{
// Fall back to default WaveOut device
- TrackerSettings::Instance().m_nWaveDevice = SNDDEV_BUILD_ID(0, SNDDEV_WAVEOUT);
+ TrackerSettings::Instance().m_nWaveDevice = SoundDeviceID();
}
if(TrackerSettings::Instance().m_MixerSettings.gdwMixingFreq == 0)
{
TrackerSettings::Instance().m_MixerSettings.gdwMixingFreq = MixerSettings().gdwMixingFreq;
#ifndef NO_ASIO
// If no mixing rate is specified and we're using ASIO, get a mixing rate supported by the device.
- if(SNDDEV_GET_TYPE(TrackerSettings::Instance().m_nWaveDevice) == SNDDEV_ASIO)
+ if(TrackerSettings::Instance().m_nWaveDevice.GetType() == SNDDEV_ASIO)
{
ISoundDevice *dummy = theApp.GetSoundDevicesManager()->CreateSoundDevice(TrackerSettings::Instance().m_nWaveDevice);
if(dummy)
@@ -890,15 +890,15 @@
//--------------------------------------
{
Util::lock_guard<Util::mutex> lock(m_SoundDeviceMutex);
- const UINT nDevID = TrackerSettings::Instance().m_nWaveDevice;
- if(gpSoundDevice && (gpSoundDevice->GetDeviceID() != nDevID))
+ const SoundDeviceID deviceID = TrackerSettings::Instance().m_nWaveDevice;
+ if(gpSoundDevice && (gpSoundDevice->GetDeviceID() != deviceID))
{
delete gpSoundDevice;
gpSoundDevice = nullptr;
}
if(!gpSoundDevice)
{
- gpSoundDevice = theApp.GetSoundDevicesManager()->CreateSoundDevice(nDevID);
+ gpSoundDevice = theApp.GetSoundDevicesManager()->CreateSoundDevice(deviceID);
}
if(!gpSoundDevice)
{
@@ -1724,13 +1724,13 @@
}
-BOOL CMainFrame::SetupSoundCard(DWORD deviceflags, DWORD rate, SampleFormat sampleformat, UINT nChns, UINT latency_ms, UINT updateinterval_ms, LONG wd)
-//-----------------------------------------------------------------------------------------------------------------------------------------------------
+BOOL CMainFrame::SetupSoundCard(DWORD deviceflags, DWORD rate, SampleFormat sampleformat, UINT nChns, UINT latency_ms, UINT updateinterval_ms, SoundDeviceID deviceID)
+//--------------------------------------------------------------------------------------------------------------------------------------------------------------------
{
const bool isPlaying = IsPlaying();
if ((TrackerSettings::Instance().GetSoundDeviceFlags() != deviceflags)
|| (TrackerSettings::Instance().m_MixerSettings.gdwMixingFreq != rate)
- || (TrackerSettings::Instance().m_nWaveDevice != wd)
+ || (TrackerSettings::Instance().m_nWaveDevice != deviceID)
|| (TrackerSettings::Instance().m_LatencyMS != latency_ms)
|| (TrackerSettings::Instance().m_UpdateIntervalMS != updateinterval_ms)
|| (TrackerSettings::Instance().m_SampleFormat != sampleformat)
@@ -1742,7 +1742,7 @@
if ((m_pSndFile) && (!m_pSndFile->IsPaused())) pActiveMod = GetModPlaying();
PauseMod();
}
- TrackerSettings::Instance().m_nWaveDevice = wd;
+ TrackerSettings::Instance().m_nWaveDevice = deviceID;
TrackerSettings::Instance().m_MixerSettings.gdwMixingFreq = rate;
TrackerSettings::Instance().SetSoundDeviceFlags(deviceflags);
TrackerSettings::Instance().m_LatencyMS = latency_ms;
Modified: trunk/OpenMPT/mptrack/Mainfrm.h
===================================================================
--- trunk/OpenMPT/mptrack/Mainfrm.h 2013-10-13 06:29:24 UTC (rev 2879)
+++ trunk/OpenMPT/mptrack/Mainfrm.h 2013-10-13 06:49:47 UTC (rev 2880)
@@ -440,7 +440,7 @@
BOOL StopRenderer(CSoundFile*);
void SwitchToActiveView();
- BOOL SetupSoundCard(DWORD deviceflags, DWORD rate, SampleFormat sampleformat, UINT chns, UINT latency_ms, UINT updateinterval_ms, LONG wd);
+ BOOL SetupSoundCard(DWORD deviceflags, DWORD rate, SampleFormat sampleformat, UINT chns, UINT latency_ms, UINT updateinterval_ms, SoundDeviceID deviceID);
BOOL SetupMiscOptions();
BOOL SetupPlayer();
Modified: trunk/OpenMPT/mptrack/Mpdlgs.cpp
===================================================================
--- trunk/OpenMPT/mptrack/Mpdlgs.cpp 2013-10-13 06:29:24 UTC (rev 2879)
+++ trunk/OpenMPT/mptrack/Mpdlgs.cpp 2013-10-13 06:49:47 UTC (rev 2880)
@@ -191,7 +191,7 @@
if(!TrackerSettings::Instance().m_MorePortaudio)
{
- if(it->type == SNDDEV_PORTAUDIO_ASIO || it->type == SNDDEV_PORTAUDIO_DS || it->type == SNDDEV_PORTAUDIO_WMME)
+ if(it->id.GetType() == SNDDEV_PORTAUDIO_ASIO || it->id.GetType() == SNDDEV_PORTAUDIO_DS || it->id.GetType() == SNDDEV_PORTAUDIO_WMME)
{
// skip those portaudio apis that are already implemented via our own ISoundDevice class
// can be overwritten via [Sound Settings]MorePortaudio=1
@@ -204,7 +204,7 @@
cbi.mask = CBEIF_IMAGE | CBEIF_LPARAM | CBEIF_TEXT | CBEIF_SELECTEDIMAGE | CBEIF_OVERLAY;
cbi.iItem = iItem;
cbi.cchTextMax = 0;
- switch(it->type)
+ switch(it->id.GetType())
{
case SNDDEV_DSOUND:
case SNDDEV_PORTAUDIO_DS:
@@ -221,10 +221,13 @@
cbi.iSelectedImage = cbi.iImage;
cbi.iOverlay = cbi.iImage;
cbi.iIndent = 0;
- cbi.lParam = SNDDEV_BUILD_ID(it->index, it->type);
+ cbi.lParam = it->id.GetIdRaw();
cbi.pszText = s;
int pos = m_CbnDevice.InsertItem(&cbi);
- if (cbi.lParam == (LONG)m_nSoundDevice) m_CbnDevice.SetCurSel(pos);
+ if(cbi.lParam == m_nSoundDevice.GetIdRaw())
+ {
+ m_CbnDevice.SetCurSel(pos);
+ }
iItem++;
}
}
@@ -238,8 +241,8 @@
}
-void COptionsSoundcard::UpdateChannels(int dev)
-//---------------------------------------------
+void COptionsSoundcard::UpdateChannels(SoundDeviceID dev)
+//-------------------------------------------------------
{
MPT_UNREFERENCED_PARAMETER(dev);
CHAR s[128];
@@ -259,12 +262,12 @@
}
-void COptionsSoundcard::UpdateSampleFormat(int dev)
-//-------------------------------------------------
+void COptionsSoundcard::UpdateSampleFormat(SoundDeviceID dev)
+//-----------------------------------------------------------
{
UINT n = 0;
m_CbnSampleFormat.ResetContent();
- const bool asio = SNDDEV_GET_TYPE(dev) == SNDDEV_ASIO;
+ const bool asio = dev.GetType() == SNDDEV_ASIO;
if(asio)
{
m_SampleFormat = TrackerSettings::Instance().m_SampleFormat;
@@ -363,7 +366,7 @@
int n = m_CbnDevice.GetCurSel();
if (n >= 0)
{
- int dev = m_CbnDevice.GetItemData(n);
+ SoundDeviceID dev = SoundDeviceID::FromIdRaw(m_CbnDevice.GetItemData(n));
UpdateControls(dev);
UpdateSampleRates(dev);
UpdateChannels(dev);
@@ -374,8 +377,8 @@
// Fill the dropdown box with a list of valid sample rates, depending on the selected sound device.
-void COptionsSoundcard::UpdateSampleRates(int dev)
-//------------------------------------------------
+void COptionsSoundcard::UpdateSampleRates(SoundDeviceID dev)
+//----------------------------------------------------------
{
m_CbnMixingFreq.ResetContent();
@@ -426,13 +429,13 @@
}
-void COptionsSoundcard::UpdateControls(int dev)
-//---------------------------------------------
+void COptionsSoundcard::UpdateControls(SoundDeviceID dev)
+//-------------------------------------------------------
{
- GetDlgItem(IDC_CHECK4)->EnableWindow((SNDDEV_GET_TYPE(dev) == SNDDEV_DSOUND || SNDDEV_GET_TYPE(dev) == SNDDEV_PORTAUDIO_WASAPI) ? TRUE : FALSE);
- GetDlgItem(IDC_STATIC_UPDATEINTERVAL)->EnableWindow((SNDDEV_GET_TYPE(dev) == SNDDEV_ASIO) ? FALSE : TRUE);
- GetDlgItem(IDC_COMBO_UPDATEINTERVAL)->EnableWindow((SNDDEV_GET_TYPE(dev) == SNDDEV_ASIO) ? FALSE : TRUE);
- if(SNDDEV_GET_TYPE(dev) == SNDDEV_DSOUND)
+ GetDlgItem(IDC_CHECK4)->EnableWindow((dev.GetType() == SNDDEV_DSOUND || dev.GetType() == SNDDEV_PORTAUDIO_WASAPI) ? TRUE : FALSE);
+ GetDlgItem(IDC_STATIC_UPDATEINTERVAL)->EnableWindow((dev.GetType() == SNDDEV_ASIO) ? FALSE : TRUE);
+ GetDlgItem(IDC_COMBO_UPDATEINTERVAL)->EnableWindow((dev.GetType() == SNDDEV_ASIO) ? FALSE : TRUE);
+ if(dev.GetType() == SNDDEV_DSOUND)
{
GetDlgItem(IDC_CHECK4)->SetWindowText("Use primary buffer");
} else
@@ -484,7 +487,10 @@
// Sound Device
{
int n = m_CbnDevice.GetCurSel();
- if (n >= 0) m_nSoundDevice = m_CbnDevice.GetItemData(n);
+ if(n >= 0)
+ {
+ m_nSoundDevice = SoundDeviceID::FromIdRaw(m_CbnDevice.GetItemData(n));
+ }
}
// Latency
{
Modified: trunk/OpenMPT/mptrack/Mpdlgs.h
===================================================================
--- trunk/OpenMPT/mptrack/Mpdlgs.h 2013-10-13 06:29:24 UTC (rev 2879)
+++ trunk/OpenMPT/mptrack/Mpdlgs.h 2013-10-13 06:49:47 UTC (rev 2880)
@@ -29,21 +29,21 @@
DWORD m_nChannels;
DWORD m_LatencyMS;
DWORD m_UpdateIntervalMS;
- DWORD m_nSoundDevice;
+ SoundDeviceID m_nSoundDevice;
bool m_PreAmpNoteShowed;
public:
- COptionsSoundcard(DWORD rate, DWORD flags, SampleFormat sampleformat, DWORD chns, DWORD latency_ms, DWORD updateinterval_ms, DWORD sd):CPropertyPage(IDD_OPTIONS_SOUNDCARD)
+ COptionsSoundcard(DWORD rate, DWORD flags, SampleFormat sampleformat, DWORD chns, DWORD latency_ms, DWORD updateinterval_ms, SoundDeviceID sd):CPropertyPage(IDD_OPTIONS_SOUNDCARD)
{ m_dwRate = rate; m_SoundDeviceFlags = flags; m_SampleFormat = sampleformat; m_nChannels = chns;
m_LatencyMS = latency_ms; m_UpdateIntervalMS = updateinterval_ms; m_nSoundDevice = sd; m_PreAmpNoteShowed = false; }
void UpdateStatistics();
private:
- void UpdateSampleRates(int dev);
- void UpdateChannels(int dev);
- void UpdateSampleFormat(int dev);
- void UpdateControls(int dev);
+ void UpdateSampleRates(SoundDeviceID dev);
+ void UpdateChannels(SoundDeviceID dev);
+ void UpdateSampleFormat(SoundDeviceID dev);
+ void UpdateControls(SoundDeviceID dev);
void SetPreAmpSliderPosition();
protected:
Modified: trunk/OpenMPT/mptrack/TrackerSettings.cpp
===================================================================
--- trunk/OpenMPT/mptrack/TrackerSettings.cpp 2013-10-13 06:29:24 UTC (rev 2879)
+++ trunk/OpenMPT/mptrack/TrackerSettings.cpp 2013-10-13 06:49:47 UTC (rev 2880)
@@ -70,7 +70,7 @@
// Audio device
gbLoopSong = TRUE;
m_MorePortaudio = false;
- m_nWaveDevice = SNDDEV_BUILD_ID(0, SNDDEV_WAVEOUT); // Default value will be overridden
+ m_nWaveDevice = SoundDeviceID(); // Default value will be overridden
m_LatencyMS = SNDDEV_DEFAULT_LATENCY_MS;
m_UpdateIntervalMS = SNDDEV_DEFAULT_UPDATEINTERVAL_MS;
m_SoundDeviceExclusiveMode = false;
@@ -332,11 +332,10 @@
}
m_MorePortaudio = CMainFrame::GetPrivateProfileBool("Sound Settings", "MorePortaudio", m_MorePortaudio, iniFile);
- DWORD defaultDevice = SNDDEV_BUILD_ID(0, SNDDEV_WAVEOUT); // first WaveOut device
#ifndef NO_ASIO
CASIODevice::baseChannel = GetPrivateProfileInt("Sound Settings", "ASIOBaseChannel", CASIODevice::baseChannel, iniFile);
#endif // NO_ASIO
- m_nWaveDevice = CMainFrame::GetPrivateProfileLong("Sound Settings", "WaveDevice", defaultDevice, iniFile);
+ m_nWaveDevice = SoundDeviceID::FromIdRaw(CMainFrame::GetPrivateProfileLong("Sound Settings", "WaveDevice", SoundDeviceID().GetIdRaw(), iniFile));
if(vIniVersion < MAKE_VERSION_NUMERIC(1, 22, 01, 03)) m_MixerSettings.MixerFlags |= OLD_SOUNDSETUP_SECONDARY;
m_MixerSettings.MixerFlags = CMainFrame::GetPrivateProfileDWord("Sound Settings", "SoundSetup", m_MixerSettings.MixerFlags, iniFile);
m_SoundDeviceExclusiveMode = CMainFrame::GetPrivateProfileBool("Sound Settings", "ExclusiveMode", m_SoundDeviceExclusiveMode, iniFile);
@@ -364,7 +363,7 @@
{
if(BufferLengthMS < OLD_SNDDEV_MINBUFFERLEN) BufferLengthMS = OLD_SNDDEV_MINBUFFERLEN;
if(BufferLengthMS > OLD_SNDDEV_MAXBUFFERLEN) BufferLengthMS = OLD_SNDDEV_MAXBUFFERLEN;
- if(SNDDEV_GET_TYPE(m_nWaveDevice) == SNDDEV_ASIO)
+ if(m_nWaveDevice.GetType() == SNDDEV_ASIO)
{
m_LatencyMS = BufferLengthMS;
m_UpdateIntervalMS = BufferLengthMS / 8;
@@ -612,7 +611,7 @@
if(BufferLengthMS != 0)
{
if((BufferLengthMS < OLD_SNDDEV_MINBUFFERLEN) || (BufferLengthMS > OLD_SNDDEV_MAXBUFFERLEN)) BufferLengthMS = 100;
- if(SNDDEV_GET_TYPE(m_nWaveDevice) == SNDDEV_ASIO)
+ if(m_nWaveDevice.GetType() == SNDDEV_ASIO)
{
m_LatencyMS = BufferLengthMS;
m_UpdateIntervalMS = BufferLengthMS / 8;
@@ -810,7 +809,7 @@
CMainFrame::WritePrivateProfileDWord("Display", s, rgbCustomColors[ncol], iniFile);
}
- CMainFrame::WritePrivateProfileLong("Sound Settings", "WaveDevice", m_nWaveDevice, iniFile);
+ CMainFrame::WritePrivateProfileLong("Sound Settings", "WaveDevice", m_nWaveDevice.GetIdRaw(), iniFile);
CMainFrame::WritePrivateProfileDWord("Sound Settings", "SoundSetup", m_MixerSettings.MixerFlags, iniFile);
CMainFrame::WritePrivateProfileBool("Sound Settings", "ExclusiveMode", m_SoundDeviceExclusiveMode, iniFile);
CMainFrame::WritePrivateProfileBool("Sound Settings", "BoostThreadPriority", m_SoundDeviceBoostThreadPriority, iniFile);
Modified: trunk/OpenMPT/mptrack/TrackerSettings.h
===================================================================
--- trunk/OpenMPT/mptrack/TrackerSettings.h 2013-10-13 06:29:24 UTC (rev 2879)
+++ trunk/OpenMPT/mptrack/TrackerSettings.h 2013-10-13 06:49:47 UTC (rev 2880)
@@ -17,6 +17,7 @@
#include "../sounddsp/EQ.h"
#include "../sounddsp/DSP.h"
#include "../sounddsp/Reverb.h"
+#include "../sounddev/SoundDevice.h"
#include <bitset>
/////////////////////////////////////////////////////////////////////////
@@ -180,7 +181,7 @@
// Audio Setup
DWORD gbLoopSong;
bool m_MorePortaudio;
- LONG m_nWaveDevice; // use the SNDDEV_GET_NUMBER and SNDDEV_GET_TYPE macros to decode
+ SoundDeviceID m_nWaveDevice;
DWORD m_LatencyMS;
DWORD m_UpdateIntervalMS;
bool m_SoundDeviceExclusiveMode;
Modified: trunk/OpenMPT/sounddev/SoundDevice.cpp
===================================================================
--- trunk/OpenMPT/sounddev/SoundDevice.cpp 2013-10-13 06:29:24 UTC (rev 2879)
+++ trunk/OpenMPT/sounddev/SoundDevice.cpp 2013-10-13 06:49:47 UTC (rev 2880)
@@ -31,13 +31,13 @@
// ISoundDevice base class
//
-ISoundDevice::ISoundDevice()
-//--------------------------
+ISoundDevice::ISoundDevice(SoundDeviceID id, const std::wstring &internalID)
+//--------------------------------------------------------------------------
+ : m_Source(nullptr)
+ , m_ID(id)
+ , m_InternalID(internalID)
{
- m_Source = nullptr;
- m_Index = 0;
-
m_RealLatencyMS = static_cast<float>(m_Settings.LatencyMS);
m_RealUpdateIntervalMS = static_cast<float>(m_Settings.UpdateIntervalMS);
@@ -53,14 +53,6 @@
}
-void ISoundDevice::SetDevice(UINT index, const std::wstring &internalID)
-//----------------------------------------------------------------------
-{
- m_Index = index;
- m_InternalID = internalID;
-}
-
-
bool ISoundDevice::FillWaveFormatExtensible(WAVEFORMATEXTENSIBLE &WaveFormat)
//---------------------------------------------------------------------------
{
@@ -646,7 +638,7 @@
case SNDDEV_PORTAUDIO_WMME:
case SNDDEV_PORTAUDIO_DS:
case SNDDEV_PORTAUDIO_ASIO:
- infos = CPortaudioDevice::EnumerateDevices(type);
+ infos = CPortaudioDevice::EnumerateDevices((SoundDeviceType)type);
break;
#endif // NO_PORTAUDIO
@@ -656,12 +648,12 @@
}
-const SoundDeviceInfo * SoundDevicesManager::FindDeviceInfo(UINT type, UINT index) const
-//--------------------------------------------------------------------------------------
+const SoundDeviceInfo * SoundDevicesManager::FindDeviceInfo(SoundDeviceID id) const
+//---------------------------------------------------------------------------------
{
for(std::vector<SoundDeviceInfo>::const_iterator it = begin(); it != end(); ++it)
{
- if(it->type == type && it->index == index)
+ if(it->id == id)
{
return &(*it);
}
@@ -670,23 +662,23 @@
}
-ISoundDevice * SoundDevicesManager::CreateSoundDevice(UINT type, UINT index)
-//--------------------------------------------------------------------------
+ISoundDevice * SoundDevicesManager::CreateSoundDevice(SoundDeviceID id)
+//---------------------------------------------------------------------
{
- const SoundDeviceInfo *info = FindDeviceInfo(type, index);
+ const SoundDeviceInfo *info = FindDeviceInfo(id);
if(!info)
{
return nullptr;
}
ISoundDevice *result = nullptr;
- switch(type)
+ switch(id.GetType())
{
- case SNDDEV_WAVEOUT: result = new CWaveDevice(); break;
+ case SNDDEV_WAVEOUT: result = new CWaveDevice(id, info->internalID); break;
#ifndef NO_DSOUND
- case SNDDEV_DSOUND: result = new CDSoundDevice(); break;
+ case SNDDEV_DSOUND: result = new CDSoundDevice(id, info->internalID); break;
#endif // NO_DSOUND
#ifndef NO_ASIO
- case SNDDEV_ASIO: result = new CASIODevice(); break;
+ case SNDDEV_ASIO: result = new CASIODevice(id, info->internalID); break;
#endif // NO_ASIO
#ifndef NO_PORTAUDIO
case SNDDEV_PORTAUDIO_WASAPI:
@@ -694,14 +686,10 @@
case SNDDEV_PORTAUDIO_WMME:
case SNDDEV_PORTAUDIO_DS:
case SNDDEV_PORTAUDIO_ASIO:
- result = SndDevPortaudioIsInitialized() ? new CPortaudioDevice(CPortaudioDevice::SndDevTypeToHostApi(type)) : nullptr;
+ result = SndDevPortaudioIsInitialized() ? new CPortaudioDevice(id, info->internalID) : nullptr;
break;
#endif // NO_PORTAUDIO
}
- if(result)
- {
- result->SetDevice(index, info->internalID);
- }
return result;
}
Modified: trunk/OpenMPT/sounddev/SoundDevice.h
===================================================================
--- trunk/OpenMPT/sounddev/SoundDevice.h 2013-10-13 06:29:24 UTC (rev 2879)
+++ trunk/OpenMPT/sounddev/SoundDevice.h 2013-10-13 06:49:47 UTC (rev 2880)
@@ -53,9 +53,10 @@
// ISoundDevice Interface
//
-// Sound Device Types
-enum // do not change old values, these get saved to the ini
+enum SoundDeviceType
{
+ // do not change old values, these get saved to the ini
+ SNDDEV_INVALID =-1,
SNDDEV_WAVEOUT = 0,
SNDDEV_DSOUND = 1,
SNDDEV_ASIO = 2,
@@ -67,12 +68,54 @@
SNDDEV_NUM_DEVTYPES
};
-#define SNDDEV_DEVICE_MASK 0xFF // Mask for getting the device number
-#define SNDDEV_DEVICE_SHIFT 8 // Shift amount for getting the device type
-#define SNDDEV_GET_NUMBER(x) (x & SNDDEV_DEVICE_MASK) // Use this for getting the device number
-#define SNDDEV_GET_TYPE(x) (x >> SNDDEV_DEVICE_SHIFT) // ...and this for getting the device type
-#define SNDDEV_BUILD_ID(number, type) ((number & SNDDEV_DEVICE_MASK) | (type << SNDDEV_DEVICE_SHIFT)) // Build a sound device ID from device number and device type.
+typedef uint8 SoundDeviceIndex;
+template<typename T>
+bool SoundDeviceIndexIsValid(const T & x)
+{
+ return 0 <= x && x <= std::numeric_limits<SoundDeviceIndex>::max();
+}
+
+//=================
+class SoundDeviceID
+//=================
+{
+private:
+ SoundDeviceType type;
+ SoundDeviceIndex index;
+public:
+ SoundDeviceID() : type(SNDDEV_WAVEOUT), index(0) {}
+ SoundDeviceID(SoundDeviceType type, SoundDeviceIndex index)
+ : type(type)
+ , index(index)
+ {
+ return;
+ }
+ SoundDeviceType GetType() const { return type; }
+ SoundDeviceIndex GetIndex() const { return index; }
+ bool operator == (const SoundDeviceID &cmp) const
+ {
+ return (type == cmp.type) && (index == cmp.index);
+ }
+
+ bool operator != (const SoundDeviceID &cmp) const
+ {
+ return (type != cmp.type) || (index != cmp.index);
+ }
+public:
+ // Do not change these. These functions are used to manipulate the value that gets stored in the settings.
+ template<typename T>
+ static SoundDeviceID FromIdRaw(T id_)
+ {
+ uint16 id = static_cast<uint16>(id_);
+ return SoundDeviceID((SoundDeviceType)((id>>8)&0xff), (id>>0)&0xff);
+ }
+ uint16 GetIdRaw() const
+ {
+ return static_cast<uint16>(((int)type<<8) | (index<<0));
+ }
+};
+
#define SNDDEV_DEFAULT_LATENCY_MS 100
#define SNDDEV_DEFAULT_UPDATEINTERVAL_MS 5
@@ -120,11 +163,13 @@
friend class SoundDevicesManager;
private:
+
ISoundSource *m_Source;
+ const SoundDeviceID m_ID;
+
protected:
- UINT m_Index;
std::wstring m_InternalID;
SoundDeviceSettings m_Settings;
@@ -144,16 +189,14 @@
void SourceAudioDone(ULONG NumSamples, ULONG SamplesLatency);
public:
- ISoundDevice();
+ ISoundDevice(SoundDeviceID id, const std::wstring &internalID);
virtual ~ISoundDevice();
void SetSource(ISoundSource *source) { m_Source = source; }
ISoundSource *GetSource() const { return m_Source; }
-protected:
- void SetDevice(UINT index, const std::wstring &internalID);
public:
- UINT GetDeviceIndex() const { return m_Index; }
- UINT GetDeviceID() const { return SNDDEV_BUILD_ID(GetDeviceIndex(), GetDeviceType()); }
-
+ SoundDeviceID GetDeviceID() const { return m_ID; }
+ SoundDeviceType GetDeviceType() const { return m_ID.GetType(); }
+ SoundDeviceIndex GetDeviceIndex() const { return m_ID.GetIndex(); }
std::wstring GetDeviceInternalID() const { return m_InternalID; }
public:
@@ -174,7 +217,6 @@
virtual int64 InternalGetStreamPositionSamples() const { return 0; }
public:
- virtual UINT GetDeviceType() const = 0;
bool Open(const SoundDeviceSettings &settings); // Open a device
bool Close(); // Close the currently open device
void Start();
@@ -193,21 +235,14 @@
struct SoundDeviceInfo
{
- UINT type;
- UINT index;
+ SoundDeviceID id;
std::wstring name;
std::wstring internalID;
- SoundDeviceInfo()
- : type(0)
- , index(0)
- {
- return;
- }
- SoundDeviceInfo(UINT type, UINT index, const std::wstring &name, const std::wstring &id = std::wstring())
- : type(type)
- , index(index)
+ SoundDeviceInfo() { }
+ SoundDeviceInfo(SoundDeviceID id, const std::wstring &name, const std::wstring &internalID = std::wstring())
+ : id(id)
, name(name)
- , internalID(id)
+ , internalID(internalID)
{
return;
}
@@ -233,10 +268,8 @@
std::vector<SoundDeviceInfo>::const_iterator end() const { return m_SoundDevices.end(); }
const std::vector<SoundDeviceInfo> & GetDeviceInfos() const { return m_SoundDevices; }
- const SoundDeviceInfo * FindDeviceInfo(UINT type, UINT index) const;
- const SoundDeviceInfo * FindDeviceInfo(UINT id) const { return FindDeviceInfo(SNDDEV_GET_TYPE(id), SNDDEV_GET_NUMBER(id)); }
+ const SoundDeviceInfo * FindDeviceInfo(SoundDeviceID id) const;
- ISoundDevice * CreateSoundDevice(UINT type, UINT index);
- ISoundDevice * CreateSoundDevice(UINT id) { return CreateSoundDevice(SNDDEV_GET_TYPE(id), SNDDEV_GET_NUMBER(id)); }
+ ISoundDevice * CreateSoundDevice(SoundDeviceID id);
};
Modified: trunk/OpenMPT/sounddev/SoundDeviceASIO.cpp
===================================================================
--- trunk/OpenMPT/sounddev/SoundDeviceASIO.cpp 2013-10-13 06:29:24 UTC (rev 2879)
+++ trunk/OpenMPT/sounddev/SoundDeviceASIO.cpp 2013-10-13 06:49:47 UTC (rev 2880)
@@ -134,8 +134,11 @@
Log(" clsid=\"%s\"\n", s);
#endif
- // everything ok
- devices.push_back(SoundDeviceInfo(SNDDEV_ASIO, devices.size(), mpt::String::Decode(description, mpt::CharsetLocale), internalID));
+ if(SoundDeviceIndexIsValid(devices.size()))
+ {
+ // everything ok
+ devices.push_back(SoundDeviceInfo(SoundDeviceID(SNDDEV_ASIO, static_cast<SoundDeviceIndex>(devices.size())), mpt::String::Decode(description, mpt::CharsetLocale), internalID));
+ }
}
}
@@ -155,8 +158,9 @@
}
-CASIODevice::CASIODevice()
-//------------------------
+CASIODevice::CASIODevice(SoundDeviceID id, const std::wstring &internalID)
+//------------------------------------------------------------------------
+ : ISoundDevice(id, internalID)
{
m_pAsioDrv = NULL;
m_nAsioBufferLen = 0;
Modified: trunk/OpenMPT/sounddev/SoundDeviceASIO.h
===================================================================
--- trunk/OpenMPT/sounddev/SoundDeviceASIO.h 2013-10-13 06:29:24 UTC (rev 2879)
+++ trunk/OpenMPT/sounddev/SoundDeviceASIO.h 2013-10-13 06:49:47 UTC (rev 2880)
@@ -52,11 +52,10 @@
static int baseChannel;
public:
- CASIODevice();
+ CASIODevice(SoundDeviceID id, const std::wstring &internalID);
~CASIODevice();
public:
- UINT GetDeviceType() const { return SNDDEV_ASIO; }
bool InternalOpen();
bool InternalClose();
void FillAudioBuffer();
Modified: trunk/OpenMPT/sounddev/SoundDeviceDirectSound.cpp
===================================================================
--- trunk/OpenMPT/sounddev/SoundDeviceDirectSound.cpp 2013-10-13 06:29:24 UTC (rev 2879)
+++ trunk/OpenMPT/sounddev/SoundDeviceDirectSound.cpp 2013-10-13 06:49:47 UTC (rev 2880)
@@ -62,9 +62,12 @@
{
return TRUE;
}
+ if(!SoundDeviceIndexIsValid(devices.size()))
+ {
+ return FALSE;
+ }
SoundDeviceInfo info;
- info.type = SNDDEV_DSOUND;
- info.index = devices.size();
+ info.id = SoundDeviceID(SNDDEV_DSOUND, static_cast<SoundDeviceIndex>(devices.size()));
info.name = lpstrDescription;
if(lpGuid)
{
@@ -84,8 +87,9 @@
}
-CDSoundDevice::CDSoundDevice()
-//----------------------------
+CDSoundDevice::CDSoundDevice(SoundDeviceID id, const std::wstring &internalID)
+//----------------------------------------------------------------------------
+ : CSoundDeviceWithThread(id, internalID)
{
m_piDS = NULL;
m_pPrimary = NULL;
Modified: trunk/OpenMPT/sounddev/SoundDeviceDirectSound.h
===================================================================
--- trunk/OpenMPT/sounddev/SoundDeviceDirectSound.h 2013-10-13 06:29:24 UTC (rev 2879)
+++ trunk/OpenMPT/sounddev/SoundDeviceDirectSound.h 2013-10-13 06:49:47 UTC (rev 2880)
@@ -41,11 +41,10 @@
DWORD m_dwWritePos, m_dwLatency;
public:
- CDSoundDevice();
+ CDSoundDevice(SoundDeviceID id, const std::wstring &internalID);
~CDSoundDevice();
public:
- UINT GetDeviceType() const { return SNDDEV_DSOUND; }
bool InternalOpen();
bool InternalClose();
void FillAudioBuffer();
Modified: trunk/OpenMPT/sounddev/SoundDevicePortAudio.cpp
===================================================================
--- trunk/OpenMPT/sounddev/SoundDevicePortAudio.cpp 2013-10-13 06:29:24 UTC (rev 2879)
+++ trunk/OpenMPT/sounddev/SoundDevicePortAudio.cpp 2013-10-13 06:49:47 UTC (rev 2880)
@@ -26,10 +26,11 @@
#ifndef NO_PORTAUDIO
-CPortaudioDevice::CPortaudioDevice(PaHostApiIndex hostapi)
-//--------------------------------------------------------
+CPortaudioDevice::CPortaudioDevice(SoundDeviceID id, const std::wstring &internalID)
+//----------------------------------------------------------------------------------
+ : ISoundDevice(id, internalID)
{
- m_HostApi = hostapi;
+ m_HostApi = SndDevTypeToHostApi(id.GetType());
MemsetZero(m_StreamParameters);
m_Stream = 0;
m_CurrentFrameCount = 0;
@@ -274,20 +275,20 @@
}
-int CPortaudioDevice::HostApiToSndDevType(PaHostApiIndex hostapi)
-//---------------------------------------------------------------
+SoundDeviceType CPortaudioDevice::HostApiToSndDevType(PaHostApiIndex hostapi)
+//---------------------------------------------------------------------------
{
if(hostapi == Pa_HostApiTypeIdToHostApiIndex(paWASAPI)) return SNDDEV_PORTAUDIO_WASAPI;
if(hostapi == Pa_HostApiTypeIdToHostApiIndex(paWDMKS)) return SNDDEV_PORTAUDIO_WDMKS;
if(hostapi == Pa_HostApiTypeIdToHostApiIndex(paMME)) return SNDDEV_PORTAUDIO_WMME;
if(hostapi == Pa_HostApiTypeIdToHostApiIndex(paDirectSound)) return SNDDEV_PORTAUDIO_DS;
if(hostapi == Pa_HostApiTypeIdToHostApiIndex(paASIO)) return SNDDEV_PORTAUDIO_ASIO;
- return -1;
+ return SNDDEV_INVALID;
}
-PaHostApiIndex CPortaudioDevice::SndDevTypeToHostApi(int snddevtype)
-//------------------------------------------------------------------
+PaHostApiIndex CPortaudioDevice::SndDevTypeToHostApi(SoundDeviceType snddevtype)
+//------------------------------------------------------------------------------
{
if(snddevtype == SNDDEV_PORTAUDIO_WASAPI) return Pa_HostApiTypeIdToHostApiIndex(paWASAPI);
if(snddevtype == SNDDEV_PORTAUDIO_WDMKS) return Pa_HostApiTypeIdToHostApiIndex(paWDMKS);
@@ -298,17 +299,16 @@
}
-bool CPortaudioDevice::EnumerateDevices(SoundDeviceInfo &result, UINT nIndex, PaHostApiIndex hostapi)
-//---------------------------------------------------------------------------------------------------
+bool CPortaudioDevice::EnumerateDevices(SoundDeviceInfo &result, SoundDeviceIndex index, PaHostApiIndex hostapi)
+//--------------------------------------------------------------------------------------------------------------
{
result = SoundDeviceInfo();
- PaDeviceIndex dev = HostApiOutputIndexToGlobalDeviceIndex(nIndex, hostapi);
+ PaDeviceIndex dev = HostApiOutputIndexToGlobalDeviceIndex(index, hostapi);
if(dev == -1)
return false;
if(!Pa_GetDeviceInfo(dev))
return false;
- result.type = HostApiToSndDevType(hostapi);
- result.index = nIndex;
+ result.id = SoundDeviceID(HostApiToSndDevType(hostapi), index);
result.name = mpt::String::Decode(
mpt::String::Format("%s - %s%s (portaudio)",
Pa_GetHostApiInfo(Pa_GetDeviceInfo(dev)->hostApi)->name,
@@ -320,15 +320,15 @@
}
-std::vector<SoundDeviceInfo> CPortaudioDevice::EnumerateDevices(UINT type)
-//------------------------------------------------------------------------
+std::vector<SoundDeviceInfo> CPortaudioDevice::EnumerateDevices(SoundDeviceType type)
+//-----------------------------------------------------------------------------------
{
std::vector<SoundDeviceInfo> devices;
if(!SndDevPortaudioIsInitialized())
{
return devices;
}
- for(UINT index = 0; ; ++index)
+ for(SoundDeviceIndex index = 0; ; ++index)
{
SoundDeviceInfo info;
if(!EnumerateDevices(info, index, CPortaudioDevice::SndDevTypeToHostApi(type)))
Modified: trunk/OpenMPT/sounddev/SoundDevicePortAudio.h
===================================================================
--- trunk/OpenMPT/sounddev/SoundDevicePortAudio.h 2013-10-13 06:29:24 UTC (rev 2879)
+++ trunk/OpenMPT/sounddev/SoundDevicePortAudio.h 2013-10-13 06:49:47 UTC (rev 2880)
@@ -39,11 +39,10 @@
float m_CurrentRealLatencyMS;
public:
- CPortaudioDevice(PaHostApiIndex hostapi);
+ CPortaudioDevice(SoundDeviceID id, const std::wstring &internalID);
~CPortaudioDevice();
public:
- UINT GetDeviceType() const { return HostApiToSndDevType(m_HostApi); }
bool InternalOpen();
bool InternalClose();
void FillAudioBuffer();
@@ -74,13 +73,13 @@
);
static PaDeviceIndex HostApiOutputIndexToGlobalDeviceIndex(int hostapioutputdeviceindex, PaHostApiIndex hostapi);
- static int HostApiToSndDevType(PaHostApiIndex hostapi);
- static PaHostApiIndex SndDevTypeToHostApi(int snddevtype);
+ static SoundDeviceType HostApiToSndDevType(PaHostApiIndex hostapi);
+ static PaHostApiIndex SndDevTypeToHostApi(SoundDeviceType snddevtype);
- static std::vector<SoundDeviceInfo> EnumerateDevices(UINT type);
+ static std::vector<SoundDeviceInfo> EnumerateDevices(SoundDeviceType type);
private:
- static bool EnumerateDevices(SoundDeviceInfo &result, UINT nIndex, PaHostApiIndex hostapi);
+ static bool EnumerateDevices(SoundDeviceInfo &result, SoundDeviceIndex index, PaHostApiIndex hostapi);
};
Modified: trunk/OpenMPT/sounddev/SoundDeviceWaveout.cpp
===================================================================
--- trunk/OpenMPT/sounddev/SoundDeviceWaveout.cpp 2013-10-13 06:29:24 UTC (rev 2879)
+++ trunk/OpenMPT/sounddev/SoundDeviceWaveout.cpp 2013-10-13 06:49:47 UTC (rev 2880)
@@ -25,8 +25,9 @@
//
-CWaveDevice::CWaveDevice()
-//------------------------
+CWaveDevice::CWaveDevice(SoundDeviceID id, const std::wstring &internalID)
+//------------------------------------------------------------------------
+ : CSoundDeviceWithThread(id, internalID)
{
m_hWaveOut = NULL;
m_nWaveBufferSize = 0;
@@ -223,9 +224,12 @@
UINT numDevs = waveOutGetNumDevs();
for(UINT index = 0; index <= numDevs; ++index)
{
+ if(!SoundDeviceIndexIsValid(index))
+ {
+ break;
+ }
SoundDeviceInfo info;
- info.type = SNDDEV_WAVEOUT;
- info.index = index;
+ info.id = SoundDeviceID(SNDDEV_WAVEOUT, static_cast<SoundDeviceIndex>(index));
if(index == 0)
{
info.name = L"Auto (Wave Mapper)";
Modified: trunk/OpenMPT/sounddev/SoundDeviceWaveout.h
===================================================================
--- trunk/OpenMPT/sounddev/SoundDeviceWaveout.h 2013-10-13 06:29:24 UTC (rev 2879)
+++ trunk/OpenMPT/sounddev/SoundDeviceWaveout.h 2013-10-13 06:49:47 UTC (rev 2880)
@@ -40,11 +40,10 @@
std::vector<std::vector<char> > m_WaveBuffersData;
public:
- CWaveDevice();
+ CWaveDevice(SoundDeviceID id, const std::wstring &internalID);
~CWaveDevice();
public:
- UINT GetDeviceType() const { return SNDDEV_WAVEOUT; }
bool InternalOpen();
bool InternalClose();
void FillAudioBuffer();
Modified: trunk/OpenMPT/sounddev/SoundDevices.h
===================================================================
--- trunk/OpenMPT/sounddev/SoundDevices.h 2013-10-13 06:29:24 UTC (rev 2879)
+++ trunk/OpenMPT/sounddev/SoundDevices.h 2013-10-13 06:49:47 UTC (rev 2880)
@@ -63,7 +63,7 @@
private:
void FillAudioBufferLocked();
public:
- CSoundDeviceWithThread() : m_AudioThread(*this) {}
+ CSoundDeviceWithThread(SoundDeviceID id, const std::wstring &internalID) : ISoundDevice(id, internalID), m_AudioThread(*this) {}
virtual ~CSoundDeviceWithThread() {}
void InternalStart();
void InternalStop();
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <man...@us...> - 2013-10-13 09:29:28
|
Revision: 2886
http://sourceforge.net/p/modplug/code/2886
Author: manxorist
Date: 2013-10-13 09:29:16 +0000 (Sun, 13 Oct 2013)
Log Message:
-----------
[Ref] Pass SoundDeviceSettings around as a struct instead of each member individually.
Modified Paths:
--------------
trunk/OpenMPT/mptrack/MainFrm.cpp
trunk/OpenMPT/mptrack/Mainfrm.h
trunk/OpenMPT/mptrack/Mpdlgs.cpp
trunk/OpenMPT/mptrack/Mpdlgs.h
trunk/OpenMPT/mptrack/TrackerSettings.cpp
trunk/OpenMPT/mptrack/TrackerSettings.h
trunk/OpenMPT/sounddev/SoundDevice.cpp
trunk/OpenMPT/sounddev/SoundDevice.h
trunk/OpenMPT/sounddev/SoundDeviceDirectSound.cpp
trunk/OpenMPT/sounddev/SoundDevicePortAudio.cpp
Modified: trunk/OpenMPT/mptrack/MainFrm.cpp
===================================================================
--- trunk/OpenMPT/mptrack/MainFrm.cpp 2013-10-13 08:17:05 UTC (rev 2885)
+++ trunk/OpenMPT/mptrack/MainFrm.cpp 2013-10-13 09:29:16 UTC (rev 2886)
@@ -905,15 +905,7 @@
return false;
}
gpSoundDevice->SetSource(this);
- SoundDeviceSettings settings;
- settings.hWnd = m_hWnd;
- settings.LatencyMS = TrackerSettings::Instance().m_LatencyMS;
- settings.UpdateIntervalMS = TrackerSettings::Instance().m_UpdateIntervalMS;
- settings.fulCfgOptions = TrackerSettings::Instance().GetSoundDeviceFlags();
- settings.Samplerate = TrackerSettings::Instance().m_MixerSettings.gdwMixingFreq;
- settings.Channels = (uint8)TrackerSettings::Instance().m_MixerSettings.gnChannels;
- settings.sampleFormat = TrackerSettings::Instance().m_SampleFormat;
- return gpSoundDevice->Open(settings);
+ return gpSoundDevice->Open(TrackerSettings::Instance().GetSoundDeviceSettings());
}
@@ -1724,17 +1716,11 @@
}
-BOOL CMainFrame::SetupSoundCard(DWORD deviceflags, DWORD rate, SampleFormat sampleformat, UINT nChns, UINT latency_ms, UINT updateinterval_ms, SoundDeviceID deviceID)
-//--------------------------------------------------------------------------------------------------------------------------------------------------------------------
+BOOL CMainFrame::SetupSoundCard(const SoundDeviceSettings &deviceSettings, SoundDeviceID deviceID)
+//------------------------------------------------------------------------------------------------
{
const bool isPlaying = IsPlaying();
- if ((TrackerSettings::Instance().GetSoundDeviceFlags() != deviceflags)
- || (TrackerSettings::Instance().m_MixerSettings.gdwMixingFreq != rate)
- || (TrackerSettings::Instance().m_nWaveDevice != deviceID)
- || (TrackerSettings::Instance().m_LatencyMS != latency_ms)
- || (TrackerSettings::Instance().m_UpdateIntervalMS != updateinterval_ms)
- || (TrackerSettings::Instance().m_SampleFormat != sampleformat)
- || (TrackerSettings::Instance().m_MixerSettings.gnChannels != nChns))
+ if((TrackerSettings::Instance().m_nWaveDevice != deviceID) || (TrackerSettings::Instance().GetSoundDeviceSettings() != deviceSettings))
{
CModDoc *pActiveMod = NULL;
if (isPlaying)
@@ -1743,12 +1729,7 @@
PauseMod();
}
TrackerSettings::Instance().m_nWaveDevice = deviceID;
- TrackerSettings::Instance().m_MixerSettings.gdwMixingFreq = rate;
- TrackerSettings::Instance().SetSoundDeviceFlags(deviceflags);
- TrackerSettings::Instance().m_LatencyMS = latency_ms;
- TrackerSettings::Instance().m_UpdateIntervalMS = updateinterval_ms;
- TrackerSettings::Instance().m_SampleFormat = sampleformat;
- TrackerSettings::Instance().m_MixerSettings.gnChannels = nChns;
+ TrackerSettings::Instance().SetSoundDeviceSettings(deviceSettings);
{
CriticalSection cs;
if (pActiveMod) UpdateAudioParameters(pActiveMod->GetrSoundFile(), FALSE);
@@ -1916,7 +1897,7 @@
CPropertySheet dlg("OpenMPT Setup", this, m_nLastOptionsPage);
COptionsGeneral general;
- COptionsSoundcard sounddlg(TrackerSettings::Instance().m_MixerSettings.gdwMixingFreq, TrackerSettings::Instance().GetSoundDeviceFlags(), TrackerSettings::Instance().m_SampleFormat, TrackerSettings::Instance().m_MixerSettings.gnChannels, TrackerSettings::Instance().m_LatencyMS, TrackerSettings::Instance().m_UpdateIntervalMS, TrackerSettings::Instance().m_nWaveDevice);
+ COptionsSoundcard sounddlg(TrackerSettings::Instance().GetSoundDeviceSettings(), TrackerSettings::Instance().m_nWaveDevice);
COptionsKeyboard keyboard;
COptionsColors colors;
COptionsPlayer playerdlg;
Modified: trunk/OpenMPT/mptrack/Mainfrm.h
===================================================================
--- trunk/OpenMPT/mptrack/Mainfrm.h 2013-10-13 08:17:05 UTC (rev 2885)
+++ trunk/OpenMPT/mptrack/Mainfrm.h 2013-10-13 09:29:16 UTC (rev 2886)
@@ -440,7 +440,7 @@
BOOL StopRenderer(CSoundFile*);
void SwitchToActiveView();
- BOOL SetupSoundCard(DWORD deviceflags, DWORD rate, SampleFormat sampleformat, UINT chns, UINT latency_ms, UINT updateinterval_ms, SoundDeviceID deviceID);
+ BOOL SetupSoundCard(const SoundDeviceSettings &deviceSettings, SoundDeviceID deviceID);
BOOL SetupMiscOptions();
BOOL SetupPlayer();
Modified: trunk/OpenMPT/mptrack/Mpdlgs.cpp
===================================================================
--- trunk/OpenMPT/mptrack/Mpdlgs.cpp 2013-10-13 08:17:05 UTC (rev 2885)
+++ trunk/OpenMPT/mptrack/Mpdlgs.cpp 2013-10-13 09:29:16 UTC (rev 2886)
@@ -107,8 +107,8 @@
CPropertyPage::OnInitDialog();
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);
+ if(m_Settings.ExclusiveMode) CheckDlgButton(IDC_CHECK4, MF_CHECKED);
+ if(m_Settings.BoostThreadPriority) CheckDlgButton(IDC_CHECK5, MF_CHECKED);
// Sampling Rate
UpdateSampleRates(m_nSoundDevice);
@@ -124,7 +124,7 @@
}
// latency
{
- wsprintf(s, "%d ms", m_LatencyMS);
+ wsprintf(s, "%d ms", m_Settings.LatencyMS);
m_CbnLatencyMS.SetWindowText(s);
m_CbnLatencyMS.AddString("1 ms");
m_CbnLatencyMS.AddString("2 ms");
@@ -146,7 +146,7 @@
}
// update interval
{
- wsprintf(s, "%d ms", m_UpdateIntervalMS);
+ wsprintf(s, "%d ms", m_Settings.UpdateIntervalMS);
m_CbnUpdateIntervalMS.SetWindowText(s);
m_CbnUpdateIntervalMS.AddString("1 ms");
m_CbnUpdateIntervalMS.AddString("2 ms");
@@ -253,7 +253,7 @@
wsprintf(s, "%s", gszChnCfgNames[(channels+2)/2-1]);
UINT ndx = m_CbnChannels.AddString(s);
m_CbnChannels.SetItemData(ndx, channels);
- if(channels == m_nChannels)
+ if(channels == m_Settings.Channels)
{
n = ndx;
}
@@ -270,29 +270,29 @@
const bool asio = dev.GetType() == SNDDEV_ASIO;
if(asio)
{
- m_SampleFormat = TrackerSettings::Instance().m_SampleFormat;
+ m_Settings.sampleFormat = TrackerSettings::Instance().m_SampleFormat;
}
m_CbnSampleFormat.EnableWindow(asio ? FALSE : TRUE);
for(UINT bits = 40; bits >= 8; bits -= 8)
{
if(bits == 40)
{
- if(!asio || (asio && SampleFormatFloat32 == m_SampleFormat))
+ if(!asio || (asio && SampleFormatFloat32 == m_Settings.sampleFormat))
{
UINT ndx = m_CbnSampleFormat.AddString("Floating Point");
m_CbnSampleFormat.SetItemData(ndx, (32+128));
- if(SampleFormatFloat32 == m_SampleFormat)
+ if(SampleFormatFloat32 == m_Settings.sampleFormat)
{
n = ndx;
}
}
} else
{
- if(!asio || (asio && (SampleFormat)bits == m_SampleFormat))
+ if(!asio || (asio && (SampleFormat)bits == m_Settings.sampleFormat))
{
UINT ndx = m_CbnSampleFormat.AddString(mpt::String::Format("%d Bit", bits).c_str());
m_CbnSampleFormat.SetItemData(ndx, bits);
- if((SampleFormat)bits == m_SampleFormat)
+ if((SampleFormat)bits == m_Settings.sampleFormat)
{
n = ndx;
}
@@ -423,7 +423,10 @@
wsprintf(s, "%i Hz", samplerates[i]);
int pos = m_CbnMixingFreq.AddString(s);
m_CbnMixingFreq.SetItemData(pos, samplerates[i]);
- if(m_dwRate == samplerates[i]) n = pos;
+ if(m_Settings.Samplerate == samplerates[i])
+ {
+ n = pos;
+ }
}
m_CbnMixingFreq.SetCurSel(n);
}
@@ -457,23 +460,25 @@
//----------------------------
{
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;
- if(IsDlgButtonChecked(IDC_CHECK5)) m_SoundDeviceFlags |= SNDDEV_OPTIONS_BOOSTTHREADPRIORITY;
+ m_Settings.ExclusiveMode = IsDlgButtonChecked(IDC_CHECK4) ? true : false;
+ m_Settings.BoostThreadPriority = IsDlgButtonChecked(IDC_CHECK5) ? true : false;
// Mixing Freq
{
- m_dwRate = m_CbnMixingFreq.GetItemData(m_CbnMixingFreq.GetCurSel());
+ m_Settings.Samplerate = m_CbnMixingFreq.GetItemData(m_CbnMixingFreq.GetCurSel());
}
// Channels
{
UINT n = m_CbnChannels.GetItemData(m_CbnChannels.GetCurSel());
- m_nChannels = n;
- if((m_nChannels != 1) && (m_nChannels != 4))m_nChannels = 2;
+ m_Settings.Channels = static_cast<uint8>(n);
+ if((m_Settings.Channels != 1) && (m_Settings.Channels != 4))
+ {
+ m_Settings.Channels = 2;
+ }
}
// SampleFormat
{
UINT n = m_CbnSampleFormat.GetItemData(m_CbnSampleFormat.GetCurSel());
- m_SampleFormat = (SampleFormat)(n & 0xFF);
+ m_Settings.sampleFormat = (SampleFormat)(n & 0xFF);
}
// Polyphony
{
@@ -496,23 +501,23 @@
{
CHAR s[32];
m_CbnLatencyMS.GetWindowText(s, sizeof(s));
- m_LatencyMS = atoi(s);
+ m_Settings.LatencyMS = atoi(s);
//Check given value.
- m_LatencyMS = CLAMP(m_LatencyMS, SNDDEV_MINLATENCY_MS, SNDDEV_MAXLATENCY_MS);
- wsprintf(s, "%d ms", m_LatencyMS);
+ m_Settings.LatencyMS = CLAMP(m_Settings.LatencyMS, SNDDEV_MINLATENCY_MS, SNDDEV_MAXLATENCY_MS);
+ wsprintf(s, "%d ms", m_Settings.LatencyMS);
m_CbnLatencyMS.SetWindowText(s);
}
// Update Interval
{
CHAR s[32];
m_CbnUpdateIntervalMS.GetWindowText(s, sizeof(s));
- m_UpdateIntervalMS = atoi(s);
+ m_Settings.UpdateIntervalMS = atoi(s);
//Check given value.
- m_UpdateIntervalMS = CLAMP(m_UpdateIntervalMS, SNDDEV_MINUPDATEINTERVAL_MS, SNDDEV_MAXUPDATEINTERVAL_MS);
- wsprintf(s, "%d ms", m_UpdateIntervalMS);
+ m_Settings.UpdateIntervalMS = CLAMP(m_Settings.UpdateIntervalMS, SNDDEV_MINUPDATEINTERVAL_MS, SNDDEV_MAXUPDATEINTERVAL_MS);
+ wsprintf(s, "%d ms", m_Settings.UpdateIntervalMS);
m_CbnUpdateIntervalMS.SetWindowText(s);
}
- CMainFrame::GetMainFrame()->SetupSoundCard(m_SoundDeviceFlags, m_dwRate, m_SampleFormat, m_nChannels, m_LatencyMS, m_UpdateIntervalMS, m_nSoundDevice);
+ CMainFrame::GetMainFrame()->SetupSoundCard(m_Settings, m_nSoundDevice);
UpdateSampleFormat(m_nSoundDevice);
UpdateStatistics();
CPropertyPage::OnOK();
Modified: trunk/OpenMPT/mptrack/Mpdlgs.h
===================================================================
--- trunk/OpenMPT/mptrack/Mpdlgs.h 2013-10-13 08:17:05 UTC (rev 2885)
+++ trunk/OpenMPT/mptrack/Mpdlgs.h 2013-10-13 09:29:16 UTC (rev 2886)
@@ -24,18 +24,13 @@
CComboBox m_CbnLatencyMS, m_CbnUpdateIntervalMS, m_CbnMixingFreq, m_CbnPolyphony, m_CbnChannels, m_CbnSampleFormat;
CSliderCtrl m_SliderStereoSep, m_SliderPreAmp;
CEdit m_EditStatistics;
- DWORD m_dwRate, m_SoundDeviceFlags;
- SampleFormat m_SampleFormat;
- DWORD m_nChannels;
- DWORD m_LatencyMS;
- DWORD m_UpdateIntervalMS;
+ SoundDeviceSettings m_Settings;
SoundDeviceID m_nSoundDevice;
bool m_PreAmpNoteShowed;
public:
- COptionsSoundcard(DWORD rate, DWORD flags, SampleFormat sampleformat, DWORD chns, DWORD latency_ms, DWORD updateinterval_ms, SoundDeviceID sd):CPropertyPage(IDD_OPTIONS_SOUNDCARD)
- { m_dwRate = rate; m_SoundDeviceFlags = flags; m_SampleFormat = sampleformat; m_nChannels = chns;
- m_LatencyMS = latency_ms; m_UpdateIntervalMS = updateinterval_ms; m_nSoundDevice = sd; m_PreAmpNoteShowed = false; }
+ COptionsSoundcard(const SoundDeviceSettings &settings, SoundDeviceID sd):CPropertyPage(IDD_OPTIONS_SOUNDCARD)
+ { m_Settings = settings; m_nSoundDevice = sd; m_PreAmpNoteShowed = false; }
void UpdateStatistics();
Modified: trunk/OpenMPT/mptrack/TrackerSettings.cpp
===================================================================
--- trunk/OpenMPT/mptrack/TrackerSettings.cpp 2013-10-13 08:17:05 UTC (rev 2885)
+++ trunk/OpenMPT/mptrack/TrackerSettings.cpp 2013-10-13 09:29:16 UTC (rev 2886)
@@ -157,18 +157,31 @@
}
-DWORD TrackerSettings::GetSoundDeviceFlags() const
-//------------------------------------------------
+SoundDeviceSettings TrackerSettings::GetSoundDeviceSettings() const
+//-----------------------------------------------------------------
{
- return (m_SoundDeviceExclusiveMode ? SNDDEV_OPTIONS_EXCLUSIVE : 0) | (m_SoundDeviceBoostThreadPriority ? SNDDEV_OPTIONS_BOOSTTHREADPRIORITY : 0);
+ SoundDeviceSettings settings;
+ settings.hWnd = CMainFrame::GetMainFrame()->m_hWnd;
+ settings.LatencyMS = m_LatencyMS;
+ settings.UpdateIntervalMS = m_UpdateIntervalMS;
+ settings.Samplerate = m_MixerSettings.gdwMixingFreq;
+ settings.Channels = (uint8)m_MixerSettings.gnChannels;
+ settings.sampleFormat = m_SampleFormat;
+ settings.ExclusiveMode = m_SoundDeviceExclusiveMode;
+ settings.BoostThreadPriority = m_SoundDeviceBoostThreadPriority;
+ return settings;
}
-void TrackerSettings::SetSoundDeviceFlags(DWORD flags)
-//----------------------------------------------------
+void TrackerSettings::SetSoundDeviceSettings(const SoundDeviceSettings &settings)
{
- m_SoundDeviceExclusiveMode = (flags & SNDDEV_OPTIONS_EXCLUSIVE) ? true : false;
- m_SoundDeviceBoostThreadPriority = (flags & SNDDEV_OPTIONS_BOOSTTHREADPRIORITY) ? true : false;
+ m_LatencyMS = settings.LatencyMS;
+ m_UpdateIntervalMS = settings.UpdateIntervalMS;
+ m_MixerSettings.gdwMixingFreq = settings.Samplerate;
+ m_MixerSettings.gnChannels = settings.Channels;
+ m_SampleFormat = settings.sampleFormat;
+ m_SoundDeviceExclusiveMode = settings.ExclusiveMode;
+ m_SoundDeviceBoostThreadPriority = settings.BoostThreadPriority;
}
Modified: trunk/OpenMPT/mptrack/TrackerSettings.h
===================================================================
--- trunk/OpenMPT/mptrack/TrackerSettings.h 2013-10-13 08:17:05 UTC (rev 2885)
+++ trunk/OpenMPT/mptrack/TrackerSettings.h 2013-10-13 09:29:16 UTC (rev 2886)
@@ -186,8 +186,8 @@
DWORD m_UpdateIntervalMS;
bool m_SoundDeviceExclusiveMode;
bool m_SoundDeviceBoostThreadPriority;
- DWORD GetSoundDeviceFlags() const;
- void SetSoundDeviceFlags(DWORD flags);
+ SoundDeviceSettings GetSoundDeviceSettings() const;
+ void SetSoundDeviceSettings(const SoundDeviceSettings &settings);
#ifndef NO_EQ
EQPreset m_EqSettings;
Modified: trunk/OpenMPT/sounddev/SoundDevice.cpp
===================================================================
--- trunk/OpenMPT/sounddev/SoundDevice.cpp 2013-10-13 08:17:05 UTC (rev 2885)
+++ trunk/OpenMPT/sounddev/SoundDevice.cpp 2013-10-13 09:29:16 UTC (rev 2886)
@@ -509,7 +509,7 @@
if(!terminate)
{
- CPriorityBooster priorityBooster(*this, (m_SoundDevice.m_Settings.fulCfgOptions & SNDDEV_OPTIONS_BOOSTTHREADPRIORITY)?true:false);
+ CPriorityBooster priorityBooster(*this, m_SoundDevice.m_Settings.BoostThreadPriority);
CPeriodicWaker periodicWaker(*this, 0.001 * m_SoundDevice.GetRealUpdateIntervalMS());
m_SoundDevice.StartFromSoundThread();
Modified: trunk/OpenMPT/sounddev/SoundDevice.h
===================================================================
--- trunk/OpenMPT/sounddev/SoundDevice.h 2013-10-13 08:17:05 UTC (rev 2885)
+++ trunk/OpenMPT/sounddev/SoundDevice.h 2013-10-13 09:29:16 UTC (rev 2886)
@@ -126,30 +126,46 @@
#define SNDDEV_MINUPDATEINTERVAL_MS 1
#define SNDDEV_MAXUPDATEINTERVAL_MS 200
-#define SNDDEV_OPTIONS_EXCLUSIVE 0x01 // Use hardware buffers directly
-#define SNDDEV_OPTIONS_BOOSTTHREADPRIORITY 0x02 // Boost thread priority for glitch-free audio rendering
-
struct SoundDeviceSettings
{
HWND hWnd;
- ULONG LatencyMS;
- ULONG UpdateIntervalMS;
- ULONG fulCfgOptions;
+ uint32 LatencyMS;
+ uint32 UpdateIntervalMS;
uint32 Samplerate;
uint8 Channels;
SampleFormat sampleFormat;
+ bool ExclusiveMode; // Use hardware buffers directly
+ bool BoostThreadPriority; // Boost thread priority for glitch-free audio rendering
SoundDeviceSettings()
: hWnd(NULL)
, LatencyMS(SNDDEV_DEFAULT_LATENCY_MS)
, UpdateIntervalMS(SNDDEV_DEFAULT_UPDATEINTERVAL_MS)
- , fulCfgOptions(0)
, Samplerate(48000)
, Channels(2)
, sampleFormat(SampleFormatInt16)
+ , ExclusiveMode(false)
+ , BoostThreadPriority(false)
{
return;
}
+ bool operator == (const SoundDeviceSettings &cmp) const
+ {
+ return true
+ && hWnd == cmp.hWnd
+ && LatencyMS == cmp.LatencyMS
+ && UpdateIntervalMS == cmp.UpdateIntervalMS
+ && Samplerate == cmp.Samplerate
+ && Channels == cmp.Channels
+ && sampleFormat == cmp.sampleFormat
+ && ExclusiveMode == cmp.ExclusiveMode
+ && BoostThreadPriority == cmp.BoostThreadPriority
+ ;
+ }
+ bool operator != (const SoundDeviceSettings &cmp) const
+ {
+ return !(*this == cmp);
+ }
};
Modified: trunk/OpenMPT/sounddev/SoundDeviceDirectSound.cpp
===================================================================
--- trunk/OpenMPT/sounddev/SoundDeviceDirectSound.cpp 2013-10-13 08:17:05 UTC (rev 2885)
+++ trunk/OpenMPT/sounddev/SoundDeviceDirectSound.cpp 2013-10-13 09:29:16 UTC (rev 2886)
@@ -117,7 +117,7 @@
DSBUFFERDESC dsbd;
DSBCAPS dsc;
- UINT nPriorityLevel = (m_Settings.fulCfgOptions & SNDDEV_OPTIONS_EXCLUSIVE) ? DSSCL_WRITEPRIMARY : DSSCL_PRIORITY;
+ UINT nPriorityLevel = (m_Settings.ExclusiveMode) ? DSSCL_WRITEPRIMARY : DSSCL_PRIORITY;
if(m_piDS) return true;
const std::wstring internalID = GetDeviceInternalID();
@@ -132,7 +132,7 @@
if(m_nDSoundBufferSize > DSOUND_MAXBUFFERSIZE) m_nDSoundBufferSize = DSOUND_MAXBUFFERSIZE;
m_nBytesPerSec = pwfx->nAvgBytesPerSec;
m_BytesPerSample = (pwfx->wBitsPerSample/8) * pwfx->nChannels;
- if(!(m_Settings.fulCfgOptions & SNDDEV_OPTIONS_EXCLUSIVE))
+ if(!m_Settings.ExclusiveMode)
{
// Set the format of the primary buffer
dsbd.dwSize = sizeof(dsbd);
Modified: trunk/OpenMPT/sounddev/SoundDevicePortAudio.cpp
===================================================================
--- trunk/OpenMPT/sounddev/SoundDevicePortAudio.cpp 2013-10-13 08:17:05 UTC (rev 2885)
+++ trunk/OpenMPT/sounddev/SoundDevicePortAudio.cpp 2013-10-13 09:29:16 UTC (rev 2886)
@@ -73,7 +73,7 @@
}
m_StreamParameters.suggestedLatency = m_Settings.LatencyMS / 1000.0;
m_StreamParameters.hostApiSpecificStreamInfo = NULL;
- if((m_HostApi == Pa_HostApiTypeIdToHostApiIndex(paWASAPI)) && (m_Settings.fulCfgOptions & SNDDEV_OPTIONS_EXCLUSIVE))
+ if((m_HostApi == Pa_HostApiTypeIdToHostApiIndex(paWASAPI)) && m_Settings.ExclusiveMode)
{
MemsetZero(m_WasapiStreamInfo);
m_WasapiStreamInfo.size = sizeof(PaWasapiStreamInfo);
@@ -178,7 +178,7 @@
StreamParameters.sampleFormat = paInt16;
StreamParameters.suggestedLatency = 0.0;
StreamParameters.hostApiSpecificStreamInfo = NULL;
- if((m_HostApi == Pa_HostApiTypeIdToHostApiIndex(paWASAPI)) && (m_Settings.fulCfgOptions & SNDDEV_OPTIONS_EXCLUSIVE))
+ if((m_HostApi == Pa_HostApiTypeIdToHostApiIndex(paWASAPI)) && m_Settings.ExclusiveMode)
{
MemsetZero(m_WasapiStreamInfo);
m_WasapiStreamInfo.size = sizeof(PaWasapiStreamInfo);
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <man...@us...> - 2013-10-13 09:44:46
|
Revision: 2888
http://sourceforge.net/p/modplug/code/2888
Author: manxorist
Date: 2013-10-13 09:44:38 +0000 (Sun, 13 Oct 2013)
Log Message:
-----------
[Fix] sounddev: Make defaults consistent.
Modified Paths:
--------------
trunk/OpenMPT/mptrack/TrackerSettings.cpp
trunk/OpenMPT/sounddev/SoundDevice.h
Modified: trunk/OpenMPT/mptrack/TrackerSettings.cpp
===================================================================
--- trunk/OpenMPT/mptrack/TrackerSettings.cpp 2013-10-13 09:38:01 UTC (rev 2887)
+++ trunk/OpenMPT/mptrack/TrackerSettings.cpp 2013-10-13 09:44:38 UTC (rev 2888)
@@ -174,6 +174,7 @@
void TrackerSettings::SetSoundDeviceSettings(const SoundDeviceSettings &settings)
+//-------------------------------------------------------------------------------
{
m_LatencyMS = settings.LatencyMS;
m_UpdateIntervalMS = settings.UpdateIntervalMS;
Modified: trunk/OpenMPT/sounddev/SoundDevice.h
===================================================================
--- trunk/OpenMPT/sounddev/SoundDevice.h 2013-10-13 09:38:01 UTC (rev 2887)
+++ trunk/OpenMPT/sounddev/SoundDevice.h 2013-10-13 09:44:38 UTC (rev 2888)
@@ -145,7 +145,7 @@
, Channels(2)
, sampleFormat(SampleFormatInt16)
, ExclusiveMode(false)
- , BoostThreadPriority(false)
+ , BoostThreadPriority(true)
{
return;
}
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <man...@us...> - 2013-10-13 10:23:17
|
Revision: 2892
http://sourceforge.net/p/modplug/code/2892
Author: manxorist
Date: 2013-10-13 10:23:09 +0000 (Sun, 13 Oct 2013)
Log Message:
-----------
[Ref] sounddev: Explicitly pass SoundDeviceSettings to AudioRead and AudioDone..
[Ref] sounddev: Be more clear about samples vs frames in class ISoundDevice.
Modified Paths:
--------------
trunk/OpenMPT/mptrack/MainFrm.cpp
trunk/OpenMPT/mptrack/Mainfrm.h
trunk/OpenMPT/sounddev/SoundDevice.cpp
trunk/OpenMPT/sounddev/SoundDevice.h
Modified: trunk/OpenMPT/mptrack/MainFrm.cpp
===================================================================
--- trunk/OpenMPT/mptrack/MainFrm.cpp 2013-10-13 09:50:19 UTC (rev 2891)
+++ trunk/OpenMPT/mptrack/MainFrm.cpp 2013-10-13 10:23:09 UTC (rev 2892)
@@ -854,35 +854,36 @@
};
-void CMainFrame::AudioRead(PVOID pvData, ULONG NumFrames, SampleFormat sampleFormat)
-//----------------------------------------------------------------------------------
+void CMainFrame::AudioRead(const SoundDeviceSettings &settings, std::size_t numFrames, void *buffer)
+//--------------------------------------------------------------------------------------------------
{
OPENMPT_PROFILE_FUNCTION(Profiler::Audio);
- StereoVuMeterTargetWrapper target(sampleFormat, m_Dither, pvData);
- CSoundFile::samplecount_t renderedFrames = m_pSndFile->Read(NumFrames, target);
- ASSERT(renderedFrames <= NumFrames);
- CSoundFile::samplecount_t remainingFrames = NumFrames - renderedFrames;
+ StereoVuMeterTargetWrapper target(settings.sampleFormat, m_Dither, buffer);
+ CSoundFile::samplecount_t renderedFrames = m_pSndFile->Read(numFrames, target);
+ ASSERT(renderedFrames <= numFrames);
+ CSoundFile::samplecount_t remainingFrames = numFrames - renderedFrames;
if(remainingFrames > 0)
{
// The sound device interface expects the whole buffer to be filled, always.
// Clear remaining buffer if not enough samples got rendered.
- std::size_t frameSize = m_pSndFile->m_MixerSettings.gnChannels * (sampleFormat.GetBitsPerSample()/8);
- if(sampleFormat.IsUnsigned())
+ std::size_t frameSize = settings.Channels * (settings.sampleFormat.GetBitsPerSample()/8);
+ if(settings.sampleFormat.IsUnsigned())
{
- std::memset((char*)(pvData) + renderedFrames * frameSize, 0x80, remainingFrames * frameSize);
+ std::memset((char*)(buffer) + renderedFrames * frameSize, 0x80, remainingFrames * frameSize);
} else
{
- std::memset((char*)(pvData) + renderedFrames * frameSize, 0, remainingFrames * frameSize);
+ std::memset((char*)(buffer) + renderedFrames * frameSize, 0, remainingFrames * frameSize);
}
}
}
-void CMainFrame::AudioDone(ULONG NumSamples, int64 streamPosition)
-//----------------------------------------------------------------
+void CMainFrame::AudioDone(const SoundDeviceSettings &settings, std::size_t numFrames, int64 streamPosition)
+//----------------------------------------------------------------------------------------------------------
{
+ MPT_UNREFERENCED_PARAMETER(settings);
OPENMPT_PROFILE_FUNCTION(Profiler::Notify);
- DoNotification(NumSamples, streamPosition);
+ DoNotification(numFrames, streamPosition);
}
Modified: trunk/OpenMPT/mptrack/Mainfrm.h
===================================================================
--- trunk/OpenMPT/mptrack/Mainfrm.h 2013-10-13 09:50:19 UTC (rev 2891)
+++ trunk/OpenMPT/mptrack/Mainfrm.h 2013-10-13 10:23:09 UTC (rev 2892)
@@ -325,8 +325,8 @@
// from ISoundSource
void FillAudioBufferLocked(IFillAudioBuffer &callback);
- void AudioRead(PVOID pData, ULONG NumSamples, SampleFormat sampleFormat);
- void AudioDone(ULONG NumSamples, int64 streamPosition);
+ void AudioRead(const SoundDeviceSettings &settings, std::size_t numFrames, void *buffer);
+ void AudioDone(const SoundDeviceSettings &settings, std::size_t numFrames, int64 streamPosition);
bool audioTryOpeningDevice();
bool audioOpenDevice();
Modified: trunk/OpenMPT/sounddev/SoundDevice.cpp
===================================================================
--- trunk/OpenMPT/sounddev/SoundDevice.cpp 2013-10-13 09:50:19 UTC (rev 2891)
+++ trunk/OpenMPT/sounddev/SoundDevice.cpp 2013-10-13 10:23:09 UTC (rev 2892)
@@ -42,7 +42,7 @@
m_RealUpdateIntervalMS = static_cast<float>(m_Settings.UpdateIntervalMS);
m_IsPlaying = false;
- m_SamplesRendered = 0;
+ m_FramesRendered = 0;
}
@@ -118,36 +118,36 @@
}
-void ISoundDevice::SourceAudioRead(void* pData, ULONG NumSamples)
-//---------------------------------------------------------------
+void ISoundDevice::SourceAudioRead(void *buffer, std::size_t numFrames)
+//---------------------------------------------------------------------
{
- if(NumSamples <= 0)
+ if(numFrames <= 0)
{
return;
}
- m_Source->AudioRead(pData, NumSamples, m_Settings.sampleFormat);
+ m_Source->AudioRead(m_Settings, numFrames, buffer);
}
-void ISoundDevice::SourceAudioDone(ULONG NumSamples, ULONG SamplesLatency)
-//------------------------------------------------------------------------
+void ISoundDevice::SourceAudioDone(std::size_t numFrames, int32 framesLatency)
+//----------------------------------------------------------------------------
{
- if(NumSamples <= 0)
+ if(numFrames <= 0)
{
return;
}
- int64 samplesRendered = 0;
+ int64 framesRendered = 0;
{
- Util::lock_guard<Util::mutex> lock(m_SamplesRenderedMutex);
- m_SamplesRendered += NumSamples;
- samplesRendered = m_SamplesRendered;
+ Util::lock_guard<Util::mutex> lock(m_FramesRenderedMutex);
+ m_FramesRendered += numFrames;
+ framesRendered = m_FramesRendered;
}
if(InternalHasGetStreamPosition())
{
- m_Source->AudioDone(NumSamples, samplesRendered);
+ m_Source->AudioDone(m_Settings, numFrames, framesRendered);
} else
{
- m_Source->AudioDone(NumSamples, samplesRendered + SamplesLatency);
+ m_Source->AudioDone(m_Settings, numFrames, framesRendered + framesLatency);
}
}
@@ -159,8 +159,8 @@
if(!IsPlaying())
{
{
- Util::lock_guard<Util::mutex> lock(m_SamplesRenderedMutex);
- m_SamplesRendered = 0;
+ Util::lock_guard<Util::mutex> lock(m_FramesRenderedMutex);
+ m_FramesRendered = 0;
}
InternalStart();
m_IsPlaying = true;
@@ -177,8 +177,8 @@
InternalStop();
m_IsPlaying = false;
{
- Util::lock_guard<Util::mutex> lock(m_SamplesRenderedMutex);
- m_SamplesRendered = 0;
+ Util::lock_guard<Util::mutex> lock(m_FramesRenderedMutex);
+ m_FramesRendered = 0;
}
}
}
@@ -201,14 +201,14 @@
return InternalGetStreamPositionSamples();
} else
{
- Util::lock_guard<Util::mutex> lock(m_SamplesRenderedMutex);
- return m_SamplesRendered;
+ Util::lock_guard<Util::mutex> lock(m_FramesRenderedMutex);
+ return m_FramesRendered;
}
}
CAudioThread::CAudioThread(CSoundDeviceWithThread &SoundDevice) : m_SoundDevice(SoundDevice)
-//-----------------------------------------------------------------------------------
+//------------------------------------------------------------------------------------------
{
OSVERSIONINFO versioninfo;
Modified: trunk/OpenMPT/sounddev/SoundDevice.h
===================================================================
--- trunk/OpenMPT/sounddev/SoundDevice.h 2013-10-13 09:50:19 UTC (rev 2891)
+++ trunk/OpenMPT/sounddev/SoundDevice.h 2013-10-13 10:23:09 UTC (rev 2892)
@@ -28,6 +28,9 @@
//
+struct SoundDeviceSettings;
+
+
//====================
class IFillAudioBuffer
//====================
@@ -43,8 +46,8 @@
{
public:
virtual void FillAudioBufferLocked(IFillAudioBuffer &callback) = 0; // take any locks needed while rendering audio and then call FillAudioBuffer
- virtual void AudioRead(void* pData, ULONG NumSamples, SampleFormat sampleFormat) = 0;
- virtual void AudioDone(ULONG NumSamples, int64 streamPosition) = 0; // in samples
+ virtual void AudioRead(const SoundDeviceSettings &settings, std::size_t numFrames, void *buffer) = 0;
+ virtual void AudioDone(const SoundDeviceSettings &settings, std::size_t numFrames, int64 streamPosition) = 0; // in sample frames
};
@@ -195,14 +198,14 @@
bool m_IsPlaying;
- mutable Util::mutex m_SamplesRenderedMutex;
- int64 m_SamplesRendered;
+ mutable Util::mutex m_FramesRenderedMutex;
+ int64 m_FramesRendered;
protected:
virtual void FillAudioBuffer() = 0;
void SourceFillAudioBufferLocked();
- void SourceAudioRead(void* pData, ULONG NumSamples);
- void SourceAudioDone(ULONG NumSamples, ULONG SamplesLatency);
+ void SourceAudioRead(void *buffer, std::size_t numFrames);
+ void SourceAudioDone(std::size_t numFrames, int32 framesLatency);
public:
ISoundDevice(SoundDeviceID id, const std::wstring &internalID);
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <man...@us...> - 2013-10-14 11:36:39
|
Revision: 2899
http://sourceforge.net/p/modplug/code/2899
Author: manxorist
Date: 2013-10-14 11:36:27 +0000 (Mon, 14 Oct 2013)
Log Message:
-----------
[Fix] openmpt123: Fix mingw64 builds on windows hosts.
Modified Paths:
--------------
trunk/OpenMPT/common/typedefs.h
trunk/OpenMPT/openmpt123/Makefile
Modified: trunk/OpenMPT/common/typedefs.h
===================================================================
--- trunk/OpenMPT/common/typedefs.h 2013-10-14 03:11:01 UTC (rev 2898)
+++ trunk/OpenMPT/common/typedefs.h 2013-10-14 11:36:27 UTC (rev 2899)
@@ -59,6 +59,10 @@
#define PACKED __declspec(align(1))
#define NEEDS_PRAGMA_PACK
#elif MPT_COMPILER_GCC || MPT_COMPILER_CLANG
+#if MPT_COMPILER_GCC && defined(WIN32)
+// Some versions of mingw64 need this when windows-hosted. Strange.
+#define NEEDS_PRAGMA_PACK
+#endif
#define PACKED __attribute__((packed)) __attribute__((aligned(1)))
#else
#define PACKED alignas(1)
Modified: trunk/OpenMPT/openmpt123/Makefile
===================================================================
--- trunk/OpenMPT/openmpt123/Makefile 2013-10-14 03:11:01 UTC (rev 2898)
+++ trunk/OpenMPT/openmpt123/Makefile 2013-10-14 11:36:27 UTC (rev 2899)
@@ -279,10 +279,12 @@
-include $(ALL_DEPENDS)
+ifeq ($(DYNLINK),1)
OUTPUTS += bin/openmpt.a
OUTPUTS += bin/libopenmpt.so
+OUTPUTS += bin/libopenmpt_modplug.so
+endif
OUTPUTS += bin/openmpt123$(EXESUFFIX)
-OUTPUTS += bin/libopenmpt_modplug.so
ifeq ($(NO_PORTAUDIO),1)
else
OUTPUTS += bin/libopenmpt_example_c$(EXESUFFIX)
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <man...@us...> - 2013-10-15 10:25:52
|
Revision: 2904
http://sourceforge.net/p/modplug/code/2904
Author: manxorist
Date: 2013-10-15 10:25:42 +0000 (Tue, 15 Oct 2013)
Log Message:
-----------
[Ref] sounddev: Decouple sound device code from GUI code some more.
Modified Paths:
--------------
trunk/OpenMPT/mptrack/MainFrm.cpp
trunk/OpenMPT/mptrack/Mainfrm.h
trunk/OpenMPT/mptrack/Mpdlgs.cpp
trunk/OpenMPT/sounddev/SoundDevice.cpp
trunk/OpenMPT/sounddev/SoundDevice.h
trunk/OpenMPT/sounddev/SoundDeviceASIO.cpp
trunk/OpenMPT/sounddev/SoundDeviceASIO.h
Modified: trunk/OpenMPT/mptrack/MainFrm.cpp
===================================================================
--- trunk/OpenMPT/mptrack/MainFrm.cpp 2013-10-15 05:08:21 UTC (rev 2903)
+++ trunk/OpenMPT/mptrack/MainFrm.cpp 2013-10-15 10:25:42 UTC (rev 2904)
@@ -259,6 +259,7 @@
ISoundDevice *dummy = theApp.GetSoundDevicesManager()->CreateSoundDevice(TrackerSettings::Instance().m_nWaveDevice);
if(dummy)
{
+ dummy->SetMessageReceiver(CMainFrame::GetMainFrame());
TrackerSettings::Instance().m_MixerSettings.gdwMixingFreq = dummy->GetCurrentSampleRate();
delete dummy;
}
@@ -774,6 +775,13 @@
}
+void CMainFrame::AudioMessage(const std::string &str)
+//---------------------------------------------------
+{
+ Reporting::Notification(str.c_str());
+}
+
+
void CMainFrame::FillAudioBufferLocked(IFillAudioBuffer &callback)
//----------------------------------------------------------------
{
@@ -905,6 +913,7 @@
{
return false;
}
+ gpSoundDevice->SetMessageReceiver(this);
gpSoundDevice->SetSource(this);
return gpSoundDevice->Open(TrackerSettings::Instance().GetSoundDeviceSettings());
}
Modified: trunk/OpenMPT/mptrack/Mainfrm.h
===================================================================
--- trunk/OpenMPT/mptrack/Mainfrm.h 2013-10-15 05:08:21 UTC (rev 2903)
+++ trunk/OpenMPT/mptrack/Mainfrm.h 2013-10-15 10:25:42 UTC (rev 2904)
@@ -246,9 +246,9 @@
#include "TrackerSettings.h"
struct MODPLUGDIB;
-//========================================================
-class CMainFrame: public CMDIFrameWnd, public ISoundSource
-//========================================================
+//======================================================================================
+class CMainFrame: public CMDIFrameWnd, public ISoundSource, public ISoundMessageReceiver
+//======================================================================================
{
DECLARE_DYNAMIC(CMainFrame)
// static data
@@ -328,6 +328,9 @@
void AudioRead(const SoundDeviceSettings &settings, std::size_t numFrames, void *buffer);
void AudioDone(const SoundDeviceSettings &settings, std::size_t numFrames, int64 streamPosition);
+ // from ISoundMessageReceiver
+ void AudioMessage(const std::string &str);
+
bool audioTryOpeningDevice();
bool audioOpenDevice();
bool audioReopenDevice();
Modified: trunk/OpenMPT/mptrack/Mpdlgs.cpp
===================================================================
--- trunk/OpenMPT/mptrack/Mpdlgs.cpp 2013-10-15 05:08:21 UTC (rev 2903)
+++ trunk/OpenMPT/mptrack/Mpdlgs.cpp 2013-10-15 10:25:42 UTC (rev 2904)
@@ -397,6 +397,10 @@
{
justCreated = true;
dummy = theApp.GetSoundDevicesManager()->CreateSoundDevice(dev);
+ if(dummy)
+ {
+ dummy->SetMessageReceiver(CMainFrame::GetMainFrame());
+ }
}
if(dummy != nullptr)
Modified: trunk/OpenMPT/sounddev/SoundDevice.cpp
===================================================================
--- trunk/OpenMPT/sounddev/SoundDevice.cpp 2013-10-15 05:08:21 UTC (rev 2903)
+++ trunk/OpenMPT/sounddev/SoundDevice.cpp 2013-10-15 10:25:42 UTC (rev 2904)
@@ -34,6 +34,7 @@
ISoundDevice::ISoundDevice(SoundDeviceID id, const std::wstring &internalID)
//--------------------------------------------------------------------------
: m_Source(nullptr)
+ , m_MessageReceiver(nullptr)
, m_ID(id)
, m_InternalID(internalID)
{
@@ -152,6 +153,16 @@
}
+void ISoundDevice::AudioSendMessage(const std::string &str)
+//---------------------------------------------------------
+{
+ if(m_MessageReceiver)
+ {
+ m_MessageReceiver->AudioMessage(str);
+ }
+}
+
+
void ISoundDevice::Start()
//------------------------
{
Modified: trunk/OpenMPT/sounddev/SoundDevice.h
===================================================================
--- trunk/OpenMPT/sounddev/SoundDevice.h 2013-10-15 05:08:21 UTC (rev 2903)
+++ trunk/OpenMPT/sounddev/SoundDevice.h 2013-10-15 10:25:42 UTC (rev 2904)
@@ -40,6 +40,15 @@
};
+//=========================
+class ISoundMessageReceiver
+//=========================
+{
+public:
+ virtual void AudioMessage(const std::string &str) = 0;
+};
+
+
//================
class ISoundSource
//================
@@ -184,6 +193,7 @@
private:
ISoundSource *m_Source;
+ ISoundMessageReceiver *m_MessageReceiver;
const SoundDeviceID m_ID;
@@ -206,12 +216,15 @@
void SourceFillAudioBufferLocked();
void SourceAudioRead(void *buffer, std::size_t numFrames);
void SourceAudioDone(std::size_t numFrames, int32 framesLatency);
+ void AudioSendMessage(const std::string &str);
public:
ISoundDevice(SoundDeviceID id, const std::wstring &internalID);
virtual ~ISoundDevice();
void SetSource(ISoundSource *source) { m_Source = source; }
ISoundSource *GetSource() const { return m_Source; }
+ void SetMessageReceiver(ISoundMessageReceiver *receiver) { m_MessageReceiver = receiver; }
+ ISoundMessageReceiver *GetMessageReceiver() const { return m_MessageReceiver; }
public:
SoundDeviceID GetDeviceID() const { return m_ID; }
SoundDeviceType GetDeviceType() const { return m_ID.GetType(); }
Modified: trunk/OpenMPT/sounddev/SoundDeviceASIO.cpp
===================================================================
--- trunk/OpenMPT/sounddev/SoundDeviceASIO.cpp 2013-10-15 05:08:21 UTC (rev 2903)
+++ trunk/OpenMPT/sounddev/SoundDeviceASIO.cpp 2013-10-15 10:25:42 UTC (rev 2904)
@@ -17,9 +17,6 @@
#include "SoundDeviceASIO.h"
#include "../common/misc_util.h"
-#ifdef MODPLUG_TRACKER
-#include "../mptrack/Reporting.h"
-#endif
#include "../common/StringFixer.h"
#include "../soundlib/SampleFormatConverters.h"
@@ -715,7 +712,7 @@
void CASIODevice::ReportASIOException(const std::string &str)
//-----------------------------------------------------------
{
- Reporting::Notification(str.c_str());
+ AudioSendMessage(str);
Log("%s", str.c_str());
}
Modified: trunk/OpenMPT/sounddev/SoundDeviceASIO.h
===================================================================
--- trunk/OpenMPT/sounddev/SoundDeviceASIO.h 2013-10-15 05:08:21 UTC (rev 2903)
+++ trunk/OpenMPT/sounddev/SoundDeviceASIO.h 2013-10-15 10:25:42 UTC (rev 2904)
@@ -85,7 +85,8 @@
static void SampleRateDidChange(ASIOSampleRate sRate);
static long AsioMessage(long selector, long value, void* message, double* opt);
static ASIOTime* BufferSwitchTimeInfo(ASIOTime* params, long doubleBufferIndex, ASIOBool directProcess);
- static void ReportASIOException(const std::string &str);
+
+ void ReportASIOException(const std::string &str);
};
#endif // NO_ASIO
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <man...@us...> - 2013-10-17 10:36:41
|
Revision: 2911
http://sourceforge.net/p/modplug/code/2911
Author: manxorist
Date: 2013-10-17 10:36:28 +0000 (Thu, 17 Oct 2013)
Log Message:
-----------
[Fix] Limit WFIR cutoff frequency setting to meaningful range.
[Fix] Correct importing of old registry based cutoff settings.
Modified Paths:
--------------
trunk/OpenMPT/mptrack/Mpdlgs.cpp
trunk/OpenMPT/mptrack/TrackerSettings.cpp
trunk/OpenMPT/soundlib/Tables.cpp
Modified: trunk/OpenMPT/mptrack/Mpdlgs.cpp
===================================================================
--- trunk/OpenMPT/mptrack/Mpdlgs.cpp 2013-10-15 14:10:23 UTC (rev 2910)
+++ trunk/OpenMPT/mptrack/Mpdlgs.cpp 2013-10-17 10:36:28 UTC (rev 2911)
@@ -861,8 +861,17 @@
//rewbs.resamplerConf
CString s;
m_CEditWFIRCutoff.GetWindowText(s);
- if (s != "")
- TrackerSettings::Instance().m_ResamplerSettings.gdWFIRCutoff = atoi(s)/100.0;
+ if(s != "")
+ {
+ double newCutoff = atoi(s)/100.0;
+ Limit(newCutoff, 0.0, 1.0);
+ TrackerSettings::Instance().m_ResamplerSettings.gdWFIRCutoff = newCutoff;
+ }
+ {
+ CHAR s[64];
+ wsprintf(s, "%d", static_cast<int>((TrackerSettings::Instance().m_ResamplerSettings.gdWFIRCutoff*100)));
+ m_CEditWFIRCutoff.SetWindowText(s);
+ }
//TrackerSettings::Instance().m_ResamplerSettings.gbWFIRType set in OnWFIRTypeChange
m_CEditRampUp.GetWindowText(s);
Modified: trunk/OpenMPT/mptrack/TrackerSettings.cpp
===================================================================
--- trunk/OpenMPT/mptrack/TrackerSettings.cpp 2013-10-15 14:10:23 UTC (rev 2910)
+++ trunk/OpenMPT/mptrack/TrackerSettings.cpp 2013-10-17 10:36:28 UTC (rev 2911)
@@ -404,6 +404,7 @@
m_ResamplerSettings.gbWFIRType = static_cast<BYTE>(CMainFrame::GetPrivateProfileDWord("Sound Settings", "XMMSModplugResamplerWFIRType", m_ResamplerSettings.gbWFIRType, iniFile));
//gdWFIRCutoff = static_cast<double>(CMainFrame::GetPrivateProfileLong("Sound Settings", "ResamplerWFIRCutoff", gdWFIRCutoff * 100.0, iniFile)) / 100.0;
m_ResamplerSettings.gdWFIRCutoff = static_cast<double>(CMainFrame::GetPrivateProfileLong("Sound Settings", "ResamplerWFIRCutoff", Util::Round<long>(m_ResamplerSettings.gdWFIRCutoff * 100.0), iniFile)) / 100.0;
+ Limit(m_ResamplerSettings.gdWFIRCutoff, 0.0, 1.0);
// Ramping... first try to read the old setting, then the new ones
const long volRamp = CMainFrame::GetPrivateProfileLong("Sound Settings", "VolumeRampSamples", -1, iniFile);
@@ -701,7 +702,10 @@
dwDWORDSize = sizeof(m_ResamplerSettings.gbWFIRType);
RegQueryValueEx(key, "XMMSModplugResamplerWFIRType", NULL, &dwREG_DWORD, (LPBYTE)&m_ResamplerSettings.gbWFIRType, &dwDWORDSize);
dwDWORDSize = sizeof(m_ResamplerSettings.gdWFIRCutoff);
- RegQueryValueEx(key, "ResamplerWFIRCutoff", NULL, &dwREG_DWORD, (LPBYTE)&m_ResamplerSettings.gdWFIRCutoff, &dwDWORDSize);
+ DWORD tmpWFIRCutoff = Util::Round<DWORD>(100.0 * m_ResamplerSettings.gdWFIRCutoff);
+ RegQueryValueEx(key, "ResamplerWFIRCutoff", NULL, &dwREG_DWORD, (LPBYTE)&tmpWFIRCutoff, &dwDWORDSize);
+ m_ResamplerSettings.gdWFIRCutoff = tmpWFIRCutoff / 100.0;
+ Limit(m_ResamplerSettings.gdWFIRCutoff, 0.0, 1.0);
dwDWORDSize = sizeof(m_MixerSettings.glVolumeRampUpSamples);
RegQueryValueEx(key, "VolumeRampSamples", NULL, &dwREG_DWORD, (LPBYTE)&m_MixerSettings.glVolumeRampUpSamples, &dwDWORDSize);
m_MixerSettings.glVolumeRampDownSamples = m_MixerSettings.glVolumeRampUpSamples;
Modified: trunk/OpenMPT/soundlib/Tables.cpp
===================================================================
--- trunk/OpenMPT/soundlib/Tables.cpp 2013-10-15 14:10:23 UTC (rev 2910)
+++ trunk/OpenMPT/soundlib/Tables.cpp 2013-10-17 10:36:28 UTC (rev 2911)
@@ -838,6 +838,12 @@
static void getsinc(SINC_TYPE *psinc, double beta, double lowpass_factor)
{
+ if(lowpass_factor >= 0.999)
+ {
+ // Avoid mixer overflows.
+ // 1.0 itself does not make much sense.
+ lowpass_factor = 0.999;
+ }
const double izero_beta = izero(beta);
const double kPi = 4.0*atan(1.0)*lowpass_factor;
for (int isrc=0; isrc<8*SINC_PHASES; isrc++)
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <man...@us...> - 2013-10-19 13:42:10
|
Revision: 2930
http://sourceforge.net/p/modplug/code/2930
Author: manxorist
Date: 2013-10-19 13:42:04 +0000 (Sat, 19 Oct 2013)
Log Message:
-----------
[Ref] unarchiver: Add support for using miniz instead of zlib and minizip to decompress .zip and .gz files. The only missing feature is the zip file global comment, so use zlib+minizip by default for now.
[Ref] unarchiver: Cleanup GetComments() interface.
[Fix] unarchiver: Fix memleak in CZipArchive::GetComments() .
Modified Paths:
--------------
trunk/OpenMPT/soundlib/Sndfile.cpp
trunk/OpenMPT/unarchiver/unarchiver.cpp
trunk/OpenMPT/unarchiver/unarchiver.h
trunk/OpenMPT/unarchiver/ungzip.cpp
trunk/OpenMPT/unarchiver/ungzip.h
trunk/OpenMPT/unarchiver/unzip.cpp
trunk/OpenMPT/unarchiver/unzip.h
Modified: trunk/OpenMPT/soundlib/Sndfile.cpp
===================================================================
--- trunk/OpenMPT/soundlib/Sndfile.cpp 2013-10-19 13:31:36 UTC (rev 2929)
+++ trunk/OpenMPT/soundlib/Sndfile.cpp 2013-10-19 13:42:04 UTC (rev 2930)
@@ -742,9 +742,9 @@
#ifndef NO_ARCHIVE_SUPPORT
// Read archive comment if there is no song comment
- if(songMessage.empty() && unarchiver.GetComments(false))
+ if(songMessage.empty())
{
- songMessage.assign(unarchiver.GetComments(true));
+ songMessage.assign(unarchiver.GetComments());
}
#endif
Modified: trunk/OpenMPT/unarchiver/unarchiver.cpp
===================================================================
--- trunk/OpenMPT/unarchiver/unarchiver.cpp 2013-10-19 13:31:36 UTC (rev 2929)
+++ trunk/OpenMPT/unarchiver/unarchiver.cpp 2013-10-19 13:42:04 UTC (rev 2930)
@@ -93,12 +93,14 @@
}
-const char *CUnarchiver::GetComments(bool get)
+std::string CUnarchiver::GetComments()
+//------------------------------------
{
#ifdef ZIPPED_MOD_SUPPORT
- if(!zipArchive.IsArchive()) return nullptr;
- return zipArchive.GetComments(get);
-#else
- return nullptr;
+ if(zipArchive.IsArchive())
+ {
+ return zipArchive.GetComments();
+ }
#endif
+ return "";
}
Modified: trunk/OpenMPT/unarchiver/unarchiver.h
===================================================================
--- trunk/OpenMPT/unarchiver/unarchiver.h 2013-10-19 13:31:36 UTC (rev 2929)
+++ trunk/OpenMPT/unarchiver/unarchiver.h 2013-10-19 13:42:04 UTC (rev 2930)
@@ -51,7 +51,7 @@
FileReader GetOutputFile() const { return outFile; }
bool IsArchive() const;
bool ExtractFile();
- const char *GetComments(bool get);
+ std::string GetComments();
CUnarchiver(FileReader &file, const std::vector<const char *> &extensions);
~CUnarchiver();
Modified: trunk/OpenMPT/unarchiver/ungzip.cpp
===================================================================
--- trunk/OpenMPT/unarchiver/ungzip.cpp 2013-10-19 13:31:36 UTC (rev 2929)
+++ trunk/OpenMPT/unarchiver/ungzip.cpp 2013-10-19 13:42:04 UTC (rev 2930)
@@ -12,7 +12,12 @@
#include "../soundlib/FileReader.h"
#include "ungzip.h"
+#if !defined(NO_ZLIB)
#include <zlib/zlib.h>
+#elif !defined(NO_MINIZ)
+#define MINIZ_HEADER_FILE_ONLY
+#include <miniz/miniz.c>
+#endif
CGzipArchive::CGzipArchive(FileReader &file) : inFile(file)
@@ -115,7 +120,7 @@
inflateEnd(&strm);
// Everything went OK? Check return code, number of written bytes and CRC32.
- if(retVal == Z_STREAM_END && trailer.isize == strm.total_out && trailer.crc32 == crc32(0, (Bytef *)data, trailer.isize))
+ if(retVal == Z_STREAM_END && trailer.isize == strm.total_out && trailer.crc32_ == crc32(0, (Bytef *)data, trailer.isize))
{
// Success! :)
outFile = FileReader(data, trailer.isize);
Modified: trunk/OpenMPT/unarchiver/ungzip.h
===================================================================
--- trunk/OpenMPT/unarchiver/ungzip.h 2013-10-19 13:31:36 UTC (rev 2929)
+++ trunk/OpenMPT/unarchiver/ungzip.h 2013-10-19 13:42:04 UTC (rev 2930)
@@ -35,12 +35,12 @@
struct PACKED GZtrailer
{
- uint32 crc32; // CRC32 of decompressed data
+ uint32 crc32_; // CRC32 of decompressed data
uint32 isize; // Size of decompressed data
void ConvertEndianness()
{
- SwapBytesLE(crc32);
+ SwapBytesLE(crc32_);
SwapBytesLE(isize);
}
};
Modified: trunk/OpenMPT/unarchiver/unzip.cpp
===================================================================
--- trunk/OpenMPT/unarchiver/unzip.cpp 2013-10-19 13:31:36 UTC (rev 2929)
+++ trunk/OpenMPT/unarchiver/unzip.cpp 2013-10-19 13:42:04 UTC (rev 2930)
@@ -15,9 +15,17 @@
#include "../common/misc_util.h"
#include <algorithm>
+#if !defined(NO_ZLIB)
#include <contrib/minizip/unzip.h>
+#elif !defined(NO_MINIZ)
+#define MINIZ_HEADER_FILE_ONLY
+#include <miniz/miniz.c>
+#endif
+#if !defined(NO_ZLIB)
+
+
// Low-level file abstractions for in-memory file handling
struct ZipFileAbstraction
{
@@ -204,20 +212,17 @@
}
-const char *CZipArchive::GetComments(bool get)
-//--------------------------------------------
+std::string CZipArchive::GetComments()
+//------------------------------------
{
unz_global_info info;
if(zipFile == nullptr || unzGetGlobalInfo(zipFile, &info) != UNZ_OK)
{
- return nullptr;
+ return "";
}
- if(!get)
+ if(info.size_comment > 0)
{
- return reinterpret_cast<char *>((info.size_comment > 0) ? 1 : 0);
- } else if(info.size_comment > 0)
- {
if(info.size_comment < Util::MaxValueOfType(info.size_comment))
{
info.size_comment++;
@@ -226,11 +231,151 @@
if(comment != nullptr && unzGetGlobalComment(zipFile, comment, info.size_comment) >= 0)
{
comment[info.size_comment - 1] = '\0';
- return comment;
+ std::string result = comment;
+ delete[] comment;
+ return result;
} else
{
delete[] comment;
}
}
- return nullptr;
+ return "";
}
+
+
+#elif !defined(NO_MINIZ)
+
+
+CZipArchive::CZipArchive(FileReader &file, const std::vector<const char *> &ext) : inFile(file), extensions(ext)
+//--------------------------------------------------------------------------------------------------------------
+{
+ zipFile = new mz_zip_archive();
+
+ mz_zip_archive *zip = static_cast<mz_zip_archive*>(zipFile);
+
+ MemsetZero(*zip);
+ if(!mz_zip_reader_init_mem(zip, file.GetRawData(), file.GetLength(), 0))
+ {
+ delete zip;
+ zipFile = nullptr;
+ }
+
+}
+
+
+CZipArchive::~CZipArchive()
+//-------------------------
+{
+ mz_zip_archive *zip = static_cast<mz_zip_archive*>(zipFile);
+
+ if(zip)
+ {
+ mz_zip_reader_end(zip);
+
+ delete zip;
+ zipFile = nullptr;
+ }
+
+ delete[] outFile.GetRawData();
+}
+
+
+bool CZipArchive::IsArchive() const
+//---------------------------------
+{
+ return (zipFile != nullptr);
+}
+
+
+static inline std::string GetExtension(const std::string &filename)
+//-----------------------------------------------------------------
+{
+ if(filename.find_last_of(".") != std::string::npos)
+ {
+ return filename.substr(filename.find_last_of(".") + 1);
+ }
+ return std::string();
+}
+
+
+bool CZipArchive::ExtractFile()
+//-----------------------------
+{
+ mz_zip_archive *zip = static_cast<mz_zip_archive*>(zipFile);
+
+ if(!zip)
+ {
+ return false;
+ }
+
+ mz_uint bestFile = (mz_uint)-1;
+ mz_uint64 biggestFile = 0;
+ for(mz_uint i = 0; i < mz_zip_reader_get_num_files(zip); ++i)
+ {
+ mz_zip_archive_file_stat stat;
+ MemsetZero(stat);
+ if(!mz_zip_reader_file_stat(zip, i, &stat))
+ {
+ continue;
+ }
+ if(mz_zip_reader_is_file_a_directory(zip, i))
+ {
+ continue;
+ }
+ if(mz_zip_reader_is_file_encrypted(zip, i))
+ {
+ continue;
+ }
+ std::string ext = GetExtension(stat.m_filename);
+ if(std::find(extensions.begin(), extensions.end(), ext) != extensions.end())
+ {
+ // File has a preferred extension: use it.
+ bestFile = i;
+ break;
+ }
+ if(ext != "diz" && ext != "nfo" && ext != "txt" && stat.m_uncomp_size >= biggestFile)
+ {
+ // If this isn't some kind of info file, we should maybe pick it.
+ bestFile = i;
+ biggestFile = stat.m_uncomp_size;
+ }
+ }
+ if(bestFile == (mz_uint)-1)
+ {
+ return false;
+ }
+ delete [] outFile.GetRawData();
+ mz_zip_archive_file_stat stat;
+ MemsetZero(stat);
+ mz_zip_reader_file_stat(zip, bestFile, &stat);
+ char *data = new (std::nothrow) char[stat.m_uncomp_size];
+ if(data != nullptr)
+ {
+ if(!mz_zip_reader_extract_to_mem(zip, bestFile, data, stat.m_uncomp_size, 0))
+ {
+ delete [] data;
+ return false;
+ }
+ outFile = FileReader(data, stat.m_uncomp_size);
+ comment = std::string(stat.m_comment, stat.m_comment + stat.m_comment_size);
+ }
+
+ return true;
+}
+
+
+std::string CZipArchive::GetComments()
+//------------------------------------
+{
+ mz_zip_archive *zip = static_cast<mz_zip_archive*>(zipFile);
+
+ if(!zip)
+ {
+ return "";
+ }
+
+ return comment;
+}
+
+
+#endif // NO_ZLIB || NO_MINIZ
Modified: trunk/OpenMPT/unarchiver/unzip.h
===================================================================
--- trunk/OpenMPT/unarchiver/unzip.h 2013-10-19 13:31:36 UTC (rev 2929)
+++ trunk/OpenMPT/unarchiver/unzip.h 2013-10-19 13:42:04 UTC (rev 2930)
@@ -17,13 +17,14 @@
FileReader inFile, outFile;
void *zipFile;
const std::vector<const char *> &extensions;
+ std::string comment;
public:
FileReader GetOutputFile() const { return outFile; }
bool IsArchive() const;
bool ExtractFile();
- const char *GetComments(bool get);
+ std::string GetComments();
CZipArchive(FileReader &file, const std::vector<const char *> &ext);
~CZipArchive();
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <man...@us...> - 2013-10-19 14:21:38
|
Revision: 2935
http://sourceforge.net/p/modplug/code/2935
Author: manxorist
Date: 2013-10-19 14:21:30 +0000 (Sat, 19 Oct 2013)
Log Message:
-----------
Merged revision(s) 2923-2934 from branches/manx/sounddev:
[New] Add button to re-enumerate sound device to soundcard options dialog. This allows selecting sound devices that got added/installed while OpenMPT was already running.
[Ref] sounddev: Cache the supported sample rates for ASIO and PortAudio devices, so that selecting such a device does not potentially stall the GUI (because querying sample rates for ASIO could take some time or even fail if the hardware is unavailable).
........
[Imp] sounddev: Only show supported sample rates for DirectSound devices (mainly affects XP and older or Wine systems).
........
[Fix] sounddev: Use uint32 instead of std::uint32_t.
........
[Ref] sounddev: Tiny cleanups.
........
[Ref] sounddev: Simplify device caps handling.
........
[Ref] sounddev: Shorten portaudio device names.
........
[Var] Make soundcard options dialog less ugly.
........
[Var] Make sound device combobox a bit wider.
........
Modified Paths:
--------------
trunk/OpenMPT/mptrack/MainFrm.cpp
trunk/OpenMPT/mptrack/Mpdlgs.cpp
trunk/OpenMPT/mptrack/Mpdlgs.h
trunk/OpenMPT/mptrack/mptrack.rc
trunk/OpenMPT/sounddev/SoundDevice.cpp
trunk/OpenMPT/sounddev/SoundDevice.h
trunk/OpenMPT/sounddev/SoundDeviceASIO.cpp
trunk/OpenMPT/sounddev/SoundDeviceASIO.h
trunk/OpenMPT/sounddev/SoundDeviceDirectSound.cpp
trunk/OpenMPT/sounddev/SoundDeviceDirectSound.h
trunk/OpenMPT/sounddev/SoundDevicePortAudio.cpp
trunk/OpenMPT/sounddev/SoundDevicePortAudio.h
trunk/OpenMPT/sounddev/SoundDeviceWaveout.cpp
trunk/OpenMPT/sounddev/SoundDeviceWaveout.h
Property Changed:
----------------
trunk/OpenMPT/
Index: trunk/OpenMPT
===================================================================
--- trunk/OpenMPT 2013-10-19 14:17:52 UTC (rev 2934)
+++ trunk/OpenMPT 2013-10-19 14:21:30 UTC (rev 2935)
Property changes on: trunk/OpenMPT
___________________________________________________________________
Modified: svn:mergeinfo
## -14,6 +14,7 ##
/branches/manx/serialization-utils-cleanup:2382-2386,2395
/branches/manx/snddev:2780-2788
/branches/manx/snddev-fixes:1605-1713
+/branches/manx/sounddev:2923-2934
/branches/manx/stdstring-names:2223,2228
/branches/manx/stdstring-song-name:2462-2463
/branches/manx/unarchiver:1887-1888
\ No newline at end of property
Modified: trunk/OpenMPT/mptrack/MainFrm.cpp
===================================================================
--- trunk/OpenMPT/mptrack/MainFrm.cpp 2013-10-19 14:17:52 UTC (rev 2934)
+++ trunk/OpenMPT/mptrack/MainFrm.cpp 2013-10-19 14:21:30 UTC (rev 2935)
@@ -256,13 +256,7 @@
// If no mixing rate is specified and we're using ASIO, get a mixing rate supported by the device.
if(TrackerSettings::Instance().m_nWaveDevice.GetType() == SNDDEV_ASIO)
{
- ISoundDevice *dummy = theApp.GetSoundDevicesManager()->CreateSoundDevice(TrackerSettings::Instance().m_nWaveDevice);
- if(dummy)
- {
- dummy->SetMessageReceiver(CMainFrame::GetMainFrame());
- TrackerSettings::Instance().m_MixerSettings.gdwMixingFreq = dummy->GetCurrentSampleRate();
- delete dummy;
- }
+ TrackerSettings::Instance().m_MixerSettings.gdwMixingFreq = theApp.GetSoundDevicesManager()->GetDeviceCaps(TrackerSettings::Instance().m_nWaveDevice, TrackerSettings::Instance().GetSampleRates(), CMainFrame::GetMainFrame(), CMainFrame::GetMainFrame()->gpSoundDevice).currentSampleRate;
}
#endif // NO_ASIO
}
Modified: trunk/OpenMPT/mptrack/Mpdlgs.cpp
===================================================================
--- trunk/OpenMPT/mptrack/Mpdlgs.cpp 2013-10-19 14:17:52 UTC (rev 2934)
+++ trunk/OpenMPT/mptrack/Mpdlgs.cpp 2013-10-19 14:21:30 UTC (rev 2935)
@@ -76,6 +76,7 @@
ON_CBN_SELCHANGE(IDC_COMBO6, OnSettingsChanged)
ON_CBN_EDITCHANGE(IDC_COMBO2, OnSettingsChanged)
ON_CBN_EDITCHANGE(IDC_COMBO_UPDATEINTERVAL, OnSettingsChanged)
+ ON_COMMAND(IDC_BUTTON1, OnSoundCardRescan)
END_MESSAGE_MAP()
@@ -98,23 +99,45 @@
}
+void COptionsSoundcard::OnSoundCardRescan()
+//-----------------------------------------
+{
+ {
+ // Close sound device because IDs might change when re-enumerating which could cause all kinds of havoc.
+ CMainFrame::GetMainFrame()->audioCloseDevice();
+ delete CMainFrame::GetMainFrame()->gpSoundDevice;
+ CMainFrame::GetMainFrame()->gpSoundDevice = nullptr;
+ }
+ theApp.GetSoundDevicesManager()->ReEnumerate();
+ UpdateEverything();
+}
+
+
BOOL COptionsSoundcard::OnInitDialog()
//------------------------------------
{
- CMainFrame *pMainFrm = CMainFrame::GetMainFrame();
- BOOL bAsio = FALSE;
+ CPropertyPage::OnInitDialog();
+ UpdateEverything();
+ return TRUE;
+}
+
+
+void COptionsSoundcard::UpdateEverything()
+//----------------------------------------
+{
+
CHAR s[128];
- CPropertyPage::OnInitDialog();
- if(TrackerSettings::Instance().m_MixerSettings.MixerFlags & SNDMIX_SOFTPANNING) CheckDlgButton(IDC_CHECK2, MF_CHECKED);
- if(m_Settings.ExclusiveMode) CheckDlgButton(IDC_CHECK4, MF_CHECKED);
- if(m_Settings.BoostThreadPriority) CheckDlgButton(IDC_CHECK5, MF_CHECKED);
+ CheckDlgButton(IDC_CHECK2, (TrackerSettings::Instance().m_MixerSettings.MixerFlags & SNDMIX_SOFTPANNING) ? MF_CHECKED : MF_UNCHECKED);
+ CheckDlgButton(IDC_CHECK4, m_Settings.ExclusiveMode ? MF_CHECKED : MF_UNCHECKED);
+ CheckDlgButton(IDC_CHECK5, m_Settings.BoostThreadPriority ? MF_CHECKED : MF_UNCHECKED);
// Sampling Rate
UpdateSampleRates(m_nSoundDevice);
// Max Mixing Channels
{
+ m_CbnPolyphony.ResetContent();
for (UINT n = 0; n < CountOf(nCPUMix); n++)
{
wsprintf(s, "%d (%s)", nCPUMix[n], szCPUNames[n]);
@@ -124,6 +147,7 @@
}
// latency
{
+ m_CbnLatencyMS.ResetContent();
wsprintf(s, "%d ms", m_Settings.LatencyMS);
m_CbnLatencyMS.SetWindowText(s);
m_CbnLatencyMS.AddString("1 ms");
@@ -146,6 +170,7 @@
}
// update interval
{
+ m_CbnUpdateIntervalMS.ResetContent();
wsprintf(s, "%d ms", m_Settings.UpdateIntervalMS);
m_CbnUpdateIntervalMS.SetWindowText(s);
m_CbnUpdateIntervalMS.AddString("1 ms");
@@ -179,10 +204,9 @@
}
// Sound Device
{
- if (pMainFrm)
- {
- m_CbnDevice.SetImageList(pMainFrm->GetImageList());
- }
+ m_CbnDevice.ResetContent();
+ m_CbnDevice.SetImageList(CMainFrame::GetMainFrame()->GetImageList());
+
COMBOBOXEXITEM cbi;
UINT iItem = 0;
@@ -212,7 +236,6 @@
break;
case SNDDEV_ASIO:
case SNDDEV_PORTAUDIO_ASIO:
- bAsio = TRUE;
cbi.iImage = IMAGE_ASIO;
break;
default:
@@ -237,7 +260,6 @@
UpdateChannels(m_nSoundDevice);
UpdateSampleFormat(m_nSoundDevice);
- return TRUE;
}
@@ -382,36 +404,11 @@
{
m_CbnMixingFreq.ResetContent();
- std::vector<uint32> samplerates = TrackerSettings::Instance().GetSampleRates();
+ std::vector<uint32> samplerates;
{
Util::lock_guard<Util::mutex> lock(CMainFrame::GetMainFrame()->m_SoundDeviceMutex);
- ISoundDevice *dummy = nullptr;
- bool justCreated = false;
- if(TrackerSettings::Instance().m_nWaveDevice == dev)
- {
- // If this is the currently active sound device, it might already be playing something, so we shouldn't create yet another instance of it.
- dummy = CMainFrame::GetMainFrame()->gpSoundDevice;
- }
- if(dummy == nullptr)
- {
- justCreated = true;
- dummy = theApp.GetSoundDevicesManager()->CreateSoundDevice(dev);
- if(dummy)
- {
- dummy->SetMessageReceiver(CMainFrame::GetMainFrame());
- }
- }
-
- if(dummy != nullptr)
- {
- // Now we can query the supported sample rates.
- samplerates = dummy->GetSampleRates(samplerates);
- if(justCreated)
- {
- delete dummy;
- }
- }
+ samplerates = theApp.GetSoundDevicesManager()->GetDeviceCaps(dev, TrackerSettings::Instance().GetSampleRates(), CMainFrame::GetMainFrame(), CMainFrame::GetMainFrame()->gpSoundDevice).supportedSampleRates;
}
if(samplerates.empty())
Modified: trunk/OpenMPT/mptrack/Mpdlgs.h
===================================================================
--- trunk/OpenMPT/mptrack/Mpdlgs.h 2013-10-19 14:17:52 UTC (rev 2934)
+++ trunk/OpenMPT/mptrack/Mpdlgs.h 2013-10-19 14:21:30 UTC (rev 2935)
@@ -22,6 +22,7 @@
CComboBox m_CbnLatencyMS, m_CbnUpdateIntervalMS, m_CbnMixingFreq, m_CbnPolyphony, m_CbnChannels, m_CbnSampleFormat;
CSliderCtrl m_SliderStereoSep, m_SliderPreAmp;
CEdit m_EditStatistics;
+ CButton m_BtnRescan;
SoundDeviceSettings m_Settings;
SoundDeviceID m_nSoundDevice;
bool m_PreAmpNoteShowed;
@@ -33,6 +34,7 @@
void UpdateStatistics();
private:
+ void UpdateEverything();
void UpdateSampleRates(SoundDeviceID dev);
void UpdateChannels(SoundDeviceID dev);
void UpdateSampleFormat(SoundDeviceID dev);
@@ -49,6 +51,7 @@
afx_msg void OnSettingsChanged() { SetModified(TRUE); }
afx_msg void OnHScroll(UINT, UINT, CScrollBar *);
afx_msg void OnVScroll(UINT, UINT, CScrollBar *);
+ afx_msg void OnSoundCardRescan();
DECLARE_MESSAGE_MAP()
};
Modified: trunk/OpenMPT/mptrack/mptrack.rc
===================================================================
--- trunk/OpenMPT/mptrack/mptrack.rc 2013-10-19 14:17:52 UTC (rev 2934)
+++ trunk/OpenMPT/mptrack/mptrack.rc 2013-10-19 14:21:30 UTC (rev 2935)
@@ -1269,14 +1269,15 @@
LTEXT "Description",IDC_TEXT1,144,126,111,138
END
-IDD_OPTIONS_SOUNDCARD DIALOGEX 0, 0, 272, 263
+IDD_OPTIONS_SOUNDCARD DIALOGEX 0, 0, 268, 263
STYLE DS_SETFONT | DS_3DLOOK | DS_FIXEDSYS | WS_CHILD | WS_DISABLED | WS_CAPTION
CAPTION "Sound Card"
FONT 8, "MS Shell Dlg", 0, 0, 0x0
BEGIN
GROUPBOX "",IDC_STATIC,6,6,258,114
- LTEXT "Sound Device:",IDC_STATIC,12,18,54,8
- CONTROL "",IDC_COMBO1,"ComboBoxEx32",CBS_DROPDOWNLIST | CBS_SORT | WS_VSCROLL | WS_TABSTOP,12,30,246,96
+ LTEXT "Sound Device:",IDC_STATIC,12,18,47,8
+ CONTROL "",IDC_COMBO1,"ComboBoxEx32",CBS_DROPDOWNLIST | CBS_SORT | WS_VSCROLL | WS_TABSTOP,12,30,204,96
+ PUSHBUTTON "Rescan",IDC_BUTTON1,222,30,36,12
LTEXT "Latency:",IDC_STATIC,12,48,54,12,SS_CENTERIMAGE
COMBOBOX IDC_COMBO2,72,48,66,83,CBS_DROPDOWN | WS_VSCROLL | WS_TABSTOP
CONTROL "Use device exclusively",IDC_CHECK4,"Button",BS_AUTOCHECKBOX | WS_TABSTOP,144,48,102,12
@@ -1745,7 +1746,7 @@
IDD_OPTIONS_SOUNDCARD, DIALOG
BEGIN
RIGHTMARGIN, 246
- BOTTOMMARGIN, 166
+ BOTTOMMARGIN, 160
END
IDD_MIDIMACRO, DIALOG
Modified: trunk/OpenMPT/sounddev/SoundDevice.cpp
===================================================================
--- trunk/OpenMPT/sounddev/SoundDevice.cpp 2013-10-19 14:17:52 UTC (rev 2934)
+++ trunk/OpenMPT/sounddev/SoundDevice.cpp 2013-10-19 14:21:30 UTC (rev 2935)
@@ -54,6 +54,15 @@
}
+SoundDeviceCaps ISoundDevice::GetDeviceCaps(const std::vector<uint32> &baseSampleRates)
+//-------------------------------------------------------------------------------------
+{
+ SoundDeviceCaps result;
+ result.supportedSampleRates = baseSampleRates;
+ return result;
+}
+
+
bool ISoundDevice::FillWaveFormatExtensible(WAVEFORMATEXTENSIBLE &WaveFormat)
//---------------------------------------------------------------------------
{
@@ -620,7 +629,12 @@
void SoundDevicesManager::ReEnumerate()
//-------------------------------------
{
+#ifndef NO_PORTAUDIO
+ SndDevPortaudioUnnitialize();
+ SndDevPortaudioInitialize();
+#endif // NO_PORTAUDIO
m_SoundDevices.clear();
+ m_DeviceCaps.clear();
for(int type = 0; type < SNDDEV_NUM_DEVTYPES; ++type)
{
std::vector<SoundDeviceInfo> infos;
@@ -673,6 +687,29 @@
}
+SoundDeviceCaps SoundDevicesManager::GetDeviceCaps(SoundDeviceID id, const std::vector<uint32> &baseSampleRates, ISoundMessageReceiver *messageReceiver, ISoundDevice *currentSoundDevice)
+//----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
+{
+ if(m_DeviceCaps.find(id) == m_DeviceCaps.end())
+ {
+ if(currentSoundDevice && FindDeviceInfo(id) && (currentSoundDevice->GetDeviceID() == id) && (currentSoundDevice->GetDeviceInternalID() == FindDeviceInfo(id)->internalID))
+ {
+ m_DeviceCaps[id] = currentSoundDevice->GetDeviceCaps(baseSampleRates);
+ } else
+ {
+ ISoundDevice *dummy = CreateSoundDevice(id);
+ if(dummy)
+ {
+ dummy->SetMessageReceiver(messageReceiver);
+ m_DeviceCaps[id] = dummy->GetDeviceCaps(baseSampleRates);
+ }
+ delete dummy;
+ }
+ }
+ return m_DeviceCaps[id];
+}
+
+
ISoundDevice * SoundDevicesManager::CreateSoundDevice(SoundDeviceID id)
//---------------------------------------------------------------------
{
@@ -708,9 +745,6 @@
SoundDevicesManager::SoundDevicesManager()
//----------------------------------------
{
-#ifndef NO_PORTAUDIO
- SndDevPortaudioInitialize();
-#endif // NO_PORTAUDIO
ReEnumerate();
}
Modified: trunk/OpenMPT/sounddev/SoundDevice.h
===================================================================
--- trunk/OpenMPT/sounddev/SoundDevice.h 2013-10-19 14:17:52 UTC (rev 2934)
+++ trunk/OpenMPT/sounddev/SoundDevice.h 2013-10-19 14:21:30 UTC (rev 2935)
@@ -14,6 +14,7 @@
#include "../common/mutex.h"
#include "../soundlib/SampleFormat.h"
+#include <map>
#include <vector>
@@ -114,6 +115,10 @@
{
return (type != cmp.type) || (index != cmp.index);
}
+ bool operator < (const SoundDeviceID &cmp) const
+ {
+ return (type < cmp.type) || (type == cmp.type && index < cmp.index);
+ }
public:
// Do not change these. These functions are used to manipulate the value that gets stored in the settings.
template<typename T>
@@ -181,6 +186,18 @@
};
+struct SoundDeviceCaps
+{
+ uint32 currentSampleRate;
+ std::vector<uint32> supportedSampleRates; // Which samplerates are actually supported by the device. Currently only implemented properly for ASIO, DirectSound and PortAudio.
+ SoundDeviceCaps()
+ : currentSampleRate(0)
+ {
+ return;
+ }
+};
+
+
class SoundDevicesManager;
@@ -231,6 +248,8 @@
SoundDeviceIndex GetDeviceIndex() const { return m_ID.GetIndex(); }
std::wstring GetDeviceInternalID() const { return m_InternalID; }
+ virtual SoundDeviceCaps GetDeviceCaps(const std::vector<uint32> &baseSampleRates);
+
public:
float GetRealLatencyMS() const { return m_RealLatencyMS; }
float GetRealUpdateIntervalMS() const { return m_RealUpdateIntervalMS; }
@@ -259,9 +278,6 @@
virtual bool IsOpen() const = 0;
virtual UINT GetNumBuffers() { return 0; }
virtual float GetCurrentRealLatencyMS() { return GetRealLatencyMS(); }
- virtual UINT GetCurrentSampleRate() { return 0; }
- // Return which samplerates are actually supported by the device. Currently only implemented properly for ASIO and PortAudio.
- virtual std::vector<uint32> GetSampleRates(const std::vector<uint32> &samplerates) { return samplerates; }
};
@@ -287,6 +303,7 @@
{
private:
std::vector<SoundDeviceInfo> m_SoundDevices;
+ std::map<SoundDeviceID, SoundDeviceCaps> m_DeviceCaps;
public:
SoundDevicesManager();
@@ -302,6 +319,8 @@
const SoundDeviceInfo * FindDeviceInfo(SoundDeviceID id) const;
+ SoundDeviceCaps GetDeviceCaps(SoundDeviceID id, const std::vector<uint32> &baseSampleRates, ISoundMessageReceiver *messageReceiver = nullptr, ISoundDevice *currentSoundDevice = nullptr);
+
ISoundDevice * CreateSoundDevice(SoundDeviceID id);
};
Modified: trunk/OpenMPT/sounddev/SoundDeviceASIO.cpp
===================================================================
--- trunk/OpenMPT/sounddev/SoundDeviceASIO.cpp 2013-10-19 14:17:52 UTC (rev 2934)
+++ trunk/OpenMPT/sounddev/SoundDeviceASIO.cpp 2013-10-19 14:21:30 UTC (rev 2935)
@@ -717,63 +717,43 @@
}
-std::vector<uint32> CASIODevice::GetSampleRates(const std::vector<uint32> &samplerates)
-//-------------------------------------------------------------------------------------
+SoundDeviceCaps CASIODevice::GetDeviceCaps(const std::vector<uint32> &baseSampleRates)
+//------------------------------------------------------------------------------------
{
- std::vector<uint32> results;
+ SoundDeviceCaps caps;
+
const bool wasOpen = (m_pAsioDrv != NULL);
if(!wasOpen)
{
OpenDevice();
if(m_pAsioDrv == NULL)
{
- return results;
+ return caps;
}
}
- for(size_t i = 0; i < samplerates.size(); i++)
+ ASIOSampleRate samplerate;
+ if(m_pAsioDrv->getSampleRate(&samplerate) != ASE_OK)
{
- if(m_pAsioDrv->canSampleRate((ASIOSampleRate)samplerates[i]) == ASE_OK)
- {
- results.push_back(samplerates[i]);
- }
+ samplerate = 0;
}
+ caps.currentSampleRate = Util::Round<uint32>(samplerate);
- if(!wasOpen)
+ for(size_t i = 0; i < baseSampleRates.size(); i++)
{
- CloseDevice();
- }
-
- return results;
-}
-
-
-// If the device is open, this returns the current sample rate. If it's not open, it returns some sample rate supported by the device.
-UINT CASIODevice::GetCurrentSampleRate()
-//--------------------------------------
-{
- const bool wasOpen = (m_pAsioDrv != NULL);
- if(!wasOpen)
- {
- OpenDevice();
- if(m_pAsioDrv == NULL)
+ if(m_pAsioDrv->canSampleRate((ASIOSampleRate)baseSampleRates[i]) == ASE_OK)
{
- return 0;
+ caps.supportedSampleRates.push_back(baseSampleRates[i]);
}
}
- ASIOSampleRate samplerate;
- if(m_pAsioDrv->getSampleRate(&samplerate) != ASE_OK)
- {
- samplerate = 0;
- }
-
if(!wasOpen)
{
CloseDevice();
}
- return (UINT)samplerate;
+ return caps;
}
+
#endif // NO_ASIO
Modified: trunk/OpenMPT/sounddev/SoundDeviceASIO.h
===================================================================
--- trunk/OpenMPT/sounddev/SoundDeviceASIO.h 2013-10-19 14:17:52 UTC (rev 2934)
+++ trunk/OpenMPT/sounddev/SoundDeviceASIO.h 2013-10-19 14:21:30 UTC (rev 2935)
@@ -66,8 +66,7 @@
UINT GetNumBuffers() { return 2; }
float GetCurrentRealLatencyMS() { return m_nAsioBufferLen * 2 * 1000.0f / m_Settings.Samplerate; }
- std::vector<uint32> GetSampleRates(const std::vector<uint32> &samplerates);
- UINT GetCurrentSampleRate();
+ SoundDeviceCaps GetDeviceCaps(const std::vector<uint32> &baseSampleRates);
public:
static std::vector<SoundDeviceInfo> EnumerateDevices();
Modified: trunk/OpenMPT/sounddev/SoundDeviceDirectSound.cpp
===================================================================
--- trunk/OpenMPT/sounddev/SoundDeviceDirectSound.cpp 2013-10-19 14:17:52 UTC (rev 2934)
+++ trunk/OpenMPT/sounddev/SoundDeviceDirectSound.cpp 2013-10-19 14:21:30 UTC (rev 2935)
@@ -28,6 +28,10 @@
#ifndef NO_DSOUND
+#define DSOUND_MINBUFFERSIZE 1024
+#define DSOUND_MAXBUFFERSIZE SNDDEV_MAXBUFFERSIZE
+
+
static std::wstring GuidToString(GUID guid)
//-----------------------------------------
{
@@ -108,6 +112,58 @@
}
+SoundDeviceCaps CDSoundDevice::GetDeviceCaps(const std::vector<uint32> &baseSampleRates)
+//--------------------------------------------------------------------------------------
+{
+ SoundDeviceCaps caps;
+ IDirectSound *dummy = nullptr;
+ IDirectSound *ds = nullptr;
+ if(IsOpen())
+ {
+ ds = m_piDS;
+ } else
+ {
+ const std::wstring internalID = GetDeviceInternalID();
+ GUID guid = internalID.empty() ? GUID() : StringToGuid(internalID);
+ if(DirectSoundCreate(internalID.empty() ? NULL : &guid, &dummy, NULL) != DS_OK)
+ {
+ return caps;
+ }
+ if(!dummy)
+ {
+ return caps;
+ }
+ ds = dummy;
+ }
+ DSCAPS dscaps;
+ MemsetZero(dscaps);
+ dscaps.dwSize = sizeof(dscaps);
+ if(DS_OK != ds->GetCaps(&dscaps))
+ {
+ // nothing known about supported sample rates
+ } else if(dscaps.dwMaxSecondarySampleRate == 0)
+ {
+ // nothing known about supported sample rates
+ } else
+ {
+ for(std::size_t i = 0; i < baseSampleRates.size(); ++i)
+ {
+ if(dscaps.dwMinSecondarySampleRate <= baseSampleRates[i] && baseSampleRates[i] <= dscaps.dwMaxSecondarySampleRate)
+ {
+ caps.supportedSampleRates.push_back(baseSampleRates[i]);
+ }
+ }
+ }
+ if(dummy)
+ {
+ dummy->Release();
+ dummy = nullptr;
+ }
+ ds = nullptr;
+ return caps;
+}
+
+
bool CDSoundDevice::InternalOpen()
//--------------------------------
{
Modified: trunk/OpenMPT/sounddev/SoundDeviceDirectSound.h
===================================================================
--- trunk/OpenMPT/sounddev/SoundDeviceDirectSound.h 2013-10-19 14:17:52 UTC (rev 2934)
+++ trunk/OpenMPT/sounddev/SoundDeviceDirectSound.h 2013-10-19 14:21:30 UTC (rev 2935)
@@ -24,9 +24,6 @@
#ifndef NO_DSOUND
-#define DSOUND_MINBUFFERSIZE 1024
-#define DSOUND_MAXBUFFERSIZE SNDDEV_MAXBUFFERSIZE
-
//================================================
class CDSoundDevice: public CSoundDeviceWithThread
//================================================
@@ -54,6 +51,7 @@
bool IsOpen() const { return (m_pMixBuffer != NULL); }
UINT GetNumBuffers() { return 1; } // meaning 1 ring buffer
float GetCurrentRealLatencyMS() { return m_dwLatency * 1000.0f / m_nBytesPerSec; }
+ SoundDeviceCaps GetDeviceCaps(const std::vector<uint32> &baseSampleRates);
protected:
DWORD LockBuffer(DWORD dwBytes, LPVOID *lpBuf1, LPDWORD lpSize1, LPVOID *lpBuf2, LPDWORD lpSize2);
Modified: trunk/OpenMPT/sounddev/SoundDevicePortAudio.cpp
===================================================================
--- trunk/OpenMPT/sounddev/SoundDevicePortAudio.cpp 2013-10-19 14:17:52 UTC (rev 2934)
+++ trunk/OpenMPT/sounddev/SoundDevicePortAudio.cpp 2013-10-19 14:21:30 UTC (rev 2935)
@@ -160,16 +160,16 @@
}
-std::vector<uint32> CPortaudioDevice::GetSampleRates(const std::vector<uint32> &samplerates)
-//------------------------------------------------------------------------------------------
+SoundDeviceCaps CPortaudioDevice::GetDeviceCaps(const std::vector<uint32> &baseSampleRates)
+//-----------------------------------------------------------------------------------------
{
- std::vector<uint32> results;
+ SoundDeviceCaps caps;
PaDeviceIndex device = HostApiOutputIndexToGlobalDeviceIndex(GetDeviceIndex(), m_HostApi);
if(device == -1)
{
- return results;
+ return caps;
}
- for(UINT n=0; n<samplerates.size(); n++)
+ for(UINT n=0; n<baseSampleRates.size(); n++)
{
PaStreamParameters StreamParameters;
MemsetZero(StreamParameters);
@@ -187,12 +187,12 @@
m_WasapiStreamInfo.flags = paWinWasapiExclusive;
m_StreamParameters.hostApiSpecificStreamInfo = &m_WasapiStreamInfo;
}
- if(Pa_IsFormatSupported(NULL, &StreamParameters, samplerates[n]) == paFormatIsSupported)
+ if(Pa_IsFormatSupported(NULL, &StreamParameters, baseSampleRates[n]) == paFormatIsSupported)
{
- results.push_back(samplerates[n]);
+ caps.supportedSampleRates.push_back(baseSampleRates[n]);
}
}
- return results;
+ return caps;
}
@@ -299,6 +299,18 @@
}
+std::string CPortaudioDevice::HostApiToString(PaHostApiIndex hostapi)
+//-------------------------------------------------------------------
+{
+ if(hostapi == Pa_HostApiTypeIdToHostApiIndex(paWASAPI)) return "WASAPI";
+ if(hostapi == Pa_HostApiTypeIdToHostApiIndex(paWDMKS)) return "WDM-KS";
+ if(hostapi == Pa_HostApiTypeIdToHostApiIndex(paMME)) return "MME";
+ if(hostapi == Pa_HostApiTypeIdToHostApiIndex(paDirectSound)) return "DS";
+ if(hostapi == Pa_HostApiTypeIdToHostApiIndex(paASIO)) return "ASIO";
+ return "PortAudio";
+}
+
+
bool CPortaudioDevice::EnumerateDevices(SoundDeviceInfo &result, SoundDeviceIndex index, PaHostApiIndex hostapi)
//--------------------------------------------------------------------------------------------------------------
{
@@ -310,8 +322,8 @@
return false;
result.id = SoundDeviceID(HostApiToSndDevType(hostapi), index);
result.name = mpt::String::Decode(
- mpt::String::Format("%s - %s%s (portaudio)",
- Pa_GetHostApiInfo(Pa_GetDeviceInfo(dev)->hostApi)->name,
+ mpt::String::Format("%s - %s%s",
+ HostApiToString(Pa_GetDeviceInfo(dev)->hostApi).c_str(),
Pa_GetDeviceInfo(dev)->name,
Pa_GetHostApiInfo(Pa_GetDeviceInfo(dev)->hostApi)->defaultOutputDevice == (PaDeviceIndex)dev ? " (Default)" : ""
),
Modified: trunk/OpenMPT/sounddev/SoundDevicePortAudio.h
===================================================================
--- trunk/OpenMPT/sounddev/SoundDevicePortAudio.h 2013-10-19 14:17:52 UTC (rev 2934)
+++ trunk/OpenMPT/sounddev/SoundDevicePortAudio.h 2013-10-19 14:21:30 UTC (rev 2935)
@@ -54,7 +54,7 @@
float GetCurrentRealLatencyMS();
bool InternalHasGetStreamPosition() const { return false; }
int64 InternalGetStreamPositionSamples() const;
- std::vector<uint32> GetSampleRates(const std::vector<uint32> &samplerates);
+ SoundDeviceCaps GetDeviceCaps(const std::vector<uint32> &baseSampleRates);
int StreamCallback(
const void *input, void *output,
@@ -72,6 +72,8 @@
void *userData
);
+ static std::string HostApiToString(PaHostApiIndex hostapi);
+
static PaDeviceIndex HostApiOutputIndexToGlobalDeviceIndex(int hostapioutputdeviceindex, PaHostApiIndex hostapi);
static SoundDeviceType HostApiToSndDevType(PaHostApiIndex hostapi);
static PaHostApiIndex SndDevTypeToHostApi(SoundDeviceType snddevtype);
Modified: trunk/OpenMPT/sounddev/SoundDeviceWaveout.cpp
===================================================================
--- trunk/OpenMPT/sounddev/SoundDeviceWaveout.cpp 2013-10-19 14:17:52 UTC (rev 2934)
+++ trunk/OpenMPT/sounddev/SoundDeviceWaveout.cpp 2013-10-19 14:21:30 UTC (rev 2935)
@@ -25,6 +25,11 @@
//
+#define WAVEOUT_MAXBUFFERS 256
+#define WAVEOUT_MINBUFFERSIZE 1024
+#define WAVEOUT_MAXBUFFERSIZE 65536
+
+
CWaveDevice::CWaveDevice(SoundDeviceID id, const std::wstring &internalID)
//------------------------------------------------------------------------
: CSoundDeviceWithThread(id, internalID)
Modified: trunk/OpenMPT/sounddev/SoundDeviceWaveout.h
===================================================================
--- trunk/OpenMPT/sounddev/SoundDeviceWaveout.h 2013-10-19 14:17:52 UTC (rev 2934)
+++ trunk/OpenMPT/sounddev/SoundDeviceWaveout.h 2013-10-19 14:21:30 UTC (rev 2935)
@@ -20,10 +20,6 @@
// MMSYSTEM WaveOut device
//
-#define WAVEOUT_MAXBUFFERS 256
-#define WAVEOUT_MINBUFFERSIZE 1024
-#define WAVEOUT_MAXBUFFERSIZE 65536
-
//==============================================
class CWaveDevice: public CSoundDeviceWithThread
//==============================================
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <sag...@us...> - 2013-10-19 16:37:35
|
Revision: 2938
http://sourceforge.net/p/modplug/code/2938
Author: saga-games
Date: 2013-10-19 16:37:27 +0000 (Sat, 19 Oct 2013)
Log Message:
-----------
[Fix] ModSpecs are now also set to something sensible for formats that are not editable by OpenMPT (useful when using e.g. the pattern vis in xmp-openmpt, since it relies on effect letters from ModSpecs)
[Fix] DMO plugins could potentially crash in 64-bit builds.
Modified Paths:
--------------
trunk/OpenMPT/mptrack/Vstplug.cpp
trunk/OpenMPT/soundlib/Sndfile.cpp
Modified: trunk/OpenMPT/mptrack/Vstplug.cpp
===================================================================
--- trunk/OpenMPT/mptrack/Vstplug.cpp 2013-10-19 14:28:29 UTC (rev 2937)
+++ trunk/OpenMPT/mptrack/Vstplug.cpp 2013-10-19 16:37:27 UTC (rev 2938)
@@ -3031,7 +3031,7 @@
m_Effect.numParams = dwParamCount;
}
if (FAILED(m_pMediaObject->QueryInterface(IID_IMediaParams, (void **)&m_pMediaParams))) m_pMediaParams = nullptr;
- m_pMixBuffer = (int16 *)((((int)m_MixBuffer) + 15) & ~15);
+ m_pMixBuffer = (int16 *)((((intptr_t)m_MixBuffer) + 15) & ~15);
// Callbacks
m_Effect.dispatcher = DmoDispatcher;
m_Effect.setParameter = DmoSetParameter;
Modified: trunk/OpenMPT/soundlib/Sndfile.cpp
===================================================================
--- trunk/OpenMPT/soundlib/Sndfile.cpp 2013-10-19 14:28:29 UTC (rev 2937)
+++ trunk/OpenMPT/soundlib/Sndfile.cpp 2013-10-19 16:37:27 UTC (rev 2938)
@@ -901,7 +901,7 @@
if(GetType() != MOD_TYPE_NONE)
{
- SetModSpecsPointer(m_pModSpecs, m_nType);
+ SetModSpecsPointer(m_pModSpecs, GetBestSaveFormat());
const ORDERINDEX CacheSize = ModSequenceSet::s_nCacheSize; // workaround reference to static const member problem
const ORDERINDEX nMinLength = std::min(CacheSize, GetModSpecifications().ordersMax);
if (Order.GetLength() < nMinLength)
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <man...@us...> - 2013-10-20 08:22:06
|
Revision: 2942
http://sourceforge.net/p/modplug/code/2942
Author: manxorist
Date: 2013-10-20 08:21:58 +0000 (Sun, 20 Oct 2013)
Log Message:
-----------
[Ref] sounddev: Split API name from device name.
Modified Paths:
--------------
trunk/OpenMPT/mptrack/Mpdlgs.cpp
trunk/OpenMPT/sounddev/SoundDevice.h
trunk/OpenMPT/sounddev/SoundDeviceASIO.cpp
trunk/OpenMPT/sounddev/SoundDeviceDirectSound.cpp
trunk/OpenMPT/sounddev/SoundDevicePortAudio.cpp
trunk/OpenMPT/sounddev/SoundDeviceWaveout.cpp
Modified: trunk/OpenMPT/mptrack/Mpdlgs.cpp
===================================================================
--- trunk/OpenMPT/mptrack/Mpdlgs.cpp 2013-10-20 05:47:53 UTC (rev 2941)
+++ trunk/OpenMPT/mptrack/Mpdlgs.cpp 2013-10-20 08:21:58 UTC (rev 2942)
@@ -224,12 +224,16 @@
}
{
- mpt::String::Copy(s, mpt::String::Encode(it->name, mpt::CharsetLocale));
+ std::string name = mpt::String::Encode(it->name, mpt::CharsetLocale);
cbi.mask = CBEIF_IMAGE | CBEIF_LPARAM | CBEIF_TEXT | CBEIF_SELECTEDIMAGE | CBEIF_OVERLAY;
cbi.iItem = iItem;
cbi.cchTextMax = 0;
switch(it->id.GetType())
{
+ case SNDDEV_WAVEOUT:
+ case SNDDEV_PORTAUDIO_WMME:
+ cbi.iImage = IMAGE_WAVEOUT;
+ break;
case SNDDEV_DSOUND:
case SNDDEV_PORTAUDIO_DS:
cbi.iImage = IMAGE_DIRECTX;
@@ -238,13 +242,22 @@
case SNDDEV_PORTAUDIO_ASIO:
cbi.iImage = IMAGE_ASIO;
break;
+ case SNDDEV_PORTAUDIO_WASAPI:
+ case SNDDEV_PORTAUDIO_WDMKS:
+ cbi.iImage = IMAGE_WAVEOUT;
+ // No image available for now,
+ // prepend API name to name.
+ name = mpt::String::Encode(it->apiName, mpt::CharsetLocale) + " - " + name;
+ break;
default:
cbi.iImage = IMAGE_WAVEOUT;
+ break;
}
cbi.iSelectedImage = cbi.iImage;
cbi.iOverlay = cbi.iImage;
cbi.iIndent = 0;
cbi.lParam = it->id.GetIdRaw();
+ mpt::String::Copy(s, name);
cbi.pszText = s;
int pos = m_CbnDevice.InsertItem(&cbi);
if(cbi.lParam == m_nSoundDevice.GetIdRaw())
Modified: trunk/OpenMPT/sounddev/SoundDevice.h
===================================================================
--- trunk/OpenMPT/sounddev/SoundDevice.h 2013-10-20 05:47:53 UTC (rev 2941)
+++ trunk/OpenMPT/sounddev/SoundDevice.h 2013-10-20 08:21:58 UTC (rev 2942)
@@ -285,11 +285,13 @@
{
SoundDeviceID id;
std::wstring name;
+ std::wstring apiName;
std::wstring internalID;
SoundDeviceInfo() { }
- SoundDeviceInfo(SoundDeviceID id, const std::wstring &name, const std::wstring &internalID = std::wstring())
+ SoundDeviceInfo(SoundDeviceID id, const std::wstring &name, const std::wstring &apiName, const std::wstring &internalID = std::wstring())
: id(id)
, name(name)
+ , apiName(apiName)
, internalID(internalID)
{
return;
Modified: trunk/OpenMPT/sounddev/SoundDeviceASIO.cpp
===================================================================
--- trunk/OpenMPT/sounddev/SoundDeviceASIO.cpp 2013-10-20 05:47:53 UTC (rev 2941)
+++ trunk/OpenMPT/sounddev/SoundDeviceASIO.cpp 2013-10-20 08:21:58 UTC (rev 2942)
@@ -134,7 +134,7 @@
if(SoundDeviceIndexIsValid(devices.size()))
{
// everything ok
- devices.push_back(SoundDeviceInfo(SoundDeviceID(SNDDEV_ASIO, static_cast<SoundDeviceIndex>(devices.size())), mpt::String::Decode(description, mpt::CharsetLocale), internalID));
+ devices.push_back(SoundDeviceInfo(SoundDeviceID(SNDDEV_ASIO, static_cast<SoundDeviceIndex>(devices.size())), mpt::String::Decode(description, mpt::CharsetLocale), L"ASIO", internalID));
}
}
Modified: trunk/OpenMPT/sounddev/SoundDeviceDirectSound.cpp
===================================================================
--- trunk/OpenMPT/sounddev/SoundDeviceDirectSound.cpp 2013-10-20 05:47:53 UTC (rev 2941)
+++ trunk/OpenMPT/sounddev/SoundDeviceDirectSound.cpp 2013-10-20 08:21:58 UTC (rev 2942)
@@ -73,6 +73,7 @@
SoundDeviceInfo info;
info.id = SoundDeviceID(SNDDEV_DSOUND, static_cast<SoundDeviceIndex>(devices.size()));
info.name = lpstrDescription;
+ info.apiName = L"DirectSound";
if(lpGuid)
{
info.internalID = GuidToString(*lpGuid);
Modified: trunk/OpenMPT/sounddev/SoundDevicePortAudio.cpp
===================================================================
--- trunk/OpenMPT/sounddev/SoundDevicePortAudio.cpp 2013-10-20 05:47:53 UTC (rev 2941)
+++ trunk/OpenMPT/sounddev/SoundDevicePortAudio.cpp 2013-10-20 08:21:58 UTC (rev 2942)
@@ -322,12 +322,12 @@
return false;
result.id = SoundDeviceID(HostApiToSndDevType(hostapi), index);
result.name = mpt::String::Decode(
- mpt::String::Format("%s - %s%s",
- HostApiToString(Pa_GetDeviceInfo(dev)->hostApi).c_str(),
+ mpt::String::Format("%s%s",
Pa_GetDeviceInfo(dev)->name,
Pa_GetHostApiInfo(Pa_GetDeviceInfo(dev)->hostApi)->defaultOutputDevice == (PaDeviceIndex)dev ? " (Default)" : ""
),
mpt::CharsetUTF8);
+ result.apiName = mpt::String::Decode(HostApiToString(Pa_GetDeviceInfo(dev)->hostApi).c_str(), mpt::CharsetUTF8);
return true;
}
Modified: trunk/OpenMPT/sounddev/SoundDeviceWaveout.cpp
===================================================================
--- trunk/OpenMPT/sounddev/SoundDeviceWaveout.cpp 2013-10-20 05:47:53 UTC (rev 2941)
+++ trunk/OpenMPT/sounddev/SoundDeviceWaveout.cpp 2013-10-20 08:21:58 UTC (rev 2942)
@@ -235,6 +235,7 @@
}
SoundDeviceInfo info;
info.id = SoundDeviceID(SNDDEV_WAVEOUT, static_cast<SoundDeviceIndex>(index));
+ info.apiName = L"WaveOut";
if(index == 0)
{
info.name = L"Auto (Wave Mapper)";
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <man...@us...> - 2013-10-21 10:58:12
|
Revision: 2953
http://sourceforge.net/p/modplug/code/2953
Author: manxorist
Date: 2013-10-21 10:58:03 +0000 (Mon, 21 Oct 2013)
Log Message:
-----------
[Ref] Make the behaviour of ASSERT independent of whether _DEBUG is defined by introduction of a new NO_ASSERTS build setting.
[Ref] For MFC builds (which means MODPLUG_TRACKER), set NO_ASSERTS if and only if !_DEBUG. Enforce consistency bewteen these 2 macros in typedefs.h .
[Ref] Cleanup AlwaysAssertHandler and AssertHandler.
[Mod] libopenmpt: Activate ASSERT in all builds.
[Ref] Small related cleanups.
Modified Paths:
--------------
trunk/OpenMPT/common/BuildSettings.h
trunk/OpenMPT/common/typedefs.cpp
trunk/OpenMPT/common/typedefs.h
trunk/OpenMPT/mptrack/ExceptionHandler.cpp
Modified: trunk/OpenMPT/common/BuildSettings.h
===================================================================
--- trunk/OpenMPT/common/BuildSettings.h 2013-10-21 08:32:43 UTC (rev 2952)
+++ trunk/OpenMPT/common/BuildSettings.h 2013-10-21 10:58:03 UTC (rev 2953)
@@ -73,12 +73,17 @@
#define NO_LOGGING
#endif
-// Disable unarchiving support
-//#define NO_ARCHIVE_SUPPORT
+// Disable all runtime asserts
+#ifndef _DEBUG
+#define NO_ASSERTS
+#endif
// Disable std::istream support in class FileReader (this is generally not needed for the tracker, local files can easily be mmapped as they have been before introducing std::istream support)
#define NO_FILEREADER_STD_ISTREAM
+// Disable unarchiving support
+//#define NO_ARCHIVE_SUPPORT
+
// Disable the built-in reverb effect
//#define NO_REVERB
@@ -121,7 +126,7 @@
// Do not build libmodplug emulation layer (only makes sense for library)
#define NO_LIBMODPLUG
-// Do not build xmplay input plugin cod (only makes snse for library)
+// Do not build xmplay input plugin code (only makes sense for library)
#define NO_XMPLAY
// Do not build winamp input plugin code (only makes sense for library)
@@ -140,9 +145,10 @@
#else
#define MODPLUG_NO_FILESAVE
#endif
+//#define NO_ASSERTS
//#define NO_LOGGING
+//#define NO_FILEREADER_STD_ISTREAM
#define NO_ARCHIVE_SUPPORT
-//#define NO_FILEREADER_STD_ISTREAM
#define NO_REVERB
#define NO_DSP
#define NO_EQ
Modified: trunk/OpenMPT/common/typedefs.cpp
===================================================================
--- trunk/OpenMPT/common/typedefs.cpp 2013-10-21 08:32:43 UTC (rev 2952)
+++ trunk/OpenMPT/common/typedefs.cpp 2013-10-21 10:58:03 UTC (rev 2953)
@@ -14,49 +14,23 @@
#include <cstring>
-#ifndef MODPLUG_TRACKER
-void AlwaysAssertHandler(const char *file, int line, const char *function, const char *expr, const char *msg)
-//-----------------------------------------------------------------------------------------------------------
+#if !defined(MODPLUG_TRACKER) && defined(MPT_ASSERT_HANDLER_NEEDED)
+
+noinline void AssertHandler(const char *file, int line, const char *function, const char *expr, const char *msg)
+//--------------------------------------------------------------------------------------------------------------
{
if(msg)
{
- std::cerr
- << "openmpt: ASSERTION FAILED: "
- << file << "(" << line << ")" << ": "
- << msg
- << " (" << std::string(expr) << ") "
- << " [" << function << "]"
- << std::endl
- ;
+ Logger(file, line, function)("ASSERTION FAILED: %s (%s)", msg, expr);
} else
{
- std::cerr
- << "openmpt: ASSERTION FAILED: "
- << file << "(" << line << ")" << ": "
- << std::string(expr)
- << " [" << function << "]"
- << std::endl
- ;
+ Logger(file, line, function)("ASSERTION FAILED: %s", expr);
}
}
-#endif
+#endif // !MODPLUG_TRACKER && MPT_ASSERT_HANDLER_NEEDED
-#if !defined(_MFC_VER)
-void AssertHandler(const char *file, int line, const char *function, const char *expr)
-//------------------------------------------------------------------------------------
-{
- std::cerr
- << "openmpt: ASSERTION FAILED: "
- << file << "(" << line << ")" << ": "
- << std::string(expr)
- << " [" << function << "]"
- << std::endl
- ;
-}
-#endif
-
//#define LOG_TO_FILE
@@ -109,8 +83,8 @@
#endif // MODPLUG_TRACKER
-static void DoLog(const char *file, int line, const char *function, const char *format, va_list args)
-//---------------------------------------------------------------------------------------------------
+static noinline void DoLog(const char *file, int line, const char *function, const char *format, va_list args)
+//------------------------------------------------------------------------------------------------------------
{
#if !defined(MODPLUG_TRACKER) || (defined(MODPLUG_TRACKER) && defined(_DEBUG))
char message[LOGBUF_SIZE];
@@ -163,7 +137,7 @@
}
#else // !MODPLUG_TRACKER
std::clog
- << "openmpt: DEBUG: "
+ << "openmpt: "
<< file << "(" << line << ")" << ": "
<< std::string(message)
<< " [" << function << "]"
@@ -201,4 +175,5 @@
va_end(va);
}
-#endif
+#endif // !NO_LOGGING
+
Modified: trunk/OpenMPT/common/typedefs.h
===================================================================
--- trunk/OpenMPT/common/typedefs.h 2013-10-21 08:32:43 UTC (rev 2952)
+++ trunk/OpenMPT/common/typedefs.h 2013-10-21 10:58:03 UTC (rev 2953)
@@ -125,26 +125,85 @@
-#if !defined(_MFC_VER)
-void AssertHandler(const char *file, int line, const char *function, const char *expr);
+#if defined(_MFC_VER)
+
+#if !defined(ASSERT)
+#error "MFC is expected to #define ASSERT"
+#endif // !defined(ASERRT)
+#define MPT_ASSERT_IS_DEFINED
+
#if defined(_DEBUG)
+ #define MPT_ASSERT_IS_ACTIVE 1
+#else // !_DEBUG
+ #define MPT_ASSERT_IS_ACTIVE 0
+#endif // _DEBUG
+
+#else // !_MFC_VER
+
+#if defined(ASSERT)
+#error "ASSERT(expr) is expected to NOT be defined by any other header"
+#endif // !defined(ASERRT)
+
+#endif // _MFC_VER
+
+
+#if defined(MPT_ASSERT_IS_DEFINED)
+
+//#define ASSERT // already defined
+#define ASSERT_WARN_MESSAGE(expr,msg) ASSERT(expr)
+
+#elif defined(NO_ASSERTS)
+
+#define MPT_ASSERT_IS_DEFINED
+#define MPT_ASSERT_IS_ACTIVE 0
+#define ASSERT(expr) do { } while(0)
+#define ASSERT_WARN_MESSAGE(expr,msg) do { } while(0)
+
+#else // !NO_ASSERTS
+
+#define MPT_ASSERT_IS_DEFINED
+#define MPT_ASSERT_IS_ACTIVE 1
#define ASSERT(expr) do { if(!(expr)) { AssertHandler(__FILE__, __LINE__, __FUNCTION__, #expr); } } while(0)
-#else
-#define ASSERT(expr) do { } while(0)
+#define ASSERT_WARN_MESSAGE(expr,msg) do { if(!(expr)) { AssertHandler(__FILE__, __LINE__, __FUNCTION__, #expr, msg); } } while(0)
+#ifndef MPT_ASSERT_HANDLER_NEEDED
+#define MPT_ASSERT_HANDLER_NEEDED
#endif
+
+#endif // NO_ASSERTS
+
+// error checking
+#if !defined(MPT_ASSERT_IS_DEFINED)
+#error "ASSERT(expr) has to be defined"
+#endif // !MPT_ASSERT_IS_DEFINED
+#if MPT_ASSERT_IS_ACTIVE && defined(NO_ASSERTS)
+#error "ASSERT is active but NO_ASSERT is defined"
+#elif !MPT_ASSERT_IS_ACTIVE && !defined(NO_ASSERTS)
+#error "NO_ASSERT is not defined but ASSERTs are not active"
#endif
-#define ASSERT_WARN_MESSAGE(expr,msg) ASSERT(expr)
-#if defined(_DEBUG)
+#if (MPT_ASSERT_IS_ACTIVE == 1)
+
#define ALWAYS_ASSERT(expr) ASSERT(expr)
-#define ALWAYS_ASSERT_WARN_MESSAGE(expr,msg) ASSERT(expr)
-#else
-void AlwaysAssertHandler(const char *file, int line, const char *function, const char *expr, const char *msg=nullptr);
-#define ALWAYS_ASSERT(expr) do { if(!(expr)) { AlwaysAssertHandler(__FILE__, __LINE__, __FUNCTION__, #expr); } } while(0)
-#define ALWAYS_ASSERT_WARN_MESSAGE(expr,msg) do { if(!(expr)) { AlwaysAssertHandler(__FILE__, __LINE__, __FUNCTION__, #expr, msg); } } while(0)
+#define ALWAYS_ASSERT_WARN_MESSAGE(expr,msg) ASSERT_WARN_MESSAGE(expr.msg)
+
+#else // (MPT_ASSERT_IS_ACTIVE != 1)
+
+#define ALWAYS_ASSERT(expr) do { if(!(expr)) { AssertHandler(__FILE__, __LINE__, __FUNCTION__, #expr); } } while(0)
+#define ALWAYS_ASSERT_WARN_MESSAGE(expr,msg) do { if(!(expr)) { AssertHandler(__FILE__, __LINE__, __FUNCTION__, #expr, msg); } } while(0)
+#ifndef MPT_ASSERT_HANDLER_NEEDED
+#define MPT_ASSERT_HANDLER_NEEDED
#endif
+#endif // MPT_ASSERT_IS_ACTIVE
+
+
+#if defined(MPT_ASSERT_HANDLER_NEEDED)
+// custom assert handler needed
+noinline void AssertHandler(const char *file, int line, const char *function, const char *expr, const char *msg=nullptr);
+#endif // MPT_ASSERT_HANDLER_NEEDED
+
+
// Compile time assert.
#if MPT_COMPILER_MSVC && MPT_MSVC_BEFORE(2010,0)
#define static_assert(expr, msg) typedef char OPENMPT_STATIC_ASSERT[(expr)?1:-1]
Modified: trunk/OpenMPT/mptrack/ExceptionHandler.cpp
===================================================================
--- trunk/OpenMPT/mptrack/ExceptionHandler.cpp 2013-10-21 08:32:43 UTC (rev 2952)
+++ trunk/OpenMPT/mptrack/ExceptionHandler.cpp 2013-10-21 10:58:03 UTC (rev 2953)
@@ -162,10 +162,10 @@
}
-#ifndef _DEBUG
+#if defined(MPT_ASSERT_HANDLER_NEEDED)
-void AlwaysAssertHandler(const char *file, int line, const char *function, const char *expr, const char *msg)
-//-----------------------------------------------------------------------------------------------------------
+noinline void AssertHandler(const char *file, int line, const char *function, const char *expr, const char *msg)
+//--------------------------------------------------------------------------------------------------------------
{
if(IsDebuggerPresent())
{
@@ -189,5 +189,5 @@
}
}
-#endif
+#endif MPT_ASSERT_HANDLER_NEEDED
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <sag...@us...> - 2013-10-21 12:54:03
|
Revision: 2958
http://sourceforge.net/p/modplug/code/2958
Author: saga-games
Date: 2013-10-21 12:53:54 +0000 (Mon, 21 Oct 2013)
Log Message:
-----------
[Fix] AMS Loader: Default speed + tempo was broken since rev.1977
[Fix] AMS Loader: Velvet Studio format version was printed wrong.
[Fix] AMS Loader: Instrument Fadeout was too quick.
[Fix] AMS Loader: Vibrato Envelope is now imported more correctly. Works best in libopenmpt builds, since in that case the envelope is kept in a more precise manner than IT-compatible envelopes allow.
[Imp] AMS Loader: Added support for AMS format 2.00
Modified Paths:
--------------
trunk/OpenMPT/common/versionNumber.h
trunk/OpenMPT/soundlib/Load_ams.cpp
trunk/OpenMPT/soundlib/ModInstrument.cpp
trunk/OpenMPT/soundlib/ModInstrument.h
trunk/OpenMPT/soundlib/Sndmix.cpp
Modified: trunk/OpenMPT/common/versionNumber.h
===================================================================
--- trunk/OpenMPT/common/versionNumber.h 2013-10-21 11:03:05 UTC (rev 2957)
+++ trunk/OpenMPT/common/versionNumber.h 2013-10-21 12:53:54 UTC (rev 2958)
@@ -17,7 +17,7 @@
#define VER_MAJORMAJOR 1
#define VER_MAJOR 22
#define VER_MINOR 05
-#define VER_MINORMINOR 06
+#define VER_MINORMINOR 07
//Version string. For example "1.17.02.28"
#define MPT_VERSION_STR VER_STRINGIZE(VER_MAJORMAJOR) "." VER_STRINGIZE(VER_MAJOR) "." VER_STRINGIZE(VER_MINOR) "." VER_STRINGIZE(VER_MINORMINOR)
Modified: trunk/OpenMPT/soundlib/Load_ams.cpp
===================================================================
--- trunk/OpenMPT/soundlib/Load_ams.cpp 2013-10-21 11:03:05 UTC (rev 2957)
+++ trunk/OpenMPT/soundlib/Load_ams.cpp 2013-10-21 12:53:54 UTC (rev 2958)
@@ -411,7 +411,7 @@
m_nSamples = fileHeader.numSamps;
SetModFlag(MSF_COMPATIBLE_PLAY, true);
SetupMODPanning(true);
- madeWithTracker = mpt::String::Format("Extreme's tracker %d.%d", fileHeader.versionHigh, fileHeader.versionLow);
+ madeWithTracker = mpt::String::Format("Extreme's Tracker %d.%d", fileHeader.versionHigh, fileHeader.versionLow);
std::vector<bool> packSample(fileHeader.numSamps);
@@ -532,7 +532,8 @@
linearSlides = 0x40,
};
- uint16 format; // Version of format (Hi = MainVer, Low = SubVer e.g. 0202 = 2.2)
+ uint8 versionLow; // Version of format (Hi = MainVer, Low = SubVer e.g. 0202 = 2.2)
+ uint8 versionHigh; // ditto
uint8 numIns; // Nr of Instruments (0-255)
uint16 numPats; // Nr of Patterns (1-1024)
uint16 numOrds; // Nr of Positions (1-65535)
@@ -541,7 +542,6 @@
// Convert all multi-byte numeric values to current platform's endianness or vice versa.
void ConvertEndianness()
{
- SwapBytesLE(format);
SwapBytesLE(numPats);
SwapBytesLE(numOrds);
};
@@ -758,7 +758,8 @@
AMS2FileHeader fileHeader;
if(!file.ReadMagic("AMShdr\x1A")
|| !ReadAMSString(songName, file)
- || !file.ReadConvertEndianness(fileHeader))
+ || !file.ReadConvertEndianness(fileHeader)
+ || fileHeader.versionHigh != 2 || fileHeader.versionLow > 2)
{
return false;
} else if(loadFlags == onlyVerifyHeader)
@@ -766,32 +767,30 @@
return true;
}
+ InitializeGlobals();
+
+ m_nType = MOD_TYPE_AMS2;
+ m_nInstruments = fileHeader.numIns;
+ m_nChannels = 32;
+ SetModFlag(MSF_COMPATIBLE_PLAY, true);
+ SetupMODPanning(true);
+ madeWithTracker = mpt::String::Format("Velvet Studio %d.%02d", fileHeader.versionHigh, fileHeader.versionLow);
+
uint16 headerFlags;
- if(fileHeader.format == 0x202)
+ if(fileHeader.versionLow >= 2)
{
m_nDefaultTempo = std::max(uint8(32), static_cast<uint8>(file.ReadUint16LE() >> 8)); // 16.16 Tempo
m_nDefaultSpeed = std::max(uint8(1), file.ReadUint8());
file.Skip(3); // Default values for pattern editor
headerFlags = file.ReadUint16LE();
- } else if(fileHeader.format == 0x201)
+ } else
{
m_nDefaultTempo = std::max(uint8(32), file.ReadUint8());
m_nDefaultSpeed = std::max(uint8(1), file.ReadUint8());
headerFlags = file.ReadUint8();
- } else
- {
- return false;
}
- InitializeGlobals();
-
- m_nType = MOD_TYPE_AMS2;
m_SongFlags = SONG_ITCOMPATGXX | SONG_ITOLDEFFECTS | ((headerFlags & AMS2FileHeader::linearSlides) ? SONG_LINEARSLIDES : SongFlags(0));
- m_nInstruments = fileHeader.numIns;
- m_nChannels = 32;
- SetModFlag(MSF_COMPATIBLE_PLAY, true);
- SetupMODPanning(true);
- madeWithTracker = mpt::String::Format("Velvet Studio %d.%02x", fileHeader.format & 0x0F, fileHeader.format >> 4);
// Instruments
std::vector<SAMPLEINDEX> firstSample; // First sample of instrument
@@ -816,9 +815,11 @@
uint8 numSamples = file.ReadUint8();
uint8 sampleAssignment[120];
+ MemsetZero(sampleAssignment); // Only really needed for v2.0, where the lowest and highest octave aren't cleared.
if(numSamples == 0
- || !file.ReadArray(sampleAssignment))
+ || (fileHeader.versionLow > 0 && !file.ReadArray(sampleAssignment)) // v2.01+: 120 Notes
+ || (fileHeader.versionLow == 0 && !file.ReadArray(reinterpret_cast<uint8 (&) [96]>(sampleAssignment[12])))) // v2.0: 96 Notes
{
continue;
}
@@ -836,8 +837,8 @@
AMS2Instrument instrHeader;
file.ReadConvertEndianness(instrHeader);
- instrument->nFadeOut = (instrHeader.vibampFadeout & AMS2Instrument::fadeOutMask) * 2;
- const uint8 vibAmp = 1 + ((instrHeader.vibampFadeout & AMS2Instrument::vibAmpMask) >> AMS2Instrument::vibAmpShift); // "Close enough"
+ instrument->nFadeOut = (instrHeader.vibampFadeout & AMS2Instrument::fadeOutMask);
+ const int16 vibAmp = 1 << ((instrHeader.vibampFadeout & AMS2Instrument::vibAmpMask) >> AMS2Instrument::vibAmpShift);
instrHeader.ApplyFlags(instrument->VolEnv, AMS2Instrument::volEnvShift);
instrHeader.ApplyFlags(instrument->PanEnv, AMS2Instrument::panEnvShift);
@@ -848,7 +849,12 @@
{
instrument->VolEnv.Values[i] = std::min(uint8(ENVELOPE_MAX), static_cast<uint8>((instrument->VolEnv.Values[i] * ENVELOPE_MAX + 64u) / 127u));
instrument->PanEnv.Values[i] = std::min(uint8(ENVELOPE_MAX), static_cast<uint8>((instrument->PanEnv.Values[i] * ENVELOPE_MAX + 128u) / 255u));
- instrument->PitchEnv.Values[i] = std::min(uint8(ENVELOPE_MAX), static_cast<uint8>(32 + (static_cast<int8>(instrument->PitchEnv.Values[i] - 128) * vibAmp) / 255));
+#ifdef MODPLUG_TRACKER
+ instrument->PitchEnv.Values[i] = std::min(uint8(ENVELOPE_MAX), static_cast<uint8>(32 + Util::muldivrfloor(static_cast<int8>(instrument->PitchEnv.Values[i] - 128), vibAmp, 255)));
+#else
+ // Try to keep as much precision as possible... divide by 8 since that's the highest possible vibAmp factor.
+ instrument->PitchEnv.Values[i] = static_cast<uint8>(128 + Util::muldivrfloor(static_cast<int8>(instrument->PitchEnv.Values[i] - 128), vibAmp, 8));
+#endif
}
// Sample headers - we will have to read them even for shadow samples, and we will have to load them several times,
@@ -867,7 +873,9 @@
file.ReadConvertEndianness(sampleHeader);
sampleHeader.ConvertToMPT(Samples[firstSmp + smp]);
- uint16 settings = (instrHeader.shadowInstr & instrIndexMask) | ((smp << sampleIndexShift) & sampleIndexMask) | ((sampleHeader.flags & AMS2SampleHeader::smpPacked) ? packStatusMask : 0);
+ uint16 settings = (instrHeader.shadowInstr & instrIndexMask)
+ | ((smp << sampleIndexShift) & sampleIndexMask)
+ | ((sampleHeader.flags & AMS2SampleHeader::smpPacked) ? packStatusMask : 0);
sampleSettings.push_back(settings);
}
Modified: trunk/OpenMPT/soundlib/ModInstrument.cpp
===================================================================
--- trunk/OpenMPT/soundlib/ModInstrument.cpp 2013-10-21 11:03:05 UTC (rev 2957)
+++ trunk/OpenMPT/soundlib/ModInstrument.cpp 2013-10-21 12:53:54 UTC (rev 2958)
@@ -74,8 +74,8 @@
// Get envelope value at a given tick. Returns value in range [0.0, 1.0].
-float InstrumentEnvelope::GetValueFromPosition(int position) const
-//----------------------------------------------------------------
+float InstrumentEnvelope::GetValueFromPosition(int position, int range) const
+//---------------------------------------------------------------------------
{
uint32 pt = nNodes - 1u;
@@ -95,7 +95,7 @@
if(position >= x2)
{
// Case: current 'tick' is on a envelope point.
- value = static_cast<float>(Values[pt]) / 64.0f;
+ value = static_cast<float>(Values[pt]) / float(range);
} else
{
// Case: current 'tick' is between two envelope points.
@@ -104,7 +104,7 @@
if(pt)
{
// Get previous node's value and tick.
- value = static_cast<float>(Values[pt - 1]) / 64.0f;
+ value = static_cast<float>(Values[pt - 1]) / float(range);
x1 = Ticks[pt - 1];
}
@@ -112,7 +112,7 @@
{
// Linear approximation between the points;
// f(x + d) ~ f(x) + f'(x) * d, where f'(x) = (y2 - y1) / (x2 - x1)
- value += ((position - x1) * (static_cast<float>(Values[pt]) / 64.0f - value)) / (x2 - x1);
+ value += ((position - x1) * (static_cast<float>(Values[pt]) / float(range) - value)) / (x2 - x1);
}
}
Modified: trunk/OpenMPT/soundlib/ModInstrument.h
===================================================================
--- trunk/OpenMPT/soundlib/ModInstrument.h 2013-10-21 11:03:05 UTC (rev 2957)
+++ trunk/OpenMPT/soundlib/ModInstrument.h 2013-10-21 12:53:54 UTC (rev 2958)
@@ -42,7 +42,7 @@
void Convert(MODTYPE fromType, MODTYPE toType);
// Get envelope value at a given tick. Returns value in range [0.0, 1.0].
- float GetValueFromPosition(int position) const;
+ float GetValueFromPosition(int position, int range = ENVELOPE_MAX) const;
};
Modified: trunk/OpenMPT/soundlib/Sndmix.cpp
===================================================================
--- trunk/OpenMPT/soundlib/Sndmix.cpp 2013-10-21 11:03:05 UTC (rev 2957)
+++ trunk/OpenMPT/soundlib/Sndmix.cpp 2013-10-21 12:53:54 UTC (rev 2958)
@@ -850,7 +850,14 @@
const int envpos = pChn->PitchEnv.nEnvPosition - (IsCompatibleMode(TRK_IMPULSETRACKER) ? 1 : 0);
// Get values in [-256, 256]
- const int envval = Util::Round<int>((pIns->PitchEnv.GetValueFromPosition(envpos) - 0.5f) * 512.0f);
+#ifdef MODPLUG_TRACKER
+ const int range = ENVELOPE_MAX;
+ const float amp = 512.0f;
+#else
+ const int range = GetType() == MOD_TYPE_AMS2 ? uint8_max : ENVELOPE_MAX;
+ const int amp = GetType() == MOD_TYPE_AMS2 ? 64.0f : 512.0f;
+#endif
+ const int envval = Util::Round<int>((pIns->PitchEnv.GetValueFromPosition(envpos, range) - 0.5f) * amp);
if(pChn->PitchEnv.flags[ENV_FILTER])
{
@@ -1176,7 +1183,8 @@
}
}
- if (note > 108 + NOTE_MIN && arpPos != 0)
+ // Test case: ArpeggioClamp.xm
+ if(note > 108 + NOTE_MIN && arpPos != 0)
note = 108 + NOTE_MIN; // FT2's note limit
period = GetPeriodFromNote(note, pChn->nFineTune, pChn->nC5Speed);
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <sag...@us...> - 2013-10-21 16:08:43
|
Revision: 2960
http://sourceforge.net/p/modplug/code/2960
Author: saga-games
Date: 2013-10-21 16:08:36 +0000 (Mon, 21 Oct 2013)
Log Message:
-----------
[Fix] Support 16-bit samples in AMS 1.x files.
[Fix] Display special characters in AMS 2.x files correctly
[Ref] Text converters for SongMessage::Read/etc. are no longer in-place (this should be better when, at some point, these things are supposed to convert to wide chars or something)
Modified Paths:
--------------
trunk/OpenMPT/common/StringFixer.h
trunk/OpenMPT/soundlib/Load_ams.cpp
trunk/OpenMPT/soundlib/Message.cpp
trunk/OpenMPT/soundlib/Message.h
trunk/OpenMPT/soundlib/Tables.cpp
Modified: trunk/OpenMPT/common/StringFixer.h
===================================================================
--- trunk/OpenMPT/common/StringFixer.h 2013-10-21 14:29:37 UTC (rev 2959)
+++ trunk/OpenMPT/common/StringFixer.h 2013-10-21 16:08:36 UTC (rev 2960)
@@ -95,8 +95,6 @@
void Read(std::string &dest, const char *srcBuffer, const size_t srcSize)
//-----------------------------------------------------------------------
{
- ASSERT(srcSize > 0);
-
dest.clear();
if(mode == nullTerminated || mode == maybeNullTerminated)
@@ -163,7 +161,6 @@
//----------------------------------------------------------------------------------
{
STATIC_ASSERT(destSize > 0);
- //ASSERT(srcSize > 0);
const size_t maxSize = MIN(destSize, srcSize);
char *dst = destBuffer;
@@ -389,7 +386,7 @@
// Copy from a fixed size char array to a std::string.
template <size_t srcSize>
void Copy(std::string &dest, const char (&srcBuffer)[srcSize])
- //----------------------------------------------------------------------------
+ //------------------------------------------------------------
{
CopyN(dest, srcBuffer, srcSize);
}
Modified: trunk/OpenMPT/soundlib/Load_ams.cpp
===================================================================
--- trunk/OpenMPT/soundlib/Load_ams.cpp 2013-10-21 14:29:37 UTC (rev 2959)
+++ trunk/OpenMPT/soundlib/Load_ams.cpp 2013-10-21 16:08:36 UTC (rev 2960)
@@ -8,6 +8,8 @@
* While the two programs look rather similiar, the structure of both
* programs' "AMS" format is significantly different in some places -
* Velvet Studio is a rather advanced tracker in comparison to Extreme's Tracker.
+ * The source code of Velvet Studio has been released into the
+ * public domain in 2013: https://github.com/Patosc/VelvetStudio/commits/master
* Authors: OpenMPT Devs
* The OpenMPT source code is released under the BSD license. Read LICENSE for more details.
*/
@@ -21,34 +23,35 @@
// Common code for both AMS formats
// Callback function for reading text
-void ConvertAMSTextChars(char &c)
-//-------------------------------
+static char ConvertAMSTextChars(char c)
+//-------------------------------------
{
switch((unsigned char)c)
{
- case 0x00: c = ' '; break;
- case 0x14: c = '\xF6'; break;
- case 0x19: c = '\xD6'; break;
- case 0x04: c = '\xE4'; break;
- case 0x0E: c = '\xC4'; break;
- case 0x06: c = '\xE5'; break;
- case 0x0F: c = '\xC5'; break;
+ case 0x00: return ' ';
+ case 0x04: return '\xE4'; // Lower-case ae
+ case 0x06: return '\xE5'; // Lower-case a-ring
+ case 0x0E: return '\xC4'; // Upper-case AE
+ case 0x0F: return '\xC5'; // Upper-case A-ring
+ case 0x14: return '\xF6'; // Lower-case oe
+ case 0x19: return '\xD6'; // Upper-case OE
}
+ return c;
}
// Read variable-length AMS string (we ignore the maximum text length specified by the AMS specs and accept any length).
template<size_t destSize>
-bool ReadAMSString(char (&destBuffer)[destSize], FileReader &file)
-//----------------------------------------------------------------
+static bool ReadAMSString(char (&destBuffer)[destSize], FileReader &file)
+//-----------------------------------------------------------------------
{
const size_t length = file.ReadUint8();
return file.ReadString<mpt::String::spacePadded>(destBuffer, length);
}
// Read variable-length AMS string (we ignore the maximum text length specified by the AMS specs and accept any length).
-bool ReadAMSString(std::string &dest, FileReader &file)
-//-----------------------------------------------------
+static bool ReadAMSString(std::string &dest, FileReader &file)
+//------------------------------------------------------------
{
const size_t length = file.ReadUint8();
return file.ReadString<mpt::String::spacePadded>(dest, length);
@@ -56,8 +59,8 @@
// Read AMS or AMS2 (newVersion = true) pattern. At least this part of the format is more or less identical between the two trackers...
-void ReadAMSPattern(CPattern &pattern, bool newVersion, FileReader &patternChunk, CSoundFile &sndFile)
-//----------------------------------------------------------------------------------------------------
+static void ReadAMSPattern(CPattern &pattern, bool newVersion, FileReader &patternChunk, CSoundFile &sndFile)
+//-----------------------------------------------------------------------------------------------------------
{
enum
{
@@ -324,7 +327,8 @@
{
enum SampleFlags
{
- smp16Bit = 0x80,
+ smp16BitOld = 0x04, // AMS 1.0 (at least according to docs, I yet have to find such a file)
+ smp16Bit = 0x80, // AMS 1.1+
smpPacked = 0x03,
};
@@ -372,8 +376,13 @@
if(mptSmp.nLoopStart < mptSmp.nLoopEnd)
{
- mptSmp.uFlags |= CHN_LOOP;
+ mptSmp.uFlags.set(CHN_LOOP);
}
+
+ if((flags & smp16Bit) || (flags & smp16BitOld))
+ {
+ mptSmp.uFlags.set(CHN_16BIT);
+ }
}
};
@@ -504,7 +513,7 @@
for(SAMPLEINDEX smp = 1; smp <= GetNumSamples(); smp++)
{
SampleIO(
- (Samples[smp].uFlags & CHN_16BIT) ? SampleIO::_16bit : SampleIO::_8bit,
+ Samples[smp].uFlags[CHN_16BIT] ? SampleIO::_16bit : SampleIO::_8bit,
SampleIO::mono,
SampleIO::littleEndian,
packSample[smp - 1] ? SampleIO::AMS : SampleIO::signedPCM)
@@ -517,9 +526,32 @@
/////////////////////////////////////////////////////////////////////
-// AMS (Velvet Studio) 2.1 / 2.2 loader
+// AMS (Velvet Studio) 2.0 - 2.02 loader
+// Callback function for reading text - looking at Velvet Studio's bitmap font (TPIC32.PCX), these appear to be the only supported non-ASCII chars.
+static char ConvertAMS2TextChars(char c)
+//--------------------------------------
+{
+ const char controlChars[] =
+ {
+ ' ', '\xA9', 'v' /* actually supposed to be a root/check sign */, '\xB7',
+ '0', '1', '2', '3', '4', '5', '6', '7', '8', '9', 'A', 'B', 'C', 'D', 'E', 'F', // Small GUI letters
+ ' ', '\xA7'
+ };
+ const char highChars[] = { '\xE4', ' ', '\xE5', ' ', ' ', ' ', ' ', ' ', ' ', ' ', '\xC4', '\xC5', ' ', ' ', ' ', ' ', '\xF6', ' ', ' ', ' ', ' ', '\xD6' };
+
+ if(c < CountOf(controlChars))
+ {
+ return controlChars[c];
+ } else if((unsigned char)c >= 0x84 && (unsigned char)c < 0x84 + CountOf(highChars))
+ {
+ return highChars[(unsigned char)c - 0x84];
+ }
+ return c;
+}
+
+
#ifdef NEEDS_PRAGMA_PACK
#pragma pack(push, 1)
#endif
@@ -532,7 +564,7 @@
linearSlides = 0x40,
};
- uint8 versionLow; // Version of format (Hi = MainVer, Low = SubVer e.g. 0202 = 2.2)
+ uint8 versionLow; // Version of format (Hi = MainVer, Low = SubVer e.g. 0202 = 2.02)
uint8 versionHigh; // ditto
uint8 numIns; // Nr of Instruments (0-255)
uint16 numPats; // Nr of Patterns (1-1024)
@@ -553,7 +585,7 @@
// AMS2 Instument Envelope
struct PACKED AMS2Envelope
{
- uint8 speed; // Envelope speed
+ uint8 speed; // Envelope speed (currently not supported, always the same as current BPM)
uint8 sustainPoint; // Envelope sustain point
uint8 loopStart; // Envelope loop Start
uint8 loopEnd; // Envelope loop End
@@ -889,7 +921,7 @@
uint8 composerLength = file.ReadUint8();
if(composerLength)
{
- songMessage.Read(file, composerLength, SongMessage::leAutodetect, ConvertAMSTextChars);
+ songMessage.Read(file, composerLength, SongMessage::leAutodetect, ConvertAMS2TextChars);
}
// Channel names
@@ -929,7 +961,7 @@
}
}
// Packed text doesn't include any line breaks!
- songMessage.ReadFixedLineLength(&textOut[0], descriptionHeader.unpackedLen, 74, 0, ConvertAMSTextChars);
+ songMessage.ReadFixedLineLength(&textOut[0], descriptionHeader.unpackedLen, 74, 0, ConvertAMS2TextChars);
}
// Read Order List
Modified: trunk/OpenMPT/soundlib/Message.cpp
===================================================================
--- trunk/OpenMPT/soundlib/Message.cpp 2013-10-21 14:29:37 UTC (rev 2959)
+++ trunk/OpenMPT/soundlib/Message.cpp 2013-10-21 16:08:36 UTC (rev 2960)
@@ -43,7 +43,7 @@
{
char c = str[i];
if(pTextConverter != nullptr)
- pTextConverter(c);
+ c = pTextConverter(c);
if(c == '\r') nCR++;
else if(c == '\n') nLF++;
@@ -68,7 +68,7 @@
{
char c = str[i];
if(pTextConverter != nullptr)
- pTextConverter(c);
+ c = pTextConverter(c);
if(c != '\n' || lineEnding != leCRLF)
finalLength++;
@@ -81,7 +81,7 @@
{
char c = str[i];
if(pTextConverter != nullptr)
- pTextConverter(c);
+ c = pTextConverter(c);
switch(c)
{
@@ -149,7 +149,7 @@
for(size_t lpos = 0; lpos < lineLength; lpos++)
{
// Pre-process text
- if(pTextConverter != nullptr) pTextConverter(at(cpos + lpos));
+ if(pTextConverter != nullptr) at(cpos + lpos) = pTextConverter(at(cpos + lpos));
switch(at(cpos + lpos))
{
@@ -215,7 +215,7 @@
{
char c = at(i);
// Pre-process text
- if(pTextConverter != nullptr) pTextConverter(c);
+ if(pTextConverter != nullptr) c = pTextConverter(c);
comments.at(writePos++) = c;
}
}
Modified: trunk/OpenMPT/soundlib/Message.h
===================================================================
--- trunk/OpenMPT/soundlib/Message.h 2013-10-21 14:29:37 UTC (rev 2959)
+++ trunk/OpenMPT/soundlib/Message.h 2013-10-21 16:08:36 UTC (rev 2960)
@@ -20,7 +20,7 @@
{
public:
- typedef void (*ConverterFunc)(char &);
+ typedef char (*ConverterFunc)(char);
// Line ending types (for reading song messages from module files)
enum LineEnding
Modified: trunk/OpenMPT/soundlib/Tables.cpp
===================================================================
--- trunk/OpenMPT/soundlib/Tables.cpp 2013-10-21 14:29:37 UTC (rev 2959)
+++ trunk/OpenMPT/soundlib/Tables.cpp 2013-10-21 16:08:36 UTC (rev 2960)
@@ -29,7 +29,8 @@
"F#", "G-", "G#", "A-", "A#", "B-"
};
-const LPCSTR szDefaultNoteNames[NOTE_MAX] = {
+const LPCSTR szDefaultNoteNames[NOTE_MAX] =
+{
"C-0", "C#0", "D-0", "D#0", "E-0", "F-0", "F#0", "G-0", "G#0", "A-0", "A#0", "B-0",
"C-1", "C#1", "D-1", "D#1", "E-1", "F-1", "F#1", "G-1", "G#1", "A-1", "A#1", "B-1",
"C-2", "C#2", "D-2", "D#2", "E-2", "F-2", "F#2", "G-2", "G#2", "A-2", "A#2", "B-2",
@@ -48,8 +49,8 @@
struct ModFormatInfo
{
- MODTYPE format; // MOD_TYPE_XXXX
- const char *name; // "ProTracker"
+ MODTYPE format; // MOD_TYPE_XXXX
+ const char *name; // "ProTracker"
const char *extension; // "mod"
};
@@ -134,7 +135,8 @@
#endif
-struct ModCharsetInfo {
+struct ModCharsetInfo
+{
MODTYPE type;
MOD_CHARSET_CERTAINTY certainty;
const char *charset;
@@ -166,8 +168,8 @@
{ MOD_TYPE_J2B , MOD_CHARSET_IS , "cp437" },
{ MOD_TYPE_IMF , MOD_CHARSET_IS , "cp437" },
{ MOD_TYPE_ULT , MOD_CHARSET_IS , "cp437" },
- { MOD_TYPE_AMS , MOD_CHARSET_IS , "cp437" },
- { MOD_TYPE_AMS2, MOD_CHARSET_IS , "cp437" },
+ { MOD_TYPE_AMS , MOD_CHARSET_IS , "Windows-1252"}, // We convert the custom AMS special character set to our own set.
+ { MOD_TYPE_AMS2, MOD_CHARSET_IS , "Windows-1252"}, // ditto
{ MOD_TYPE_DSM , MOD_CHARSET_IS , "cp437" },
// Windows
{ MOD_TYPE_MT2 , MOD_CHARSET_MAYBE , "Windows-1252"},
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <sag...@us...> - 2013-10-21 17:26:24
|
Revision: 2963
http://sourceforge.net/p/modplug/code/2963
Author: saga-games
Date: 2013-10-21 17:26:17 +0000 (Mon, 21 Oct 2013)
Log Message:
-----------
[Ref] Added macro MPT_FALLTHROUGH to annotate intentional fall-through in switch statements.
Modified Paths:
--------------
trunk/OpenMPT/common/typedefs.h
trunk/OpenMPT/mptrack/Ctrl_seq.cpp
trunk/OpenMPT/mptrack/EffectInfo.cpp
trunk/OpenMPT/mptrack/Mpt_midi.cpp
trunk/OpenMPT/mptrack/View_ins.cpp
trunk/OpenMPT/mptrack/View_pat.cpp
trunk/OpenMPT/mptrack/View_smp.cpp
trunk/OpenMPT/mptrack/View_tre.cpp
trunk/OpenMPT/soundlib/Load_okt.cpp
trunk/OpenMPT/soundlib/Load_stm.cpp
trunk/OpenMPT/soundlib/Message.cpp
trunk/OpenMPT/soundlib/Snd_fx.cpp
Modified: trunk/OpenMPT/common/typedefs.h
===================================================================
--- trunk/OpenMPT/common/typedefs.h 2013-10-21 17:05:44 UTC (rev 2962)
+++ trunk/OpenMPT/common/typedefs.h 2013-10-21 17:26:17 UTC (rev 2963)
@@ -211,7 +211,14 @@
#define STATIC_ASSERT(expr) static_assert((expr), "compile time assertion failed: " #expr)
+// Macro for marking intentional fall-throughs in switch statements - can be used for static analysis if supported.
+#if MPT_COMPILER_MSVC
+#define MPT_FALLTHROUGH __fallthrough
+#else
+#define MPT_FALLTHROUGH do { } while(0)
+#endif
+
#include <cstdarg>
#if MPT_COMPILER_MSVC
#ifndef va_copy
Modified: trunk/OpenMPT/mptrack/Ctrl_seq.cpp
===================================================================
--- trunk/OpenMPT/mptrack/Ctrl_seq.cpp 2013-10-21 17:05:44 UTC (rev 2962)
+++ trunk/OpenMPT/mptrack/Ctrl_seq.cpp 2013-10-21 17:26:17 UTC (rev 2963)
@@ -430,7 +430,7 @@
SetCurSelTo2ndSel(wParam == kcOrderlistNavigateFirstSelect); SetCurSel(0); return wParam;
case kcEditSelectAll:
SetCurSel(0);
- // fallthroughs intended.
+ MPT_FALLTHROUGH;
case kcOrderlistNavigateLastSelect:
case kcOrderlistNavigateLast:
{
Modified: trunk/OpenMPT/mptrack/EffectInfo.cpp
===================================================================
--- trunk/OpenMPT/mptrack/EffectInfo.cpp 2013-10-21 17:05:44 UTC (rev 2962)
+++ trunk/OpenMPT/mptrack/EffectInfo.cpp 2013-10-21 17:26:17 UTC (rev 2963)
@@ -728,6 +728,7 @@
case 0x0B: strcpy(s, "7B: Pitch Env Off"); break;
case 0x0C: strcpy(s, "7C: Pitch Env On"); break;
// intentional fall-through for non-MPT modules follows
+ MPT_FALLTHROUGH;
case 0x0D: if(sndFile.GetType() == MOD_TYPE_MPT) { strcpy(s, "7D: Force Pitch Env"); break; }
case 0x0E: if(sndFile.GetType() == MOD_TYPE_MPT) { strcpy(s, "7E: Force Filter Env"); break; }
default: wsprintf(s, "%02X: undefined", param); break;
Modified: trunk/OpenMPT/mptrack/Mpt_midi.cpp
===================================================================
--- trunk/OpenMPT/mptrack/Mpt_midi.cpp 2013-10-21 17:05:44 UTC (rev 2962)
+++ trunk/OpenMPT/mptrack/Mpt_midi.cpp 2013-10-21 17:26:17 UTC (rev 2963)
@@ -97,8 +97,7 @@
case MIDIEvents::evNoteOff: // Note Off
case MIDIEvents::evNoteOn: // Note On
ApplyTransposeKeyboardSetting(*pMainFrm, dwParam1);
- // Intentional fall-through
-
+ MPT_FALLTHROUGH;
default:
if(::SendMessage(hWndMidi, WM_MOD_MIDIMSG, dwParam1, dwParam2))
return; // Message has been handled
Modified: trunk/OpenMPT/mptrack/View_ins.cpp
===================================================================
--- trunk/OpenMPT/mptrack/View_ins.cpp 2013-10-21 17:05:44 UTC (rev 2962)
+++ trunk/OpenMPT/mptrack/View_ins.cpp 2013-10-21 17:26:17 UTC (rev 2963)
@@ -2089,6 +2089,7 @@
}
}
// Instrument file -> fall through
+ MPT_FALLTHROUGH;
case DRAGONDROP_SOUNDFILE:
SendCtrlMessage(CTRLMSG_INS_OPENFILE, lpDropInfo->lDropParam);
break;
Modified: trunk/OpenMPT/mptrack/View_pat.cpp
===================================================================
--- trunk/OpenMPT/mptrack/View_pat.cpp 2013-10-21 17:05:44 UTC (rev 2962)
+++ trunk/OpenMPT/mptrack/View_pat.cpp 2013-10-21 17:26:17 UTC (rev 2963)
@@ -2537,7 +2537,7 @@
{
case PatternCursor::noteColumn:
m.note = m_cmdOld.note;
- // Intentional fall-through
+ MPT_FALLTHROUGH;
case PatternCursor::instrColumn:
m.instr = m_cmdOld.instr;
break;
Modified: trunk/OpenMPT/mptrack/View_smp.cpp
===================================================================
--- trunk/OpenMPT/mptrack/View_smp.cpp 2013-10-21 17:05:44 UTC (rev 2962)
+++ trunk/OpenMPT/mptrack/View_smp.cpp 2013-10-21 17:26:17 UTC (rev 2963)
@@ -2327,7 +2327,7 @@
break;
}
}
- // Fall through
+ MPT_FALLTHROUGH;
case DRAGONDROP_SOUNDFILE:
SendCtrlMessage(CTRLMSG_SMP_OPENFILE, (LPARAM)lpDropInfo->lDropParam);
break;
Modified: trunk/OpenMPT/mptrack/View_tre.cpp
===================================================================
--- trunk/OpenMPT/mptrack/View_tre.cpp 2013-10-21 17:05:44 UTC (rev 2962)
+++ trunk/OpenMPT/mptrack/View_tre.cpp 2013-10-21 17:26:17 UTC (rev 2963)
@@ -3445,7 +3445,7 @@
{
break;
}
- // Intentional fall-through
+ MPT_FALLTHROUGH;
case MODITEM_SEQUENCE:
if(modItem.val1 < sndFile.Order.GetNumSequences())
{
Modified: trunk/OpenMPT/soundlib/Load_okt.cpp
===================================================================
--- trunk/OpenMPT/soundlib/Load_okt.cpp 2013-10-21 17:05:44 UTC (rev 2962)
+++ trunk/OpenMPT/soundlib/Load_okt.cpp 2013-10-21 17:26:17 UTC (rev 2963)
@@ -240,6 +240,7 @@
break;
}
// 0x40 is set volume -- fall through
+ MPT_FALLTHROUGH;
case 0: case 1: case 2: case 3:
m->volcmd = VOLCMD_VOLUME;
m->vol = m->param;
Modified: trunk/OpenMPT/soundlib/Load_stm.cpp
===================================================================
--- trunk/OpenMPT/soundlib/Load_stm.cpp 2013-10-21 17:05:44 UTC (rev 2962)
+++ trunk/OpenMPT/soundlib/Load_stm.cpp 2013-10-21 17:26:17 UTC (rev 2963)
@@ -265,9 +265,9 @@
// natively supporting STM editing, so we just assume the tempo is 125 and
// divide the speed by 16 instead. Parameters below 10 might behave weird.
m->param >>= 4;
+ MPT_FALLTHROUGH;
#endif // MODPLUG_TRACKER
- // Intentonal fall-through
default:
// Anything not listed above is a no-op if there's no value.
// (ST2 doesn't have effect memory)
Modified: trunk/OpenMPT/soundlib/Message.cpp
===================================================================
--- trunk/OpenMPT/soundlib/Message.cpp 2013-10-21 17:05:44 UTC (rev 2962)
+++ trunk/OpenMPT/soundlib/Message.cpp 2013-10-21 17:26:17 UTC (rev 2963)
@@ -206,7 +206,7 @@
break;
case leCRLF:
comments.at(writePos++) = '\r';
- // Intentional fall-through
+ MPT_FALLTHROUGH;
case leLF:
comments.at(writePos++) = '\n';
break;
Modified: trunk/OpenMPT/soundlib/Snd_fx.cpp
===================================================================
--- trunk/OpenMPT/soundlib/Snd_fx.cpp 2013-10-21 17:05:44 UTC (rev 2962)
+++ trunk/OpenMPT/soundlib/Snd_fx.cpp 2013-10-21 17:26:17 UTC (rev 2963)
@@ -2107,7 +2107,7 @@
{
pChn->nPan = 0;
}
- // Intentional fall-through
+ MPT_FALLTHROUGH;
default:
// no memory here.
volcmd = VOLCMD_NONE;
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <man...@us...> - 2013-10-21 18:34:29
|
Revision: 2968
http://sourceforge.net/p/modplug/code/2968
Author: manxorist
Date: 2013-10-21 18:34:22 +0000 (Mon, 21 Oct 2013)
Log Message:
-----------
[Ref] Remove unused struct fixed5p27 .
Modified Paths:
--------------
trunk/OpenMPT/common/typedefs.h
trunk/OpenMPT/mptrack/MainFrm.cpp
trunk/OpenMPT/mptrack/Mod2wave.cpp
trunk/OpenMPT/soundlib/SampleFormat.h
trunk/OpenMPT/soundlib/SampleFormatConverters.h
Modified: trunk/OpenMPT/common/typedefs.h
===================================================================
--- trunk/OpenMPT/common/typedefs.h 2013-10-21 18:29:01 UTC (rev 2967)
+++ trunk/OpenMPT/common/typedefs.h 2013-10-21 18:34:22 UTC (rev 2968)
@@ -301,22 +301,6 @@
#define int24_min (0-0x00800000)
#define int24_max (0+0x007fffff)
-struct fixed5p27
-{
- // 5 integer bits (including sign)
- // 27 fractional bits
- int32 raw;
-
- static fixed5p27 Raw(int32 x) { return fixed5p27().SetRaw(x); }
-
- fixed5p27& SetRaw(int32 x) { raw = x; return *this; }
- int32 GetRaw() const { return raw; }
-
-};
-STATIC_ASSERT(sizeof(fixed5p27) == 4);
-#define fixed5p27_min fixed5p27::Raw(int32_min)
-#define fixed5p27_max fixed5p27::Raw(int32_max)
-
struct uint8_4
{
uint8 x[4];
Modified: trunk/OpenMPT/mptrack/MainFrm.cpp
===================================================================
--- trunk/OpenMPT/mptrack/MainFrm.cpp 2013-10-21 18:29:01 UTC (rev 2967)
+++ trunk/OpenMPT/mptrack/MainFrm.cpp 2013-10-21 18:34:22 UTC (rev 2968)
@@ -842,13 +842,6 @@
target.DataCallback(MixSoundBuffer, channels, countChunk);
}
break;
- case SampleFormatFixed5p27:
- {
- typedef SampleFormatToType<SampleFormatFixed5p27>::type Tsample;
- AudioReadTargetBuffer<Tsample> target(dither, reinterpret_cast<Tsample*>(buffer), nullptr);
- target.DataCallback(MixSoundBuffer, channels, countChunk);
- }
- break;
}
// increment output buffer for potentially next callback
buffer = (char*)buffer + (sampleFormat.GetBitsPerSample()/8) * channels * countChunk;
Modified: trunk/OpenMPT/mptrack/Mod2wave.cpp
===================================================================
--- trunk/OpenMPT/mptrack/Mod2wave.cpp 2013-10-21 18:29:01 UTC (rev 2967)
+++ trunk/OpenMPT/mptrack/Mod2wave.cpp 2013-10-21 18:34:22 UTC (rev 2968)
@@ -68,13 +68,6 @@
return sndFile.Read(count, target);
}
break;
- case SampleFormatFixed5p27:
- {
- typedef SampleFormatToType<SampleFormatFixed5p27>::type Tsample;
- AudioReadTargetBuffer<Tsample> target(dither, reinterpret_cast<Tsample*>(outputBuffer), nullptr);
- return sndFile.Read(count, target);
- }
- break;
}
return 0;
}
Modified: trunk/OpenMPT/soundlib/SampleFormat.h
===================================================================
--- trunk/OpenMPT/soundlib/SampleFormat.h 2013-10-21 18:29:01 UTC (rev 2967)
+++ trunk/OpenMPT/soundlib/SampleFormat.h 2013-10-21 18:34:22 UTC (rev 2968)
@@ -17,7 +17,6 @@
SampleFormatInt24 = 24, // do not change value (for compatibility with old configuration settings)
SampleFormatInt32 = 32, // do not change value (for compatibility with old configuration settings)
SampleFormatFloat32 = 32 + 128, // do not change value (for compatibility with old configuration settings)
- SampleFormatFixed5p27 = 255, // mixbuffer format
SampleFormatInvalid = 0
};
@@ -27,7 +26,6 @@
template<> struct SampleFormatTraits<int24> { static const SampleFormatEnum sampleFormat = SampleFormatInt24; };
template<> struct SampleFormatTraits<int32> { static const SampleFormatEnum sampleFormat = SampleFormatInt32; };
template<> struct SampleFormatTraits<float> { static const SampleFormatEnum sampleFormat = SampleFormatFloat32; };
-template<> struct SampleFormatTraits<fixed5p27> { static const SampleFormatEnum sampleFormat = SampleFormatFixed5p27; };
template<SampleFormatEnum sampleFormat> struct SampleFormatToType;
template<> struct SampleFormatToType<SampleFormatUnsigned8> { typedef uint8 type; };
@@ -35,7 +33,6 @@
template<> struct SampleFormatToType<SampleFormatInt24> { typedef int24 type; };
template<> struct SampleFormatToType<SampleFormatInt32> { typedef int32 type; };
template<> struct SampleFormatToType<SampleFormatFloat32> { typedef float type; };
-template<> struct SampleFormatToType<SampleFormatFixed5p27> { typedef fixed5p27 type; };
struct SampleFormat
@@ -69,11 +66,6 @@
if(!IsValid()) return false;
return value != SampleFormatFloat32;
}
- bool IsMixBuffer() const
- {
- if(!IsValid()) return false;
- return value == SampleFormatFixed5p27;
- }
uint8 GetBitsPerSample() const
{
if(!IsValid()) return 0;
@@ -94,9 +86,6 @@
case SampleFormatFloat32:
return 32;
break;
- case SampleFormatFixed5p27:
- return 32;
- break;
default:
return 0;
break;
Modified: trunk/OpenMPT/soundlib/SampleFormatConverters.h
===================================================================
--- trunk/OpenMPT/soundlib/SampleFormatConverters.h 2013-10-21 18:29:01 UTC (rev 2967)
+++ trunk/OpenMPT/soundlib/SampleFormatConverters.h 2013-10-21 18:34:22 UTC (rev 2968)
@@ -490,21 +490,9 @@
}
};
-template <int fractionalBits>
-struct ConvertFixedPoint<fixed5p27, int32, fractionalBits>
-{
- typedef int32 input_t;
- typedef fixed5p27 output_t;
- forceinline output_t operator() (input_t val)
- {
- STATIC_ASSERT(fractionalBits == 27 && sizeof(input_t)*8 == 32);
- return fixed5p27::Raw(val);
- }
-};
-
// Reads sample data with Func and passes it directly to Func2.
// Func1::output_t and Func2::input_t must be identical
template <typename Func2, typename Func1>
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <sag...@us...> - 2013-10-21 19:28:46
|
Revision: 2972
http://sourceforge.net/p/modplug/code/2972
Author: saga-games
Date: 2013-10-21 19:28:38 +0000 (Mon, 21 Oct 2013)
Log Message:
-----------
[Ref] Get rid of a few more WinAPI types in typedef.h and replace them in other parts of the soundlib code.
Modified Paths:
--------------
trunk/OpenMPT/common/serialization_utils.h
trunk/OpenMPT/common/typedefs.h
trunk/OpenMPT/mptrack/Autotune.cpp
trunk/OpenMPT/mptrack/MemoryMappedFile.cpp
trunk/OpenMPT/mptrack/MemoryMappedFile.h
trunk/OpenMPT/mptrack/Mod2wave.cpp
trunk/OpenMPT/mptrack/Moddoc.cpp
trunk/OpenMPT/mptrack/Mpdlgs.cpp
trunk/OpenMPT/mptrack/Mptrack.h
trunk/OpenMPT/mptrack/View_ins.cpp
trunk/OpenMPT/mptrack/mod2midi.cpp
trunk/OpenMPT/mptrack/mod2midi.h
trunk/OpenMPT/mptrack/mod2wave.h
trunk/OpenMPT/sounddsp/Reverb.cpp
trunk/OpenMPT/soundlib/Dlsbank.cpp
trunk/OpenMPT/soundlib/Dlsbank.h
trunk/OpenMPT/soundlib/Fastmix.cpp
trunk/OpenMPT/soundlib/Load_it.cpp
trunk/OpenMPT/soundlib/Load_itp.cpp
trunk/OpenMPT/soundlib/Load_med.cpp
trunk/OpenMPT/soundlib/Load_mid.cpp
trunk/OpenMPT/soundlib/Load_mod.cpp
trunk/OpenMPT/soundlib/Load_s3m.cpp
trunk/OpenMPT/soundlib/Load_xm.cpp
trunk/OpenMPT/soundlib/Mmcmp.cpp
trunk/OpenMPT/soundlib/SampleFormats.cpp
trunk/OpenMPT/soundlib/Sndfile.cpp
trunk/OpenMPT/soundlib/Sndfile.h
trunk/OpenMPT/soundlib/Tables.cpp
trunk/OpenMPT/soundlib/tuningCollection.cpp
Modified: trunk/OpenMPT/common/serialization_utils.h
===================================================================
--- trunk/OpenMPT/common/serialization_utils.h 2013-10-21 19:11:20 UTC (rev 2971)
+++ trunk/OpenMPT/common/serialization_utils.h 2013-10-21 19:28:38 UTC (rev 2972)
@@ -117,7 +117,7 @@
template<class T>
inline void Binarywrite(std::ostream& oStrm, const T& data)
-//------------------------------------------------------
+//---------------------------------------------------------
{
union {
T t;
@@ -135,7 +135,7 @@
//Write only given number of bytes from the beginning.
template<class T>
inline void Binarywrite(std::ostream& oStrm, const T& data, const Offtype bytecount)
-//--------------------------------------------------------------------------
+//----------------------------------------------------------------------------------
{
union {
T t;
@@ -152,7 +152,7 @@
template <class T>
inline void WriteItem(std::ostream& oStrm, const T& data)
-//----------------------------------------------------
+//-------------------------------------------------------
{
#ifdef HAS_TYPE_TRAITS
static_assert(std::is_trivial<T>::value == true, "");
@@ -166,12 +166,12 @@
inline void WriteItem<std::string>(std::ostream& oStrm, const std::string& str) {WriteItemString(oStrm, str.c_str(), str.length());}
template <>
-inline void WriteItem<LPCSTR>(std::ostream& oStrm, const LPCSTR& psz) {WriteItemString(oStrm, psz, strlen(psz));}
+inline void WriteItem<const char *>(std::ostream& oStrm, const char * const & psz) { WriteItemString(oStrm, psz, strlen(psz));}
template<class T>
inline void Binaryread(std::istream& iStrm, T& data)
-//----------------------------------------------
+//--------------------------------------------------
{
union {
T t;
@@ -189,7 +189,7 @@
//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(std::istream& iStrm, T& data, const Offtype bytecount)
-//-----------------------------------------------------------------------
+//---------------------------------------------------------------------------
{
#ifdef HAS_TYPE_TRAITS
static_assert(std::is_trivial<T>::value == true, "");
@@ -211,7 +211,7 @@
template <class T>
inline void ReadItem(std::istream& iStrm, T& data, const DataSize nSize)
-//------------------------------------------------------------------
+//----------------------------------------------------------------------
{
#ifdef HAS_TYPE_TRAITS
static_assert(std::is_trivial<T>::value == true, "");
@@ -225,7 +225,7 @@
// Read specialization for float. If data size is 8, read double and assign it to given float.
template <>
inline void ReadItem<float>(std::istream& iStrm, float& f, const DataSize nSize)
-//--------------------------------------------------------------------------
+//------------------------------------------------------------------------------
{
if (nSize == 8)
{
@@ -240,7 +240,7 @@
// Read specialization for double. If data size is 4, read float and assign it to given double.
template <>
inline void ReadItem<double>(std::istream& iStrm, double& d, const DataSize nSize)
-//----------------------------------------------------------------------------
+//--------------------------------------------------------------------------------
{
if (nSize == 4)
{
@@ -252,11 +252,11 @@
Binaryread(iStrm, d);
}
-void ReadItemString(std::istream& iStrm, std::string& str, const DataSize);
+void ReadItemString(std::istream& iStrm, std::string& str, const DataSize);
template <>
inline void ReadItem<std::string>(std::istream& iStrm, std::string& str, const DataSize nSize)
-//----------------------------------------------------------------------------------------
+//--------------------------------------------------------------------------------------------
{
ReadItemString(iStrm, str, nSize);
}
@@ -323,7 +323,7 @@
// Returns read iterator to the beginning of entries.
// The behaviour of read iterators is undefined if map doesn't
- // contain entry ids or data begin positions.
+ // contain entry ids or data begin positions.
ReadIterator GetReadBegin();
// Returns read iterator to the end(one past last) of entries.
Modified: trunk/OpenMPT/common/typedefs.h
===================================================================
--- trunk/OpenMPT/common/typedefs.h 2013-10-21 19:11:20 UTC (rev 2971)
+++ trunk/OpenMPT/common/typedefs.h 2013-10-21 19:28:38 UTC (rev 2972)
@@ -272,6 +272,8 @@
const uint32 uint32_max = UINT32_MAX;
const uint64 uint64_max = UINT64_MAX;
+
+// 24-bit integer wrapper (for 24-bit PCM)
struct int24
{
uint8 bytes[3];
@@ -301,6 +303,8 @@
#define int24_min (0-0x00800000)
#define int24_max (0+0x007fffff)
+
+// 32-bit wrapper for encoding 32-bit floats
struct uint8_4
{
uint8 x[4];
@@ -313,6 +317,7 @@
};
STATIC_ASSERT(sizeof(uint8_4) == 4);
+
typedef float float32;
STATIC_ASSERT(sizeof(float32) == 4);
@@ -342,27 +347,16 @@
typedef std::uint8_t BYTE;
typedef std::uint16_t WORD;
typedef std::uint32_t DWORD;
-typedef std::uint64_t QWORD;
typedef std::int8_t CHAR;
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 BYTE * LPBYTE;
-typedef WORD * LPWORD;
typedef DWORD * LPDWORD;
-typedef INT * LPINT;
typedef LONG * LPLONG;
-typedef const char * LPCSTR;
-typedef char * LPSTR;
-
// for BOOL
#define TRUE (1)
#define FALSE (0)
Modified: trunk/OpenMPT/mptrack/Autotune.cpp
===================================================================
--- trunk/OpenMPT/mptrack/Autotune.cpp 2013-10-21 19:11:20 UTC (rev 2971)
+++ trunk/OpenMPT/mptrack/Autotune.cpp 2013-10-21 19:28:38 UTC (rev 2972)
@@ -256,8 +256,6 @@
int CAutotuneDlg::pitchReference = 440; // Pitch reference in Hz
int CAutotuneDlg::targetNote = 0; // Target note (C = 0, C# = 1, etc...)
-extern const LPCSTR szNoteNames[12];
-
void CAutotuneDlg::DoDataExchange(CDataExchange* pDX)
//---------------------------------------------------
{
Modified: trunk/OpenMPT/mptrack/MemoryMappedFile.cpp
===================================================================
--- trunk/OpenMPT/mptrack/MemoryMappedFile.cpp 2013-10-21 19:11:20 UTC (rev 2971)
+++ trunk/OpenMPT/mptrack/MemoryMappedFile.cpp 2013-10-21 19:28:38 UTC (rev 2972)
@@ -19,8 +19,8 @@
}
-bool CMappedFile::Open(LPCSTR lpszFileName)
-//-----------------------------------------
+bool CMappedFile::Open(const char * lpszFileName)
+//-----------------------------------------------
{
return m_File.Open(lpszFileName, CFile::modeRead | CFile::typeBinary | CFile::shareDenyWrite) != FALSE;
}
Modified: trunk/OpenMPT/mptrack/MemoryMappedFile.h
===================================================================
--- trunk/OpenMPT/mptrack/MemoryMappedFile.h 2013-10-21 19:11:20 UTC (rev 2971)
+++ trunk/OpenMPT/mptrack/MemoryMappedFile.h 2013-10-21 19:28:38 UTC (rev 2972)
@@ -29,7 +29,7 @@
~CMappedFile();
public:
- bool Open(LPCSTR lpszFileName);
+ bool Open(const char *lpszFileName);
void Close();
size_t GetLength();
const void *Lock();
Modified: trunk/OpenMPT/mptrack/Mod2wave.cpp
===================================================================
--- trunk/OpenMPT/mptrack/Mod2wave.cpp 2013-10-21 19:11:20 UTC (rev 2971)
+++ trunk/OpenMPT/mptrack/Mod2wave.cpp 2013-10-21 19:28:38 UTC (rev 2972)
@@ -26,7 +26,7 @@
#include <fstream>
-extern LPCSTR gszChnCfgNames[3];
+extern const char *gszChnCfgNames[3];
static CSoundFile::samplecount_t ReadInterleaved(CSoundFile &sndFile, void *outputBuffer, CSoundFile::samplecount_t count, SampleFormat sampleFormat, Dither &dither)
//-------------------------------------------------------------------------------------------------------------------------------------------------------------------
@@ -283,7 +283,7 @@
m_CbnSampleFormat.CComboBox::ResetContent();
int sel = 0;
DWORD dwSamplerate = m_CbnSampleRate.GetItemData(m_CbnSampleRate.GetCurSel());
- INT nChannels = m_CbnChannels.GetItemData(m_CbnChannels.GetCurSel());
+ int nChannels = m_CbnChannels.GetItemData(m_CbnChannels.GetCurSel());
if(encTraits->modes & Encoder::ModeQuality)
{
for(int quality = 100; quality >= 0; quality -= 10)
Modified: trunk/OpenMPT/mptrack/Moddoc.cpp
===================================================================
--- trunk/OpenMPT/mptrack/Moddoc.cpp 2013-10-21 19:11:20 UTC (rev 2971)
+++ trunk/OpenMPT/mptrack/Moddoc.cpp 2013-10-21 19:28:38 UTC (rev 2972)
@@ -260,7 +260,7 @@
// Scan Instruments
if (lpMidiLib) for (INSTRUMENTINDEX nIns = 1; nIns <= m_SndFile.m_nInstruments; nIns++) if (m_SndFile.Instruments[nIns])
{
- LPCSTR pszMidiMapName;
+ const char *pszMidiMapName;
ModInstrument *pIns = m_SndFile.Instruments[nIns];
UINT nMidiCode;
BOOL bEmbedded = FALSE;
Modified: trunk/OpenMPT/mptrack/Mpdlgs.cpp
===================================================================
--- trunk/OpenMPT/mptrack/Mpdlgs.cpp 2013-10-21 19:11:20 UTC (rev 2971)
+++ trunk/OpenMPT/mptrack/Mpdlgs.cpp 2013-10-21 19:28:38 UTC (rev 2972)
@@ -50,7 +50,7 @@
};
-LPCSTR gszChnCfgNames[3] =
+const char *gszChnCfgNames[3] =
{
"Mono",
"Stereo",
Modified: trunk/OpenMPT/mptrack/Mptrack.h
===================================================================
--- trunk/OpenMPT/mptrack/Mptrack.h 2013-10-21 19:11:20 UTC (rev 2971)
+++ trunk/OpenMPT/mptrack/Mptrack.h 2013-10-21 19:28:38 UTC (rev 2972)
@@ -320,9 +320,9 @@
const LPCSTR szHexChar = "0123456789ABCDEF";
// Defined in load_mid.cpp
-extern const LPCSTR szMidiProgramNames[128];
-extern const LPCSTR szMidiPercussionNames[61]; // notes 25..85
-extern const LPCSTR szMidiGroupNames[17]; // 16 groups + Percussions
+extern const char *szMidiProgramNames[128];
+extern const char *szMidiPercussionNames[61]; // notes 25..85
+extern const char *szMidiGroupNames[17]; // 16 groups + Percussions
/////////////////////////////////////////////////////////////////////////////
Modified: trunk/OpenMPT/mptrack/View_ins.cpp
===================================================================
--- trunk/OpenMPT/mptrack/View_ins.cpp 2013-10-21 19:11:20 UTC (rev 2971)
+++ trunk/OpenMPT/mptrack/View_ins.cpp 2013-10-21 19:28:38 UTC (rev 2972)
@@ -162,9 +162,9 @@
SIZE sizeTotal, sizePage, sizeLine;
UINT ntickmax = EnvGetTick(EnvGetLastPoint());
- sizeTotal.cx = (INT)((ntickmax + 2) * m_fZoom);
+ sizeTotal.cx = (int)((ntickmax + 2) * m_fZoom);
sizeTotal.cy = 1;
- sizeLine.cx = (INT)m_fZoom;
+ sizeLine.cx = (int)m_fZoom;
sizeLine.cy = 2;
sizePage.cx = sizeLine.cx * 4;
sizePage.cy = sizeLine.cy;
Modified: trunk/OpenMPT/mptrack/mod2midi.cpp
===================================================================
--- trunk/OpenMPT/mptrack/mod2midi.cpp 2013-10-21 19:11:20 UTC (rev 2971)
+++ trunk/OpenMPT/mptrack/mod2midi.cpp 2013-10-21 19:28:38 UTC (rev 2972)
@@ -76,7 +76,7 @@
{
UINT nGrow = 4096;
if (nBytes >= nGrow) nGrow = nBytes * 2;
- PUCHAR p = new UCHAR[nAllocatedMem+nGrow];
+ uint8 *p = new uint8[nAllocatedMem+nGrow];
if (!p) return;
memcpy(p, pTrackData, nTrackSize);
delete[] pTrackData;
@@ -150,8 +150,8 @@
}
-CModToMidi::CModToMidi(LPCSTR pszPathName, CSoundFile *pSndFile, CWnd *pWndParent):CDialog(IDD_MOD2MIDI, pWndParent)
-//------------------------------------------------------------------------------------------------------------------
+CModToMidi::CModToMidi(const char * pszPathName, CSoundFile *pSndFile, CWnd *pWndParent):CDialog(IDD_MOD2MIDI, pWndParent)
+//------------------------------------------------------------------------------------------------------------------------
{
CHAR fext[_MAX_EXT];
Modified: trunk/OpenMPT/mptrack/mod2midi.h
===================================================================
--- trunk/OpenMPT/mptrack/mod2midi.h 2013-10-21 19:11:20 UTC (rev 2971)
+++ trunk/OpenMPT/mptrack/mod2midi.h 2013-10-21 19:28:38 UTC (rev 2972)
@@ -31,7 +31,7 @@
MOD2MIDIINSTR m_InstrMap[MAX_SAMPLES];
public:
- CModToMidi(LPCSTR pszFileName, CSoundFile *pSndFile, CWnd *pWndParent=NULL);
+ CModToMidi(const char *pszFileName, CSoundFile *pSndFile, CWnd *pWndParent=NULL);
~CModToMidi() {}
BOOL DoConvert();
Modified: trunk/OpenMPT/mptrack/mod2wave.h
===================================================================
--- trunk/OpenMPT/mptrack/mod2wave.h 2013-10-21 19:11:20 UTC (rev 2971)
+++ trunk/OpenMPT/mptrack/mod2wave.h 2013-10-21 19:28:38 UTC (rev 2972)
@@ -40,7 +40,7 @@
CWaveConvertSettings m_Settings;
const Encoder::Traits *encTraits;
CSoundFile *m_pSndFile;
- ULONGLONG m_dwFileLimit;
+ uint64 m_dwFileLimit;
DWORD m_dwSongLimit;
bool m_bSelectPlay, m_bHighQuality, m_bGivePlugsIdleTime;
ORDERINDEX m_nMinOrder, m_nMaxOrder, m_nNumOrders;
@@ -93,13 +93,13 @@
public:
CWaveConvertSettings m_Settings;
CSoundFile *m_pSndFile;
- LPCSTR m_lpszFileName;
+ const char *m_lpszFileName;
DWORD m_dwFileLimit, m_dwSongLimit;
UINT m_nMaxPatterns;
bool m_bAbort, m_bGivePlugsIdleTime;
public:
- CDoWaveConvert(CSoundFile *sndfile, LPCSTR fname, CWaveConvertSettings settings, CWnd *parent = NULL)
+ CDoWaveConvert(CSoundFile *sndfile, const char *fname, CWaveConvertSettings settings, CWnd *parent = NULL)
: CDialog(IDD_PROGRESS, parent)
, m_Settings(settings)
{ m_pSndFile = sndfile;
Modified: trunk/OpenMPT/sounddsp/Reverb.cpp
===================================================================
--- trunk/OpenMPT/sounddsp/Reverb.cpp 2013-10-21 19:11:20 UTC (rev 2971)
+++ trunk/OpenMPT/sounddsp/Reverb.cpp 2013-10-21 19:28:38 UTC (rev 2972)
@@ -89,7 +89,7 @@
typedef struct _SNDMIX_RVBPRESET
{
SNDMIX_REVERB_PROPERTIES Preset;
- LPCSTR lpszName;
+ const char *lpszName;
} SNDMIX_RVBPRESET, *PSNDMIX_RVBPRESET;
@@ -126,7 +126,7 @@
{{ SNDMIX_REVERB_PRESET_UNDERWATER }, "Underwater"},
};
-LPCSTR GetReverbPresetName(UINT nPreset)
+const char *GetReverbPresetName(UINT nPreset)
{
return (nPreset < NUM_REVERBTYPES) ? gRvbPresets[nPreset].lpszName : NULL;
}
Modified: trunk/OpenMPT/soundlib/Dlsbank.cpp
===================================================================
--- trunk/OpenMPT/soundlib/Dlsbank.cpp 2013-10-21 19:11:20 UTC (rev 2971)
+++ trunk/OpenMPT/soundlib/Dlsbank.cpp 2013-10-21 19:28:38 UTC (rev 2972)
@@ -500,8 +500,8 @@
}
-BOOL CDLSBank::IsDLSBank(LPCSTR lpszFileName)
-//-------------------------------------------
+BOOL CDLSBank::IsDLSBank(const char *lpszFileName)
+//------------------------------------------------
{
RIFFCHUNKID riff;
FILE *f;
@@ -783,7 +783,7 @@
case IFFID_INAM:
{
UINT len = (pchunk->len < 32) ? pchunk->len : 31;
- if (len) memcpy(pDlsIns->szName, ((LPCSTR)pchunk)+8, len);
+ if (len) memcpy(pDlsIns->szName, ((const char *)pchunk)+8, len);
pDlsIns->szName[31] = 0;
//Log("%s\n", (DWORD)pDlsIns->szName);
}
@@ -1138,8 +1138,8 @@
///////////////////////////////////////////////////////////////
// Open: opens a DLS bank
-BOOL CDLSBank::Open(LPCSTR lpszFileName)
-//--------------------------------------
+BOOL CDLSBank::Open(const char *lpszFileName)
+//-------------------------------------------
{
SF2LOADERINFO sf2info;
const BYTE *lpMemFile; // Pointer to memory-mapped file
@@ -1304,7 +1304,7 @@
if ((plist->listid == IFFID_INFO) && (psublist->len))
{
UINT len = (psublist->len < 255) ? psublist->len : 255;
- LPCSTR pszInfo = (LPCSTR)(lpMemFile+dwPos+8);
+ const char *pszInfo = (const char *)(lpMemFile+dwPos+8);
switch(psublist->id)
{
case IFFID_INAM:
Modified: trunk/OpenMPT/soundlib/Dlsbank.h
===================================================================
--- trunk/OpenMPT/soundlib/Dlsbank.h 2013-10-21 19:11:20 UTC (rev 2971)
+++ trunk/OpenMPT/soundlib/Dlsbank.h 2013-10-21 19:28:38 UTC (rev 2972)
@@ -129,13 +129,13 @@
CDLSBank();
virtual ~CDLSBank();
void Destroy();
- static BOOL IsDLSBank(LPCSTR lpszFileName);
+ static BOOL IsDLSBank(const char *lpszFileName);
static DWORD MakeMelodicCode(UINT bank, UINT instr) { return ((bank << 16) | (instr));}
static DWORD MakeDrumCode(UINT rgn, UINT instr) { return (0x80000000 | (rgn << 16) | (instr));}
public:
- BOOL Open(LPCSTR lpszFileName);
- LPCSTR GetFileName() const { return m_szFileName; }
+ BOOL Open(const char *lpszFileName);
+ const char *GetFileName() const { return m_szFileName; }
UINT GetBankType() const { return m_nType; }
UINT GetBankInfo(SOUNDBANKINFO *pBankInfo=NULL) const { if (pBankInfo) *pBankInfo = m_BankInfo; return m_nType; }
Modified: trunk/OpenMPT/soundlib/Fastmix.cpp
===================================================================
--- trunk/OpenMPT/soundlib/Fastmix.cpp 2013-10-21 19:11:20 UTC (rev 2971)
+++ trunk/OpenMPT/soundlib/Fastmix.cpp 2013-10-21 19:28:38 UTC (rev 2972)
@@ -1393,7 +1393,7 @@
if ((nPos < 0) || (nInc < 0)) return 0;
}
if ((nPos < 0) || (nPos >= (LONG)pChn->nLength)) return 0;
- LONG nPosLo = (USHORT)pChn->nPosLo, nSmpCount = nSamples;
+ LONG nPosLo = (uint16)pChn->nPosLo, nSmpCount = nSamples;
if (nInc < 0)
{
LONG nInv = -nInc;
@@ -1405,7 +1405,7 @@
LONG nPosDest = nPos - nDeltaHi + ((nPosLo - nDeltaLo) >> 16);
if (nPosDest < nLoopStart)
{
- nSmpCount = (ULONG)(((((LONGLONG)nPos - nLoopStart) << 16) + nPosLo - 1) / nInv) + 1;
+ nSmpCount = (ULONG)(((((int64)nPos - nLoopStart) << 16) + nPosLo - 1) / nInv) + 1;
}
} else
{
@@ -1417,7 +1417,7 @@
LONG nPosDest = nPos + nDeltaHi + ((nPosLo + nDeltaLo)>>16);
if (nPosDest >= (LONG)pChn->nLength)
{
- nSmpCount = (ULONG)(((((LONGLONG)pChn->nLength - nPos) << 16) - nPosLo - 1) / nInc) + 1;
+ nSmpCount = (ULONG)(((((int64)pChn->nLength - nPos) << 16) - nPosLo - 1) / nInc) + 1;
}
}
#ifdef _DEBUG
Modified: trunk/OpenMPT/soundlib/Load_it.cpp
===================================================================
--- trunk/OpenMPT/soundlib/Load_it.cpp 2013-10-21 19:11:20 UTC (rev 2971)
+++ trunk/OpenMPT/soundlib/Load_it.cpp 2013-10-21 19:28:38 UTC (rev 2972)
@@ -1110,8 +1110,8 @@
#include "../mptrack/Mptrack.h" // For config filename
#endif // MODPLUG_TRACKER
-bool CSoundFile::SaveIT(LPCSTR lpszFileName, bool compatibilityExport)
-//--------------------------------------------------------------------
+bool CSoundFile::SaveIT(const char *lpszFileName, bool compatibilityExport)
+//-------------------------------------------------------------------------
{
const CModSpecifications &specs = (GetType() == MOD_TYPE_MPT ? ModSpecs::mptm : (compatibilityExport ? ModSpecs::it : ModSpecs::itEx));
Modified: trunk/OpenMPT/soundlib/Load_itp.cpp
===================================================================
--- trunk/OpenMPT/soundlib/Load_itp.cpp 2013-10-21 19:11:20 UTC (rev 2971)
+++ trunk/OpenMPT/soundlib/Load_itp.cpp 2013-10-21 19:28:38 UTC (rev 2972)
@@ -279,8 +279,8 @@
#ifndef MODPLUG_NO_FILESAVE
-bool CSoundFile::SaveITProject(LPCSTR lpszFileName)
-//-------------------------------------------------
+bool CSoundFile::SaveITProject(const char *lpszFileName)
+//------------------------------------------------------
{
#ifndef MODPLUG_TRACKER
MPT_UNREFERENCED_PARAMETER(lpszFileName);
Modified: trunk/OpenMPT/soundlib/Load_med.cpp
===================================================================
--- trunk/OpenMPT/soundlib/Load_med.cpp 2013-10-21 19:11:20 UTC (rev 2971)
+++ trunk/OpenMPT/soundlib/Load_med.cpp 2013-10-21 19:28:38 UTC (rev 2972)
@@ -759,7 +759,7 @@
if ((iinfoptr) && (ientrysz < 256) && (ientries*ientrysz < dwMemLength) && (iinfoptr < dwMemLength - ientries*ientrysz))
{
- LPCSTR psznames = (LPCSTR)(lpStream + iinfoptr);
+ const char *psznames = (const char *)(lpStream + iinfoptr);
for (UINT i=0; i<ientries; i++) if (i < m_nSamples)
{
mpt::String::Read<mpt::String::maybeNullTerminated>(m_szNames[i + 1], reinterpret_cast<const char *>(psznames + i * ientrysz), ientrysz);
@@ -811,7 +811,7 @@
#endif
if(dwPos + len + 6 > dwMemLength) len = 0;
UINT stype = BigEndianW(psdh->type);
- LPSTR psdata = (LPSTR)(lpStream + dwPos + 6);
+ char *psdata = (char *)(lpStream + dwPos + 6);
SampleIO sampleIO(
SampleIO::_8bit,
Modified: trunk/OpenMPT/soundlib/Load_mid.cpp
===================================================================
--- trunk/OpenMPT/soundlib/Load_mid.cpp 2013-10-21 19:11:20 UTC (rev 2971)
+++ trunk/OpenMPT/soundlib/Load_mid.cpp 2013-10-21 19:28:38 UTC (rev 2972)
@@ -98,7 +98,7 @@
} MIDITRACK;
-extern const LPCSTR szMidiGroupNames[17] =
+extern const char *szMidiGroupNames[17] =
{
"Piano",
"Chromatic Percussion",
@@ -120,7 +120,7 @@
};
-extern const LPCSTR szMidiProgramNames[128] =
+extern const char *szMidiProgramNames[128] =
{
// 1-8: Piano
"Acoustic Grand Piano",
@@ -270,7 +270,7 @@
// Notes 25-85
-extern const LPCSTR szMidiPercussionNames[61] =
+extern const char *szMidiPercussionNames[61] =
{
"Seq Click",
"Brush Tap",
Modified: trunk/OpenMPT/soundlib/Load_mod.cpp
===================================================================
--- trunk/OpenMPT/soundlib/Load_mod.cpp 2013-10-21 19:11:20 UTC (rev 2971)
+++ trunk/OpenMPT/soundlib/Load_mod.cpp 2013-10-21 19:28:38 UTC (rev 2972)
@@ -1090,8 +1090,8 @@
#include "../mptrack/moddoc.h"
#endif // MODPLUG_TRACKER
-bool CSoundFile::SaveMod(LPCSTR lpszFileName) const
-//-------------------------------------------------
+bool CSoundFile::SaveMod(const char *lpszFileName) const
+//------------------------------------------------------
{
FILE *f;
Modified: trunk/OpenMPT/soundlib/Load_s3m.cpp
===================================================================
--- trunk/OpenMPT/soundlib/Load_s3m.cpp 2013-10-21 19:11:20 UTC (rev 2971)
+++ trunk/OpenMPT/soundlib/Load_s3m.cpp 2013-10-21 19:28:38 UTC (rev 2972)
@@ -539,8 +539,8 @@
#ifndef MODPLUG_NO_FILESAVE
-bool CSoundFile::SaveS3M(LPCSTR lpszFileName) const
-//-------------------------------------------------
+bool CSoundFile::SaveS3M(const char *lpszFileName) const
+//------------------------------------------------------
{
static const uint8 filler[16] =
{
Modified: trunk/OpenMPT/soundlib/Load_xm.cpp
===================================================================
--- trunk/OpenMPT/soundlib/Load_xm.cpp 2013-10-21 19:11:20 UTC (rev 2971)
+++ trunk/OpenMPT/soundlib/Load_xm.cpp 2013-10-21 19:28:38 UTC (rev 2972)
@@ -651,8 +651,8 @@
#define str_pattern (GetStrI18N((MPT_TEXT("pattern"))))
-bool CSoundFile::SaveXM(LPCSTR lpszFileName, bool compatibilityExport)
-//--------------------------------------------------------------------
+bool CSoundFile::SaveXM(const char *lpszFileName, bool compatibilityExport)
+//-------------------------------------------------------------------------
{
FILE *f;
if(lpszFileName == nullptr || (f = fopen(lpszFileName, "wb")) == nullptr)
Modified: trunk/OpenMPT/soundlib/Mmcmp.cpp
===================================================================
--- trunk/OpenMPT/soundlib/Mmcmp.cpp 2013-10-21 19:11:20 UTC (rev 2971)
+++ trunk/OpenMPT/soundlib/Mmcmp.cpp 2013-10-21 19:28:38 UTC (rev 2972)
@@ -162,11 +162,11 @@
if (pblk->flags & MMCMP_16BIT)
{
MMCMPBITBUFFER bb;
- LPWORD pDest = (LPWORD)(pBuffer + psubblk->unpk_pos);
- DWORD dwSize = psubblk->unpk_size >> 1;
- DWORD dwPos = 0;
- UINT numbits = pblk->num_bits;
- UINT subblk = 0, oldval = 0;
+ uint16 *pDest = (uint16 *)(pBuffer + psubblk->unpk_pos);
+ uint32 dwSize = psubblk->unpk_size >> 1;
+ uint32 dwPos = 0;
+ uint32 numbits = pblk->num_bits;
+ uint32 subblk = 0, oldval = 0;
#ifdef MMCMP_LOG
Log(" 16-bit block: pos=%d size=%d ", psubblk->unpk_pos, psubblk->unpk_size);
@@ -180,13 +180,13 @@
bb.pEnd = lpMemFile+dwMemPos+pblk->pk_size;
while (subblk < pblk->sub_blk)
{
- UINT newval = 0x10000;
- DWORD d = bb.GetBits(numbits+1);
+ uint32 newval = 0x10000;
+ uint32 d = bb.GetBits(numbits+1);
if (d >= MMCMP16BitCommands[numbits])
{
- UINT nFetch = MMCMP16BitFetch[numbits];
- UINT newbits = bb.GetBits(nFetch) + ((d - MMCMP16BitCommands[numbits]) << nFetch);
+ uint32 nFetch = MMCMP16BitFetch[numbits];
+ uint32 newbits = bb.GetBits(nFetch) + ((d - MMCMP16BitCommands[numbits]) << nFetch);
if (newbits != numbits)
{
numbits = newbits & 0x0F;
@@ -207,7 +207,7 @@
}
if (newval < 0x10000)
{
- newval = (newval & 1) ? (UINT)(-(LONG)((newval+1) >> 1)) : (UINT)(newval >> 1);
+ newval = (newval & 1) ? (uint32)(-(int32)((newval+1) >> 1)) : (uint32)(newval >> 1);
if (pblk->flags & MMCMP_DELTA)
{
newval += oldval;
@@ -217,14 +217,14 @@
{
newval ^= 0x8000;
}
- pDest[dwPos++] = (WORD)newval;
+ pDest[dwPos++] = (uint16)newval;
}
if (dwPos >= dwSize)
{
subblk++;
dwPos = 0;
dwSize = psubblk[subblk].unpk_size >> 1;
- pDest = (LPWORD)(pBuffer + psubblk[subblk].unpk_pos);
+ pDest = (uint16 *)(pBuffer + psubblk[subblk].unpk_pos);
}
}
} else
@@ -232,10 +232,10 @@
{
MMCMPBITBUFFER bb;
LPBYTE pDest = pBuffer + psubblk->unpk_pos;
- DWORD dwSize = psubblk->unpk_size;
- DWORD dwPos = 0;
- UINT numbits = pblk->num_bits;
- UINT subblk = 0, oldval = 0;
+ uint32 dwSize = psubblk->unpk_size;
+ uint32 dwPos = 0;
+ uint32 numbits = pblk->num_bits;
+ uint32 subblk = 0, oldval = 0;
LPCBYTE ptable = lpMemFile+dwMemPos;
bb.bitcount = 0;
@@ -244,13 +244,13 @@
bb.pEnd = lpMemFile+dwMemPos+pblk->pk_size;
while (subblk < pblk->sub_blk)
{
- UINT newval = 0x100;
- DWORD d = bb.GetBits(numbits+1);
+ uint32 newval = 0x100;
+ uint32 d = bb.GetBits(numbits+1);
if (d >= MMCMP8BitCommands[numbits])
{
- UINT nFetch = MMCMP8BitFetch[numbits];
- UINT newbits = bb.GetBits(nFetch) + ((d - MMCMP8BitCommands[numbits]) << nFetch);
+ uint32 nFetch = MMCMP8BitFetch[numbits];
+ uint32 newbits = bb.GetBits(nFetch) + ((d - MMCMP8BitCommands[numbits]) << nFetch);
if (newbits != numbits)
{
numbits = newbits & 0x07;
@@ -277,7 +277,7 @@
n += oldval;
oldval = n;
}
- pDest[dwPos++] = (BYTE)n;
+ pDest[dwPos++] = (uint8)n;
}
if (dwPos >= dwSize)
{
Modified: trunk/OpenMPT/soundlib/SampleFormats.cpp
===================================================================
--- trunk/OpenMPT/soundlib/SampleFormats.cpp 2013-10-21 19:11:20 UTC (rev 2971)
+++ trunk/OpenMPT/soundlib/SampleFormats.cpp 2013-10-21 19:28:38 UTC (rev 2972)
@@ -461,8 +461,8 @@
#ifndef MODPLUG_NO_FILESAVE
-bool CSoundFile::SaveWAVSample(SAMPLEINDEX nSample, const LPCSTR lpszFileName) const
-//----------------------------------------------------------------------------------
+bool CSoundFile::SaveWAVSample(SAMPLEINDEX nSample, const char *lpszFileName) const
+//---------------------------------------------------------------------------------
{
WAVWriter file(lpszFileName);
@@ -502,8 +502,8 @@
///////////////////////////////////////////////////////////////
// Save RAW
-bool CSoundFile::SaveRAWSample(SAMPLEINDEX nSample, const LPCSTR lpszFileName) const
-//----------------------------------------------------------------------------------
+bool CSoundFile::SaveRAWSample(SAMPLEINDEX nSample, const char *lpszFileName) const
+//---------------------------------------------------------------------------------
{
FILE *f;
if ((f = fopen(lpszFileName, "wb")) == NULL) return false;
@@ -968,8 +968,8 @@
#ifndef MODPLUG_NO_FILESAVE
-bool CSoundFile::SaveXIInstrument(INSTRUMENTINDEX nInstr, const LPCSTR lpszFileName) const
-//----------------------------------------------------------------------------------------
+bool CSoundFile::SaveXIInstrument(INSTRUMENTINDEX nInstr, const char *lpszFileName) const
+//---------------------------------------------------------------------------------------
{
ModInstrument *pIns = Instruments[nInstr];
if(pIns == nullptr || lpszFileName == nullptr)
@@ -1554,8 +1554,8 @@
#ifndef MODPLUG_NO_FILESAVE
-bool CSoundFile::SaveITIInstrument(INSTRUMENTINDEX nInstr, const LPCSTR lpszFileName, bool compress) const
-//--------------------------------------------------------------------------------------------------------
+bool CSoundFile::SaveITIInstrument(INSTRUMENTINDEX nInstr, const char *lpszFileName, bool compress) const
+//-------------------------------------------------------------------------------------------------------
{
ITInstrumentEx iti;
ModInstrument *pIns = Instruments[nInstr];
@@ -2063,8 +2063,8 @@
#ifndef MODPLUG_NO_FILESAVE
-bool CSoundFile::SaveFLACSample(SAMPLEINDEX nSample, const LPCSTR lpszFileName) const
-//-----------------------------------------------------------------------------------
+bool CSoundFile::SaveFLACSample(SAMPLEINDEX nSample, const char *lpszFileName) const
+//----------------------------------------------------------------------------------
{
#ifndef NO_FLAC
FLAC__StreamEncoder *encoder = FLAC__stream_encoder_new();
Modified: trunk/OpenMPT/soundlib/Sndfile.cpp
===================================================================
--- trunk/OpenMPT/soundlib/Sndfile.cpp 2013-10-21 19:11:20 UTC (rev 2971)
+++ trunk/OpenMPT/soundlib/Sndfile.cpp 2013-10-21 19:28:38 UTC (rev 2972)
@@ -976,7 +976,7 @@
try
{
- LPSTR p = (LPSTR)new char[allocSize];
+ char *p = new char[allocSize];
memset(p, 0, allocSize);
return (p + 16);
} catch(MPTMemoryException)
Modified: trunk/OpenMPT/soundlib/Sndfile.h
===================================================================
--- trunk/OpenMPT/soundlib/Sndfile.h 2013-10-21 19:11:20 UTC (rev 2971)
+++ trunk/OpenMPT/soundlib/Sndfile.h 2013-10-21 19:28:38 UTC (rev 2972)
@@ -58,7 +58,7 @@
#define NUM_REVERBTYPES 29
-LPCSTR GetReverbPresetName(UINT nPreset);
+const char *GetReverbPresetName(UINT nPreset);
#endif
@@ -565,11 +565,11 @@
// Save Functions
#ifndef MODPLUG_NO_FILESAVE
- bool SaveXM(LPCSTR lpszFileName, bool compatibilityExport = false);
- bool SaveS3M(LPCSTR lpszFileName) const;
- bool SaveMod(LPCSTR lpszFileName) const;
- bool SaveIT(LPCSTR lpszFileName, bool compatibilityExport = false);
- bool SaveITProject(LPCSTR lpszFileName); // -> CODE#0023 -> DESC="IT project files (.itp)" -! NEW_FEATURE#0023
+ bool SaveXM(const char *lpszFileName, bool compatibilityExport = false);
+ bool SaveS3M(const char *lpszFileName) const;
+ bool SaveMod(const char *lpszFileName) const;
+ bool SaveIT(const char *lpszFileName, bool compatibilityExport = false);
+ bool SaveITProject(const char *lpszFileName); // -> CODE#0023 -> DESC="IT project files (.itp)" -! NEW_FEATURE#0023
UINT SaveMixPlugins(FILE *f=NULL, BOOL bUpdate=TRUE);
void WriteInstrumentPropertyForAllInstruments(uint32 code, int16 size, FILE* f, UINT nInstruments) const;
void SaveExtendedInstrumentProperties(UINT nInstruments, FILE* f) const;
@@ -749,9 +749,9 @@
bool ReadFLACSample(SAMPLEINDEX sample, FileReader &file);
bool ReadMP3Sample(SAMPLEINDEX sample, FileReader &file);
#ifndef MODPLUG_NO_FILESAVE
- bool SaveWAVSample(SAMPLEINDEX nSample, const LPCSTR lpszFileName) const;
- bool SaveRAWSample(SAMPLEINDEX nSample, const LPCSTR lpszFileName) const;
- bool SaveFLACSample(SAMPLEINDEX nSample, const LPCSTR lpszFileName) const;
+ bool SaveWAVSample(SAMPLEINDEX nSample, const char *lpszFileName) const;
+ bool SaveRAWSample(SAMPLEINDEX nSample, const char *lpszFileName) const;
+ bool SaveFLACSample(SAMPLEINDEX nSample, const char *lpszFileName) const;
#endif
// Instrument file I/O
@@ -761,8 +761,8 @@
bool ReadPATInstrument(INSTRUMENTINDEX nInstr, const LPBYTE lpMemFile, DWORD dwFileLength);
bool ReadSampleAsInstrument(INSTRUMENTINDEX nInstr, FileReader &file, bool mayNormalize=false);
#ifndef MODPLUG_NO_FILESAVE
- bool SaveXIInstrument(INSTRUMENTINDEX nInstr, const LPCSTR lpszFileName) const;
- bool SaveITIInstrument(INSTRUMENTINDEX nInstr, const LPCSTR lpszFileName, bool compress) const;
+ bool SaveXIInstrument(INSTRUMENTINDEX nInstr, const char *lpszFileName) const;
+ bool SaveITIInstrument(INSTRUMENTINDEX nInstr, const char *lpszFileName, bool compress) const;
#endif
// I/O from another sound file
@@ -812,17 +812,17 @@
#endif
-extern const LPCSTR szNoteNames[12];
-extern const LPCSTR szDefaultNoteNames[NOTE_MAX];
+extern const char *szNoteNames[12];
+extern const char *szDefaultNoteNames[NOTE_MAX];
inline IMixPlugin* CSoundFile::GetInstrumentPlugin(INSTRUMENTINDEX instr)
//-----------------------------------------------------------------------
{
if(instr > 0 && instr < MAX_INSTRUMENTS && Instruments[instr] && Instruments[instr]->nMixPlug && Instruments[instr]->nMixPlug <= MAX_MIXPLUGINS)
- return m_MixPlugins[Instruments[instr]->nMixPlug-1].pMixPlugin;
+ return m_MixPlugins[Instruments[instr]->nMixPlug - 1].pMixPlugin;
else
- return NULL;
+ return nullptr;
}
Modified: trunk/OpenMPT/soundlib/Tables.cpp
===================================================================
--- trunk/OpenMPT/soundlib/Tables.cpp 2013-10-21 19:11:20 UTC (rev 2971)
+++ trunk/OpenMPT/soundlib/Tables.cpp 2013-10-21 19:28:38 UTC (rev 2972)
@@ -23,13 +23,13 @@
/////////////////////////////////////////////////////////////////////////////
// Common Tables
-const LPCSTR szNoteNames[12] =
+const char *szNoteNames[12] =
{
"C-", "C#", "D-", "D#", "E-", "F-",
"F#", "G-", "G#", "A-", "A#", "B-"
};
-const LPCSTR szDefaultNoteNames[NOTE_MAX] =
+const char *szDefaultNoteNames[NOTE_MAX] =
{
"C-0", "C#0", "D-0", "D#0", "E-0", "F-0", "F#0", "G-0", "G#0", "A-0", "A#0", "B-0",
"C-1", "C#1", "D-1", "D#1", "E-1", "F-1", "F#1", "G-1", "G#1", "A-1", "A#1", "B-1",
Modified: trunk/OpenMPT/soundlib/tuningCollection.cpp
===================================================================
--- trunk/OpenMPT/soundlib/tuningCollection.cpp 2013-10-21 19:11:20 UTC (rev 2971)
+++ trunk/OpenMPT/soundlib/tuningCollection.cpp 2013-10-21 19:28:38 UTC (rev 2972)
@@ -46,7 +46,7 @@
CTuningCollection::CTuningCollection(const std::string& name) : m_Name(name), m_EditMask(EM_ALLOWALL)
-//------------------------------------
+//---------------------------------------------------------------------------------------------------
{
if(m_Name.size() > GetNameLengthMax()) m_Name.resize(GetNameLengthMax());
}
@@ -69,7 +69,7 @@
}
CTuning* CTuningCollection::FindTuning(const std::string& name) const
-//------------------------------------------------------
+//-------------------------------------------------------------------
{
for(size_t i = 0; i<m_Tunings.size(); i++)
{
@@ -87,20 +87,20 @@
CTuning* CTuningCollection::GetTuning(const std::string& name)
-//----------------------------------------------
+//------------------------------------------------------------
{
return FindTuning(name);
}
const CTuning* CTuningCollection::GetTuning(const std::string& name) const
-//-------------------------------------------------------------------
+//------------------------------------------------------------------------
{
return FindTuning(name);
}
CTuningCollection::SERIALIZATION_RETURN_TYPE CTuningCollection::Serialize(std::ostream& oStrm) const
-//--------------------------------------------------------------
+//--------------------------------------------------------------------------------------------------
{
srlztn::Ssb ssb(oStrm);
ssb.BeginWrite("TC", s_SerializationVersion);
@@ -120,7 +120,7 @@
CTuningCollection::SERIALIZATION_RETURN_TYPE CTuningCollection::Serialize() const
-//-------------------------------------------------------------------------------------
+//-------------------------------------------------------------------------------
{
if(m_SavefilePath.length() < 1)
return SERIALIZATION_FAILURE;
@@ -135,7 +135,7 @@
}
CTuningCollection::SERIALIZATION_RETURN_TYPE CTuningCollection::Deserialize()
-//-------------------------------------------------------------------------------------
+//---------------------------------------------------------------------------
{
if(m_SavefilePath.length() < 1)
return SERIALIZATION_FAILURE;
@@ -151,7 +151,7 @@
CTuningCollection::SERIALIZATION_RETURN_TYPE CTuningCollection::Deserialize(std::istream& iStrm)
-//---------------------------------------------------------
+//----------------------------------------------------------------------------------------------
{
std::istream::pos_type startpos = iStrm.tellg();
bool oldLoadingSuccess = false;
@@ -192,7 +192,7 @@
//Returns false if stream content was recognised to be right kind of file(by beginmarker),
//else true, and sets bool parameter to true if loading was successful
bool CTuningCollection::DeserializeOLD(std::istream& inStrm, bool& loadingSuccessful)
-//------------------------------------------------------------------------------
+//-----------------------------------------------------------------------------------
{
//s_SerializationBeginMarker = 0x54435348; //ascii of TCSH
//s_SerializationEndMarker = 0x54435346; //ascii of TCSF(TuningCollectionSerialisationFooter) in hex.
@@ -254,7 +254,7 @@
bool CTuningCollection::Remove(const CTuning* pT)
-//--------------------------------------------
+//-----------------------------------------------
{
TITER iter = find(m_Tunings.begin(), m_Tunings.end(), pT);
if(iter != m_Tunings.end())
@@ -264,7 +264,7 @@
}
bool CTuningCollection::Remove(TITER removable, bool moveToTrashBin)
-//---------------------------------------------
+//------------------------------------------------------------------
{
//Behavior:
//By default, moves tuning to carbage bin(m_DeletedTunings) so that
@@ -308,7 +308,7 @@
bool CTuningCollection::AddTuning(std::istream& inStrm, const bool ignoreEditmask)
-//---------------------------------------------------------------------------
+//--------------------------------------------------------------------------------
{
if((!ignoreEditmask && (m_EditMask & EM_ADD) == 0) || m_Tunings.size() >= s_nMaxTuningCount)
return true;
@@ -352,7 +352,7 @@
}
std::string CTuningCollection::GetEditMaskString() const
-//-------------------------------------------------
+//------------------------------------------------------
{
std::bitset<16> mask(m_EditMask);
return mask.to_string<char, std::char_traits<char>, std::allocator<char> >();
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <sag...@us...> - 2013-10-23 16:18:15
|
Revision: 2986
http://sourceforge.net/p/modplug/code/2986
Author: saga-games
Date: 2013-10-23 16:18:07 +0000 (Wed, 23 Oct 2013)
Log Message:
-----------
[New] Export: Added option to clean output buffers of plugins before export (renders up to 20 seconds of silence per plugin)
[Mod] OpenMPT: Version is now 1.22.05.08
Modified Paths:
--------------
trunk/OpenMPT/common/versionNumber.h
trunk/OpenMPT/mptrack/Mod2wave.cpp
trunk/OpenMPT/mptrack/Vstplug.cpp
trunk/OpenMPT/mptrack/Vstplug.h
trunk/OpenMPT/mptrack/mod2wave.h
trunk/OpenMPT/mptrack/mptrack.rc
trunk/OpenMPT/mptrack/resource.h
trunk/OpenMPT/soundlib/plugins/PlugInterface.h
trunk/OpenMPT/soundlib/plugins/PluginMixBuffer.h
Modified: trunk/OpenMPT/common/versionNumber.h
===================================================================
--- trunk/OpenMPT/common/versionNumber.h 2013-10-23 12:07:42 UTC (rev 2985)
+++ trunk/OpenMPT/common/versionNumber.h 2013-10-23 16:18:07 UTC (rev 2986)
@@ -17,7 +17,7 @@
#define VER_MAJORMAJOR 1
#define VER_MAJOR 22
#define VER_MINOR 05
-#define VER_MINORMINOR 07
+#define VER_MINORMINOR 08
//Version string. For example "1.17.02.28"
#define MPT_VERSION_STR VER_STRINGIZE(VER_MAJORMAJOR) "." VER_STRINGIZE(VER_MAJOR) "." VER_STRINGIZE(VER_MINOR) "." VER_STRINGIZE(VER_MINORMINOR)
Modified: trunk/OpenMPT/mptrack/Mod2wave.cpp
===================================================================
--- trunk/OpenMPT/mptrack/Mod2wave.cpp 2013-10-23 12:07:42 UTC (rev 2985)
+++ trunk/OpenMPT/mptrack/Mod2wave.cpp 2013-10-23 16:18:07 UTC (rev 2986)
@@ -175,6 +175,18 @@
FillInfo();
+ GetDlgItem(IDC_GIVEPLUGSIDLETIME)->EnableWindow(FALSE);
+ GetDlgItem(IDC_RENDERSILENCE)->EnableWindow(FALSE);
+ for(PLUGINDEX i = 0; i < MAX_MIXPLUGINS; i++)
+ {
+ if(m_pSndFile->m_MixPlugins[i].pMixPlugin != nullptr)
+ {
+ GetDlgItem(IDC_GIVEPLUGSIDLETIME)->EnableWindow(TRUE);
+ GetDlgItem(IDC_RENDERSILENCE)->EnableWindow(TRUE);
+ break;
+ }
+ }
+
UpdateDialog();
return TRUE;
}
@@ -480,6 +492,7 @@
loopCount = static_cast<uint16>(GetDlgItemInt(IDC_EDIT5, NULL, FALSE));
if (m_nMaxOrder < m_nMinOrder) m_bSelectPlay = false;
m_Settings.Normalize = IsDlgButtonChecked(IDC_CHECK5) != BST_UNCHECKED;
+ m_Settings.SilencePlugBuffers = IsDlgButtonChecked(IDC_RENDERSILENCE) != BST_UNCHECKED;
m_bGivePlugsIdleTime = IsDlgButtonChecked(IDC_GIVEPLUGSIDLETIME) != BST_UNCHECKED;
if (m_bGivePlugsIdleTime)
{
@@ -604,11 +617,12 @@
//--------------------------------------------------------------------------------------------------------------------------
: EncoderFactories(encFactories)
, EncoderIndex(defaultEncoder)
- , Normalize(false)
, SampleRate(44100)
, Channels(2)
, FinalSampleFormat(SampleFormatInt16)
, EncoderSettings(true, Encoder::ModeCBR, 256, 0.8f, -1)
+ , Normalize(false)
+ , SilencePlugBuffers(false)
{
SelectEncoder(EncoderIndex);
}
@@ -672,6 +686,26 @@
ASSERT(m_Settings.GetEncoderFactory() && m_Settings.GetEncoderFactory()->IsAvailable());
IAudioStreamEncoder *fileEnc = m_Settings.GetEncoderFactory()->ConstructStreamEncoder(fileStream);
+ // Silence mix buffer of plugins, for plugins that don't clear their reverb buffers and similar stuff when they are reset
+ if(m_Settings.SilencePlugBuffers)
+ {
+ for(PLUGINDEX i = 0; i < MAX_MIXPLUGINS; i++)
+ {
+ if(m_pSndFile->m_MixPlugins[i].pMixPlugin != nullptr)
+ {
+ // Render up to 20 seconds per plugin
+ for(int j = 0; j < 20; j++)
+ {
+ const float maxVal = m_pSndFile->m_MixPlugins[i].pMixPlugin->RenderSilence(m_Settings.SampleRate);
+ if(maxVal <= FLT_EPSILON)
+ {
+ break;
+ }
+ }
+ }
+ }
+ }
+
MixerSettings oldmixersettings = m_pSndFile->m_MixerSettings;
MixerSettings mixersettings = TrackerSettings::Instance().m_MixerSettings;
mixersettings.m_nMaxMixChannels = MAX_CHANNELS; // always use max mixing channels when rendering
@@ -715,7 +749,7 @@
uint64 l = static_cast<uint64>(m_pSndFile->GetSongTime() + 0.5) * m_Settings.SampleRate * std::max<uint64>(1, 1 + m_pSndFile->GetRepeatCount());
if (m_nMaxPatterns > 0)
{
- DWORD dwOrds = m_pSndFile->Order.GetLengthFirstEmpty();
+ ORDERINDEX dwOrds = m_pSndFile->Order.GetLengthFirstEmpty();
if ((m_nMaxPatterns < dwOrds) && (dwOrds > 0)) l = (l*m_nMaxPatterns) / dwOrds;
}
Modified: trunk/OpenMPT/mptrack/Vstplug.cpp
===================================================================
--- trunk/OpenMPT/mptrack/Vstplug.cpp 2013-10-23 12:07:42 UTC (rev 2985)
+++ trunk/OpenMPT/mptrack/Vstplug.cpp 2013-10-23 16:18:07 UTC (rev 2986)
@@ -2049,6 +2049,46 @@
}
+// Render some silence and return maximum level returned by the plugin.
+float CVstPlugin::RenderSilence(size_t numSamples)
+//------------------------------------------------
+{
+ // The JUCE framework doesn't like processing while being suspended.
+ const bool wasSuspended = !IsResumed();
+ if(wasSuspended)
+ {
+ Resume();
+ }
+
+ float out[2][MIXBUFFERSIZE]; // scratch buffers
+ float maxVal = 0.0f;
+
+ while(numSamples > 0)
+ {
+ size_t renderSamples = numSamples;
+ LimitMax(renderSamples, CountOf(out[0]));
+ MemsetZero(out);
+
+ mixBuffer.ClearInputBuffers(renderSamples);
+ Process(out[0], out[1], renderSamples);
+ for(size_t i = 0; i < renderSamples; i++)
+ {
+ maxVal = std::max(maxVal, fabs(out[0][i]));
+ maxVal = std::max(maxVal, fabs(out[1][i]));
+ }
+
+ numSamples -= renderSamples;
+ }
+
+ if(wasSuspended)
+ {
+ Suspend();
+ }
+
+ return maxVal;
+}
+
+
void CVstPlugin::Process(float *pOutL, float *pOutR, size_t nSamples)
//-------------------------------------------------------------------
{
@@ -2301,7 +2341,7 @@
void CVstPlugin::HardAllNotesOff()
//--------------------------------
{
- float in[2][SCRATCH_BUFFER_SIZE], out[2][SCRATCH_BUFFER_SIZE]; // scratch buffers
+ float out[2][SCRATCH_BUFFER_SIZE]; // scratch buffers
// The JUCE framework doesn't like processing while being suspended.
const bool wasSuspended = !IsResumed();
@@ -2334,14 +2374,13 @@
// let plug process events
while(vstEvents.GetNumQueuedEvents() > 0)
{
- Process((float*)in, (float*)out, SCRATCH_BUFFER_SIZE);
+ Process(out[0], out[1], SCRATCH_BUFFER_SIZE);
}
if(wasSuspended)
{
Suspend();
}
-
}
Modified: trunk/OpenMPT/mptrack/Vstplug.h
===================================================================
--- trunk/OpenMPT/mptrack/Vstplug.h 2013-10-23 12:07:42 UTC (rev 2985)
+++ trunk/OpenMPT/mptrack/Vstplug.h 2013-10-23 16:18:07 UTC (rev 2986)
@@ -240,6 +240,7 @@
void RestoreAllParameters(long nProg=-1); //rewbs.plugDefaultProgram - added param
void RecalculateGain();
void Process(float *pOutL, float *pOutR, size_t nSamples);
+ float RenderSilence(size_t numSamples);
bool MidiSend(uint32 dwMidiCode);
bool MidiSysexSend(const char *message, uint32 length);
void MidiCC(uint8 nMidiCh, MIDIEvents::MidiCC nController, uint8 nParam, CHANNELINDEX trackChannel);
Modified: trunk/OpenMPT/mptrack/mod2wave.h
===================================================================
--- trunk/OpenMPT/mptrack/mod2wave.h 2013-10-23 12:07:42 UTC (rev 2985)
+++ trunk/OpenMPT/mptrack/mod2wave.h 2013-10-23 16:18:07 UTC (rev 2986)
@@ -20,12 +20,14 @@
{
std::vector<EncoderFactoryBase*> EncoderFactories;
std::size_t EncoderIndex;
- bool Normalize;
uint32 SampleRate;
uint16 Channels;
SampleFormat FinalSampleFormat;
Encoder::Settings EncoderSettings;
FileTags Tags;
+ bool Normalize;
+ bool SilencePlugBuffers;
+
void SelectEncoder(std::size_t index);
EncoderFactoryBase *GetEncoderFactory() const;
const Encoder::Traits *GetTraits() const;
Modified: trunk/OpenMPT/mptrack/mptrack.rc
===================================================================
--- trunk/OpenMPT/mptrack/mptrack.rc 2013-10-23 12:07:42 UTC (rev 2985)
+++ trunk/OpenMPT/mptrack/mptrack.rc 2013-10-23 16:18:07 UTC (rev 2986)
@@ -449,57 +449,60 @@
PUSHBUTTON "Default Settings",IDC_BUTTON_DEFAULT_RESAMPLING,186,180,66,12
END
-IDD_WAVECONVERT DIALOGEX 0, 0, 400, 250
+IDD_WAVECONVERT DIALOGEX 0, 0, 388, 257
STYLE DS_SETFONT | DS_MODALFRAME | DS_FIXEDSYS | DS_CENTER | WS_POPUP | WS_VISIBLE | WS_CAPTION | WS_SYSMENU
CAPTION "Export"
FONT 8, "MS Shell Dlg", 0, 0, 0x0
BEGIN
+ DEFPUSHBUTTON "OK",IDOK,270,240,50,14
+ PUSHBUTTON "Cancel",IDCANCEL,330,240,50,14
GROUPBOX "Format",IDC_STATIC,6,6,186,48
COMBOBOX IDC_COMBO5,12,18,66,82,CBS_DROPDOWNLIST | WS_VSCROLL | WS_TABSTOP
COMBOBOX IDC_COMBO1,84,18,54,82,CBS_DROPDOWNLIST | WS_VSCROLL | WS_TABSTOP
COMBOBOX IDC_COMBO4,144,18,42,82,CBS_DROPDOWNLIST | WS_VSCROLL | WS_TABSTOP
COMBOBOX IDC_COMBO2,12,36,174,75,CBS_DROPDOWNLIST | WS_VSCROLL | WS_TABSTOP
- GROUPBOX "Render",IDC_STATIC,6,60,186,84
+ GROUPBOX "Render",IDC_STATIC,6,60,186,72
PUSHBUTTON "Player &Options",IDC_PLAYEROPTIONS,12,72,60,14,BS_CENTER
CONTROL "&Channel mode (one file per channel)",IDC_CHECK4,"Button",BS_AUTOCHECKBOX | WS_TABSTOP,12,90,168,12
CONTROL "&Instrument mode (one file per instrument)",IDC_CHECK6,
"Button",BS_AUTOCHECKBOX | WS_TABSTOP,12,102,168,12
CONTROL "&Normalize Output",IDC_CHECK5,"Button",BS_AUTOCHECKBOX | WS_TABSTOP,12,114,168,12
+ GROUPBOX "Limit",IDC_STATIC,6,138,186,96
+ CONTROL "Limit file &size to: (KBytes)",IDC_CHECK1,"Button",BS_AUTOCHECKBOX | WS_TABSTOP,12,151,111,11
+ EDITTEXT IDC_EDIT1,132,151,50,12,ES_AUTOHSCROLL
+ CONTROL "Limit song &length to: (seconds)",IDC_CHECK2,"Button",BS_AUTOCHECKBOX | WS_TABSTOP,12,170,111,10
+ EDITTEXT IDC_EDIT2,132,170,50,12,ES_AUTOHSCROLL
+ LTEXT "Play:",IDC_STATIC,12,186,37,8
+ CONTROL "&Entire song",IDC_RADIO1,"Button",BS_AUTORADIOBUTTON | BS_VCENTER,12,199,54,12
+ EDITTEXT IDC_EDIT5,72,199,36,12,ES_AUTOHSCROLL | ES_NUMBER
+ CONTROL "",IDC_SPIN5,"msctls_updown32",UDS_SETBUDDYINT | UDS_ALIGNRIGHT | UDS_AUTOBUDDY | UDS_NOTHOUSANDS,96,199,11,11
+ LTEXT "times",IDC_STATIC,115,199,65,12,SS_CENTERIMAGE
+ CONTROL "From &position",IDC_RADIO2,"Button",BS_AUTORADIOBUTTON | BS_VCENTER,12,216,58,12
+ EDITTEXT IDC_EDIT3,72,216,36,12,ES_AUTOHSCROLL | ES_NUMBER
+ CONTROL "",IDC_SPIN3,"msctls_updown32",UDS_SETBUDDYINT | UDS_ALIGNRIGHT | UDS_AUTOBUDDY | UDS_NOTHOUSANDS,96,216,11,11
+ CTEXT "to",IDC_STATIC,114,150,8,12,SS_CENTERIMAGE
+ EDITTEXT IDC_EDIT4,126,216,36,12,ES_AUTOHSCROLL | ES_NUMBER
+ CONTROL "",IDC_SPIN4,"msctls_updown32",UDS_SETBUDDYINT | UDS_ALIGNRIGHT | UDS_AUTOBUDDY | UDS_NOTHOUSANDS,150,216,11,11
+ GROUPBOX "Plugin Quirks",IDC_STATIC,198,6,186,42
CONTROL "Slow &render (for Kontakt+DFD)",IDC_GIVEPLUGSIDLETIME,
- "Button",BS_AUTOCHECKBOX | BS_LEFT | BS_MULTILINE | WS_TABSTOP,12,126,168,12
- GROUPBOX "Limit",IDC_STATIC,6,150,186,96
- CONTROL "Limit file &size to: (KBytes)",IDC_CHECK1,"Button",BS_AUTOCHECKBOX | WS_TABSTOP,12,163,111,11
- EDITTEXT IDC_EDIT1,132,163,50,12,ES_AUTOHSCROLL
- CONTROL "Limit song &length to: (seconds)",IDC_CHECK2,"Button",BS_AUTOCHECKBOX | WS_TABSTOP,12,182,111,10
- EDITTEXT IDC_EDIT2,132,182,50,12,ES_AUTOHSCROLL
- LTEXT "Play:",IDC_STATIC,12,198,37,8
- CONTROL "&Entire song",IDC_RADIO1,"Button",BS_AUTORADIOBUTTON | BS_VCENTER,12,211,54,12
- CONTROL "From &position",IDC_RADIO2,"Button",BS_AUTORADIOBUTTON | BS_VCENTER,12,228,58,12
- EDITTEXT IDC_EDIT5,72,211,36,12,ES_AUTOHSCROLL | ES_NUMBER
- CONTROL "",IDC_SPIN5,"msctls_updown32",UDS_SETBUDDYINT | UDS_ALIGNRIGHT | UDS_AUTOBUDDY | UDS_NOTHOUSANDS,96,211,11,11
- LTEXT "times",IDC_STATIC,115,211,65,12,SS_CENTERIMAGE
- EDITTEXT IDC_EDIT3,72,228,36,12,ES_AUTOHSCROLL | ES_NUMBER
- CONTROL "",IDC_SPIN3,"msctls_updown32",UDS_SETBUDDYINT | UDS_ALIGNRIGHT | UDS_AUTOBUDDY | UDS_NOTHOUSANDS,96,228,11,11
- CTEXT "to",IDC_STATIC,114,228,8,12,SS_CENTERIMAGE
- EDITTEXT IDC_EDIT4,126,228,36,12,ES_AUTOHSCROLL | ES_NUMBER
- CONTROL "",IDC_SPIN4,"msctls_updown32",UDS_SETBUDDYINT | UDS_ALIGNRIGHT | UDS_AUTOBUDDY | UDS_NOTHOUSANDS,150,228,11,11
- GROUPBOX "Tags",IDC_STATIC,198,102,198,120
- CONTROL "Include Song Information",IDC_CHECK7,"Button",BS_AUTOCHECKBOX | WS_TABSTOP,204,114,132,10
- LTEXT "Title:",IDC_STATIC,204,133,17,8
- EDITTEXT IDC_EDIT11,240,130,150,12,ES_AUTOHSCROLL
- LTEXT "Author:",IDC_STATIC,204,151,30,8
- EDITTEXT IDC_EDIT6,240,149,150,12,ES_AUTOHSCROLL
- LTEXT "Album:",IDC_STATIC,204,170,30,8
- EDITTEXT IDC_EDIT7,240,167,150,12,ES_AUTOHSCROLL
- LTEXT "URL:",IDC_STATIC,204,188,30,8
- EDITTEXT IDC_EDIT8,240,186,150,12,ES_AUTOHSCROLL
- LTEXT "Genre:",IDC_STATIC,204,205,29,8
- COMBOBOX IDC_COMBO3,240,203,92,64,CBS_DROPDOWN | CBS_SORT | WS_VSCROLL | WS_TABSTOP
- RTEXT "Year:",IDC_STATIC,336,205,18,8
- EDITTEXT IDC_EDIT9,360,203,30,12,ES_AUTOHSCROLL | ES_NUMBER
- DEFPUSHBUTTON "OK",IDOK,282,228,50,14
- PUSHBUTTON "Cancel",IDCANCEL,342,228,50,14
- EDITTEXT IDC_EDIT10,198,6,198,90,ES_MULTILINE | ES_READONLY | WS_VSCROLL | NOT WS_TABSTOP
+ "Button",BS_AUTOCHECKBOX | BS_LEFT | BS_MULTILINE | WS_TABSTOP,204,18,174,12
+ CONTROL "Clear plugin &buffers before exporting",IDC_RENDERSILENCE,
+ "Button",BS_AUTOCHECKBOX | BS_LEFT | BS_MULTILINE | WS_TABSTOP,204,30,174,12
+ EDITTEXT IDC_EDIT10,198,174,186,60,ES_MULTILINE | ES_READONLY | WS_VSCROLL | NOT WS_TABSTOP
+ GROUPBOX "Tags",IDC_STATIC,198,54,186,114
+ CONTROL "Incl&ude Song Information",IDC_CHECK7,"Button",BS_AUTOCHECKBOX | WS_TABSTOP,204,66,174,10
+ LTEXT "Title:",IDC_STATIC,204,80,17,8
+ EDITTEXT IDC_EDIT11,240,78,138,12,ES_AUTOHSCROLL
+ LTEXT "Author:",IDC_STATIC,204,98,30,8
+ EDITTEXT IDC_EDIT6,240,96,138,12,ES_AUTOHSCROLL
+ LTEXT "Album:",IDC_STATIC,204,116,30,8
+ EDITTEXT IDC_EDIT7,240,114,138,12,ES_AUTOHSCROLL
+ LTEXT "URL:",IDC_STATIC,204,134,30,8
+ EDITTEXT IDC_EDIT8,240,132,138,12,ES_AUTOHSCROLL
+ LTEXT "Genre:",IDC_STATIC,204,152,29,8
+ COMBOBOX IDC_COMBO3,240,150,78,64,CBS_DROPDOWN | CBS_SORT | WS_VSCROLL | WS_TABSTOP
+ RTEXT "Year:",IDC_STATIC,324,152,18,8
+ EDITTEXT IDC_EDIT9,348,150,30,12,ES_AUTOHSCROLL | ES_NUMBER
END
IDD_PROGRESS DIALOG 0, 0, 186, 55
@@ -697,28 +700,28 @@
STYLE DS_SETFONT | DS_FIXEDSYS | WS_CHILD
FONT 8, "MS Shell Dlg", 0, 0, 0x1
BEGIN
- CONTROL "Follow Song",IDC_PATTERN_FOLLOWSONG,"Button",BS_AUTOCHECKBOX | BS_FLAT,312,33,55,8
+ CONTROL "Toolbar1",IDC_TOOLBAR1,"ToolbarWindow32",WS_GROUP | 0x4d,2,4,370,18
+ CONTROL "Spin1",IDC_SPIN_INSTRUMENT,"msctls_updown32",0x0,6,31,11,12
COMBOBOX IDC_COMBO_INSTRUMENT,18,31,102,137,CBS_DROPDOWNLIST | WS_VSCROLL
+ PUSHBUTTON "Plugin",IDC_PATINSTROPLUGGUI,126,31,33,13,0,WS_EX_STATICEDGE
CTEXT "Row Spacing",IDC_STATIC,168,33,42,8,SS_CENTERIMAGE
EDITTEXT IDC_EDIT_SPACING,216,31,28,12,ES_AUTOHSCROLL | ES_NUMBER | NOT WS_TABSTOP
CONTROL "Spin1",IDC_SPIN_SPACING,"msctls_updown32",UDS_WRAP | UDS_SETBUDDYINT | UDS_ALIGNRIGHT | UDS_AUTOBUDDY | UDS_ARROWKEYS | UDS_NOTHOUSANDS,236,31,11,11
+ CONTROL "Loop Pattern",IDC_PATTERN_LOOP,"Button",BS_AUTOCHECKBOX | BS_FLAT | WS_TABSTOP,252,33,57,8
+ CONTROL "Follow Song",IDC_PATTERN_FOLLOWSONG,"Button",BS_AUTOCHECKBOX | BS_FLAT,312,33,55,8
+ LTEXT "Pattern Name",IDC_STATIC_PATTERNNAME,384,33,48,8,SS_CENTERIMAGE
+ EDITTEXT IDC_EDIT_PATTERNNAME,438,31,109,12,ES_AUTOHSCROLL
+ LTEXT "Sequence",IDC_STATIC_SEQUENCE_NAME,384,10,36,8
+ EDITTEXT IDC_EDIT_SEQNUM,420,8,28,12,ES_AUTOHSCROLL | ES_NUMBER | NOT WS_TABSTOP
+ CONTROL "",IDC_SPIN_SEQNUM,"msctls_updown32",UDS_WRAP | UDS_SETBUDDYINT | UDS_ALIGNRIGHT | UDS_AUTOBUDDY | UDS_ARROWKEYS | UDS_NOTHOUSANDS,438,6,11,11
+ EDITTEXT IDC_EDIT_SEQUENCE_NAME,450,8,97,12,ES_AUTOHSCROLL
PUSHBUTTON "<<",IDC_BUTTON2,3,51,14,15,NOT WS_TABSTOP,WS_EX_STATICEDGE
PUSHBUTTON ">>",IDC_BUTTON1,15,51,14,15,NOT WS_TABSTOP,WS_EX_STATICEDGE
- LTEXT "Pattern Name",IDC_STATIC_PATTERNNAME,384,33,48,8,SS_CENTERIMAGE
- EDITTEXT IDC_EDIT_PATTERNNAME,438,31,109,12,ES_AUTOHSCROLL
- CONTROL "Toolbar1",IDC_TOOLBAR1,"ToolbarWindow32",WS_GROUP | 0x4d,2,4,370,18
- CONTROL "Spin1",IDC_SPIN_INSTRUMENT,"msctls_updown32",0x0,6,31,11,12
- PUSHBUTTON "Plugin",IDC_PATINSTROPLUGGUI,126,31,33,13,0,WS_EX_STATICEDGE
GROUPBOX "",IDC_STATIC,3,23,369,24
- CONTROL "Loop Pattern",IDC_PATTERN_LOOP,"Button",BS_AUTOCHECKBOX | BS_FLAT | WS_TABSTOP,252,33,57,8
EDITTEXT IDC_EDIT_ORDERLIST_MARGINS,3,65,28,12,ES_AUTOHSCROLL | ES_READONLY
CONTROL "",IDC_SPIN_ORDERLIST_MARGINS,"msctls_updown32",UDS_SETBUDDYINT | UDS_ALIGNRIGHT | UDS_AUTOBUDDY | UDS_NOTHOUSANDS,16,70,11,11
- EDITTEXT IDC_EDIT_SEQUENCE_NAME,450,8,97,12,ES_AUTOHSCROLL
- LTEXT "Sequence",IDC_STATIC_SEQUENCE_NAME,384,10,36,8
GROUPBOX "",IDC_STATIC_SEQUENCE_NAME_FRAME,378,0,174,24
GROUPBOX "",IDC_STATIC,378,23,174,24
- EDITTEXT IDC_EDIT_SEQNUM,420,8,28,12,ES_AUTOHSCROLL | ES_NUMBER | NOT WS_TABSTOP
- CONTROL "",IDC_SPIN_SEQNUM,"msctls_updown32",UDS_WRAP | UDS_SETBUDDYINT | UDS_ALIGNRIGHT | UDS_AUTOBUDDY | UDS_ARROWKEYS | UDS_NOTHOUSANDS,438,6,11,11
END
IDD_CONTROL_SAMPLES DIALOGEX 0, 0, 544, 106
@@ -1012,7 +1015,7 @@
CONTROL "Dry Mix",IDC_CHECK11,"Button",BS_AUTOCHECKBOX | BS_FLAT | WS_TABSTOP,199,286,37,10
COMBOBOX IDC_COMBO9,285,241,62,99,CBS_DROPDOWNLIST | WS_VSCROLL | WS_TABSTOP
LTEXT "Gain: x 1.0",IDC_STATIC2,353,241,37,14,SS_CENTERIMAGE
- CONTROL "",IDC_SPIN10,"msctls_updown32",UDS_ALIGNRIGHT | UDS_ARROWKEYS | UDS_NOTHOUSANDS,392,242,9,11
+ CONTROL "",IDC_SPIN10,"msctls_updown32",UDS_ARROWKEYS | UDS_NOTHOUSANDS | WS_TABSTOP,392,242,9,11
COMBOBOX IDC_COMBO7,285,261,117,68,CBS_DROPDOWNLIST | WS_VSCROLL | WS_TABSTOP
CONTROL "",IDC_SLIDER10,"msctls_trackbar32",TBS_BOTH | TBS_NOTICKS | WS_TABSTOP,314,282,88,14,WS_EX_STATICEDGE
GROUPBOX "Plugins",IDC_STATIC,5,177,408,131
@@ -1605,8 +1608,8 @@
IDD_WAVECONVERT, DIALOG
BEGIN
- RIGHTMARGIN, 349
- BOTTOMMARGIN, 247
+ RIGHTMARGIN, 337
+ BOTTOMMARGIN, 254
END
IDD_OPTIONS_KEYBOARD, DIALOG
Modified: trunk/OpenMPT/mptrack/resource.h
===================================================================
--- trunk/OpenMPT/mptrack/resource.h 2013-10-23 12:07:42 UTC (rev 2985)
+++ trunk/OpenMPT/mptrack/resource.h 2013-10-23 16:18:07 UTC (rev 2986)
@@ -735,6 +735,7 @@
#define IDC_SECONDARYHILITE 2227
#define IDC_GIVEPLUGSIDLETIME 2228
#define IDC_ROWSPERBEAT 2229
+#define IDC_RENDERSILENCE 2229
#define IDC_ROWSPERMEASURE 2230
#define IDC_GOTO_ROW 2231
#define IDC_GOTO_CHAN 2232
Modified: trunk/OpenMPT/soundlib/plugins/PlugInterface.h
===================================================================
--- trunk/OpenMPT/soundlib/plugins/PlugInterface.h 2013-10-23 12:07:42 UTC (rev 2985)
+++ trunk/OpenMPT/soundlib/plugins/PlugInterface.h 2013-10-23 16:18:07 UTC (rev 2986)
@@ -40,6 +40,7 @@
virtual void SaveAllParameters() = 0;
virtual void RestoreAllParameters(long nProg=-1) = 0; //rewbs.plugDefaultProgram: added param
virtual void Process(float *pOutL, float *pOutR, size_t nSamples) = 0;
+ virtual float RenderSilence(size_t numSamples) = 0;
virtual bool MidiSend(uint32 dwMidiCode) = 0;
virtual bool MidiSysexSend(const char *message, uint32 length) = 0;
virtual void MidiCC(uint8 nMidiCh, MIDIEvents::MidiCC nController, uint8 nParam, CHANNELINDEX trackChannel) = 0;
Modified: trunk/OpenMPT/soundlib/plugins/PluginMixBuffer.h
===================================================================
--- trunk/OpenMPT/soundlib/plugins/PluginMixBuffer.h 2013-10-23 12:07:42 UTC (rev 2985)
+++ trunk/OpenMPT/soundlib/plugins/PluginMixBuffer.h 2013-10-23 16:18:07 UTC (rev 2986)
@@ -107,6 +107,17 @@
}
// Silence all output buffers.
+ void ClearInputBuffers(size_t numSamples)
+ //---------------------------------------
+ {
+ ASSERT(numSamples <= bufferSize);
+ for(size_t i = 0; i < outputs; i++)
+ {
+ memset(inputsArray[i], 0, numSamples * sizeof(buffer_t));
+ }
+ }
+
+ // Silence all output buffers.
void ClearOutputBuffers(size_t numSamples)
//----------------------------------------
{
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <sag...@us...> - 2013-10-24 11:57:23
|
Revision: 3001
http://sourceforge.net/p/modplug/code/3001
Author: saga-games
Date: 2013-10-24 11:57:14 +0000 (Thu, 24 Oct 2013)
Log Message:
-----------
[Ref] More warning clenaups and additional changes for 64-bit builds
Modified Paths:
--------------
trunk/OpenMPT/include/soundtouch/OpenMPT.txt
trunk/OpenMPT/include/soundtouch/STTypes.h
trunk/OpenMPT/mptrack/Vstplug.cpp
trunk/OpenMPT/mptrack/Vstplug.h
trunk/OpenMPT/plugins/MidiInOut/MidiInOut.vcxproj
trunk/OpenMPT/soundlib/Load_mo3.cpp
trunk/OpenMPT/soundlib/Load_wav.cpp
Added Paths:
-----------
trunk/OpenMPT/mptrack/res/rt_manif64.bin
Modified: trunk/OpenMPT/include/soundtouch/OpenMPT.txt
===================================================================
--- trunk/OpenMPT/include/soundtouch/OpenMPT.txt 2013-10-24 11:36:56 UTC (rev 3000)
+++ trunk/OpenMPT/include/soundtouch/OpenMPT.txt 2013-10-24 11:57:14 UTC (rev 3001)
@@ -4,5 +4,10 @@
The "samples" parameter type of soundtouch_putSamples (line 116) has been changed
from float to short.
+In STTypes.h, the preprocessor statement
+#if (WIN32 || __i386__ || __x86_64__)
+has been changed to
+#if ((WIN32 && defined(_M_IX86)) || __i386__ || __x86_64__)
+
For building, premake4 is used to generate Visual Studio project files.
See ../premake4.lua for details.
Modified: trunk/OpenMPT/include/soundtouch/STTypes.h
===================================================================
--- trunk/OpenMPT/include/soundtouch/STTypes.h 2013-10-24 11:36:56 UTC (rev 3000)
+++ trunk/OpenMPT/include/soundtouch/STTypes.h 2013-10-24 11:57:14 UTC (rev 3001)
@@ -86,7 +86,7 @@
#endif
- #if (WIN32 || __i386__ || __x86_64__)
+ #if ((WIN32 && defined(_M_IX86)) || __i386__ || __x86_64__)
/// Define this to allow X86-specific assembler/intrinsic optimizations.
/// Notice that library contains also usual C++ versions of each of these
/// these routines, so if you're having difficulties getting the optimized
Modified: trunk/OpenMPT/mptrack/Vstplug.cpp
===================================================================
--- trunk/OpenMPT/mptrack/Vstplug.cpp 2013-10-24 11:36:56 UTC (rev 3000)
+++ trunk/OpenMPT/mptrack/Vstplug.cpp 2013-10-24 11:57:14 UTC (rev 3001)
@@ -2062,6 +2062,7 @@
float out[2][MIXBUFFERSIZE]; // scratch buffers
float maxVal = 0.0f;
+ mixBuffer.ClearInputBuffers(MIXBUFFERSIZE);
while(numSamples > 0)
{
@@ -2069,7 +2070,6 @@
LimitMax(renderSamples, CountOf(out[0]));
MemsetZero(out);
- mixBuffer.ClearInputBuffers(renderSamples);
Process(out[0], out[1], renderSamples);
for(size_t i = 0; i < renderSamples; i++)
{
@@ -2823,13 +2823,6 @@
}
-BOOL CVstPlugin::GetCommandName(UINT nIndex, LPSTR pszName)
-//---------------------------------------------------------
-{
- return Dispatch(effGetParamName, nIndex, 0, pszName, 0.0f);
-}
-
-
CAbstractVstEditor* CVstPlugin::GetEditor()
//-----------------------------------------
{
Modified: trunk/OpenMPT/mptrack/Vstplug.h
===================================================================
--- trunk/OpenMPT/mptrack/Vstplug.h 2013-10-24 11:36:56 UTC (rev 3000)
+++ trunk/OpenMPT/mptrack/Vstplug.h 2013-10-24 11:57:14 UTC (rev 3001)
@@ -219,7 +219,6 @@
void ToggleEditor();
void GetPluginType(LPSTR pszType);
BOOL GetDefaultEffectName(LPSTR pszName);
- BOOL GetCommandName(UINT index, LPSTR pszName);
CAbstractVstEditor* GetEditor(); //rewbs.defaultPlugGUI
void Bypass(bool bypass = true);
Added: trunk/OpenMPT/mptrack/res/rt_manif64.bin
===================================================================
--- trunk/OpenMPT/mptrack/res/rt_manif64.bin (rev 0)
+++ trunk/OpenMPT/mptrack/res/rt_manif64.bin 2013-10-24 11:57:14 UTC (rev 3001)
@@ -0,0 +1,22 @@
+<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
+<assembly
+ xmlns="urn:schemas-microsoft-com:asm.v1"
+ manifestVersion="1.0">
+ <assemblyIdentity
+ processorArchitecture="amd64"
+ version="5.1.0.0"
+ type="win32"
+ name="mptrack.exe"/>
+ <description>OpenMPT</description>
+ <dependency>
+ <dependentAssembly>
+ <assemblyIdentity
+ type="win32"
+ name="Microsoft.Windows.Common-Controls"
+ version="6.0.0.0"
+ publicKeyToken="6595b64144ccf1df"
+ language="*"
+ processorArchitecture="amd64"/>
+ </dependentAssembly>
+ </dependency>
+</assembly>
\ No newline at end of file
Modified: trunk/OpenMPT/plugins/MidiInOut/MidiInOut.vcxproj
===================================================================
--- trunk/OpenMPT/plugins/MidiInOut/MidiInOut.vcxproj 2013-10-24 11:36:56 UTC (rev 3000)
+++ trunk/OpenMPT/plugins/MidiInOut/MidiInOut.vcxproj 2013-10-24 11:57:14 UTC (rev 3001)
@@ -111,7 +111,7 @@
</Midl>
<ClCompile>
<Optimization>Disabled</Optimization>
- <AdditionalIncludeDirectories>../../../../..;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
+ <AdditionalIncludeDirectories>../../include/;../../include/vstsdk2.4/;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
<PreprocessorDefinitions>WIN32;_DEBUG;_WINDOWS;_USRDLL;AGAIN_EXPORTS;VST_64BIT_PLATFORM=1;_CRT_SECURE_NO_DEPRECATE=1;%(PreprocessorDefinitions)</PreprocessorDefinitions>
<MinimalRebuild>true</MinimalRebuild>
<BasicRuntimeChecks>EnableFastChecks</BasicRuntimeChecks>
@@ -168,7 +168,7 @@
<TargetEnvironment>X64</TargetEnvironment>
</Midl>
<ClCompile>
- <AdditionalIncludeDirectories>../../../../..;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
+ <AdditionalIncludeDirectories>../../include/;../../include/vstsdk2.4/;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
<PreprocessorDefinitions>WIN32;NDEBUG;_WINDOWS;_USRDLL;AGAIN_EXPORTS;VST_64BIT_PLATFORM=1;_CRT_SECURE_NO_DEPRECATE=1;%(PreprocessorDefinitions)</PreprocessorDefinitions>
<RuntimeLibrary>MultiThreaded</RuntimeLibrary>
<PrecompiledHeader>
@@ -177,7 +177,7 @@
<DebugInformationFormat>ProgramDatabase</DebugInformationFormat>
</ClCompile>
<Link>
- <ModuleDefinitionFile>../../win/vstplug.def</ModuleDefinitionFile>
+ <ModuleDefinitionFile>../../include/vstsdk2.4/public.sdk/samples/vst2.x/win/vstplug.def</ModuleDefinitionFile>
<GenerateDebugInformation>true</GenerateDebugInformation>
<SubSystem>Windows</SubSystem>
<OptimizeReferences>true</OptimizeReferences>
Modified: trunk/OpenMPT/soundlib/Load_mo3.cpp
===================================================================
--- trunk/OpenMPT/soundlib/Load_mo3.cpp 2013-10-24 11:36:56 UTC (rev 3000)
+++ trunk/OpenMPT/soundlib/Load_mo3.cpp 2013-10-24 11:57:14 UTC (rev 3001)
@@ -46,7 +46,7 @@
file.Rewind();
const void *stream = file.GetRawData();
- int length = file.GetLength();
+ uint32 length = mpt::saturate_cast<uint32>(file.GetLength());
bool result = false; // Result of trying to load the module, false == fail.
@@ -68,7 +68,7 @@
// Decode a MO3 file (returns the same "exit codes" as UNMO3.EXE, eg. 0=success)
// IN: data/len = MO3 data/len
// OUT: data/len = decoded data/len (if successful)
- typedef int (WINAPI * UNMO3_DECODE)(const void **data, int *len);
+ typedef int (WINAPI * UNMO3_DECODE)(const void **data, uint32 *len);
// Free the data returned by UNMO3_Decode
typedef void (WINAPI * UNMO3_FREE)(const void *data);
Modified: trunk/OpenMPT/soundlib/Load_wav.cpp
===================================================================
--- trunk/OpenMPT/soundlib/Load_wav.cpp 2013-10-24 11:36:56 UTC (rev 3000)
+++ trunk/OpenMPT/soundlib/Load_wav.cpp 2013-10-24 11:57:14 UTC (rev 3001)
@@ -69,7 +69,7 @@
// Setting up module length
// Calculate sample length in ticks at tempo 125
- const uint32 sampleTicks = ((sampleLength * 50) / wavFile.GetSampleRate()) + 1;
+ const uint32 sampleTicks = mpt::saturate_cast<uint32>(((sampleLength * 50) / wavFile.GetSampleRate()) + 1);
uint32 ticksPerRow = std::max((sampleTicks + 63u) / 63u, 1u);
Order.clear();
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <man...@us...> - 2013-10-24 13:19:29
|
Revision: 3008
http://sourceforge.net/p/modplug/code/3008
Author: manxorist
Date: 2013-10-24 13:19:19 +0000 (Thu, 24 Oct 2013)
Log Message:
-----------
Merged revision(s) 2979 from branches/manx/serialization-utils-cleanup:
[Ref] Remove completely unused serialization subentry code.
........
Modified Paths:
--------------
trunk/OpenMPT/common/serialization_utils.cpp
trunk/OpenMPT/common/serialization_utils.h
Property Changed:
----------------
trunk/OpenMPT/
Index: trunk/OpenMPT
===================================================================
--- trunk/OpenMPT 2013-10-24 13:14:25 UTC (rev 3007)
+++ trunk/OpenMPT 2013-10-24 13:19:19 UTC (rev 3008)
Property changes on: trunk/OpenMPT
___________________________________________________________________
Modified: svn:mergeinfo
## -11,7 +11,7 ##
/branches/manx/profiler:1813
/branches/manx/project-files-cleanups:1378-1382
/branches/manx/sampleformat-ref:2554-2582
-/branches/manx/serialization-utils-cleanup:2382-2386,2395
+/branches/manx/serialization-utils-cleanup:2382-2386,2395,2979
/branches/manx/snddev:2780-2788
/branches/manx/snddev-fixes:1605-1713
/branches/manx/sounddev:2923-2934
\ No newline at end of property
Modified: trunk/OpenMPT/common/serialization_utils.cpp
===================================================================
--- trunk/OpenMPT/common/serialization_utils.cpp 2013-10-24 13:14:25 UTC (rev 3007)
+++ trunk/OpenMPT/common/serialization_utils.cpp 2013-10-24 13:19:19 UTC (rev 3008)
@@ -250,7 +250,6 @@
const char tstrEndOfMap[] = "End of map(rpos): %u\n";
const char tstrReadProgress[] = "Read entry: {num, id, rpos, size, desc} = {%u, %s, %u, %s, %s}\n";
const char tstrNoEntryFound[] = "No entry with id %s found.\n";
-const char tstrCantFindSubEntry[] = "Unable to find subentry with id=%s\n";
const char strReadNote[] = "Read note: ";
@@ -272,8 +271,6 @@
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), \
@@ -423,36 +420,6 @@
}
-void Ssb::CreateWriteSubEntry()
-//-----------------------------
-{
- m_posSubEntryStart = m_pOstrm->tellp();
- delete m_pSubEntry;
- m_pSubEntry = new Ssb(*m_pOstrm);
- m_pSubEntry->m_fpLogFunc = m_fpLogFunc;
-}
-
-
-Ssb* Ssb::CreateReadSubEntry(const char* pId, const size_t nLength)
-//-----------------------------------------------------------------
-{
- const ReadEntry* pE = Find(pId, nLength);
- if (pE && pE->rposStart != 0)
- {
- m_nCounter++;
- delete m_pSubEntry;
- m_pSubEntry = new Ssb(*m_pIstrm);
- m_pSubEntry->m_fpLogFunc = m_fpLogFunc;
- m_pIstrm->seekg(m_posStart + Postype(pE->rposStart));
- return m_pSubEntry;
- }
- else if (m_fpLogFunc)
- m_fpLogFunc(tstrCantFindSubEntry, IdToString(pId, nLength).c_str());
-
- return nullptr;
-}
-
-
void Ssb::IncrementWriteCounter()
//-------------------------------
{
@@ -465,18 +432,6 @@
}
-void Ssb::ReleaseWriteSubEntry(const char* pId, const size_t nIdLength)
-//---------------------------------------------------------------------
-{
- if ((m_pSubEntry->m_Status & SNT_FAILURE) != 0)
- m_Status |= SNW_SUBENTRY_FAILURE;
-
- delete m_pSubEntry; m_pSubEntry = nullptr;
- WriteMapItem(pId, nIdLength, static_cast<RposType>(m_posSubEntryStart - m_posStart), static_cast<DataSize>(m_pOstrm->tellp() - m_posSubEntryStart), "");
- IncrementWriteCounter();
-}
-
-
void Ssb::BeginWrite(const char* pId, const size_t nIdSize, const uint64& nVersion)
//---------------------------------------------------------------------------------
{
Modified: trunk/OpenMPT/common/serialization_utils.h
===================================================================
--- trunk/OpenMPT/common/serialization_utils.h 2013-10-24 13:14:25 UTC (rev 3007)
+++ trunk/OpenMPT/common/serialization_utils.h 2013-10-24 13:19:19 UTC (rev 3008)
@@ -67,7 +67,6 @@
SNW_INSUFFICIENT_MAPSIZE = (0x12) | SNT_FAILURE,
SNW_DATASIZETYPE_OVERFLOW = (0x13) | SNT_FAILURE,
SNW_MAX_WRITE_COUNT_REACHED = (0x14) | SNT_FAILURE,
- SNW_SUBENTRY_FAILURE = (0x15) | SNT_FAILURE,
SNW_INSUFFICIENT_DATASIZETYPE = (0x16) | SNT_FAILURE
};
@@ -284,7 +283,7 @@
Ssb(std::ostream& oStrm);
Ssb(std::istream& iStrm);
- ~Ssb() {delete m_pSubEntry;}
+ ~Ssb() {}
// Sets map ID size in writing.
void SetIdSize(uint16 idSize);
@@ -300,24 +299,6 @@
// Reserves space for map to current position. Call after BeginWrite and before writing any entries.
void ReserveMapSize(uint32 nSize);
- // Creates subentry for writing. Use SubEntry() to access the subentry and
- // when done, call ReleaseSubEntry. Don't call WriteItem() for 'this' while
- // subentry is active.
- void CreateWriteSubEntry();
-
- // Returns current write/read subentry. CreateWriteSubEntry/CreateReadSubEntry
- // must be called before calling this.
- Ssb& SubEntry() {return *m_pSubEntry;}
-
- // Releases write subentry and writes corresponding map information.
- void ReleaseWriteSubEntry(const char* pId, const size_t nIdLength);
- void ReleaseWriteSubEntry(const char* pszId) {ReleaseWriteSubEntry(pszId, strlen(pszId));}
-
- // If ID was found, returns pointer to Ssb object, nullptr if not found.
- // Note: All reading on subentry must be done before calling ReadItem with 'this'.
- Ssb* CreateReadSubEntry(const char* pId, const size_t nLength);
- Ssb* CreateReadSubEntry(const char* pszId) {return CreateReadSubEntry(pszId, strlen(pszId));}
-
// After calling BeginRead(), this returns number of entries in the file.
NumType GetNumEntries() const {return m_nReadEntrycount;}
@@ -453,8 +434,6 @@
NumType m_nNextReadHint; // Read: Hint where to start looking for the next read entry.
std::bitset<RwfNumFlags> m_Flags; // Read/write: Various flags.
- Ssb* m_pSubEntry; // Read/Write: Pointer to SubEntry.
- Postype m_posSubEntryStart; // Write: Holds data position where SubEntry started.
uint32 m_nMapReserveSize; // Write: Number of bytes to reserve for map if writing it before data.
Postype m_posEntrycount; // Write: Pos of entrycount field.
Postype m_posMapPosField; // Write: Pos of map position field.
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <man...@us...> - 2013-10-25 13:26:51
|
Revision: 3016
http://sourceforge.net/p/modplug/code/3016
Author: manxorist
Date: 2013-10-25 13:26:42 +0000 (Fri, 25 Oct 2013)
Log Message:
-----------
[Ref] sounddev: ISoundDevice::Reset() is only ever called directly before Close() and Close() does a superset of Reset() for all device types. The implementation for DirectSound called IDirectSoundBuffer::stop() from the wrong thread. And generelly, the intendet semantics for ISoundDevice::Reset() are totally unclear and the implemented semantics differ depending on the actual device type. Just remove it, it is just not needed.
[Fix] sounddev: Ensure InternalClose() is only ever called if the output has been Stop()ed before.
Modified Paths:
--------------
trunk/OpenMPT/mptrack/ExceptionHandler.cpp
trunk/OpenMPT/mptrack/MainFrm.cpp
trunk/OpenMPT/sounddev/SoundDevice.cpp
trunk/OpenMPT/sounddev/SoundDevice.h
trunk/OpenMPT/sounddev/SoundDeviceASIO.cpp
trunk/OpenMPT/sounddev/SoundDeviceASIO.h
trunk/OpenMPT/sounddev/SoundDeviceDirectSound.cpp
trunk/OpenMPT/sounddev/SoundDeviceDirectSound.h
trunk/OpenMPT/sounddev/SoundDevicePortAudio.cpp
trunk/OpenMPT/sounddev/SoundDevicePortAudio.h
trunk/OpenMPT/sounddev/SoundDeviceWaveout.cpp
trunk/OpenMPT/sounddev/SoundDeviceWaveout.h
trunk/OpenMPT/sounddev/SoundDevices.h
Modified: trunk/OpenMPT/mptrack/ExceptionHandler.cpp
===================================================================
--- trunk/OpenMPT/mptrack/ExceptionHandler.cpp 2013-10-25 11:06:48 UTC (rev 3015)
+++ trunk/OpenMPT/mptrack/ExceptionHandler.cpp 2013-10-25 13:26:42 UTC (rev 3016)
@@ -148,7 +148,6 @@
{
if(pMainFrame->gpSoundDevice)
{
- pMainFrame->gpSoundDevice->Reset();
pMainFrame->gpSoundDevice->Close();
}
if(pMainFrame->m_NotifyTimer)
Modified: trunk/OpenMPT/mptrack/MainFrm.cpp
===================================================================
--- trunk/OpenMPT/mptrack/MainFrm.cpp 2013-10-25 11:06:48 UTC (rev 3015)
+++ trunk/OpenMPT/mptrack/MainFrm.cpp 2013-10-25 13:26:42 UTC (rev 3016)
@@ -873,7 +873,6 @@
{
if(gpSoundDevice)
{
- gpSoundDevice->Reset();
gpSoundDevice->Close();
}
Modified: trunk/OpenMPT/sounddev/SoundDevice.cpp
===================================================================
--- trunk/OpenMPT/sounddev/SoundDevice.cpp 2013-10-25 11:06:48 UTC (rev 3015)
+++ trunk/OpenMPT/sounddev/SoundDevice.cpp 2013-10-25 13:26:42 UTC (rev 3016)
@@ -100,6 +100,7 @@
bool ISoundDevice::Open(const SoundDeviceSettings &settings)
//----------------------------------------------------------
{
+ if(IsOpen()) return false;
m_Settings = settings;
if(m_Settings.LatencyMS < SNDDEV_MINLATENCY_MS) m_Settings.LatencyMS = SNDDEV_MINLATENCY_MS;
if(m_Settings.LatencyMS > SNDDEV_MAXLATENCY_MS) m_Settings.LatencyMS = SNDDEV_MAXLATENCY_MS;
@@ -114,6 +115,8 @@
bool ISoundDevice::Close()
//------------------------
{
+ if(!IsOpen()) return true;
+ Stop();
return InternalClose();
}
@@ -204,15 +207,6 @@
}
-void ISoundDevice::Reset()
-//------------------------
-{
- if(!IsOpen()) return;
- Stop();
- InternalReset();
-}
-
-
int64 ISoundDevice::GetStreamPositionSamples() const
//--------------------------------------------------
{
@@ -612,14 +606,7 @@
}
-void CSoundDeviceWithThread::InternalReset()
-//------------------------------------------
-{
- ResetFromOutsideSoundThread();
-}
-
-
///////////////////////////////////////////////////////////////////////////////////////
//
// Global Functions
Modified: trunk/OpenMPT/sounddev/SoundDevice.h
===================================================================
--- trunk/OpenMPT/sounddev/SoundDevice.h 2013-10-25 11:06:48 UTC (rev 3015)
+++ trunk/OpenMPT/sounddev/SoundDevice.h 2013-10-25 13:26:42 UTC (rev 3016)
@@ -262,17 +262,15 @@
virtual bool InternalOpen() = 0;
virtual void InternalStart() = 0;
virtual void InternalStop() = 0;
- virtual void InternalReset() = 0;
virtual bool InternalClose() = 0;
virtual bool InternalHasGetStreamPosition() const { return false; }
virtual int64 InternalGetStreamPositionSamples() const { return 0; }
public:
- bool Open(const SoundDeviceSettings &settings); // Open a device
- bool Close(); // Close the currently open device
+ bool Open(const SoundDeviceSettings &settings);
+ bool Close();
void Start();
void Stop();
- void Reset();
int64 GetStreamPositionSamples() const;
SampleFormat GetActualSampleFormat() { return IsOpen() ? m_Settings.sampleFormat : SampleFormatInvalid; }
virtual bool IsOpen() const = 0;
Modified: trunk/OpenMPT/sounddev/SoundDeviceASIO.cpp
===================================================================
--- trunk/OpenMPT/sounddev/SoundDeviceASIO.cpp 2013-10-25 11:06:48 UTC (rev 3015)
+++ trunk/OpenMPT/sounddev/SoundDeviceASIO.cpp 2013-10-25 13:26:42 UTC (rev 3016)
@@ -176,7 +176,6 @@
CASIODevice::~CASIODevice()
//-------------------------
{
- Reset();
Close();
}
@@ -459,30 +458,6 @@
}
-void CASIODevice::InternalReset()
-//-------------------------------
-{
- if(IsOpen())
- {
- Stop();
- if(m_bMixRunning)
- {
- m_bMixRunning = FALSE;
- ALWAYS_ASSERT(g_asio_startcount==0);
- try
- {
- m_pAsioDrv->stop();
- } catch(...)
- {
- CASIODevice::ReportASIOException("ASIO crash in stop()\n");
- }
- g_asio_startcount = 0;
- SetRenderSilence(false);
- }
- }
-}
-
-
void CASIODevice::OpenDevice()
//----------------------------
{
Modified: trunk/OpenMPT/sounddev/SoundDeviceASIO.h
===================================================================
--- trunk/OpenMPT/sounddev/SoundDeviceASIO.h 2013-10-25 11:06:48 UTC (rev 3015)
+++ trunk/OpenMPT/sounddev/SoundDeviceASIO.h 2013-10-25 13:26:42 UTC (rev 3016)
@@ -59,7 +59,6 @@
bool InternalOpen();
bool InternalClose();
void FillAudioBuffer();
- void InternalReset();
void InternalStart();
void InternalStop();
bool IsOpen() const { return (m_pAsioDrv != NULL); }
Modified: trunk/OpenMPT/sounddev/SoundDeviceDirectSound.cpp
===================================================================
--- trunk/OpenMPT/sounddev/SoundDeviceDirectSound.cpp 2013-10-25 11:06:48 UTC (rev 3015)
+++ trunk/OpenMPT/sounddev/SoundDeviceDirectSound.cpp 2013-10-25 13:26:42 UTC (rev 3016)
@@ -108,7 +108,6 @@
CDSoundDevice::~CDSoundDevice()
//-----------------------------
{
- Reset();
Close();
}
@@ -305,17 +304,6 @@
}
-void CDSoundDevice::ResetFromOutsideSoundThread()
-//-----------------------------------------------
-{
- if(m_pMixBuffer)
- {
- m_pMixBuffer->Stop();
- }
- m_bMixRunning = FALSE;
-}
-
-
DWORD CDSoundDevice::LockBuffer(DWORD dwBytes, LPVOID *lpBuf1, LPDWORD lpSize1, LPVOID *lpBuf2, LPDWORD lpSize2)
//--------------------------------------------------------------------------------------------------------------
{
Modified: trunk/OpenMPT/sounddev/SoundDeviceDirectSound.h
===================================================================
--- trunk/OpenMPT/sounddev/SoundDeviceDirectSound.h 2013-10-25 11:06:48 UTC (rev 3015)
+++ trunk/OpenMPT/sounddev/SoundDeviceDirectSound.h 2013-10-25 13:26:42 UTC (rev 3016)
@@ -45,7 +45,6 @@
bool InternalOpen();
bool InternalClose();
void FillAudioBuffer();
- void ResetFromOutsideSoundThread();
void StartFromSoundThread();
void StopFromSoundThread();
bool IsOpen() const { return (m_pMixBuffer != NULL); }
Modified: trunk/OpenMPT/sounddev/SoundDevicePortAudio.cpp
===================================================================
--- trunk/OpenMPT/sounddev/SoundDevicePortAudio.cpp 2013-10-25 11:06:48 UTC (rev 3015)
+++ trunk/OpenMPT/sounddev/SoundDevicePortAudio.cpp 2013-10-25 13:26:42 UTC (rev 3016)
@@ -41,7 +41,6 @@
CPortaudioDevice::~CPortaudioDevice()
//-----------------------------------
{
- Reset();
Close();
}
@@ -113,13 +112,6 @@
}
-void CPortaudioDevice::InternalReset()
-//------------------------------------
-{
- Pa_AbortStream(m_Stream);
-}
-
-
void CPortaudioDevice::InternalStart()
//------------------------------------
{
Modified: trunk/OpenMPT/sounddev/SoundDevicePortAudio.h
===================================================================
--- trunk/OpenMPT/sounddev/SoundDevicePortAudio.h 2013-10-25 11:06:48 UTC (rev 3015)
+++ trunk/OpenMPT/sounddev/SoundDevicePortAudio.h 2013-10-25 13:26:42 UTC (rev 3016)
@@ -46,7 +46,6 @@
bool InternalOpen();
bool InternalClose();
void FillAudioBuffer();
- void InternalReset();
void InternalStart();
void InternalStop();
bool IsOpen() const { return m_Stream ? true : false; }
Modified: trunk/OpenMPT/sounddev/SoundDeviceWaveout.cpp
===================================================================
--- trunk/OpenMPT/sounddev/SoundDeviceWaveout.cpp 2013-10-25 11:06:48 UTC (rev 3015)
+++ trunk/OpenMPT/sounddev/SoundDeviceWaveout.cpp 2013-10-25 13:26:42 UTC (rev 3016)
@@ -46,7 +46,6 @@
CWaveDevice::~CWaveDevice()
//-------------------------
{
- Reset();
Close();
}
@@ -108,10 +107,12 @@
bool CWaveDevice::InternalClose()
//-------------------------------
{
- Reset();
- if (m_hWaveOut)
+ if(m_hWaveOut)
{
- ResetFromOutsideSoundThread(); // always reset so that waveOutClose does not fail if we did only P->Stop() (meaning waveOutPause()) before
+ waveOutReset(m_hWaveOut);
+ m_JustStarted = false;
+ InterlockedExchange(&m_nBuffersPending, 0);
+ m_nWriteBuffer = 0;
while (m_nPreparedHeaders > 0)
{
m_nPreparedHeaders--;
@@ -147,19 +148,6 @@
}
-void CWaveDevice::ResetFromOutsideSoundThread()
-//---------------------------------------------
-{
- if(m_hWaveOut)
- {
- waveOutReset(m_hWaveOut);
- m_JustStarted = false;
- }
- InterlockedExchange(&m_nBuffersPending, 0);
- m_nWriteBuffer = 0;
-}
-
-
void CWaveDevice::FillAudioBuffer()
//---------------------------------
{
Modified: trunk/OpenMPT/sounddev/SoundDeviceWaveout.h
===================================================================
--- trunk/OpenMPT/sounddev/SoundDeviceWaveout.h 2013-10-25 11:06:48 UTC (rev 3015)
+++ trunk/OpenMPT/sounddev/SoundDeviceWaveout.h 2013-10-25 13:26:42 UTC (rev 3016)
@@ -44,7 +44,6 @@
bool InternalOpen();
bool InternalClose();
void FillAudioBuffer();
- void ResetFromOutsideSoundThread();
void StartFromSoundThread();
void StopFromSoundThread();
bool IsOpen() const { return (m_hWaveOut != NULL); }
Modified: trunk/OpenMPT/sounddev/SoundDevices.h
===================================================================
--- trunk/OpenMPT/sounddev/SoundDevices.h 2013-10-25 11:06:48 UTC (rev 3015)
+++ trunk/OpenMPT/sounddev/SoundDevices.h 2013-10-25 13:26:42 UTC (rev 3016)
@@ -67,9 +67,7 @@
virtual ~CSoundDeviceWithThread() {}
void InternalStart();
void InternalStop();
- void InternalReset();
virtual void StartFromSoundThread() = 0;
virtual void StopFromSoundThread() = 0;
- virtual void ResetFromOutsideSoundThread() = 0;
};
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <man...@us...> - 2013-10-25 16:59:19
|
Revision: 3023
http://sourceforge.net/p/modplug/code/3023
Author: manxorist
Date: 2013-10-25 16:59:10 +0000 (Fri, 25 Oct 2013)
Log Message:
-----------
[Ref] unarchiver: Factor out common code of different archive types and thus simplify each archive implementation.
[Ref] unarchiver: Move best file heuristic to a single place in CUnarchiver.
Modified Paths:
--------------
trunk/OpenMPT/mptrack/mptrack_08.vcproj
trunk/OpenMPT/mptrack/mptrack_10.vcxproj
trunk/OpenMPT/mptrack/mptrack_10.vcxproj.filters
trunk/OpenMPT/soundlib/Sndfile.cpp
trunk/OpenMPT/unarchiver/unarchiver.cpp
trunk/OpenMPT/unarchiver/unarchiver.h
trunk/OpenMPT/unarchiver/ungzip.cpp
trunk/OpenMPT/unarchiver/ungzip.h
trunk/OpenMPT/unarchiver/unlha.cpp
trunk/OpenMPT/unarchiver/unlha.h
trunk/OpenMPT/unarchiver/unzip.cpp
trunk/OpenMPT/unarchiver/unzip.h
Added Paths:
-----------
trunk/OpenMPT/unarchiver/archive.h
Modified: trunk/OpenMPT/mptrack/mptrack_08.vcproj
===================================================================
--- trunk/OpenMPT/mptrack/mptrack_08.vcproj 2013-10-25 16:31:52 UTC (rev 3022)
+++ trunk/OpenMPT/mptrack/mptrack_08.vcproj 2013-10-25 16:59:10 UTC (rev 3023)
@@ -1573,6 +1573,10 @@
Name="unarchiver"
>
<File
+ RelativePath="..\unarchiver\archive.h"
+ >
+ </File>
+ <File
RelativePath="..\unarchiver\unarchiver.cpp"
>
</File>
Modified: trunk/OpenMPT/mptrack/mptrack_10.vcxproj
===================================================================
--- trunk/OpenMPT/mptrack/mptrack_10.vcxproj 2013-10-25 16:31:52 UTC (rev 3022)
+++ trunk/OpenMPT/mptrack/mptrack_10.vcxproj 2013-10-25 16:59:10 UTC (rev 3023)
@@ -538,6 +538,7 @@
<ClInclude Include="..\soundlib\WindowedFIR.h" />
<ClInclude Include="..\soundlib\XMTools.h" />
<ClInclude Include="..\test\test.h" />
+ <ClInclude Include="..\unarchiver\archive.h" />
<ClInclude Include="..\unarchiver\unarchiver.h" />
<ClInclude Include="..\unarchiver\ungzip.h" />
<ClInclude Include="..\unarchiver\unlha.h" />
Modified: trunk/OpenMPT/mptrack/mptrack_10.vcxproj.filters
===================================================================
--- trunk/OpenMPT/mptrack/mptrack_10.vcxproj.filters 2013-10-25 16:31:52 UTC (rev 3022)
+++ trunk/OpenMPT/mptrack/mptrack_10.vcxproj.filters 2013-10-25 16:59:10 UTC (rev 3023)
@@ -957,6 +957,9 @@
<ClInclude Include="StreamEncoderFLAC.h">
<Filter>Header Files\mptrack</Filter>
</ClInclude>
+ <ClInclude Include="..\unarchiver\archive.h">
+ <Filter>Header Files\unarchiver</Filter>
+ </ClInclude>
</ItemGroup>
<ItemGroup>
<None Include="res\bitmap1.bmp">
Modified: trunk/OpenMPT/soundlib/Sndfile.cpp
===================================================================
--- trunk/OpenMPT/soundlib/Sndfile.cpp 2013-10-25 16:31:52 UTC (rev 3022)
+++ trunk/OpenMPT/soundlib/Sndfile.cpp 2013-10-25 16:59:10 UTC (rev 3023)
@@ -673,8 +673,8 @@
DWORD dwMemLength = file.GetLength();
#ifndef NO_ARCHIVE_SUPPORT
- CUnarchiver unarchiver(file, GetSupportedExtensions(true));
- if(unarchiver.IsArchive() && unarchiver.ExtractFile())
+ CUnarchiver unarchiver(file);
+ if(unarchiver.ExtractBestFile(GetSupportedExtensions(true)))
{
file = unarchiver.GetOutputFile();
lpStream = (LPCBYTE)file.GetRawData();
@@ -744,7 +744,7 @@
// Read archive comment if there is no song comment
if(songMessage.empty())
{
- songMessage.assign(unarchiver.GetComments());
+ songMessage.assign(unarchiver.GetComment());
}
#endif
Added: trunk/OpenMPT/unarchiver/archive.h
===================================================================
--- trunk/OpenMPT/unarchiver/archive.h (rev 0)
+++ trunk/OpenMPT/unarchiver/archive.h 2013-10-25 16:59:10 UTC (rev 3023)
@@ -0,0 +1,103 @@
+/*
+ * archive.h
+ * ---------
+ * Purpose: archive loader
+ * Notes : (currently none)
+ * Authors: OpenMPT Devs
+ * The OpenMPT source code is released under the BSD license. Read LICENSE for more details.
+ */
+
+#pragma once
+
+#include "../soundlib/FileReader.h"
+#include <string>
+#include <vector>
+
+enum ArchiveFileType
+{
+ ArchiveFileInvalid,
+ ArchiveFileNormal,
+ ArchiveFileSpecial,
+};
+
+struct ArchiveFileInfo
+{
+ std::string name;
+ ArchiveFileType type;
+ uint64 size;
+ std::string comment;
+ uint64 cookie1;
+ uint64 cookie2;
+ ArchiveFileInfo()
+ : name(std::string())
+ , type(ArchiveFileInvalid)
+ , size(0)
+ , comment(std::string())
+ , cookie1(0)
+ , cookie2(0)
+ {
+ return;
+ }
+};
+
+//============
+class IArchive
+//============
+{
+public:
+ typedef std::vector<ArchiveFileInfo>::const_iterator const_iterator;
+protected:
+ IArchive() {}
+public:
+ virtual ~IArchive() {};
+public:
+ virtual bool IsArchive() const = 0;
+ virtual std::string GetComment() const = 0;
+ virtual bool ExtractFile(std::size_t index) = 0;
+ virtual FileReader GetOutputFile() const = 0;
+ virtual std::size_t size() const = 0;
+ virtual IArchive::const_iterator begin() const = 0;
+ virtual IArchive::const_iterator end() const = 0;
+ virtual const ArchiveFileInfo & at(std::size_t index) const = 0;
+ virtual const ArchiveFileInfo & operator [] (std::size_t index) const = 0;
+};
+
+//=================================
+class ArchiveBase : public IArchive
+//=================================
+{
+protected:
+ FileReader inFile;
+ std::string comment;
+ std::vector<ArchiveFileInfo> contents;
+ std::vector<char> data;
+public:
+ ArchiveBase(const FileReader &inFile)
+ : inFile(inFile)
+ {
+ return;
+ }
+ virtual ~ArchiveBase()
+ {
+ return;
+ }
+ virtual bool ExtractFile(std::size_t index) { MPT_UNREFERENCED_PARAMETER(index); return false; } // overwrite this
+public:
+ virtual bool IsArchive() const
+ {
+ return !contents.empty();
+ }
+ virtual std::string GetComment() const
+ {
+ return comment;
+ }
+ virtual FileReader GetOutputFile() const
+ {
+ return FileReader(&data[0], data.size());
+ }
+ virtual std::size_t size() const { return contents.size(); }
+ virtual IArchive::const_iterator begin() const { return contents.begin(); }
+ virtual IArchive::const_iterator end() const { return contents.end(); }
+ virtual const ArchiveFileInfo & at(std::size_t index) const { return contents.at(index); }
+ virtual const ArchiveFileInfo & operator [] (std::size_t index) const { return contents[index]; }
+};
Property changes on: trunk/OpenMPT/unarchiver/archive.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/unarchiver/unarchiver.cpp
===================================================================
--- trunk/OpenMPT/unarchiver/unarchiver.cpp 2013-10-25 16:31:52 UTC (rev 3022)
+++ trunk/OpenMPT/unarchiver/unarchiver.cpp 2013-10-25 16:59:10 UTC (rev 3023)
@@ -14,16 +14,38 @@
#include "unarchiver.h"
#include "../soundlib/FileReader.h"
-CUnarchiver::CUnarchiver(FileReader &file, const std::vector<const char *> &extensions) :
-ext(extensions),
-inFile(file),
-zipArchive(inFile, ext),
-rarArchive((LPBYTE)inFile.GetRawData(), inFile.GetLength()),
-lhaArchive(inFile),
-gzipArchive(inFile)
-//---------------------------------------------------------------------------------
+CUnarchiver::CUnarchiver(FileReader &file)
+//----------------------------------------
+ : impl(nullptr)
+ , inFile(file)
+ , emptyArchive(inFile)
+#ifdef ZIPPED_MOD_SUPPORT
+ , zipArchive(inFile)
+#endif
+#ifdef UNRAR_SUPPORT
+ , rarArchive(inFile)
+#endif
+#ifdef UNLHA_SUPPORT
+ , lhaArchive(inFile)
+#endif
+#ifdef UNGZIP_SUPPORT
+ , gzipArchive(inFile)
+#endif
{
inFile.Rewind();
+#ifdef ZIPPED_MOD_SUPPORT
+ if(zipArchive.IsArchive()) { impl = &zipArchive; return; }
+#endif
+#ifdef UNRAR_SUPPORT
+ if(rarArchive.IsArchive()) { impl = &rarArchive; return; }
+#endif
+#ifdef UNLHA_SUPPORT
+ if(lhaArchive.IsArchive()) { impl = &lhaArchive; return; }
+#endif
+#ifdef UNGZIP_SUPPORT
+ if(gzipArchive.IsArchive()) { impl = &gzipArchive; return; }
+#endif
+ impl = &emptyArchive;
}
@@ -34,73 +56,141 @@
}
-bool CUnarchiver::IsArchive() const
-//---------------------------------
+struct find_str
{
- return false
-#ifdef ZIPPED_MOD_SUPPORT
- || zipArchive.IsArchive()
-#endif
-#ifdef UNRAR_SUPPORT
- || rarArchive.IsArchive()
-#endif
-#ifdef UNLHA_SUPPORT
- || lhaArchive.IsArchive()
-#endif
-#ifdef UNGZIP_SUPPORT
- || gzipArchive.IsArchive()
-#endif
- ;
-}
+ find_str(const char *str): s1(str) { }
+ bool operator() (const char *s2) const
+ {
+ return !strcmp(s1, s2);
+ }
+ const char *s1;
+};
-bool CUnarchiver::ExtractFile()
-//-----------------------------
+static inline std::string GetExtension(const std::string &filename)
+//-----------------------------------------------------------------
{
-#ifdef ZIPPED_MOD_SUPPORT
- if(zipArchive.IsArchive())
+ if(filename.find_last_of(".") != std::string::npos)
{
- if(!zipArchive.ExtractFile()) return false;
- outFile = zipArchive.GetOutputFile();
- return outFile.GetRawData()?true:false;
+ std::string ext = filename.substr(filename.find_last_of(".") + 1);
+ std::transform(ext.begin(), ext.end(), ext.begin(), tolower);
+ return ext;
}
-#endif
-#ifdef UNRAR_SUPPORT
- if(rarArchive.IsArchive())
+ return std::string();
+}
+
+
+std::size_t CUnarchiver::FindBestFile(const std::vector<const char *> &extensions)
+//--------------------------------------------------------------------------------
+{
+ if(!IsArchive())
{
- if(!rarArchive.ExtrFile()) return false;
- outFile = FileReader(rarArchive.GetOutputFile(), rarArchive.GetOutputFileLength());
- return outFile.GetRawData()?true:false;
+ return failIndex;
}
-#endif
-#ifdef UNLHA_SUPPORT
- if(lhaArchive.IsArchive())
+ uint64 biggestSize = 0;
+ std::size_t bestIndex = failIndex;
+ for(std::size_t i = 0; i < size(); ++i)
{
- if(!lhaArchive.ExtractFile()) return false;
- outFile = lhaArchive.GetOutputFile();
- return outFile.GetRawData()?true:false;
+ if(at(i).type != ArchiveFileNormal)
+ {
+ continue;
+ }
+ const std::string ext = GetExtension(at(i).name);
+
+ // Compare with list of preferred extensions
+ if(std::find_if(extensions.begin(), extensions.end(), find_str(ext.c_str())) != extensions.end())
+ {
+ bestIndex = i;
+ break;
+ }
+
+ if(ext == "diz" || ext == "nfo" || ext == "txt")
+ {
+ // we do not want these
+ continue;
+ }
+
+ if(at(i).size >= biggestSize)
+ {
+ biggestSize = at(i).size;
+ bestIndex = i;
+ }
}
-#endif
-#ifdef UNGZIP_SUPPORT
- if(gzipArchive.IsArchive())
- {
- if(!gzipArchive.ExtractFile()) return false;
- outFile = gzipArchive.GetOutputFile();
- return outFile.GetRawData()?true:false;
- }
-#endif
- return false;
+ return bestIndex;
}
-std::string CUnarchiver::GetComments()
-//------------------------------------
+bool CUnarchiver::ExtractBestFile(const std::vector<const char *> &extensions)
+//----------------------------------------------------------------------------
{
-#ifdef ZIPPED_MOD_SUPPORT
- if(zipArchive.IsArchive())
+ std::size_t bestFile = FindBestFile(extensions);
+ if(bestFile == failIndex)
{
- return zipArchive.GetComments();
+ return false;
}
-#endif
- return "";
+ return ExtractFile(bestFile);
}
+
+
+bool CUnarchiver::IsArchive() const
+//---------------------------------
+{
+ return impl->IsArchive();
+}
+
+
+std::string CUnarchiver::GetComment() const
+//-----------------------------------------
+{
+ return impl->GetComment();
+}
+
+
+bool CUnarchiver::ExtractFile(std::size_t index)
+//----------------------------------------------
+{
+ return impl->ExtractFile(index);
+}
+
+
+FileReader CUnarchiver::GetOutputFile() const
+//-------------------------------------------
+{
+ return impl->GetOutputFile();
+}
+
+
+std::size_t CUnarchiver::size() const
+//-----------------------------------
+{
+ return impl->size();
+}
+
+
+IArchive::const_iterator CUnarchiver::begin() const
+//-------------------------------------------------
+{
+ return impl->begin();
+}
+
+
+IArchive::const_iterator CUnarchiver::end() const
+//-----------------------------------------------
+{
+ return impl->end();
+}
+
+
+const ArchiveFileInfo & CUnarchiver::at(std::size_t index) const
+//--------------------------------------------------------------
+{
+ return impl->at(index);
+}
+
+
+const ArchiveFileInfo & CUnarchiver::operator [] (std::size_t index) const
+//------------------------------------------------------------------------
+{
+ return impl->operator[](index);
+}
+
Modified: trunk/OpenMPT/unarchiver/unarchiver.h
===================================================================
--- trunk/OpenMPT/unarchiver/unarchiver.h 2013-10-25 16:31:52 UTC (rev 3022)
+++ trunk/OpenMPT/unarchiver/unarchiver.h 2013-10-25 16:59:10 UTC (rev 3023)
@@ -11,6 +11,8 @@
#include "../soundlib/FileReader.h"
+#include "archive.h"
+
#define UNGZIP_SUPPORT
#define UNLHA_SUPPORT
#define UNRAR_SUPPORT
@@ -29,30 +31,85 @@
#include "ungzip.h"
#endif
-//===============
-class CUnarchiver
-//===============
+#ifdef UNRAR_SUPPORT
+class CWrappedRarArchive : public IArchive
{
-protected:
+private:
FileReader inFile;
- const std::vector<const char *> ext;
+ std::vector<ArchiveFileInfo> contents;
+ mutable CRarArchive rar;
+public:
+ CWrappedRarArchive(FileReader &inFile)
+ : inFile(inFile)
+ , rar((LPBYTE)inFile.GetRawData(), inFile.GetLength())
+ {
+ if(rar.IsArchive())
+ {
+ ArchiveFileInfo info;
+ info.type = ArchiveFileNormal;
+ contents.push_back(info);
+ }
+ }
+ virtual ~CWrappedRarArchive() { return; }
+public:
+ virtual bool IsArchive() const { return rar.IsArchive() == TRUE; }
+ virtual std::string GetComment() const { return std::string(); }
+ virtual bool ExtractFile(std::size_t index) { if(index >= contents.size()) { return false; } return rar.ExtrFile() == TRUE; }
+ virtual FileReader GetOutputFile() const { return FileReader(rar.GetOutputFile(), rar.GetOutputFileLength()); }
+ virtual std::size_t size() const { return contents.size(); }
+ virtual IArchive::const_iterator begin() const { return contents.begin(); }
+ virtual IArchive::const_iterator end() const { return contents.end(); }
+ virtual const ArchiveFileInfo & at(std::size_t index) const { return contents.at(index); }
+ virtual const ArchiveFileInfo & operator [] (std::size_t index) const { return contents[index]; }
+};
+#endif
+
+//=================================
+class CUnarchiver : public IArchive
+//=================================
+{
+
private:
+
+ IArchive *impl;
+
+ FileReader inFile;
+
+ ArchiveBase emptyArchive;
+#ifdef ZIPPED_MOD_SUPPORT
CZipArchive zipArchive;
- mutable CRarArchive rarArchive;
- mutable CLhaArchive lhaArchive;
+#endif
+#ifdef UNRAR_SUPPORT
+ CWrappedRarArchive rarArchive;
+#endif
+#ifdef UNLHA_SUPPORT
+ CLhaArchive lhaArchive;
+#endif
+#ifdef UNGZIP_SUPPORT
CGzipArchive gzipArchive;
+#endif
-protected:
- FileReader outFile;
+public:
+ CUnarchiver(FileReader &file);
+ virtual ~CUnarchiver();
+
+ virtual bool IsArchive() const;
+ virtual std::string GetComment() const;
+ virtual bool ExtractFile(std::size_t index);
+ virtual FileReader GetOutputFile() const;
+ virtual std::size_t size() const;
+ virtual IArchive::const_iterator begin() const;
+ virtual IArchive::const_iterator end() const;
+ virtual const ArchiveFileInfo & at(std::size_t index) const;
+ virtual const ArchiveFileInfo & operator [] (std::size_t index) const;
+
public:
- FileReader GetOutputFile() const { return outFile; }
- bool IsArchive() const;
- bool ExtractFile();
- std::string GetComments();
+ static const std::size_t failIndex = (std::size_t)-1;
- CUnarchiver(FileReader &file, const std::vector<const char *> &extensions);
- ~CUnarchiver();
+ std::size_t FindBestFile(const std::vector<const char *> &extensions);
+ bool ExtractBestFile(const std::vector<const char *> &extensions);
+
};
Modified: trunk/OpenMPT/unarchiver/ungzip.cpp
===================================================================
--- trunk/OpenMPT/unarchiver/ungzip.cpp 2013-10-25 16:31:52 UTC (rev 3022)
+++ trunk/OpenMPT/unarchiver/ungzip.cpp 2013-10-25 16:59:10 UTC (rev 3023)
@@ -20,42 +20,39 @@
#endif
-CGzipArchive::CGzipArchive(FileReader &file) : inFile(file)
-//---------------------------------------------------------
+CGzipArchive::CGzipArchive(FileReader &file) : ArchiveBase(file)
+//--------------------------------------------------------------
{
inFile.Rewind();
inFile.Read(header);
+
+ // Check header data + file size
+ if(header.magic1 != GZ_HMAGIC1 || header.magic2 != GZ_HMAGIC2 || header.method != GZ_HMDEFLATE || (header.flags & GZ_FRESERVED) != 0
+ || inFile.GetLength() <= sizeof(GZheader) + sizeof(GZtrailer))
+ {
+ return;
+ }
+ ArchiveFileInfo info;
+ info.type = ArchiveFileNormal;
+ contents.push_back(info);
}
CGzipArchive::~CGzipArchive()
//---------------------------
{
- delete[] outFile.GetRawData();
+ return;
}
-bool CGzipArchive::IsArchive() const
-//----------------------------------
+bool CGzipArchive::ExtractFile(std::size_t index)
+//-----------------------------------------------
{
- // Check header data + file size
- if(header.magic1 != GZ_HMAGIC1 || header.magic2 != GZ_HMAGIC2 || header.method != GZ_HMDEFLATE || (header.flags & GZ_FRESERVED) != 0
- || inFile.GetLength() <= sizeof(GZheader) + sizeof(GZtrailer))
+ if(index >= contents.size())
{
return false;
}
- return true;
-}
-
-bool CGzipArchive::ExtractFile()
-//------------------------------
-{
- if(!IsArchive())
- {
- return false;
- }
-
// Read trailer
GZtrailer trailer;
inFile.Seek(inFile.GetLength() - sizeof(GZtrailer));
@@ -94,10 +91,9 @@
return false;
}
- delete[] outFile.GetRawData();
-
- char *data = new (std::nothrow) char[trailer.isize];
- if(data == nullptr)
+ try {
+ data.resize(trailer.isize);
+ } catch(...)
{
return false;
}
@@ -114,21 +110,19 @@
return false;
}
strm.avail_out = trailer.isize;
- strm.next_out = (Bytef *)data;
+ strm.next_out = (Bytef *)&data[0];
int retVal = inflate(&strm, Z_NO_FLUSH);
inflateEnd(&strm);
// Everything went OK? Check return code, number of written bytes and CRC32.
- if(retVal == Z_STREAM_END && trailer.isize == strm.total_out && trailer.crc32_ == crc32(0, (Bytef *)data, trailer.isize))
+ if(retVal == Z_STREAM_END && trailer.isize == strm.total_out && trailer.crc32_ == crc32(0, (Bytef *)&data[0], trailer.isize))
{
// Success! :)
- outFile = FileReader(data, trailer.isize);
return true;
} else
{
// Fail :(
- delete[] outFile.GetRawData();
return false;
}
}
Modified: trunk/OpenMPT/unarchiver/ungzip.h
===================================================================
--- trunk/OpenMPT/unarchiver/ungzip.h 2013-10-25 16:31:52 UTC (rev 3022)
+++ trunk/OpenMPT/unarchiver/ungzip.h 2013-10-25 16:59:10 UTC (rev 3023)
@@ -9,12 +9,13 @@
#pragma once
-//================
-class CGzipArchive
-//================
+#include "archive.h"
+
+//=====================================
+class CGzipArchive : public ArchiveBase
+//=====================================
{
protected:
- FileReader inFile, outFile;
#ifdef NEEDS_PRAGMA_PACK
#pragma pack(push, 1)
@@ -72,10 +73,8 @@
public:
- FileReader GetOutputFile() const { return outFile; }
- bool IsArchive() const;
- bool ExtractFile();
+ bool ExtractFile(std::size_t index);
CGzipArchive(FileReader &file);
- ~CGzipArchive();
+ virtual ~CGzipArchive();
};
Modified: trunk/OpenMPT/unarchiver/unlha.cpp
===================================================================
--- trunk/OpenMPT/unarchiver/unlha.cpp 2013-10-25 16:31:52 UTC (rev 3022)
+++ trunk/OpenMPT/unarchiver/unlha.cpp 2013-10-25 16:59:10 UTC (rev 3023)
@@ -45,20 +45,35 @@
LHAcloseFileReader
};
-static inline std::string get_extension( std::string filename )
+
+CLhaArchive::CLhaArchive(FileReader &file) : ArchiveBase(file), inputstream(nullptr), reader(nullptr), firstfile(nullptr)
+//-----------------------------------------------------------------------------------------------------------------------
{
- if ( filename.find_last_of( "." ) != std::string::npos )
+ OpenArchive();
+ for(LHAFileHeader *fileheader = firstfile; fileheader; fileheader = lha_reader_next_file(reader))
{
- return filename.substr( filename.find_last_of( "." ) + 1 );
+ ArchiveFileInfo info;
+ info.name = fileheader->filename;
+ info.size = fileheader->length;
+ info.type = ArchiveFileNormal;
+ contents.push_back(info);
}
- return "";
+ CloseArchive();
}
-CLhaArchive::CLhaArchive(FileReader file_ ) : file(file_), inputstream(nullptr), reader(nullptr), firstfile(nullptr)
-//------------------------------------------------------------------------------------------------------------------
+CLhaArchive::~CLhaArchive()
+//-------------------------
{
- inputstream = lha_input_stream_new(&vtable, &file);
+ return;
+}
+
+
+void CLhaArchive::OpenArchive()
+//-----------------------------
+{
+ inFile.Rewind();
+ inputstream = lha_input_stream_new(&vtable, &inFile);
if(inputstream)
{
reader = lha_reader_new(inputstream);
@@ -71,8 +86,8 @@
}
-CLhaArchive::~CLhaArchive()
-//-------------------------
+void CLhaArchive::CloseArchive()
+//------------------------------
{
if(reader)
{
@@ -87,79 +102,49 @@
}
-bool CLhaArchive::IsArchive()
-//---------------------------
+bool CLhaArchive::ExtractFile(std::size_t index)
+//----------------------------------------------
{
- return firstfile != nullptr;
-}
-
-
-bool CLhaArchive::ExtractFile()
-//-----------------------------
-{
+ if(index >= contents.size())
+ {
+ return false;
+ }
+ data.clear();
+ OpenArchive();
const std::size_t bufSize = 4096;
+ std::size_t i = 0;
for(LHAFileHeader *fileheader = firstfile; fileheader; fileheader = lha_reader_next_file(reader))
{
- // get the biggest file
- if(fileheader->length >= data.size())
+ if(index == i)
{
data.clear();
std::size_t countRead = 0;
do
{
- data.resize(data.size() + bufSize);
+ try
+ {
+ data.resize(data.size() + bufSize);
+ } catch(...)
+ {
+ CloseArchive();
+ return false;
+ }
countRead = lha_reader_read(reader, &data[data.size() - bufSize], bufSize);
if(countRead < bufSize)
{
- data.resize(data.size() - (bufSize - countRead));
+ try
+ {
+ data.resize(data.size() - (bufSize - countRead));
+ } catch(...)
+ {
+ CloseArchive();
+ return false;
+ }
}
} while(countRead > 0);
}
+ ++i;
}
+ CloseArchive();
return data.size() > 0;
}
-
-
-bool CLhaArchive::ExtractFile(const std::vector<const char *> &extensions)
-//------------------------------------------------------------------------
-{
- const std::size_t bufSize = 4096;
- for(LHAFileHeader *fileheader = firstfile; fileheader; fileheader = lha_reader_next_file(reader))
- {
- if(fileheader->filename)
- {
- std::string ext = get_extension(fileheader->filename);
- if(!ext.empty())
- {
- std::transform(ext.begin(), ext.end(), ext.begin(), tolower);
- if(std::find(extensions.begin(), extensions.end(), ext) != extensions.end())
- {
- data.clear();
- std::size_t countRead = 0;
- do
- {
- data.resize(data.size() + bufSize);
- countRead = lha_reader_read(reader, &data[data.size() - bufSize], bufSize);
- if(countRead < bufSize)
- {
- data.resize(data.size() - (bufSize - countRead));
- }
- } while(countRead > 0);
- return true;
- }
- }
- }
- }
- return false;
-}
-
-
-FileReader CLhaArchive::GetOutputFile() const
-//-------------------------------------------
-{
- if(data.size() == 0)
- {
- return FileReader();
- }
- return FileReader(&data[0], data.size());
-}
Modified: trunk/OpenMPT/unarchiver/unlha.h
===================================================================
--- trunk/OpenMPT/unarchiver/unlha.h 2013-10-25 16:31:52 UTC (rev 3022)
+++ trunk/OpenMPT/unarchiver/unlha.h 2013-10-25 16:59:10 UTC (rev 3023)
@@ -9,28 +9,25 @@
#pragma once
-#include "../soundlib/FileReader.h"
+#include "archive.h"
typedef struct _LHAInputStream LHAInputStream;
typedef struct _LHAReader LHAReader;
typedef struct _LHAFileHeader LHAFileHeader;
-//===============
-class CLhaArchive
-//===============
+//====================================
+class CLhaArchive : public ArchiveBase
+//====================================
{
private:
- FileReader file;
LHAInputStream *inputstream;
LHAReader *reader;
LHAFileHeader *firstfile;
- std::vector<char> data;
+ void OpenArchive();
+ void CloseArchive();
public:
- CLhaArchive(FileReader file_);
- ~CLhaArchive();
+ CLhaArchive(FileReader &file);
+ virtual ~CLhaArchive();
public:
- bool IsArchive();
- FileReader GetOutputFile() const;
- bool ExtractFile();
- bool ExtractFile(const std::vector<const char *> &extensions);
+ virtual bool ExtractFile(std::size_t index);
};
Modified: trunk/OpenMPT/unarchiver/unzip.cpp
===================================================================
--- trunk/OpenMPT/unarchiver/unzip.cpp 2013-10-25 16:31:52 UTC (rev 3022)
+++ trunk/OpenMPT/unarchiver/unzip.cpp 2013-10-25 16:59:10 UTC (rev 3023)
@@ -10,10 +10,10 @@
#include "stdafx.h"
#include "../soundlib/FileReader.h"
-#include <vector>
#include "unzip.h"
#include "../common/misc_util.h"
#include <algorithm>
+#include <vector>
#if !defined(NO_ZLIB)
#include <contrib/minizip/unzip.h>
@@ -97,8 +97,8 @@
};
-CZipArchive::CZipArchive(FileReader &file, const std::vector<const char *> &ext) : inFile(file), extensions(ext)
-//--------------------------------------------------------------------------------------------------------------
+CZipArchive::CZipArchive(FileReader &file) : ArchiveBase(file)
+//------------------------------------------------------------
{
zlib_filefunc_def functions =
{
@@ -112,142 +112,113 @@
&inFile
};
zipFile = unzOpen2(nullptr, &functions);
-}
+ if(zipFile == nullptr)
+ {
+ return;
+ }
-CZipArchive::~CZipArchive()
-//-------------------------
-{
- unzClose(zipFile);
- delete[] outFile.GetRawData();
-}
-
-
-bool CZipArchive::IsArchive() const
-//---------------------------------
-{
- return (zipFile != nullptr);
-}
-
-
-struct find_str
-{
- find_str(const char *str): s1(str) { }
-
- bool operator() (const char *s2) const
+ // read comment
{
- return !strcmp(s1, s2);
+ unz_global_info info;
+ if(unzGetGlobalInfo(zipFile, &info) == UNZ_OK)
+ {
+ if(info.size_comment > 0)
+ {
+ if(info.size_comment < Util::MaxValueOfType(info.size_comment))
+ {
+ info.size_comment++;
+ }
+ std::vector<char> commentData(info.size_comment);
+ if(unzGetGlobalComment(zipFile, &commentData[0], info.size_comment) >= 0)
+ {
+ commentData[info.size_comment - 1] = '\0';
+ comment = &commentData[0];
+ }
+ }
+ }
}
- const char *s1;
-};
-
-
-bool CZipArchive::ExtractFile()
-//-----------------------------
-{
+ // read contents
unz_file_pos bestFile;
unz_file_info info;
- uLong biggestFile = 0;
int status = unzGoToFirstFile(zipFile);
unzGetFilePos(zipFile, &bestFile);
while(status == UNZ_OK)
{
+ ArchiveFileInfo fileinfo;
+
+ fileinfo.type = ArchiveFileNormal;
+
char name[256];
unzGetCurrentFileInfo(zipFile, &info, name, sizeof(name), nullptr, 0, nullptr, 0);
+ fileinfo.name = name;
+ fileinfo.size = info.uncompressed_size;
- // Extract file extension
- char *ext = name + info.size_filename;
- while(ext > name)
- {
- ext--;
- *ext = static_cast<char>(tolower(*ext));
- if(*ext == '.')
- {
- ext++;
- break;
- }
- }
+ unzGetFilePos(zipFile, &bestFile);
+ fileinfo.cookie1 = bestFile.pos_in_zip_directory;
+ fileinfo.cookie2 = bestFile.num_of_file;
- // Compare with list of preferred extensions
- if(std::find_if(extensions.begin(), extensions.end(), find_str(ext)) != extensions.end())
- {
- // File has a preferred extension: use it.
- unzGetFilePos(zipFile, &bestFile);
- break;
- }
+ contents.push_back(fileinfo);
- if(strcmp(ext, "diz")
- && strcmp(ext, "nfo")
- && strcmp(ext, "txt")
- && info.uncompressed_size >= biggestFile)
- {
- // If this isn't some kind of info file, we should maybe pick it.
- unzGetFilePos(zipFile, &bestFile);
- biggestFile = info.uncompressed_size;
- }
-
status = unzGoToNextFile(zipFile);
}
- if(unzGoToFilePos(zipFile, &bestFile) == UNZ_OK && unzOpenCurrentFile(zipFile) == UNZ_OK)
- {
- unzGetCurrentFileInfo(zipFile, &info, nullptr, 0, nullptr, 0, nullptr, 0);
-
- delete[] outFile.GetRawData();
- char *data = new (std::nothrow) char[info.uncompressed_size];
- if(data != nullptr)
- {
- unzReadCurrentFile(zipFile, data, info.uncompressed_size);
- outFile = FileReader(data, info.uncompressed_size);
- }
- unzCloseCurrentFile(zipFile);
+}
- return (data != nullptr);
- }
- return false;
+CZipArchive::~CZipArchive()
+//-------------------------
+{
+ unzClose(zipFile);
}
-std::string CZipArchive::GetComments()
-//------------------------------------
+bool CZipArchive::ExtractFile(std::size_t index)
+//----------------------------------------------
{
- unz_global_info info;
- if(zipFile == nullptr || unzGetGlobalInfo(zipFile, &info) != UNZ_OK)
+ if(index >= contents.size())
{
- return "";
+ return false;
}
- if(info.size_comment > 0)
+ data.clear();
+
+ unz_file_pos bestFile;
+ unz_file_info info;
+
+ bestFile.pos_in_zip_directory = static_cast<uLong>(contents[index].cookie1);
+ bestFile.num_of_file = static_cast<uLong>(contents[index].cookie2);
+
+ if(unzGoToFilePos(zipFile, &bestFile) == UNZ_OK && unzOpenCurrentFile(zipFile) == UNZ_OK)
{
- if(info.size_comment < Util::MaxValueOfType(info.size_comment))
+ unzGetCurrentFileInfo(zipFile, &info, nullptr, 0, nullptr, 0, nullptr, 0);
+
+ try
{
- info.size_comment++;
- }
- char *comment = new (std::nothrow) char[info.size_comment];
- if(comment != nullptr && unzGetGlobalComment(zipFile, comment, info.size_comment) >= 0)
+ data.resize(info.uncompressed_size);
+ } catch(...)
{
- comment[info.size_comment - 1] = '\0';
- std::string result = comment;
- delete[] comment;
- return result;
- } else
- {
- delete[] comment;
+ unzCloseCurrentFile(zipFile);
+ return false;
}
+ unzReadCurrentFile(zipFile, &data[0], info.uncompressed_size);
+ unzCloseCurrentFile(zipFile);
+
+ return true;
}
- return "";
+
+ return false;
}
#elif !defined(NO_MINIZ)
-CZipArchive::CZipArchive(FileReader &file, const std::vector<const char *> &ext) : inFile(file), extensions(ext)
-//--------------------------------------------------------------------------------------------------------------
+CZipArchive::CZipArchive(FileReader &file) : ArchiveBase(file)
+//------------------------------------------------------------
{
zipFile = new mz_zip_archive();
@@ -257,9 +228,37 @@
if(!mz_zip_reader_init_mem(zip, file.GetRawData(), file.GetLength(), 0))
{
delete zip;
+ zip = nullptr;
zipFile = nullptr;
}
+ if(!zip)
+ {
+ return;
+ }
+
+ for(mz_uint i = 0; i < mz_zip_reader_get_num_files(zip); ++i)
+ {
+ ArchiveFileInfo info;
+ info.type = ArchiveFileInvalid;
+ mz_zip_archive_file_stat stat;
+ MemsetZero(stat);
+ if(mz_zip_reader_file_stat(zip, i, &stat))
+ {
+ info.type = ArchiveFileNormal;
+ info.name = stat.m_filename;
+ info.size = stat.m_uncomp_size;
+ }
+ if(mz_zip_reader_is_file_a_directory(zip, i))
+ {
+ info.type = ArchiveFileSpecial;
+ } else if(mz_zip_reader_is_file_encrypted(zip, i))
+ {
+ info.type = ArchiveFileSpecial;
+ }
+ contents.push_back(info);
+ }
+
}
@@ -276,106 +275,42 @@
zipFile = nullptr;
}
- delete[] outFile.GetRawData();
}
-bool CZipArchive::IsArchive() const
-//---------------------------------
+bool CZipArchive::ExtractFile(std::size_t index)
+//----------------------------------------------
{
- return (zipFile != nullptr);
-}
+ mz_zip_archive *zip = static_cast<mz_zip_archive*>(zipFile);
-
-static inline std::string GetExtension(const std::string &filename)
-//-----------------------------------------------------------------
-{
- if(filename.find_last_of(".") != std::string::npos)
+ if(index >= contents.size())
{
- return filename.substr(filename.find_last_of(".") + 1);
+ return false;
}
- return std::string();
-}
+ mz_uint bestFile = index;
-bool CZipArchive::ExtractFile()
-//-----------------------------
-{
- mz_zip_archive *zip = static_cast<mz_zip_archive*>(zipFile);
-
- if(!zip)
+ mz_zip_archive_file_stat stat;
+ MemsetZero(stat);
+ mz_zip_reader_file_stat(zip, bestFile, &stat);
+ if(stat.m_uncomp_size >= std::numeric_limits<std::size_t>::max())
{
return false;
}
-
- mz_uint bestFile = (mz_uint)-1;
- mz_uint64 biggestFile = 0;
- for(mz_uint i = 0; i < mz_zip_reader_get_num_files(zip); ++i)
+ try
{
- mz_zip_archive_file_stat stat;
- MemsetZero(stat);
- if(!mz_zip_reader_file_stat(zip, i, &stat))
- {
- continue;
- }
- if(mz_zip_reader_is_file_a_directory(zip, i))
- {
- continue;
- }
- if(mz_zip_reader_is_file_encrypted(zip, i))
- {
- continue;
- }
- std::string ext = GetExtension(stat.m_filename);
- if(std::find(extensions.begin(), extensions.end(), ext) != extensions.end())
- {
- // File has a preferred extension: use it.
- bestFile = i;
- break;
- }
- if(ext != "diz" && ext != "nfo" && ext != "txt" && stat.m_uncomp_size >= biggestFile)
- {
- // If this isn't some kind of info file, we should maybe pick it.
- bestFile = i;
- biggestFile = stat.m_uncomp_size;
- }
- }
- if(bestFile == (mz_uint)-1)
+ data.resize(static_cast<std::size_t>(stat.m_uncomp_size));
+ } catch(...)
{
return false;
}
- delete [] outFile.GetRawData();
- mz_zip_archive_file_stat stat;
- MemsetZero(stat);
- mz_zip_reader_file_stat(zip, bestFile, &stat);
- char *data = new (std::nothrow) char[stat.m_uncomp_size];
- if(data != nullptr)
+ if(!mz_zip_reader_extract_to_mem(zip, bestFile, &data[0], static_cast<std::size_t>(stat.m_uncomp_size), 0))
{
- if(!mz_zip_reader_extract_to_mem(zip, bestFile, data, stat.m_uncomp_size, 0))
- {
- delete [] data;
- return false;
- }
- outFile = FileReader(data, stat.m_uncomp_size);
- comment = std::string(stat.m_comment, stat.m_comment + stat.m_comment_size);
+ return false;
}
-
+ comment = std::string(stat.m_comment, stat.m_comment + stat.m_comment_size);
return true;
}
-std::string CZipArchive::GetComments()
-//------------------------------------
-{
- mz_zip_archive *zip = static_cast<mz_zip_archive*>(zipFile);
-
- if(!zip)
- {
- return "";
- }
-
- return comment;
-}
-
-
#endif // NO_ZLIB || NO_MINIZ
Modified: trunk/OpenMPT/unarchiver/unzip.h
===================================================================
--- trunk/OpenMPT/unarchiver/unzip.h 2013-10-25 16:31:52 UTC (rev 3022)
+++ trunk/OpenMPT/unarchiver/unzip.h 2013-10-25 16:59:10 UTC (rev 3023)
@@ -9,23 +9,17 @@
#pragma once
-//===============
-class CZipArchive
-//===============
+#include "archive.h"
+
+//====================================
+class CZipArchive : public ArchiveBase
+//====================================
{
protected:
- FileReader inFile, outFile;
void *zipFile;
- const std::vector<const char *> &extensions;
- std::string comment;
-
public:
-
- FileReader GetOutputFile() const { return outFile; }
- bool IsArchive() const;
- bool ExtractFile();
- std::string GetComments();
-
- CZipArchive(FileReader &file, const std::vector<const char *> &ext);
- ~CZipArchive();
+ CZipArchive(FileReader &file);
+ virtual ~CZipArchive();
+public:
+ virtual bool ExtractFile(std::size_t index);
};
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <man...@us...> - 2013-10-26 08:41:35
|
Revision: 3032
http://sourceforge.net/p/modplug/code/3032
Author: manxorist
Date: 2013-10-26 08:41:27 +0000 (Sat, 26 Oct 2013)
Log Message:
-----------
[Ref] sounddev: Make some functions and variable names more clear.
Modified Paths:
--------------
trunk/OpenMPT/mptrack/MainFrm.cpp
trunk/OpenMPT/sounddev/SoundDevice.cpp
trunk/OpenMPT/sounddev/SoundDevice.h
trunk/OpenMPT/sounddev/SoundDevicePortAudio.cpp
trunk/OpenMPT/sounddev/SoundDevicePortAudio.h
trunk/OpenMPT/sounddev/SoundDeviceWaveout.cpp
trunk/OpenMPT/sounddev/SoundDeviceWaveout.h
Modified: trunk/OpenMPT/mptrack/MainFrm.cpp
===================================================================
--- trunk/OpenMPT/mptrack/MainFrm.cpp 2013-10-26 07:42:58 UTC (rev 3031)
+++ trunk/OpenMPT/mptrack/MainFrm.cpp 2013-10-26 08:41:27 UTC (rev 3032)
@@ -654,7 +654,7 @@
int64 currenttotalsamples = 0;
if(gpSoundDevice)
{
- currenttotalsamples = gpSoundDevice->GetStreamPositionSamples();
+ currenttotalsamples = gpSoundDevice->GetStreamPositionFrames();
}
{
// advance to the newest notification, drop the obsolete ones
Modified: trunk/OpenMPT/sounddev/SoundDevice.cpp
===================================================================
--- trunk/OpenMPT/sounddev/SoundDevice.cpp 2013-10-26 07:42:58 UTC (rev 3031)
+++ trunk/OpenMPT/sounddev/SoundDevice.cpp 2013-10-26 08:41:27 UTC (rev 3032)
@@ -43,8 +43,8 @@
m_RealUpdateIntervalMS = static_cast<float>(m_Settings.UpdateIntervalMS);
m_IsPlaying = false;
- m_FramesStreamRenderPosition = 0;
- m_FramesStreamOutputPosition = 0;
+ m_StreamPositionRenderFrames = 0;
+ m_StreamPositionOutputFrames = 0;
}
@@ -155,9 +155,9 @@
int64 framesRendered = 0;
{
Util::lock_guard<Util::mutex> lock(m_StreamPositionMutex);
- m_FramesStreamRenderPosition += numFrames;
- m_FramesStreamOutputPosition = m_FramesStreamRenderPosition - framesLatency;
- framesRendered = m_FramesStreamRenderPosition;
+ m_StreamPositionRenderFrames += numFrames;
+ m_StreamPositionOutputFrames = m_StreamPositionRenderFrames - framesLatency;
+ framesRendered = m_StreamPositionRenderFrames;
}
m_Source->AudioDone(m_Settings, numFrames, framesRendered);
}
@@ -181,8 +181,8 @@
{
{
Util::lock_guard<Util::mutex> lock(m_StreamPositionMutex);
- m_FramesStreamRenderPosition = 0;
- m_FramesStreamOutputPosition = 0;
+ m_StreamPositionRenderFrames = 0;
+ m_StreamPositionOutputFrames = 0;
}
InternalStart();
m_IsPlaying = true;
@@ -200,24 +200,24 @@
m_IsPlaying = false;
{
Util::lock_guard<Util::mutex> lock(m_StreamPositionMutex);
- m_FramesStreamRenderPosition = 0;
- m_FramesStreamOutputPosition = 0;
+ m_StreamPositionRenderFrames = 0;
+ m_StreamPositionOutputFrames = 0;
}
}
}
-int64 ISoundDevice::GetStreamPositionSamples() const
+int64 ISoundDevice::GetStreamPositionFrames() const
//--------------------------------------------------
{
if(!IsOpen()) return 0;
if(InternalHasGetStreamPosition())
{
- return InternalGetStreamPositionSamples();
+ return InternalGetStreamPositionFrames();
} else
{
Util::lock_guard<Util::mutex> lock(m_StreamPositionMutex);
- return m_FramesStreamOutputPosition;
+ return m_StreamPositionOutputFrames;
}
}
Modified: trunk/OpenMPT/sounddev/SoundDevice.h
===================================================================
--- trunk/OpenMPT/sounddev/SoundDevice.h 2013-10-26 07:42:58 UTC (rev 3031)
+++ trunk/OpenMPT/sounddev/SoundDevice.h 2013-10-26 08:41:27 UTC (rev 3032)
@@ -234,8 +234,8 @@
bool m_IsPlaying;
mutable Util::mutex m_StreamPositionMutex;
- int64 m_FramesStreamRenderPosition;
- int64 m_FramesStreamOutputPosition;
+ int64 m_StreamPositionRenderFrames;
+ int64 m_StreamPositionOutputFrames;
protected:
virtual void FillAudioBuffer() = 0;
@@ -273,14 +273,14 @@
virtual void InternalStop() = 0;
virtual bool InternalClose() = 0;
virtual bool InternalHasGetStreamPosition() const { return false; }
- virtual int64 InternalGetStreamPositionSamples() const { return 0; }
+ virtual int64 InternalGetStreamPositionFrames() const { return 0; }
public:
bool Open(const SoundDeviceSettings &settings);
bool Close();
void Start();
void Stop();
- int64 GetStreamPositionSamples() const;
+ int64 GetStreamPositionFrames() const;
SampleFormat GetActualSampleFormat() { return IsOpen() ? m_Settings.sampleFormat : SampleFormatInvalid; }
virtual bool IsOpen() const = 0;
virtual UINT GetNumBuffers() { return 0; }
Modified: trunk/OpenMPT/sounddev/SoundDevicePortAudio.cpp
===================================================================
--- trunk/OpenMPT/sounddev/SoundDevicePortAudio.cpp 2013-10-26 07:42:58 UTC (rev 3031)
+++ trunk/OpenMPT/sounddev/SoundDevicePortAudio.cpp 2013-10-26 08:41:27 UTC (rev 3032)
@@ -135,7 +135,7 @@
}
-int64 CPortaudioDevice::InternalGetStreamPositionSamples() const
+int64 CPortaudioDevice::InternalGetStreamPositionFrames() const
//--------------------------------------------------------------
{
if(Pa_IsStreamActive(m_Stream) != 1) return 0;
Modified: trunk/OpenMPT/sounddev/SoundDevicePortAudio.h
===================================================================
--- trunk/OpenMPT/sounddev/SoundDevicePortAudio.h 2013-10-26 07:42:58 UTC (rev 3031)
+++ trunk/OpenMPT/sounddev/SoundDevicePortAudio.h 2013-10-26 08:41:27 UTC (rev 3032)
@@ -52,7 +52,7 @@
UINT GetNumBuffers() { return 1; }
float GetCurrentRealLatencyMS();
bool InternalHasGetStreamPosition() const { return false; }
- int64 InternalGetStreamPositionSamples() const;
+ int64 InternalGetStreamPositionFrames() const;
SoundDeviceCaps GetDeviceCaps(const std::vector<uint32> &baseSampleRates);
int StreamCallback(
Modified: trunk/OpenMPT/sounddev/SoundDeviceWaveout.cpp
===================================================================
--- trunk/OpenMPT/sounddev/SoundDeviceWaveout.cpp 2013-10-26 07:42:58 UTC (rev 3031)
+++ trunk/OpenMPT/sounddev/SoundDeviceWaveout.cpp 2013-10-26 08:41:27 UTC (rev 3032)
@@ -100,6 +100,7 @@
return true;
}
+
bool CWaveDevice::InternalClose()
//-------------------------------
{
@@ -183,7 +184,7 @@
}
-int64 CWaveDevice::InternalGetStreamPositionSamples() const
+int64 CWaveDevice::InternalGetStreamPositionFrames() const
//---------------------------------------------------------
{
MMTIME mmtime;
Modified: trunk/OpenMPT/sounddev/SoundDeviceWaveout.h
===================================================================
--- trunk/OpenMPT/sounddev/SoundDeviceWaveout.h 2013-10-26 07:42:58 UTC (rev 3031)
+++ trunk/OpenMPT/sounddev/SoundDeviceWaveout.h 2013-10-26 08:41:27 UTC (rev 3032)
@@ -48,7 +48,7 @@
UINT GetNumBuffers() { return m_nPreparedHeaders; }
float GetCurrentRealLatencyMS() { return InterlockedExchangeAdd(&m_nBuffersPending, 0) * m_nWaveBufferSize * 1000.0f / m_Settings.GetBytesPerSecond(); }
bool InternalHasGetStreamPosition() const { return true; }
- int64 InternalGetStreamPositionSamples() const;
+ int64 InternalGetStreamPositionFrames() const;
public:
static void CALLBACK WaveOutCallBack(HWAVEOUT, UINT uMsg, DWORD_PTR, DWORD_PTR dw1, DWORD_PTR dw2);
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <man...@us...> - 2013-10-26 12:24:11
|
Revision: 3038
http://sourceforge.net/p/modplug/code/3038
Author: manxorist
Date: 2013-10-26 12:24:03 +0000 (Sat, 26 Oct 2013)
Log Message:
-----------
[Ref] serialization-utils: Read and Write functionalities share almost no code or data at all. Trivially seperate them into two seperate classes with a tiny common base class.
Modified Paths:
--------------
trunk/OpenMPT/common/serialization_utils.cpp
trunk/OpenMPT/common/serialization_utils.h
trunk/OpenMPT/soundlib/Load_it.cpp
trunk/OpenMPT/soundlib/ModSequence.cpp
trunk/OpenMPT/soundlib/pattern.cpp
trunk/OpenMPT/soundlib/patternContainer.cpp
trunk/OpenMPT/soundlib/tuning.cpp
trunk/OpenMPT/soundlib/tuningCollection.cpp
Modified: trunk/OpenMPT/common/serialization_utils.cpp
===================================================================
--- trunk/OpenMPT/common/serialization_utils.cpp 2013-10-26 10:31:29 UTC (rev 3037)
+++ trunk/OpenMPT/common/serialization_utils.cpp 2013-10-26 12:24:03 UTC (rev 3038)
@@ -250,45 +250,44 @@
const char strReadNote[] = "Read note: ";
-#define SSB_INITIALIZATION_LIST \
- m_Status(SNT_NONE), \
- m_nFixedEntrySize(0), \
- m_posStart(0), \
- m_nReadVersion(0), \
- m_nMaxReadEntryCount(16000), \
- m_rposMapBegin(0), \
- m_posMapEnd(0), \
- m_posDataBegin(0), \
- m_rposEndofHdrData(0), \
- m_nReadEntrycount(0), \
- m_nIdbytes(IdSizeVariable), \
- m_nCounter(0), \
- m_nNextReadHint(0), \
- m_Flags(s_DefaultFlags), \
- m_nMapReserveSize(0), \
- m_posEntrycount(0), \
- m_posMapPosField(0), \
- m_posMapStart(0) \
+Ssb::Ssb()
+ : m_Status(SNT_NONE)
+ , m_nFixedEntrySize(0)
+ , m_posStart(0)
+ , m_nIdbytes(IdSizeVariable)
+ , m_nCounter(0)
+ , m_Flags((1 << RwfWMapStartPosEntry) + (1 << RwfWMapSizeEntry) + (1 << RwfWVersionNum) + (1 << RwfRPartialIdMatch))
+{
+ return;
+}
-Ssb::Ssb(std::ostream& oStrm) :
- m_pOstrm(&oStrm),
- m_pIstrm(nullptr),
- SSB_INITIALIZATION_LIST
-//------------------------------
-{}
+SsbWrite::SsbWrite(std::ostream& oStrm)
+ : m_pOstrm(&oStrm)
+ , m_nMapReserveSize(0)
+ , m_posEntrycount(0)
+ , m_posMapPosField(0)
+ , m_posMapStart(0)
+{
+ return;
+}
-Ssb::Ssb(std::istream& iStrm) :
- m_pOstrm(nullptr),
- m_pIstrm(&iStrm),
- SSB_INITIALIZATION_LIST
-//------------------------------
-{}
+SsbRead::SsbRead(std::istream& iStrm)
+ : m_pIstrm(&iStrm)
+ , m_nReadVersion(0)
+ , m_nMaxReadEntryCount(16000)
+ , m_rposMapBegin(0)
+ , m_posMapEnd(0)
+ , m_posDataBegin(0)
+ , m_rposEndofHdrData(0)
+ , m_nReadEntrycount(0)
+ , m_nNextReadHint(0)
+{
+ return;
+}
-#undef SSB_INITIALIZATION_LIST
-
typedef void (*fpLogFunc_t)(const char*, ...);
static fpLogFunc_t const m_fpLogFunc = nullptr; // Pointer to log function.
@@ -311,11 +310,11 @@
m_fpLogFunc("%s: 0x%x\n", sz, s);
}
-void Ssb::AddWriteNote(const SsbStatus s) {AddNote(s, strWriteNote);}
-void Ssb::AddReadNote(const SsbStatus s) {AddNote(s, strReadNote);}
+void SsbWrite::AddWriteNote(const SsbStatus s) {AddNote(s, strWriteNote);}
+void SsbRead::AddReadNote(const SsbStatus s) {AddNote(s, strReadNote);}
-void Ssb::AddReadNote(const ReadEntry* const pRe, const NumType nNum)
+void SsbRead::AddReadNote(const ReadEntry* const pRe, const NumType nNum)
//-------------------------------------------------------------------
{
m_Status |= SNT_PROGRESS;
@@ -334,7 +333,7 @@
// Called after writing an entry.
-void Ssb::AddWriteNote(const char* pId, const size_t nIdSize, const NumType nEntryNum, const DataSize nBytecount, const RposType rposStart)
+void SsbWrite::AddWriteNote(const char* pId, const size_t nIdSize, const NumType nEntryNum, const DataSize nBytecount, const RposType rposStart)
//----------------------------------------------------------------------------
{
m_Status |= SNT_PROGRESS;
@@ -347,7 +346,7 @@
}
-void Ssb::ResetReadstatus()
+void SsbRead::ResetReadstatus()
//-------------------------
{
m_Status = SNT_NONE;
@@ -356,7 +355,7 @@
}
-void Ssb::WriteMapItem( const char* pId,
+void SsbWrite::WriteMapItem( const char* pId,
const size_t nIdSize,
const RposType& rposDataStart,
const DataSize& nDatasize,
@@ -390,7 +389,7 @@
}
-void Ssb::ReserveMapSize(uint32 nSize)
+void SsbWrite::ReserveMapSize(uint32 nSize)
//------------------------------------
{
std::ostream& oStrm = *m_pOstrm;
@@ -404,7 +403,7 @@
}
-void Ssb::SetIdSize(uint16 nSize)
+void SsbWrite::SetIdSize(uint16 nSize)
//-------------------------------
{
if (nSize == IdSizeVariable || nSize > IdSizeMaxFixedSize)
@@ -414,7 +413,7 @@
}
-void Ssb::IncrementWriteCounter()
+void SsbWrite::IncrementWriteCounter()
//-------------------------------
{
m_nCounter++;
@@ -426,7 +425,7 @@
}
-void Ssb::BeginWrite(const char* pId, const size_t nIdSize, const uint64& nVersion)
+void SsbWrite::BeginWrite(const char* pId, const size_t nIdSize, const uint64& nVersion)
//---------------------------------------------------------------------------------
{
std::ostream& oStrm = *m_pOstrm;
@@ -505,7 +504,7 @@
}
-Ssb::ReadRv Ssb::OnReadEntry(const ReadEntry* pE, const char* pId, const size_t nIdSize, const Postype& posReadBegin)
+SsbRead::ReadRv SsbRead::OnReadEntry(const ReadEntry* pE, const char* pId, const size_t nIdSize, const Postype& posReadBegin)
//-------------------------------------------------------------------------------------------------------------------
{
if (pE != nullptr)
@@ -528,7 +527,7 @@
}
-void Ssb::OnWroteItem(const char* pId, const size_t nIdSize, const Postype& posBeforeWrite)
+void SsbWrite::OnWroteItem(const char* pId, const size_t nIdSize, const Postype& posBeforeWrite)
//-----------------------------------------------------------------------------------------
{
const Offtype nRawEntrySize = m_pOstrm->tellp() - posBeforeWrite;
@@ -562,7 +561,7 @@
}
-void Ssb::CompareId(std::istream& iStrm, const char* pId, const size_t nIdlength)
+void SsbRead::CompareId(std::istream& iStrm, const char* pId, const size_t nIdlength)
//---------------------------------------------------------------------------
{
uint8 tempU8 = 0;
@@ -581,7 +580,7 @@
}
-void Ssb::BeginRead(const char* pId, const size_t nLength, const uint64& nVersion)
+void SsbRead::BeginRead(const char* pId, const size_t nLength, const uint64& nVersion)
//---------------------------------------------------------------------------------
{
std::istream& iStrm = *m_pIstrm;
@@ -726,7 +725,7 @@
}
-void Ssb::CacheMap()
+void SsbRead::CacheMap()
//------------------
{
std::istream& iStrm = *m_pIstrm;
@@ -820,7 +819,7 @@
}
-const ReadEntry* Ssb::Find(const char* pId, const size_t nIdLength)
+const ReadEntry* SsbRead::Find(const char* pId, const size_t nIdLength)
//-----------------------------------------------------------------
{
m_pIstrm->clear();
@@ -850,7 +849,7 @@
}
-void Ssb::FinishWrite()
+void SsbWrite::FinishWrite()
//---------------------
{
std::ostream& oStrm = *m_pOstrm;
Modified: trunk/OpenMPT/common/serialization_utils.h
===================================================================
--- trunk/OpenMPT/common/serialization_utils.h 2013-10-26 10:31:29 UTC (rev 3037)
+++ trunk/OpenMPT/common/serialization_utils.h 2013-10-26 12:24:03 UTC (rev 3038)
@@ -259,11 +259,59 @@
}
+
class Ssb
-//=======
{
+
+protected:
+
+ Ssb();
+
public:
+ // When writing, returns the number of entries written.
+ // When reading, returns the number of entries read not including unrecognized entries.
+ NumType GetCounter() const {return m_nCounter;}
+
+ void SetFlag(Rwf flag, bool val) {m_Flags.set(flag, val);}
+ bool GetFlag(Rwf flag) const {return m_Flags[flag];}
+
+ // Write given string to log if log func is defined.
+ void AddToLog(const char *psz);
+
+protected:
+
+ void AddNote(const SsbStatus s, const char* sz);
+
+public:
+
+ SsbStatus m_Status;
+ uint32 m_nFixedEntrySize; // Read/write: If > 0, data entries have given fixed size.
+
+protected:
+
+ Postype m_posStart; // Read/write: Stream position at the beginning of object.
+
+ uint16 m_nIdbytes; // Read/Write: Tells map ID entry size in bytes. If size is variable, value is IdSizeVariable.
+ NumType m_nCounter; // Read/write: Keeps count of entries written/read.
+
+ std::bitset<RwfNumFlags> m_Flags; // Read/write: Various flags.
+
+public:
+
+ static const uint8 s_DefaultFlagbyte = 0;
+ static const char s_EntryID[3];
+
+};
+
+
+
+class SsbRead
+ : public Ssb
+{
+
+public:
+
enum ReadRv // Read return value.
{
EntryRead,
@@ -275,25 +323,12 @@
};
typedef std::vector<ReadEntry>::const_iterator ReadIterator;
- Ssb(std::ostream& oStrm);
- Ssb(std::istream& iStrm);
+ SsbRead(std::istream& iStrm);
- ~Ssb() {}
-
- // Sets map ID size in writing.
- void SetIdSize(uint16 idSize);
-
- // Write header
- void BeginWrite(const char* pId, const size_t nIdSize, const uint64& nVersion);
- void BeginWrite(const char* pszId, const uint64& nVersion) {BeginWrite(pszId, strlen(pszId), nVersion);}
-
// Call this to begin reading: must be called before other read functions.
void BeginRead(const char* pId, const size_t nLength, const uint64& nVersion);
void BeginRead(const char* pszId, const uint64& nVersion) {return BeginRead(pszId, strlen(pszId), nVersion);}
- // Reserves space for map to current position. Call after BeginWrite and before writing any entries.
- void ReserveMapSize(uint32 nSize);
-
// After calling BeginRead(), this returns number of entries in the file.
NumType GetNumEntries() const {return m_nReadEntrycount;}
@@ -309,10 +344,6 @@
IdMatchStatus CompareId(const ReadIterator& iter, const char* pszId) {return CompareId(iter, pszId, strlen(pszId));}
IdMatchStatus CompareId(const ReadIterator& iter, const char* pId, const size_t nIdSize);
- // When writing, returns the number of entries written.
- // When reading, returns the number of entries read not including unrecognized entries.
- NumType GetCounter() const {return m_nCounter;}
-
uint64 GetReadVersion() {return m_nReadVersion;}
// Read item using default read implementation.
@@ -332,27 +363,8 @@
template <class T, class FuncObj>
ReadRv ReadItem(const ReadIterator& iter, T& obj, FuncObj func);
- // Write item using default write implementation.
- template <class T>
- void WriteItem(const T& obj, const char* pszId) {WriteItem(obj, pszId, strlen(pszId), &srlztn::WriteItem<T>);}
+private:
- template <class T>
- void WriteItem(const T& obj, const char* pId, const size_t nIdSize) {WriteItem(obj, pId, nIdSize, &srlztn::WriteItem<T>);}
-
- // Write item using given function.
- template <class T, class FuncObj>
- void WriteItem(const T& obj, const char* pId, const size_t nIdSize, FuncObj);
-
- // Writes mapping.
- void FinishWrite();
-
- void SetFlag(Rwf flag, bool val) {m_Flags.set(flag, val);}
- bool GetFlag(Rwf flag) const {return m_Flags[flag];}
-
- // Write given string to log if log func is defined.
- void AddToLog(const char *psz);
-
-private:
// Reads map to cache.
void CacheMap();
@@ -367,50 +379,21 @@
// Called after reading an object.
ReadRv OnReadEntry(const ReadEntry* pE, const char* pId, const size_t nIdSize, const Postype& posReadBegin);
- // Called after writing an item.
- void OnWroteItem(const char* pId, const size_t nIdSize, const Postype& posBeforeWrite);
-
- void AddNote(const SsbStatus s, const char* sz);
-
void AddReadNote(const SsbStatus s);
// Called after reading entry. pRe is a pointer to associated map entry if exists.
void AddReadNote(const ReadEntry* const pRe, const NumType nNum);
- void AddWriteNote(const SsbStatus s);
- void AddWriteNote(const char* pId,
- const size_t nIdLength,
- const NumType nEntryNum,
- const DataSize nBytecount,
- const RposType rposStart);
-
- // Writes mapping item to mapstream.
- void WriteMapItem(const char* pId,
- const size_t nIdSize,
- const RposType& rposDataStart,
- const DataSize& nDatasize,
- const char* pszDesc);
-
void ResetReadstatus();
- void ResetWritestatus() {m_Status = SNT_NONE;}
- void IncrementWriteCounter();
-
private:
- std::ostream* m_pOstrm; // Write: Pointer to write stream.
std::istream* m_pIstrm; // Read: Pointer to read stream.
-public:
-
- SsbStatus m_Status;
- uint32 m_nFixedEntrySize; // Read/write: If > 0, data entries have given fixed size.
-
private:
std::vector<char> m_Idarray; // Read: Holds entry ids.
- Postype m_posStart; // Read/write: Stream position at the beginning of object.
std::vector<ReadEntry> mapData; // Read: Contains map information.
uint64 m_nReadVersion; // Read: Version is placed here when reading.
NumType m_nMaxReadEntryCount; // Read: Limits the number of entries allowed to be read.
@@ -420,25 +403,83 @@
RposType m_rposEndofHdrData; // Read: rpos of end of header data.
NumType m_nReadEntrycount; // Read: Number of entries.
- uint16 m_nIdbytes; // Read/Write: Tells map ID entry size in bytes. If size is variable, value is IdSizeVariable.
- NumType m_nCounter; // Read/write: Keeps count of entries written/read.
NumType m_nNextReadHint; // Read: Hint where to start looking for the next read entry.
- std::bitset<RwfNumFlags> m_Flags; // Read/write: Various flags.
+};
+
+
+
+class SsbWrite
+ : public Ssb
+{
+
+public:
+
+ SsbWrite(std::ostream& oStrm);
+
+ // Sets map ID size in writing.
+ void SetIdSize(uint16 idSize);
+
+ // Write header
+ void BeginWrite(const char* pId, const size_t nIdSize, const uint64& nVersion);
+ void BeginWrite(const char* pszId, const uint64& nVersion) {BeginWrite(pszId, strlen(pszId), nVersion);}
+
+ // Reserves space for map to current position. Call after BeginWrite and before writing any entries.
+ void ReserveMapSize(uint32 nSize);
+
+ // Write item using default write implementation.
+ template <class T>
+ void WriteItem(const T& obj, const char* pszId) {WriteItem(obj, pszId, strlen(pszId), &srlztn::WriteItem<T>);}
+
+ template <class T>
+ void WriteItem(const T& obj, const char* pId, const size_t nIdSize) {WriteItem(obj, pId, nIdSize, &srlztn::WriteItem<T>);}
+
+ // Write item using given function.
+ template <class T, class FuncObj>
+ void WriteItem(const T& obj, const char* pId, const size_t nIdSize, FuncObj);
+
+ // Writes mapping.
+ void FinishWrite();
+
+private:
+
+ // Called after writing an item.
+ void OnWroteItem(const char* pId, const size_t nIdSize, const Postype& posBeforeWrite);
+
+ void AddWriteNote(const SsbStatus s);
+ void AddWriteNote(const char* pId,
+ const size_t nIdLength,
+ const NumType nEntryNum,
+ const DataSize nBytecount,
+ const RposType rposStart);
+
+ // Writes mapping item to mapstream.
+ void WriteMapItem(const char* pId,
+ const size_t nIdSize,
+ const RposType& rposDataStart,
+ const DataSize& nDatasize,
+ const char* pszDesc);
+
+ void ResetWritestatus() {m_Status = SNT_NONE;}
+
+ void IncrementWriteCounter();
+
+private:
+
+ std::ostream* m_pOstrm; // Write: Pointer to write stream.
+
+private:
+
uint32 m_nMapReserveSize; // Write: Number of bytes to reserve for map if writing it before data.
Postype m_posEntrycount; // Write: Pos of entrycount field.
Postype m_posMapPosField; // Write: Pos of map position field.
Postype m_posMapStart; // Write: Pos of map start.
std::ostringstream m_MapStream; // Write: Map stream.
-public:
- static const uint8 s_DefaultFlagbyte = 0;
- static const char s_EntryID[3];
- static const int32 s_DefaultFlags = (1 << RwfWMapStartPosEntry) +
- (1 << RwfWMapSizeEntry) + (1 << RwfWVersionNum) +
- (1 << RwfRPartialIdMatch);
};
+
+
template<typename T>
struct IdLE
{
@@ -461,7 +502,7 @@
template <class T, class FuncObj>
-void Ssb::WriteItem(const T& obj, const char* pId, const size_t nIdSize, FuncObj Func)
+void SsbWrite::WriteItem(const T& obj, const char* pId, const size_t nIdSize, FuncObj Func)
//------------------------------------------------------------------------------------
{
const Postype pos = m_pOstrm->tellp();
@@ -470,7 +511,7 @@
}
template <class T, class FuncObj>
-Ssb::ReadRv Ssb::ReadItem(T& obj, const char* pId, const size_t nIdSize, FuncObj Func)
+SsbRead::ReadRv SsbRead::ReadItem(T& obj, const char* pId, const size_t nIdSize, FuncObj Func)
//------------------------------------------------------------------------------------
{
const ReadEntry* pE = Find(pId, nIdSize);
@@ -482,7 +523,7 @@
template <class T, class FuncObj>
-Ssb::ReadRv Ssb::ReadItem(const ReadIterator& iter, T& obj, FuncObj func)
+SsbRead::ReadRv SsbRead::ReadItem(const ReadIterator& iter, T& obj, FuncObj func)
//-----------------------------------------------------------------------
{
m_pIstrm->clear();
@@ -494,7 +535,7 @@
}
-inline Ssb::IdMatchStatus Ssb::CompareId(const ReadIterator& iter, const char* pId, const size_t nIdSize)
+inline SsbRead::IdMatchStatus SsbRead::CompareId(const ReadIterator& iter, const char* pId, const size_t nIdSize)
//-------------------------------------------------------------------------------------------------------
{
if (nIdSize == iter->nIdLength && memcmp(&m_Idarray[iter->nIdpos], pId, iter->nIdLength) == 0)
@@ -504,7 +545,7 @@
}
-inline Ssb::ReadIterator Ssb::GetReadBegin()
+inline SsbRead::ReadIterator SsbRead::GetReadBegin()
//------------------------------------------
{
ASSERT(GetFlag(RwfRMapHasId) && (GetFlag(RwfRMapHasStartpos) || GetFlag(RwfRMapHasSize) || m_nFixedEntrySize > 0));
@@ -514,7 +555,7 @@
}
-inline Ssb::ReadIterator Ssb::GetReadEnd()
+inline SsbRead::ReadIterator SsbRead::GetReadEnd()
//----------------------------------------
{
if (GetFlag(RwfRMapCached) == false)
Modified: trunk/OpenMPT/soundlib/Load_it.cpp
===================================================================
--- trunk/OpenMPT/soundlib/Load_it.cpp 2013-10-26 10:31:29 UTC (rev 3037)
+++ trunk/OpenMPT/soundlib/Load_it.cpp 2013-10-26 12:24:03 UTC (rev 3038)
@@ -1016,7 +1016,7 @@
if(version >= 0x88D)
{
- srlztn::Ssb ssb(iStrm);
+ srlztn::SsbRead ssb(iStrm);
ssb.BeginRead("mptm", MptVersion::num);
ssb.ReadItem(GetTuneSpecificTunings(), "0", 1, &ReadTuningCollection);
ssb.ReadItem(*this, "1", 1, &ReadTuningMap);
@@ -1632,7 +1632,7 @@
// catch standard library truncating files
ALWAYS_ASSERT(MPTStartPos > 0);
- srlztn::Ssb ssb(fout);
+ srlztn::SsbWrite ssb(fout);
ssb.BeginWrite("mptm", MptVersion::num);
if(GetTuneSpecificTunings().GetNumTunings() > 0)
Modified: trunk/OpenMPT/soundlib/ModSequence.cpp
===================================================================
--- trunk/OpenMPT/soundlib/ModSequence.cpp 2013-10-26 10:31:29 UTC (rev 3037)
+++ trunk/OpenMPT/soundlib/ModSequence.cpp 2013-10-26 12:24:03 UTC (rev 3038)
@@ -798,7 +798,7 @@
void WriteModSequence(std::ostream& oStrm, const ModSequence& seq)
//----------------------------------------------------------------
{
- srlztn::Ssb ssb(oStrm);
+ srlztn::SsbWrite ssb(oStrm);
ssb.BeginWrite(FileIdSequence, MptVersion::num);
ssb.WriteItem(seq.m_sName.c_str(), "n");
const uint16 nLength = seq.GetLengthTailTrimmed();
@@ -811,7 +811,7 @@
void ReadModSequence(std::istream& iStrm, ModSequence& seq, const size_t)
//-----------------------------------------------------------------------
{
- srlztn::Ssb ssb(iStrm);
+ srlztn::SsbRead ssb(iStrm);
ssb.BeginRead(FileIdSequence, MptVersion::num);
if ((ssb.m_Status & srlztn::SNT_FAILURE) != 0)
return;
@@ -829,7 +829,7 @@
void WriteModSequences(std::ostream& oStrm, const ModSequenceSet& seq)
//--------------------------------------------------------------------
{
- srlztn::Ssb ssb(oStrm);
+ srlztn::SsbWrite ssb(oStrm);
ssb.BeginWrite(FileIdSequences, MptVersion::num);
const uint8 nSeqs = seq.GetNumSequences();
const uint8 nCurrent = seq.GetCurrentSequenceIndex();
@@ -849,7 +849,7 @@
void ReadModSequences(std::istream& iStrm, ModSequenceSet& seq, const size_t)
//---------------------------------------------------------------------------
{
- srlztn::Ssb ssb(iStrm);
+ srlztn::SsbRead ssb(iStrm);
ssb.BeginRead(FileIdSequences, MptVersion::num);
if ((ssb.m_Status & srlztn::SNT_FAILURE) != 0)
return;
Modified: trunk/OpenMPT/soundlib/pattern.cpp
===================================================================
--- trunk/OpenMPT/soundlib/pattern.cpp 2013-10-26 10:31:29 UTC (rev 3037)
+++ trunk/OpenMPT/soundlib/pattern.cpp 2013-10-26 12:24:03 UTC (rev 3038)
@@ -481,7 +481,7 @@
void WriteModPattern(std::ostream& oStrm, const CPattern& pat)
//------------------------------------------------------------
{
- srlztn::Ssb ssb(oStrm);
+ srlztn::SsbWrite ssb(oStrm);
ssb.BeginWrite(FileIdPattern, MptVersion::num);
ssb.WriteItem(pat, "data", strlen("data"), &WriteData);
// pattern time signature
@@ -497,7 +497,7 @@
void ReadModPattern(std::istream& iStrm, CPattern& pat, const size_t)
//-------------------------------------------------------------------
{
- srlztn::Ssb ssb(iStrm);
+ srlztn::SsbRead ssb(iStrm);
ssb.BeginRead(FileIdPattern, MptVersion::num);
if ((ssb.m_Status & srlztn::SNT_FAILURE) != 0)
return;
Modified: trunk/OpenMPT/soundlib/patternContainer.cpp
===================================================================
--- trunk/OpenMPT/soundlib/patternContainer.cpp 2013-10-26 10:31:29 UTC (rev 3037)
+++ trunk/OpenMPT/soundlib/patternContainer.cpp 2013-10-26 12:24:03 UTC (rev 3038)
@@ -195,7 +195,7 @@
void WriteModPatterns(std::ostream& oStrm, const CPatternContainer& patc)
//----------------------------------------------------------------------
{
- srlztn::Ssb ssb(oStrm);
+ srlztn::SsbWrite ssb(oStrm);
ssb.BeginWrite(FileIdPatterns, MptVersion::num);
const PATTERNINDEX nPatterns = patc.Size();
uint16 nCount = 0;
@@ -212,13 +212,13 @@
void ReadModPatterns(std::istream& iStrm, CPatternContainer& patc, const size_t)
//--------------------------------------------------------------------------------
{
- srlztn::Ssb ssb(iStrm);
+ srlztn::SsbRead ssb(iStrm);
ssb.BeginRead(FileIdPatterns, MptVersion::num);
if ((ssb.m_Status & srlztn::SNT_FAILURE) != 0)
return;
PATTERNINDEX nPatterns = patc.Size();
uint16 nCount = uint16_max;
- if (ssb.ReadItem(nCount, "num") != srlztn::Ssb::EntryNotFound)
+ if (ssb.ReadItem(nCount, "num") != srlztn::SsbRead::EntryNotFound)
nPatterns = nCount;
LimitMax(nPatterns, ModSpecs::mptm.patternsMax);
if (nPatterns > patc.Size())
Modified: trunk/OpenMPT/soundlib/tuning.cpp
===================================================================
--- trunk/OpenMPT/soundlib/tuning.cpp 2013-10-26 10:31:29 UTC (rev 3037)
+++ trunk/OpenMPT/soundlib/tuning.cpp 2013-10-26 12:24:03 UTC (rev 3038)
@@ -379,7 +379,7 @@
CTuningRTI* pTuning = new CTuningRTI;
- srlztn::Ssb ssb(iStrm);
+ srlztn::SsbRead ssb(iStrm);
ssb.BeginRead("CTB244RTI", (CTuning::GetVersion() << 24) + GetVersion());
ssb.ReadItem(pTuning->m_TuningName, "0", 1, ReadStr);
ssb.ReadItem(pTuning->m_EditMask, "1");
@@ -470,7 +470,7 @@
CTuning::SERIALIZATION_RETURN_TYPE CTuningRTI::Serialize(std::ostream& outStrm) const
//----------------------------------------------------------------------------------
{
- srlztn::Ssb ssb(outStrm);
+ srlztn::SsbWrite ssb(outStrm);
ssb.BeginWrite("CTB244RTI", (GetVersion() << 24) + GetClassVersion());
if (m_TuningName.length() > 0)
ssb.WriteItem(m_TuningName, "0", 1, WriteStr);
Modified: trunk/OpenMPT/soundlib/tuningCollection.cpp
===================================================================
--- trunk/OpenMPT/soundlib/tuningCollection.cpp 2013-10-26 10:31:29 UTC (rev 3037)
+++ trunk/OpenMPT/soundlib/tuningCollection.cpp 2013-10-26 12:24:03 UTC (rev 3038)
@@ -102,7 +102,7 @@
CTuningCollection::SERIALIZATION_RETURN_TYPE CTuningCollection::Serialize(std::ostream& oStrm) const
//--------------------------------------------------------------------------------------------------
{
- srlztn::Ssb ssb(oStrm);
+ srlztn::SsbWrite ssb(oStrm);
ssb.BeginWrite("TC", s_SerializationVersion);
ssb.WriteItem(m_Name, "0", 1, &WriteStr);
ssb.WriteItem(m_EditMask, "1");
@@ -160,18 +160,18 @@
{ // An old version was not recognised - trying new version.
iStrm.clear();
iStrm.seekg(startpos);
- srlztn::Ssb ssb(iStrm);
+ srlztn::SsbRead ssb(iStrm);
ssb.BeginRead("TC", s_SerializationVersion);
- const srlztn::Ssb::ReadIterator iterBeg = ssb.GetReadBegin();
- const srlztn::Ssb::ReadIterator iterEnd = ssb.GetReadEnd();
- for(srlztn::Ssb::ReadIterator iter = iterBeg; iter != iterEnd; iter++)
+ const srlztn::SsbRead::ReadIterator iterBeg = ssb.GetReadBegin();
+ const srlztn::SsbRead::ReadIterator iterEnd = ssb.GetReadEnd();
+ for(srlztn::SsbRead::ReadIterator iter = iterBeg; iter != iterEnd; iter++)
{
- if (ssb.CompareId(iter, "0") == srlztn::Ssb::IdMatch)
+ if (ssb.CompareId(iter, "0") == srlztn::SsbRead::IdMatch)
ssb.ReadItem(iter, m_Name, &ReadStr);
- else if (ssb.CompareId(iter, "1") == srlztn::Ssb::IdMatch)
+ else if (ssb.CompareId(iter, "1") == srlztn::SsbRead::IdMatch)
ssb.ReadItem(iter, m_EditMask);
- else if (ssb.CompareId(iter, "2") == srlztn::Ssb::IdMatch)
+ else if (ssb.CompareId(iter, "2") == srlztn::SsbRead::IdMatch)
ssb.ReadItem(iter, *this, &ReadTuning);
}
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|