From: <rel...@us...> - 2009-08-16 11:46:45
|
Revision: 327 http://modplug.svn.sourceforge.net/modplug/?rev=327&view=rev Author: relabsoluness Date: 2009-08-16 11:46:32 +0000 (Sun, 16 Aug 2009) Log Message: ----------- [Fix] Sample tab: Fix to crash that occurred when resizing sample while it was playing. [Fix] Instrument tab: Fix to crash that occurred when multiple windows had instrument tab of the same document open. [Fix] Tuning: Default tuning file should now load correctly (broken in rev. 323). [Ref] S3M load: Check parameters before reading. [Ref] Internal: Changes to get rid of some compiler warnings and disabled some warnings (see Stdafx.h). Modified Paths: -------------- trunk/OpenMPT/mptrack/Ctrl_ins.cpp trunk/OpenMPT/mptrack/ScaleEnvPointsDlg.cpp trunk/OpenMPT/mptrack/ScaleEnvPointsDlg.h trunk/OpenMPT/mptrack/Stdafx.h trunk/OpenMPT/mptrack/View_tre.cpp trunk/OpenMPT/mptrack/serialization_utils.cpp trunk/OpenMPT/soundlib/Load_s3m.cpp trunk/OpenMPT/soundlib/modsmp_ctrl.cpp trunk/OpenMPT/soundlib/modsmp_ctrl.h Modified: trunk/OpenMPT/mptrack/Ctrl_ins.cpp =================================================================== --- trunk/OpenMPT/mptrack/Ctrl_ins.cpp 2009-08-15 19:28:24 UTC (rev 326) +++ trunk/OpenMPT/mptrack/Ctrl_ins.cpp 2009-08-16 11:46:32 UTC (rev 327) @@ -1295,7 +1295,7 @@ // -> DESC="IT project files (.itp)" int n = strlen(lpszFileName); if(n >= _MAX_PATH) n = _MAX_PATH-1; - strncpy(&m_pSndFile->m_szInstrumentPath[m_nInstrument-1][0],lpszFileName,n); + strncpy(m_pSndFile->m_szInstrumentPath[m_nInstrument-1],lpszFileName,n); m_pSndFile->m_szInstrumentPath[m_nInstrument-1][n] = '\0'; m_pSndFile->instrumentModified[m_nInstrument-1] = FALSE; // -! NEW_FEATURE#0023 @@ -1643,7 +1643,7 @@ // -> DESC="IT project files (.itp)" int n = strlen(dlg.GetPathName()); if(n > _MAX_PATH) n = _MAX_PATH; - strncpy(&m_pSndFile->m_szInstrumentPath[m_nInstrument-1][0],dlg.GetPathName(),n); + strncpy(m_pSndFile->m_szInstrumentPath[m_nInstrument-1],dlg.GetPathName(),n); m_pSndFile->instrumentModified[m_nInstrument-1] = FALSE; // -! NEW_FEATURE#0023 @@ -2030,13 +2030,12 @@ if ((!IsLocked()) && pIns->nMixPlug != nPlug) { m_pModDoc->SetModified(); pIns->nMixPlug = nPlug; + m_pModDoc->UpdateAllViews(NULL, HINT_MIXPLUGINS, this); + m_pModDoc->UpdateAllViews(NULL, (m_nInstrument << HINT_SHIFT_INS) | HINT_INSNAMES, this); } m_CbnPluginVelocityHandling.SetCurSel(pIns->nPluginVelocityHandling); m_CbnPluginVolumeHandling.SetCurSel(pIns->nPluginVolumeHandling); - m_pModDoc->UpdateAllViews(NULL, HINT_MIXPLUGINS, this); - m_pModDoc->UpdateAllViews(NULL, (m_nInstrument << HINT_SHIFT_INS) | HINT_INSNAMES, this); - if (pIns->nMixPlug) //if we have not just set to no plugin { PSNDMIXPLUGIN pPlug = &(m_pSndFile->m_MixPlugins[pIns->nMixPlug-1]); @@ -2653,7 +2652,6 @@ pIns->SetTuning(pIns->s_DefaultTuning); END_CRITICAL(); m_pModDoc->SetModified(); - UpdateView((m_nInstrument << HINT_SHIFT_INS) | HINT_INSTRUMENT); } void CCtrlInstruments::OnEnChangeEditPitchtempolock() Modified: trunk/OpenMPT/mptrack/ScaleEnvPointsDlg.cpp =================================================================== --- trunk/OpenMPT/mptrack/ScaleEnvPointsDlg.cpp 2009-08-15 19:28:24 UTC (rev 326) +++ trunk/OpenMPT/mptrack/ScaleEnvPointsDlg.cpp 2009-08-16 11:46:32 UTC (rev 327) @@ -9,7 +9,7 @@ // CScaleEnvPointsDlg dialog IMPLEMENT_DYNAMIC(CScaleEnvPointsDlg, CDialog) -CScaleEnvPointsDlg::CScaleEnvPointsDlg(CWnd* pParent, MODINSTRUMENT* pInst, BYTE env) +CScaleEnvPointsDlg::CScaleEnvPointsDlg(CWnd* pParent, MODINSTRUMENT* pInst, UINT env) : CDialog(CScaleEnvPointsDlg::IDD, pParent), m_pInstrument(pInst), m_Env(env) Modified: trunk/OpenMPT/mptrack/ScaleEnvPointsDlg.h =================================================================== --- trunk/OpenMPT/mptrack/ScaleEnvPointsDlg.h 2009-08-15 19:28:24 UTC (rev 326) +++ trunk/OpenMPT/mptrack/ScaleEnvPointsDlg.h 2009-08-16 11:46:32 UTC (rev 327) @@ -11,7 +11,7 @@ DECLARE_DYNAMIC(CScaleEnvPointsDlg) public: - CScaleEnvPointsDlg(CWnd* pParent, MODINSTRUMENT* pInst, BYTE env); // standard constructor + CScaleEnvPointsDlg(CWnd* pParent, MODINSTRUMENT* pInst, UINT env); // standard constructor virtual ~CScaleEnvPointsDlg(); // Dialog Data @@ -24,7 +24,7 @@ private: MODINSTRUMENT* m_pInstrument; - BYTE m_Env; //To tell which envelope to process. + UINT m_Env; //To tell which envelope to process. CEdit m_EditFactor; protected: virtual void OnOK(); Modified: trunk/OpenMPT/mptrack/Stdafx.h =================================================================== --- trunk/OpenMPT/mptrack/Stdafx.h 2009-08-15 19:28:24 UTC (rev 326) +++ trunk/OpenMPT/mptrack/Stdafx.h 2009-08-16 11:46:32 UTC (rev 327) @@ -29,7 +29,7 @@ #define MMNODRV #define MMNOMCI -//#define _CRT_SECURE_NO_WARNINGS // Define to disable the "This function or variable may be unsafe" warnings. +#define _CRT_SECURE_NO_WARNINGS // Define to disable the "This function or variable may be unsafe" warnings. #define _CRT_SECURE_CPP_OVERLOAD_STANDARD_NAMES 1 #define _CRT_SECURE_CPP_OVERLOAD_STANDARD_NAMES_COUNT 1 Modified: trunk/OpenMPT/mptrack/View_tre.cpp =================================================================== --- trunk/OpenMPT/mptrack/View_tre.cpp 2009-08-15 19:28:24 UTC (rev 326) +++ trunk/OpenMPT/mptrack/View_tre.cpp 2009-08-16 11:46:32 UTC (rev 327) @@ -2606,7 +2606,7 @@ dlg.m_ofn.nMaxFile = _MAX_PATH; if(dlg.DoModal() == IDOK){ - strcpy(&pSndFile->m_szInstrumentPath[dwItem-1][0],pszFileNames); + strcpy(pSndFile->m_szInstrumentPath[dwItem-1], pszFileNames); OnRefreshTree(); } @@ -2642,7 +2642,7 @@ dlg.m_ofn.lpstrFile = pszFileNames; dlg.m_ofn.nMaxFile = _MAX_PATH; - if(dlg.DoModal() == IDOK) strcpy(&pSndFile->m_szInstrumentPath[dwItem-1][0],pszFileNames); + if(dlg.DoModal() == IDOK) strcpy(pSndFile->m_szInstrumentPath[dwItem-1], pszFileNames); dlg.m_ofn.lpstrFile = NULL; dlg.m_ofn.nMaxFile = 0; Modified: trunk/OpenMPT/mptrack/serialization_utils.cpp =================================================================== --- trunk/OpenMPT/mptrack/serialization_utils.cpp 2009-08-15 19:28:24 UTC (rev 326) +++ trunk/OpenMPT/mptrack/serialization_utils.cpp 2009-08-16 11:46:32 UTC (rev 327) @@ -696,7 +696,7 @@ } if(Testbit(flagbyte, 3)) - iStrm.ignore(8); + iStrm.ignore(5); // Read entrycount ReadAdaptive1248(iStrm, tempU64); Modified: trunk/OpenMPT/soundlib/Load_s3m.cpp =================================================================== --- trunk/OpenMPT/soundlib/Load_s3m.cpp 2009-08-15 19:28:24 UTC (rev 326) +++ trunk/OpenMPT/soundlib/Load_s3m.cpp 2009-08-16 11:46:32 UTC (rev 327) @@ -255,6 +255,8 @@ bool CSoundFile::ReadS3M(const BYTE *lpStream, DWORD dwMemLength) //--------------------------------------------------------------- { + if ((!lpStream) || (dwMemLength <= sizeof(S3MFILEHEADER)+sizeof(S3MSAMPLESTRUCT)+64)) return false; + UINT insnum,patnum,nins,npat; DWORD insfile[128]; WORD ptr[256]; @@ -273,7 +275,6 @@ psfh.scrm = LittleEndian(psfh.scrm); psfh.special = LittleEndianW(psfh.special); - if ((!lpStream) || (dwMemLength <= sizeof(S3MFILEHEADER)+sizeof(S3MSAMPLESTRUCT)+64)) return false; if (psfh.scrm != 0x4D524353) return false; if((psfh.cwtv & 0xF000) == 0x5000) // OpenMPT Version number (Major.Minor) Modified: trunk/OpenMPT/soundlib/modsmp_ctrl.cpp =================================================================== --- trunk/OpenMPT/soundlib/modsmp_ctrl.cpp 2009-08-15 19:28:24 UTC (rev 326) +++ trunk/OpenMPT/soundlib/modsmp_ctrl.cpp 2009-08-16 11:46:32 UTC (rev 327) @@ -11,15 +11,17 @@ namespace ctrlSmp { -void ReplaceSample(MODSAMPLE& smp, const LPSTR pNewSample, const SmpLength nNewLength) -//---------------------------------------------------------------------------------------- +void ReplaceSample(MODSAMPLE& smp, const LPSTR pNewSample, const SmpLength nNewLength, CSoundFile* pSndFile) +//---------------------------------------------------------------------------------------------------------- { LPSTR const pOldSmp = smp.pSample; BEGIN_CRITICAL(); + if (pSndFile != nullptr) + ctrlChn::ReplaceSample(pSndFile->Chn, pOldSmp, pNewSample, nNewLength); smp.pSample = pNewSample; smp.nLength = nNewLength; - END_CRITICAL(); - CSoundFile::FreeSample(pOldSmp); + CSoundFile::FreeSample(pOldSmp); + END_CRITICAL(); } @@ -60,7 +62,7 @@ AfxMessageBox(TEXT("Unsupported start position in InsertSilence.")); } - ReplaceSample(smp, pNewSmp, nNewLength); + ReplaceSample(smp, pNewSmp, nNewLength, pSndFile); AdjustEndOfSample(smp, pSndFile); return smp.nLength; @@ -88,7 +90,7 @@ // Copy over old data and replace sample by the new one memcpy(pNewSmp, smp.pSample, nNewSmpBytes); - ReplaceSample(smp, pNewSmp, nNewLength); + ReplaceSample(smp, pNewSmp, nNewLength, pSndFile); // Adjust loops if(smp.nLoopStart > nNewLength) @@ -340,3 +342,32 @@ } // namespace ctrlSmp + + + +namespace ctrlChn +{ + +void ReplaceSample( MODCHANNEL (&Chn)[MAX_CHANNELS], + LPCSTR pOldSample, + LPSTR pNewSample, + const ctrlSmp::SmpLength nNewLength, + DWORD orFlags /* = 0*/, + DWORD andFlags /* = MAXDWORD*/) +{ + for (CHANNELINDEX i = 0; i < MAX_CHANNELS; i++) + { + if (Chn[i].pSample == pOldSample) + { + Chn[i].pSample = pNewSample; + Chn[i].pCurrentSample = pNewSample; + if (Chn[i].nPos > nNewLength) + Chn[i].nPos = 0; + Chn[i].nLength = nNewLength; + Chn[i].dwFlags |= orFlags; + Chn[i].dwFlags &= andFlags; + } + } +} + +} // namespace ctrlChn Modified: trunk/OpenMPT/soundlib/modsmp_ctrl.h =================================================================== --- trunk/OpenMPT/soundlib/modsmp_ctrl.h 2009-08-15 19:28:24 UTC (rev 326) +++ trunk/OpenMPT/soundlib/modsmp_ctrl.h 2009-08-16 11:46:32 UTC (rev 327) @@ -21,15 +21,16 @@ // Insert silence to given location. // Note: Is currently implemented only for inserting silence to the beginning and to the end of the sample. // Return: Length of the new sample. -SmpLength InsertSilence(MODSAMPLE& smp, const SmpLength nSilenceLength, const SmpLength nStartFrom, CSoundFile* pSndFile = nullptr); +SmpLength InsertSilence(MODSAMPLE& smp, const SmpLength nSilenceLength, const SmpLength nStartFrom, CSoundFile* pSndFile); // Change sample size. // Note: If resized sample is bigger, silence will be added to the sample's tail. // Return: Length of the new sample. -SmpLength ResizeSample(MODSAMPLE& smp, const SmpLength nNewLength, CSoundFile* pSndFile = nullptr); +SmpLength ResizeSample(MODSAMPLE& smp, const SmpLength nNewLength, CSoundFile* pSndFile); // Replaces sample in 'smp' with given sample and frees the old sample. -void ReplaceSample(MODSAMPLE& smp, const LPSTR pNewSample, const SmpLength nNewLength); +// If valid CSoundFile pointer is given, the sample will be replaced also from the sounds channels. +void ReplaceSample(MODSAMPLE& smp, const LPSTR pNewSample, const SmpLength nNewLength, CSoundFile* pSndFile); bool AdjustEndOfSample(MODSAMPLE& smp, CSoundFile* pSndFile = 0); @@ -53,4 +54,17 @@ } // Namespace ctrlSmp +namespace ctrlChn +{ + +// Replaces sample from sound channels by given sample. +void ReplaceSample( MODCHANNEL (&Chn)[MAX_CHANNELS], + LPCSTR pOldSample, + LPSTR pNewSample, + const ctrlSmp::SmpLength nNewLength, + DWORD orFlags = 0, + DWORD andFlags = MAXDWORD); + +} // namespace ctrlChn + #endif This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |