From: <man...@us...> - 2013-04-13 13:07:58
|
Revision: 1869 http://sourceforge.net/p/modplug/code/1869 Author: manxorist Date: 2013-04-13 13:07:51 +0000 (Sat, 13 Apr 2013) Log Message: ----------- [Ref] Properly protect the state of gpSoundDevice with a new m_SoundDeviceMutex instead of overloading the responsability of AudioCriticalSection. [Fix] This might or might not fix some asio or wasapi related deadlocks. [Ref] Remove CMainFrame::m_IsPlaybackRunning and move it into ISoundDevice. [Fix] Fix stupid potential crashes when stopping waveout devices. [Ref] Change audio rendering callbacks to take an additional ISoundDevice& parameter. Modified Paths: -------------- trunk/OpenMPT/mptrack/ExceptionHandler.cpp 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/SoundDevices.h Modified: trunk/OpenMPT/mptrack/ExceptionHandler.cpp =================================================================== --- trunk/OpenMPT/mptrack/ExceptionHandler.cpp 2013-04-13 13:03:30 UTC (rev 1868) +++ trunk/OpenMPT/mptrack/ExceptionHandler.cpp 2013-04-13 13:07:51 UTC (rev 1869) @@ -117,15 +117,18 @@ LONG ExceptionHandler::UnhandledExceptionFilter(_EXCEPTION_POINTERS *pExceptionInfo) //---------------------------------------------------------------------------------- { + // Shut down audio device... CMainFrame* pMainFrame = CMainFrame::GetMainFrame(); - - // Shut down audio device... if(pMainFrame) { try { - if(pMainFrame->gpSoundDevice) pMainFrame->gpSoundDevice->Reset(); - pMainFrame->audioCloseDevice(); + // do not take m_SoundDeviceMutex here, just try closing it, no matter what + if(pMainFrame->gpSoundDevice) + { + pMainFrame->gpSoundDevice->Reset(); + pMainFrame->gpSoundDevice->Close(); + } } catch(...) { } Modified: trunk/OpenMPT/mptrack/MainFrm.cpp =================================================================== --- trunk/OpenMPT/mptrack/MainFrm.cpp 2013-04-13 13:03:30 UTC (rev 1868) +++ trunk/OpenMPT/mptrack/MainFrm.cpp 2013-04-13 13:07:51 UTC (rev 1869) @@ -184,7 +184,6 @@ m_dwNotifyThreadId = 0; m_hNotifyWakeUp = NULL; gpSoundDevice = NULL; - m_IsPlaybackRunning = false; m_bModTreeHasFocus = false; //rewbs.customKeys m_pNoteMapHasFocus = nullptr; //rewbs.customKeys @@ -473,14 +472,16 @@ BeginWaitCursor(); if (IsPlaying()) PauseMod(); if (pMDIActive) pMDIActive->SavePosition(TRUE); - if (gpSoundDevice) + { - CriticalSection cs; - //gpSoundDevice->Reset(); - //audioCloseDevice(); - delete gpSoundDevice; - gpSoundDevice = NULL; + Util::lock_guard<Util::mutex> lock(m_SoundDeviceMutex); + if(gpSoundDevice) + { + delete gpSoundDevice; + gpSoundDevice = nullptr; + } } + // Save Settings RemoveControlBar(&m_wndStatusBar); // Remove statusbar so that its state won't get saved. TrackerSettings::Instance().SaveSettings(); @@ -702,7 +703,7 @@ int64 currenttotalsamples = 0; bool currenttotalsamplesValid = false; { - CriticalSection cs; + Util::lock_guard<Util::mutex> lock(m_SoundDeviceMutex); if(gpSoundDevice && gpSoundDevice->HasGetStreamPosition()) { currenttotalsamples = gpSoundDevice->GetStreamPositionSamples(); @@ -748,45 +749,28 @@ } -void CMainFrame::SetAudioThreadActive(bool active) -//------------------------------------------------ +void CMainFrame::FillAudioBufferLocked(const ISoundDevice &device, IFillAudioBuffer &callback) +//-------------------------------------------------------------------------------------------- { - if(active) - { - if(m_IsPlaybackRunning) return; - m_IsPlaybackRunning = true; - gpSoundDevice->Start(); - } else - { - if(!m_IsPlaybackRunning) return; - gpSoundDevice->Stop(); - m_IsPlaybackRunning = false; - } -} - - -void CMainFrame::FillAudioBufferLocked(IFillAudioBuffer &callback) -//---------------------------------------------------------------- -{ CriticalSection cs; callback.FillAudioBuffer(); } -ULONG CMainFrame::AudioRead(PVOID pvData, ULONG MaxSamples) -//--------------------------------------------------------- +ULONG CMainFrame::AudioRead(const ISoundDevice &device, PVOID pvData, ULONG MaxSamples) +//------------------------------------------------------------------------------------- { OPENMPT_PROFILE_FUNCTION(Profiler::Audio); return m_pSndFile->Read(pvData, MaxSamples); } -void CMainFrame::AudioDone(ULONG SamplesWritten, ULONG SamplesLatency, bool endOfStream) -//-------------------------------------------------------------------------------------- +void CMainFrame::AudioDone(const ISoundDevice &device, ULONG SamplesWritten, ULONG SamplesLatency, bool endOfStream) +//------------------------------------------------------------------------------------------------------------------ { if(SamplesWritten > 0) { - DoNotification(SamplesWritten, SamplesLatency, endOfStream); + DoNotification(SamplesWritten, SamplesLatency, endOfStream, device.HasGetStreamPosition()); } } @@ -821,21 +805,24 @@ } WaveFormat.SubFormat = guid_MEDIASUBTYPE_PCM; } - UINT nDevType = SNDDEV_GET_TYPE(TrackerSettings::Instance().m_nWaveDevice); - if ((gpSoundDevice) && (gpSoundDevice->GetDeviceType() != nDevType)) { - delete gpSoundDevice; - gpSoundDevice = NULL; + Util::lock_guard<Util::mutex> lock(m_SoundDeviceMutex); + UINT nDevType = SNDDEV_GET_TYPE(TrackerSettings::Instance().m_nWaveDevice); + if(gpSoundDevice && (gpSoundDevice->GetDeviceType() != nDevType)) + { + delete gpSoundDevice; + gpSoundDevice = NULL; + } + if(!gpSoundDevice) gpSoundDevice = CreateSoundDevice(nDevType); + if(!gpSoundDevice) return false; + gpSoundDevice->SetSource(this); + gpSoundDevice->Configure(m_hWnd, TrackerSettings::Instance().m_LatencyMS, TrackerSettings::Instance().m_UpdateIntervalMS, + ((TrackerSettings::Instance().m_MixerSettings.MixerFlags & SOUNDSETUP_SECONDARY) ? 0 : SNDDEV_OPTIONS_EXCLUSIVE) + | + ((TrackerSettings::Instance().m_MixerSettings.MixerFlags & SOUNDSETUP_NOBOOSTTHREADPRIORITY) ? 0 : SNDDEV_OPTIONS_BOOSTTHREADPRIORITY) + ); + if (!gpSoundDevice->Open(SNDDEV_GET_NUMBER(TrackerSettings::Instance().m_nWaveDevice), &WaveFormat.Format)) return false; } - if(!gpSoundDevice) gpSoundDevice = CreateSoundDevice(nDevType); - if(!gpSoundDevice) return false; - gpSoundDevice->SetSource(this); - gpSoundDevice->Configure(m_hWnd, TrackerSettings::Instance().m_LatencyMS, TrackerSettings::Instance().m_UpdateIntervalMS, - ((TrackerSettings::Instance().m_MixerSettings.MixerFlags & SOUNDSETUP_SECONDARY) ? 0 : SNDDEV_OPTIONS_EXCLUSIVE) - | - ((TrackerSettings::Instance().m_MixerSettings.MixerFlags & SOUNDSETUP_NOBOOSTTHREADPRIORITY) ? 0 : SNDDEV_OPTIONS_BOOSTTHREADPRIORITY) - ); - if (!gpSoundDevice->Open(SNDDEV_GET_NUMBER(TrackerSettings::Instance().m_nWaveDevice), &WaveFormat.Format)) return false; return true; } @@ -843,7 +830,8 @@ bool CMainFrame::IsAudioDeviceOpen() const //---------------------------------------- { - return gpSoundDevice && gpSoundDevice->IsOpen(); + Util::lock_guard<Util::mutex> lock(m_SoundDeviceMutex); + return gpSoundDevice && gpSoundDevice->IsOpen(); } @@ -861,7 +849,10 @@ err = !audioTryOpeningDevice(TrackerSettings::Instance().m_MixerSettings.gnChannels, TrackerSettings::Instance().m_MixerSettings.m_SampleFormat, TrackerSettings::Instance().m_MixerSettings.gdwMixingFreq); - nFixedBitsPerSample = (gpSoundDevice) ? gpSoundDevice->HasFixedBitsPerSample() : 0; + { + Util::lock_guard<Util::mutex> lock(m_SoundDeviceMutex); + nFixedBitsPerSample = (gpSoundDevice) ? gpSoundDevice->HasFixedBitsPerSample() : 0; + } if(err && (nFixedBitsPerSample && (nFixedBitsPerSample != TrackerSettings::Instance().m_MixerSettings.m_SampleFormat))) { if(nFixedBitsPerSample) TrackerSettings::Instance().m_MixerSettings.m_SampleFormat = (SampleFormat)nFixedBitsPerSample; @@ -892,19 +883,18 @@ void CMainFrame::audioCloseDevice() //--------------------------------- { - if (gpSoundDevice) + Util::lock_guard<Util::mutex> lock(m_SoundDeviceMutex); + if(gpSoundDevice) { - CriticalSection cs; - gpSoundDevice->Reset(); gpSoundDevice->Close(); + } - // reset notify buffer as timestamps revert here - { - Util::lock_guard<Util::mutex> lock(m_NotificationBufferMutex); - m_NotifyBuffer.clear(); - m_TotalSamplesRendered = 0; - } + // reset notify buffer as timestamps revert here + { + Util::lock_guard<Util::mutex> lock(m_NotificationBufferMutex); + m_NotifyBuffer.clear(); + m_TotalSamplesRendered = 0; } } @@ -942,15 +932,15 @@ } -BOOL CMainFrame::DoNotification(DWORD dwSamplesRead, DWORD SamplesLatency, bool endOfStream) -//------------------------------------------------------------------------------------------ +BOOL CMainFrame::DoNotification(DWORD dwSamplesRead, DWORD SamplesLatency, bool endOfStream, bool hasSoundDeviceGetStreamPosition) +//-------------------------------------------------------------------------------------------------------------------------------- { OPENMPT_PROFILE_FUNCTION(Profiler::Notify); int64 notificationtimestamp = 0; { Util::lock_guard<Util::mutex> lock(m_NotificationBufferMutex); // protect m_TotalSamplesRendered m_TotalSamplesRendered += dwSamplesRead; - if(gpSoundDevice->HasGetStreamPosition()) + if(hasSoundDeviceGetStreamPosition) { notificationtimestamp = m_TotalSamplesRendered; } else @@ -1263,7 +1253,10 @@ { if(!m_pSndFile) return false; // nothing to play if(!IsAudioDeviceOpen()) return false; - SetAudioThreadActive(true); + { + Util::lock_guard<Util::mutex> lock(m_SoundDeviceMutex); + gpSoundDevice->Start(); + } return true; } @@ -1272,7 +1265,10 @@ //----------------------------- { if(!IsAudioDeviceOpen()) return; - SetAudioThreadActive(false); + { + Util::lock_guard<Util::mutex> lock(m_SoundDeviceMutex); + gpSoundDevice->Stop(); + } audioCloseDevice(); } @@ -1281,7 +1277,10 @@ //------------------------------ { if(!IsAudioDeviceOpen()) return false; - SetAudioThreadActive(false); + { + Util::lock_guard<Util::mutex> lock(m_SoundDeviceMutex); + gpSoundDevice->Stop(); + } return true; } Modified: trunk/OpenMPT/mptrack/Mainfrm.h =================================================================== --- trunk/OpenMPT/mptrack/Mainfrm.h 2013-04-13 13:03:30 UTC (rev 1868) +++ trunk/OpenMPT/mptrack/Mainfrm.h 2013-04-13 13:07:51 UTC (rev 1869) @@ -270,13 +270,13 @@ public: // Low-Level Audio + mutable Util::mutex m_SoundDeviceMutex; ISoundDevice *gpSoundDevice; HANDLE m_hNotifyWakeUp; HANDLE m_hNotifyThread; DWORD m_dwNotifyThreadId; static LONG gnLVuMeter, gnRVuMeter; static bool gnClipLeft, gnClipRight; - bool m_IsPlaybackRunning; // Midi Input public: @@ -321,19 +321,18 @@ static void CalcStereoVuMeters(int *, unsigned long, unsigned long); static DWORD WINAPI NotifyThreadWrapper(LPVOID); DWORD NotifyThread(); - void SetAudioThreadActive(bool active=true); // from ISoundSource - void FillAudioBufferLocked(IFillAudioBuffer &callback); - ULONG AudioRead(PVOID pData, ULONG MaxSamples); - void AudioDone(ULONG SamplesWritten, ULONG SamplesLatency, bool endOfStream); + void FillAudioBufferLocked(const ISoundDevice &device, IFillAudioBuffer &callback); + ULONG AudioRead(const ISoundDevice &device, PVOID pData, ULONG MaxSamples); + void AudioDone(const ISoundDevice &device, ULONG SamplesWritten, ULONG SamplesLatency, bool endOfStream); bool audioTryOpeningDevice(UINT channels, UINT bits, UINT samplespersec); bool audioOpenDevice(); bool audioReopenDevice(); void audioCloseDevice(); bool IsAudioDeviceOpen() const; - BOOL DoNotification(DWORD dwSamplesRead, DWORD SamplesLatency, bool endOfStream); + BOOL DoNotification(DWORD dwSamplesRead, DWORD SamplesLatency, bool endOfStream, bool hasSoundDeviceGetStreamPosition); // Midi Input Functions public: @@ -411,7 +410,6 @@ bool StartPlayback(); void StopPlayback(); bool PausePlayback(); - bool IsPlaybackRunning() const { return m_IsPlaybackRunning; } static bool IsValidSoundFile(CSoundFile &sndFile) { return sndFile.GetType() ? true : false; } static bool IsValidSoundFile(CSoundFile *pSndFile) { return pSndFile && pSndFile->GetType(); } void SetPlaybackSoundFile(CSoundFile *pSndFile); Modified: trunk/OpenMPT/mptrack/Mpdlgs.cpp =================================================================== --- trunk/OpenMPT/mptrack/Mpdlgs.cpp 2013-04-13 13:03:30 UTC (rev 1868) +++ trunk/OpenMPT/mptrack/Mpdlgs.cpp 2013-04-13 13:07:51 UTC (rev 1869) @@ -359,8 +359,11 @@ samplerates.push_back(nMixingRates[i]); } + bool knowRates = false; + { + Util::lock_guard<Util::mutex> lock(CMainFrame::GetMainFrame()->m_SoundDeviceMutex); ISoundDevice *dummy = nullptr; - bool justCreated = false, knowRates = false; + 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. @@ -381,6 +384,7 @@ delete dummy; } } + } if(!knowRates) { @@ -481,19 +485,22 @@ { if (!m_EditStatistics) return; CMainFrame *pMainFrm = CMainFrame::GetMainFrame(); - if (pMainFrm && pMainFrm->gpSoundDevice && pMainFrm->IsPlaying()) { - CHAR s[256]; - _snprintf(s, 255, "Buffers: %d\r\nUpdate interval: %4.1f ms\r\nLatency: %4.1f ms\r\nCurrent Latency: %4.1f ms", - pMainFrm->gpSoundDevice->GetNumBuffers(), - (float)pMainFrm->gpSoundDevice->GetRealUpdateIntervalMS(), - (float)pMainFrm->gpSoundDevice->GetRealLatencyMS(), - (float)pMainFrm->gpSoundDevice->GetCurrentRealLatencyMS() - ); - m_EditStatistics.SetWindowText(s); - } else - { - m_EditStatistics.SetWindowText(""); + Util::lock_guard<Util::mutex> lock(pMainFrm->m_SoundDeviceMutex); + if(pMainFrm->gpSoundDevice && pMainFrm->IsPlaying()) + { + CHAR s[256]; + _snprintf(s, 255, "Buffers: %d\r\nUpdate interval: %4.1f ms\r\nLatency: %4.1f ms\r\nCurrent Latency: %4.1f ms", + pMainFrm->gpSoundDevice->GetNumBuffers(), + (float)pMainFrm->gpSoundDevice->GetRealUpdateIntervalMS(), + (float)pMainFrm->gpSoundDevice->GetRealLatencyMS(), + (float)pMainFrm->gpSoundDevice->GetCurrentRealLatencyMS() + ); + m_EditStatistics.SetWindowText(s); + } else + { + m_EditStatistics.SetWindowText(""); + } } } Modified: trunk/OpenMPT/sounddev/SoundDevice.cpp =================================================================== --- trunk/OpenMPT/sounddev/SoundDevice.cpp 2013-04-13 13:03:30 UTC (rev 1868) +++ trunk/OpenMPT/sounddev/SoundDevice.cpp 2013-04-13 13:07:51 UTC (rev 1869) @@ -33,8 +33,11 @@ m_RealLatencyMS = static_cast<float>(m_LatencyMS); m_RealUpdateIntervalMS = static_cast<float>(m_UpdateIntervalMS); + + m_IsPlaying = false; } + ISoundDevice::~ISoundDevice() //--------------------------- { @@ -57,6 +60,40 @@ } + +void ISoundDevice::Start() +//------------------------ +{ + if(!IsOpen()) return; + if(!IsPlaying()) + { + InternalStart(); + m_IsPlaying = true; + } +} + + +void ISoundDevice::Stop() +//----------------------- +{ + if(!IsOpen()) return; + if(IsPlaying()) + { + InternalStop(); + m_IsPlaying = false; + } +} + + +void ISoundDevice::Reset() +//------------------------ +{ + if(!IsOpen()) return; + Stop(); + InternalReset(); +} + + CAudioThread::CAudioThread(CSoundDeviceWithThread &SoundDevice) : m_SoundDevice(SoundDevice) //----------------------------------------------------------------------------------- { @@ -174,7 +211,7 @@ // increase resolution of multimedia timer bool period_set = (timeBeginPeriod(1) == TIMERR_NOERROR); - m_SoundDevice.Start(); + m_SoundDevice.StartFromSoundThread(); while(!idle && !terminate) { @@ -202,7 +239,7 @@ } - m_SoundDevice.Stop(); + m_SoundDevice.StopFromSoundThread(); if(period_set) timeEndPeriod(1); @@ -241,7 +278,11 @@ void CAudioThread::Activate() //--------------------------- { - if(InterlockedExchangeAdd(&m_AudioThreadActive, 0)) return; + if(InterlockedExchangeAdd(&m_AudioThreadActive, 0)) + { + ALWAYS_ASSERT(false); + return; + } ResetEvent(m_hAudioThreadGoneIdle); InterlockedExchange(&m_AudioThreadActive, 1); SetEvent(m_hAudioWakeUp); @@ -251,38 +292,40 @@ void CAudioThread::Deactivate() //----------------------------- { - if(!InterlockedExchangeAdd(&m_AudioThreadActive, 0)) return; + if(!InterlockedExchangeAdd(&m_AudioThreadActive, 0)) + { + ALWAYS_ASSERT(false); + return; + } InterlockedExchange(&m_AudioThreadActive, 0); WaitForSingleObject(m_hAudioThreadGoneIdle, INFINITE); - } void CSoundDeviceWithThread::FillAudioBufferLocked() //-------------------------------------------------- { - m_Source->FillAudioBufferLocked(*this); + m_Source->FillAudioBufferLocked(*this, *this); } -void CSoundDeviceWithThread::Start() -//---------------------------------- +void CSoundDeviceWithThread::InternalStart() +//------------------------------------------ { m_AudioThread.Activate(); } -void CSoundDeviceWithThread::Stop() -//--------------------------------- +void CSoundDeviceWithThread::InternalStop() +//----------------------------------------- { m_AudioThread.Deactivate(); } -void CSoundDeviceWithThread::Reset() -//---------------------------------- +void CSoundDeviceWithThread::InternalReset() +//------------------------------------------ { - m_AudioThread.Deactivate(); ResetFromOutsideSoundThread(); } @@ -309,10 +352,8 @@ CWaveDevice::~CWaveDevice() //------------------------- { - if (m_hWaveOut) - { - Close(); - } + Reset(); + Close(); } @@ -371,8 +412,10 @@ BOOL CWaveDevice::Close() //----------------------- { + Reset(); if (m_hWaveOut) { + ResetFromOutsideSoundThread(); // always reset so that waveOutClose does not fail if we did only P->Stop() (meaning waveOutPause()) before while (m_nPreparedHeaders > 0) { m_nPreparedHeaders--; @@ -380,7 +423,8 @@ GlobalFreePtr(m_WaveBuffers[m_nPreparedHeaders]); m_WaveBuffers[m_nPreparedHeaders] = NULL; } - waveOutClose(m_hWaveOut); + MMRESULT err = waveOutClose(m_hWaveOut); + ALWAYS_ASSERT(err == MMSYSERR_NOERROR); m_hWaveOut = NULL; Sleep(1); // Linux WINE-friendly } @@ -389,7 +433,7 @@ void CWaveDevice::StartFromSoundThread() -//----------------------- +//-------------------------------------- { if(m_hWaveOut) { @@ -399,7 +443,7 @@ void CWaveDevice::StopFromSoundThread() -//---------------------- +//------------------------------------- { if(m_hWaveOut) { @@ -409,7 +453,7 @@ void CWaveDevice::ResetFromOutsideSoundThread() -//----------------------- +//--------------------------------------------- { if(m_hWaveOut) { @@ -441,7 +485,7 @@ while((ULONG)oldBuffersPending < m_nPreparedHeaders) { - ULONG len = m_BytesPerSample * pSource->AudioRead(m_WaveBuffers[m_nWriteBuffer]->lpData, m_nWaveBufferSize/m_BytesPerSample); + ULONG len = m_BytesPerSample * pSource->AudioRead(*this, m_WaveBuffers[m_nWriteBuffer]->lpData, m_nWaveBufferSize/m_BytesPerSample); if(len < m_nWaveBufferSize) { eos = true; @@ -454,7 +498,7 @@ waveOutWrite(m_hWaveOut, m_WaveBuffers[m_nWriteBuffer], sizeof(WAVEHDR)); m_nWriteBuffer++; m_nWriteBuffer %= m_nPreparedHeaders; - pSource->AudioDone(m_nWaveBufferSize/m_BytesPerSample, nLatency/m_BytesPerSample, eos); + pSource->AudioDone(*this, m_nWaveBufferSize/m_BytesPerSample, nLatency/m_BytesPerSample, eos); } if(wasempty) waveOutRestart(m_hWaveOut); @@ -463,7 +507,7 @@ int64 CWaveDevice::GetStreamPositionSamples() const -//------------------------------------------------------ +//------------------------------------------------- { if(!IsOpen()) return 0; MMTIME mmtime; @@ -481,7 +525,7 @@ VOID CWaveDevice::WaveOutCallBack(HWAVEOUT, UINT uMsg, DWORD_PTR dwUser, DWORD_PTR, DWORD_PTR) -//-------------------------------------------------------------------------------- +//-------------------------------------------------------------------------------------------- { if ((uMsg == MM_WOM_DONE) && (dwUser)) { @@ -588,10 +632,8 @@ CDSoundDevice::~CDSoundDevice() //----------------------------- { - if (m_piDS) - { - Close(); - } + Reset(); + Close(); } @@ -714,7 +756,7 @@ void CDSoundDevice::StartFromSoundThread() -//------------------------- +//---------------------------------------- { if(!m_pMixBuffer) return; // done in FillAudioBuffer for now @@ -722,21 +764,23 @@ void CDSoundDevice::StopFromSoundThread() -//------------------------ +//--------------------------------------- { - if(!m_pMixBuffer) return; - if(m_bMixRunning) + if(m_pMixBuffer) { - m_bMixRunning = FALSE; m_pMixBuffer->Stop(); } + m_bMixRunning = FALSE; } void CDSoundDevice::ResetFromOutsideSoundThread() -//------------------------- +//----------------------------------------------- { - if (m_pMixBuffer) m_pMixBuffer->Stop(); + if(m_pMixBuffer) + { + m_pMixBuffer->Stop(); + } m_bMixRunning = FALSE; } @@ -815,8 +859,8 @@ { DWORD nRead1=0, nRead2=0; - if ((lpBuf1) && (dwSize1)) nRead1 = m_BytesPerSample * pSource->AudioRead(lpBuf1, dwSize1/m_BytesPerSample); - if ((lpBuf2) && (dwSize2)) nRead2 = m_BytesPerSample * pSource->AudioRead(lpBuf2, dwSize2/m_BytesPerSample); + if ((lpBuf1) && (dwSize1)) nRead1 = m_BytesPerSample * pSource->AudioRead(*this, lpBuf1, dwSize1/m_BytesPerSample); + if ((lpBuf2) && (dwSize2)) nRead2 = m_BytesPerSample * pSource->AudioRead(*this, lpBuf2, dwSize2/m_BytesPerSample); UnlockBuffer(lpBuf1, dwSize1, lpBuf2, dwSize2); if(nRead1+nRead2 < dwSize1+dwSize2) { @@ -847,7 +891,7 @@ } m_bMixRunning = TRUE; } - pSource->AudioDone((dwSize1+dwSize2)/m_BytesPerSample, m_dwLatency/m_BytesPerSample, eos); + pSource->AudioDone(*this, (dwSize1+dwSize2)/m_BytesPerSample, m_dwLatency/m_BytesPerSample, eos); } } @@ -968,11 +1012,8 @@ CASIODevice::~CASIODevice() //------------------------- { - if (gpCurrentAsio == this) - { - gpCurrentAsio = NULL; - } - CloseDevice(); + Reset(); + Close(); } @@ -1127,11 +1168,9 @@ } -void CASIODevice::Start() -//----------------------- +void CASIODevice::InternalStart() +//------------------------------- { - if (IsOpen()) - { ALWAYS_ASSERT(g_asio_startcount==0); g_asio_startcount++; @@ -1147,19 +1186,15 @@ CASIODevice::ReportASIOException("ASIO crash in start()\n"); } } - } } -void CASIODevice::Stop() -//----------------------- +void CASIODevice::InternalStop() +//------------------------------ { - if (IsOpen()) - { InterlockedExchange(&m_RenderSilence, 1); g_asio_startcount--; ALWAYS_ASSERT(g_asio_startcount==0); - } } @@ -1196,11 +1231,9 @@ } -void CASIODevice::Reset() -//----------------------- +void CASIODevice::InternalReset() +//------------------------------- { - if (IsOpen()) - { if(m_bMixRunning) { m_bMixRunning = FALSE; @@ -1214,7 +1247,6 @@ g_asio_startcount = 0; InterlockedExchange(&m_RenderSilence, 0); } - } } @@ -1278,7 +1310,7 @@ memset(m_FrameBuffer, 0, n*dwSampleSize); } else { - UINT readn = pSource->AudioRead(m_FrameBuffer, n); + UINT readn = pSource->AudioRead(*this, m_FrameBuffer, n); if(readn < n) { eos = true; @@ -1360,7 +1392,7 @@ if (m_bPostOutput) m_pAsioDrv->outputReady(); if(!rendersilence) { - pSource->AudioDone(dwBufferOffset, m_nAsioBufferLen, eos); + pSource->AudioDone(*this, dwBufferOffset, m_nAsioBufferLen, eos); } return; } @@ -1371,7 +1403,7 @@ { UNREFERENCED_PARAMETER(directProcess); g_dwBuffer = doubleBufferIndex; - if (gpCurrentAsio && gpCurrentAsio->m_Source) gpCurrentAsio->m_Source->FillAudioBufferLocked(*gpCurrentAsio); + if (gpCurrentAsio && gpCurrentAsio->m_Source) gpCurrentAsio->m_Source->FillAudioBufferLocked(*gpCurrentAsio, *gpCurrentAsio); } @@ -1759,10 +1791,8 @@ CPortaudioDevice::~CPortaudioDevice() //----------------------------------- { - if(IsOpen()) - { - Close(); - } + Reset(); + Close(); } @@ -1826,26 +1856,23 @@ } -void CPortaudioDevice::Reset() -//---------------------------- +void CPortaudioDevice::InternalReset() +//------------------------------------ { - if(!IsOpen()) return; Pa_AbortStream(m_Stream); } -void CPortaudioDevice::Start() -//---------------------------- +void CPortaudioDevice::InternalStart() +//------------------------------------ { - if(!IsOpen()) return; Pa_StartStream(m_Stream); } -void CPortaudioDevice::Stop() -//--------------------------- +void CPortaudioDevice::InternalStop() +//----------------------------------- { - if(!IsOpen()) return; Pa_StopStream(m_Stream); } @@ -1856,12 +1883,12 @@ ISoundSource *pSource = m_Source; if(m_CurrentFrameCount == 0) return; bool eos = false; - ULONG read = pSource->AudioRead(m_CurrentFrameBuffer, m_CurrentFrameCount); + ULONG read = pSource->AudioRead(*this, m_CurrentFrameBuffer, m_CurrentFrameCount); if(read < m_CurrentFrameCount) { eos = true; } - pSource->AudioDone(m_CurrentFrameCount, static_cast<ULONG>(m_CurrentRealLatencyMS * Pa_GetStreamInfo(m_Stream)->sampleRate / 1000.0f), eos); + pSource->AudioDone(*this, m_CurrentFrameCount, static_cast<ULONG>(m_CurrentRealLatencyMS * Pa_GetStreamInfo(m_Stream)->sampleRate / 1000.0f), eos); } @@ -1929,7 +1956,7 @@ m_CurrentRealLatencyMS = static_cast<float>( timeInfo->outputBufferDacTime - timeInfo->currentTime ) * 1000.0f; m_CurrentFrameBuffer = output; m_CurrentFrameCount = frameCount; - m_Source->FillAudioBufferLocked(*this); + m_Source->FillAudioBufferLocked(*this, *this); m_CurrentFrameCount = 0; m_CurrentFrameBuffer = 0; return paContinue; Modified: trunk/OpenMPT/sounddev/SoundDevice.h =================================================================== --- trunk/OpenMPT/sounddev/SoundDevice.h 2013-04-13 13:03:30 UTC (rev 1868) +++ trunk/OpenMPT/sounddev/SoundDevice.h 2013-04-13 13:07:51 UTC (rev 1869) @@ -13,6 +13,12 @@ #include <vector> + +class ISoundDevice; +class IFillAudioBuffer; +class ISoundSource; + + //////////////////////////////////////////////////////////////////////////////////// // // ISoundSource: provides streaming audio data to a device @@ -33,10 +39,10 @@ //================ { public: - virtual void FillAudioBufferLocked(IFillAudioBuffer &callback) = 0; // take any locks needed while rendering audio and then call FillAudioBuffer - virtual ULONG AudioRead(PVOID pData, ULONG MaxSamples) = 0; // returns number of valid samples read, the remaining space has to be filled with zeroes by the callee, + virtual void FillAudioBufferLocked(const ISoundDevice &device, IFillAudioBuffer &callback) = 0; // take any locks needed while rendering audio and then call FillAudioBuffer + virtual ULONG AudioRead(const ISoundDevice &device, PVOID pData, ULONG MaxSamples) = 0; // returns number of valid samples read, the remaining space has to be filled with zeroes by the callee, // if return value != MaxSamples then end_of_stream = true - virtual void AudioDone(ULONG SamplesWritten, ULONG SamplesLatency, bool end_of_stream) = 0; // all in samples + virtual void AudioDone(const ISoundDevice &device, ULONG SamplesWritten, ULONG SamplesLatency, bool end_of_stream) = 0; // all in samples }; @@ -94,6 +100,8 @@ float m_RealLatencyMS; float m_RealUpdateIntervalMS; + bool m_IsPlaying; + protected: virtual void FillAudioBuffer() = 0; @@ -107,14 +115,20 @@ VOID Configure(HWND hwnd, UINT LatencyMS, UINT UpdateIntervalMS, DWORD fdwCfgOptions); float GetRealLatencyMS() const { return m_RealLatencyMS; } float GetRealUpdateIntervalMS() const { return m_RealUpdateIntervalMS; } + bool IsPlaying() const { return m_IsPlaying; } +protected: + virtual void InternalStart() = 0; + virtual void InternalStop() = 0; + virtual void InternalReset() = 0; + public: virtual UINT GetDeviceType() = 0; virtual BOOL Open(UINT nDevice, LPWAVEFORMATEX pwfx) = 0; // Open a device virtual BOOL Close() = 0; // Close the currently open device - virtual void Start() = 0; - virtual void Stop() = 0; - virtual void Reset() = 0; + void Start(); + void Stop(); + void Reset(); virtual UINT HasFixedBitsPerSample() { return 0; } virtual bool IsOpen() const = 0; virtual UINT GetNumBuffers() { return 0; } Modified: trunk/OpenMPT/sounddev/SoundDevices.h =================================================================== --- trunk/OpenMPT/sounddev/SoundDevices.h 2013-04-13 13:03:30 UTC (rev 1868) +++ trunk/OpenMPT/sounddev/SoundDevices.h 2013-04-13 13:07:51 UTC (rev 1869) @@ -62,9 +62,9 @@ public: CSoundDeviceWithThread() : m_AudioThread(*this) {} virtual ~CSoundDeviceWithThread() {} - void Start(); - void Stop(); - void Reset(); + void InternalStart(); + void InternalStop(); + void InternalReset(); virtual void StartFromSoundThread() = 0; virtual void StopFromSoundThread() = 0; virtual void ResetFromOutsideSoundThread() = 0; @@ -205,9 +205,9 @@ BOOL Open(UINT nDevice, LPWAVEFORMATEX pwfx); BOOL Close(); void FillAudioBuffer(); - void Reset(); - void Start(); - void Stop(); + void InternalReset(); + void InternalStart(); + void InternalStop(); bool IsOpen() const { return (m_pAsioDrv != NULL); } UINT HasFixedBitsPerSample() { return m_nBitsPerSample; } UINT GetNumBuffers() { return 2; } @@ -280,9 +280,9 @@ BOOL Open(UINT nDevice, LPWAVEFORMATEX pwfx); BOOL Close(); void FillAudioBuffer(); - void Reset(); - void Start(); - void Stop(); + void InternalReset(); + void InternalStart(); + void InternalStop(); bool IsOpen() const { return m_Stream ? true : false; } UINT GetNumBuffers() { return 1; } float GetCurrentRealLatencyMS(); This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <man...@us...> - 2013-04-13 13:43:33
|
Revision: 1870 http://sourceforge.net/p/modplug/code/1870 Author: manxorist Date: 2013-04-13 13:43:27 +0000 (Sat, 13 Apr 2013) Log Message: ----------- [Ref] Replace __declspec(align(n)) with a macro ALIGN(n) defined in typedefs.h Modified Paths: -------------- trunk/OpenMPT/common/typedefs.h trunk/OpenMPT/soundlib/ModChannel.h Modified: trunk/OpenMPT/common/typedefs.h =================================================================== --- trunk/OpenMPT/common/typedefs.h 2013-04-13 13:07:51 UTC (rev 1869) +++ trunk/OpenMPT/common/typedefs.h 2013-04-13 13:43:27 UTC (rev 1870) @@ -29,9 +29,22 @@ #ifdef _MSC_VER #define CountOf(x) _countof(x) #else - #define CountOf(x) (sizeof(x)/sizeof(x[0])) + #define CountOf(x) (sizeof((x))/sizeof((x)[0])) #endif +#if defined(_MSC_VER) +//#define USE_PRAGMA_PACK +#define PACKED __declspec(align(1)) +#elif defined(__GNUC__) +#define PACKED __attribute__((packed))) __attribute__((aligned(1)))) +#endif + +#if defined(_MSC_VER) +#define ALIGN(n) __declspec(align(n)) +#elif defined(__GNUC__) +#define ALIGN(n) __attribute__((aligned(n))) +#endif + #ifndef MAX #define MAX(a,b) (((a) > (b)) ? (a) : (b)) #endif Modified: trunk/OpenMPT/soundlib/ModChannel.h =================================================================== --- trunk/OpenMPT/soundlib/ModChannel.h 2013-04-13 13:07:51 UTC (rev 1869) +++ trunk/OpenMPT/soundlib/ModChannel.h 2013-04-13 13:43:27 UTC (rev 1870) @@ -13,7 +13,7 @@ #pragma warning(disable : 4324) //structure was padded due to __declspec(align()) // Mix Channel Struct -struct __declspec(align(32)) ModChannel +struct ALIGN(32) ModChannel { // Envelope playback info struct EnvInfo @@ -176,7 +176,7 @@ // Default pattern channel settings -struct __declspec(align(32)) ModChannelSettings +struct ALIGN(32) ModChannelSettings { FlagSet<ChannelFlags> dwFlags; // Channel flags uint16 nPan; // Initial pan (0...256) This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <sag...@us...> - 2013-04-14 00:32:54
|
Revision: 1873 http://sourceforge.net/p/modplug/code/1873 Author: saga-games Date: 2013-04-14 00:32:41 +0000 (Sun, 14 Apr 2013) Log Message: ----------- [Ref] Mostly small changes, partly to get rid of compiler warnings. Modified Paths: -------------- trunk/OpenMPT/common/StringFixer.h trunk/OpenMPT/mptrack/Autotune.cpp trunk/OpenMPT/mptrack/CommandSet.cpp trunk/OpenMPT/mptrack/CommandSet.h trunk/OpenMPT/mptrack/Ctrl_com.cpp trunk/OpenMPT/mptrack/Ctrl_gen.cpp trunk/OpenMPT/mptrack/Ctrl_pat.cpp trunk/OpenMPT/mptrack/Ctrl_pat.h trunk/OpenMPT/mptrack/Ctrl_seq.cpp trunk/OpenMPT/mptrack/InputHandler.cpp trunk/OpenMPT/mptrack/Moptions.cpp trunk/OpenMPT/mptrack/Mpdlgs.cpp trunk/OpenMPT/mptrack/PatternEditorDialogs.cpp trunk/OpenMPT/mptrack/PatternGotoDialog.cpp trunk/OpenMPT/mptrack/PatternGotoDialog.h trunk/OpenMPT/mptrack/View_pat.cpp trunk/OpenMPT/mptrack/test/test.cpp trunk/OpenMPT/sounddev/SoundDevice.cpp trunk/OpenMPT/soundlib/ITCompression.cpp trunk/OpenMPT/soundlib/Message.cpp trunk/OpenMPT/soundlib/Message.h trunk/OpenMPT/soundlib/ModSequence.cpp trunk/OpenMPT/soundlib/Sndfile.h trunk/OpenMPT/soundlib/plugins/PluginEventQueue.h Modified: trunk/OpenMPT/common/StringFixer.h =================================================================== --- trunk/OpenMPT/common/StringFixer.h 2013-04-13 16:38:15 UTC (rev 1872) +++ trunk/OpenMPT/common/StringFixer.h 2013-04-14 00:32:41 UTC (rev 1873) @@ -226,8 +226,8 @@ // Copy from a char array to a fixed size char array. template <size_t destSize> - void CopyN(char (&destBuffer)[destSize], const char *srcBuffer, const size_t srcSize = SIZE_T_MAX) - //------------------------------------------------------------------------------------------------ + void CopyN(char (&destBuffer)[destSize], const char *srcBuffer, const size_t srcSize = SIZE_MAX) + //---------------------------------------------------------------------------------------------- { const size_t copySize = MIN(destSize - 1, srcSize); strncpy(destBuffer, srcBuffer, copySize); Modified: trunk/OpenMPT/mptrack/Autotune.cpp =================================================================== --- trunk/OpenMPT/mptrack/Autotune.cpp 2013-04-13 16:38:15 UTC (rev 1872) +++ trunk/OpenMPT/mptrack/Autotune.cpp 2013-04-14 00:32:41 UTC (rev 1873) @@ -39,7 +39,7 @@ //--------------------------------------------------------------------------------------- { const double fundamentalFrequency = NoteToFrequency((double)note / BINS_PER_NOTE, pitchReference); - return (SmpLength)MAX(Util::Round((double)sampleFreq / fundamentalFrequency), 1); + return std::max(Util::Round<SmpLength>((double)sampleFreq / fundamentalFrequency), SmpLength(1)); } Modified: trunk/OpenMPT/mptrack/CommandSet.cpp =================================================================== --- trunk/OpenMPT/mptrack/CommandSet.cpp 2013-04-13 16:38:15 UTC (rev 1872) +++ trunk/OpenMPT/mptrack/CommandSet.cpp 2013-04-14 00:32:41 UTC (rev 1873) @@ -44,7 +44,7 @@ enforceRule[krCheckModifiers] = true; enforceRule[krPropagateSampleManipulation] = true; // enforceRule[krCheckContextHierarchy] = true; - + commands.SetSize(kcNumCommands); SetupCommands(); SetupContextHierarchy(); @@ -690,16 +690,16 @@ //--------------------------------------------------------------------------------- { CString report= ""; - + KeyCombination curKc; //Avoid duplicate - for (int k=0; k<commands[cmd].kcList.GetSize(); k++) + for (int k=0; k<commands[cmd].kcList.GetSize(); k++) { curKc=commands[cmd].kcList[k]; if (curKc==kc) { //cm'ed out for perf - //Log("Not adding key:%d; ctx:%d; mod:%d event %d - Duplicate!\n", kc.code, kc.ctx, kc.mod, kc.event); + //Log("Not adding key:%d; ctx:%d; mod:%d event %d - Duplicate!\n", kc.code, kc.ctx, kc.mod, kc.event); return ""; } } @@ -725,7 +725,7 @@ else { if (crossContext) - { + { report += "Warning! the following commands may conflict:\r\n >" + GetCommandText((CommandID)curCmd) + " in " + GetContextText(curKc.ctx) + "\r\n >" + GetCommandText((CommandID)cmd) + " in " + GetContextText(kc.ctx) + "\r\n\r\n"; Log("%s", report); } else @@ -738,7 +738,7 @@ } } } - + if (pos>=0) commands[cmd].kcList.InsertAt(pos, kc); else @@ -753,7 +753,7 @@ bool CCommandSet::IsDummyCommand(CommandID cmd) //--------------------------------------------- { - // e.g. Chord modifier is a dummy command, which serves only to automatically + // e.g. Chord modifier is a dummy command, which serves only to automatically // generate a set of keycombinations for chords (I'm not proud of this design). return commands[cmd].isDummy; } @@ -767,7 +767,7 @@ return Remove(commands[cmd].kcList[pos], cmd); } - Log("Failed to remove a key: keychoice out of range.\n"); + Log("Failed to remove a key: keychoice out of range.\n"); return ""; } @@ -790,7 +790,7 @@ } else { - Log("Failed to remove a key as it was not found\n"); + Log("Failed to remove a key as it was not found\n"); return ""; } @@ -808,7 +808,7 @@ if(enforceRule[krAllowNavigationWithSelection]) { - // When we get a new navigation command key, we need to + // When we get a new navigation command key, we need to // make sure this navigation will work when any selection key is pressed if(inCmd >= kcStartPatNavigation && inCmd <= kcEndPatNavigation) {//Check that it is a nav cmd @@ -824,7 +824,7 @@ Add(newKc, cmdNavSelection, false); } else { - Log("Enforcing rule krAllowNavigationWithSelection - removing key:%d with modifier:%d to command: %d\n", kSel, newKc.mod, cmdNavSelection); + Log("Enforcing rule krAllowNavigationWithSelection - removing key:%d with modifier:%d to command: %d\n", kSel, newKc.mod, cmdNavSelection); Remove(newKc, cmdNavSelection); } } @@ -844,12 +844,12 @@ Add(newKc, cmdNavSelection, false); } else { - Log("Enforcing rule krAllowNavigationWithSelection - removing key:%d with modifier:%d to command: %d\n", kSel, newKc.mod, cmdNavSelection); + Log("Enforcing rule krAllowNavigationWithSelection - removing key:%d with modifier:%d to command: %d\n", kSel, newKc.mod, cmdNavSelection); Remove(newKc, cmdNavSelection); } } } - // When we get a new selection key, we need to make sure that + // When we get a new selection key, we need to make sure that // all navigation commands will work with this selection key pressed else if(inCmd == kcSelect) { @@ -869,7 +869,7 @@ Add(newKc, cmdNavSelection, false); } else { - Log("Enforcing rule krAllowNavigationWithSelection - removing key:%d with modifier:%d to command: %d\n", curCmd, inKc.mod, cmdNavSelection); + Log("Enforcing rule krAllowNavigationWithSelection - removing key:%d with modifier:%d to command: %d\n", curCmd, inKc.mod, cmdNavSelection); Remove(newKc, cmdNavSelection); } } @@ -887,7 +887,7 @@ Add(newKc, cmdNavSelection, false); } else { - Log("Enforcing rule krAllowNavigationWithSelection - removing key:%d with modifier:%d to command: %d\n", curCmd, inKc.mod, cmdNavSelection); + Log("Enforcing rule krAllowNavigationWithSelection - removing key:%d with modifier:%d to command: %d\n", curCmd, inKc.mod, cmdNavSelection); Remove(newKc, cmdNavSelection); } } @@ -898,7 +898,7 @@ if(enforceRule[krAllowSelectionWithNavigation]) { KeyCombination newKcSel; - + // When we get a new navigation command key, we need to ensure // all selection keys will work even when this new selection key is pressed if(inCmd >= kcStartPatNavigation && inCmd <= kcEndPatNavigation) @@ -909,11 +909,11 @@ newKcSel.mod |= inKc.mod; // add modifiers from the new nav command if(adding) { - Log("Enforcing rule krAllowSelectionWithNavigation: adding removing kcSelectWithNav and kcSelectOffWithNav\n"); + Log("Enforcing rule krAllowSelectionWithNavigation: adding removing kcSelectWithNav and kcSelectOffWithNav\n"); Add(newKcSel, kcSelectWithNav, false); } else { - Log("Enforcing rule krAllowSelectionWithNavigation: removing kcSelectWithNav and kcSelectOffWithNav\n"); + Log("Enforcing rule krAllowSelectionWithNavigation: removing kcSelectWithNav and kcSelectOffWithNav\n"); Remove(newKcSel, kcSelectWithNav); } } @@ -927,11 +927,11 @@ newKcSel.mod|=inKc.mod; // add modifiers from the new nav command if(adding) { - Log("Enforcing rule krAllowSelectionWithNavigation: adding removing kcSelectWithNav and kcSelectOffWithNav\n"); + Log("Enforcing rule krAllowSelectionWithNavigation: adding removing kcSelectWithNav and kcSelectOffWithNav\n"); Add(newKcSel, kcSelectWithNav, false); } else { - Log("Enforcing rule krAllowSelectionWithNavigation: removing kcSelectWithNav and kcSelectOffWithNav\n"); + Log("Enforcing rule krAllowSelectionWithNavigation: removing kcSelectWithNav and kcSelectOffWithNav\n"); Remove(newKcSel, kcSelectWithNav); } } @@ -952,7 +952,7 @@ Add(newKcSel, kcSelectWithNav, false); } else { - Log("Enforcing rule krAllowSelectionWithNavigation - removing key:%d with modifier:%d to command: %d\n", curCmd, inKc.mod, kcSelectWithNav); + Log("Enforcing rule krAllowSelectionWithNavigation - removing key:%d with modifier:%d to command: %d\n", curCmd, inKc.mod, kcSelectWithNav); Remove(newKcSel, kcSelectWithNav); } } @@ -970,15 +970,15 @@ Add(newKcSel, kcSelectWithNav, false); } else { - Log("Enforcing rule krAllowSelectionWithNavigation - removing key:%d with modifier:%d to command: %d\n", curCmd, inKc.mod, kcSelectWithNav); + Log("Enforcing rule krAllowSelectionWithNavigation - removing key:%d with modifier:%d to command: %d\n", curCmd, inKc.mod, kcSelectWithNav); Remove(newKcSel, kcSelectWithNav); } } } // end all nav commands - } + } } - + // if we add a selector or a copy selector, we need it to switch off when we release the key. if (enforceRule[krAutoSelectOff]) { @@ -997,7 +997,7 @@ default: ruleApplies = false; } - + if(ruleApplies) { newKcDeSel = inKc; @@ -1016,7 +1016,7 @@ Remove(newKcDeSel, cmdOff); } } - + } // Allow combinations of copyselect and select if(enforceRule[krAllowSelectCopySelectCombos]) @@ -1032,7 +1032,7 @@ newKcSel.mod|=commands[kcCopySelect].kcList[k].mod; newKcCopySel=commands[kcCopySelect].kcList[k]; newKcCopySel.mod|=inKc.mod; - Log("Enforcing rule krAllowSelectCopySelectCombos\n"); + Log("Enforcing rule krAllowSelectCopySelectCombos\n"); if(adding) { Add(newKcSel, kcSelectWithCopySelect, false); @@ -1045,7 +1045,7 @@ } } if(inCmd == kcCopySelect) - { + { // On getting a new copyselection key, make this copyselection key work with all selects' modifiers // On getting a new copyselection key, make all selects work with this key's modifiers for(int k = 0; k < commands[kcSelect].kcList.GetSize(); k++) @@ -1054,7 +1054,7 @@ newKcSel.mod |= inKc.mod; newKcCopySel=inKc; newKcCopySel.mod|=commands[kcSelect].kcList[k].mod; - Log("Enforcing rule krAllowSelectCopySelectCombos\n"); + Log("Enforcing rule krAllowSelectCopySelectCombos\n"); if(adding) { Add(newKcSel, kcSelectWithCopySelect, false); @@ -1068,10 +1068,10 @@ } } - + //# Lock Notes to Chords if (enforceRule[krLockNotesToChords]) - { + { if (inCmd>=kcVPStartNotes && inCmd<=kcVPEndNotes) { int noteOffset = inCmd - kcVPStartNotes; @@ -1081,12 +1081,12 @@ newKc.mod|=commands[kcChordModifier].kcList[k].mod; if (adding) { - Log("Enforcing rule krLockNotesToChords: auto adding in a chord command\n"); + Log("Enforcing rule krLockNotesToChords: auto adding in a chord command\n"); Add(newKc, (CommandID)(kcVPStartChords+noteOffset), false); } else { - Log("Enforcing rule krLockNotesToChords: auto removing a chord command\n"); + Log("Enforcing rule krLockNotesToChords: auto removing a chord command\n"); Remove(newKc, (CommandID)(kcVPStartChords+noteOffset)); } } @@ -1103,12 +1103,12 @@ newKc.mod|=inKc.mod; if (adding) { - Log("Enforcing rule krLockNotesToChords: auto adding in a chord command\n"); + Log("Enforcing rule krLockNotesToChords: auto adding in a chord command\n"); Add(newKc, (CommandID)(kcVPStartChords+noteOffset), false); } else { - Log("Enforcing rule krLockNotesToChords: auto removing a chord command\n"); + Log("Enforcing rule krLockNotesToChords: auto removing a chord command\n"); Remove(newKc, (CommandID)(kcVPStartChords+noteOffset)); } } @@ -1116,7 +1116,7 @@ } } - + //# Auto set note off on release if (enforceRule[krNoteOffOnKeyRelease]) { @@ -1127,12 +1127,12 @@ newKc.event=kKeyEventUp; if (adding) { - Log("Enforcing rule krNoteOffOnKeyRelease: adding note off command\n"); + Log("Enforcing rule krNoteOffOnKeyRelease: adding note off command\n"); Add(newKc, (CommandID)(kcVPStartNoteStops+noteOffset), false); } else { - Log("Enforcing rule krNoteOffOnKeyRelease: removing note off command\n"); + Log("Enforcing rule krNoteOffOnKeyRelease: removing note off command\n"); Remove(newKc, (CommandID)(kcVPStartNoteStops+noteOffset)); } } @@ -1143,12 +1143,12 @@ newKc.event=kKeyEventUp; if (adding) { - Log("Enforcing rule krNoteOffOnKeyRelease: adding Chord off command\n"); + Log("Enforcing rule krNoteOffOnKeyRelease: adding Chord off command\n"); Add(newKc, (CommandID)(kcVPStartChordStops+noteOffset), false); } else { - Log("Enforcing rule krNoteOffOnKeyRelease: removing Chord off command\n"); + Log("Enforcing rule krNoteOffOnKeyRelease: removing Chord off command\n"); Remove(newKc, (CommandID)(kcVPStartChordStops+noteOffset)); } } @@ -1159,23 +1159,23 @@ newKc.event=kKeyEventUp; if (adding) { - Log("Enforcing rule krNoteOffOnKeyRelease: adding Chord off command\n"); + Log("Enforcing rule krNoteOffOnKeyRelease: adding Chord off command\n"); Add(newKc, (CommandID)(kcSetOctaveStop0+noteOffset), false); } else { - Log("Enforcing rule krNoteOffOnKeyRelease: removing Chord off command\n"); + Log("Enforcing rule krNoteOffOnKeyRelease: removing Chord off command\n"); Remove(newKc, (CommandID)(kcSetOctaveStop0+noteOffset)); } } } - + //# Reassign freed number keys to octaves if (enforceRule[krReassignDigitsToOctaves] && !adding) - { + { if ( (inKc.mod == 0) && //no modifier ( (inKc.ctx == kCtxViewPatternsNote) || (inKc.ctx == kCtxViewPatterns) ) && //note scope or pattern scope - ( ('0'<=inKc.code && inKc.code<='9') || (VK_NUMPAD0<=inKc.code && inKc.code<=VK_NUMPAD9) ) ) { //is number key + ( ('0'<=inKc.code && inKc.code<='9') || (VK_NUMPAD0<=inKc.code && inKc.code<=VK_NUMPAD9) ) ) { //is number key newKc.ctx=kCtxViewPatternsNote; newKc.mod=0; newKc.event= kKeyEventDown; @@ -1219,7 +1219,7 @@ Add(newKc, (CommandID)(kcSetSpacing0 + inKc.code - VK_NUMPAD0), false); } } - + } } if (enforceRule[krPropagateNotes]) @@ -1244,7 +1244,7 @@ noteOffset = inCmd - kcVPStartNotes; if (adding) { - Log("Enforcing rule krPropagateNotesToSampAndIns: adding Note on in samp ctx\n"); + Log("Enforcing rule krPropagateNotesToSampAndIns: adding Note on in samp ctx\n"); Add(newKcSamp, (CommandID)(kcSampStartNotes+noteOffset), false); Add(newKcIns, (CommandID)(kcInstrumentStartNotes+noteOffset), false); Add(newKcTree, (CommandID)(kcTreeViewStartNotes+noteOffset), false); @@ -1253,7 +1253,7 @@ } else { - Log("Enforcing rule krPropagateNotesToSampAndIns: removing Note on in samp ctx\n"); + Log("Enforcing rule krPropagateNotesToSampAndIns: removing Note on in samp ctx\n"); Remove(newKcSamp, (CommandID)(kcSampStartNotes+noteOffset)); Remove(newKcIns, (CommandID)(kcInstrumentStartNotes+noteOffset)); Remove(newKcTree, (CommandID)(kcTreeViewStartNotes+noteOffset)); @@ -1278,7 +1278,7 @@ noteOffset = inCmd - kcVPStartNoteStops; if (adding) { - Log("Enforcing rule krPropagateNotesToSampAndIns: adding Note stop on in samp ctx\n"); + Log("Enforcing rule krPropagateNotesToSampAndIns: adding Note stop on in samp ctx\n"); Add(newKcSamp, (CommandID)(kcSampStartNoteStops+noteOffset), false); Add(newKcIns, (CommandID)(kcInstrumentStartNoteStops+noteOffset), false); Add(newKcTree, (CommandID)(kcTreeViewStartNoteStops+noteOffset), false); @@ -1287,7 +1287,7 @@ } else { - Log("Enforcing rule krPropagateNotesToSampAndIns: removing Note stop on in samp ctx\n"); + Log("Enforcing rule krPropagateNotesToSampAndIns: removing Note stop on in samp ctx\n"); Remove(newKcSamp, (CommandID)(kcSampStartNoteStops+noteOffset)); Remove(newKcIns, (CommandID)(kcInstrumentStartNoteStops+noteOffset)); Remove(newKcTree, (CommandID)(kcTreeViewStartNoteStops+noteOffset)); @@ -1305,7 +1305,7 @@ for (int i = 0; i < CountOf(forcedModifiers); i++) { CommandID curCmd = forcedModifiers[i]; - + //for all of this command's key combinations for (int k=0; k<commands[curCmd].kcList.GetSize(); k++) { @@ -1321,7 +1321,7 @@ //commands[curCmd].kcList[k].ctx; } } - + } } if (enforceRule[krPropagateSampleManipulation]) @@ -1350,7 +1350,7 @@ if (inKc.ctx == kCtxViewPatternsFX) { KeyCombination newKc = inKc; newKc.ctx = kCtxViewPatternsFXparam; - if (adding) { + if (adding) { Add(newKc, inCmd, false); } else { Remove(newKc, inCmd); @@ -1359,12 +1359,12 @@ if (inKc.ctx == kCtxViewPatternsFXparam) { KeyCombination newKc = inKc; newKc.ctx = kCtxViewPatternsFX; - if (adding) { + if (adding) { Add(newKc, inCmd, false); } else { Remove(newKc, inCmd); } - } + } } */ return report; @@ -1382,7 +1382,7 @@ case VK_LWIN: case VK_RWIN: return HOTKEYF_EXT; // Feature: use Windows keys as modifier keys default: /*DEBUG: ASSERT(false);*/ return 0; //can only get modifier for modifier key } - + } @@ -1396,13 +1396,13 @@ KeyCombination curKc; CArray<KeyEventType, KeyEventType> eventTypes; CArray<InputTargetContext, InputTargetContext> contexts; - + //Clear map memset(km, kcNull, sizeof(KeyMap)); //Copy commandlist content into map: for(UINT cmd=0; cmd<kcNumCommands; cmd++) - { + { if(IsDummyCommand((CommandID)cmd)) continue; @@ -1411,7 +1411,7 @@ contexts.RemoveAll(); eventTypes.RemoveAll(); curKc = commands[cmd].kcList[k]; - + //Handle keyEventType mask. if (curKc.event & kKeyEventDown) eventTypes.Add(kKeyEventDown); @@ -1504,7 +1504,7 @@ ErrorBox(IDS_CANT_OPEN_FILE_FOR_WRITING); return false; } - fprintf(outStream, "//-------- OpenMPT key binding definition file -------\n"); + fprintf(outStream, "//-------- OpenMPT key binding definition file -------\n"); fprintf(outStream, "//-Format is: -\n"); fprintf(outStream, "//- Context:Command ID:Modifiers:Key:KeypressEventType //Comments -\n"); fprintf(outStream, "//----------------------------------------------------------------------\n"); @@ -1512,22 +1512,22 @@ for (int ctx=0; ctx<kCtxMaxInputContexts; ctx++) { - fprintf(outStream, "\n//----( %s (%d) )------------\n", GetContextText((InputTargetContext)ctx), ctx); + fprintf(outStream, "\n//----( %s (%d) )------------\n", GetContextText((InputTargetContext)ctx), ctx); for (int cmd=0; cmd<kcNumCommands; cmd++) { for (int k=0; k<GetKeyListSize((CommandID)cmd); k++) { kc = GetKey((CommandID)cmd, k); - + if (kc.ctx != ctx) continue; //sort by context - + if (!commands[cmd].isHidden) { - fprintf(outStream, "%d:%d:%d:%d:%d\t\t//%s: %s (%s)\n", - ctx, commands[cmd].UID, kc.mod, kc.code, kc.event, - GetCommandText((CommandID)cmd), GetKeyText(kc.mod,kc.code), GetKeyEventText(kc.event)); + fprintf(outStream, "%d:%d:%d:%d:%d\t\t//%s: %s (%s)\n", + ctx, commands[cmd].UID, kc.mod, kc.code, kc.event, + GetCommandText((CommandID)cmd), GetKeyText(kc.mod,kc.code), GetKeyEventText(kc.event)); } } @@ -1560,18 +1560,18 @@ while(iStrm.getline(s, sizeof(s))) { curLine = s; - - + + //Cut everything after a // commentStart = curLine.Find("//"); if (commentStart>=0) curLine = curLine.Left(commentStart); curLine.Trim(); //remove whitespace - + if (!curLine.IsEmpty() && curLine.Compare("\n") !=0) { bool ignoreLine = false; - + //ctx:UID:Description:Modifier:Key:EventMask int spos = 0; @@ -1803,7 +1803,7 @@ { switch(ctx) { - + case kCtxAllContexts: return "Global Context"; case kCtxViewGeneral: return "General Context [bottom]"; case kCtxViewPatterns: return "Pattern Context [bottom]"; @@ -1892,7 +1892,7 @@ { if ( static_cast<INT_PTR>(key) < commands[c].kcList.GetSize()) return GetKeyText(commands[c].kcList[0].mod, commands[c].kcList[0].code); - else + else return ""; } @@ -1908,7 +1908,7 @@ //------------------------------------------------------- // Quick Changes - modify many commands with one call. //------------------------------------------------------- - + bool CCommandSet::QuickChange_NotesRepeat() //----------------------------------------- { @@ -1965,7 +1965,7 @@ { Remove(p, cmd); } - + char effect = modSpecs.GetEffectLetter(static_cast<ModCommand::COMMAND>(cmd - kcSetFXStart + 1)); if(effect >= 'A' && effect <= 'Z') { @@ -1980,10 +1980,10 @@ if(effect != '?') { SHORT codeNmod = VkKeyScanEx(effect, GetKeyboardLayout(0)); - kc.code = LOBYTE(codeNmod); + kc.code = LOBYTE(codeNmod); kc.mod = HIBYTE(codeNmod) & 0x07; //We're only interest in the bottom 3 bits. Add(kc, cmd, true); - + if (kc.code >= '0' && kc.code <= '9') //for numbers, ensure numpad works too { kc.code = VK_NUMPAD0 + (kc.code-'0'); @@ -1991,11 +1991,12 @@ } } } + return true; } // Stupid MFC crap: for some reason VK code isn't enough to get correct string with GetKeyName. -// We also need to figure out the correct "extended" bit. +// We also need to figure out the correct "extended" bit. bool CCommandSet::IsExtended(UINT code) { if (code==VK_SNAPSHOT) //print screen @@ -2003,7 +2004,7 @@ if (code>=VK_PRIOR && code<=VK_DOWN) //pgup, pg down, home, end, cursor keys, return true; if (code>=VK_INSERT && code<=VK_DELETE) // ins, del - return true; + return true; if (code>=VK_LWIN && code<=VK_APPS) //winkeys & application key return true; if (code==VK_DIVIDE) //Numpad '/' @@ -2017,42 +2018,17 @@ } -void CCommandSet::GetParentContexts(InputTargetContext child, CArray<InputTargetContext, InputTargetContext> parentList) +void CCommandSet::SetupContextHierarchy() { - UNREFERENCED_PARAMETER(child); - //parentList.RemoveAll(); +// m_isParentContext.SetSize(kCtxMaxInputContexts); - //for (InputTargetContext parent; parent<kCtxMaxInputContexts; parent++) { - // if (m_isParentContext[child][parent]) { - // parentList.Add(parent); - // } - //} -} - -void CCommandSet::GetChildContexts(InputTargetContext parent, CArray<InputTargetContext, InputTargetContext> childList) -{ - UNREFERENCED_PARAMETER(parent); - //childList.RemoveAll(); - - //for (InputTargetContext child; child<kCtxMaxInputContexts; child++) { - // if (m_isParentContext[child][parent]) { - // childList.Add(child); - // } - //} -} - - -void CCommandSet::SetupContextHierarchy() -{ -// m_isParentContext.SetSize(kCtxMaxInputContexts); - for (UINT nCtx=0; nCtx<kCtxMaxInputContexts; nCtx++) { // m_isParentContext[nCtx].SetSize(kCtxMaxInputContexts); for (UINT nCtx2=0; nCtx2<kCtxMaxInputContexts; nCtx2++) { m_isParentContext[nCtx][nCtx2] = false; }//InputTargetContext } - + //For now much be fully expanded (i.e. don't rely on grandparent relationships). m_isParentContext[kCtxViewGeneral][kCtxAllContexts] = true; m_isParentContext[kCtxViewPatterns][kCtxAllContexts] = true; @@ -2085,19 +2061,19 @@ } -bool CCommandSet::KeyCombinationConflict(KeyCombination kc1, KeyCombination kc2, bool &crossCxtConflict) +bool CCommandSet::KeyCombinationConflict(KeyCombination kc1, KeyCombination kc2, bool &crossCxtConflict) { bool modConflict = (kc1.mod==kc2.mod); bool codeConflict = (kc1.code==kc2.code); bool eventConflict = ((kc1.event&kc2.event)!=0); bool ctxConflict = (kc1.ctx == kc2.ctx); crossCxtConflict = m_isParentContext[kc1.ctx][kc2.ctx] || m_isParentContext[kc2.ctx][kc1.ctx]; - - bool conflict = modConflict && codeConflict && eventConflict && + + bool conflict = modConflict && codeConflict && eventConflict && (ctxConflict || crossCxtConflict); return conflict; } -//end rewbs.customKeys +//end rewbs.customKeys \ No newline at end of file Modified: trunk/OpenMPT/mptrack/CommandSet.h =================================================================== --- trunk/OpenMPT/mptrack/CommandSet.h 2013-04-13 16:38:15 UTC (rev 1872) +++ trunk/OpenMPT/mptrack/CommandSet.h 2013-04-14 00:32:41 UTC (rev 1873) @@ -1223,8 +1223,6 @@ bool IsDummyCommand(CommandID cmd); UINT CodeToModifier(UINT code); CString EnforceAll(KeyCombination kc, CommandID cmd, bool adding); - void GetParentContexts(InputTargetContext child, CArray<InputTargetContext, InputTargetContext> ctxList); - void GetChildContexts(InputTargetContext child, CArray<InputTargetContext, InputTargetContext> ctxList); bool IsExtended(UINT code); int FindCmd(int uid); Modified: trunk/OpenMPT/mptrack/Ctrl_com.cpp =================================================================== --- trunk/OpenMPT/mptrack/Ctrl_com.cpp 2013-04-13 16:38:15 UTC (rev 1872) +++ trunk/OpenMPT/mptrack/Ctrl_com.cpp 2013-04-14 00:32:41 UTC (rev 1873) @@ -137,9 +137,9 @@ if ((ln >= LINE_LENGTH-1) || (!*p)) { if (((BYTE)c) > ' ') s[ln++] = c; - c = INTERNAL_LINEENDING; + c = SongMessage::InternalLineEnding; } - if (c == INTERNAL_LINEENDING) + if (c == SongMessage::InternalLineEnding) { s[ln] = 0x0D; s[ln+1] = 0x0A; @@ -173,7 +173,6 @@ if ((!m_bInitialized) || (!m_EditComments.m_hWnd) || (!m_EditComments.GetModify())) return; CHAR s[LINE_LENGTH + 2]; - const char *oldMsg = m_pSndFile->songMessage.c_str(); // Updating comments { @@ -195,13 +194,13 @@ if (i+1 < n) { size_t l = strlen(s); - s[l++] = INTERNAL_LINEENDING; + s[l++] = SongMessage::InternalLineEnding; s[l] = '\0'; } strcat(p, s); } UINT len = strlen(p); - while ((len > 0) && ((p[len-1] == ' ') || (p[len-1] == INTERNAL_LINEENDING))) + while ((len > 0) && ((p[len-1] == ' ') || (p[len-1] == SongMessage::InternalLineEnding))) { len--; p[len] = 0; Modified: trunk/OpenMPT/mptrack/Ctrl_gen.cpp =================================================================== --- trunk/OpenMPT/mptrack/Ctrl_gen.cpp 2013-04-13 16:38:15 UTC (rev 1872) +++ trunk/OpenMPT/mptrack/Ctrl_gen.cpp 2013-04-14 00:32:41 UTC (rev 1873) @@ -144,7 +144,6 @@ void CCtrlGeneral::OnActivatePage(LPARAM) //--------------------------------------- { - CMainFrame *pMainFrm = CMainFrame::GetMainFrame(); if (m_pModDoc) m_pModDoc->SetNotifications(Notification::Default); if (m_pModDoc) m_pModDoc->SetFollowWnd(m_hWnd); PostViewMessage(VIEWMSG_SETACTIVE, NULL); @@ -629,8 +628,8 @@ } -VOID CVuMeter::DrawVuMeter(CDC &dc, bool redraw) -//---------------------------------------------- +VOID CVuMeter::DrawVuMeter(CDC &dc, bool /*redraw*/) +//-------------------------------------------------- { LONG vu; LONG lastvu; Modified: trunk/OpenMPT/mptrack/Ctrl_pat.cpp =================================================================== --- trunk/OpenMPT/mptrack/Ctrl_pat.cpp 2013-04-13 16:38:15 UTC (rev 1872) +++ trunk/OpenMPT/mptrack/Ctrl_pat.cpp 2013-04-14 00:32:41 UTC (rev 1873) @@ -838,15 +838,15 @@ CSoundFile *pSndFile = m_pModDoc->GetSoundFile(); OrdSelection selection = m_OrderList.GetCurSel(false); - ORDERINDEX nInsertCount = selection.lastOrd - selection.firstOrd; - ORDERINDEX nInsertWhere = selection.firstOrd + nInsertCount + 1; - if (nInsertWhere >= pSndFile->GetModSpecifications().ordersMax) + const ORDERINDEX insertCount = selection.lastOrd - selection.firstOrd; + const ORDERINDEX insertWhere = selection.firstOrd + insertCount + 1; + if (insertWhere >= pSndFile->GetModSpecifications().ordersMax) return; bool success = false; // Has this pattern been duplicated already? (for multiselect) vector<PATTERNINDEX> patReplaceIndex(pSndFile->Patterns.Size(), PATTERNINDEX_INVALID); - for(ORDERINDEX i = 0; i <= nInsertCount; i++) + for(ORDERINDEX i = 0; i <= insertCount; i++) { PATTERNINDEX nCurPat = pSndFile->Order[selection.firstOrd + i]; if (pSndFile->Patterns.IsValidIndex(nCurPat) && patReplaceIndex[nCurPat] == PATTERNINDEX_INVALID) @@ -854,7 +854,7 @@ ROWINDEX rows = pSndFile->Patterns[nCurPat].GetNumRows(); Limit(rows, pSndFile->GetModSpecifications().patternRowsMin, pSndFile->GetModSpecifications().patternRowsMax); - PATTERNINDEX nNewPat = m_pModDoc->InsertPattern(nInsertWhere + i, rows); + PATTERNINDEX nNewPat = m_pModDoc->InsertPattern(insertWhere + i, rows); if ((nNewPat != PATTERNINDEX_INVALID) && (nNewPat < pSndFile->Patterns.Size()) && (pSndFile->Patterns[nCurPat] != nullptr)) { // Update time signature and pattern name @@ -882,7 +882,7 @@ } else { // Invalid pattern, or it has been duplicated before (multiselect) - for (int j = pSndFile->Order.size() - 1; j > selection.firstOrd + i + nInsertCount + 1; j--) pSndFile->Order[j] = pSndFile->Order[j - 1]; + for (int j = pSndFile->Order.size() - 1; j > selection.firstOrd + i + insertCount + 1; j--) pSndFile->Order[j] = pSndFile->Order[j - 1]; PATTERNINDEX nNewPat; if(nCurPat < pSndFile->Patterns.Size() && patReplaceIndex[nCurPat] != PATTERNINDEX_INVALID) @@ -894,9 +894,9 @@ nNewPat = pSndFile->Order[selection.firstOrd + i]; } - if (selection.firstOrd + i + nInsertCount + 1 < pSndFile->Order.GetLength()) + if (selection.firstOrd + i + insertCount + 1 < pSndFile->Order.GetLength()) { - pSndFile->Order[selection.firstOrd + i + nInsertCount + 1] = nNewPat; + pSndFile->Order[selection.firstOrd + i + insertCount + 1] = nNewPat; } success = true; @@ -906,10 +906,10 @@ if(success) { m_OrderList.InvalidateRect(NULL, FALSE); - m_OrderList.SetCurSel(nInsertWhere); + m_OrderList.SetCurSel(insertWhere); // If the first duplicated order is e.g. a +++ item, we need to move the pattern display on or else we'll still edit the previously shown pattern. - ORDERINDEX showPattern = MIN(nInsertWhere, pSndFile->Order.GetLastIndex()); + ORDERINDEX showPattern = std::min(insertWhere, pSndFile->Order.GetLastIndex()); while(!pSndFile->Patterns.IsValidPat(pSndFile->Order[showPattern]) && showPattern < pSndFile->Order.GetLastIndex()) { showPattern++; @@ -918,7 +918,7 @@ m_pModDoc->SetModified(); m_pModDoc->UpdateAllViews(NULL, HINT_MODSEQUENCE | HINT_PATNAMES, this); - if(selection.lastOrd != selection.firstOrd) m_OrderList.m_nScrollPos2nd = nInsertWhere + nInsertCount; + if(selection.lastOrd != selection.firstOrd) m_OrderList.m_nScrollPos2nd = insertWhere + insertCount; } } SwitchToView(); @@ -1244,35 +1244,17 @@ void CCtrlPatterns::TogglePluginEditor() //-------------------------------------- { - if(m_nInstrument && m_pModDoc && m_pSndFile && m_pSndFile->Instruments[m_nInstrument] != nullptr) + if(m_pModDoc && m_pSndFile && m_pSndFile->GetInstrumentPlugin(m_nInstrument) != nullptr) { - PLUGINDEX nPlug = m_pSndFile->Instruments[m_nInstrument]->nMixPlug; - if(nPlug) - { - // Has a plugin assigned - if(m_pSndFile->m_MixPlugins[nPlug - 1].pMixPlugin != nullptr) - { - // Has a valid plugin assigned - m_pModDoc->TogglePluginEditor(nPlug - 1); - } - } + m_pModDoc->TogglePluginEditor(m_pSndFile->Instruments[m_nInstrument]->nMixPlug - 1); } } -bool CCtrlPatterns::HasValidPlug(UINT instr) -//------------------------------------------ +bool CCtrlPatterns::HasValidPlug(INSTRUMENTINDEX instr) +//----------------------------------------------------- { - if ((instr) && (instr < MAX_INSTRUMENTS) && (m_pSndFile) && m_pSndFile->Instruments[instr] != nullptr) - { - PLUGINDEX nPlug = m_pSndFile->Instruments[instr]->nMixPlug; - if(nPlug) - { - // Has a plugin assigned - return (m_pSndFile->m_MixPlugins[nPlug - 1].pMixPlugin != nullptr); - } - } - return false; + return m_pSndFile != nullptr && m_pSndFile->GetInstrumentPlugin(instr) != nullptr; } Modified: trunk/OpenMPT/mptrack/Ctrl_pat.h =================================================================== --- trunk/OpenMPT/mptrack/Ctrl_pat.h 2013-04-13 16:38:15 UTC (rev 1872) +++ trunk/OpenMPT/mptrack/Ctrl_pat.h 2013-04-14 00:32:41 UTC (rev 1873) @@ -262,7 +262,7 @@ //}}AFX_MSG DECLARE_MESSAGE_MAP() private: - bool HasValidPlug(UINT instr); + bool HasValidPlug(INSTRUMENTINDEX instr); public: afx_msg BOOL OnMouseWheel(UINT nFlags, short zDelta, CPoint pt); afx_msg BOOL OnToolTip(UINT id, NMHDR *pTTTStruct, LRESULT *pResult); Modified: trunk/OpenMPT/mptrack/Ctrl_seq.cpp =================================================================== --- trunk/OpenMPT/mptrack/Ctrl_seq.cpp 2013-04-13 16:38:15 UTC (rev 1872) +++ trunk/OpenMPT/mptrack/Ctrl_seq.cpp 2013-04-14 00:32:41 UTC (rev 1873) @@ -1121,9 +1121,9 @@ CSoundFile &sndFile = m_pModDoc->GetrSoundFile(); const OrdSelection selection = GetCurSel(false); - const ORDERINDEX nInsertCount = selection.lastOrd - selection.firstOrd, nInsertEnd = selection.lastOrd; + const ORDERINDEX insertCount = selection.lastOrd - selection.firstOrd, insertEnd = selection.lastOrd; - for(ORDERINDEX i = 0; i <= nInsertCount; i++) + for(ORDERINDEX i = 0; i <= insertCount; i++) { // Checking whether there is some pattern at the end of orderlist. if (sndFile.Order.GetLength() < 1 || sndFile.Order.Last() < sndFile.Patterns.Size()) @@ -1131,20 +1131,21 @@ if(sndFile.Order.GetLength() < sndFile.GetModSpecifications().ordersMax) sndFile.Order.Append(); } - for(int j = sndFile.Order.GetLastIndex(); j > nInsertEnd; j--) + for(int j = sndFile.Order.GetLastIndex(); j > insertEnd; j--) sndFile.Order[j] = sndFile.Order[j - 1]; } // now that there is enough space in the order list, overwrite the orders - for(ORDERINDEX i = 0; i <= nInsertCount; i++) + for(ORDERINDEX i = 0; i <= insertCount; i++) { - if(nInsertEnd + i + 1 < sndFile.GetModSpecifications().ordersMax - && - nInsertEnd + i + 1 < sndFile.Order.GetLength()) - sndFile.Order[nInsertEnd + i + 1] = sndFile.Order[nInsertEnd - nInsertCount + i]; + if(insertEnd + i + 1 < sndFile.GetModSpecifications().ordersMax + && insertEnd + i + 1 < sndFile.Order.GetLength()) + { + sndFile.Order[insertEnd + i + 1] = sndFile.Order[insertEnd - insertCount + i]; + } } - m_nScrollPos = MIN(nInsertEnd + 1, sndFile.Order.GetLastIndex()); - if(nInsertCount > 0) - m_nScrollPos2nd = MIN(m_nScrollPos + nInsertCount, sndFile.Order.GetLastIndex()); + m_nScrollPos = std::min(ORDERINDEX(insertEnd + 1), sndFile.Order.GetLastIndex()); + if(insertCount > 0) + m_nScrollPos2nd = std::min(ORDERINDEX(m_nScrollPos + insertCount), sndFile.Order.GetLastIndex()); else m_nScrollPos2nd = ORDERINDEX_INVALID; Modified: trunk/OpenMPT/mptrack/InputHandler.cpp =================================================================== --- trunk/OpenMPT/mptrack/InputHandler.cpp 2013-04-13 16:38:15 UTC (rev 1872) +++ trunk/OpenMPT/mptrack/InputHandler.cpp 2013-04-14 00:32:41 UTC (rev 1873) @@ -147,9 +147,6 @@ { CommandID executeCommand = keyMap[context][modifierMask][nChar][keyEventType]; -/* if (keyEventType == kKeyEventUp) - keyEventType=kKeyEventUp; -*/ if(pSourceWnd == nullptr) pSourceWnd = m_pMainFrm; //by default, send command message to main frame. Modified: trunk/OpenMPT/mptrack/Moptions.cpp =================================================================== --- trunk/OpenMPT/mptrack/Moptions.cpp 2013-04-13 16:38:15 UTC (rev 1872) +++ trunk/OpenMPT/mptrack/Moptions.cpp 2013-04-14 00:32:41 UTC (rev 1873) @@ -108,7 +108,7 @@ } -BOOL COptionsColors::OnKillActive() +BOOL COptionsColors::OnKillActive() //--------------------------------- { int temp_nRowSpacing = GetDlgItemInt(IDC_PRIMARYHILITE); @@ -260,8 +260,8 @@ PREVIEWBMP_HEIGHT, m_pPreviewDib->lpDibBits, (LPBITMAPINFO)m_pPreviewDib, - DIB_RGB_COLORS, - SRCCOPY); + DIB_RGB_COLORS, + SRCCOPY); } } @@ -332,7 +332,7 @@ void COptionsColors::OnSettingsChanged() //-------------------------------------- { - SetModified(TRUE); + SetModified(TRUE); } void COptionsColors::OnUpdateDialog() Modified: trunk/OpenMPT/mptrack/Mpdlgs.cpp =================================================================== --- trunk/OpenMPT/mptrack/Mpdlgs.cpp 2013-04-13 16:38:15 UTC (rev 1872) +++ trunk/OpenMPT/mptrack/Mpdlgs.cpp 2013-04-14 00:32:41 UTC (rev 1873) @@ -354,7 +354,7 @@ vector<bool> supportedRates; vector<UINT> samplerates; - for(size_t i = 0; i < NUMMIXRATE; i++) + for(size_t i = 0; i < CountOf(nMixingRates); i++) { samplerates.push_back(nMixingRates[i]); } @@ -392,7 +392,7 @@ supportedRates.assign(samplerates.size(), true); } int n = 1; - for(size_t i = 0; i < NUMMIXRATE; i++) + for(size_t i = 0; i < CountOf(nMixingRates); i++) { if(supportedRates[i]) { @@ -504,6 +504,7 @@ } } + ////////////////////////////////////////////////////////// // COptionsPlayer @@ -806,8 +807,6 @@ CMainFrame::GetMainFrame()->SetupPlayer(); } #endif - // Notify CMainFrame - CMainFrame *pParent = CMainFrame::GetMainFrame(); //rewbs.resamplerConf CString s; m_CEditWFIRCutoff.GetWindowText(s); Modified: trunk/OpenMPT/mptrack/PatternEditorDialogs.cpp =================================================================== --- trunk/OpenMPT/mptrack/PatternEditorDialogs.cpp 2013-04-13 16:38:15 UTC (rev 1872) +++ trunk/OpenMPT/mptrack/PatternEditorDialogs.cpp 2013-04-14 00:32:41 UTC (rev 1873) @@ -185,7 +185,7 @@ combo->SetItemData(combo->AddString("ins -1"), replaceInstrumentMinusOne); combo->SetItemData(combo->AddString("ins +1"), replaceInstrumentPlusOne); } - for (UINT n=1; n<MAX_INSTRUMENTS; n++) + for(INSTRUMENTINDEX n = 1; n < MAX_INSTRUMENTS; n++) { if(sndFile.GetNumInstruments()) { Modified: trunk/OpenMPT/mptrack/PatternGotoDialog.cpp =================================================================== --- trunk/OpenMPT/mptrack/PatternGotoDialog.cpp 2013-04-13 16:38:15 UTC (rev 1872) +++ trunk/OpenMPT/mptrack/PatternGotoDialog.cpp 2013-04-14 00:32:41 UTC (rev 1873) @@ -51,50 +51,44 @@ // CPatternGotoDialog message handlers -void CPatternGotoDialog::UpdatePos(UINT row, UINT chan, UINT pat, UINT ord, CSoundFile* pSndFile) +void CPatternGotoDialog::UpdatePos(ROWINDEX row, CHANNELINDEX chan, PATTERNINDEX pat, ORDERINDEX ord, CSoundFile &sndFile) { m_nRow = row; m_nChannel = chan; - m_nPattern = static_cast<PATTERNINDEX>(pat); + m_nPattern = pat; m_nActiveOrder = ord; m_nOrder = ord; - m_pSndFile = pSndFile; + m_pSndFile = &sndFile; } void CPatternGotoDialog::OnOK() { UpdateData(); - bool validated=true; + bool validated = true; - //is pattern number sensible? - if(m_nPattern>=m_pSndFile->Patterns.Size()) + // Does pattern exist? + if(validated && !m_pSndFile->Patterns.IsValidPat(m_nPattern)) { - validated=false; + validated = false; } - - //Does pattern exist? - if(validated && !(m_pSndFile->Patterns[m_nPattern])) - { - validated=false; - } - //Does order match pattern? + // Does order match pattern? if(validated && m_pSndFile->Order[m_nOrder] != m_nPattern) { - validated=false; + validated = false; } - //Does pattern have enough rows? + // Does pattern have enough rows? if(validated && m_pSndFile->Patterns[m_nPattern].GetNumRows() <= m_nRow) { - validated=false; + validated = false; } - //Does track have enough channels? + // Does track have enough channels? if(validated && m_pSndFile->m_nChannels < m_nChannel) { - validated=false; + validated = false; } @@ -122,7 +116,7 @@ if(m_nOrder == ORDERINDEX_INVALID) { - m_nOrder=0; + m_nOrder = 0; } LockControls(); @@ -141,8 +135,8 @@ if(m_nOrder<m_pSndFile->Order.size()) { - UINT candidatePattern = m_pSndFile->Order[m_nOrder]; - if(candidatePattern<m_pSndFile->Patterns.Size() && m_pSndFile->Patterns[candidatePattern]) + PATTERNINDEX candidatePattern = m_pSndFile->Order[m_nOrder]; + if(candidatePattern < m_pSndFile->Patterns.Size() && m_pSndFile->Patterns[candidatePattern]) { m_nPattern = candidatePattern; } Modified: trunk/OpenMPT/mptrack/PatternGotoDialog.h =================================================================== --- trunk/OpenMPT/mptrack/PatternGotoDialog.h 2013-04-13 16:38:15 UTC (rev 1872) +++ trunk/OpenMPT/mptrack/PatternGotoDialog.h 2013-04-14 00:32:41 UTC (rev 1873) @@ -27,7 +27,7 @@ public: UINT m_nRow, m_nChannel, m_nPattern, m_nOrder, m_nActiveOrder; - void UpdatePos(UINT row, UINT chan, UINT pat, UINT ord, CSoundFile* pSndFile); + void UpdatePos(ROWINDEX row, CHANNELINDEX chan, PATTERNINDEX pat, ORDERINDEX ord, CSoundFile &sndFile); protected: bool m_bControlLock; Modified: trunk/OpenMPT/mptrack/View_pat.cpp =================================================================== --- trunk/OpenMPT/mptrack/View_pat.cpp 2013-04-13 16:38:15 UTC (rev 1872) +++ trunk/OpenMPT/mptrack/View_pat.cpp 2013-04-14 00:32:41 UTC (rev 1873) @@ -1975,11 +1975,11 @@ } if (m_pGotoWnd) { - CSoundFile *pSndFile = pModDoc->GetSoundFile(); + CSoundFile &sndFile = pModDoc->GetrSoundFile(); ORDERINDEX curOrder = GetCurrentOrder(); CHANNELINDEX curChannel = GetCurrentChannel() + 1; - m_pGotoWnd->UpdatePos(GetCurrentRow(), curChannel, m_nPattern, curOrder, pSndFile); + m_pGotoWnd->UpdatePos(GetCurrentRow(), curChannel, m_nPattern, curOrder, sndFile); if (m_pGotoWnd->DoModal() == IDOK) { Modified: trunk/OpenMPT/mptrack/test/test.cpp =================================================================== --- trunk/OpenMPT/mptrack/test/test.cpp 2013-04-13 16:38:15 UTC (rev 1872) +++ trunk/OpenMPT/mptrack/test/test.cpp 2013-04-14 00:32:41 UTC (rev 1873) @@ -3,8 +3,7 @@ * -------- * Purpose: Unit tests for OpenMPT. * Notes : We need FAAAAAAAR more unit tests! - * Authors: Olivier Lapicque - * OpenMPT Devs + * Authors: OpenMPT Devs * The OpenMPT source code is released under the BSD license. Read LICENSE for more details. */ @@ -324,50 +323,50 @@ void TestLoadXMFile(const CModDoc *pModDoc) //----------------------------------------- { - const CSoundFile *pSndFile = pModDoc->GetSoundFile(); + const CSoundFile &sndFile = pModDoc->GetrSoundFile(); // Global Variables - VERIFY_EQUAL_NONCONT(strcmp(pSndFile->m_szNames[0], "Test Module"), 0); - VERIFY_EQUAL_NONCONT(pSndFile->songMessage.at(0), 'O'); - VERIFY_EQUAL_NONCONT(pSndFile->m_nDefaultTempo, 139); - VERIFY_EQUAL_NONCONT(pSndFile->m_nDefaultSpeed, 5); - VERIFY_EQUAL_NONCONT(pSndFile->m_nGlobalVolume, 128); - VERIFY_EQUAL_NONCONT(pSndFile->m_nVSTiVolume, 42); - VERIFY_EQUAL_NONCONT(pSndFile->m_nSamplePreAmp, 23); - VERIFY_EQUAL_NONCONT((pSndFile->m_SongFlags & SONG_FILE_FLAGS), SONG_EMBEDMIDICFG | SONG_LINEARSLIDES | SONG_EXFILTERRANGE); - VERIFY_EQUAL_NONCONT(pSndFile->GetModFlag(MSF_COMPATIBLE_PLAY), true); - VERIFY_EQUAL_NONCONT(pSndFile->GetModFlag(MSF_MIDICC_BUGEMULATION), false); - VERIFY_EQUAL_NONCONT(pSndFile->GetModFlag(MSF_OLDVOLSWING), false); - VERIFY_EQUAL_NONCONT(pSndFile->GetModFlag(MSF_OLD_MIDI_PITCHBENDS), false); - VERIFY_EQUAL_NONCONT(pSndFile->m_nMixLevels, mixLevels_compatible); - VERIFY_EQUAL_NONCONT(pSndFile->m_nTempoMode, tempo_mode_modern); - VERIFY_EQUAL_NONCONT(pSndFile->m_nDefaultRowsPerBeat, 6); - VERIFY_EQUAL_NONCONT(pSndFile->m_nDefaultRowsPerMeasure, 12); - VERIFY_EQUAL_NONCONT(pSndFile->m_dwCreatedWithVersion, MAKE_VERSION_NUMERIC(1, 19, 02, 05)); - VERIFY_EQUAL_NONCONT(pSndFile->m_nRestartPos, 1); + VERIFY_EQUAL_NONCONT(strcmp(sndFile.m_szNames[0], "Test Module"), 0); + VERIFY_EQUAL_NONCONT(sndFile.songMessage.at(0), 'O'); + VERIFY_EQUAL_NONCONT(sndFile.m_nDefaultTempo, 139); + VERIFY_EQUAL_NONCONT(sndFile.m_nDefaultSpeed, 5); + VERIFY_EQUAL_NONCONT(sndFile.m_nGlobalVolume, 128); + VERIFY_EQUAL_NONCONT(sndFile.m_nVSTiVolume, 42); + VERIFY_EQUAL_NONCONT(sndFile.m_nSamplePreAmp, 23); + VERIFY_EQUAL_NONCONT((sndFile.m_SongFlags & SONG_FILE_FLAGS), SONG_EMBEDMIDICFG | SONG_LINEARSLIDES | SONG_EXFILTERRANGE); + VERIFY_EQUAL_NONCONT(sndFile.GetModFlag(MSF_COMPATIBLE_PLAY), true); + VERIFY_EQUAL_NONCONT(sndFile.GetModFlag(MSF_MIDICC_BUGEMULATION), false); + VERIFY_EQUAL_NONCONT(sndFile.GetModFlag(MSF_OLDVOLSWING), false); + VERIFY_EQUAL_NONCONT(sndFile.GetModFlag(MSF_OLD_MIDI_PITCHBENDS), false); + VERIFY_EQUAL_NONCONT(sndFile.m_nMixLevels, mixLevels_compatible); + VERIFY_EQUAL_NONCONT(sndFile.m_nTempoMode, tempo_mode_modern); + VERIFY_EQUAL_NONCONT(sndFile.m_nDefaultRowsPerBeat, 6); + VERIFY_EQUAL_NONCONT(sndFile.m_nDefaultRowsPerMeasure, 12); + VERIFY_EQUAL_NONCONT(sndFile.m_dwCreatedWithVersion, MAKE_VERSION_NUMERIC(1, 19, 02, 05)); + VERIFY_EQUAL_NONCONT(sndFile.m_nRestartPos, 1); // Macros - VERIFY_EQUAL_NONCONT(pSndFile->m_MidiCfg.GetParameteredMacroType(0), sfx_reso); - VERIFY_EQUAL_NONCONT(pSndFile->m_MidiCfg.GetParameteredMacroType(1), sfx_drywet); - VERIFY_EQUAL_NONCONT(pSndFile->m_MidiCfg.GetFixedMacroType(), zxx_resomode); + VERIFY_EQUAL_NONCONT(sndFile.m_MidiCfg.GetParameteredMacroType(0), sfx_reso); + VERIFY_EQUAL_NONCONT(sndFile.m_MidiCfg.GetParameteredMacroType(1), sfx_drywet); + VERIFY_EQUAL_NONCONT(sndFile.m_MidiCfg.GetFixedMacroType(), zxx_resomode); // Channels - VERIFY_EQUAL_NONCONT(pSndFile->GetNumChannels(), 2); - VERIFY_EQUAL_NONCONT(strcmp(pSndFile->ChnSettings[0].szName, "First Channel"), 0); - VERIFY_EQUAL_NONCONT(pSndFile->ChnSettings[0].nMixPlugin, 0); + VERIFY_EQUAL_NONCONT(sndFile.GetNumChannels(), 2); + VERIFY_EQUAL_NONCONT(strcmp(sndFile.ChnSettings[0].szName, "First Channel"), 0); + VERIFY_EQUAL_NONCONT(sndFile.ChnSettings[0].nMixPlugin, 0); - VERIFY_EQUAL_NONCONT(strcmp(pSndFile->ChnSettings[1].szName, "Second Channel"), 0); - VERIFY_EQUAL_NONCONT(pSndFile->ChnSettings[1].nMixPlugin, 1); + VERIFY_EQUAL_NONCONT(strcmp(sndFile.ChnSettings[1].szName, "Second Channel"), 0); + VERIFY_EQUAL_NONCONT(sndFile.ChnSettings[1].nMixPlugin, 1); // Samples - VERIFY_EQUAL_NONCONT(pSndFile->GetNumSamples(), 3); - VERIFY_EQUAL_NONCONT(strcmp(pSndFile->m_szNames[1], "Pulse Sample"), 0); - VERIFY_EQUAL_NONCONT(strcmp(pSndFile->m_szNames[2], "Empty Sample"), 0); - VERIFY_EQUAL_NONCONT(strcmp(pSndFile->m_szNames[3], "Unassigned Sample"), 0); + VERIFY_EQUAL_NONCONT(sndFile.GetNumSamples(), 3); + VERIFY_EQUAL_NONCONT(strcmp(sndFile.m_szNames[1], "Pulse Sample"), 0); + VERIFY_EQUAL_NONCONT(strcmp(sndFile.m_szNames[2], "Empty Sample"), 0); + VERIFY_EQUAL_NONCONT(strcmp(sndFile.m_szNames[3], "Unassigned Sample"), 0); VERIFY_EQUAL_NONCONT(pModDoc->FindSampleParent(1), 1); VERIFY_EQUAL_NONCONT(pModDoc->FindSampleParent(2), 1); VERIFY_EQUAL_NONCONT(pModDoc->FindSampleParent(3), INSTRUMENTINDEX_INVALID); - const ModSample &sample = pSndFile->GetSample(1); + const ModSample &sample = sndFile.GetSample(1); VERIFY_EQUAL_NONCONT(sample.GetBytesPerSample(), 1); VERIFY_EQUAL_NONCONT(sample.GetNumChannels(), 1); VERIFY_EQUAL_NONCONT(sample.GetElementarySampleSize(), 1); @@ -388,18 +387,19 @@ VERIFY_EQUAL_NONCONT(sample.nVibDepth, 5); // Sample Data + const int8 *p8 = static_cast<const int8 *>(sample.pSample); for(size_t i = 0; i < 6; i++) { - VERIFY_EQUAL_NONCONT(static_cast<int8*>(sample.pSample)[i], 18); + VERIFY_EQUAL_NONCONT(p8[i], 18); } for(size_t i = 6; i < 16; i++) { - VERIFY_EQUAL_NONCONT(static_cast<int8*>(sample.pSample)[i], 0); + VERIFY_EQUAL_NONCONT(p8[i], 0); } // Instruments - VERIFY_EQUAL_NONCONT(pSndFile->GetNumInstruments(), 1); - const ModInstrument *pIns = pSndFile->Instruments[1]; + VERIFY_EQUAL_NONCONT(sndFile.GetNumInstruments(), 1); + const ModInstrument *pIns = sndFile.Instruments[1]; VERIFY_EQUAL_NONCONT(pIns->nFadeOut, 1024); VERIFY_EQUAL_NONCONT(pIns->nPan, 128); VERIFY_EQUAL_NONCONT(pIns->dwFlags, InstrumentFlags(0)); @@ -430,14 +430,14 @@ VERIFY_EQUAL_NONCONT(pIns->wMidiBank, 2); VERIFY_EQUAL_NONCONT(pIns->midiPWD, 8); - VERIFY_EQUAL_NONCONT(pIns->pTuning, pSndFile->GetDefaultTuning()); + VERIFY_EQUAL_NONCONT(pIns->pTuning, sndFile.GetDefaultTuning()); VERIFY_EQUAL_NONCONT(pIns->wPitchToTempoLock, 0); VERIFY_EQUAL_NONCONT(pIns->nPluginVelocityHandling, PLUGIN_VELOCITYHANDLING_VOLUME); VERIFY_EQUAL_NONCONT(pIns->nPluginVolumeHandling, PLUGIN_VOLUMEHANDLING_MIDI); - for(size_t i = pSndFile->GetModSpecifications().noteMin; i < pSndFile->GetModSpecifications().noteMax; i++) + for(size_t i = sndFile.GetModSpecifications().noteMin; i < sndFile.GetModSpecifications().noteMax; i++) { VERIFY_EQUAL_NONCONT(pIns->Keyboard[i], (i == NOTE_MIDDLEC - 1) ? 2 : 1); } @@ -462,51 +462,51 @@ VERIFY_EQUAL_NONCONT(pIns->PitchEnv.nNodes, 0); // Sequences - VERIFY_EQUAL_NONCONT(pSndFile->Order.GetNumSequences(), 1); - VERIFY_EQUAL_NONCONT(pSndFile->Order[0], 0); - VERIFY_EQUAL_NONCONT(pSndFile->Order[1], 1); + VERIFY_EQUAL_NONCONT(sndFile.Order.GetNumSequences(), 1); + VERIFY_EQUAL_NONCONT(sndFile.Order[0], 0); + VERIFY_EQUAL_NONCONT(sndFile.Order[1], 1); // Patterns - VERIFY_EQUAL_NONCONT(pSndFile->Patterns.GetNumPatterns(), 2); + VERIFY_EQUAL_NONCONT(sndFile.Patterns.GetNumPatterns(), 2); - VERIFY_EQUAL_NONCONT(pSndFile->Patterns[0].GetName(), "First Pattern"); - VERIFY_EQUAL_NONCONT(pSndFile->Patterns[0].GetNumRows(), 64); - VERIFY_EQUAL_NONCONT(pSndFile->Patterns[0].GetNumChannels(), 2); - VERIFY_EQUAL_NONCONT(pSndFile->Patterns[0].GetOverrideSignature(), false); - VERIFY_EQUAL_NONCONT(pSndFile->Patterns[0].GetRowsPerBeat(), 0); - VERIFY_EQUAL_NONCONT(pSndFile->Patterns[0].GetRowsPerMeasure(), 0); - VERIFY_EQUAL_NONCONT(pSndFile->Patterns.IsPatternEmpty(0), true); + VERIFY_EQUAL_NONCONT(sndFile.Patterns[0].GetName(), "First Pattern"); + VERIFY_EQUAL_NONCONT(sndFile.Patterns[0].GetNumRows(), 64); + VERIFY_EQUAL_NONCONT(sndFile.Patterns[0].GetNumChannels(), 2); + VERIFY_EQUAL_NONCONT(sndFile.Patterns[0].GetOverrideSignature(), false); + VERIFY_EQUAL_NONCONT(sndFile.Patterns[0].GetRowsPerBeat(), 0); + VERIFY_EQUAL_NONCONT(sndFile.Patterns[0].GetRowsPerMeasure(), 0); + VERIFY_EQUAL_NONCONT(sndFile.Patterns.IsPatternEmpty(0), true); - VERIFY_EQUAL_NONCONT(pSndFile->Patterns[1].GetName(), "Second Pattern"); - VERIFY_EQUAL_NONCONT(pSndFile->Patterns[1].GetNumRows(), 32); - VERIFY_EQUAL_NONCONT(pSndFile->Patterns[1].GetNumChannels(), 2); - VERIFY_EQUAL_NONCONT(pSndFile->Patterns[1].GetOverrideSignature(), false); - VERIFY_EQUAL_NONCONT(pSndFile->Patterns[1].GetRowsPerBeat(), 0); - VERIFY_EQUAL_NONCONT(pSndFile->Patterns[1].GetRowsPerMeasure(), 0); - VERIFY_EQUAL_NONCONT(pSndFile->Patterns.IsPatternEmpty(1), false); - VERIFY_EQUAL_NONCONT(pSndFile->Patterns[1].GetpModCommand(0, 0)->IsPcNote(), false); - VERIFY_EQUAL_NONCONT(pSndFile->Patterns[1].GetpModCommand(0, 0)->note, NOTE_NONE); - VERIFY_EQUAL_NONCONT(pSndFile->Patterns[1].GetpModCommand(0, 0)->instr, 0); - VERIFY_EQUAL_NONCONT(pSndFile->Patterns[1].GetpModCommand(0, 0)->volcmd, VOLCMD_VIBRATOSPEED); - VERIFY_EQUAL_NONCONT(pSndFile->Patterns[1].GetpModCommand(0, 0)->vol, 15); - VERIFY_EQUAL_NONCONT(pSndFile->Patterns[1].GetpModCommand(31, 0)->IsEmpty(), true); - VERIFY_EQUAL_NONCONT(pSndFile->Patterns[1].GetpModCommand(31, 1)->IsEmpty(), false); - VERIFY_EQUAL_NONCONT(pSndFile->Patterns[1].GetpModCommand(31, 1)->IsPcNote(), false); - VERIFY_EQUAL_NONCONT(pSndFile->Patterns[1].GetpModCommand(31, 1)->note, NOTE_MIDDLEC + 12); - VERIFY_EQUAL_NONCONT(pSndFile->Patterns[1].GetpModCommand(31, 1)->instr, 45); - VERIFY_EQUAL_NONCONT(pSndFile->Patterns[1].GetpModCommand(31, 1)->volcmd, VOLCMD_VOLSLIDEDOWN); - VERIFY_EQUAL_NONCONT(pSndFile->Patterns[1].GetpModCommand(31, 1)->vol, 5); - VERIFY_EQUAL_NONCONT(pSndFile->Patterns[1].GetpModCommand(31, 1)->command, CMD_PANNING8); - VERIFY_EQUAL_NONCONT(pSndFile->Patterns[1].GetpModCommand(31, 1)->param, 0xFF); + VERIFY_EQUAL_NONCONT(sndFile.Patterns[1].GetName(), "Second Pattern"); + VERIFY_EQUAL_NONCONT(sndFile.Patterns[1].GetNumRows(), 32); + VERIFY_EQUAL_NONCONT(sndFile.Patterns[1].GetNumChannels(), 2); + VERIFY_EQUAL_NONCONT(sndFile.Patterns[1].GetOverrideSignature(), false); + VERIFY_EQUAL_NONCONT(sndFile.Patterns[1].GetRowsPerBeat(), 0); + VERIFY_EQUAL_NONCONT(sndFile.Patterns[1].GetRowsPerMeasure(), 0); + VERIFY_EQUAL_NONCONT(sndFile.Patterns.IsPatternEmpty(1), false); + VERIFY_EQUAL_NONCONT(sndFile.Patterns[1].GetpModCommand(0, 0)->IsPcNote(), false); + VERIFY_EQUAL_NONCONT(sndFile.Patterns[1].GetpModCommand(0, 0)->note, NOTE_NONE); + VERIFY_EQUAL_NONCONT(sndFile.Patterns[1].GetpModCommand(0, 0)->instr, 0); + VERIFY_EQUAL_NONCONT(sndFile.Patterns[1].GetpModCommand(0, 0)->volcmd, VOLCMD_VIBRATOSPEED); + VERIFY_EQUAL_NONCONT(sndFile.Patterns[1].GetpModCommand(0, 0)->vol, 15); + VERIFY_EQUAL_NONCONT(sndFile.Patterns[1].GetpModCommand(31, 0)->IsEmpty(), true); + VERIFY_EQUAL_NONCONT(sndFile.Patterns[1].GetpModCommand(31, 1)->IsEmpty(), false); + VERIFY_EQUAL_NONCONT(sndFile.Patterns[1].GetpModCommand(31, 1)->IsPcNote(), false); + VERIFY_EQUAL_NONCONT(sndFile.Patterns[1].GetpModCommand(31, 1)->note, NOTE_MIDDLEC + 12); + VERIFY_EQUAL_NONCONT(sndFile.Patterns[1].GetpModCommand(31, 1)->instr, 45); + VERIFY_EQUAL_NONCONT(sndFile.Patterns[1].GetpModCommand(31, 1)->volcmd, VOLCMD_VOLSLIDEDOWN); + VERIFY_EQUAL_NONCONT(sndFile.Patterns[1].GetpModCommand(31, 1)->vol, 5); + VERIFY_EQUAL_NONCONT(sndFile.Patterns[1].GetpModCommand(31, 1)->command, CMD_PANNING8); + VERIFY_EQUAL_NONCONT(sndFile.Patterns[1].GetpModCommand(31, 1)->param, 0xFF); // Test 4-Bit Panning conversion for(int i = 0; i < 16; i++) { - VERIFY_EQUAL_NONCONT(pSndFile->Patterns[1].GetpModCommand(10 + i, 0)->vol, ((i * 64 + 8) / 15)); + VERIFY_EQUAL_NONCONT(sndFile.Patterns[1].GetpModCommand(10 + i, 0)->vol, ((i * 64 + 8) / 15)); } // Plugins - const SNDMIXPLUGIN &plug = pSndFile->m_MixPlugins[0]; + const SNDMIXPLUGIN &plug = sndFile.m_MixPlugins[0]; VERIFY_EQUAL_NONCONT(strcmp(plug.GetName(), "First Plugin"), 0); VERIFY_EQUAL_NONCONT(plug.fDryRatio, 0.26f); VERIFY_EQUAL_NONCONT(plug.IsMasterEffect(), true); @@ -518,27 +518,27 @@ void TestLoadMPTMFile(const CModDoc *pModDoc) //------------------------------------------- { - const CSoundFile *pSndFile = pModDoc->GetSoundFile(); + const CSoundFile &sndFile = pModDoc->GetrSoundFile(); // Global Variables - VERIFY_EQUAL_NONCONT(strcmp(pSndFile->m_szNames[0], "Test Module_____________X"), 0); - VERIFY_EQUAL_NONCONT(pSndFile->songMessage.at(0), 'O'); - VERIFY_EQUAL_NONCONT(pSndFile->m_nDefaultTempo, 139); - VERIFY_EQUAL_NONCONT(pSndFile->m_nDefaultSpeed, 5); - VERIFY_EQUAL_NONCONT(pSndFile->m_nGlobalVolume, 128); - VERIFY_EQUAL_NONCONT(pSndFile->m_nVSTiVolume, 42); - VERIFY_EQUAL_NONCONT(pSndFile->m_nSamplePreAmp, 23); - VERIFY_EQUAL_NONCONT((pSndFile->m_SongFlags & SONG_FILE_FLAGS), SONG_EMBEDMIDICFG | SONG_LINEARSLIDES | SONG_EXFILTERRANGE | SONG_ITCOMPATGXX | SONG_ITOLDEFFECTS); - VERIFY_EQUAL_NONCONT(pSndFile->GetModFlag(MSF_COMPATIBLE_PLAY), true); - VERIFY_EQUAL_NONCONT(pSndFile->GetModFlag(MSF_MIDICC_BUGEMULATION), false); - VERIFY_EQUAL_NONCONT(pSndFile->GetModFlag(MSF_OLDVOLSWING), false); - VERIFY_EQUAL_NONCONT(pSndFile->GetModFlag(MSF_OLD_MIDI_PITCHBENDS), false); - VERIFY_EQUAL_NONCONT(pSndFile->m_nMixLevels, mixLevels_compatible); - VERIFY_EQUAL_NONCONT(pSndFile->m_nTempoMode, tempo_mode_modern); - VERIFY_EQUAL_NONCONT(pSndFile->m_nDefaultRowsPerBeat, 6); - VERIFY_EQUAL_NONCONT(pSndFile->m_nDefaultRowsPerMeasure, 12); - VERIFY_EQUAL_NONCONT(pSndFile->m_dwCreatedWithVersion, MAKE_VERSION_NUMERIC(1, 19, 02, 05)); - VERIFY_EQUAL_NONCONT(pSndFile->m_nRestartPos, 1); + VERIFY_EQUAL_NONCONT(strcmp(sndFile.m_szNames[0], "Test Module_____________X"), 0); + VERIFY_EQUAL_NONCONT(sndFile.songMessage.at(0), 'O'); + VERIFY_EQUAL_NONCONT(sndFile.m_nDefaultTempo, 139); + VERIFY_EQUAL_NONCONT(sndFile.m_nDefaultSpeed, 5); + VERIFY_EQUAL_NONCONT(sndFile.m_nGlobalVolume, 128); + VERIFY_EQUAL_NONCONT(sndFile.m_nVSTiVolume, 42); + VERIFY_EQUAL_NONCONT(sndFile.m_nSamplePreAmp, 23); + VERIFY_EQUAL_NONCONT((sndFile.m_SongFlags & SONG_FILE_FLAGS), SONG_EMBEDMIDICFG | SONG_LINEARSLIDES | SONG_EXFILTERRANGE | SONG_ITCOMPATGXX | SONG_ITOLDEFFECTS); + VERIFY_EQUAL_NONCONT(sndFile.GetModFlag(MSF_COMPATIBLE_PLAY), true); + VERIFY_EQUAL_NONCONT(sndFile.GetModFlag(MSF_MIDICC_BUGEMULATION), false); + VERIFY_EQUAL_NONCONT(sndFile.GetModFlag(MSF_OLDVOLSWING), false); + VERIFY_EQUAL_NONCONT(sndFile.GetModFlag(MSF_OLD_MIDI_PITCHBENDS), false); + VERIFY_EQUAL_NONCONT(sndFile.m_nMixLevels, mixLevels_compatible); + VERIFY_EQUAL_NONCONT(sndFile.m_nTempoMode, tempo_mode_modern); + VERIFY_EQUAL_NONCONT(sndFile.m_nDefaultRowsPerBeat, 6); + VERIFY_EQUAL_NONCONT(sndFile.m_nDefaultRowsPerMeasure, 12); + VERIFY_EQUAL_NONCONT(sndFile.m_dwCreatedWithVersion, MAKE_VERSION_NUMERIC(1, 19, 02, 05)); + VERIFY_EQUAL_NONCONT(sndFile.m_nRestartPos, 1); // Edit history VERIFY_EQUAL_NONCONT(pModDoc->GetFileHistory().size() > 0, true); @@ -552,34 +552,34 @@ VERIFY_EQUAL_NONCONT((uint32)((double)fh.openTime / HISTORY_TIMER_PRECISION), 31); // Macros - VERIFY_EQUAL_NONCONT(pSndFile->m_MidiCfg.GetParameteredMacroType(0), sfx_reso); - VERIFY_EQUAL_NONCONT(pSndFile->m_MidiCfg.GetParameteredMacroType(1), sfx_drywet); - VERIFY_EQUAL_NONCONT(pSndFile->m_MidiCfg.GetParameteredMacroType(2), sfx_polyAT); - VERIFY_EQUAL_NONCONT(pSndFile->m_MidiCfg.GetFixedMacroType(), zxx_resomode); + VERIFY_EQUAL_NONCONT(sndFile.m_MidiCfg.GetParameteredMacroType(0), sfx_reso); + VERIFY_EQUAL_NONCONT(sndFile.m_MidiCfg.GetParameteredMacroType(1), sfx_drywet); + VERIFY_EQUAL_NONCONT(sndFile.m_MidiCfg.GetParameteredMacroType(2), sfx_polyAT); + VERIFY_EQUAL_NONCONT(sndFile.m_MidiCfg.GetFixedMacroType(), zxx_resomode); // Channels - VERIFY_EQUAL_NONCONT(pSndFile->GetNumChannels(), 70); - VERIFY_EQUAL_NONCONT(strcmp(pSndFile->ChnSettings[0].szName, "First Channel"), 0); - VERIFY_EQUAL_NONCONT(pSndFile->ChnSettings[0].nPan, 32); - VERIFY_EQUAL_NONCONT(pSndFile->ChnSettings[0].nVolume, 32); - VERIFY_EQUAL_NONCONT(pSndFile->ChnSettings[0].dwFlags, CHN_MUTE); - VERIFY_EQUAL_NONCONT(pSndFile->ChnSettings[0].nMixPlugin, 0); + VERIFY_EQUAL_NONCONT(sndFile.GetNumChannels(), 70); + VERIFY_EQUAL_NONCONT(strcmp(sndFile.ChnSettings[0].szName, "First Channel"), 0); + VERIFY_EQUAL_NONCONT(sndFile.ChnSettings[0].nPan, 32); + VERIFY_EQUAL_NONCONT(sndFile.ChnSettings[0].nVolume, 32); + VERIFY_EQUAL_NONCONT(sndFile.ChnSettings[0].dwFlags, CHN_MUTE); + VERIFY_EQUAL_NONCONT(sndFile.ChnSettings[0].nMixPlugin, 0); - VERIFY_EQUAL_NONCONT(strcmp(pSndFile->ChnSettings[1].szName, "Second Channel"), 0); - VERIFY_EQUAL_NONCONT(pSndFile->ChnSettings[1].nPan, 128); - VERIFY_EQUAL_NONCONT(pSndFile->ChnSettings[1].nVolume, 16); - VERIFY_EQUAL_NONCONT(pSndFile->ChnSettings[1].dwFlags, CHN_SURROUND); - VERIFY_EQUAL_NONCONT(pSndFile->ChnSettings[1].nMixPlugin, 1); + VERIFY_EQUAL_NONCONT(strcmp(sndFile.ChnSettings[1].szName, "Second Channel"), 0); + VERIFY_EQUAL_NONCONT(sndFile.ChnSettings[1].nPan, 128); + VERIFY_EQUAL_NONCONT(sndFile.ChnSettings[1].nVolume, 16); + VERIFY_EQUAL_NONCONT(sndFile.ChnSettings[1].dwFlags, CHN_SURROUND); + VERIFY_EQUAL_NONCONT(sndFile.ChnSettings[1].nMixPlugin, 1); - VERIFY_EQUAL_NONCONT(strcmp(pSndFile->ChnSettings[69].szName, "Last Channel______X"), 0); - VERIFY_EQUAL_NONCONT(pSndFile->ChnSettings[69].nPan, 256); - VERIFY_EQUAL_NO... [truncated message content] |
From: <man...@us...> - 2013-04-14 13:46:02
|
Revision: 1875 http://sourceforge.net/p/modplug/code/1875 Author: manxorist Date: 2013-04-14 13:45:50 +0000 (Sun, 14 Apr 2013) Log Message: ----------- [Ref] Split sound device flags from mixer flags. [Mod] Rename "Use secondary buffers" option to the negated form "Use primary buffer". [Imp] Support exclusive device access also for wasapi devices. Show "Use primary buffer" as "Use device exclusively" in that case. [Fix] New installations defaulted to not using secondary buffers since some time. This was accidental, revert to non-primary access by default. [Mod] OpenMPT: Version is now 1.22.01.03 Modified Paths: -------------- trunk/OpenMPT/common/version.h 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/mptrack/mptrack.rc trunk/OpenMPT/sounddev/SoundDevice.cpp trunk/OpenMPT/soundlib/Snd_defs.h Modified: trunk/OpenMPT/common/version.h =================================================================== --- trunk/OpenMPT/common/version.h 2013-04-14 11:18:13 UTC (rev 1874) +++ trunk/OpenMPT/common/version.h 2013-04-14 13:45:50 UTC (rev 1875) @@ -19,7 +19,7 @@ #define VER_MAJORMAJOR 1 #define VER_MAJOR 22 #define VER_MINOR 01 -#define VER_MINORMINOR 02 +#define VER_MINORMINOR 03 //Creates version number from version parts that appears in version string. //For example MAKE_VERSION_NUMERIC(1,17,02,28) gives version number of Modified: trunk/OpenMPT/mptrack/MainFrm.cpp =================================================================== --- trunk/OpenMPT/mptrack/MainFrm.cpp 2013-04-14 11:18:13 UTC (rev 1874) +++ trunk/OpenMPT/mptrack/MainFrm.cpp 2013-04-14 13:45:50 UTC (rev 1875) @@ -498,6 +498,26 @@ } +bool CMainFrame::WritePrivateProfileBool(const CString section, const CString key, const bool value, const CString iniFile) +{ + CHAR valueBuffer[INIBUFFERSIZE]; + wsprintf(valueBuffer, "%li", value?1:0); + return (WritePrivateProfileString(section, key, valueBuffer, iniFile) != 0); +} + + +bool CMainFrame::GetPrivateProfileBool(const CString section, const CString key, const bool defaultValue, const CString iniFile) +{ + CHAR defaultValueBuffer[INIBUFFERSIZE]; + wsprintf(defaultValueBuffer, "%li", defaultValue?1:0); + + CHAR valueBuffer[INIBUFFERSIZE]; + GetPrivateProfileString(section, key, defaultValueBuffer, valueBuffer, INIBUFFERSIZE, iniFile); + + return atol(valueBuffer)?true:false; +} + + bool CMainFrame::WritePrivateProfileLong(const CString section, const CString key, const long value, const CString iniFile) { CHAR valueBuffer[INIBUFFERSIZE]; @@ -817,11 +837,7 @@ if(!gpSoundDevice) gpSoundDevice = CreateSoundDevice(nDevType); if(!gpSoundDevice) return false; gpSoundDevice->SetSource(this); - gpSoundDevice->Configure(m_hWnd, TrackerSettings::Instance().m_LatencyMS, TrackerSettings::Instance().m_UpdateIntervalMS, - ((TrackerSettings::Instance().m_MixerSettings.MixerFlags & SOUNDSETUP_SECONDARY) ? 0 : SNDDEV_OPTIONS_EXCLUSIVE) - | - ((TrackerSettings::Instance().m_MixerSettings.MixerFlags & SOUNDSETUP_NOBOOSTTHREADPRIORITY) ? 0 : SNDDEV_OPTIONS_BOOSTTHREADPRIORITY) - ); + gpSoundDevice->Configure(m_hWnd, TrackerSettings::Instance().m_LatencyMS, TrackerSettings::Instance().m_UpdateIntervalMS, TrackerSettings::Instance().GetSoundDeviceFlags()); if (!gpSoundDevice->Open(SNDDEV_GET_NUMBER(TrackerSettings::Instance().m_nWaveDevice), &WaveFormat.Format)) return false; } return true; @@ -1672,11 +1688,11 @@ } -BOOL CMainFrame::SetupSoundCard(DWORD q, 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, LONG wd) //--------------------------------------------------------------------------------------------------------------------------------------------- { const bool isPlaying = IsPlaying(); - if (((TrackerSettings::Instance().m_MixerSettings.MixerFlags & SOUNDSETUP_RESTARTMASK) != (q & SOUNDSETUP_RESTARTMASK)) + if ((TrackerSettings::Instance().GetSoundDeviceFlags() != deviceflags) || (TrackerSettings::Instance().m_MixerSettings.gdwMixingFreq != rate) || (TrackerSettings::Instance().m_nWaveDevice != wd) || (TrackerSettings::Instance().m_LatencyMS != latency_ms) @@ -1692,7 +1708,7 @@ } TrackerSettings::Instance().m_nWaveDevice = wd; TrackerSettings::Instance().m_MixerSettings.gdwMixingFreq = rate; - TrackerSettings::Instance().m_MixerSettings.MixerFlags = q; + TrackerSettings::Instance().SetSoundDeviceFlags(deviceflags); TrackerSettings::Instance().m_LatencyMS = latency_ms; TrackerSettings::Instance().m_UpdateIntervalMS = updateinterval_ms; TrackerSettings::Instance().m_MixerSettings.m_SampleFormat = sampleformat; @@ -1705,7 +1721,6 @@ UpdateWindow(); } else { - TrackerSettings::Instance().m_MixerSettings.MixerFlags = q; // No need to restart playback CriticalSection cs; if(GetSoundFilePlaying()) UpdateAudioParameters(*GetSoundFilePlaying(), FALSE); @@ -1865,7 +1880,7 @@ CPropertySheet dlg("OpenMPT Setup", this, m_nLastOptionsPage); COptionsGeneral general; - COptionsSoundcard sounddlg(TrackerSettings::Instance().m_MixerSettings.gdwMixingFreq, TrackerSettings::Instance().m_MixerSettings.MixerFlags, TrackerSettings::Instance().m_MixerSettings.m_SampleFormat, TrackerSettings::Instance().m_MixerSettings.gnChannels, TrackerSettings::Instance().m_LatencyMS, TrackerSettings::Instance().m_UpdateIntervalMS, TrackerSettings::Instance().m_nWaveDevice); + COptionsSoundcard sounddlg(TrackerSettings::Instance().m_MixerSettings.gdwMixingFreq, TrackerSettings::Instance().GetSoundDeviceFlags(), TrackerSettings::Instance().m_MixerSettings.m_SampleFormat, TrackerSettings::Instance().m_MixerSettings.gnChannels, TrackerSettings::Instance().m_LatencyMS, TrackerSettings::Instance().m_UpdateIntervalMS, TrackerSettings::Instance().m_nWaveDevice); COptionsKeyboard keyboard; COptionsColors colors; COptionsPlayer playerdlg; Modified: trunk/OpenMPT/mptrack/Mainfrm.h =================================================================== --- trunk/OpenMPT/mptrack/Mainfrm.h 2013-04-14 11:18:13 UTC (rev 1874) +++ trunk/OpenMPT/mptrack/Mainfrm.h 2013-04-14 13:45:50 UTC (rev 1875) @@ -357,6 +357,8 @@ static CInputHandler *m_InputHandler; //rewbs.customKeys static CAutoSaver *m_pAutoSaver; //rewbs.customKeys + static bool WritePrivateProfileBool(const CString section, const CString key, const bool value, const CString iniFile); + static bool GetPrivateProfileBool(const CString section, const CString key, const bool defaultValue, const CString iniFile); static bool WritePrivateProfileLong(const CString section, const CString key, const long value, const CString iniFile); static long GetPrivateProfileLong(const CString section, const CString key, const long defaultValue, const CString iniFile); static bool WritePrivateProfileDWord(const CString section, const CString key, const DWORD value, const CString iniFile); @@ -437,7 +439,7 @@ BOOL StopRenderer(CSoundFile*); void SwitchToActiveView(); - BOOL SetupSoundCard(DWORD q, 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, LONG wd); BOOL SetupMiscOptions(); BOOL SetupPlayer(); Modified: trunk/OpenMPT/mptrack/Mpdlgs.cpp =================================================================== --- trunk/OpenMPT/mptrack/Mpdlgs.cpp 2013-04-14 11:18:13 UTC (rev 1874) +++ trunk/OpenMPT/mptrack/Mpdlgs.cpp 2013-04-14 13:45:50 UTC (rev 1875) @@ -124,10 +124,10 @@ CHAR s[128]; CPropertyPage::OnInitDialog(); - if (m_dwSoundSetup & SNDMIX_SOFTPANNING) CheckDlgButton(IDC_CHECK2, MF_CHECKED); - if (m_dwSoundSetup & SNDMIX_ENABLEMMX) CheckDlgButton(IDC_CHECK3, MF_CHECKED); - if (m_dwSoundSetup & SOUNDSETUP_SECONDARY) CheckDlgButton(IDC_CHECK4, MF_CHECKED); - if (!(m_dwSoundSetup & SOUNDSETUP_NOBOOSTTHREADPRIORITY)) CheckDlgButton(IDC_CHECK5, MF_CHECKED); + if(TrackerSettings::Instance().m_MixerSettings.MixerFlags & SNDMIX_SOFTPANNING) CheckDlgButton(IDC_CHECK2, MF_CHECKED); + if(TrackerSettings::Instance().m_MixerSettings.MixerFlags & SNDMIX_ENABLEMMX) CheckDlgButton(IDC_CHECK3, MF_CHECKED); + if(m_SoundDeviceFlags & SNDDEV_OPTIONS_EXCLUSIVE) CheckDlgButton(IDC_CHECK4, MF_CHECKED); + if(m_SoundDeviceFlags & SNDDEV_OPTIONS_BOOSTTHREADPRIORITY) CheckDlgButton(IDC_CHECK5, MF_CHECKED); // Multimedia extensions ::EnableWindow(::GetDlgItem(m_hWnd, IDC_CHECK3), (CSoundFile::GetSysInfo() & PROCSUPPORT_MMX) ? TRUE : FALSE); if(CSoundFile::GetSysInfo() & PROCSUPPORT_SSE) @@ -245,9 +245,7 @@ nDev++; } } - GetDlgItem(IDC_CHECK4)->EnableWindow((SNDDEV_GET_TYPE(m_nSoundDevice) == SNDDEV_DSOUND /*|| SNDDEV_GET_TYPE(m_nSoundDevice) == SNDDEV_PORTAUDIO_WASAPI*/) ? TRUE : FALSE); - GetDlgItem(IDC_STATIC_UPDATEINTERVAL)->EnableWindow((SNDDEV_GET_TYPE(m_nSoundDevice) == SNDDEV_ASIO) ? FALSE : TRUE); - GetDlgItem(IDC_COMBO_UPDATEINTERVAL)->EnableWindow((SNDDEV_GET_TYPE(m_nSoundDevice) == SNDDEV_ASIO) ? FALSE : TRUE); + UpdateControls(m_nSoundDevice); } // Sample Format { @@ -336,9 +334,7 @@ if (n >= 0) { int dev = m_CbnDevice.GetItemData(n); - 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); + UpdateControls(dev); UpdateSampleRates(dev); OnSettingsChanged(); } @@ -406,6 +402,22 @@ } +void COptionsSoundcard::UpdateControls(int 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)->SetWindowText("Use primary buffer"); + } else + { + GetDlgItem(IDC_CHECK4)->SetWindowText("Use device exclusively"); + } +} + + BOOL COptionsSoundcard::OnSetActive() //----------------------------------- { @@ -417,11 +429,11 @@ void COptionsSoundcard::OnOK() //---------------------------- { - m_dwSoundSetup &= ~(SNDMIX_ENABLEMMX | SOUNDSETUP_SECONDARY | SNDMIX_SOFTPANNING | SOUNDSETUP_NOBOOSTTHREADPRIORITY); - if (IsDlgButtonChecked(IDC_CHECK2)) m_dwSoundSetup |= SNDMIX_SOFTPANNING; - if (IsDlgButtonChecked(IDC_CHECK3)) m_dwSoundSetup |= SNDMIX_ENABLEMMX; - if (IsDlgButtonChecked(IDC_CHECK4)) m_dwSoundSetup |= SOUNDSETUP_SECONDARY; - if (!IsDlgButtonChecked(IDC_CHECK5)) m_dwSoundSetup |= SOUNDSETUP_NOBOOSTTHREADPRIORITY; + if(IsDlgButtonChecked(IDC_CHECK2)) TrackerSettings::Instance().m_MixerSettings.MixerFlags |= SNDMIX_SOFTPANNING; else TrackerSettings::Instance().m_MixerSettings.MixerFlags &= ~SNDMIX_SOFTPANNING; + if(IsDlgButtonChecked(IDC_CHECK3)) TrackerSettings::Instance().m_MixerSettings.MixerFlags |= SNDMIX_ENABLEMMX; else TrackerSettings::Instance().m_MixerSettings.MixerFlags &= ~SNDMIX_ENABLEMMX; + m_SoundDeviceFlags = 0; + if(IsDlgButtonChecked(IDC_CHECK4)) m_SoundDeviceFlags |= SNDDEV_OPTIONS_EXCLUSIVE; + if(IsDlgButtonChecked(IDC_CHECK5)) m_SoundDeviceFlags |= SNDDEV_OPTIONS_BOOSTTHREADPRIORITY; // Mixing Freq { m_dwRate = m_CbnMixingFreq.GetItemData(m_CbnMixingFreq.GetCurSel()); @@ -467,7 +479,7 @@ wsprintf(s, "%d ms", m_UpdateIntervalMS); m_CbnUpdateIntervalMS.SetWindowText(s); } - CMainFrame::GetMainFrame()->SetupSoundCard(m_dwSoundSetup, m_dwRate, m_SampleFormat, m_nChannels, m_LatencyMS, m_UpdateIntervalMS, m_nSoundDevice); + CMainFrame::GetMainFrame()->SetupSoundCard(m_SoundDeviceFlags, m_dwRate, m_SampleFormat, m_nChannels, m_LatencyMS, m_UpdateIntervalMS, m_nSoundDevice); UpdateStatistics(); CPropertyPage::OnOK(); } Modified: trunk/OpenMPT/mptrack/Mpdlgs.h =================================================================== --- trunk/OpenMPT/mptrack/Mpdlgs.h 2013-04-14 11:18:13 UTC (rev 1874) +++ trunk/OpenMPT/mptrack/Mpdlgs.h 2013-04-14 13:45:50 UTC (rev 1875) @@ -24,7 +24,7 @@ CComboBox m_CbnLatencyMS, m_CbnUpdateIntervalMS, m_CbnMixingFreq, m_CbnPolyphony, m_CbnQuality; CSliderCtrl m_SliderStereoSep, m_SliderPreAmp; CEdit m_EditStatistics; - DWORD m_dwRate, m_dwSoundSetup; + DWORD m_dwRate, m_SoundDeviceFlags; SampleFormat m_SampleFormat; DWORD m_nChannels; DWORD m_LatencyMS; @@ -33,14 +33,15 @@ bool m_PreAmpNoteShowed; public: - COptionsSoundcard(DWORD rate, DWORD q, SampleFormat sampleformat, DWORD chns, DWORD latency_ms, DWORD updateinterval_ms, DWORD sd):CPropertyPage(IDD_OPTIONS_SOUNDCARD) - { m_dwRate = rate; m_dwSoundSetup = q; m_SampleFormat = sampleformat; m_nChannels = chns; + COptionsSoundcard(DWORD rate, DWORD flags, SampleFormat sampleformat, DWORD chns, DWORD latency_ms, DWORD updateinterval_ms, DWORD 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 UpdateControls(int dev); void SetPreAmpSliderPosition(); protected: Modified: trunk/OpenMPT/mptrack/TrackerSettings.cpp =================================================================== --- trunk/OpenMPT/mptrack/TrackerSettings.cpp 2013-04-14 11:18:13 UTC (rev 1874) +++ trunk/OpenMPT/mptrack/TrackerSettings.cpp 2013-04-14 13:45:50 UTC (rev 1875) @@ -23,12 +23,17 @@ #include "TrackerSettings.h" #include "../common/misc_util.h" #include "PatternClipboard.h" +#include "../sounddev/SoundDevice.h" #define OLD_SNDDEV_MINBUFFERLEN 1 // 1ms #define OLD_SNDDEV_MAXBUFFERLEN 1000 // 1sec +#define OLD_SOUNDSETUP_REVERSESTEREO 0x20 +#define OLD_SOUNDSETUP_SECONDARY 0x40 +#define OLD_SOUNDSETUP_NOBOOSTTHREADPRIORITY 0x80 + TrackerSettings TrackerSettings::settings; const TCHAR *TrackerSettings::m_szDirectoryToSettingsName[NUM_DIRS] = { _T("Songs_Directory"), _T("Samples_Directory"), _T("Instruments_Directory"), _T("Plugins_Directory"), _T("Plugin_Presets_Directory"), _T("Export_Directory"), _T(""), _T("") }; @@ -66,6 +71,8 @@ m_nWaveDevice = SNDDEV_BUILD_ID(0, SNDDEV_WAVEOUT); // Default value will be overridden m_LatencyMS = SNDDEV_DEFAULT_LATENCY_MS; m_UpdateIntervalMS = SNDDEV_DEFAULT_UPDATEINTERVAL_MS; + m_SoundDeviceExclusiveMode = false; + m_SoundDeviceBoostThreadPriority = true; #ifndef NO_EQ // Default EQ settings @@ -146,6 +153,21 @@ } +DWORD TrackerSettings::GetSoundDeviceFlags() const +//------------------------------------------------ +{ + return (m_SoundDeviceExclusiveMode ? SNDDEV_OPTIONS_EXCLUSIVE : 0) | (m_SoundDeviceBoostThreadPriority ? SNDDEV_OPTIONS_BOOSTTHREADPRIORITY : 0); +} + + +void TrackerSettings::SetSoundDeviceFlags(DWORD flags) +//---------------------------------------------------- +{ + m_SoundDeviceExclusiveMode = (flags & SNDDEV_OPTIONS_EXCLUSIVE) ? true : false; + m_SoundDeviceBoostThreadPriority = (flags & SNDDEV_OPTIONS_BOOSTTHREADPRIORITY) ? true : false; +} + + void TrackerSettings::GetDefaultColourScheme(COLORREF (&colours)[MAX_MODCOLORS]) //------------------------------------------------------------------------------ { @@ -255,7 +277,7 @@ } // GUI Stuff - m_ShowSplashScreen = !!CMainFrame::GetPrivateProfileLong("Display", "ShowSplashScreen", m_ShowSplashScreen, iniFile); + m_ShowSplashScreen = CMainFrame::GetPrivateProfileBool("Display", "ShowSplashScreen", m_ShowSplashScreen, iniFile); gbMdiMaximize = CMainFrame::GetPrivateProfileLong("Display", "MDIMaximize", gbMdiMaximize, iniFile); glTreeWindowWidth = CMainFrame::GetPrivateProfileLong("Display", "MDITreeWidth", glTreeWindowWidth, iniFile); glTreeSplitRatio = CMainFrame::GetPrivateProfileLong("Display", "MDITreeRatio", glTreeSplitRatio, iniFile); @@ -315,9 +337,18 @@ CASIODevice::baseChannel = GetPrivateProfileInt("Sound Settings", "ASIOBaseChannel", CASIODevice::baseChannel, iniFile); #endif // NO_ASIO m_nWaveDevice = CMainFrame::GetPrivateProfileLong("Sound Settings", "WaveDevice", defaultDevice, 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); - if(vIniVersion < MAKE_VERSION_NUMERIC(1, 21, 01, 26)) - m_MixerSettings.MixerFlags &= ~0x20; // Reverse stereo + m_SoundDeviceExclusiveMode = CMainFrame::GetPrivateProfileBool("Sound Settings", "ExclusiveMode", m_SoundDeviceExclusiveMode, iniFile); + m_SoundDeviceBoostThreadPriority = CMainFrame::GetPrivateProfileBool("Sound Settings", "BoostThreadPriority", m_SoundDeviceBoostThreadPriority, iniFile); + if(vIniVersion < MAKE_VERSION_NUMERIC(1, 21, 01, 26)) m_MixerSettings.MixerFlags &= ~OLD_SOUNDSETUP_REVERSESTEREO; + if(vIniVersion < MAKE_VERSION_NUMERIC(1, 22, 01, 03)) + { + m_SoundDeviceExclusiveMode = ((m_MixerSettings.MixerFlags & OLD_SOUNDSETUP_SECONDARY) == 0); + m_SoundDeviceBoostThreadPriority = ((m_MixerSettings.MixerFlags & OLD_SOUNDSETUP_NOBOOSTTHREADPRIORITY) == 0); + m_MixerSettings.MixerFlags &= ~OLD_SOUNDSETUP_SECONDARY; + m_MixerSettings.MixerFlags &= ~OLD_SOUNDSETUP_NOBOOSTTHREADPRIORITY; + } m_MixerSettings.DSPMask = CMainFrame::GetPrivateProfileDWord("Sound Settings", "Quality", m_MixerSettings.DSPMask, iniFile); m_ResamplerSettings.SrcMode = (ResamplingMode)CMainFrame::GetPrivateProfileDWord("Sound Settings", "SrcMode", m_ResamplerSettings.SrcMode, iniFile); m_MixerSettings.gdwMixingFreq = CMainFrame::GetPrivateProfileDWord("Sound Settings", "Mixing_Rate", 0, iniFile); @@ -580,7 +611,9 @@ if (RegOpenKeyEx(HKEY_CURRENT_USER, m_csRegKey, 0, KEY_READ, &key) == ERROR_SUCCESS) { RegQueryValueEx(key, "SoundSetup", NULL, &dwREG_DWORD, (LPBYTE)&m_MixerSettings.MixerFlags, &dwDWORDSize); - m_MixerSettings.MixerFlags &= ~0x20; // Reverse stereo + m_MixerSettings.MixerFlags &= ~OLD_SOUNDSETUP_REVERSESTEREO; + m_SoundDeviceExclusiveMode = ((m_MixerSettings.MixerFlags & OLD_SOUNDSETUP_SECONDARY) == 0); + m_MixerSettings.MixerFlags &= ~OLD_SOUNDSETUP_SECONDARY; RegQueryValueEx(key, "Quality", NULL, &dwREG_DWORD, (LPBYTE)&m_MixerSettings.DSPMask, &dwDWORDSize); DWORD dummysrcmode = m_ResamplerSettings.SrcMode; RegQueryValueEx(key, "SrcMode", NULL, &dwREG_DWORD, (LPBYTE)&dummysrcmode, &dwDWORDSize); @@ -791,6 +824,8 @@ CMainFrame::WritePrivateProfileLong("Sound Settings", "WaveDevice", m_nWaveDevice, 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); CMainFrame::WritePrivateProfileDWord("Sound Settings", "Quality", m_MixerSettings.DSPMask, iniFile); CMainFrame::WritePrivateProfileDWord("Sound Settings", "SrcMode", m_ResamplerSettings.SrcMode, iniFile); CMainFrame::WritePrivateProfileDWord("Sound Settings", "Mixing_Rate", m_MixerSettings.gdwMixingFreq, iniFile); Modified: trunk/OpenMPT/mptrack/TrackerSettings.h =================================================================== --- trunk/OpenMPT/mptrack/TrackerSettings.h 2013-04-14 11:18:13 UTC (rev 1874) +++ trunk/OpenMPT/mptrack/TrackerSettings.h 2013-04-14 13:45:50 UTC (rev 1875) @@ -117,11 +117,6 @@ #define MIDISETUP_PLAYPATTERNONMIDIIN 0x100 // Play pattern if MIDI Note is received and playback is paused -#define SOUNDSETUP_SECONDARY SNDMIX_SECONDARY -#define SOUNDSETUP_NOBOOSTTHREADPRIORITY SNDMIX_NOBOOSTTHREADPRIORITY -#define SOUNDSETUP_RESTARTMASK (SOUNDSETUP_SECONDARY|SOUNDSETUP_NOBOOSTTHREADPRIORITY) - - // EQ struct EQPreset { @@ -178,6 +173,11 @@ LONG m_nWaveDevice; // use the SNDDEV_GET_NUMBER and SNDDEV_GET_TYPE macros to decode DWORD m_LatencyMS; DWORD m_UpdateIntervalMS; + bool m_SoundDeviceExclusiveMode; + bool m_SoundDeviceBoostThreadPriority; + DWORD GetSoundDeviceFlags() const; + void SetSoundDeviceFlags(DWORD flags); + #ifndef NO_EQ EQPreset m_EqSettings; #endif Modified: trunk/OpenMPT/mptrack/mptrack.rc =================================================================== --- trunk/OpenMPT/mptrack/mptrack.rc 2013-04-14 11:18:13 UTC (rev 1874) +++ trunk/OpenMPT/mptrack/mptrack.rc 2013-04-14 13:45:50 UTC (rev 1875) @@ -1278,7 +1278,7 @@ CONTROL "",IDC_COMBO1,"ComboBoxEx32",CBS_DROPDOWNLIST | CBS_SORT | WS_VSCROLL | WS_TABSTOP,12,30,246,96 LTEXT "Latency:",IDC_STATIC,12,48,60,12,SS_CENTERIMAGE COMBOBOX IDC_COMBO2,78,48,72,83,CBS_DROPDOWN | WS_VSCROLL | WS_TABSTOP - CONTROL "Use secondary buffers",IDC_CHECK4,"Button",BS_AUTOCHECKBOX | WS_TABSTOP,156,48,102,12 + CONTROL "Use device exclusively",IDC_CHECK4,"Button",BS_AUTOCHECKBOX | WS_TABSTOP,156,48,102,12 LTEXT "Update Interval:",IDC_STATIC_UPDATEINTERVAL,12,66,60,12,SS_CENTERIMAGE COMBOBOX IDC_COMBO_UPDATEINTERVAL,78,66,72,83,CBS_DROPDOWN | WS_VSCROLL | WS_TABSTOP LTEXT "Mixing Quality:",IDC_STATIC,12,84,57,12,SS_CENTERIMAGE Modified: trunk/OpenMPT/sounddev/SoundDevice.cpp =================================================================== --- trunk/OpenMPT/sounddev/SoundDevice.cpp 2013-04-14 11:18:13 UTC (rev 1874) +++ trunk/OpenMPT/sounddev/SoundDevice.cpp 2013-04-14 13:45:50 UTC (rev 1875) @@ -1816,7 +1816,7 @@ } m_StreamParameters.suggestedLatency = m_LatencyMS / 1000.0; m_StreamParameters.hostApiSpecificStreamInfo = NULL; - if(false && (m_HostApi == Pa_HostApiTypeIdToHostApiIndex(paWASAPI)) && (m_fulCfgOptions & SNDDEV_OPTIONS_EXCLUSIVE)) + if((m_HostApi == Pa_HostApiTypeIdToHostApiIndex(paWASAPI)) && (m_fulCfgOptions & SNDDEV_OPTIONS_EXCLUSIVE)) { MemsetZero(m_WasapiStreamInfo); m_WasapiStreamInfo.size = sizeof(PaWasapiStreamInfo); @@ -1927,7 +1927,7 @@ StreamParameters.sampleFormat = paInt16; StreamParameters.suggestedLatency = 0.0; StreamParameters.hostApiSpecificStreamInfo = NULL; - if(false && (m_HostApi == Pa_HostApiTypeIdToHostApiIndex(paWASAPI)) && (m_fulCfgOptions & SNDDEV_OPTIONS_EXCLUSIVE)) + if((m_HostApi == Pa_HostApiTypeIdToHostApiIndex(paWASAPI)) && (m_fulCfgOptions & SNDDEV_OPTIONS_EXCLUSIVE)) { MemsetZero(m_WasapiStreamInfo); m_WasapiStreamInfo.size = sizeof(PaWasapiStreamInfo); Modified: trunk/OpenMPT/soundlib/Snd_defs.h =================================================================== --- trunk/OpenMPT/soundlib/Snd_defs.h 2013-04-14 11:18:13 UTC (rev 1874) +++ trunk/OpenMPT/soundlib/Snd_defs.h 2013-04-14 13:45:50 UTC (rev 1875) @@ -295,9 +295,6 @@ // Misc Flags (can safely be turned on or off) #define SNDMIX_ENABLEMMX 0x08 // use MMX-accelerated code -#define SNDMIX_SECONDARY 0x40 -#define SNDMIX_NOBOOSTTHREADPRIORITY 0x80 - //#define SNDMIX_NOBACKWARDJUMPS 0x40000 // stop when jumping back in the order (currently unused as it seems) #define SNDMIX_MAXDEFAULTPAN 0x80000 // Used by the MOD loader (currently unused) #define SNDMIX_MUTECHNMODE 0x100000 // Notes are not played on muted channels This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <man...@us...> - 2013-04-14 19:41:32
|
Revision: 1879 http://sourceforge.net/p/modplug/code/1879 Author: manxorist Date: 2013-04-14 19:41:22 +0000 (Sun, 14 Apr 2013) Log Message: ----------- [Var] Silence some compiler warnings. Modified Paths: -------------- trunk/OpenMPT/common/serialization_utils.cpp trunk/OpenMPT/mptrack/Ctrl_smp.cpp trunk/OpenMPT/soundlib/Snd_fx.cpp Modified: trunk/OpenMPT/common/serialization_utils.cpp =================================================================== --- trunk/OpenMPT/common/serialization_utils.cpp 2013-04-14 17:30:46 UTC (rev 1878) +++ trunk/OpenMPT/common/serialization_utils.cpp 2013-04-14 19:41:22 UTC (rev 1879) @@ -727,7 +727,7 @@ if (GetFlag(RwfRwHasMap)) { ReadAdaptive1248(iStrm, tempU64); - if(tempU64 > std::numeric_limits<Offtype>::max()) + if(tempU64 > static_cast<uint64>(std::numeric_limits<Offtype>::max())) { AddReadNote(SNR_INSUFFICIENT_STREAM_OFFTYPE); return; } } @@ -787,7 +787,7 @@ { uint64 tempU64; ReadAdaptive1248(iStrm, tempU64); - if(tempU64 > std::numeric_limits<Offtype>::max()) + if(tempU64 > static_cast<uint64>(std::numeric_limits<Offtype>::max())) { AddReadNote(SNR_INSUFFICIENT_STREAM_OFFTYPE); return; } mapData[i].rposStart = static_cast<RposType>(tempU64); } @@ -799,7 +799,7 @@ { uint64 tempU64; ReadAdaptive1248(iStrm, tempU64); - if(tempU64 > std::numeric_limits<Offtype>::max()) + if(tempU64 > static_cast<uint64>(std::numeric_limits<Offtype>::max())) { AddReadNote(SNR_INSUFFICIENT_STREAM_OFFTYPE); return; } mapData[i].nSize = static_cast<DataSize>(tempU64); } Modified: trunk/OpenMPT/mptrack/Ctrl_smp.cpp =================================================================== --- trunk/OpenMPT/mptrack/Ctrl_smp.cpp 2013-04-14 17:30:46 UTC (rev 1878) +++ trunk/OpenMPT/mptrack/Ctrl_smp.cpp 2013-04-14 19:41:22 UTC (rev 1879) @@ -373,9 +373,9 @@ if (m_sndFile.GetNumInstruments()) { INSTRUMENTINDEX k = m_parent.GetInstrumentChange(); - if (!m_modDoc.IsChildSample(k, lParam)) + if (!m_modDoc.IsChildSample(k, (SAMPLEINDEX)lParam)) { - INSTRUMENTINDEX nins = m_modDoc.FindSampleParent(lParam); + INSTRUMENTINDEX nins = m_modDoc.FindSampleParent((SAMPLEINDEX)lParam); if(nins != INSTRUMENTINDEX_INVALID) { m_parent.InstrumentChanged(nins); Modified: trunk/OpenMPT/soundlib/Snd_fx.cpp =================================================================== --- trunk/OpenMPT/soundlib/Snd_fx.cpp 2013-04-14 17:30:46 UTC (rev 1878) +++ trunk/OpenMPT/soundlib/Snd_fx.cpp 2013-04-14 19:41:22 UTC (rev 1879) @@ -502,7 +502,7 @@ } else if (((param & 0xF0) == 0xF0) && (param & 0x0F)) { - if (memory.chnSettings[nChn].chnVol > (param & 0x0F)) param = memory.chnSettings[nChn].chnVol - (param & 0x0F); + if (memory.chnSettings[nChn].chnVol > (UINT)(param & 0x0F)) param = memory.chnSettings[nChn].chnVol - (param & 0x0F); else param = 0; } else if (param & 0x0F) This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <man...@us...> - 2013-04-15 13:09:55
|
Revision: 1882 http://sourceforge.net/p/modplug/code/1882 Author: manxorist Date: 2013-04-15 13:09:48 +0000 (Mon, 15 Apr 2013) Log Message: ----------- [Ref] Move locking out of CPattern. Modified Paths: -------------- trunk/OpenMPT/mptrack/Modedit.cpp trunk/OpenMPT/soundlib/pattern.cpp Modified: trunk/OpenMPT/mptrack/Modedit.cpp =================================================================== --- trunk/OpenMPT/mptrack/Modedit.cpp 2013-04-15 12:52:49 UTC (rev 1881) +++ trunk/OpenMPT/mptrack/Modedit.cpp 2013-04-15 13:09:48 UTC (rev 1882) @@ -889,8 +889,10 @@ } BeginWaitCursor(); + CriticalSection cs; GetPatternUndo().PrepareUndo(nPattern, 0, 0, GetNumChannels(), numRows); bool success = m_SndFile.Patterns[nPattern].Expand(); + cs.Leave(); EndWaitCursor(); if(success) @@ -917,8 +919,10 @@ } BeginWaitCursor(); + CriticalSection cs; GetPatternUndo().PrepareUndo(nPattern, 0, 0, GetNumChannels(), numRows); bool success = m_SndFile.Patterns[nPattern].Shrink(); + cs.Leave(); EndWaitCursor(); if(success) Modified: trunk/OpenMPT/soundlib/pattern.cpp =================================================================== --- trunk/OpenMPT/soundlib/pattern.cpp 2013-04-15 12:52:49 UTC (rev 1881) +++ trunk/OpenMPT/soundlib/pattern.cpp 2013-04-15 13:09:48 UTC (rev 1882) @@ -13,7 +13,6 @@ #include "patternContainer.h" #include "../common/serialization_utils.h" #include "../common/version.h" -#include "../common/AudioCriticalSection.h" #include "ITTools.h" #include "Sndfile.h" @@ -86,7 +85,6 @@ // Copy over pattern data memcpy(newPattern, m_ModCommands, GetNumChannels() * std::min(m_Rows, newRowCount) * sizeof(ModCommand)); - CriticalSection cs; FreePattern(m_ModCommands); m_ModCommands = newPattern; m_Rows = newRowCount; @@ -156,7 +154,6 @@ memcpy(newPattern + y * 2 * nChns, m_ModCommands + y * nChns, nChns * sizeof(ModCommand)); } - CriticalSection cs; FreePattern(m_ModCommands); m_ModCommands = newPattern; m_Rows = newRows; This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <sag...@us...> - 2013-04-15 16:33:54
|
Revision: 1883 http://sourceforge.net/p/modplug/code/1883 Author: saga-games Date: 2013-04-15 16:33:46 +0000 (Mon, 15 Apr 2013) Log Message: ----------- [Ref] Updating mix levels has been unified to a single function call. Mix level stuff is now protected in CSoundFile. [Mod] Instrument previews in the tree view are now played at 0dB. Modified Paths: -------------- trunk/OpenMPT/mptrack/CleanupSong.cpp trunk/OpenMPT/mptrack/Ctrl_gen.cpp trunk/OpenMPT/mptrack/MPTHacks.cpp trunk/OpenMPT/mptrack/MainFrm.cpp trunk/OpenMPT/mptrack/Mod2wave.cpp trunk/OpenMPT/mptrack/ModConvert.cpp trunk/OpenMPT/mptrack/Moddoc.cpp trunk/OpenMPT/mptrack/Vstplug.cpp trunk/OpenMPT/mptrack/dlg_misc.cpp trunk/OpenMPT/mptrack/test/test.cpp trunk/OpenMPT/soundlib/Sndfile.cpp trunk/OpenMPT/soundlib/Sndfile.h trunk/OpenMPT/soundlib/SoundFilePlayConfig.cpp trunk/OpenMPT/soundlib/SoundFilePlayConfig.h Modified: trunk/OpenMPT/mptrack/CleanupSong.cpp =================================================================== --- trunk/OpenMPT/mptrack/CleanupSong.cpp 2013-04-15 13:09:48 UTC (rev 1882) +++ trunk/OpenMPT/mptrack/CleanupSong.cpp 2013-04-15 16:33:46 UTC (rev 1883) @@ -816,7 +816,7 @@ // convert to IT... modDoc.ChangeModType(MOD_TYPE_IT); - sndFile.m_nMixLevels = mixLevels_compatible; + sndFile.SetMixLevels(mixLevels_compatible); sndFile.m_nTempoMode = tempo_mode_classic; sndFile.m_SongFlags = SONG_LINEARSLIDES; sndFile.m_MidiCfg.Reset(); Modified: trunk/OpenMPT/mptrack/Ctrl_gen.cpp =================================================================== --- trunk/OpenMPT/mptrack/Ctrl_gen.cpp 2013-04-15 13:09:48 UTC (rev 1882) +++ trunk/OpenMPT/mptrack/Ctrl_gen.cpp 2013-04-15 16:33:46 UTC (rev 1883) @@ -301,7 +301,8 @@ } } - else if (pSlider==&m_SliderVSTiVol) { + else if (pSlider==&m_SliderVSTiVol) + { const UINT vv = MAX_SLIDER_VSTI_VOL - m_SliderVSTiVol.GetPos(); if ((vv >= 0) && (vv <= MAX_SLIDER_VSTI_VOL) && (vv != m_sndFile.m_nVSTiVolume)) { @@ -528,20 +529,20 @@ const char moreRecentMixModeNote[] = "Use a more recent mixmode to see dB offsets."; if ((pszText) && (uId)) { - const bool displayDBValues = m_sndFile.m_PlayConfig.getDisplayDBValues(); + const bool displayDBValues = m_sndFile.GetPlayConfig().getDisplayDBValues(); switch(uId) { case IDC_SLIDER_SAMPLEPREAMP: - (displayDBValues) ? setAsDecibels(pszText, m_sndFile.m_nSamplePreAmp, m_sndFile.m_PlayConfig.getNormalSamplePreAmp()) : wsprintf(pszText, moreRecentMixModeNote); + (displayDBValues) ? setAsDecibels(pszText, m_sndFile.m_nSamplePreAmp, m_sndFile.GetPlayConfig().getNormalSamplePreAmp()) : wsprintf(pszText, moreRecentMixModeNote); return TRUE; break; case IDC_SLIDER_VSTIVOL: - (displayDBValues) ? setAsDecibels(pszText, m_sndFile.m_nVSTiVolume, m_sndFile.m_PlayConfig.getNormalVSTiVol()) : wsprintf(pszText, moreRecentMixModeNote); + (displayDBValues) ? setAsDecibels(pszText, m_sndFile.m_nVSTiVolume, m_sndFile.GetPlayConfig().getNormalVSTiVol()) : wsprintf(pszText, moreRecentMixModeNote); return TRUE; break; case IDC_SLIDER_GLOBALVOL: - (displayDBValues) ? setAsDecibels(pszText, m_sndFile.m_nGlobalVolume, m_sndFile.m_PlayConfig.getNormalGlobalVol()) : wsprintf(pszText, moreRecentMixModeNote); + (displayDBValues) ? setAsDecibels(pszText, m_sndFile.m_nGlobalVolume, m_sndFile.GetPlayConfig().getNormalGlobalVol()) : wsprintf(pszText, moreRecentMixModeNote); return TRUE; break; } Modified: trunk/OpenMPT/mptrack/MPTHacks.cpp =================================================================== --- trunk/OpenMPT/mptrack/MPTHacks.cpp 2013-04-15 13:09:48 UTC (rev 1882) +++ trunk/OpenMPT/mptrack/MPTHacks.cpp 2013-04-15 16:33:46 UTC (rev 1883) @@ -523,12 +523,12 @@ } } - if(m_SndFile.m_nMixLevels != mixLevels_compatible) + if(m_SndFile.GetMixLevels() != mixLevels_compatible) { AddToLog("Found incorrect mix levels (only compatible mix levels allowed)"); foundHacks = true; if(autofix) - m_SndFile.m_nMixLevels = mixLevels_compatible; + m_SndFile.SetMixLevels(mixLevels_compatible); } if(autofix && foundHacks) Modified: trunk/OpenMPT/mptrack/MainFrm.cpp =================================================================== --- trunk/OpenMPT/mptrack/MainFrm.cpp 2013-04-15 13:09:48 UTC (rev 1882) +++ trunk/OpenMPT/mptrack/MainFrm.cpp 2013-04-15 16:33:46 UTC (rev 1883) @@ -1635,19 +1635,18 @@ m_WaveFile.Destroy(); m_WaveFile.Create(NULL, 0); // Avoid global volume ramping when trying samples in the treeview. - m_WaveFile.m_PlayConfig.setGlobalVolumeAppliesToMaster(false); m_WaveFile.m_nDefaultGlobalVolume = m_WaveFile.m_nGlobalVolume = MAX_GLOBAL_VOLUME; - m_WaveFile.m_nSamplePreAmp = 48; + m_WaveFile.SetMixLevels(mixLevels_117RC3); + m_WaveFile.m_nSamplePreAmp = m_WaveFile.GetPlayConfig().getNormalSamplePreAmp(); m_WaveFile.m_nDefaultTempo = 125; m_WaveFile.m_nDefaultSpeed = 6; m_WaveFile.m_nType = MOD_TYPE_MPT; - m_WaveFile.m_nChannels = 4; + m_WaveFile.m_nChannels = 2; m_WaveFile.m_nInstruments = 1; m_WaveFile.m_nTempoMode = tempo_mode_classic; - m_WaveFile.m_nMixLevels = mixLevels_compatible; m_WaveFile.Order.resize(1); m_WaveFile.Order[0] = 0; - m_WaveFile.Patterns.Insert(0, 64); + m_WaveFile.Patterns.Insert(0, 80); } @@ -1663,19 +1662,15 @@ { m[0].note = note; m[0].instr = 1; - m[1].note = note; - m[1].instr = 1; if(m_WaveFile.m_nSamples > 1 || m_WaveFile.GetSample(1).uFlags[CHN_LOOP]) { - m[32 * 4].note = NOTE_KEYOFF; - m[32 * 4 + 1].note = NOTE_KEYOFF; - m[63 * 4].note = NOTE_NOTECUT; - m[63 * 4 + 1].note = NOTE_NOTECUT; + m[48 * 2].note = NOTE_KEYOFF; + m[79 * 2].note = NOTE_NOTECUT; } - m[63 * 4 + 2].command = CMD_POSITIONJUMP; - m[63 * 4 + 3].command = CMD_PATTERNBREAK; - m[63 * 4 + 3].param = 63; + m[79 * 2].command = CMD_POSITIONJUMP; + m[79 * 2 + 1].command = CMD_PATTERNBREAK; + m[79 * 2 + 1].param = 63; } } Modified: trunk/OpenMPT/mptrack/Mod2wave.cpp =================================================================== --- trunk/OpenMPT/mptrack/Mod2wave.cpp 2013-04-15 13:09:48 UTC (rev 1882) +++ trunk/OpenMPT/mptrack/Mod2wave.cpp 2013-04-15 16:33:46 UTC (rev 1883) @@ -1117,7 +1117,7 @@ m_pSndFile->InitPlayer(TRUE); m_pSndFile->m_SongFlags.reset(SONG_PAUSED | SONG_STEP); - m_pSndFile->visitedSongRows.Initialize(true); + m_pSndFile->InitializeVisitedRows(); // Setting up file limits and progress range if ((!m_dwFileLimit) || (m_dwFileLimit > 512000)) m_dwFileLimit = 512000; @@ -1208,7 +1208,7 @@ m_pSndFile->m_MixerSettings.MixerFlags = oldsndcfg; m_pSndFile->SetRepeatCount(oldrepeat); m_pSndFile->m_nMaxOrderPosition = 0; - m_pSndFile->visitedSongRows.Initialize(true); + m_pSndFile->InitializeVisitedRows(); CMainFrame::UpdateAudioParameters(*m_pSndFile, TRUE); // Success Modified: trunk/OpenMPT/mptrack/ModConvert.cpp =================================================================== --- trunk/OpenMPT/mptrack/ModConvert.cpp 2013-04-15 13:09:48 UTC (rev 1882) +++ trunk/OpenMPT/mptrack/ModConvert.cpp 2013-04-15 16:33:46 UTC (rev 1883) @@ -489,10 +489,9 @@ // Adjust mix levels if(newTypeIsMOD || newTypeIsS3M) { - m_SndFile.m_nMixLevels = mixLevels_compatible; - m_SndFile.m_PlayConfig.SetMixLevels(mixLevels_compatible); + m_SndFile.SetMixLevels(mixLevels_compatible); } - if(oldTypeIsMPT && m_SndFile.m_nMixLevels != mixLevels_compatible) + if(oldTypeIsMPT && m_SndFile.GetMixLevels() != mixLevels_compatible) { CHANGEMODTYPE_WARNING(wMixmode); } Modified: trunk/OpenMPT/mptrack/Moddoc.cpp =================================================================== --- trunk/OpenMPT/mptrack/Moddoc.cpp 2013-04-15 13:09:48 UTC (rev 1882) +++ trunk/OpenMPT/mptrack/Moddoc.cpp 2013-04-15 16:33:46 UTC (rev 1883) @@ -690,8 +690,7 @@ } // Refresh mix levels now that the correct mod type has been set - m_SndFile.m_nMixLevels = m_SndFile.GetModSpecifications().defaultMixLevels; - m_SndFile.m_PlayConfig.SetMixLevels(m_SndFile.m_nMixLevels); + m_SndFile.SetMixLevels(m_SndFile.GetModSpecifications().defaultMixLevels); // ...and the order length m_SndFile.Order.resize(MIN(ModSequenceSet::s_nCacheSize, m_SndFile.GetModSpecifications().ordersMax)); @@ -1714,7 +1713,7 @@ thisName += fileExt; // Render song (or current channel, or current sample/instrument) - m_SndFile.visitedSongRows.Initialize(true); + m_SndFile.InitializeVisitedRows(); m_SndFile.SetCurrentPos(0); m_SndFile.m_SongFlags.reset(SONG_PATTERNLOOP); if(wsdlg.m_bSelectPlay) Modified: trunk/OpenMPT/mptrack/Vstplug.cpp =================================================================== --- trunk/OpenMPT/mptrack/Vstplug.cpp 2013-04-15 13:09:48 UTC (rev 1882) +++ trunk/OpenMPT/mptrack/Vstplug.cpp 2013-04-15 16:33:46 UTC (rev 1883) @@ -2032,8 +2032,8 @@ if(m_bIsInstrument) { - gain /= m_SndFile.m_PlayConfig.getVSTiAttenuation(); - gain = static_cast<float>(gain * (m_SndFile.m_nVSTiVolume / m_SndFile.m_PlayConfig.getNormalVSTiVol())); + gain /= m_SndFile.GetPlayConfig().getVSTiAttenuation(); + gain = static_cast<float>(gain * (m_SndFile.m_nVSTiVolume / m_SndFile.GetPlayConfig().getNormalVSTiVol())); } m_fGain = gain; } Modified: trunk/OpenMPT/mptrack/dlg_misc.cpp =================================================================== --- trunk/OpenMPT/mptrack/dlg_misc.cpp 2013-04-15 13:09:48 UTC (rev 1882) +++ trunk/OpenMPT/mptrack/dlg_misc.cpp 2013-04-15 16:33:46 UTC (rev 1883) @@ -114,9 +114,9 @@ // Mix levels m_PlugMixBox.SetItemData(m_PlugMixBox.AddString("OpenMPT 1.17RC3"), mixLevels_117RC3); - if(sndFile.m_nMixLevels == mixLevels_117RC2) // Only shown for backwards compatibility with existing tunes + if(sndFile.GetMixLevels() == mixLevels_117RC2) // Only shown for backwards compatibility with existing tunes m_PlugMixBox.SetItemData(m_PlugMixBox.AddString("OpenMPT 1.17RC2"), mixLevels_117RC2); - if(sndFile.m_nMixLevels == mixLevels_117RC1) // Dito + if(sndFile.GetMixLevels() == mixLevels_117RC1) // Dito m_PlugMixBox.SetItemData(m_PlugMixBox.AddString("OpenMPT 1.17RC1"), mixLevels_117RC1); m_PlugMixBox.SetItemData(m_PlugMixBox.AddString("Original (MPT 1.16)"), mixLevels_original); m_PlugMixBox.SetItemData(m_PlugMixBox.AddString("Compatible"), mixLevels_compatible); @@ -124,7 +124,7 @@ m_PlugMixBox.SetCurSel(0); for(int i = m_PlugMixBox.GetCount(); i > 0; i--) { - if(m_PlugMixBox.GetItemData(i) == sndFile.m_nMixLevels) + if(m_PlugMixBox.GetItemData(i) == sndFile.GetMixLevels()) { m_PlugMixBox.SetCurSel(i); break; @@ -359,11 +359,9 @@ } sel = m_PlugMixBox.GetCurSel(); - if (sel >= 0) + if(sel >= 0) { - sndFile.m_nMixLevels = m_PlugMixBox.GetItemData(sel); - sndFile.m_PlayConfig.SetMixLevels(sndFile.m_nMixLevels); - sndFile.RecalculateGainForAllPlugs(); + sndFile.SetMixLevels(static_cast<mixLevels>(m_PlugMixBox.GetItemData(sel))); } if(m_nType & (MOD_TYPE_IT | MOD_TYPE_MPT | MOD_TYPE_XM)) Modified: trunk/OpenMPT/mptrack/test/test.cpp =================================================================== --- trunk/OpenMPT/mptrack/test/test.cpp 2013-04-15 13:09:48 UTC (rev 1882) +++ trunk/OpenMPT/mptrack/test/test.cpp 2013-04-15 16:33:46 UTC (rev 1883) @@ -338,7 +338,7 @@ VERIFY_EQUAL_NONCONT(sndFile.GetModFlag(MSF_MIDICC_BUGEMULATION), false); VERIFY_EQUAL_NONCONT(sndFile.GetModFlag(MSF_OLDVOLSWING), false); VERIFY_EQUAL_NONCONT(sndFile.GetModFlag(MSF_OLD_MIDI_PITCHBENDS), false); - VERIFY_EQUAL_NONCONT(sndFile.m_nMixLevels, mixLevels_compatible); + VERIFY_EQUAL_NONCONT(sndFile.GetMixLevels(), mixLevels_compatible); VERIFY_EQUAL_NONCONT(sndFile.m_nTempoMode, tempo_mode_modern); VERIFY_EQUAL_NONCONT(sndFile.m_nDefaultRowsPerBeat, 6); VERIFY_EQUAL_NONCONT(sndFile.m_nDefaultRowsPerMeasure, 12); @@ -533,7 +533,7 @@ VERIFY_EQUAL_NONCONT(sndFile.GetModFlag(MSF_MIDICC_BUGEMULATION), false); VERIFY_EQUAL_NONCONT(sndFile.GetModFlag(MSF_OLDVOLSWING), false); VERIFY_EQUAL_NONCONT(sndFile.GetModFlag(MSF_OLD_MIDI_PITCHBENDS), false); - VERIFY_EQUAL_NONCONT(sndFile.m_nMixLevels, mixLevels_compatible); + VERIFY_EQUAL_NONCONT(sndFile.GetMixLevels(), mixLevels_compatible); VERIFY_EQUAL_NONCONT(sndFile.m_nTempoMode, tempo_mode_modern); VERIFY_EQUAL_NONCONT(sndFile.m_nDefaultRowsPerBeat, 6); VERIFY_EQUAL_NONCONT(sndFile.m_nDefaultRowsPerMeasure, 12); @@ -784,7 +784,7 @@ VERIFY_EQUAL_NONCONT(sndFile.m_nVSTiVolume, 48); VERIFY_EQUAL_NONCONT(sndFile.m_nSamplePreAmp, 16); VERIFY_EQUAL_NONCONT((sndFile.m_SongFlags & SONG_FILE_FLAGS), SONG_FASTVOLSLIDES); - VERIFY_EQUAL_NONCONT(sndFile.m_nMixLevels, mixLevels_compatible); + VERIFY_EQUAL_NONCONT(sndFile.GetMixLevels(), mixLevels_compatible); VERIFY_EQUAL_NONCONT(sndFile.m_nTempoMode, tempo_mode_classic); VERIFY_EQUAL_NONCONT(sndFile.m_dwLastSavedWithVersion, resaved ? (MptVersion::num & 0xFFFF0000) : MAKE_VERSION_NUMERIC(1, 20, 00, 00)); VERIFY_EQUAL_NONCONT(sndFile.m_nRestartPos, 0); Modified: trunk/OpenMPT/soundlib/Sndfile.cpp =================================================================== --- trunk/OpenMPT/soundlib/Sndfile.cpp 2013-04-15 13:09:48 UTC (rev 1882) +++ trunk/OpenMPT/soundlib/Sndfile.cpp 2013-04-15 16:33:46 UTC (rev 1883) @@ -805,8 +805,7 @@ #endif // NO_VST // Set up mix levels - m_PlayConfig.SetMixLevels(m_nMixLevels); - RecalculateGainForAllPlugs(); + SetMixLevels(m_nMixLevels); if(GetType() != MOD_TYPE_NONE) { @@ -1129,6 +1128,15 @@ } +void CSoundFile::SetMixLevels(mixLevels levels) +//--------------------------------------------- +{ + m_nMixLevels = levels; + m_PlayConfig.SetMixLevels(m_nMixLevels); + RecalculateGainForAllPlugs(); +} + + void CSoundFile::RecalculateGainForAllPlugs() //------------------------------------------- { Modified: trunk/OpenMPT/soundlib/Sndfile.h =================================================================== --- trunk/OpenMPT/soundlib/Sndfile.h 2013-04-15 13:09:48 UTC (rev 1882) +++ trunk/OpenMPT/soundlib/Sndfile.h 2013-04-15 16:33:46 UTC (rev 1883) @@ -212,8 +212,8 @@ #endif // MODPLUG_TRACKER private: //Misc data + const CModSpecifications *m_pModSpecs; FlagSet<ModSpecificFlag, uint16> m_ModFlags; - const CModSpecifications* m_pModSpecs; private: DWORD gdwSysInfo; @@ -264,7 +264,6 @@ INSTRUMENTINDEX m_nInstruments; UINT m_nDefaultSpeed, m_nDefaultTempo, m_nDefaultGlobalVolume; FlagSet<SongFlags> m_SongFlags; - bool m_bIsRendering; UINT m_nMixChannels, m_nMixStat; samplecount_t m_nBufferCount; double m_dBufferDiff; @@ -276,7 +275,6 @@ ROWINDEX m_nDefaultRowsPerBeat, m_nDefaultRowsPerMeasure; // default rows per beat and measure for this module // rewbs.betterBPM ROWINDEX m_nCurrentRowsPerBeat, m_nCurrentRowsPerMeasure; // current rows per beat and measure for this module BYTE m_nTempoMode; // rewbs.betterBPM - BYTE m_nMixLevels; UINT m_nMusicSpeed, m_nMusicTempo; // Current speed and tempo ROWINDEX m_nNextRow, m_nRow; ROWINDEX m_nNextPatStartRow; // for FT2's E60 bug @@ -288,7 +286,6 @@ ORDERINDEX m_lockOrderStart, m_lockOrderEnd; #endif // MODPLUG_TRACKER - bool m_bPatternTransitionOccurred; UINT m_nGlobalVolume, m_nSamplesToGlobalVolRampDest, m_nGlobalVolumeRampAmount, m_nGlobalVolumeDestination, m_nSamplePreAmp, m_nVSTiVolume; long m_lHighResRampingGlobalVolume; @@ -311,7 +308,6 @@ char m_szNames[MAX_SAMPLES][MAX_SAMPLENAME]; // Song and sample names std::bitset<MAX_BASECHANNELS> m_bChannelMuteTogglePending; - CSoundFilePlayConfig m_PlayConfig; DWORD m_dwCreatedWithVersion; DWORD m_dwLastSavedWithVersion; @@ -319,9 +315,15 @@ std::vector<PatternCuePoint> m_PatternCuePoints; // For WAV export (writing pattern positions to file) #endif // MODPLUG_TRACKER +protected: + // Mix level stuff + CSoundFilePlayConfig m_PlayConfig; + mixLevels m_nMixLevels; + // For handling backwards jumps and stuff to prevent infinite loops when counting the mod length or rendering to wav. RowVisitor visitedSongRows; +public: // Song message SongMessage songMessage; @@ -330,6 +332,9 @@ mpt::String m_szInstrumentPath[MAX_INSTRUMENTS]; // -! NEW_FEATURE#0023 + bool m_bIsRendering; + bool m_bPatternTransitionOccurred; + public: CSoundFile(); ~CSoundFile(); @@ -356,6 +361,10 @@ void SetPreAmp(UINT vol); UINT GetPreAmp() const { return m_MixerSettings.m_nPreAmp; } + void SetMixLevels(mixLevels levels); + mixLevels GetMixLevels() const { return m_nMixLevels; } + const CSoundFilePlayConfig &GetPlayConfig() const { return m_PlayConfig; } + INSTRUMENTINDEX GetNumInstruments() const { return m_nInstruments; } SAMPLEINDEX GetNumSamples() const { return m_nSamples; } UINT GetCurrentPos() const; @@ -383,6 +392,8 @@ //specific order&row etc. Return value is in seconds. GetLengthType GetLength(enmGetLengthResetMode adjustMode, ORDERINDEX ord = ORDERINDEX_INVALID, ROWINDEX row = ROWINDEX_INVALID); + void InitializeVisitedRows() { visitedSongRows.Initialize(true); } + public: //Returns song length in seconds. DWORD GetSongTime() { return static_cast<DWORD>(GetLength(eNoAdjust).duration + 0.5); } Modified: trunk/OpenMPT/soundlib/SoundFilePlayConfig.cpp =================================================================== --- trunk/OpenMPT/soundlib/SoundFilePlayConfig.cpp 2013-04-15 13:09:48 UTC (rev 1882) +++ trunk/OpenMPT/soundlib/SoundFilePlayConfig.cpp 2013-04-15 16:33:46 UTC (rev 1883) @@ -121,8 +121,8 @@ //getters and setters. -bool CSoundFilePlayConfig::getGlobalVolumeAppliesToMaster() -//--------------------------------------------------------- +bool CSoundFilePlayConfig::getGlobalVolumeAppliesToMaster() const +//--------------------------------------------------------------- { return m_globalVolumeAppliesToMaster; } @@ -134,14 +134,14 @@ m_globalVolumeAppliesToMaster=inGlobalVolumeAppliesToMaster; } -float CSoundFilePlayConfig::getVSTiGainFactor() -//--------------------------------------------- +float CSoundFilePlayConfig::getVSTiGainFactor() const +//--------------------------------------------------- { return m_VSTiVolume; } -float CSoundFilePlayConfig::getVSTiVolume() -//----------------------------------------- +float CSoundFilePlayConfig::getVSTiVolume() const +//----------------------------------------------- { return m_VSTiVolume; } @@ -152,8 +152,8 @@ m_VSTiVolume = inVSTiVolume; } -float CSoundFilePlayConfig::getVSTiAttenuation() -//---------------------------------------------- +float CSoundFilePlayConfig::getVSTiAttenuation() const +//---------------------------------------------------- { return m_VSTiAttenuation; } @@ -164,8 +164,8 @@ m_VSTiAttenuation = inVSTiAttenuation; } -float CSoundFilePlayConfig::getIntToFloat() -//----------------------------------------- +float CSoundFilePlayConfig::getIntToFloat() const +//----------------------------------------------- { return m_IntToFloat; } @@ -177,8 +177,8 @@ } -float CSoundFilePlayConfig::getFloatToInt() -//----------------------------------------- +float CSoundFilePlayConfig::getFloatToInt() const +//----------------------------------------------- { return m_FloatToInt; } @@ -190,8 +190,8 @@ m_FloatToInt = inFloatToInt; } -bool CSoundFilePlayConfig::getUseGlobalPreAmp() -//--------------------------------------------- +bool CSoundFilePlayConfig::getUseGlobalPreAmp() const +//--------------------------------------------------- { return m_ignorePreAmp; } @@ -203,8 +203,8 @@ } -forcePanningMode CSoundFilePlayConfig::getForcePanningMode() -//---------------------------------------------------------- +forcePanningMode CSoundFilePlayConfig::getForcePanningMode() const +//---------------------------------------------------------------- { return m_forceSoftPanning; } @@ -239,26 +239,26 @@ m_normalGlobalVol = in; } -bool CSoundFilePlayConfig::getDisplayDBValues() -//--------------------------------------------- +bool CSoundFilePlayConfig::getDisplayDBValues() const +//--------------------------------------------------- { return m_displayDBValues; } -double CSoundFilePlayConfig::getNormalSamplePreAmp() -//-------------------------------------------------- +double CSoundFilePlayConfig::getNormalSamplePreAmp() const +//-------------------------------------------------------- { return m_normalSamplePreAmp; } -double CSoundFilePlayConfig::getNormalVSTiVol() -//--------------------------------------------- +double CSoundFilePlayConfig::getNormalVSTiVol() const +//--------------------------------------------------- { return m_normalVSTiVol; } -double CSoundFilePlayConfig::getNormalGlobalVol() -//----------------------------------------------- +double CSoundFilePlayConfig::getNormalGlobalVol() const +//----------------------------------------------------- { return m_normalGlobalVol; } @@ -269,8 +269,8 @@ m_extraAttenuation = attn; } -int CSoundFilePlayConfig::getExtraSampleAttenuation() -//--------------------------------------------------- +int CSoundFilePlayConfig::getExtraSampleAttenuation() const +//--------------------------------------------------------- { return m_extraAttenuation; } Modified: trunk/OpenMPT/soundlib/SoundFilePlayConfig.h =================================================================== --- trunk/OpenMPT/soundlib/SoundFilePlayConfig.h 2013-04-15 13:09:48 UTC (rev 1882) +++ trunk/OpenMPT/soundlib/SoundFilePlayConfig.h 2013-04-15 16:33:46 UTC (rev 1883) @@ -49,39 +49,39 @@ void SetMixLevels(int mixLevelType); //getters/setters - float getIntToFloat(); + float getIntToFloat() const; void setIntToFloat(float); - float getFloatToInt(); + float getFloatToInt() const; void setFloatToInt(float); // default VSTi gain factor, different depending on the MPT version we're "emulating" void setVSTiAttenuation(float); - float getVSTiAttenuation(); + float getVSTiAttenuation() const; // user-controllable VSTi gain factor. void setVSTiVolume(float); - float getVSTiVolume(); + float getVSTiVolume() const; void setGlobalVolumeAppliesToMaster(bool); - bool getGlobalVolumeAppliesToMaster(); + bool getGlobalVolumeAppliesToMaster() const; void setUseGlobalPreAmp(bool); - bool getUseGlobalPreAmp(); + bool getUseGlobalPreAmp() const; void setForcePanningMode(forcePanningMode); - forcePanningMode getForcePanningMode(); + forcePanningMode getForcePanningMode() const; void setDisplayDBValues(bool); - bool getDisplayDBValues(); + bool getDisplayDBValues() const; // Extra sample attenuation in bits void setExtraSampleAttenuation(int); - int getExtraSampleAttenuation(); + int getExtraSampleAttenuation() const; //Values at which volumes are unchanged - double getNormalSamplePreAmp(); - double getNormalVSTiVol(); - double getNormalGlobalVol(); + double getNormalSamplePreAmp() const; + double getNormalVSTiVol() const; + double getNormalGlobalVol() const; void setNormalSamplePreAmp(double); void setNormalVSTiVol(double); void setNormalGlobalVol(double); @@ -89,7 +89,7 @@ private: //calculated internally (getters only): - float getVSTiGainFactor(); + float getVSTiGainFactor() const; float m_IntToFloat; float m_FloatToInt; This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <man...@us...> - 2013-04-16 14:16:33
|
Revision: 1885 http://sourceforge.net/p/modplug/code/1885 Author: manxorist Date: 2013-04-16 14:16:26 +0000 (Tue, 16 Apr 2013) Log Message: ----------- [Ref] Document NO_ARCHIVE_SUPPORT in stdafx.h. [Ref] Remove pointless NO_COPYRIGHT and MODPLUG_BASIC_SUPPORT. Modified Paths: -------------- trunk/OpenMPT/common/stdafx.h trunk/OpenMPT/soundlib/Sndfile.cpp Modified: trunk/OpenMPT/common/stdafx.h =================================================================== --- trunk/OpenMPT/common/stdafx.h 2013-04-15 21:00:35 UTC (rev 1884) +++ trunk/OpenMPT/common/stdafx.h 2013-04-16 14:16:26 UTC (rev 1885) @@ -73,6 +73,9 @@ #endif // ENABLE_ASM +// Disable unarchiving support +//#define NO_ARCHIVE_SUPPORT + // Disable the built-in reverb effect //#define NO_REVERB Modified: trunk/OpenMPT/soundlib/Sndfile.cpp =================================================================== --- trunk/OpenMPT/soundlib/Sndfile.cpp 2013-04-15 21:00:35 UTC (rev 1884) +++ trunk/OpenMPT/soundlib/Sndfile.cpp 2013-04-16 14:16:26 UTC (rev 1885) @@ -21,7 +21,6 @@ #include "../common/StringFixer.h" #include "FileReader.h" -#ifndef NO_COPYRIGHT #ifndef NO_MMCMP_SUPPORT #define MMCMP_SUPPORT #endif // NO_MMCMP_SUPPORT @@ -31,9 +30,6 @@ #define UNGZIP_SUPPORT #define ZIPPED_MOD_SUPPORT #endif // NO_ARCHIVE_SUPPORT -#else // NO_COPYRIGHT: EarSaver only loads mod/s3m/xm/it/wav -#define MODPLUG_BASIC_SUPPORT -#endif #ifdef ZIPPED_MOD_SUPPORT #include "../unzip/unzip.h" @@ -609,7 +605,6 @@ /*&& !ReadMPT(lpStream, dwMemLength)*/ && !ReadS3M(file) && !ReadWav(file) -#ifndef MODPLUG_BASIC_SUPPORT && !ReadSTM(file) && !ReadMed(lpStream, dwMemLength) && !ReadMTM(file) @@ -633,7 +628,6 @@ #ifdef MODPLUG_TRACKER && !ReadMID(lpStream, dwMemLength) #endif // MODPLUG_TRACKER -#endif // MODPLUG_BASIC_SUPPORT && !ReadGDM(file) && !ReadIMF(file) && !ReadAM(file) This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <man...@us...> - 2013-04-16 15:21:39
|
Revision: 1889 http://sourceforge.net/p/modplug/code/1889 Author: manxorist Date: 2013-04-16 15:21:31 +0000 (Tue, 16 Apr 2013) Log Message: ----------- merge branch unarchiver: Merged revision(s) 1887-1888 from branches/manx/unarchiver: [Ref] Move ungzip, unlha, unrar und unzip into common unarchiver directory and merge the 4 VS2010 project files. This reduces future project file maintanance overhead. ........ [Ref] Update the unarchiver project file for VS2008 as well. ........ Modified Paths: -------------- trunk/OpenMPT/mptrack/MPTRACK_08.sln trunk/OpenMPT/mptrack/MPTRACK_10.sln trunk/OpenMPT/mptrack/mptrack_10.vcxproj trunk/OpenMPT/soundlib/Sndfile.cpp Added Paths: ----------- trunk/OpenMPT/unarchiver/ Removed Paths: ------------- trunk/OpenMPT/ungzip/ trunk/OpenMPT/unlha/ trunk/OpenMPT/unrar/ trunk/OpenMPT/unzip/ Property Changed: ---------------- trunk/OpenMPT/ trunk/OpenMPT/unarchiver/unlha/ trunk/OpenMPT/unarchiver/unrar/ Index: trunk/OpenMPT =================================================================== --- trunk/OpenMPT 2013-04-16 15:17:59 UTC (rev 1888) +++ trunk/OpenMPT 2013-04-16 15:21:31 UTC (rev 1889) Property changes on: trunk/OpenMPT ___________________________________________________________________ Modified: svn:mergeinfo ## -4,3 +4,4 ## /branches/manx/profiler:1813 /branches/manx/project-files-cleanups:1378-1382 /branches/manx/snddev-fixes:1605-1713 +/branches/manx/unarchiver:1887-1888 \ No newline at end of property Modified: trunk/OpenMPT/mptrack/MPTRACK_08.sln =================================================================== --- trunk/OpenMPT/mptrack/MPTRACK_08.sln 2013-04-16 15:17:59 UTC (rev 1888) +++ trunk/OpenMPT/mptrack/MPTRACK_08.sln 2013-04-16 15:21:31 UTC (rev 1889) @@ -3,40 +3,25 @@ Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "mptrack", "mptrack_08.vcproj", "{21D95071-FB97-4E69-B3B1-050D0D4A5021}" ProjectSection(ProjectDependencies) = postProject {94CD7910-649A-4075-9F33-7EBEE614FD45} = {94CD7910-649A-4075-9F33-7EBEE614FD45} - {44316F22-904E-48AA-B841-5A3A6AC77319} = {44316F22-904E-48AA-B841-5A3A6AC77319} {DCC2BB2F-6778-4FD3-9C00-D6CD8DC917B8} = {DCC2BB2F-6778-4FD3-9C00-D6CD8DC917B8} - {FAE39936-1DC7-40BB-AD3F-3B5B9E9AB0E8} = {FAE39936-1DC7-40BB-AD3F-3B5B9E9AB0E8} {745DEC58-EBB3-47A9-A9B8-4C6627C01BF8} = {745DEC58-EBB3-47A9-A9B8-4C6627C01BF8} {0A18A071-125E-442F-AFF7-A3F68ABECF99} = {0A18A071-125E-442F-AFF7-A3F68ABECF99} {4CEFBC84-C215-11DB-8314-0800200C9A66} = {4CEFBC84-C215-11DB-8314-0800200C9A66} {CF3C2CA5-5D45-4635-BBA4-C1F435E10896} = {CF3C2CA5-5D45-4635-BBA4-C1F435E10896} - {FF541CE2-DAA1-4F84-9883-0A0F111BAA0B} = {FF541CE2-DAA1-4F84-9883-0A0F111BAA0B} EndProjectSection EndProject -Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "unlha", "..\unlha\unlha_08.vcproj", "{FAE39936-1DC7-40BB-AD3F-3B5B9E9AB0E8}" -EndProject -Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "unrar", "..\unrar\unrar_08.vcproj", "{FF541CE2-DAA1-4F84-9883-0A0F111BAA0B}" -EndProject -Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "unzip", "..\unzip\unzip_08.vcproj", "{44316F22-904E-48AA-B841-5A3A6AC77319}" - ProjectSection(ProjectDependencies) = postProject - {745DEC58-EBB3-47A9-A9B8-4C6627C01BF8} = {745DEC58-EBB3-47A9-A9B8-4C6627C01BF8} - EndProjectSection -EndProject Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "xsoundlib", "..\xsoundlib\xsoundlib_08.vcproj", "{DCC2BB2F-6778-4FD3-9C00-D6CD8DC917B8}" EndProject Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "SoundTouch", "..\soundtouch\soundtouch_08.vcproj", "{CF3C2CA5-5D45-4635-BBA4-C1F435E10896}" EndProject Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "zlibstat", "..\include\zlib\contrib\vstudio\vc9\zlibstat.vcproj", "{745DEC58-EBB3-47A9-A9B8-4C6627C01BF8}" EndProject -Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "ungzip", "..\ungzip\ungzip_08.vcproj", "{94CD7910-649A-4075-9F33-7EBEE614FD45}" - ProjectSection(ProjectDependencies) = postProject - {745DEC58-EBB3-47A9-A9B8-4C6627C01BF8} = {745DEC58-EBB3-47A9-A9B8-4C6627C01BF8} - EndProjectSection -EndProject Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "libFLAC_static", "..\include\flac\src\libFLAC\libFLAC_static_08.vcproj", "{4CEFBC84-C215-11DB-8314-0800200C9A66}" EndProject Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "portaudio", "..\include\portaudio\build\msvc\portaudio_openmpt_vs2008.vcproj", "{0A18A071-125E-442F-AFF7-A3F68ABECF99}" EndProject +Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "unarchiver", "..\unarchiver\unarchiver_08.vcproj", "{94CD7910-649A-4075-9F33-7EBEE614FD45}" +EndProject Global GlobalSection(SolutionConfigurationPlatforms) = preSolution Debug|Win32 = Debug|Win32 @@ -47,18 +32,6 @@ {21D95071-FB97-4E69-B3B1-050D0D4A5021}.Debug|Win32.Build.0 = Debug|Win32 {21D95071-FB97-4E69-B3B1-050D0D4A5021}.Release|Win32.ActiveCfg = Release|Win32 {21D95071-FB97-4E69-B3B1-050D0D4A5021}.Release|Win32.Build.0 = Release|Win32 - {FAE39936-1DC7-40BB-AD3F-3B5B9E9AB0E8}.Debug|Win32.ActiveCfg = Debug|Win32 - {FAE39936-1DC7-40BB-AD3F-3B5B9E9AB0E8}.Debug|Win32.Build.0 = Debug|Win32 - {FAE39936-1DC7-40BB-AD3F-3B5B9E9AB0E8}.Release|Win32.ActiveCfg = Release|Win32 - {FAE39936-1DC7-40BB-AD3F-3B5B9E9AB0E8}.Release|Win32.Build.0 = Release|Win32 - {FF541CE2-DAA1-4F84-9883-0A0F111BAA0B}.Debug|Win32.ActiveCfg = Debug|Win32 - {FF541CE2-DAA1-4F84-9883-0A0F111BAA0B}.Debug|Win32.Build.0 = Debug|Win32 - {FF541CE2-DAA1-4F84-9883-0A0F111BAA0B}.Release|Win32.ActiveCfg = Release|Win32 - {FF541CE2-DAA1-4F84-9883-0A0F111BAA0B}.Release|Win32.Build.0 = Release|Win32 - {44316F22-904E-48AA-B841-5A3A6AC77319}.Debug|Win32.ActiveCfg = Debug|Win32 - {44316F22-904E-48AA-B841-5A3A6AC77319}.Debug|Win32.Build.0 = Debug|Win32 - {44316F22-904E-48AA-B841-5A3A6AC77319}.Release|Win32.ActiveCfg = Release|Win32 - {44316F22-904E-48AA-B841-5A3A6AC77319}.Release|Win32.Build.0 = Release|Win32 {DCC2BB2F-6778-4FD3-9C00-D6CD8DC917B8}.Debug|Win32.ActiveCfg = Debug|Win32 {DCC2BB2F-6778-4FD3-9C00-D6CD8DC917B8}.Debug|Win32.Build.0 = Debug|Win32 {DCC2BB2F-6778-4FD3-9C00-D6CD8DC917B8}.Release|Win32.ActiveCfg = Release|Win32 @@ -71,10 +44,6 @@ {745DEC58-EBB3-47A9-A9B8-4C6627C01BF8}.Debug|Win32.Build.0 = Debug|Win32 {745DEC58-EBB3-47A9-A9B8-4C6627C01BF8}.Release|Win32.ActiveCfg = Release|Win32 {745DEC58-EBB3-47A9-A9B8-4C6627C01BF8}.Release|Win32.Build.0 = Release|Win32 - {94CD7910-649A-4075-9F33-7EBEE614FD45}.Debug|Win32.ActiveCfg = Debug|Win32 - {94CD7910-649A-4075-9F33-7EBEE614FD45}.Debug|Win32.Build.0 = Debug|Win32 - {94CD7910-649A-4075-9F33-7EBEE614FD45}.Release|Win32.ActiveCfg = Release|Win32 - {94CD7910-649A-4075-9F33-7EBEE614FD45}.Release|Win32.Build.0 = Release|Win32 {4CEFBC84-C215-11DB-8314-0800200C9A66}.Debug|Win32.ActiveCfg = Debug|Win32 {4CEFBC84-C215-11DB-8314-0800200C9A66}.Debug|Win32.Build.0 = Debug|Win32 {4CEFBC84-C215-11DB-8314-0800200C9A66}.Release|Win32.ActiveCfg = Release|Win32 @@ -83,6 +52,10 @@ {0A18A071-125E-442F-AFF7-A3F68ABECF99}.Debug|Win32.Build.0 = Debug|Win32 {0A18A071-125E-442F-AFF7-A3F68ABECF99}.Release|Win32.ActiveCfg = Release|Win32 {0A18A071-125E-442F-AFF7-A3F68ABECF99}.Release|Win32.Build.0 = Release|Win32 + {94CD7910-649A-4075-9F33-7EBEE614FD45}.Debug|Win32.ActiveCfg = Debug|Win32 + {94CD7910-649A-4075-9F33-7EBEE614FD45}.Debug|Win32.Build.0 = Debug|Win32 + {94CD7910-649A-4075-9F33-7EBEE614FD45}.Release|Win32.ActiveCfg = Release|Win32 + {94CD7910-649A-4075-9F33-7EBEE614FD45}.Release|Win32.Build.0 = Release|Win32 EndGlobalSection GlobalSection(SolutionProperties) = preSolution HideSolutionNode = FALSE Modified: trunk/OpenMPT/mptrack/MPTRACK_10.sln =================================================================== --- trunk/OpenMPT/mptrack/MPTRACK_10.sln 2013-04-16 15:17:59 UTC (rev 1888) +++ trunk/OpenMPT/mptrack/MPTRACK_10.sln 2013-04-16 15:21:31 UTC (rev 1889) @@ -5,24 +5,18 @@ {4CEFBC84-C215-11DB-8314-0800200C9A66} = {4CEFBC84-C215-11DB-8314-0800200C9A66} EndProjectSection EndProject -Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "unlha", "..\unlha\unlha_10.vcxproj", "{FAE39936-1DC7-40BB-AD3F-3B5B9E9AB0E8}" -EndProject -Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "unrar", "..\unrar\unrar_10.vcxproj", "{FF541CE2-DAA1-4F84-9883-0A0F111BAA0B}" -EndProject Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "xsoundlib", "..\xsoundlib\xsoundlib_10.vcxproj", "{DCC2BB2F-6778-4FD3-9C00-D6CD8DC917B8}" EndProject Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "SoundTouch", "..\soundtouch\soundtouch_10.vcxproj", "{CF3C2CA5-5D45-4635-BBA4-C1F435E10896}" EndProject -Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "ungzip", "..\ungzip\ungzip_10.vcxproj", "{94CD7910-649A-4075-9F33-7EBEE614FD45}" -EndProject Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "zlibstat", "..\include\zlib\contrib\vstudio\vc10\zlibstat.vcxproj", "{745DEC58-EBB3-47A9-A9B8-4C6627C01BF8}" EndProject Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "libFLAC_static", "..\include\flac\src\libFLAC\libFLAC_static_10.vcxproj", "{4CEFBC84-C215-11DB-8314-0800200C9A66}" EndProject -Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "unzip", "..\unzip\unzip_10.vcxproj", "{F23CC68D-1D58-4EB1-9425-A28F5058EB31}" -EndProject Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "portaudio", "..\include\portaudio\build\msvc\portaudio_openmpt_vs2010.vcxproj", "{0A18A071-125E-442F-AFF7-A3F68ABECF99}" EndProject +Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "unarchiver", "..\unarchiver\unarchiver_10.vcxproj", "{94CD7910-649A-4075-9F33-7EBEE614FD45}" +EndProject Global GlobalSection(SolutionConfigurationPlatforms) = preSolution Debug|Win32 = Debug|Win32 @@ -36,18 +30,6 @@ {21D95071-FB97-4E69-B3B1-050D0D4A5021}.Release|Win32.Build.0 = ReleaseLTCG|Win32 {21D95071-FB97-4E69-B3B1-050D0D4A5021}.ReleaseNoLTCG|Win32.ActiveCfg = Release|Win32 {21D95071-FB97-4E69-B3B1-050D0D4A5021}.ReleaseNoLTCG|Win32.Build.0 = Release|Win32 - {FAE39936-1DC7-40BB-AD3F-3B5B9E9AB0E8}.Debug|Win32.ActiveCfg = Debug|Win32 - {FAE39936-1DC7-40BB-AD3F-3B5B9E9AB0E8}.Debug|Win32.Build.0 = Debug|Win32 - {FAE39936-1DC7-40BB-AD3F-3B5B9E9AB0E8}.Release|Win32.ActiveCfg = Release|Win32 - {FAE39936-1DC7-40BB-AD3F-3B5B9E9AB0E8}.Release|Win32.Build.0 = Release|Win32 - {FAE39936-1DC7-40BB-AD3F-3B5B9E9AB0E8}.ReleaseNoLTCG|Win32.ActiveCfg = Release|Win32 - {FAE39936-1DC7-40BB-AD3F-3B5B9E9AB0E8}.ReleaseNoLTCG|Win32.Build.0 = Release|Win32 - {FF541CE2-DAA1-4F84-9883-0A0F111BAA0B}.Debug|Win32.ActiveCfg = Debug|Win32 - {FF541CE2-DAA1-4F84-9883-0A0F111BAA0B}.Debug|Win32.Build.0 = Debug|Win32 - {FF541CE2-DAA1-4F84-9883-0A0F111BAA0B}.Release|Win32.ActiveCfg = Release|Win32 - {FF541CE2-DAA1-4F84-9883-0A0F111BAA0B}.Release|Win32.Build.0 = Release|Win32 - {FF541CE2-DAA1-4F84-9883-0A0F111BAA0B}.ReleaseNoLTCG|Win32.ActiveCfg = Release|Win32 - {FF541CE2-DAA1-4F84-9883-0A0F111BAA0B}.ReleaseNoLTCG|Win32.Build.0 = Release|Win32 {DCC2BB2F-6778-4FD3-9C00-D6CD8DC917B8}.Debug|Win32.ActiveCfg = Debug|Win32 {DCC2BB2F-6778-4FD3-9C00-D6CD8DC917B8}.Debug|Win32.Build.0 = Debug|Win32 {DCC2BB2F-6778-4FD3-9C00-D6CD8DC917B8}.Release|Win32.ActiveCfg = Release|Win32 @@ -60,12 +42,6 @@ {CF3C2CA5-5D45-4635-BBA4-C1F435E10896}.Release|Win32.Build.0 = Release|Win32 {CF3C2CA5-5D45-4635-BBA4-C1F435E10896}.ReleaseNoLTCG|Win32.ActiveCfg = Release|Win32 {CF3C2CA5-5D45-4635-BBA4-C1F435E10896}.ReleaseNoLTCG|Win32.Build.0 = Release|Win32 - {94CD7910-649A-4075-9F33-7EBEE614FD45}.Debug|Win32.ActiveCfg = Debug|Win32 - {94CD7910-649A-4075-9F33-7EBEE614FD45}.Debug|Win32.Build.0 = Debug|Win32 - {94CD7910-649A-4075-9F33-7EBEE614FD45}.Release|Win32.ActiveCfg = Release|Win32 - {94CD7910-649A-4075-9F33-7EBEE614FD45}.Release|Win32.Build.0 = Release|Win32 - {94CD7910-649A-4075-9F33-7EBEE614FD45}.ReleaseNoLTCG|Win32.ActiveCfg = Release|Win32 - {94CD7910-649A-4075-9F33-7EBEE614FD45}.ReleaseNoLTCG|Win32.Build.0 = Release|Win32 {745DEC58-EBB3-47A9-A9B8-4C6627C01BF8}.Debug|Win32.ActiveCfg = Debug|Win32 {745DEC58-EBB3-47A9-A9B8-4C6627C01BF8}.Debug|Win32.Build.0 = Debug|Win32 {745DEC58-EBB3-47A9-A9B8-4C6627C01BF8}.Release|Win32.ActiveCfg = Release|Win32 @@ -78,18 +54,18 @@ {4CEFBC84-C215-11DB-8314-0800200C9A66}.Release|Win32.Build.0 = Release|Win32 {4CEFBC84-C215-11DB-8314-0800200C9A66}.ReleaseNoLTCG|Win32.ActiveCfg = Release|Win32 {4CEFBC84-C215-11DB-8314-0800200C9A66}.ReleaseNoLTCG|Win32.Build.0 = Release|Win32 - {F23CC68D-1D58-4EB1-9425-A28F5058EB31}.Debug|Win32.ActiveCfg = Debug|Win32 - {F23CC68D-1D58-4EB1-9425-A28F5058EB31}.Debug|Win32.Build.0 = Debug|Win32 - {F23CC68D-1D58-4EB1-9425-A28F5058EB31}.Release|Win32.ActiveCfg = Release|Win32 - {F23CC68D-1D58-4EB1-9425-A28F5058EB31}.Release|Win32.Build.0 = Release|Win32 - {F23CC68D-1D58-4EB1-9425-A28F5058EB31}.ReleaseNoLTCG|Win32.ActiveCfg = Release|Win32 - {F23CC68D-1D58-4EB1-9425-A28F5058EB31}.ReleaseNoLTCG|Win32.Build.0 = Release|Win32 {0A18A071-125E-442F-AFF7-A3F68ABECF99}.Debug|Win32.ActiveCfg = Debug|Win32 {0A18A071-125E-442F-AFF7-A3F68ABECF99}.Debug|Win32.Build.0 = Debug|Win32 {0A18A071-125E-442F-AFF7-A3F68ABECF99}.Release|Win32.ActiveCfg = Release|Win32 {0A18A071-125E-442F-AFF7-A3F68ABECF99}.Release|Win32.Build.0 = Release|Win32 {0A18A071-125E-442F-AFF7-A3F68ABECF99}.ReleaseNoLTCG|Win32.ActiveCfg = Release|Win32 {0A18A071-125E-442F-AFF7-A3F68ABECF99}.ReleaseNoLTCG|Win32.Build.0 = Release|Win32 + {94CD7910-649A-4075-9F33-7EBEE614FD45}.Debug|Win32.ActiveCfg = Debug|Win32 + {94CD7910-649A-4075-9F33-7EBEE614FD45}.Debug|Win32.Build.0 = Debug|Win32 + {94CD7910-649A-4075-9F33-7EBEE614FD45}.Release|Win32.ActiveCfg = Release|Win32 + {94CD7910-649A-4075-9F33-7EBEE614FD45}.Release|Win32.Build.0 = Release|Win32 + {94CD7910-649A-4075-9F33-7EBEE614FD45}.ReleaseNoLTCG|Win32.ActiveCfg = Release|Win32 + {94CD7910-649A-4075-9F33-7EBEE614FD45}.ReleaseNoLTCG|Win32.Build.0 = Release|Win32 EndGlobalSection GlobalSection(SolutionProperties) = preSolution HideSolutionNode = FALSE Modified: trunk/OpenMPT/mptrack/mptrack_10.vcxproj =================================================================== --- trunk/OpenMPT/mptrack/mptrack_10.vcxproj 2013-04-16 15:17:59 UTC (rev 1888) +++ trunk/OpenMPT/mptrack/mptrack_10.vcxproj 2013-04-16 15:21:31 UTC (rev 1889) @@ -559,21 +559,9 @@ <Project>{cf3c2ca5-5d45-4635-bba4-c1f435e10896}</Project> <ReferenceOutputAssembly>false</ReferenceOutputAssembly> </ProjectReference> - <ProjectReference Include="..\ungzip\ungzip_10.vcxproj"> + <ProjectReference Include="..\unarchiver\unarchiver_10.vcxproj"> <Project>{94cd7910-649a-4075-9f33-7ebee614fd45}</Project> - <ReferenceOutputAssembly>false</ReferenceOutputAssembly> </ProjectReference> - <ProjectReference Include="..\unlha\unlha_10.vcxproj"> - <Project>{fae39936-1dc7-40bb-ad3f-3b5b9e9ab0e8}</Project> - <ReferenceOutputAssembly>false</ReferenceOutputAssembly> - </ProjectReference> - <ProjectReference Include="..\unrar\unrar_10.vcxproj"> - <Project>{ff541ce2-daa1-4f84-9883-0a0f111baa0b}</Project> - <ReferenceOutputAssembly>false</ReferenceOutputAssembly> - </ProjectReference> - <ProjectReference Include="..\unzip\unzip_10.vcxproj"> - <Project>{f23cc68d-1d58-4eb1-9425-a28f5058eb31}</Project> - </ProjectReference> <ProjectReference Include="..\xsoundlib\xsoundlib_10.vcxproj"> <Project>{dcc2bb2f-6778-4fd3-9c00-d6cd8dc917b8}</Project> </ProjectReference> Modified: trunk/OpenMPT/soundlib/Sndfile.cpp =================================================================== --- trunk/OpenMPT/soundlib/Sndfile.cpp 2013-04-16 15:17:59 UTC (rev 1888) +++ trunk/OpenMPT/soundlib/Sndfile.cpp 2013-04-16 15:21:31 UTC (rev 1889) @@ -32,19 +32,19 @@ #endif // NO_ARCHIVE_SUPPORT #ifdef ZIPPED_MOD_SUPPORT -#include "../unzip/unzip.h" +#include "../unarchiver/unzip.h" #endif #ifdef UNRAR_SUPPORT -#include "../unrar/unrar32.h" +#include "../unarchiver/unrar.h" #endif #ifdef UNLHA_SUPPORT -#include "../unlha/unlha32.h" +#include "../unarchiver/unlha.h" #endif #ifdef UNGZIP_SUPPORT -#include "../ungzip/ungzip.h" +#include "../unarchiver/ungzip.h" #endif #ifdef MMCMP_SUPPORT Index: trunk/OpenMPT/unarchiver =================================================================== --- branches/manx/unarchiver/unarchiver 2013-04-16 15:17:59 UTC (rev 1888) +++ trunk/OpenMPT/unarchiver 2013-04-16 15:21:31 UTC (rev 1889) Property changes on: trunk/OpenMPT/unarchiver ___________________________________________________________________ Added: svn:ignore ## -0,0 +1,4 ## +Debug +Release +unarchiver_10.vcxproj.user +*.user Added: tsvn:logminsize ## -0,0 +1 ## +10 \ No newline at end of property This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <man...@us...> - 2013-04-16 16:40:39
|
Revision: 1891 http://sourceforge.net/p/modplug/code/1891 Author: manxorist Date: 2013-04-16 16:40:31 +0000 (Tue, 16 Apr 2013) Log Message: ----------- [Ref] Move handling of the different archive formats out of soundlib and into the unarchiver project. Modified Paths: -------------- trunk/OpenMPT/soundlib/Sndfile.cpp trunk/OpenMPT/unarchiver/unarchiver_08.vcproj trunk/OpenMPT/unarchiver/unarchiver_10.vcxproj trunk/OpenMPT/unarchiver/unarchiver_10.vcxproj.filters Added Paths: ----------- trunk/OpenMPT/unarchiver/unarchiver.cpp trunk/OpenMPT/unarchiver/unarchiver.h Modified: trunk/OpenMPT/soundlib/Sndfile.cpp =================================================================== --- trunk/OpenMPT/soundlib/Sndfile.cpp 2013-04-16 15:22:13 UTC (rev 1890) +++ trunk/OpenMPT/soundlib/Sndfile.cpp 2013-04-16 16:40:31 UTC (rev 1891) @@ -24,29 +24,11 @@ #ifndef NO_MMCMP_SUPPORT #define MMCMP_SUPPORT #endif // NO_MMCMP_SUPPORT + #ifndef NO_ARCHIVE_SUPPORT -#define UNRAR_SUPPORT -#define UNLHA_SUPPORT -#define UNGZIP_SUPPORT -#define ZIPPED_MOD_SUPPORT +#include "../unarchiver/unarchiver.h" #endif // NO_ARCHIVE_SUPPORT -#ifdef ZIPPED_MOD_SUPPORT -#include "../unarchiver/unzip.h" -#endif - -#ifdef UNRAR_SUPPORT -#include "../unarchiver/unrar.h" -#endif - -#ifdef UNLHA_SUPPORT -#include "../unarchiver/unlha.h" -#endif - -#ifdef UNGZIP_SUPPORT -#include "../unarchiver/ungzip.h" -#endif - #ifdef MMCMP_SUPPORT extern BOOL MMCMP_Unpack(LPCBYTE *ppMemFile, LPDWORD pdwMemLength); #endif @@ -543,50 +525,15 @@ { FileReader file(lpStream, dwMemLength); - const std::vector<const char *> modExtensions = GetSupportedExtensions(true); - -#ifdef ZIPPED_MOD_SUPPORT - CZipArchive unzip(file, modExtensions); - if(unzip.IsArchive() && unzip.ExtractFile()) +#ifndef NO_ARCHIVE_SUPPORT + CUnarchiver unarchiver(file, GetSupportedExtensions(true)); + if(unarchiver.IsArchive() && unarchiver.ExtractFile()) { - file = unzip.GetOutputFile(); + file = unarchiver.GetOutputFile(); lpStream = (LPCBYTE)file.GetRawData(); dwMemLength = file.GetLength(); } #endif -#ifdef UNRAR_SUPPORT - CRarArchive unrar((LPBYTE)lpStream, dwMemLength); - if(unrar.IsArchive()) - { - if(unrar.ExtrFile() && unrar.GetOutputFile()) - { - lpStream = unrar.GetOutputFile(); - dwMemLength = unrar.GetOutputFileLength(); - file = FileReader(lpStream, dwMemLength); - } - } -#endif -#ifdef UNLHA_SUPPORT - CLhaArchive unlha((LPBYTE)lpStream, dwMemLength); - if(unlha.IsArchive()) - { - if(unlha.ExtractFile() && unlha.GetOutputFile()) - { - lpStream = unlha.GetOutputFile(); - dwMemLength = unlha.GetOutputFileLength(); - file = FileReader(lpStream, dwMemLength); - } - } -#endif -#ifdef UNGZIP_SUPPORT - CGzipArchive ungzip(file); - if(ungzip.IsArchive() && ungzip.ExtractFile()) - { - file = ungzip.GetOutputFile(); - lpStream = (LPCBYTE)file.GetRawData(); - dwMemLength = file.GetLength(); - } -#endif #ifdef MMCMP_SUPPORT BOOL bMMCmp = MMCMP_Unpack(&lpStream, &dwMemLength); @@ -639,11 +586,11 @@ m_nType = MOD_TYPE_NONE; } -#ifdef ZIPPED_MOD_SUPPORT +#ifndef NO_ARCHIVE_SUPPORT // Read archive comment if there is no song comment - if(!songMessage.empty() && unzip.GetComments(false)) + if(!songMessage.empty() && unarchiver.GetComments(false)) { - songMessage.assign(unzip.GetComments(true)); + songMessage.assign(unarchiver.GetComments(true)); } #endif #ifdef MMCMP_SUPPORT Added: trunk/OpenMPT/unarchiver/unarchiver.cpp =================================================================== --- trunk/OpenMPT/unarchiver/unarchiver.cpp (rev 0) +++ trunk/OpenMPT/unarchiver/unarchiver.cpp 2013-04-16 16:40:31 UTC (rev 1891) @@ -0,0 +1,102 @@ +/* + * unarchiver.cpp + * -------------- + * Purpose: archive loader + * Notes : (currently none) + * Authors: OpenMPT Devs + * The OpenMPT source code is released under the BSD license. Read LICENSE for more details. + */ + +#include "../common/stdafx.h" + +#include "unarchiver.h" + +#include "../soundlib/FileReader.h" + +CUnarchiver::CUnarchiver(FileReader &file, const std::vector<const char *> &extensions) : +inFile(file), +zipArchive(inFile, extensions), +rarArchive((LPBYTE)inFile.GetRawData(), inFile.GetLength()), +lhaArchive((LPBYTE)inFile.GetRawData(), inFile.GetLength()), +gzipArchive(inFile) +//--------------------------------------------------------------------------------- +{ + inFile.Rewind(); +} + + +CUnarchiver::~CUnarchiver() +//------------------------- +{ + return; +} + + +bool CUnarchiver::IsArchive() const +//--------------------------------- +{ + 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 + ; +} + + +bool CUnarchiver::ExtractFile() +//----------------------------- +{ +#ifdef ZIPPED_MOD_SUPPORT + if(zipArchive.IsArchive()) + { + if(!zipArchive.ExtractFile()) return false; + outFile = zipArchive.GetOutputFile(); + return outFile.GetRawData()?true:false; + } +#endif +#ifdef UNRAR_SUPPORT + if(rarArchive.IsArchive()) + { + if(!rarArchive.ExtrFile()) return false; + outFile = FileReader(rarArchive.GetOutputFile(), rarArchive.GetOutputFileLength()); + return outFile.GetRawData()?true:false; + } +#endif +#ifdef UNLHA_SUPPORT + if(lhaArchive.IsArchive()) + { + if(!lhaArchive.ExtractFile()) return false; + outFile = FileReader(lhaArchive.GetOutputFile(), lhaArchive.GetOutputFileLength()); + return outFile.GetRawData()?true:false; + } +#endif +#ifdef UNGZIP_SUPPORT + if(gzipArchive.IsArchive()) + { + if(!gzipArchive.ExtractFile()) return false; + outFile = gzipArchive.GetOutputFile(); + return outFile.GetRawData()?true:false; + } +#endif + return false; +} + + +const char *CUnarchiver::GetComments(bool get) +{ +#ifdef ZIPPED_MOD_SUPPORT + if(!zipArchive.IsArchive()) return nullptr; + return zipArchive.GetComments(get); +#else + return nullptr; +#endif +} Property changes on: trunk/OpenMPT/unarchiver/unarchiver.cpp ___________________________________________________________________ Added: svn:mime-type ## -0,0 +1 ## +text/x-c++src \ No newline at end of property Added: svn:eol-style ## -0,0 +1 ## +native \ No newline at end of property Added: trunk/OpenMPT/unarchiver/unarchiver.h =================================================================== --- trunk/OpenMPT/unarchiver/unarchiver.h (rev 0) +++ trunk/OpenMPT/unarchiver/unarchiver.h 2013-04-16 16:40:31 UTC (rev 1891) @@ -0,0 +1,57 @@ +/* + * unarchiver.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" + +#define UNGZIP_SUPPORT +#define UNLHA_SUPPORT +#define UNRAR_SUPPORT +#define ZIPPED_MOD_SUPPORT + +#ifdef ZIPPED_MOD_SUPPORT +#include "unzip.h" +#endif +#ifdef UNRAR_SUPPORT +#include "unrar.h" +#endif +#ifdef UNLHA_SUPPORT +#include "unlha.h" +#endif +#ifdef UNGZIP_SUPPORT +#include "ungzip.h" +#endif + +//=============== +class CUnarchiver +//=============== +{ +protected: + FileReader inFile; + +private: + CZipArchive zipArchive; + mutable CRarArchive rarArchive; + mutable CLhaArchive lhaArchive; + CGzipArchive gzipArchive; + +protected: + FileReader outFile; + +public: + + FileReader GetOutputFile() const { return outFile; } + bool IsArchive() const; + bool ExtractFile(); + const char *GetComments(bool get); + + CUnarchiver(FileReader &file, const std::vector<const char *> & extensions); + ~CUnarchiver(); +}; Property changes on: trunk/OpenMPT/unarchiver/unarchiver.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_08.vcproj =================================================================== --- trunk/OpenMPT/unarchiver/unarchiver_08.vcproj 2013-04-16 15:22:13 UTC (rev 1890) +++ trunk/OpenMPT/unarchiver/unarchiver_08.vcproj 2013-04-16 16:40:31 UTC (rev 1891) @@ -151,6 +151,10 @@ UniqueIdentifier="{4FC737F1-C7A5-4376-A066-2A32D752A2FF}" > <File + RelativePath=".\unarchiver.cpp" + > + </File> + <File RelativePath=".\ungzip.cpp" > </File> @@ -601,6 +605,10 @@ UniqueIdentifier="{93995380-89BD-4b04-88EB-625FBE52EBFB}" > <File + RelativePath=".\unarchiver.h" + > + </File> + <File RelativePath=".\ungzip.h" > </File> Modified: trunk/OpenMPT/unarchiver/unarchiver_10.vcxproj =================================================================== --- trunk/OpenMPT/unarchiver/unarchiver_10.vcxproj 2013-04-16 15:22:13 UTC (rev 1890) +++ trunk/OpenMPT/unarchiver/unarchiver_10.vcxproj 2013-04-16 16:40:31 UTC (rev 1891) @@ -11,6 +11,7 @@ </ProjectConfiguration> </ItemGroup> <ItemGroup> + <ClCompile Include="unarchiver.cpp" /> <ClCompile Include="ungzip.cpp" /> <ClCompile Include="unlha.cpp" /> <ClCompile Include="unlha\DHUF.CPP"> @@ -89,6 +90,7 @@ <ClCompile Include="unzip.cpp" /> </ItemGroup> <ItemGroup> + <ClInclude Include="unarchiver.h" /> <ClInclude Include="ungzip.h" /> <ClInclude Include="unlha.h" /> <ClInclude Include="unlha\LHARC.H"> Modified: trunk/OpenMPT/unarchiver/unarchiver_10.vcxproj.filters =================================================================== --- trunk/OpenMPT/unarchiver/unarchiver_10.vcxproj.filters 2013-04-16 15:22:13 UTC (rev 1890) +++ trunk/OpenMPT/unarchiver/unarchiver_10.vcxproj.filters 2013-04-16 16:40:31 UTC (rev 1891) @@ -67,6 +67,7 @@ <ClCompile Include="unlha\SLIDE.CPP"> <Filter>unlha</Filter> </ClCompile> + <ClCompile Include="unarchiver.cpp" /> </ItemGroup> <ItemGroup> <ClInclude Include="ungzip.h" /> @@ -82,5 +83,6 @@ <ClInclude Include="unlha\SLIDEHUF.H"> <Filter>unlha</Filter> </ClInclude> + <ClInclude Include="unarchiver.h" /> </ItemGroup> </Project> \ No newline at end of file This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <man...@us...> - 2013-04-16 22:00:45
|
Revision: 1895 http://sourceforge.net/p/modplug/code/1895 Author: manxorist Date: 2013-04-16 22:00:18 +0000 (Tue, 16 Apr 2013) Log Message: ----------- [Ref] Add compile-time assertions for the size of all on-disk structures. [Ref] Tag all on-disk structures with PACKED attribute, and use #pragma pack only when NEEDS_PRAGMA_PACK is defined for the current compiler in typedefs.h . Modified Paths: -------------- trunk/OpenMPT/common/typedefs.h trunk/OpenMPT/mptrack/TrackerSettings.h trunk/OpenMPT/mptrack/mod2midi.cpp trunk/OpenMPT/mptrack/tagging.h trunk/OpenMPT/sounddsp/EQ.cpp trunk/OpenMPT/sounddsp/EQ.h trunk/OpenMPT/soundlib/Dlsbank.cpp trunk/OpenMPT/soundlib/Dlsbank.h trunk/OpenMPT/soundlib/ITTools.h trunk/OpenMPT/soundlib/LOAD_AMF.CPP trunk/OpenMPT/soundlib/LOAD_DBM.CPP trunk/OpenMPT/soundlib/LOAD_DMF.CPP trunk/OpenMPT/soundlib/LOAD_DSM.CPP trunk/OpenMPT/soundlib/Load_669.cpp trunk/OpenMPT/soundlib/Load_ams.cpp trunk/OpenMPT/soundlib/Load_far.cpp trunk/OpenMPT/soundlib/Load_gdm.cpp trunk/OpenMPT/soundlib/Load_imf.cpp trunk/OpenMPT/soundlib/Load_it.cpp trunk/OpenMPT/soundlib/Load_itp.cpp trunk/OpenMPT/soundlib/Load_mdl.cpp trunk/OpenMPT/soundlib/Load_med.cpp trunk/OpenMPT/soundlib/Load_mid.cpp trunk/OpenMPT/soundlib/Load_mod.cpp trunk/OpenMPT/soundlib/Load_mt2.cpp trunk/OpenMPT/soundlib/Load_mtm.cpp trunk/OpenMPT/soundlib/Load_okt.cpp trunk/OpenMPT/soundlib/Load_psm.cpp trunk/OpenMPT/soundlib/Load_ptm.cpp trunk/OpenMPT/soundlib/Load_s3m.cpp trunk/OpenMPT/soundlib/Load_stm.cpp trunk/OpenMPT/soundlib/Load_ult.cpp trunk/OpenMPT/soundlib/Load_umx.cpp trunk/OpenMPT/soundlib/Load_xm.cpp trunk/OpenMPT/soundlib/MIDIMacros.h trunk/OpenMPT/soundlib/Mmcmp.cpp trunk/OpenMPT/soundlib/SampleFormats.cpp trunk/OpenMPT/soundlib/WAVTools.h trunk/OpenMPT/soundlib/Wav.h trunk/OpenMPT/soundlib/XMTools.h trunk/OpenMPT/soundlib/load_j2b.cpp trunk/OpenMPT/soundlib/plugins/PlugInterface.h trunk/OpenMPT/unarchiver/ungzip.h Modified: trunk/OpenMPT/common/typedefs.h =================================================================== --- trunk/OpenMPT/common/typedefs.h 2013-04-16 21:24:09 UTC (rev 1894) +++ trunk/OpenMPT/common/typedefs.h 2013-04-16 22:00:18 UTC (rev 1895) @@ -33,8 +33,8 @@ #endif #if defined(_MSC_VER) -#define USE_PRAGMA_PACK #define PACKED __declspec(align(1)) +#define NEEDS_PRAGMA_PACK #elif defined(__GNUC__) #define PACKED __attribute__((packed))) __attribute__((aligned(1)))) #endif Modified: trunk/OpenMPT/mptrack/TrackerSettings.h =================================================================== --- trunk/OpenMPT/mptrack/TrackerSettings.h 2013-04-16 21:24:09 UTC (rev 1894) +++ trunk/OpenMPT/mptrack/TrackerSettings.h 2013-04-16 22:00:18 UTC (rev 1895) @@ -118,12 +118,19 @@ // EQ -struct EQPreset +#ifdef NEEDS_PRAGMA_PACK +#pragma pack(push, 1) +#endif +struct PACKED EQPreset { char szName[12]; UINT Gains[MAX_EQ_BANDS]; UINT Freqs[MAX_EQ_BANDS]; }; +#ifdef NEEDS_PRAGMA_PACK +#pragma pack(pop) +#endif +STATIC_ASSERT(sizeof(EQPreset) == 60); // Chords Modified: trunk/OpenMPT/mptrack/mod2midi.cpp =================================================================== --- trunk/OpenMPT/mptrack/mod2midi.cpp 2013-04-16 21:24:09 UTC (rev 1894) +++ trunk/OpenMPT/mptrack/mod2midi.cpp 2013-04-16 22:00:18 UTC (rev 1895) @@ -15,9 +15,11 @@ #include "mod2midi.h" #include "Wav.h" +#ifdef NEEDS_PRAGMA_PACK #pragma pack(push, 1) +#endif -typedef struct _RMIDDATACHUNK +typedef struct PACKED _RMIDDATACHUNK { DWORD id_RIFF; // "RIFF" DWORD filelen; @@ -26,7 +28,9 @@ DWORD datalen; } RMIDDATACHUNK, *PRMIDDATACHUNK; -typedef struct _MTHDCHUNK // (big endian) +STATIC_ASSERT(sizeof(RMIDDATACHUNK) == 20); + +typedef struct PACKED _MTHDCHUNK // (big endian) { DWORD id; // "MThd" = 0x6468544D DWORD len; // 6 @@ -35,12 +39,20 @@ WORD wDivision; // PPQN } MTHDCHUNK, *PMTHDCHUNK; -typedef struct _MTRKCHUNK // (big endian) +STATIC_ASSERT(sizeof(MTHDCHUNK) == 14); + +typedef struct PACKED _MTRKCHUNK // (big endian) { DWORD id; // "MTrk" = 0x6B72544D DWORD len; } MTRKCHUNK, *PMTRKCHUNK; +STATIC_ASSERT(sizeof(MTRKCHUNK) == 8); + +#ifdef NEEDS_PRAGMA_PACK +#pragma pack(pop) +#endif + typedef struct _DYNMIDITRACK { UINT nTrackSize; @@ -56,9 +68,7 @@ void WriteLen(unsigned long len); } DYNMIDITRACK, *PDYNMIDITRACK; -#pragma pack(pop) - void DYNMIDITRACK::Write(const void *pBuffer, unsigned long nBytes) //----------------------------------------------------------------- { Modified: trunk/OpenMPT/mptrack/tagging.h =================================================================== --- trunk/OpenMPT/mptrack/tagging.h 2013-04-16 21:24:09 UTC (rev 1894) +++ trunk/OpenMPT/mptrack/tagging.h 2013-04-16 22:00:18 UTC (rev 1895) @@ -18,9 +18,11 @@ /////////////////////////////////////////////////////////////////////////////////////////////////// // ID3v2.4 Tags +#ifdef NEEDS_PRAGMA_PACK #pragma pack(push, 1) +#endif -struct ID3v2Header +struct PACKED ID3v2Header { uint8 signature[3]; uint8 version[2]; @@ -29,7 +31,9 @@ // Total: 10 bytes }; -struct ID3v2Frame +STATIC_ASSERT(sizeof(ID3v2Header) == 10); + +struct PACKED ID3v2Frame { uint32 frameid; uint32 size; @@ -37,7 +41,11 @@ // Total: 10 bytes }; +STATIC_ASSERT(sizeof(ID3v2Frame) == 10); + +#ifdef NEEDS_PRAGMA_PACK #pragma pack(pop) +#endif // we will add some padding bytes to our id3v2 tag (extending tags will be easier this way) #define ID3v2_PADDING 512 Modified: trunk/OpenMPT/sounddsp/EQ.cpp =================================================================== --- trunk/OpenMPT/sounddsp/EQ.cpp 2013-04-16 21:24:09 UTC (rev 1894) +++ trunk/OpenMPT/sounddsp/EQ.cpp 2013-04-16 22:00:18 UTC (rev 1895) @@ -43,24 +43,24 @@ }; -static const REAL f2ic = (REAL)(1 << 28); -static const REAL i2fc = (REAL)(1.0 / (1 << 28)); +static const float32 f2ic = (float32)(1 << 28); +static const float32 i2fc = (float32)(1.0 / (1 << 28)); static const EQBANDSTRUCT gEQDefaults[MAX_EQ_BANDS*2] = { // Default: Flat EQ - {0,0,0,0,0, 0,0,0,0, 1, 120, FALSE}, - {0,0,0,0,0, 0,0,0,0, 1, 600, FALSE}, - {0,0,0,0,0, 0,0,0,0, 1, 1200, FALSE}, - {0,0,0,0,0, 0,0,0,0, 1, 3000, FALSE}, - {0,0,0,0,0, 0,0,0,0, 1, 6000, FALSE}, - {0,0,0,0,0, 0,0,0,0, 1, 10000, FALSE}, - {0,0,0,0,0, 0,0,0,0, 1, 120, FALSE}, - {0,0,0,0,0, 0,0,0,0, 1, 600, FALSE}, - {0,0,0,0,0, 0,0,0,0, 1, 1200, FALSE}, - {0,0,0,0,0, 0,0,0,0, 1, 3000, FALSE}, - {0,0,0,0,0, 0,0,0,0, 1, 6000, FALSE}, - {0,0,0,0,0, 0,0,0,0, 1, 10000, FALSE}, + {0,0,0,0,0, 0,0,0,0, 1, 120, false}, + {0,0,0,0,0, 0,0,0,0, 1, 600, false}, + {0,0,0,0,0, 0,0,0,0, 1, 1200, false}, + {0,0,0,0,0, 0,0,0,0, 1, 3000, false}, + {0,0,0,0,0, 0,0,0,0, 1, 6000, false}, + {0,0,0,0,0, 0,0,0,0, 1, 10000, false}, + {0,0,0,0,0, 0,0,0,0, 1, 120, false}, + {0,0,0,0,0, 0,0,0,0, 1, 600, false}, + {0,0,0,0,0, 0,0,0,0, 1, 1200, false}, + {0,0,0,0,0, 0,0,0,0, 1, 3000, false}, + {0,0,0,0,0, 0,0,0,0, 1, 6000, false}, + {0,0,0,0,0, 0,0,0,0, 1, 10000, false}, }; #ifdef ENABLE_X86 @@ -77,8 +77,8 @@ #define PBS_Y1 DWORD PTR [eax+28] #define PBS_Y2 DWORD PTR [eax+32] -static void EQFilter(EQBANDSTRUCT *pbs, REAL *pbuffer, UINT nCount) -//------------------------------------------------------------------------- +static void EQFilter(EQBANDSTRUCT *pbs, float32 *pbuffer, UINT nCount) +//-------------------------------------------------------------------- { _asm { mov eax, pbs // eax = pbs @@ -124,8 +124,8 @@ } -static void AMD_StereoEQ(EQBANDSTRUCT *pbl, EQBANDSTRUCT *pbr, REAL *pbuffer, UINT nCount) -//---------------------------------------------------------------------------------------- +static void AMD_StereoEQ(EQBANDSTRUCT *pbl, EQBANDSTRUCT *pbr, float32 *pbuffer, UINT nCount) +//------------------------------------------------------------------------------------------- { #ifdef ENABLE_3DNOW float tmp[16]; @@ -208,8 +208,8 @@ } -static void SSE_StereoEQ(EQBANDSTRUCT *pbl, EQBANDSTRUCT *pbr, REAL *pbuffer, UINT nCount) -//---------------------------------------------------------------------------------------- +static void SSE_StereoEQ(EQBANDSTRUCT *pbl, EQBANDSTRUCT *pbr, float32 *pbuffer, UINT nCount) +//------------------------------------------------------------------------------------------- { #ifdef ENABLE_SSE static const float gk1 = 1.0f; @@ -306,13 +306,13 @@ #else -static void EQFilter(EQBANDSTRUCT *pbs, REAL *pbuffer, UINT nCount) -//----------------------------------------------------------------- +static void EQFilter(EQBANDSTRUCT *pbs, float32 *pbuffer, UINT nCount) +//-------------------------------------------------------------------- { for (UINT i=0; i<nCount; i++) { - REAL x = pbuffer[i]; - REAL y = pbs->a1 * pbs->x1 + pbs->a2 * pbs->x2 + pbs->a0 * x + pbs->b1 * pbs->y1 + pbs->b2 * pbs->y2; + float32 x = pbuffer[i]; + float32 y = pbs->a1 * pbs->x1 + pbs->a2 * pbs->x2 + pbs->a0 * x + pbs->b1 * pbs->y1 + pbs->b2 * pbs->y2; pbs->x2 = pbs->x1; pbs->y2 = pbs->y1; pbs->x1 = x; @@ -407,6 +407,10 @@ CEQ::CEQ() //-------- { + #if defined(ENABLE_MMX) || defined(ENABLE_SSE) + ALWAYS_ASSERT(((uintptr_t)&(gEQ[0])) % 4 == 0); + ALWAYS_ASSERT(((uintptr_t)&(gEQ[1])) % 4 == 0); + #endif memcpy(gEQ, gEQDefaults, sizeof(gEQ)); } @@ -414,12 +418,12 @@ void CEQ::Initialize(BOOL bReset, DWORD MixingFreq) //------------------------------------------------- { - REAL fMixingFreq = (REAL)MixingFreq; + float32 fMixingFreq = (float32)MixingFreq; // Gain = 0.5 (-6dB) .. 2 (+6dB) for (UINT band=0; band<MAX_EQ_BANDS*2; band++) if (gEQ[band].bEnable) { - REAL k, k2, r, f; - REAL v0, v1; + float32 k, k2, r, f; + float32 v0, v1; BOOL b = bReset; f = gEQ[band].CenterFrequency / fMixingFreq; @@ -428,7 +432,7 @@ // k = tan(PI*f); k = f * 3.141592654f; k = k + k*f; -// if (k > (REAL)0.707) k = (REAL)0.707; +// if (k > (float32)0.707) k = (float32)0.707; k2 = k*k; v0 = gEQ[band].Gain; v1 = 1; @@ -445,31 +449,31 @@ if (r != gEQ[band].a0) { gEQ[band].a0 = r; - b = TRUE; + b = true; } r = 2 * (k2 - 1) / (1 + v1*k + k2); if (r != gEQ[band].a1) { gEQ[band].a1 = r; - b = TRUE; + b = true; } r = (1 - v0*k + k2) / (1 + v1*k + k2); if (r != gEQ[band].a2) { gEQ[band].a2 = r; - b = TRUE; + b = true; } r = - 2 * (k2 - 1) / (1 + v1*k + k2); if (r != gEQ[band].b1) { gEQ[band].b1 = r; - b = TRUE; + b = true; } r = - (1 - v1*k + k2) / (1 + v1*k + k2); if (r != gEQ[band].b2) { gEQ[band].b2 = r; - b = TRUE; + b = true; } if (b) { @@ -498,13 +502,13 @@ { for (UINT i=0; i<MAX_EQ_BANDS; i++) { - REAL g, f = 0; + float32 g, f = 0; if (i < nGains) { UINT n = pGains[i]; if (n > 32) n = 32; - g = ((REAL)gEqLinearToDB[n]) / 64.0f; - if (pFreqs) f = (REAL)(int)pFreqs[i]; + g = ((float32)gEqLinearToDB[n]) / 64.0f; + if (pFreqs) f = (float32)(int)pFreqs[i]; } else { g = 1; @@ -515,12 +519,12 @@ gEQ[i+MAX_EQ_BANDS].CenterFrequency = f; if (f > 20.0f) { - gEQ[i].bEnable = TRUE; - gEQ[i+MAX_EQ_BANDS].bEnable = TRUE; + gEQ[i].bEnable = true; + gEQ[i+MAX_EQ_BANDS].bEnable = true; } else { - gEQ[i].bEnable = FALSE; - gEQ[i+MAX_EQ_BANDS].bEnable = FALSE; + gEQ[i].bEnable = false; + gEQ[i+MAX_EQ_BANDS].bEnable = false; } } Initialize(bReset, MixingFreq); Modified: trunk/OpenMPT/sounddsp/EQ.h =================================================================== --- trunk/OpenMPT/sounddsp/EQ.h 2013-04-16 21:24:09 UTC (rev 1894) +++ trunk/OpenMPT/sounddsp/EQ.h 2013-04-16 22:00:18 UTC (rev 1895) @@ -15,20 +15,24 @@ #include "../soundlib/SoundFilePlayConfig.h" -#define REAL float #define MAX_EQ_BANDS 6 -#pragma pack(push, 4) -typedef struct _EQBANDSTRUCT +typedef struct ALIGN(4) _EQBANDSTRUCT { - REAL a0, a1, a2, b1, b2; - REAL x1, x2, y1, y2; - REAL Gain, CenterFrequency; - BOOL bEnable; -} EQBANDSTRUCT, *PEQBANDSTRUCT; -#pragma pack(pop) + float32 a0; + float32 a1; + float32 a2; + float32 b1; + float32 b2; + float32 x1; + float32 x2; + float32 y1; + float32 y2; + float32 Gain; + float32 CenterFrequency; + bool bEnable; +} EQBANDSTRUCT; - //======= class CEQ //======= Modified: trunk/OpenMPT/soundlib/Dlsbank.cpp =================================================================== --- trunk/OpenMPT/soundlib/Dlsbank.cpp 2013-04-16 21:24:09 UTC (rev 1894) +++ trunk/OpenMPT/soundlib/Dlsbank.cpp 2013-04-16 22:00:18 UTC (rev 1895) @@ -108,7 +108,9 @@ #define ART_DEFAULTPAN MAKE_ART (CONN_SRC_NONE, CONN_SRC_NONE, CONN_DST_PAN) +#ifdef NEEDS_PRAGMA_PACK #pragma pack(push, 1) +#endif ////////////////////////////////////////////////////////// // DLS IFF Chunk IDs @@ -134,47 +136,59 @@ ////////////////////////////////////////////////////////// // DLS Structures definitions -typedef struct IFFCHUNK +typedef struct PACKED IFFCHUNK { DWORD id; DWORD len; } IFFCHUNK, *LPIFFCHUNK; -typedef struct RIFFCHUNKID +STATIC_ASSERT(sizeof(IFFCHUNK) == 8); + +typedef struct PACKED RIFFCHUNKID { DWORD id_RIFF; DWORD riff_len; DWORD id_DLS; } RIFFCHUNKID; -typedef struct LISTCHUNK +STATIC_ASSERT(sizeof(RIFFCHUNKID) == 12); + +typedef struct PACKED LISTCHUNK { DWORD id; DWORD len; DWORD listid; } LISTCHUNK; -typedef struct DLSRGNRANGE +STATIC_ASSERT(sizeof(LISTCHUNK) == 12); + +typedef struct PACKED DLSRGNRANGE { WORD usLow; WORD usHigh; } DLSRGNRANGE; -typedef struct COLHCHUNK +STATIC_ASSERT(sizeof(DLSRGNRANGE) == 4); + +typedef struct PACKED COLHCHUNK { DWORD id; DWORD len; DWORD ulInstruments; } COLHCHUNK; -typedef struct VERSCHUNK +STATIC_ASSERT(sizeof(COLHCHUNK) == 12); + +typedef struct PACKED VERSCHUNK { DWORD id; DWORD len; WORD version[4]; } VERSCHUNK; -typedef struct PTBLCHUNK +STATIC_ASSERT(sizeof(VERSCHUNK) == 16); + +typedef struct PACKED PTBLCHUNK { DWORD id; DWORD len; @@ -183,7 +197,9 @@ DWORD ulOffsets[1]; } PTBLCHUNK; -typedef struct INSHCHUNK +STATIC_ASSERT(sizeof(PTBLCHUNK) == 20); + +typedef struct PACKED INSHCHUNK { DWORD id; DWORD len; @@ -192,7 +208,9 @@ DWORD ulInstrument; } INSHCHUNK; -typedef struct RGNHCHUNK +STATIC_ASSERT(sizeof(INSHCHUNK) == 20); + +typedef struct PACKED RGNHCHUNK { DWORD id; DWORD len; @@ -202,7 +220,9 @@ WORD usKeyGroup; } RGNHCHUNK; -typedef struct WLNKCHUNK +STATIC_ASSERT(sizeof(RGNHCHUNK) == 20); + +typedef struct PACKED WLNKCHUNK { DWORD id; DWORD len; @@ -212,7 +232,9 @@ DWORD ulTableIndex; } WLNKCHUNK; -typedef struct ART1CHUNK +STATIC_ASSERT(sizeof(WLNKCHUNK) == 20); + +typedef struct PACKED ART1CHUNK { DWORD id; DWORD len; @@ -220,7 +242,9 @@ DWORD cConnectionBlocks; } ART1CHUNK; -typedef struct CONNECTIONBLOCK +STATIC_ASSERT(sizeof(ART1CHUNK) == 16); + +typedef struct PACKED CONNECTIONBLOCK { WORD usSource; WORD usControl; @@ -229,19 +253,23 @@ LONG lScale; } CONNECTIONBLOCK; -typedef struct WSMPCHUNK +STATIC_ASSERT(sizeof(CONNECTIONBLOCK) == 12); + +typedef struct PACKED WSMPCHUNK { DWORD id; DWORD len; DWORD cbSize; WORD usUnityNote; - signed short sFineTune; + SHORT sFineTune; LONG lAttenuation; DWORD fulOptions; DWORD cSampleLoops; } WSMPCHUNK; -typedef struct WSMPSAMPLELOOP +STATIC_ASSERT(sizeof(WSMPCHUNK) == 28); + +typedef struct PACKED WSMPSAMPLELOOP { DWORD cbSize; DWORD ulLoopType; @@ -249,7 +277,9 @@ DWORD ulLoopLength; } WSMPSAMPLELOOP; +STATIC_ASSERT(sizeof(WSMPSAMPLELOOP) == 16); + ///////////////////////////////////////////////////////////////////// // SF2 IFF Chunk IDs @@ -285,7 +315,7 @@ ///////////////////////////////////////////////////////////////////// // SF2 Structures Definitions -typedef struct SFPRESETHEADER +typedef struct PACKED SFPRESETHEADER { CHAR achPresetName[20]; WORD wPreset; @@ -296,37 +326,49 @@ DWORD dwMorphology; } SFPRESETHEADER; -typedef struct SFPRESETBAG +STATIC_ASSERT(sizeof(SFPRESETHEADER) == 38); + +typedef struct PACKED SFPRESETBAG { WORD wGenNdx; WORD wModNdx; } SFPRESETBAG; -typedef struct SFGENLIST +STATIC_ASSERT(sizeof(SFPRESETBAG) == 4); + +typedef struct PACKED SFGENLIST { WORD sfGenOper; WORD genAmount; } SFGENLIST; -typedef struct SFINST +STATIC_ASSERT(sizeof(SFGENLIST) == 4); + +typedef struct PACKED SFINST { CHAR achInstName[20]; WORD wInstBagNdx; } SFINST; -typedef struct SFINSTBAG +STATIC_ASSERT(sizeof(SFINST) == 22); + +typedef struct PACKED SFINSTBAG { WORD wGenNdx; WORD wModNdx; } SFINSTBAG; -typedef struct SFINSTGENLIST +STATIC_ASSERT(sizeof(SFINSTBAG) == 4); + +typedef struct PACKED SFINSTGENLIST { WORD sfGenOper; WORD genAmount; } SFINSTGENLIST; -typedef struct SFSAMPLE +STATIC_ASSERT(sizeof(SFINSTGENLIST) == 4); + +typedef struct PACKED SFSAMPLE { CHAR achSampleName[20]; DWORD dwStart; @@ -340,7 +382,16 @@ WORD sfSampleType; } SFSAMPLE; +STATIC_ASSERT(sizeof(SFSAMPLE) == 46); +// End of structures definitions +///////////////////////////////////////////////////////////////////// + +#ifdef NEEDS_PRAGMA_PACK +#pragma pack(pop) +#endif + + typedef struct SF2LOADERINFO { UINT nPresetBags; @@ -356,12 +407,7 @@ } SF2LOADERINFO; -// End of structures definitions ///////////////////////////////////////////////////////////////////// - -#pragma pack(pop) - -///////////////////////////////////////////////////////////////////// // Unit conversion LONG CDLSBank::DLS32BitTimeCentsToMilliseconds(LONG lTimeCents) Modified: trunk/OpenMPT/soundlib/Dlsbank.h =================================================================== --- trunk/OpenMPT/soundlib/Dlsbank.h 2013-04-16 21:24:09 UTC (rev 1894) +++ trunk/OpenMPT/soundlib/Dlsbank.h 2013-04-16 22:00:18 UTC (rev 1895) @@ -14,7 +14,9 @@ class CSoundFile; #include "Snd_defs.h" +#ifdef NEEDS_PRAGMA_PACK #pragma pack(push, 1) +#endif #define DLSMAXREGIONS 128 #define DLSMAXENVELOPES 2048 @@ -27,8 +29,7 @@ #define DLSREGION_SELFNONEXCLUSIVE 0x80 #define DLSREGION_SUSTAINLOOP 0x100 - -typedef struct DLSREGION +typedef struct PACKED DLSREGION { DWORD ulLoopStart; DWORD ulLoopEnd; @@ -42,7 +43,9 @@ BYTE uUnityNote; } DLSREGION; -typedef struct DLSENVELOPE +STATIC_ASSERT(sizeof(DLSREGION) == 21); + +typedef struct PACKED DLSENVELOPE { // Volume Envelope WORD wVolAttack; // Attack Time: 0-1000, 1 = 20ms (1/50s) -> [0-20s] @@ -53,10 +56,12 @@ BYTE nDefPan; } DLSENVELOPE; +STATIC_ASSERT(sizeof(DLSENVELOPE) == 8); + // Special Bank bits #define F_INSTRUMENT_DRUMS 0x80000000 -typedef struct DLSINSTRUMENT +typedef struct PACKED DLSINSTRUMENT { DWORD ulBank, ulInstrument; UINT nRegions, nMelodicEnv; @@ -66,7 +71,9 @@ WORD wPresetBagNdx, wPresetBagNum; } DLSINSTRUMENT; -typedef struct DLSSAMPLEEX +STATIC_ASSERT(sizeof(DLSINSTRUMENT) == 2740); + +typedef struct PACKED DLSSAMPLEEX { CHAR szName[20]; DWORD dwLen; @@ -77,6 +84,8 @@ CHAR chPitchCorrection; } DLSSAMPLEEX; +STATIC_ASSERT(sizeof(DLSSAMPLEEX) == 38); + #pragma pack(pop) #define SOUNDBANK_TYPE_INVALID 0 Modified: trunk/OpenMPT/soundlib/ITTools.h =================================================================== --- trunk/OpenMPT/soundlib/ITTools.h 2013-04-16 21:24:09 UTC (rev 1894) +++ trunk/OpenMPT/soundlib/ITTools.h 2013-04-16 22:00:18 UTC (rev 1895) @@ -14,9 +14,11 @@ #include "../soundlib/ModSample.h" #include "../soundlib/SampleIO.h" +#ifdef NEEDS_PRAGMA_PACK #pragma pack(push, 1) +#endif -struct ITFileHeader +struct PACKED ITFileHeader { // Magic Bytes enum Magic @@ -81,7 +83,7 @@ STATIC_ASSERT(sizeof(ITFileHeader) == 192); -struct ITEnvelope +struct PACKED ITEnvelope { // Envelope Flags enum ITEnvelopeFlags @@ -112,7 +114,7 @@ // Old Impulse Instrument Format (cmwt < 0x200) -struct ITOldInstrument +struct PACKED ITOldInstrument { // Magic Bytes enum Magic @@ -158,7 +160,7 @@ // Impulse Instrument Format -struct ITInstrument +struct PACKED ITInstrument { // Magic Bytes enum Magic @@ -213,7 +215,7 @@ // MPT IT Instrument Extension -struct ITInstrumentEx +struct PACKED ITInstrumentEx { enum Magic { @@ -236,7 +238,7 @@ // IT Sample Format -struct ITSample +struct PACKED ITSample { // Magic Bytes enum Magic @@ -305,7 +307,7 @@ #endif // MODPLUG_TRACKER // IT Header extension: Save history -struct ITHistoryStruct +struct PACKED ITHistoryStruct { uint16 fatdate; // DOS / FAT date when the file was opened / created in the editor. For details, read http://msdn.microsoft.com/en-us/library/ms724247(VS.85).aspx uint16 fattime; // DOS / FAT time when the file was opened / created in the editor. @@ -327,7 +329,9 @@ STATIC_ASSERT(sizeof(ITHistoryStruct) == 8); +#ifdef NEEDS_PRAGMA_PACK #pragma pack(pop) +#endif enum IT_ReaderBitMasks { Modified: trunk/OpenMPT/soundlib/LOAD_AMF.CPP =================================================================== --- trunk/OpenMPT/soundlib/LOAD_AMF.CPP 2013-04-16 21:24:09 UTC (rev 1894) +++ trunk/OpenMPT/soundlib/LOAD_AMF.CPP 2013-04-16 22:00:18 UTC (rev 1895) @@ -15,10 +15,12 @@ #include "Loaders.h" +#ifdef NEEDS_PRAGMA_PACK #pragma pack(push, 1) +#endif // ASYLUM AMF File Header -struct AsylumFileHeader +struct PACKED AsylumFileHeader { char signature[32]; uint8 defaultSpeed; @@ -33,7 +35,7 @@ // ASYLUM AMF Sample Header -struct AsylumSampleHeader +struct PACKED AsylumSampleHeader { char name[22]; uint8 finetune; @@ -71,7 +73,31 @@ STATIC_ASSERT(sizeof(AsylumSampleHeader) == 37); + +// DSMI AMF File Header +struct PACKED AMFFileHeader +{ + char amf[3]; + uint8 version; + char title[32]; + uint8 numSamples; + uint8 numOrders; + uint16 numTracks; + uint8 numChannels; + + // Convert all multi-byte numeric values to current platform's endianness or vice versa. + void ConvertEndianness() + { + SwapBytesLE(numTracks); + } +}; + +STATIC_ASSERT(sizeof(AMFFileHeader) == 41); + + +#ifdef NEEDS_PRAGMA_PACK #pragma pack(pop) +#endif bool CSoundFile::ReadAMF_Asylum(FileReader &file) @@ -159,31 +185,6 @@ } -#pragma pack(push, 1) - -// DSMI AMF File Header -struct AMFFileHeader -{ - char amf[3]; - uint8 version; - char title[32]; - uint8 numSamples; - uint8 numOrders; - uint16 numTracks; - uint8 numChannels; - - // Convert all multi-byte numeric values to current platform's endianness or vice versa. - void ConvertEndianness() - { - SwapBytesLE(numTracks); - } -}; - -STATIC_ASSERT(sizeof(AMFFileHeader) == 41); - -#pragma pack(pop) - - // Read a single AMF track (channel) into a pattern. void AMFReadPattern(CPattern &pattern, CHANNELINDEX chn, FileReader &fileChunk) //----------------------------------------------------------------------------- Modified: trunk/OpenMPT/soundlib/LOAD_DBM.CPP =================================================================== --- trunk/OpenMPT/soundlib/LOAD_DBM.CPP 2013-04-16 21:24:09 UTC (rev 1894) +++ trunk/OpenMPT/soundlib/LOAD_DBM.CPP 2013-04-16 22:00:18 UTC (rev 1895) @@ -24,9 +24,11 @@ #define DBM_ID_PATT 0x54544150 #define DBM_ID_SMPL 0x4c504d53 +#ifdef NEEDS_PRAGMA_PACK #pragma pack(push, 1) +#endif -struct DBMFileHeader +struct PACKED DBMFileHeader { uint32 dbm_id; // "DBM0" = 0x304d4244 uint16 trkver; // Tracker version: 02.15 @@ -48,7 +50,9 @@ // uint16 orderlist[0]; // orderlist[orders] in words }; -struct DBMInstrument +STATIC_ASSERT(sizeof(DBMFileHeader) == 132); + +struct PACKED DBMInstrument { char name[30]; uint16 sampleno; @@ -60,7 +64,9 @@ uint16 flags; }; -struct DBMEnvelope +STATIC_ASSERT(sizeof(DBMInstrument) == 50); + +struct PACKED DBMEnvelope { uint16 instrument; uint8 flags; @@ -72,21 +78,29 @@ uint16 volenv[2 * 32]; }; -struct DBMPattern +STATIC_ASSERT(sizeof(DBMEnvelope) == 136); + +struct PACKED DBMPattern { uint16 rows; uint32 packedsize; uint8 patterndata[2]; // [packedsize] }; -struct DBMSample +STATIC_ASSERT(sizeof(DBMPattern) == 8); + +struct PACKED DBMSample { uint32 flags; uint32 samplesize; uint8 sampledata[2]; // [samplesize] }; +STATIC_ASSERT(sizeof(DBMSample) == 10); + +#ifdef NEEDS_PRAGMA_PACK #pragma pack(pop) +#endif static const ModCommand::COMMAND dbmEffects[23] = Modified: trunk/OpenMPT/soundlib/LOAD_DMF.CPP =================================================================== --- trunk/OpenMPT/soundlib/LOAD_DMF.CPP 2013-04-16 21:24:09 UTC (rev 1894) +++ trunk/OpenMPT/soundlib/LOAD_DMF.CPP 2013-04-16 22:00:18 UTC (rev 1895) @@ -20,10 +20,12 @@ #include "../mptrack/Moddoc.h" #endif // MODPLUG_TRACKER +#ifdef NEEDS_PRAGMA_PACK #pragma pack(push, 1) +#endif // DMF header -struct DMFFileHeader +struct PACKED DMFFileHeader { char signature[4]; // "DDMF" uint8 version; // 1 - 7 are beta versions, 8 is the official thing, 10 is xtracker32 @@ -35,7 +37,9 @@ uint8 creationYear; }; -struct DMFChunk +STATIC_ASSERT(sizeof(DMFFileHeader) == 66); + +struct PACKED DMFChunk { // 32-Bit chunk identifiers enum ChunkIdentifiers @@ -68,8 +72,10 @@ } }; +STATIC_ASSERT(sizeof(DMFChunk) == 8); + // Order list -struct DMFSequence +struct PACKED DMFSequence { uint16 loopStart; uint16 loopEnd; @@ -83,8 +89,10 @@ } }; +STATIC_ASSERT(sizeof(DMFSequence) == 4); + // Pattern header (global) -struct DMFPatterns +struct PACKED DMFPatterns { uint16 numPatterns; // 1..1024 patterns uint8 numTracks; // 1..32 channels @@ -96,8 +104,10 @@ } }; +STATIC_ASSERT(sizeof(DMFPatterns) == 3); + // Pattern header (for each pattern) -struct DMFPatternHeader +struct PACKED DMFPatternHeader { uint8 numTracks; // 1..32 channels uint8 beat; // [hi|lo] -> hi = rows per beat, lo = reserved @@ -113,8 +123,10 @@ } }; +STATIC_ASSERT(sizeof(DMFPatternHeader) == 8); + // Sample header -struct DMFSampleHeader +struct PACKED DMFSampleHeader { enum SampleFlags { @@ -181,14 +193,20 @@ } }; +STATIC_ASSERT(sizeof(DMFSampleHeader) == 16); + // Sample header tail (between head and tail, there might be the library name of the sample, depending on the DMF version) -struct DMFSampleHeaderTail +struct PACKED DMFSampleHeaderTail { uint16 filler; uint32 crc32; }; +STATIC_ASSERT(sizeof(DMFSampleHeaderTail) == 6); + +#ifdef NEEDS_PRAGMA_PACK #pragma pack(pop) +#endif // Pattern translation memory struct DMFPatternSettings Modified: trunk/OpenMPT/soundlib/LOAD_DSM.CPP =================================================================== --- trunk/OpenMPT/soundlib/LOAD_DSM.CPP 2013-04-16 21:24:09 UTC (rev 1894) +++ trunk/OpenMPT/soundlib/LOAD_DSM.CPP 2013-04-16 22:00:18 UTC (rev 1895) @@ -12,7 +12,9 @@ #include "stdafx.h" #include "Loaders.h" +#ifdef NEEDS_PRAGMA_PACK #pragma pack(push, 1) +#endif #define DSMID_RIFF 0x46464952 // "RIFF" #define DSMID_DSMF 0x464d5344 // "DSMF" @@ -21,13 +23,15 @@ #define DSMID_PATT 0x54544150 // "PATT" -typedef struct DSMNOTE +typedef struct PACKED DSMNOTE { BYTE note,ins,vol,cmd,inf; } DSMNOTE; +STATIC_ASSERT(sizeof(DSMNOTE) == 5); -typedef struct DSMSAMPLE + +typedef struct PACKED DSMSAMPLE { DWORD id_INST; DWORD inst_len; @@ -44,8 +48,10 @@ CHAR samplename[28]; } DSMSAMPLE; +STATIC_ASSERT(sizeof(DSMSAMPLE) == 72); -typedef struct DSMFILEHEADER + +typedef struct PACKED DSMFILEHEADER { DWORD id_RIFF; // "RIFF" DWORD riff_len; @@ -54,8 +60,10 @@ DWORD song_len; } DSMFILEHEADER; +STATIC_ASSERT(sizeof(DSMFILEHEADER) == 20); -typedef struct DSMSONG + +typedef struct PACKED DSMSONG { CHAR songname[28]; WORD reserved1; @@ -73,7 +81,10 @@ BYTE orders[128]; } DSMSONG; -typedef struct DSMPATT +STATIC_ASSERT(sizeof(DSMSONG) == 192); + + +typedef struct PACKED DSMPATT { DWORD id_PATT; DWORD patt_len; @@ -81,7 +92,12 @@ BYTE dummy2; } DSMPATT; +STATIC_ASSERT(sizeof(DSMPATT) == 10); + + +#ifdef NEEDS_PRAGMA_PACK #pragma pack(pop) +#endif bool CSoundFile::ReadDSM(const LPCBYTE lpStream, const DWORD dwMemLength) Modified: trunk/OpenMPT/soundlib/Load_669.cpp =================================================================== --- trunk/OpenMPT/soundlib/Load_669.cpp 2013-04-16 21:24:09 UTC (rev 1894) +++ trunk/OpenMPT/soundlib/Load_669.cpp 2013-04-16 22:00:18 UTC (rev 1895) @@ -13,9 +13,11 @@ #include "stdafx.h" #include "Loaders.h" +#ifdef NEEDS_PRAGMA_PACK #pragma pack(push, 1) +#endif -struct _669FileHeader +struct PACKED _669FileHeader { enum MagicBytes { @@ -42,7 +44,7 @@ STATIC_ASSERT(sizeof(_669FileHeader) == 497); -struct _669Sample +struct PACKED _669Sample { char filename[13]; uint32 length; @@ -80,7 +82,9 @@ STATIC_ASSERT(sizeof(_669Sample) == 25); +#ifdef USER_PRAGMA_PACK #pragma pack(pop) +#endif bool CSoundFile::Read669(FileReader &file) Modified: trunk/OpenMPT/soundlib/Load_ams.cpp =================================================================== --- trunk/OpenMPT/soundlib/Load_ams.cpp 2013-04-16 21:24:09 UTC (rev 1894) +++ trunk/OpenMPT/soundlib/Load_ams.cpp 2013-04-16 22:00:18 UTC (rev 1895) @@ -283,10 +283,12 @@ ///////////////////////////////////////////////////////////////////// // AMS (Extreme's Tracker) 1.x loader +#ifdef NEEDS_PRAGMA_PACK #pragma pack(push, 1) +#endif // AMS File Header -struct AMSFileHeader +struct PACKED AMSFileHeader { uint8 versionLow; uint8 versionHigh; @@ -306,9 +308,11 @@ } }; +STATIC_ASSERT(sizeof(AMSFileHeader) == 11); + // AMS Sample Header -struct AMSSampleHeader +struct PACKED AMSSampleHeader { enum SampleFlags { @@ -365,8 +369,12 @@ } }; +STATIC_ASSERT(sizeof(AMSSampleHeader) == 17); + +#ifdef NEEDS_PRAGMA_PACK #pragma pack(pop) +#endif bool CSoundFile::ReadAMS(FileReader &file) @@ -490,10 +498,13 @@ ///////////////////////////////////////////////////////////////////// // AMS (Velvet Studio) 2.1 / 2.2 loader -#pragma pack(1) +#ifdef NEEDS_PRAGMA_PACK +#pragma pack(push, 1) +#endif + // AMS2 File Header -struct AMS2FileHeader +struct PACKED AMS2FileHeader { enum FileFlags { @@ -515,9 +526,11 @@ }; }; +STATIC_ASSERT(sizeof(AMS2FileHeader) == 7); + // AMS2 Instument Envelope -struct AMS2Envelope +struct PACKED AMS2Envelope { uint8 speed; // Envelope speed uint8 sustainPoint; // Envelope sustain point @@ -557,9 +570,11 @@ } }; +STATIC_ASSERT(sizeof(AMS2Envelope) == 5); + // AMS2 Instrument Data -struct AMS2Instrument +struct PACKED AMS2Instrument { enum EnvelopeFlags { @@ -607,9 +622,11 @@ }; +STATIC_ASSERT(sizeof(AMS2Instrument) == 5); + // AMS2 Sample Header -struct AMS2SampleHeader +struct PACKED AMS2SampleHeader { enum SampleFlags { @@ -679,9 +696,11 @@ } }; +STATIC_ASSERT(sizeof(AMS2SampleHeader) == 20); + // AMS2 Song Description Header -struct AMS2Description +struct PACKED AMS2Description { uint32 packedLen; // Including header uint32 unpackedLen; @@ -697,10 +716,14 @@ } }; +STATIC_ASSERT(sizeof(AMS2Description) == 11); -#pragma pack() +#ifdef NEEDS_PRAGMA_PACK +#pragma pack(pop) +#endif + bool CSoundFile::ReadAMS2(FileReader &file) //----------------------------------------- { Modified: trunk/OpenMPT/soundlib/Load_far.cpp =================================================================== --- trunk/OpenMPT/soundlib/Load_far.cpp 2013-04-16 21:24:09 UTC (rev 1894) +++ trunk/OpenMPT/soundlib/Load_far.cpp 2013-04-16 22:00:18 UTC (rev 1895) @@ -12,10 +12,12 @@ #include "Loaders.h" +#ifdef NEEDS_PRAGMA_PACK #pragma pack(push, 1) +#endif // FAR File Header -struct FARFileHeader +struct PACKED FARFileHeader { uint8 magic[4]; char songName[40]; @@ -40,7 +42,7 @@ STATIC_ASSERT(sizeof(FARFileHeader) == 98); -struct FAROrderHeader +struct PACKED FAROrderHeader { uint8 orders[256]; uint8 numPatterns; // supposed to be "number of patterns stored in the file"; apparently that's wrong @@ -62,7 +64,7 @@ // FAR Sample header -struct FARSampleHeader +struct PACKED FARSampleHeader { // Sample flags enum SampleFlags @@ -125,7 +127,9 @@ STATIC_ASSERT(sizeof(FARSampleHeader) == 48); +#ifdef NEEDS_PRAGMA_PACK #pragma pack(pop) +#endif bool CSoundFile::ReadFAR(FileReader &file) Modified: trunk/OpenMPT/soundlib/Load_gdm.cpp =================================================================== --- trunk/OpenMPT/soundlib/Load_gdm.cpp 2013-04-16 21:24:09 UTC (rev 1894) +++ trunk/OpenMPT/soundlib/Load_gdm.cpp 2013-04-16 22:00:18 UTC (rev 1895) @@ -16,10 +16,13 @@ #include "stdafx.h" #include "Loaders.h" +#ifdef NEEDS_PRAGMA_PACK #pragma pack(push, 1) +#endif + // GDM File Header -struct GDMFileHeader +struct PACKED GDMFileHeader { // Header magic bytes enum HeaderMagic @@ -82,8 +85,11 @@ } }; +STATIC_ASSERT(sizeof(GDMFileHeader) == 157); + + // GDM Sample Header -struct GDMSampleHeader +struct PACKED GDMSampleHeader { enum SampleFlags { @@ -116,8 +122,14 @@ } }; +STATIC_ASSERT(sizeof(GDMSampleHeader) == 62); + + +#ifdef NEEDS_PRAGMA_PACK #pragma pack(pop) +#endif + bool CSoundFile::ReadGDM(FileReader &file) //---------------------------------------- { Modified: trunk/OpenMPT/soundlib/Load_imf.cpp =================================================================== --- trunk/OpenMPT/soundlib/Load_imf.cpp 2013-04-16 21:24:09 UTC (rev 1894) +++ trunk/OpenMPT/soundlib/Load_imf.cpp 2013-04-16 22:00:18 UTC (rev 1895) @@ -15,9 +15,11 @@ #include "../mptrack/moddoc.h" #endif // MODPLUG_TRACKER +#ifdef NEEDS_PRAGMA_PACK #pragma pack(push, 1) +#endif -struct IMFChannel +struct PACKED IMFChannel { char name[12]; // Channel name (ASCIIZ-String, max 11 chars) uint8 chorus; // Default chorus @@ -26,7 +28,9 @@ uint8 status; // Channel status: 0 = enabled, 1 = mute, 2 = disabled (ignore effects!) }; -struct IMFFileHeader +STATIC_ASSERT(sizeof(IMFChannel) == 16); + +struct PACKED IMFFileHeader { enum SongFlags { @@ -59,7 +63,9 @@ } }; -struct IMFEnvelope +STATIC_ASSERT(sizeof(IMFFileHeader) == 832); + +struct PACKED IMFEnvelope { enum EnvFlags { @@ -76,13 +82,17 @@ uint8 unused[3]; }; -struct IMFEnvNode +STATIC_ASSERT(sizeof(IMFEnvelope) == 8); + +struct PACKED IMFEnvNode { uint16 tick; uint16 value; }; -struct IMFInstrument +STATIC_ASSERT(sizeof(IMFEnvNode) == 4); + +struct PACKED IMFInstrument { enum EnvTypes { @@ -166,7 +176,9 @@ } }; -struct IMFSample +STATIC_ASSERT(sizeof(IMFInstrument) == 384); + +struct PACKED IMFSample { enum SampleFlags { @@ -228,7 +240,11 @@ } }; +STATIC_ASSERT(sizeof(IMFSample) == 64); + +#ifdef NEEDS_PRAGMA_PACK #pragma pack(pop) +#endif static const uint8 imfEffects[] = { Modified: trunk/OpenMPT/soundlib/Load_it.cpp =================================================================== --- trunk/OpenMPT/soundlib/Load_it.cpp 2013-04-16 21:24:09 UTC (rev 1894) +++ trunk/OpenMPT/soundlib/Load_it.cpp 2013-04-16 22:00:18 UTC (rev 1895) @@ -1135,7 +1135,7 @@ { itHeader.flags |= ITFileHeader::reqEmbeddedMIDIConfig; itHeader.special |= ITFileHeader::embedMIDIConfiguration; - dwExtra += sizeof(MIDIMacroConfig); + dwExtra += sizeof(MIDIMacroConfigData); } // Pattern Names @@ -1180,7 +1180,7 @@ // Writing midi cfg if(itHeader.flags & ITFileHeader::reqEmbeddedMIDIConfig) { - fwrite(&m_MidiCfg, 1, sizeof(MIDIMacroConfig), f); + fwrite(static_cast<MIDIMacroConfigData*>(&m_MidiCfg), 1, sizeof(MIDIMacroConfigData), f); } // Writing pattern names Modified: trunk/OpenMPT/soundlib/Load_itp.cpp =================================================================== --- trunk/OpenMPT/soundlib/Load_itp.cpp 2013-04-16 21:24:09 UTC (rev 1894) +++ trunk/OpenMPT/soundlib/Load_itp.cpp 2013-04-16 22:00:18 UTC (rev 1895) @@ -351,7 +351,7 @@ // Song midi config // midi cfg data length - id = m_SongFlags[SONG_EMBEDMIDICFG] ? sizeof(MIDIMacroConfig) : 0; + id = m_SongFlags[SONG_EMBEDMIDICFG] ? sizeof(MIDIMacroConfigData) : 0; fwrite(&id, 1, sizeof(id), f); // midi cfg Modified: trunk/OpenMPT/soundlib/Load_mdl.cpp =================================================================== --- trunk/OpenMPT/soundlib/Load_mdl.cpp 2013-04-16 21:24:09 UTC (rev 1894) +++ trunk/OpenMPT/soundlib/Load_mdl.cpp 2013-04-16 22:00:18 UTC (rev 1895) @@ -16,16 +16,20 @@ #pragma warning(disable:4244) //"conversion from 'type1' to 'type2', possible loss of data" +#ifdef NEEDS_PRAGMA_PACK #pragma pack(push, 1) +#endif -struct MDLFileHeader +struct PACKED MDLFileHeader { DWORD id; // "DMDL" = 0x4C444D44 BYTE version; }; +STATIC_ASSERT(sizeof(MDLFileHeader) == 5); -struct MDLInfoBlock + +struct PACKED MDLInfoBlock { char songname[32]; char composer[20]; @@ -38,8 +42,10 @@ uint8 seq[256]; }; +STATIC_ASSERT(sizeof(MDLInfoBlock) == 347); -struct MDLPatternHeader + +struct PACKED MDLPatternHeader { uint8 channels; uint8 lastrow; // nrows = lastrow+1 @@ -47,16 +53,20 @@ uint16 data[1]; }; +STATIC_ASSERT(sizeof(MDLPatternHeader) == 20); -struct MDLSampleHeaderCommon + +struct PACKED MDLSampleHeaderCommon { uint8 sampleIndex; char name[32]; char filename[8]; }; +STATIC_ASSERT(sizeof(MDLSampleHeaderCommon) == 41); -struct MDLSampleHeader + +struct PACKED MDLSampleHeader { MDLSampleHeaderCommon info; uint32 c4Speed; @@ -70,7 +80,7 @@ STATIC_ASSERT(sizeof(MDLSampleHeader) == 59); -struct MDLSampleHeaderv0 +struct PACKED MDLSampleHeaderv0 { MDLSampleHeaderCommon info; uint16 c4Speed; @@ -84,7 +94,9 @@ STATIC_ASSERT(sizeof(MDLSampleHeaderv0) == 57); +#ifdef NEEDS_PRAGMA_PACK #pragma pack(pop) +#endif void ConvertMDLCommand(ModCommand *m, UINT eff, UINT data) Modified: trunk/OpenMPT/soundlib/Load_med.cpp =================================================================== --- trunk/OpenMPT/soundlib/Load_med.cpp 2013-04-16 21:24:09 UTC (rev 1894) +++ trunk/OpenMPT/soundlib/Load_med.cpp 2013-04-16 22:00:18 UTC (rev 1895) @@ -60,9 +60,12 @@ #define MMDTAG_FX_GROUPNAME (MMDTAG_PTR|5) // the Global Effects group shouldn't have name saved! #define MMDTAG_FX_GRPNAMELEN 6 // namelen includes zero term. +#ifdef NEEDS_PRAGMA_PACK #pragma pack(push, 1) +#endif -typedef struct tagMEDMODULEHEADER + +typedef struct PACKED tagMEDMODULEHEADER { DWORD id; // MMD1-MMD3 DWORD modlen; // Size of file @@ -84,8 +87,10 @@ BYTE extra_songs; // # of songs - 1 } MEDMODULEHEADER; +STATIC_ASSERT(sizeof(MEDMODULEHEADER) == 52); -typedef struct tagMMD0SAMPLE + +typedef struct PACKED tagMMD0SAMPLE { WORD rep, replen; BYTE midich; @@ -94,9 +99,11 @@ signed char strans; } MMD0SAMPLE; +STATIC_ASSERT(sizeof(MMD0SAMPLE) == 8); + // Sample header is immediately followed by sample data... -typedef struct tagMMDSAMPLEHEADER +typedef struct PACKED tagMMDSAMPLEHEADER { DWORD length; // length of *one* *unpacked* channel in *bytes* WORD type; @@ -122,9 +129,11 @@ BYTE SampleData[1]; // Sample Data } MMDSAMPLEHEADER; +STATIC_ASSERT(sizeof(MMDSAMPLEHEADER) == 21); + // MMD0/MMD1 song header -typedef struct tagMMD0SONGHEADER +typedef struct PACKED tagMMD0SONGHEADER { MMD0SAMPLE sample[63]; WORD numblocks; // # of blocks @@ -140,9 +149,11 @@ BYTE numsamples; // # of samples (max=63) } MMD0SONGHEADER; +STATIC_ASSERT(sizeof(MMD0SONGHEADER) == 788); + // MMD2/MMD3 song header -typedef struct tagMMD2SONGHEADER +typedef struct PACKED tagMMD2SONGHEADER { MMD0SAMPLE sample[63]; WORD numblocks; // # of blocks @@ -171,6 +182,9 @@ BYTE numsamples; // # of samples (max 63) } MMD2SONGHEADER; +STATIC_ASSERT(sizeof(MMD2SONGHEADER) == 788); + + // For MMD0 the note information is held in 3 bytes, byte0, byte1, byte2. For reference we // number the bits in each byte 0..7, where 0 is the low bit. // The note is held as bits 5..0 of byte0 @@ -178,13 +192,15 @@ // The command number is bits 3,2,1,0 of byte1, command data is in byte2: // For command 0, byte2 represents the second data byte, otherwise byte2 // represents the first data byte. -typedef struct tagMMD0BLOCK +typedef struct PACKED tagMMD0BLOCK { BYTE numtracks; BYTE lines; // File value is 1 less than actual, so 0 -> 1 line } MMD0BLOCK; // BYTE data[lines+1][tracks][3]; +STATIC_ASSERT(sizeof(MMD0BLOCK) == 2); + // For MMD1,MMD2,MMD3 the note information is carried in 4 bytes, byte0, byte1, // byte2 and byte3 // The note is held as byte0 (values above 0x84 are ignored) @@ -192,15 +208,17 @@ // The command number is held as byte2, command data is in byte3 // For commands 0 and 0x19 byte3 represents the second data byte, // otherwise byte2 represents the first data byte. -typedef struct tagMMD1BLOCK +typedef struct PACKED tagMMD1BLOCK { WORD numtracks; // Number of tracks, may be > 64, but then that data is skipped. WORD lines; // Stored value is 1 less than actual, so 0 -> 1 line DWORD info; // Offset of BlockInfo (if 0, no block_info is present) } MMD1BLOCK; +STATIC_ASSERT(sizeof(MMD1BLOCK) == 8); -typedef struct tagMMD1BLOCKINFO + +typedef struct PACKED tagMMD1BLOCKINFO { DWORD hlmask; // Unimplemented - ignore DWORD blockname; // file offset of block name @@ -210,10 +228,12 @@ DWORD reserved[4]; // future expansion } MMD1BLOCKINFO; +STATIC_ASSERT(sizeof(MMD1BLOCKINFO) == 36); + // A set of play sequences is stored as an array of ULONG files offsets // Each offset points to the play sequence itself. -typedef struct tagMMD2PLAYSEQ +typedef struct PACKED tagMMD2PLAYSEQ { CHAR name[32]; DWORD command_offs; // filepos of command table @@ -222,11 +242,13 @@ WORD seq[512]; // skip if > 0x8000 } MMD2PLAYSEQ; +STATIC_ASSERT(sizeof(MMD2PLAYSEQ) == 1066); + // A command table contains commands that effect a particular play sequence // entry. The only commands read in are STOP or POSJUMP, all others are ignored // POSJUMP is presumed to have extra bytes containing a WORD for the position -typedef struct tagMMDCOMMAND +typedef struct PACKED tagMMDCOMMAND { WORD offset; // Offset within current sequence entry BYTE cmdnumber; // STOP (537) or POSJUMP (538) (others skipped) @@ -234,8 +256,10 @@ BYTE extra_bytes[4];// [extra_count]; } MMDCOMMAND; // Last entry has offset == 0xFFFF, cmd_number == 0 and 0 extrabytes +STATIC_ASSERT(sizeof(MMDCOMMAND) == 8); -typedef struct tagMMD0EXP + +typedef struct PACKED tagMMD0EXP { DWORD nextmod; // File offset of next Hdr DWORD exp_smp; // Pointer to extra instrument data @@ -261,7 +285,12 @@ DWORD tag_end; } MMD0EXP; +STATIC_ASSERT(sizeof(MMD0EXP) == 80); + + +#ifdef NEEDS_PRAGMA_PACK #pragma pack(pop) +#endif Modified: trunk/OpenMPT/soundlib/Load_mid.cpp =================================================================== --- trunk/OpenMPT/soundlib/Load_mid.cpp 2013-04-16 21:24:09 UTC (rev 1894) +++ trunk/OpenMPT/soundlib/Load_mid.cpp 2013-04-16 22:00:18 UTC (rev 1895) @@ -31,9 +31,11 @@ //UINT gnMidiImportSpeed = 3; //UINT gnMidiPatternLen = 128; +#ifdef NEEDS_PRAGMA_PACK #pragma pack(push, 1) +#endif -typedef struct MIDIFILEHEADER +typedef struct PACKED MIDIFILEHEADER { DWORD id; // "MThd" = 0x6468544D DWORD len; // 6 @@ -42,13 +44,20 @@ WORD wDivision; // F0 } MIDIFILEHEADER; +STATIC_ASSERT(sizeof(MIDIFILEHEADER) == 14); -typedef struct MIDITRACKHEADER +typedef struct PACKED MIDITRACKHEADER { DWORD id; // "MTrk" = 0x6B72544D DWORD len; } MIDITRACKHEADER; +STATIC_ASSERT(sizeof(MIDITRACKHEADER) == 8); + +#ifdef NEEDS_PRAGMA_PACK +#pragma pack(pop) +#endif + ////////////////////////////////////////////////////////////////////// // Midi Loader Internal Structures @@ -88,10 +97,7 @@ LONG nexteventtime; } MIDITRACK; -#pragma pack(pop) - - extern const LPCSTR szMidiGroupNames[17] = { "Piano", Modified: trunk/OpenMPT/soundlib/Load_mod.cpp =================================================================== --- trunk/OpenMPT/soundlib/Load_mod.cpp 2013-04-16 21:24:09 UTC (rev 1894) +++ trunk/OpenMPT/soundlib/Load_mod.cpp 2013-04-16 22:00:18 UTC (rev 1895) @@ -190,10 +190,13 @@ } +#ifdef NEEDS_PRAGMA_PACK #pragma pack(push, 1) +#endif + // File Header -struct MODFileHeader +struct PACKED MODFileHeader { uint8 numOrders; uint8 restartPos; @@ -204,7 +207,7 @@ // Sample Header -struct MODSampleHeader +struct PACKED MODSampleHeader { char name[22]; uint16 length; @@ -326,7 +329,9 @@ STATIC_ASSERT(sizeof(MODSampleHeader) == 30); +#ifdef NEEDS_PRAGMA_PACK #pragma pack(pop) +#endif // Functor for fixing VBlank MODs and MODs with 7-bit panning Modified: trunk/OpenMPT/soundlib/Load_mt2.cpp =================================================================== --- trunk/OpenMPT/soundlib/Load_mt2.cpp 2013-04-16 21:24:09 UTC (rev 1894) +++ trunk/OpenMPT/soundlib/Load_mt2.cpp 2013-04-16 22:00:18 UTC (rev 1895) @@ -14,9 +14,11 @@ //#define MT2DEBUG +#ifdef NEEDS_PRAGMA_PACK #pragma pack(push, 1) +#endif -typedef struct _MT2FILEHEADER +typedef struct PACKED _MT2FILEHEADER { DWORD dwMT20; // 0x3032544D "MT20" DWORD dwSpecial; @@ -36,13 +38,17 @@ BYTE Orders[256]; } MT2FILEHEADER; -typedef struct _MT2PATTERN +STATIC_ASSERT(sizeof(MT2FILEHEADER) == 382); + +typedef struct PACKED _MT2PATTERN { WORD wLines; DWORD wDataLen; } MT2PATTERN; -typedef struct _MT2COMMAND +STATIC_ASSERT(sizeof(MT2PATTERN) == 6); + +typedef struct PACKED _MT2COMMAND { BYTE note; // 0=nothing, 97=note off BYTE instr; @@ -53,21 +59,27 @@ BYTE fxparam2; } MT2COMMAND; -typedef struct _MT2DRUMSDATA +STATIC_ASSERT(sizeof(MT2COMMAND) == 7); + +typedef struct PACKED _MT2DRUMSDATA { WORD wDrumPatterns; WORD wDrumSamples[8]; BYTE DrumPatternOrder[256]; } MT2DRUMSDATA; -typedef struct _MT2AUTOMATION +STATIC_ASSERT(sizeof(MT2DRUMSDATA) == 274); + +typedef struct PACKED _MT2AUTOMATION { DWORD dwFlags; DWORD dwEffectId; DWORD nEnvPoints; } MT2AUTOMATION; -typedef struct _MT2INSTRUMENT +STATIC_ASSERT(sizeof(MT2AUTOMATION) == 12); + +typedef struct PACKED _MT2INSTRUMENT { CHAR szName[32]; DWORD dwDataLen; @@ -84,7 +96,9 @@ WORD wEnvFlags2; } MT2INSTRUMENT; -typedef struct _MT2ENVELOPE +STATIC_ASSERT(sizeof(MT2INSTRUMENT) == 148); + +typedef struct PACKED _MT2ENVELOPE { BYTE nFlags; BYTE nPoints; @@ -95,7 +109,9 @@ BYTE EnvData[64]; } MT2ENVELOPE; -typedef struct _MT2SYNTH +STATIC_ASSERT(sizeof(MT2ENVELOPE) == 72); + +typedef struct PACKED _MT2SYNTH { BYTE nSynthId; BYTE nFxId; @@ -106,7 +122,9 @@ BYTE bReserved[25]; } MT2SYNTH; -typedef struct _MT2SAMPLE +STATIC_ASSERT(sizeof(MT2SYNTH) == 32); + +typedef struct PACKED _MT2SAMPLE { CHAR szName[32]; DWORD dwDataLen; @@ -124,7 +142,9 @@ WORD wSamplesPerBeat; } MT2SAMPLE; -typedef struct _MT2GROUP +STATIC_ASSERT(sizeof(MT2SAMPLE) == 62); + +typedef struct PACKED _MT2GROUP { BYTE nSmpNo; BYTE nVolume; // 0-128 @@ -132,7 +152,11 @@ BYTE Reserved[5]; } MT2GROUP; +STATIC_ASSERT(sizeof(MT2GROUP) == 8); + +#ifdef NEEDS_PRAGMA_PACK #pragma pack(pop) +#endif static void ConvertMT2Command(CSoundFile *that, ModCommand *m, MT2COMMAND *p) Modified: trunk/OpenMPT/soundlib/Load_mtm.cpp =================================================================== --- trunk/OpenMPT/soundlib/Load_mtm.cpp 2013-04-16 21:24:09 UTC (rev 1894) +++ trunk/OpenMPT/soundlib/Load_mtm.cpp 2013-04-16 22:00:18 UTC (rev 1895) @@ -12,10 +12,12 @@ #include "stdafx.h" #include "Loaders.h" +#ifdef NEEDS_PRAGMA_PACK #pragma pack(push, 1) +#endif // File Header -struct MTMFileHeader +struct PACKED MTMFileHeader { char id[3]; // MTM file marker uint8 version; // Tracker version @@ -42,7 +44,7 @@ // Sample Header -struct MTMSampleHeader +struct PACKED MTMSampleHeader { char samplename[22]; uint32 length; @@ -89,7 +91,10 @@ STATIC_ASSERT(sizeof(MTMSampleHeader) == 37); + +#ifdef NEEDS_PRAGMA_PACK #pragma pack(pop) +#endif bool CSoundFile::ReadMTM(FileReader &file) Modified: trunk/OpenMPT/soundlib/Load_okt.cpp =================================================================== --- trunk/OpenMPT/soundlib/Load_okt.cpp 2013-04-16 21:24:09 UTC (rev 1894) +++ trunk/OpenMPT/soundlib/Load_okt.cpp 2013-04-16 22:00:18 UTC (rev 1895) @@ -12,9 +12,11 @@ #include "stdafx.h" #include "Loaders.h" +#ifdef NEEDS_PRAGMA_PACK #pragma pack(push, 1) +#endif -struct OktIffChunk +struct PACKED OktIffChunk { // IFF chunk names enum ChunkIdentifiers @@ -40,7 +42,9 @@ } }; -struct OktSample +STATIC_ASSERT(sizeof(OktIffChunk) == 8); + +struct PACKED OktSample { char name[20]; uint32 length; // length in bytes @@ -62,7 +66,9 @@ STATIC_ASSERT(sizeof(OktSample) == 32); +#ifdef NEEDS_PRAGMA_PACK #pragma pack(pop) +#endif // Parse the sample header block void ReadOKTSamples(FileReader &chunk, vector<bool> &sample7bit, CSoundFile *pSndFile) Modified: trunk/OpenMPT/soundlib/Load_psm.cpp =================================================================== --- trunk/OpenMPT/soundlib/Load_psm.cpp 2013-04-16 21:24:09 UTC (rev 1894) +++ trunk/OpenMPT/soundlib/Load_psm.cpp 2013-04-16 22:00:18 UTC (rev 1895) @@ -27,7 +27,9 @@ #include "../mptrack/moddoc.h" #endif // MODPLUG_TRACKER +#ifdef NEEDS_PRAGMA_PACK #pragma pack(push, 1) +#endif //////////////////////////////////////////////////////////// // @@ -35,7 +37,7 @@ // // PSM File Header -struct PSMFileHeader +struct PACKED PSMFileHeader { // Magic Bytes enum PSMMagic @@ -57,8 +59,10 @@ } }; +STATIC_ASSERT(sizeof(PSMFileHeader) == 12); + // RIFF-style Chunk -struct PSMChunk +struct PACKED PSMChunk { // 32-Bit chunk identifiers enum ChunkIdentifiers @@ -93,8 +97,10 @@ } }; +STATIC_ASSERT(sizeof(PSMChunk) == 8); + // Song Information -struct PSMSongHeader +struct PACKED PSMSongHeader { char songType[9]; // Mostly "MAINSONG " (But not in Extreme Pinball!) uint8 compression; // 1 - uncompressed @@ -102,8 +108,10 @@ }; +STATIC_ASSERT(sizeof(PSMSongHeader) == 11); + // Regular sample header -struct PSMOldSampleHeader +struct PACKED PSMOldSampleHeader { uint8 flags; char fileName[8]; // Filename of the original module (without extension) @@ -159,9 +167,10 @@ } }; +STATIC_ASSERT(sizeof(PSMOldSampleHeader) == 96); // Sinaria sample header (and possibly other games) -struct PSMNewSampleHeader +struct PACKED PSMNewSampleHeader { uint8 flags; char fileName[8]; // Filename of the original module (without extension) @@ -216,7 +225,12 @@ SampleIO::deltaPCM); } }; + +STATIC_ASSERT(sizeof(PSMNewSampleHeader) == 96); + +#ifdef NEEDS_PRAGMA_PACK #pragma pack(pop) +#endif struct PSMSubSong // For internal use (pattern conversion) @@ -937,9 +951,11 @@ // PSM16 support starts here. // +#ifdef NEEDS_PRAGMA_PACK #pragma pack(push, 1) +#endif -struct PSM16FileHeader +struct PACKED PSM16FileHeader { // 32-Bit chunk identifiers enum PSM16Magic @@ -994,7 +1010,9 @@ } }; -struct PSM16SampleHeader +STATIC_ASSERT(sizeof(PSM16FileHeader) == 146); + +struct PACKED PSM16SampleHeader { enum SampleFlags { @@ -1086,7 +1104,9 @@ } }; -struct PSM16PatternHeader +STATIC_ASSERT(sizeof(PSM16SampleHeader) == 64); + +struct PACKED PSM16PatternHeader { uint16 size; // includes header bytes uint8 numRows; // 1 ... 64 @@ -1098,7 +1118,11 @@ } }; +STATIC_ASSERT(sizeof(PSM16PatternHeader) == 4); + +#ifdef NEEDS_PRAGMA_PACK #pragma pack(pop) +#endif bool CSoundFile::ReadPSM16(FileReader &file) Modified: trunk/OpenMPT/soundlib/Load_ptm.cpp =================================================================== --- trunk/OpenMPT/soundlib/Load_ptm.cpp 2013-04-16 21:24:09 UTC (rev 1894) +++ trunk/OpenMPT/soundlib/Load_ptm.cpp 2013-04-16 22:00:18 UTC (rev 1895) @@ -15,9 +15,11 @@ #pragma warning(disable:4244) //"conversion from 'type1' to 'type2', possible loss of data" +#ifdef NEEDS_PRAGMA_PACK #pragma pack(push, 1) +#endif -typedef struct PTMFILEHEADER +typedef struct PACKED PTMFILEHEADER { CHAR songname[28]; // name of song, asciiz string CHAR eof; // 26 @@ -37,8 +39,9 @@ WORD patseg[128]; // pattern offsets (*16) } PTMFILEHEADER, *LPPTMFILEHEADER; +STATIC_ASSERT(sizeof(PTMFILEHEADER) == 608); -typedef struct PTMSAMPLE +typedef struct PACKED PTMSAMPLE { BYTE sampletype; // sample type (bit array) CHAR filename[12]; // name of external sample file @@ -54,7 +57,11 @@ DWORD ptms_id; // sample identification, 'PTMS' or 0x534d5450 } PTMSAMPLE; +STATIC_ASSERT(sizeof(PTMSAMPLE) == 80); + +#ifdef NEEDS_PRAGMA_PACK #pragma pack(pop) +#endif bool CSoundFile::ReadPTM(const BYTE *lpStream, const DWORD dwMemLength) Modified: trunk/OpenMPT/soundlib/Load_s3m.cpp =================================================================== --- trunk/OpenMPT/soundlib/Load_s3m.cpp 2013-04-16 21:24:09 UTC (rev 1894) +++ trunk/OpenMPT/soundlib/Load_s3m.cpp 2013-04-16 22:00:18 UTC (rev 1895) @@ -149,10 +149,12 @@ } +#ifdef NEEDS_PRAGMA_PACK #pragma pack(push, 1) +#endif // S3M File Header -struct S3MFileHeader +struct PACKED S3MFileHeader { // Magic Bytes enum S3MMagic @@ -233,7 +235,7 @@ // S3M Sample Header -struct S3MSampleHeader +struct PACKED S3MSampleHeader { enum SampleMagic { @@ -401,7 +403,10 @@ STATIC_ASSERT(sizeof(S3MSampleHeader) == 80); + +#ifdef NEEDS_PRAGMA_PACK #pragma pack(pop) +#endif // Functor for fixing PixPlay 4-Bit Zxx panning commands Modified: trunk/OpenMPT/soundlib/Load_stm.cpp =================================================================== --- trunk/OpenMPT/soundlib/Load_stm.cpp 2013-04-16 21:24:09 UTC (rev 1894) +++ trunk/OpenMPT/soundlib/Load_stm.cpp 2013-04-16 22:00:18 UTC (rev 1895) @@ -14,10 +14,13 @@ #pragma warning(disable:4244) //"conversion from 'type1' to 'type2', possible loss of data" +#ifdef NEEDS_PRAGMA_PACK #pragma pack(push, 1) +#endif + // STM sample header struct -struct STMSampleHeader +struct PACKED STMSampleHeader { char filename[12]; // Can't have long comments - just filename comments :) uint8 zero; @@ -69,9 +72,11 @@ } }; +STATIC_ASSERT(sizeof(STMSampleHeader) == 32); + // STM file header -struct STMFileHeader +struct PACKED STMFileHeader { char songname[20]; char trackername[8]; // !SCREAM! for ST 2.xx @@ -87,9 +92,11 @@ uint8 order[128]; // Order list }; +STATIC_ASSERT(sizeof(STMFileHeader) == 1168); + // Pattern note entry -struct STMPatternEntry +struct PACKED STMPatternEntry { uint8 note; uint8 insvol; @@ -97,11 +104,14 @@ uint8 cmdinf; }; +STATIC_ASSERT(sizeof(STMPatternEntry) == 4); + +#ifdef NEEDS_PRAGMA_PACK #pragma pack(pop) +#endif - bool CSoundFile::ReadSTM(FileReader &file) //---------------------------------------- { Modified: trunk/OpenMPT/soundlib/Load_ult.cpp =================================================================== --- trunk/OpenMPT/soundlib/Load_ult.cpp 2013-04-16 21:24:09 UTC (rev 1894) +++ trunk/OpenMPT/soundlib/Load_ult.cpp 2013-04-16 22:00:18 UTC (rev 1895) @@ -12,9 +12,11 @@ #include "stdafx.h" #include "Loaders.h" +#ifdef NEEDS_PRAGMA_PACK #pragma pack(push, 1) +#endif -struct UltFileHeader +struct PACKED UltFileHeader { char signature[14]; // "MAS_UTrack_V00" uint8 version; // '1'...'4' @@ -25,7 +27,7 @@ STATIC_ASSERT(sizeof(UltFileHeader) == 48); -struct UltSample +struct PACKED UltSample { enum UltSampleFlags { @@ -97,7 +99,9 @@ STATIC_ASSERT(sizeof(UltSample) == 66); +#ifdef NEEDS_PRAGMA_PACK #pragma pack(pop) +#endif /* Unhandled effects: 5x1 - do not loop sample (x is unused) Modified: trunk/OpenMPT/soundlib/Load_umx.cpp =================================================================== --- trunk/OpenMPT/soundlib/Load_umx.cpp 2013-04-16 21:24:09 UTC (rev 1894) +++ trunk/OpenMPT/soundlib/Load_umx.cpp 2013-04-16 22:00:18 UTC (rev 1895) @@ -12,10 +12,12 @@ #include "stdafx.h" #include "Loaders.h" +#ifdef NEEDS_PRAGMA_PACK #pragma pack(push, 1) +#endif // UMX File Header -struct UMXFileHeader +struct PACKED UMXFileHeader { // Magic Bytes enum UMXMagic @@ -49,7 +51,11 @@ } }; +STATIC_ASSERT(sizeof(UMXFileHeader) == 36); + +#ifdef NEEDS_PRAGMA_PACK #pragma pack(pop) +#endif // Read compressed unreal integers - similar to MIDI integers, but signed values are possible. Modified: trunk/OpenMPT/soundlib/Load_xm.cpp =================================================================== --- trunk/OpenMPT/soundlib/Load_xm.cpp 2013-04-16 21:24:09 UTC (rev 1894) +++ trunk/OpenMPT/soundlib/Load_xm.cpp 2013-04-16 22:00:18 UTC (rev 1895) @@ -879,9 +879,9 @@ { DWORD d = 0x4944494D; fwrite(&d, 1, 4, f); - d = sizeof(MIDIMacroConfig); + d = sizeof(MIDIMacroConfigData); fwrite(&d, 1, 4, f); - fwrite(&m_MidiCfg, 1, sizeof(MIDIMacroConfig), f); + fwrite(static_cast<MIDIMacroConfigData*>(&m_MidiCfg), 1, sizeof(MIDIMacroConfigData), f); } // Writing Pattern Names const PATTERNINDEX numNamedPats = Patterns.GetNumNamedPatterns(); Modified: trunk/OpenMPT/soundlib/MIDIMacros.h =================================================================== --- trunk/OpenMPT/soundlib/MIDIMacros.h 2013-04-16 21:24:09 UTC (rev 1894) +++ trunk/OpenMPT/soundlib/MIDIMacros.h 2013-04-16 22:00:18 UTC (rev 1895) @@ -69,17 +69,25 @@ #define NUM_MACROS 16 // number of parametered macros #define MACRO_LENGTH 32 // max number of chars per macro -//=================== -class MIDIMacroConfig -//=================== -{ -public: +#ifdef NEEDS_PRAGMA_PACK +#pragma pack(push, 1) +#endif +struct PACKED MIDIMacroConfigData +{ char szMidiGlb[9][MACRO_LENGTH]; // Global MIDI macros char szMidiSFXExt[16][MACRO_LENGTH]; // Parametric MIDI macros char szMidiZXXExt[128][MACRO_LENGTH]; // Fixed MIDI macros +}; +STATIC_ASSERT(sizeof(MIDIMacroConfigData) == 4896); // this is directly written to files, so the size must be correct! + +//======================================================= +class PACKED MIDIMacroConfig : public MIDIMacroConfigData +//======================================================= +{ + public: MIDIMacroConfig() { Reset(); }; @@ -149,4 +157,8 @@ }; -STATIC_ASSERT(sizeof(MIDIMacroConfig) == 4896); // this is directly written to files, so the size must be correct! +STATIC_ASSERT(sizeof(MIDIMacroConfig) == sizeof(MIDIMacroConfigData)); // this is directly written to files, so the size must be correct! + +#ifdef NEEDS_PRAGMA_PACK +#pragma pack(pop) +#endif Modified: trunk/OpenMPT/soundlib/Mmcmp.cpp =================================================================== --- trunk/OpenMPT/soundlib/Mmcmp.cpp 2013-04-16 21:24:09 UTC (rev 1894) +++ trunk/OpenMPT/soundlib/Mmcmp.cpp 2013-04-16 22:00:18 UTC (rev 1895) @@ -304,9 +304,11 @@ // XPK unpacker // +#ifdef NEEDS_PRAGMA_PACK #pragma pack(push, 1) +#endif -typedef struct _XPKFILEHEADER +typedef struct PACKED _XPKFILEHEADER { DWORD dwXPKF; DWORD dwSrcLen; @@ -316,7 +318,11 @@ DWORD dwReserved; } XPKFILEHEADER, *PXPKFILEHEADER; +STATIC_ASSERT(sizeof(XPKFILEHEADER) == 36); + +#ifdef NEEDS_PRAGMA_PACK #pragma pack(pop) +#endif static int bfextu(const BYTE *p,int bo,int bc) Modified: trunk/OpenMPT/soundlib/SampleFormats.cpp =================================================================== --- trunk/OpenMPT/soundlib/SampleFormats.cpp 2013-04-16 21:24:09 UTC (rev 1894) +++ trunk/OpenMPT/soundlib/SampleFormats.cpp 2013-04-16 22:00:18 UTC (rev 1895) @@ -560,9 +560,12 @@ ///////////////////////////////////////////////////////////// // GUS Patches +#ifdef NEEDS_PRAGMA_PACK #pragma pack(push, 1) +#endif -typedef struct GF1PATCHFILEHEADER + +typedef struct PACKED GF1PATCHFILEHEADER { DWORD gf1p; // "GF1P" DWORD atch; // "ATCH" @@ -578,8 +581,10 @@ BYTE reserved2[36]; } GF1PATCHFILEHEADER; +STATIC_ASSERT(sizeof(GF1PATCHFILEHEADER) == 129); -typedef struct GF1INSTRUMENT + +typedef struct PACKED GF1INSTRUMENT { WORD id; // Instrument id: 0-65535 CHAR name[16]; // Name of instrument. Gravis doesn't seem to use it @@ -588,8 +593,10 @@ BYTE reserved[40]; } GF1INSTRUMENT; +STATIC_ASSERT(sizeof(GF1INSTRUMENT) == 63); -typedef struct GF1SAMPLEHEADER + +typedef struct PACKED GF1SAMPLEHEADER { CHAR name[7]; // null terminated string. name of the wave. BYTE fractions; // Start loop point fraction in 4 bits + End loop point fraction in the 4 other bits. @@ -610,6 +617,8 @@ BYTE reserved[36]; } GF1SAMPLEHEADER; +STATIC_ASSERT(sizeof(GF1SAMPLEHEADER) == 96); + // -- GF1 Envelopes -- // // It can be represented like this (the envelope is totally bogus, it is @@... [truncated message content] |
From: <sag...@us...> - 2013-04-17 23:31:31
|
Revision: 1902 http://sourceforge.net/p/modplug/code/1902 Author: saga-games Date: 2013-04-17 23:31:23 +0000 (Wed, 17 Apr 2013) Log Message: ----------- [Fix] Invalid instrument numbers do nothing, but they are remembered for upcoming notes and do not trigger a note in that case. [Mod] OpenMPT: Version is now 1.22.01.04 Modified Paths: -------------- trunk/OpenMPT/common/version.h trunk/OpenMPT/soundlib/ModChannel.cpp trunk/OpenMPT/soundlib/ModChannel.h trunk/OpenMPT/soundlib/Snd_fx.cpp Modified: trunk/OpenMPT/common/version.h =================================================================== --- trunk/OpenMPT/common/version.h 2013-04-17 21:08:11 UTC (rev 1901) +++ trunk/OpenMPT/common/version.h 2013-04-17 23:31:23 UTC (rev 1902) @@ -19,7 +19,7 @@ #define VER_MAJORMAJOR 1 #define VER_MAJOR 22 #define VER_MINOR 01 -#define VER_MINORMINOR 03 +#define VER_MINORMINOR 04 //Creates version number from version parts that appears in version string. //For example MAKE_VERSION_NUMERIC(1,17,02,28) gives version number of Modified: trunk/OpenMPT/soundlib/ModChannel.cpp =================================================================== --- trunk/OpenMPT/soundlib/ModChannel.cpp 2013-04-17 21:08:11 UTC (rev 1901) +++ trunk/OpenMPT/soundlib/ModChannel.cpp 2013-04-17 23:31:23 UTC (rev 1902) @@ -17,7 +17,7 @@ { if(resetMask & resetSetPosBasic) { - nNote = nNewNote = nNewIns = 0; + nNote = nNewNote = nNewIns = nOldIns = 0; pModSample = nullptr; pModInstrument = nullptr; nPortamentoDest = 0; Modified: trunk/OpenMPT/soundlib/ModChannel.h =================================================================== --- trunk/OpenMPT/soundlib/ModChannel.h 2013-04-17 21:08:11 UTC (rev 1901) +++ trunk/OpenMPT/soundlib/ModChannel.h 2013-04-17 23:31:23 UTC (rev 1902) @@ -83,7 +83,7 @@ uint8 nRestoreCutoffOnNewNote; //Like above uint8 nNote, nNNA; uint8 nLastNote; // Last note, ignoring note offs and cuts - for MIDI macros - uint8 nNewNote, nNewIns, nCommand, nArpeggio; + uint8 nNewNote, nNewIns, nOldIns, nCommand, nArpeggio; uint8 nOldVolumeSlide, nOldFineVolUpDown; uint8 nOldPortaUpDown, nOldFinePortaUpDown, nOldExtraFinePortaUpDown; uint8 nOldPanSlide, nOldChnVolSlide; Modified: trunk/OpenMPT/soundlib/Snd_fx.cpp =================================================================== --- trunk/OpenMPT/soundlib/Snd_fx.cpp 2013-04-17 21:08:11 UTC (rev 1901) +++ trunk/OpenMPT/soundlib/Snd_fx.cpp 2013-04-17 23:31:23 UTC (rev 1902) @@ -1650,9 +1650,10 @@ // Additional test case: tickdelay.it if(instr) { - if(GetNumInstruments() < 1 && instr < MAX_SAMPLES) + if(GetNumInstruments() == 0) { - pChn->pModSample = &Samples[instr]; + if(instr < MAX_SAMPLES) + pChn->pModSample = &Samples[instr]; } else { if(instr < MAX_INSTRUMENTS) @@ -1762,6 +1763,16 @@ { note = NOTE_NONE; } + } else if(IsCompatibleMode(TRK_IMPULSETRACKER) && GetNumInstruments() != 0 && ModCommand::IsNoteOrEmpty(note)) + { + // IT compatibility: Invalid instrument numbers do nothing, but they are remembered for upcoming notes and do not trigger a note in that case. + // Test case: InstrumentNumberChange.it + INSTRUMENTINDEX instrToCheck = (instr != 0 ? instr : pChn->nOldIns); + if(instrToCheck != 0 && (instrToCheck > GetNumInstruments() || Instruments[instrToCheck] == nullptr)) + { + note = NOTE_NONE; + instr = 0; + } } // XM: FT2 ignores a note next to a K00 effect, and a fade-out seems to be done when no volume envelope is present (not exactly the Kxx behaviour) @@ -1928,7 +1939,7 @@ if(instr) { const ModSample *oldSample = pChn->pModSample; - const ModInstrument *oldInstrument = pChn->pModInstrument; + //const ModInstrument *oldInstrument = pChn->pModInstrument; InstrumentChange(pChn, instr, bPorta, true); pChn->nNewIns = 0; @@ -2550,6 +2561,12 @@ UpdateS3MEffectMemory(pChn, param); } + if(pChn->rowCommand.instr) + { + // Not necessarily consistent with actually playing instrument for IT compatibility + pChn->nOldIns = pChn->rowCommand.instr; + } + } // for(...) end // Navigation Effects This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <man...@us...> - 2013-04-18 13:42:28
|
Revision: 1905 http://sourceforge.net/p/modplug/code/1905 Author: manxorist Date: 2013-04-18 13:42:21 +0000 (Thu, 18 Apr 2013) Log Message: ----------- [Ref] Use <cstdint> for VS2010 and up. [Ref] Do not assume int8* and char* are implicitely convertible to each other. Modified Paths: -------------- trunk/OpenMPT/common/typedefs.h trunk/OpenMPT/soundlib/Load_ams.cpp trunk/OpenMPT/soundlib/SampleIO.cpp Modified: trunk/OpenMPT/common/typedefs.h =================================================================== --- trunk/OpenMPT/common/typedefs.h 2013-04-18 01:32:41 UTC (rev 1904) +++ trunk/OpenMPT/common/typedefs.h 2013-04-18 13:42:21 UTC (rev 1905) @@ -86,11 +86,13 @@ #define DEPRECATED #endif + +#if defined(_MSC_VER) && (_MSC_VER <= MSVC_VER_2008) + typedef __int8 int8; typedef __int16 int16; typedef __int32 int32; typedef __int64 int64; - typedef unsigned __int8 uint8; typedef unsigned __int16 uint16; typedef unsigned __int32 uint32; @@ -111,6 +113,37 @@ const uint32 uint32_max = 4294967295; const uint64 uint64_max = 18446744073709551615; +#else + +#include <cstdint> + +typedef std::int8_t int8; +typedef std::int16_t int16; +typedef std::int32_t int32; +typedef std::int64_t int64; +typedef std::uint8_t uint8; +typedef std::uint16_t uint16; +typedef std::uint32_t uint32; +typedef std::uint64_t uint64; + +const int8 int8_min = INT8_MIN; +const int16 int16_min = INT16_MIN; +const int32 int32_min = INT32_MIN; +const int64 int64_min = INT64_MIN; + +const int8 int8_max = INT8_MAX; +const int16 int16_max = INT16_MAX; +const int32 int32_max = INT32_MAX; +const int64 int64_max = INT64_MAX; + +const uint8 uint8_max = UINT8_MAX; +const uint16 uint16_max = UINT16_MAX; +const uint32 uint32_max = UINT32_MAX; +const uint64 uint64_max = UINT64_MAX; + +#endif + + typedef float float32; union FloatInt32 Modified: trunk/OpenMPT/soundlib/Load_ams.cpp =================================================================== --- trunk/OpenMPT/soundlib/Load_ams.cpp 2013-04-18 01:32:41 UTC (rev 1904) +++ trunk/OpenMPT/soundlib/Load_ams.cpp 2013-04-18 13:42:21 UTC (rev 1905) @@ -982,7 +982,7 @@ ///////////////////////////////////////////////////////////////////// // AMS Sample unpacking -void AMSUnpack(const char * const source, size_t sourceSize, void * const dest, const size_t destSize, char packCharacter) +void AMSUnpack(const int8 * const source, size_t sourceSize, void * const dest, const size_t destSize, char packCharacter) //------------------------------------------------------------------------------------------------------------------------ { int8 *tempBuf = new (std::nothrow) int8[destSize]; Modified: trunk/OpenMPT/soundlib/SampleIO.cpp =================================================================== --- trunk/OpenMPT/soundlib/SampleIO.cpp 2013-04-18 01:32:41 UTC (rev 1904) +++ trunk/OpenMPT/soundlib/SampleIO.cpp 2013-04-18 13:42:21 UTC (rev 1905) @@ -18,7 +18,7 @@ // External decompressors -extern void AMSUnpack(const char * const source, size_t sourceSize, void * const dest, const size_t destSize, char packCharacter); +extern void AMSUnpack(const int8 * const source, size_t sourceSize, void * const dest, const size_t destSize, char packCharacter); extern uint16 MDLReadBits(uint32 &bitbuf, uint32 &bitnum, const uint8 *(&ibuf), int8 n); extern int DMFUnpack(LPBYTE psample, const uint8 *ibuf, const uint8 *ibufmax, uint32 maxlen); @@ -299,7 +299,7 @@ LimitMax(sourceSize, file.BytesLeft()); bytesRead = 9 + sourceSize; - AMSUnpack(reinterpret_cast<const char *>(sourceBuf) + 9, sourceSize, sample.pSample, sample.GetSampleSizeInBytes(), packCharacter); + AMSUnpack(reinterpret_cast<const int8 *>(sourceBuf) + 9, sourceSize, sample.pSample, sample.GetSampleSizeInBytes(), packCharacter); } } else if(GetEncoding() == PTM8Dto16 && GetChannelFormat() == mono && GetBitDepth() == 16) { This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <man...@us...> - 2013-04-18 15:36:47
|
Revision: 1909 http://sourceforge.net/p/modplug/code/1909 Author: manxorist Date: 2013-04-18 15:36:38 +0000 (Thu, 18 Apr 2013) Log Message: ----------- [Ref] Move IsDebuggerPresent() logic of ALWAYS_ASSERT() into AlwaysAssertHandler function. Modified Paths: -------------- trunk/OpenMPT/common/typedefs.h trunk/OpenMPT/mptrack/ExceptionHandler.cpp Modified: trunk/OpenMPT/common/typedefs.h =================================================================== --- trunk/OpenMPT/common/typedefs.h 2013-04-18 15:22:56 UTC (rev 1908) +++ trunk/OpenMPT/common/typedefs.h 2013-04-18 15:36:38 UTC (rev 1909) @@ -59,13 +59,14 @@ #endif #define STATIC_ASSERT(expr) static_assert((expr), "compile time assertion failed: " #expr) +#ifdef NDEBUG void AlwaysAssertHandler(const char *file, int line, const char *function, const char *expr); -#ifdef NDEBUG -#define ALWAYS_ASSERT(expr) do { if(!(expr)) { if(IsDebuggerPresent()) { OutputDebugString("assert failed: " #expr); DebugBreak(); } else { AlwaysAssertHandler(__FILE__, __LINE__, __FUNCTION__, #expr); } } } while(0) +#define ALWAYS_ASSERT(expr) do { if(!(expr)) { AlwaysAssertHandler(__FILE__, __LINE__, __FUNCTION__, #expr); } } while(0) #else #define ALWAYS_ASSERT(expr) ASSERT(expr) #endif + // Advanced inline attributes #if defined(_MSC_VER) #define forceinline __forceinline Modified: trunk/OpenMPT/mptrack/ExceptionHandler.cpp =================================================================== --- trunk/OpenMPT/mptrack/ExceptionHandler.cpp 2013-04-18 15:22:56 UTC (rev 1908) +++ trunk/OpenMPT/mptrack/ExceptionHandler.cpp 2013-04-18 15:36:38 UTC (rev 1909) @@ -144,10 +144,22 @@ } +#ifdef NDEBUG void AlwaysAssertHandler(const char *file, int line, const char *function, const char *expr) //------------------------------------------------------------------------------------------ { - CString errorMessage; - errorMessage.Format("Internal error occured at %s(%d): ASSERT(%s) failed in [%s].", file, line, expr, function); - GenerateDump(errorMessage); + if(IsDebuggerPresent()) + { + OutputDebugString("ASSERT("); + OutputDebugString(expr); + OutputDebugString(") failed\n"); + DebugBreak(); + } else + { + CString errorMessage; + errorMessage.Format("Internal error occured at %s(%d): ASSERT(%s) failed in [%s].", file, line, expr, function); + GenerateDump(errorMessage); + } } +#endif + This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <man...@us...> - 2013-04-18 18:24:31
|
Revision: 1911 http://sourceforge.net/p/modplug/code/1911 Author: manxorist Date: 2013-04-18 18:24:19 +0000 (Thu, 18 Apr 2013) Log Message: ----------- [Ref] Move mpt::String::Format out of the header file. [Ref] Move Log() from mptrack/mptrack.cpp to common/typedefs.cpp [Ref] Make Log() print file and line number in addition to the log message to the debug window. [Ref] Add NO_LOGGING preprocessor macro to completely disable all debug logging (not set by default). [Ref] Add AlwaysAssertHandler for !MODPLUG_TRACKER. [Ref] Add C99 compatible c99_snprintf and c99_vsnprintf for msvc. Modified Paths: -------------- trunk/OpenMPT/common/mptString.h trunk/OpenMPT/common/serialization_utils.h trunk/OpenMPT/common/stdafx.h trunk/OpenMPT/common/typedefs.h trunk/OpenMPT/mptrack/CommandSet.cpp trunk/OpenMPT/mptrack/Mptrack.cpp trunk/OpenMPT/mptrack/Mptrack.h trunk/OpenMPT/mptrack/mptrack_08.vcproj trunk/OpenMPT/mptrack/mptrack_10.vcxproj trunk/OpenMPT/mptrack/mptrack_10.vcxproj.filters trunk/OpenMPT/soundlib/Load_med.cpp trunk/OpenMPT/soundlib/Load_mid.cpp trunk/OpenMPT/soundlib/Mmcmp.cpp trunk/OpenMPT/unarchiver/unlha.cpp Added Paths: ----------- trunk/OpenMPT/common/mptString.cpp trunk/OpenMPT/common/typedefs.cpp Added: trunk/OpenMPT/common/mptString.cpp =================================================================== --- trunk/OpenMPT/common/mptString.cpp (rev 0) +++ trunk/OpenMPT/common/mptString.cpp 2013-04-18 18:24:19 UTC (rev 1911) @@ -0,0 +1,52 @@ +/* + * mptString.cpp + * ------------- + * Purpose: A wrapper around std::string implemeting the CString. + * Notes : Should be removed somewhen in the future when all uses of CString have been converted to std::string. + * Authors: OpenMPT Devs + * The OpenMPT source code is released under the BSD license. Read LICENSE for more details. + */ + + +#pragma once + +#include "stdafx.h" +#include "mptString.h" + +#include <vector> +#include <cstdarg> + + +namespace mpt { + +// Formats this string, like CString::Format. +void String::Format(const CharT* pszFormat, ...) +{ + #ifdef _MSC_VER + va_list argList; + va_start( argList, pszFormat ); + + // Count the needed array size. + const size_t nCount = _vscprintf(pszFormat, argList); // null character not included. + resize(nCount + 1); // + 1 is for null terminator. + + // Hack: directly modify the std::string's string. + // In C++11 std::string is guaranteed to be contiguous. + const int nCount2 = vsprintf_s(&*begin(), size(), pszFormat, argList); + resize(nCount2); // Removes the null character that vsprintf_s adds. + + va_end( argList ); + #else + va_list argList; + va_start(argList, pszFormat); + int size = vsnprintf(NULL, 0, pszFormat, argList); // get required size, requires c99 compliant vsnprintf which msvc does not have + va_end(argList); + std::vector<char> temp(size + 1); + va_start(argList, pszFormat); + vsnprintf(&(temp[0]), size + 1, pszFormat, argList); + va_end(argList); + assign(&(temp[0])); + #endif +} + +} // namespace mpt Property changes on: trunk/OpenMPT/common/mptString.cpp ___________________________________________________________________ Added: svn:mime-type ## -0,0 +1 ## +text/x-c++src \ No newline at end of property Added: svn:eol-style ## -0,0 +1 ## +native \ No newline at end of property Modified: trunk/OpenMPT/common/mptString.h =================================================================== --- trunk/OpenMPT/common/mptString.h 2013-04-18 17:10:49 UTC (rev 1910) +++ trunk/OpenMPT/common/mptString.h 2013-04-18 18:24:19 UTC (rev 1911) @@ -64,21 +64,7 @@ } // Formats this string, like CString::Format. - void Format(const CharT* pszFormat, ...) - { - va_list argList; - va_start( argList, pszFormat ); - - // Count the needed array size. - const size_t nCount = _vscprintf(pszFormat, argList); // null character not included. - resize(nCount + 1); // + 1 is for null terminator. - - // Hack: directly modify the std::string's string. - // In C++11 std::string is guaranteed to be contiguous. - const int nCount2 = vsprintf_s(&*begin(), size(), pszFormat, argList); - resize(nCount2); // Removes the null character that vsprintf_s adds. - - va_end( argList ); - } + void Format(const CharT* pszFormat, ...); }; } + Modified: trunk/OpenMPT/common/serialization_utils.h =================================================================== --- trunk/OpenMPT/common/serialization_utils.h 2013-04-18 17:10:49 UTC (rev 1910) +++ trunk/OpenMPT/common/serialization_utils.h 2013-04-18 18:24:19 UTC (rev 1911) @@ -234,7 +234,7 @@ bool GetFlag(Rwf flag) const {return m_Flags[flag];} // Write given string to log if log func is defined. - void Log(LPCTSTR psz) {if (m_fpLogFunc) m_fpLogFunc(psz);} + void AddToLog(LPCTSTR psz) {if (m_fpLogFunc) m_fpLogFunc(psz);} SsbStatus m_Status; uint32 m_nFixedEntrySize; // Read/write: If > 0, data entries have given fixed size. Modified: trunk/OpenMPT/common/stdafx.h =================================================================== --- trunk/OpenMPT/common/stdafx.h 2013-04-18 17:10:49 UTC (rev 1910) +++ trunk/OpenMPT/common/stdafx.h 2013-04-18 18:24:19 UTC (rev 1911) @@ -33,7 +33,6 @@ #define _CRT_SECURE_CPP_OVERLOAD_STANDARD_NAMES_COUNT 1 #define _SCL_SECURE_NO_WARNINGS - #include <afxwin.h> // MFC core and standard components #include <afxext.h> // MFC extensions #include <afxcmn.h> // MFC support for Windows Common Controls @@ -46,7 +45,6 @@ #include <mmreg.h> #include <msacm.h> #include <afxdlgs.h> -//#include <afxdhtml.h> #pragma warning(default:4201) #include <string> @@ -73,6 +71,9 @@ #endif // ENABLE_ASM +// Disable any debug logging +//#define NO_LOGGING + // Disable unarchiving support //#define NO_ARCHIVE_SUPPORT @@ -109,20 +110,11 @@ // Define to build without MP3 import support (via mpg123) //#define NO_MP3_SAMPLES - -void Log(LPCSTR format,...); - #include "../common/typedefs.h" -#include "../common/mptString.h" - // Exception type that is used to catch "operator new" exceptions. //typedef std::bad_alloc & MPTMemoryException; typedef CMemoryException * MPTMemoryException; -//To mark string that should be translated in case of multilingual version. -#define GetStrI18N(x) (x) - - //{{AFX_INSERT_LOCATION}} // Microsoft Developer Studio will insert additional declarations immediately before the previous line. Added: trunk/OpenMPT/common/typedefs.cpp =================================================================== --- trunk/OpenMPT/common/typedefs.cpp (rev 0) +++ trunk/OpenMPT/common/typedefs.cpp 2013-04-18 18:24:19 UTC (rev 1911) @@ -0,0 +1,147 @@ +/* + * typedefs.cpp + * ------------ + * Purpose: Basic data type definitions and assorted compiler-related helpers. + * Notes : (currently none) + * Authors: OpenMPT Devs + * The OpenMPT source code is released under the BSD license. Read LICENSE for more details. + */ + + +#include "stdafx.h" +#include "typedefs.h" +#include <iostream> + + +#ifndef MODPLUG_TRACKER +void AlwaysAssertHandler(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 + + +#ifdef _MSC_VER + +int c99_vsnprintf(char *str, size_t size, const char *format, va_list args) +{ + int ret; + va_list ap; + va_copy(ap, args); + ret = _vsnprintf(str, size, format, ap); + va_end(ap); + if ( ret < 0 ) { + str[size - 1] = '\0'; + ret = size; + } + return ret; +} + + +int c99_snprintf(char *str, size_t size, const char *format, ...) +{ + int ret; + va_list ap; + va_start( ap, format ); + ret = c99_vsnprintf(str, size, format, ap); + va_end( ap ); + return ret; +} + +#endif + + +static const std::size_t LOGBUF_SIZE = 1024; + +static void DoLog(const char *file, int line, const char *function, const char *format, va_list args) +//--------------------------------------------------------------------------------------------------- +{ +#if !defined(MODPLUG_TRACKER) || defined(_DEBUG) + char message[LOGBUF_SIZE]; + va_list va; + va_copy(va, args); + vsnprintf(message, LOGBUF_SIZE, format, va); + va_end(va); + #if defined(MODPLUG_TRACKER) + char buf2[LOGBUF_SIZE]; + char *verbose_message = nullptr; + if(file || function) + { + snprintf(buf2, LOGBUF_SIZE, "%s(%i): %s", file?file:"", line, message); + verbose_message = buf2; + } else + { + verbose_message = message; + } + OutputDebugString(verbose_message); + #ifdef LOG_TO_FILE + FILE *f = fopen("c:\\mptrack.log", "a"); + if(f) + { + fwrite(verbose_message, 1, strlen(verbose_message), f); + fclose(f); + } + #endif //LOG_TO_FILE + #else // !MODPLUG_TRACKER + std::size_t len = strlen(message); + // remove eol if already present + if(len > 0 && message[len-1] == '\n') + { + message[len-1] = '\0'; + len--; + } + if(len > 0 && message[len-1] == '\r') + { + message[len-1] = '\0'; + len--; + } + if(file || function) + { + std::clog + << "openmpt: DEBUG: " + << (file?file:"") << "(" << line << ")" << ": " + << std::string(message) + << " [" << (function?function:"") << "]" + << std::endl; + } else + { + std::clog + << "openmpt: DEBUG: " + << std::string(message) + << std::endl; + } + #endif // MODPLUG_TRACKER +#endif +} + + +#ifndef NO_LOGGING + +void Logger::operator () (const char *format, ...) +//------------------------------------------------ +{ + va_list va; + va_start(va, format); + DoLog(file, line, function, format, va); + va_end(va); +} + + +#undef Log +void Log(const char * format, ...) +//-------------------------------- +{ + va_list va; + va_start(va, format); + DoLog(nullptr, 0, nullptr, format, va); + va_end(va); +} + +#endif Property changes on: trunk/OpenMPT/common/typedefs.cpp ___________________________________________________________________ Added: svn:mime-type ## -0,0 +1 ## +text/x-c++src \ No newline at end of property Added: svn:eol-style ## -0,0 +1 ## +native \ No newline at end of property Modified: trunk/OpenMPT/common/typedefs.h =================================================================== --- trunk/OpenMPT/common/typedefs.h 2013-04-18 17:10:49 UTC (rev 1910) +++ trunk/OpenMPT/common/typedefs.h 2013-04-18 18:24:19 UTC (rev 1911) @@ -166,3 +166,48 @@ float32 f; uint32 i; }; + + +#include <cstdarg> +#ifdef _MSC_VER +#ifndef va_copy +#define va_copy(dst, src) do { (dst) = (src); } while (0) +#endif +#endif + + +#include "../common/mptString.h" + +//To mark string that should be translated in case of multilingual version. +#define GetStrI18N(x) (x) + + +#ifndef NO_LOGGING +void Log(const char *format, ...); +class Logger +{ +private: + const char * const file; + int const line; + const char * const function; +public: + Logger(const char *file_, int line_, const char *function_) : file(file_), line(line_), function(function_) {} + void operator () (const char *format, ...); +}; +#define Log Logger(__FILE__, __LINE__, __FUNCTION__) +#else // !NO_LOGGING +inline void Log(const char *format, ...) {} +class Logger { public: void operator () (const char *format, ...) {} }; +#define Log if(true) {} else Logger() // completely compile out arguments to Log() so that they do not even get evaluated +#endif // NO_LOGGING + +// just #undef Log in files, where this Log redefinition causes problems +//#undef Log + + +#include <stdio.h> +#ifdef _MSC_VER +int c99_vsnprintf(char *str, size_t size, const char *format, va_list args); +int c99_snprintf(char *str, size_t size, const char *format, ...); +#define snprintf c99_snprintf +#endif Modified: trunk/OpenMPT/mptrack/CommandSet.cpp =================================================================== --- trunk/OpenMPT/mptrack/CommandSet.cpp 2013-04-18 17:10:49 UTC (rev 1910) +++ trunk/OpenMPT/mptrack/CommandSet.cpp 2013-04-18 18:24:19 UTC (rev 1911) @@ -23,6 +23,7 @@ #if(ENABLE_LOGGING) // #else + #undef Log #define Log #endif Modified: trunk/OpenMPT/mptrack/Mptrack.cpp =================================================================== --- trunk/OpenMPT/mptrack/Mptrack.cpp 2013-04-18 17:10:49 UTC (rev 1910) +++ trunk/OpenMPT/mptrack/Mptrack.cpp 2013-04-18 18:24:19 UTC (rev 1911) @@ -2278,31 +2278,6 @@ } -/////////////////////////////////////////////////////////////////////////////////// -// Debug - -void Log(LPCSTR format,...) -//------------------------- -{ - #ifdef _DEBUG - CHAR cBuf[1024]; - va_list va; - va_start(va, format); - wvsprintf(cBuf, format, va); - OutputDebugString(cBuf); - #ifdef LOG_TO_FILE - FILE *f = fopen("c:\\mptrack.log", "a"); - if (f) - { - fwrite(cBuf, 1, strlen(cBuf), f); - fclose(f); - } - #endif //LOG_TO_FILE - va_end(va); - #endif //_DEBUG -} - - ////////////////////////////////////////////////////////////////////////////////// // Localized strings Modified: trunk/OpenMPT/mptrack/Mptrack.h =================================================================== --- trunk/OpenMPT/mptrack/Mptrack.h 2013-04-18 17:10:49 UTC (rev 1910) +++ trunk/OpenMPT/mptrack/Mptrack.h 2013-04-18 18:24:19 UTC (rev 1911) @@ -321,7 +321,6 @@ // Misc functions class CVstPlugin; -void Log(LPCSTR format,...); UINT MsgBox(UINT nStringID, CWnd *p=NULL, LPCSTR lpszTitle=NULL, UINT n=MB_OK); void ErrorBox(UINT nStringID, CWnd*p=NULL); Modified: trunk/OpenMPT/mptrack/mptrack_08.vcproj =================================================================== --- trunk/OpenMPT/mptrack/mptrack_08.vcproj 2013-04-18 17:10:49 UTC (rev 1910) +++ trunk/OpenMPT/mptrack/mptrack_08.vcproj 2013-04-18 18:24:19 UTC (rev 1911) @@ -381,6 +381,14 @@ > </File> <File + RelativePath="..\common\mptString.cpp" + > + </File> + <File + RelativePath="..\common\typedefs.cpp" + > + </File> + <File RelativePath="..\soundlib\MixerSettings.cpp" > </File> Modified: trunk/OpenMPT/mptrack/mptrack_10.vcxproj =================================================================== --- trunk/OpenMPT/mptrack/mptrack_10.vcxproj 2013-04-18 17:10:49 UTC (rev 1910) +++ trunk/OpenMPT/mptrack/mptrack_10.vcxproj 2013-04-18 18:24:19 UTC (rev 1911) @@ -246,9 +246,11 @@ <ItemGroup> <ClCompile Include="..\common\AudioCriticalSection.cpp" /> <ClCompile Include="..\common\misc_util.cpp" /> + <ClCompile Include="..\common\mptString.cpp" /> <ClCompile Include="..\common\Profiler.cpp" /> <ClCompile Include="..\common\Reporting.cpp" /> <ClCompile Include="..\common\serialization_utils.cpp" /> + <ClCompile Include="..\common\typedefs.cpp" /> <ClCompile Include="..\sounddev\SoundDevice.cpp" /> <ClCompile Include="..\sounddsp\AGC.cpp" /> <ClCompile Include="..\sounddsp\DSP.cpp" /> Modified: trunk/OpenMPT/mptrack/mptrack_10.vcxproj.filters =================================================================== --- trunk/OpenMPT/mptrack/mptrack_10.vcxproj.filters 2013-04-18 17:10:49 UTC (rev 1910) +++ trunk/OpenMPT/mptrack/mptrack_10.vcxproj.filters 2013-04-18 18:24:19 UTC (rev 1911) @@ -430,6 +430,12 @@ <ClCompile Include="Vstplug.cpp"> <Filter>Source Files\mptrack</Filter> </ClCompile> + <ClCompile Include="..\common\mptString.cpp"> + <Filter>Source Files\common</Filter> + </ClCompile> + <ClCompile Include="..\common\typedefs.cpp"> + <Filter>Source Files\common</Filter> + </ClCompile> </ItemGroup> <ItemGroup> <ClInclude Include="..\soundlib\Loaders.h"> Modified: trunk/OpenMPT/soundlib/Load_med.cpp =================================================================== --- trunk/OpenMPT/soundlib/Load_med.cpp 2013-04-18 17:10:49 UTC (rev 1910) +++ trunk/OpenMPT/soundlib/Load_med.cpp 2013-04-18 18:24:19 UTC (rev 1911) @@ -14,10 +14,6 @@ //#define MED_LOG -#ifdef MED_LOG -extern void Log(LPCSTR s, ...); -#endif - #define MED_MAX_COMMENT_LENGTH 5*1024 //: Is 5 kB enough? // flags Modified: trunk/OpenMPT/soundlib/Load_mid.cpp =================================================================== --- trunk/OpenMPT/soundlib/Load_mid.cpp 2013-04-18 17:10:49 UTC (rev 1910) +++ trunk/OpenMPT/soundlib/Load_mid.cpp 2013-04-18 18:24:19 UTC (rev 1911) @@ -23,7 +23,6 @@ #ifdef MIDI_LOG //#define MIDI_DETAILED_LOG -extern void Log(LPCSTR, ...); #endif #define MIDI_DRUMCHANNEL 10 Modified: trunk/OpenMPT/soundlib/Mmcmp.cpp =================================================================== --- trunk/OpenMPT/soundlib/Mmcmp.cpp 2013-04-18 17:10:49 UTC (rev 1910) +++ trunk/OpenMPT/soundlib/Mmcmp.cpp 2013-04-18 18:24:19 UTC (rev 1911) @@ -14,11 +14,7 @@ //#define MMCMP_LOG -#ifdef MMCMP_LOG -extern void Log(LPCSTR s, ...); -#endif - BOOL XPK_Unpack(LPCBYTE *ppMemFile, LPDWORD pdwMemLength); BOOL PP20_Unpack(LPCBYTE *ppMemFile, LPDWORD pdwMemLength); Modified: trunk/OpenMPT/unarchiver/unlha.cpp =================================================================== --- trunk/OpenMPT/unarchiver/unlha.cpp 2013-04-18 17:10:49 UTC (rev 1910) +++ trunk/OpenMPT/unarchiver/unlha.cpp 2013-04-18 18:24:19 UTC (rev 1911) @@ -43,7 +43,7 @@ #ifdef _DEBUG #define LHADEBUG -extern void Log(LPCSTR, ...); +extern void Log(const char *, ...); #endif #include "unlha/lharc.h" This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <man...@us...> - 2013-04-18 21:21:45
|
Revision: 1913 http://sourceforge.net/p/modplug/code/1913 Author: manxorist Date: 2013-04-18 21:21:33 +0000 (Thu, 18 Apr 2013) Log Message: ----------- [Ref] Move Reporting.* from common/ to mptrack/. [Ref] Add common/Logging.h and class ILog. [Ref] Route all user messages from soundlib via CModDoc->AddToLog(). [Ref] Handle displaying of the message log via a class ScopedLogCapturer which ensures that no messages are lost. [Ref] Optionally route user messages via a custom ILog set via SetLog in CSoundFile. Modified Paths: -------------- trunk/OpenMPT/mptrack/CleanupSong.cpp trunk/OpenMPT/mptrack/CommandSet.cpp trunk/OpenMPT/mptrack/MIDIMacroDialog.cpp trunk/OpenMPT/mptrack/Moddoc.cpp trunk/OpenMPT/mptrack/Moddoc.h trunk/OpenMPT/mptrack/Mptrack.h trunk/OpenMPT/mptrack/mptrack_08.vcproj trunk/OpenMPT/mptrack/mptrack_10.vcxproj trunk/OpenMPT/mptrack/mptrack_10.vcxproj.filters trunk/OpenMPT/sounddev/SoundDevice.cpp trunk/OpenMPT/soundlib/ITCompression.cpp trunk/OpenMPT/soundlib/Mmx_mix.cpp trunk/OpenMPT/soundlib/ModSequence.cpp trunk/OpenMPT/soundlib/SampleFormats.cpp trunk/OpenMPT/soundlib/Sndfile.cpp trunk/OpenMPT/soundlib/Sndfile.h trunk/OpenMPT/soundlib/modsmp_ctrl.cpp trunk/OpenMPT/soundlib/patternContainer.cpp trunk/OpenMPT/soundlib/tuning.cpp Added Paths: ----------- trunk/OpenMPT/common/Logging.h trunk/OpenMPT/mptrack/Reporting.cpp trunk/OpenMPT/mptrack/Reporting.h Removed Paths: ------------- trunk/OpenMPT/common/Reporting.cpp trunk/OpenMPT/common/Reporting.h Added: trunk/OpenMPT/common/Logging.h =================================================================== --- trunk/OpenMPT/common/Logging.h (rev 0) +++ trunk/OpenMPT/common/Logging.h 2013-04-18 21:21:33 UTC (rev 1913) @@ -0,0 +1,42 @@ +/* + * Logging.h + * --------- + * Purpose: General logging and user confirmation support + * Notes : (currently none) + * Authors: OpenMPT Devs + * The OpenMPT source code is released under the BSD license. Read LICENSE for more details. + */ + +#pragma once + + +enum LogLevel +{ + /*LogDebug = 1,*/ + LogNotification = 2, + LogInformation = 3, + LogWarning = 4, + LogError = 5, +}; + + +inline std::string LogLevelToString(LogLevel level) +{ + switch(level) + { + case LogError: return "error"; break; + case LogWarning: return "warning"; break; + case LogInformation: return "info"; break; + case LogNotification: return "notify"; break; + } + return "unknown"; +} + + +class ILog +{ +public: + virtual void AddToLog(const std::string &text) const { AddToLog(LogInformation, text); } + virtual void AddToLog(LogLevel level, const std::string &text) const = 0; +}; + Property changes on: trunk/OpenMPT/common/Logging.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 Deleted: trunk/OpenMPT/common/Reporting.cpp =================================================================== --- trunk/OpenMPT/common/Reporting.cpp 2013-04-18 20:23:43 UTC (rev 1912) +++ trunk/OpenMPT/common/Reporting.cpp 2013-04-18 21:21:33 UTC (rev 1913) @@ -1,149 +0,0 @@ -/* - * Reporting.cpp - * ------------- - * Purpose: A class for showing notifications, prompts, etc... - * Notes : (currently none) - * Authors: OpenMPT Devs - * The OpenMPT source code is released under the BSD license. Read LICENSE for more details. - */ - - -#include "Stdafx.h" -#include "Reporting.h" -#ifdef MODPLUG_TRACKER -#include "../mptrack/Mainfrm.h" -#else -#include <iostream> -#endif // MODPLUG_TRACKER - - -UINT Reporting::ShowNotification(const char *text, const char *caption, UINT flags, const CWnd *parent) -//----------------------------------------------------------------------------------------------------- -{ -#ifdef MODPLUG_TRACKER - CMainFrame *pMainFrm = CMainFrame::GetMainFrame(); - - if(pMainFrm != nullptr && pMainFrm->GetInputHandler() != nullptr) - { - pMainFrm->GetInputHandler()->Bypass(true); - } - - if(parent == nullptr) - { - parent = pMainFrm; - } - UINT result = ::MessageBox((parent ? parent->m_hWnd : NULL), text, caption, flags); - - if(pMainFrm != nullptr && pMainFrm->GetInputHandler() != nullptr) - { - pMainFrm->GetInputHandler()->Bypass(false); - } - - return result; -#else - std::clog << caption << std::endl << text << std::endl; - return 0; -#endif // MODPLUG_TRACKER -} - - -void Reporting::Notification(const char *text, const CWnd *parent) -//---------------------------------------------------------------- -{ - Notification(text, MAINFRAME_TITLE, parent); -} - - -void Reporting::Notification(const char *text, const char *caption, const CWnd *parent) -//------------------------------------------------------------------------------------- -{ - ShowNotification(text, caption, MB_OK, parent); -} - - -void Reporting::Information(const char *text, const CWnd *parent) -//--------------------------------------------------------------- -{ - Information(text, MAINFRAME_TITLE, parent); -} - - -void Reporting::Information(const char *text, const char *caption, const CWnd *parent) -//------------------------------------------------------------------------------------ -{ - ShowNotification(text, caption, MB_OK | MB_ICONINFORMATION, parent); -} - - -void Reporting::Warning(const char *text, const CWnd *parent) -//----------------------------------------------------------- -{ - Warning(text, MAINFRAME_TITLE " - Warning", parent); -} - - -void Reporting::Warning(const char *text, const char *caption, const CWnd *parent) -//-------------------------------------------------------------------------------- -{ - ShowNotification(text, caption, MB_OK | MB_ICONWARNING, parent); -} - - -void Reporting::Error(const char *text, const CWnd *parent) -//--------------------------------------------------------- -{ - Error(text, MAINFRAME_TITLE " - Error", parent); -} - - -void Reporting::Error(const char *text, const char *caption, const CWnd *parent) -//------------------------------------------------------------------------------ -{ - ShowNotification(text, caption, MB_OK | MB_ICONERROR, parent); -} - - -ConfirmAnswer Reporting::Confirm(const char *text, bool showCancel, bool defaultNo, const CWnd *parent) -//----------------------------------------------------------------------------------------------------- -{ - return Confirm(text, MAINFRAME_TITLE " - Confirmation", showCancel, defaultNo, parent); -} - - -ConfirmAnswer Reporting::Confirm(const char *text, const char *caption, bool showCancel, bool defaultNo, const CWnd *parent) -//-------------------------------------------------------------------------------------------------------------------------- -{ - UINT result = ShowNotification(text, caption, (showCancel ? MB_YESNOCANCEL : MB_YESNO) | MB_ICONQUESTION | (defaultNo ? MB_DEFBUTTON2 : 0), parent); - switch(result) - { - case IDYES: - return cnfYes; - case IDNO: - return cnfNo; - default: - case IDCANCEL: - return cnfCancel; - } -} - - -RetryAnswer Reporting::RetryCancel(const char *text, const CWnd *parent) -//---------------------------------------------------------------------- -{ - return RetryCancel(text, MAINFRAME_TITLE, parent); -} - - -RetryAnswer Reporting::RetryCancel(const char *text, const char *caption, const CWnd *parent) -//------------------------------------------------------------------------------------------- -{ - UINT result = ShowNotification(text, caption, MB_RETRYCANCEL, parent); - switch(result) - { - case IDRETRY: - return rtyRetry; - default: - case IDCANCEL: - return rtyCancel; - } -} Deleted: trunk/OpenMPT/common/Reporting.h =================================================================== --- trunk/OpenMPT/common/Reporting.h 2013-04-18 20:23:43 UTC (rev 1912) +++ trunk/OpenMPT/common/Reporting.h 2013-04-18 21:21:33 UTC (rev 1913) @@ -1,66 +0,0 @@ -/* - * Reporting.h - * ----------- - * Purpose: A class for showing notifications, prompts, etc... - * Notes : (currently none) - * Authors: OpenMPT Devs - * The OpenMPT source code is released under the BSD license. Read LICENSE for more details. - */ - - -#pragma once - -enum ConfirmAnswer -{ - cnfYes, - cnfNo, - cnfCancel, -}; - -enum RetryAnswer -{ - rtyRetry, - rtyCancel, -}; - -//============= -class Reporting -//============= -{ - -protected: - - static UINT ShowNotification(const char *text, const char *caption, UINT flags, const CWnd *parent); - -public: - -#ifdef MODPLUG_TRACKER - // TODO Quick'n'dirty workaround for MsgBox(). Shouldn't be public. - static UINT CustomNotification(const char *text, const char *caption, UINT flags, const CWnd *parent) { return ShowNotification(text, caption, flags, parent); }; -#endif // MODPLUG_TRACKER - - // Show a simple notification - static void Notification(const char *text, const CWnd *parent = nullptr); - static void Notification(const char *text, const char *caption, const CWnd *parent = nullptr); - - // Show a simple information - static void Information(const char *text, const CWnd *parent = nullptr); - static void Information(const char *text, const char *caption, const CWnd *parent = nullptr); - - // Show a simple warning - static void Warning(const char *text, const CWnd *parent = nullptr); - static void Warning(const char *text, const char *caption, const CWnd *parent = nullptr); - - // Show an error box. - static void Error(const char *text, const CWnd *parent = nullptr); - static void Error(const char *text, const char *caption, const CWnd *parent = nullptr); - - // Show a confirmation dialog. - static ConfirmAnswer Confirm(const char *text, bool showCancel = false, bool defaultNo = false, const CWnd *parent = nullptr); - static ConfirmAnswer Confirm(const char *text, const char *caption, bool showCancel = false, bool defaultNo = false, const CWnd *parent = nullptr); - - // Show a confirmation dialog. - static RetryAnswer RetryCancel(const char *text, const CWnd *parent = nullptr); - static RetryAnswer RetryCancel(const char *text, const char *caption, const CWnd *parent = nullptr); - -}; Modified: trunk/OpenMPT/mptrack/CleanupSong.cpp =================================================================== --- trunk/OpenMPT/mptrack/CleanupSong.cpp 2013-04-18 20:23:43 UTC (rev 1912) +++ trunk/OpenMPT/mptrack/CleanupSong.cpp 2013-04-18 21:21:33 UTC (rev 1913) @@ -120,13 +120,13 @@ void CModCleanupDlg::OnOK() //------------------------- { + ScopedLogCapturer logcapturer(modDoc, "cleanup", this); for(int i = 0; i < CU_MAX_CLEANUP_OPTIONS; i++) { m_bCheckBoxes[i] = IsDlgButtonChecked(m_nCleanupIDtoDlgID[i]) != BST_UNCHECKED; } bool bModified = false; - modDoc.ClearLog(); // Orders if(m_bCheckBoxes[CU_MERGE_SEQUENCES]) bModified |= MergeSequences(); @@ -162,7 +162,7 @@ if(bModified) modDoc.SetModified(); modDoc.UpdateAllViews(NULL, HINT_MODTYPE | HINT_MODSEQUENCE | HINT_MODGENERAL | HINT_SMPNAMES | HINT_INSNAMES); - modDoc.ShowLog("Cleanup", this); + logcapturer.ShowLog(true); CDialog::OnOK(); } Modified: trunk/OpenMPT/mptrack/CommandSet.cpp =================================================================== --- trunk/OpenMPT/mptrack/CommandSet.cpp 2013-04-18 20:23:43 UTC (rev 1912) +++ trunk/OpenMPT/mptrack/CommandSet.cpp 2013-04-18 21:21:33 UTC (rev 1913) @@ -13,7 +13,7 @@ #include "resource.h" #include "Mptrack.h" // For MsgBox #include "../soundlib/mod_specifications.h" -#include "../common/Reporting.h" +#include "../mptrack/Reporting.h" #include <stdio.h> #include <stdlib.h> #include <fstream> Modified: trunk/OpenMPT/mptrack/MIDIMacroDialog.cpp =================================================================== --- trunk/OpenMPT/mptrack/MIDIMacroDialog.cpp 2013-04-18 20:23:43 UTC (rev 1912) +++ trunk/OpenMPT/mptrack/MIDIMacroDialog.cpp 2013-04-18 21:21:33 UTC (rev 1913) @@ -9,7 +9,7 @@ #include "stdafx.h" -#include "../common/Reporting.h" +#include "../mptrack/Reporting.h" #include "../common/StringFixer.h" #include "Mainfrm.h" #include "mptrack.h" Modified: trunk/OpenMPT/mptrack/Moddoc.cpp =================================================================== --- trunk/OpenMPT/mptrack/Moddoc.cpp 2013-04-18 20:23:43 UTC (rev 1912) +++ trunk/OpenMPT/mptrack/Moddoc.cpp 2013-04-18 21:21:33 UTC (rev 1913) @@ -118,8 +118,8 @@ ///////////////////////////////////////////////////////////////////////////// // CModDoc construction/destruction -CModDoc::CModDoc() : m_PatternUndo(*this), m_SampleUndo(*this) -//------------------------------------------------------------ +CModDoc::CModDoc() : m_LogMode(LogModeInstantReporting), m_PatternUndo(*this), m_SampleUndo(*this) +//------------------------------------------------------------------------------------------------ { m_bHasValidPath = false; m_hWndFollow = NULL; @@ -201,6 +201,8 @@ BOOL bModified = TRUE; CMappedFile f; + ScopedLogCapturer logcapturer(*this); + if (!lpszPathName) return OnNewDocument(); BeginWaitCursor(); if (f.Open(lpszPathName)) @@ -220,14 +222,12 @@ EndWaitCursor(); - // Show log messages from loaders. - if (GetLog().size() > 0) - { - CString sTemp; - sTemp.Format("File: %s\nLast saved with: %s, your version is %s\n\n%s", lpszPathName, (LPCTSTR)MptVersion::ToStr(m_SndFile.m_dwLastSavedWithVersion), MptVersion::str, GetLogString().c_str()); - Reporting::Information(sTemp); - ClearLog(); - } + std::ostringstream str; + str + << "File: " << lpszPathName << std::endl + << "Last saved with: " << MptVersion::ToStr(m_SndFile.m_dwLastSavedWithVersion) << ", your version is " << MptVersion::str << std::endl + << std::endl; + logcapturer.ShowLog(str.str()); if ((m_SndFile.m_nType == MOD_TYPE_NONE) || (!m_SndFile.GetNumChannels())) return FALSE; // Midi Import @@ -428,6 +428,7 @@ BOOL CModDoc::OnSaveDocument(LPCTSTR lpszPathName, const bool bTemplateFile) //-------------------------------------------------------------------------- { + ScopedLogCapturer logcapturer(*this); static int greccount = 0; BOOL bOk = FALSE; m_SndFile.m_dwLastSavedWithVersion = MptVersion::num; @@ -443,7 +444,6 @@ return bOk; } BeginWaitCursor(); - ClearLog(); FixNullStrings(); switch(type) { @@ -461,7 +461,7 @@ // Set new path for this file, unless we are saving a template, in which case we want to keep the old file path. SetPathName(lpszPathName); } - ShowLog(); + logcapturer.ShowLog(true); if (bTemplateFile) { // Update template menu. @@ -808,25 +808,88 @@ } -void CModDoc::AddToLog(const std::string &text) -//--------------------------------------------- +ScopedLogCapturer::ScopedLogCapturer(CModDoc &modDoc, const std::string &title, CWnd *parent) : +m_modDoc(modDoc), m_oldLogMode(m_modDoc.GetLogMode()), m_title(title), m_pParent(parent) +//--------------------------------------------------------------------------------------------- { - m_Log.push_back(text); + m_modDoc.SetLogMode(LogModeGather); } +void ScopedLogCapturer::ShowLog(bool force) +//---------------------------------------- +{ + if(force || m_oldLogMode == LogModeInstantReporting) + { + m_modDoc.ShowLog(m_title, m_pParent); + m_modDoc.ClearLog(); + } +} + + +void ScopedLogCapturer::ShowLog(const std::string &preamble, bool force) +//---------------------------------------------------------------------- +{ + if(force || m_oldLogMode == LogModeInstantReporting) + { + m_modDoc.ShowLog(preamble, m_title, m_pParent); + m_modDoc.ClearLog(); + } +} + + +ScopedLogCapturer::~ScopedLogCapturer() +//------------------------------------- +{ + ShowLog(); + m_modDoc.SetLogMode(m_oldLogMode); +} + + +void CModDoc::AddToLog(LogLevel level, const std::string &text) const +//------------------------------------------------------------------- +{ + if(m_LogMode == LogModeGather) + { + m_Log.push_back(LogEntry(level, text)); + } else + { + switch(level) + { + case LogError: Reporting::Error(text.c_str()); break; + case LogWarning: Reporting::Warning(text.c_str()); break; + case LogInformation: Reporting::Information(text.c_str()); break; + case LogNotification: Reporting::Notification(text.c_str()); break; + default: Reporting::Information(text.c_str()); break; + } + } +} + + std::string CModDoc::GetLogString() const //--------------------------------------- { std::ostringstream ret; - for(std::vector<std::string>::const_iterator i=m_Log.begin(); i!=m_Log.end(); ++i) + for(std::vector<LogEntry>::const_iterator i=m_Log.begin(); i!=m_Log.end(); ++i) { - ret << *i << std::endl; + ret << (*i).message << "\r\n";//std::endl; } return ret.str(); } +LogLevel CModDoc::GetMaxLogLevel() const +//-------------------------------------- +{ + LogLevel retval = LogNotification; + for(std::vector<LogEntry>::const_iterator i=m_Log.begin(); i!=m_Log.end(); ++i) + { + retval = std::max(retval, i->level); + } + return retval; +} + + void CModDoc::ClearLog() //---------------------- { @@ -834,13 +897,22 @@ } -UINT CModDoc::ShowLog(LPCSTR lpszTitle, CWnd *parent) -//--------------------------------------------------- +UINT CModDoc::ShowLog(const std::string &preamble, const std::string &title, CWnd *parent) +//---------------------------------------------------------------------------------------- { - if(!lpszTitle) lpszTitle = MAINFRAME_TITLE; + if(!parent) parent = CMainFrame::GetMainFrame(); if(GetLog().size() > 0) { - Reporting::Information(GetLogString().c_str(), lpszTitle, parent); + std::string text = preamble + GetLogString(); + std::string actualTitle = (title.length() == 0) ? std::string(MAINFRAME_TITLE) : title; + switch(GetMaxLogLevel()) + { + case LogError: Reporting::Error(text.c_str(), actualTitle.c_str(), parent); break; + case LogWarning: Reporting::Warning(text.c_str(), actualTitle.c_str(), parent); break; + case LogInformation: Reporting::Information(text.c_str(), actualTitle.c_str(), parent); break; + case LogNotification: Reporting::Notification(text.c_str(), actualTitle.c_str(), parent); break; + default: Reporting::Information(text.c_str(), actualTitle.c_str(), parent); break; + } return IDOK; } return IDCANCEL; @@ -1899,7 +1971,7 @@ FileDlgResult files = CTrackApp::ShowOpenSaveFileDialog(false, ext, filename, pattern, TrackerSettings::Instance().GetWorkingDirectory(DIR_MODS)); if(files.abort) return; - ClearLog(); + ScopedLogCapturer logcapturer(*this); FixNullStrings(); switch (type) { @@ -1910,7 +1982,6 @@ m_SndFile.SaveIT(files.first_file.c_str(), true); break; } - ShowLog(); } @@ -2480,12 +2551,11 @@ void CModDoc::OnViewMPTHacks() //---------------------------- { + ScopedLogCapturer logcapturer(*this); if(!HasMPTHacks()) { AddToLog("No hacks found."); } - ShowLog(); - ClearLog(); } @@ -2676,8 +2746,8 @@ CModTypeDlg dlg(m_SndFile, CMainFrame::GetMainFrame()); if (dlg.DoModal() == IDOK) { + ScopedLogCapturer logcapturer(*this, "Conversion Status"); bool bShowLog = false; - ClearLog(); if(dlg.m_nType) { if (!ChangeModType(dlg.m_nType)) return; @@ -2697,7 +2767,6 @@ SetModified(); - if (bShowLog) ShowLog("Conversion Status", CMainFrame::GetMainFrame()); } } Modified: trunk/OpenMPT/mptrack/Moddoc.h =================================================================== --- trunk/OpenMPT/mptrack/Moddoc.h 2013-04-18 20:23:43 UTC (rev 1912) +++ trunk/OpenMPT/mptrack/Moddoc.h 2013-04-18 21:21:33 UTC (rev 1913) @@ -14,6 +14,7 @@ #include "../common/misc_util.h" #include "Undo.h" #include "Notification.h" +#include "../common/Logging.h" #include <time.h> @@ -139,12 +140,46 @@ enum InputTargetContext; + +struct LogEntry +{ + LogLevel level; + std::string message; + LogEntry() : level(LogInformation) {} + LogEntry(LogLevel l, const std::string &m) : level(l), message(m) {} +}; + + +enum LogMode +{ + LogModeInstantReporting, + LogModeGather, +}; + + +class ScopedLogCapturer +{ +private: + CModDoc &m_modDoc; + LogMode m_oldLogMode; + std::string m_title; + CWnd *m_pParent; +public: + ScopedLogCapturer(CModDoc &modDoc, const std::string &title = "", CWnd *parent = nullptr); + ~ScopedLogCapturer(); + void ShowLog(bool force = false); + void ShowLog(const std::string &preamble, bool force = false); +}; + + //============================= class CModDoc: public CDocument //============================= { protected: - std::vector<std::string> m_Log; + friend ScopedLogCapturer; + mutable std::vector<LogEntry> m_Log; + LogMode m_LogMode; CSoundFile m_SndFile; HWND m_hWndFollow; @@ -190,11 +225,21 @@ SAMPLEINDEX GetNumSamples() const { return m_SndFile.m_nSamples; } // Logging for general progress and error events. - void AddToLog(const std::string &text); - const std::vector<std::string> & GetLog() const { return m_Log; } + void AddToLog(LogLevel level, const std::string &text) const; + void AddToLog(const std::string &text) const { AddToLog(LogInformation, text); } + + const std::vector<LogEntry> & GetLog() const { return m_Log; } std::string GetLogString() const; + LogLevel GetMaxLogLevel() const; +protected: + LogMode GetLogMode() const { return m_LogMode; } + void SetLogMode(LogMode mode) { m_LogMode = mode; } void ClearLog(); - UINT ShowLog(LPCSTR lpszTitle=NULL, CWnd *parent=NULL); + UINT ShowLog(const std::string &preamble, const std::string &title = "", CWnd *parent = nullptr); + UINT ShowLog(const std::string &title = "", CWnd *parent = nullptr) { return ShowLog("", title, parent); } + +public: + void ClearFilePath() { m_strPathName.Empty(); } void ViewPattern(UINT nPat, UINT nOrd); Modified: trunk/OpenMPT/mptrack/Mptrack.h =================================================================== --- trunk/OpenMPT/mptrack/Mptrack.h 2013-04-18 20:23:43 UTC (rev 1912) +++ trunk/OpenMPT/mptrack/Mptrack.h 2013-04-18 21:21:33 UTC (rev 1913) @@ -13,7 +13,7 @@ #include "resource.h" // main symbols #include "ACMConvert.h" #include <windows.h> -#include "../common/Reporting.h" +#include "../mptrack/Reporting.h" #include "../soundlib/MIDIMacros.h" #include "../soundlib/modcommand.h" #include <vector> Added: trunk/OpenMPT/mptrack/Reporting.cpp =================================================================== --- trunk/OpenMPT/mptrack/Reporting.cpp (rev 0) +++ trunk/OpenMPT/mptrack/Reporting.cpp 2013-04-18 21:21:33 UTC (rev 1913) @@ -0,0 +1,140 @@ +/* + * Reporting.cpp + * ------------- + * Purpose: A class for showing notifications, prompts, etc... + * Notes : (currently none) + * Authors: OpenMPT Devs + * The OpenMPT source code is released under the BSD license. Read LICENSE for more details. + */ + + +#include "Stdafx.h" +#include "Reporting.h" +#include "../mptrack/Mainfrm.h" + + +UINT Reporting::ShowNotification(const char *text, const char *caption, UINT flags, const CWnd *parent) +//----------------------------------------------------------------------------------------------------- +{ + CMainFrame *pMainFrm = CMainFrame::GetMainFrame(); + + if(pMainFrm != nullptr && pMainFrm->GetInputHandler() != nullptr) + { + pMainFrm->GetInputHandler()->Bypass(true); + } + + if(parent == nullptr) + { + parent = pMainFrm; + } + UINT result = ::MessageBox((parent ? parent->m_hWnd : NULL), text, caption, flags); + + if(pMainFrm != nullptr && pMainFrm->GetInputHandler() != nullptr) + { + pMainFrm->GetInputHandler()->Bypass(false); + } + + return result; +} + + +void Reporting::Notification(const char *text, const CWnd *parent) +//---------------------------------------------------------------- +{ + Notification(text, MAINFRAME_TITLE, parent); +} + + +void Reporting::Notification(const char *text, const char *caption, const CWnd *parent) +//------------------------------------------------------------------------------------- +{ + ShowNotification(text, caption, MB_OK, parent); +} + + +void Reporting::Information(const char *text, const CWnd *parent) +//--------------------------------------------------------------- +{ + Information(text, MAINFRAME_TITLE, parent); +} + + +void Reporting::Information(const char *text, const char *caption, const CWnd *parent) +//------------------------------------------------------------------------------------ +{ + ShowNotification(text, caption, MB_OK | MB_ICONINFORMATION, parent); +} + + +void Reporting::Warning(const char *text, const CWnd *parent) +//----------------------------------------------------------- +{ + Warning(text, MAINFRAME_TITLE " - Warning", parent); +} + + +void Reporting::Warning(const char *text, const char *caption, const CWnd *parent) +//-------------------------------------------------------------------------------- +{ + ShowNotification(text, caption, MB_OK | MB_ICONWARNING, parent); +} + + +void Reporting::Error(const char *text, const CWnd *parent) +//--------------------------------------------------------- +{ + Error(text, MAINFRAME_TITLE " - Error", parent); +} + + +void Reporting::Error(const char *text, const char *caption, const CWnd *parent) +//------------------------------------------------------------------------------ +{ + ShowNotification(text, caption, MB_OK | MB_ICONERROR, parent); +} + + +ConfirmAnswer Reporting::Confirm(const char *text, bool showCancel, bool defaultNo, const CWnd *parent) +//----------------------------------------------------------------------------------------------------- +{ + return Confirm(text, MAINFRAME_TITLE " - Confirmation", showCancel, defaultNo, parent); +} + + +ConfirmAnswer Reporting::Confirm(const char *text, const char *caption, bool showCancel, bool defaultNo, const CWnd *parent) +//-------------------------------------------------------------------------------------------------------------------------- +{ + UINT result = ShowNotification(text, caption, (showCancel ? MB_YESNOCANCEL : MB_YESNO) | MB_ICONQUESTION | (defaultNo ? MB_DEFBUTTON2 : 0), parent); + switch(result) + { + case IDYES: + return cnfYes; + case IDNO: + return cnfNo; + default: + case IDCANCEL: + return cnfCancel; + } +} + + +RetryAnswer Reporting::RetryCancel(const char *text, const CWnd *parent) +//---------------------------------------------------------------------- +{ + return RetryCancel(text, MAINFRAME_TITLE, parent); +} + + +RetryAnswer Reporting::RetryCancel(const char *text, const char *caption, const CWnd *parent) +//------------------------------------------------------------------------------------------- +{ + UINT result = ShowNotification(text, caption, MB_RETRYCANCEL, parent); + switch(result) + { + case IDRETRY: + return rtyRetry; + default: + case IDCANCEL: + return rtyCancel; + } +} Property changes on: trunk/OpenMPT/mptrack/Reporting.cpp ___________________________________________________________________ Added: svn:mime-type ## -0,0 +1 ## +text/x-c++src \ No newline at end of property Added: svn:eol-style ## -0,0 +1 ## +native \ No newline at end of property Added: trunk/OpenMPT/mptrack/Reporting.h =================================================================== --- trunk/OpenMPT/mptrack/Reporting.h (rev 0) +++ trunk/OpenMPT/mptrack/Reporting.h 2013-04-18 21:21:33 UTC (rev 1913) @@ -0,0 +1,67 @@ +/* + * Reporting.h + * ----------- + * Purpose: A class for showing notifications, prompts, etc... + * Notes : (currently none) + * Authors: OpenMPT Devs + * The OpenMPT source code is released under the BSD license. Read LICENSE for more details. + */ + + +#pragma once + + +enum ConfirmAnswer +{ + cnfYes, + cnfNo, + cnfCancel, +}; + + +enum RetryAnswer +{ + rtyRetry, + rtyCancel, +}; + + +//============= +class Reporting +//============= +{ + +protected: + + static UINT ShowNotification(const char *text, const char *caption, UINT flags, const CWnd *parent); + +public: + + // TODO Quick'n'dirty workaround for MsgBox(). Shouldn't be public. + static UINT CustomNotification(const char *text, const char *caption, UINT flags, const CWnd *parent) { return ShowNotification(text, caption, flags, parent); }; + + // Show a simple notification + static void Notification(const char *text, const CWnd *parent = nullptr); + static void Notification(const char *text, const char *caption, const CWnd *parent = nullptr); + + // Show a simple information + static void Information(const char *text, const CWnd *parent = nullptr); + static void Information(const char *text, const char *caption, const CWnd *parent = nullptr); + + // Show a simple warning + static void Warning(const char *text, const CWnd *parent = nullptr); + static void Warning(const char *text, const char *caption, const CWnd *parent = nullptr); + + // Show an error box. + static void Error(const char *text, const CWnd *parent = nullptr); + static void Error(const char *text, const char *caption, const CWnd *parent = nullptr); + + // Show a confirmation dialog. + static ConfirmAnswer Confirm(const char *text, bool showCancel = false, bool defaultNo = false, const CWnd *parent = nullptr); + static ConfirmAnswer Confirm(const char *text, const char *caption, bool showCancel = false, bool defaultNo = false, const CWnd *parent = nullptr); + + // Show a confirmation dialog. + static RetryAnswer RetryCancel(const char *text, const CWnd *parent = nullptr); + static RetryAnswer RetryCancel(const char *text, const char *caption, const CWnd *parent = nullptr); + +}; Property changes on: trunk/OpenMPT/mptrack/Reporting.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/mptrack/mptrack_08.vcproj =================================================================== --- trunk/OpenMPT/mptrack/mptrack_08.vcproj 2013-04-18 20:23:43 UTC (rev 1912) +++ trunk/OpenMPT/mptrack/mptrack_08.vcproj 2013-04-18 21:21:33 UTC (rev 1913) @@ -481,7 +481,7 @@ > </File> <File - RelativePath="..\common\Reporting.cpp" + RelativePath="..\mptrack\Reporting.cpp" > </File> <File @@ -1023,10 +1023,14 @@ > </File> <File - RelativePath="..\common\Reporting.h" + RelativePath="..\common\Logging.h" > </File> <File + RelativePath="..\mptrack\Reporting.h" + > + </File> + <File RelativePath="..\soundlib\Resampler.h" > </File> Modified: trunk/OpenMPT/mptrack/mptrack_10.vcxproj =================================================================== --- trunk/OpenMPT/mptrack/mptrack_10.vcxproj 2013-04-18 20:23:43 UTC (rev 1912) +++ trunk/OpenMPT/mptrack/mptrack_10.vcxproj 2013-04-18 21:21:33 UTC (rev 1913) @@ -248,7 +248,6 @@ <ClCompile Include="..\common\misc_util.cpp" /> <ClCompile Include="..\common\mptString.cpp" /> <ClCompile Include="..\common\Profiler.cpp" /> - <ClCompile Include="..\common\Reporting.cpp" /> <ClCompile Include="..\common\serialization_utils.cpp" /> <ClCompile Include="..\common\typedefs.cpp" /> <ClCompile Include="..\sounddev\SoundDevice.cpp" /> @@ -338,6 +337,7 @@ <ClCompile Include="PatternEditorDialogs.cpp" /> <ClCompile Include="PatternGotoDialog.cpp" /> <ClCompile Include="PSRatioCalc.cpp" /> + <ClCompile Include="Reporting.cpp" /> <ClCompile Include="SampleEditorDialogs.cpp" /> <ClCompile Include="ScaleEnvPointsDlg.cpp" /> <ClCompile Include="..\common\stdafx.cpp"> @@ -402,11 +402,11 @@ <ItemGroup> <ClInclude Include="..\common\AudioCriticalSection.h" /> <ClInclude Include="..\common\FlagSet.h" /> + <ClInclude Include="..\common\Logging.h" /> <ClInclude Include="..\common\misc_util.h" /> <ClInclude Include="..\common\mptString.h" /> <ClInclude Include="..\common\mutex.h" /> <ClInclude Include="..\common\Profiler.h" /> - <ClInclude Include="..\common\Reporting.h" /> <ClInclude Include="..\common\serialization_utils.h" /> <ClInclude Include="..\common\StringFixer.h" /> <ClInclude Include="..\common\typedefs.h" /> @@ -484,6 +484,7 @@ <ClInclude Include="Notification.h" /> <ClInclude Include="PatternClipboard.h" /> <ClInclude Include="PatternCursor.h" /> + <ClInclude Include="Reporting.h" /> <ClInclude Include="SelectPluginDialog.h" /> <ClInclude Include="ChannelManagerDlg.h" /> <ClInclude Include="CloseMainDialog.h" /> Modified: trunk/OpenMPT/mptrack/mptrack_10.vcxproj.filters =================================================================== --- trunk/OpenMPT/mptrack/mptrack_10.vcxproj.filters 2013-04-18 20:23:43 UTC (rev 1912) +++ trunk/OpenMPT/mptrack/mptrack_10.vcxproj.filters 2013-04-18 21:21:33 UTC (rev 1913) @@ -277,9 +277,6 @@ <ClCompile Include="..\common\Profiler.cpp"> <Filter>Source Files\common</Filter> </ClCompile> - <ClCompile Include="..\common\Reporting.cpp"> - <Filter>Source Files\common</Filter> - </ClCompile> <ClCompile Include="AbstractVstEditor.cpp"> <Filter>Source Files\mptrack</Filter> </ClCompile> @@ -436,6 +433,9 @@ <ClCompile Include="..\common\typedefs.cpp"> <Filter>Source Files\common</Filter> </ClCompile> + <ClCompile Include="Reporting.cpp"> + <Filter>Source Files\mptrack</Filter> + </ClCompile> </ItemGroup> <ItemGroup> <ClInclude Include="..\soundlib\Loaders.h"> @@ -648,9 +648,6 @@ <ClInclude Include="..\common\Profiler.h"> <Filter>Header Files\common</Filter> </ClInclude> - <ClInclude Include="..\common\Reporting.h"> - <Filter>Header Files\common</Filter> - </ClInclude> <ClInclude Include="..\common\serialization_utils.h"> <Filter>Header Files\common</Filter> </ClInclude> @@ -798,6 +795,12 @@ <ClInclude Include="Vstplug.h"> <Filter>Header Files\mptrack</Filter> </ClInclude> + <ClInclude Include="..\common\Logging.h"> + <Filter>Header Files\common</Filter> + </ClInclude> + <ClInclude Include="Reporting.h"> + <Filter>Header Files\mptrack</Filter> + </ClInclude> </ItemGroup> <ItemGroup> <None Include="res\bitmap1.bmp"> Modified: trunk/OpenMPT/sounddev/SoundDevice.cpp =================================================================== --- trunk/OpenMPT/sounddev/SoundDevice.cpp 2013-04-18 20:23:43 UTC (rev 1912) +++ trunk/OpenMPT/sounddev/SoundDevice.cpp 2013-04-18 21:21:33 UTC (rev 1913) @@ -14,7 +14,7 @@ #include "SoundDevice.h" #include "SoundDevices.h" #include "../common/misc_util.h" -#include "../common/Reporting.h" +#include "../mptrack/Reporting.h" #include "../common/StringFixer.h" Modified: trunk/OpenMPT/soundlib/ITCompression.cpp =================================================================== --- trunk/OpenMPT/soundlib/ITCompression.cpp 2013-04-18 20:23:43 UTC (rev 1912) +++ trunk/OpenMPT/soundlib/ITCompression.cpp 2013-04-18 21:21:33 UTC (rev 1913) @@ -12,6 +12,9 @@ #include <stdafx.h> #include "ITCompression.h" #include "../common/misc_util.h" +#ifdef MODPLUG_TRACKER +#include "../mptrack/Reporting.h" +#endif // Algorithm parameters for 16-Bit samples struct IT16BitParams Modified: trunk/OpenMPT/soundlib/Mmx_mix.cpp =================================================================== --- trunk/OpenMPT/soundlib/Mmx_mix.cpp 2013-04-18 20:23:43 UTC (rev 1912) +++ trunk/OpenMPT/soundlib/Mmx_mix.cpp 2013-04-18 21:21:33 UTC (rev 1913) @@ -22,7 +22,6 @@ #include "stdafx.h" #include "sndfile.h" -#include "../common/Reporting.h" DWORD CSoundFile::GetSysInfo() Modified: trunk/OpenMPT/soundlib/ModSequence.cpp =================================================================== --- trunk/OpenMPT/soundlib/ModSequence.cpp 2013-04-18 20:23:43 UTC (rev 1912) +++ trunk/OpenMPT/soundlib/ModSequence.cpp 2013-04-18 21:21:33 UTC (rev 1913) @@ -13,10 +13,10 @@ #include "ModSequence.h" #ifdef MODPLUG_TRACKER #include "../mptrack/moddoc.h" +#include "../mptrack/Reporting.h" #endif // MODPLUG_TRACKER #include "../common/version.h" #include "../common/serialization_utils.h" -#include "../common/Reporting.h" #include "FileReader.h" #include <functional> @@ -444,8 +444,13 @@ bool modified = false; if(hasSepPatterns && +#ifdef MODPLUG_TRACKER Reporting::Confirm("The order list contains separator items.\nThe new format supports multiple sequences, do you want to convert those separate tracks into multiple song sequences?", - "Order list conversion", false, true) == cnfYes) + "Order list conversion", false, true) == cnfYes +#else + false +#endif + ) { SetSequence(0); Modified: trunk/OpenMPT/soundlib/SampleFormats.cpp =================================================================== --- trunk/OpenMPT/soundlib/SampleFormats.cpp 2013-04-18 20:23:43 UTC (rev 1912) +++ trunk/OpenMPT/soundlib/SampleFormats.cpp 2013-04-18 21:21:33 UTC (rev 1913) @@ -14,13 +14,13 @@ #ifdef MODPLUG_TRACKER #include "../mptrack/Moddoc.h" #include "../mptrack/Mainfrm.h" // For ini settings +#include "../mptrack/Reporting.h" #endif //MODPLUG_TRACKER #include "../common/AudioCriticalSection.h" #include "Wav.h" #include "ITTools.h" #include "XMTools.h" #include "WAVTools.h" -#include "../common/Reporting.h" #include "../common/version.h" #include "ChunkReader.h" Modified: trunk/OpenMPT/soundlib/Sndfile.cpp =================================================================== --- trunk/OpenMPT/soundlib/Sndfile.cpp 2013-04-18 20:23:43 UTC (rev 1912) +++ trunk/OpenMPT/soundlib/Sndfile.cpp 2013-04-18 21:21:33 UTC (rev 1913) @@ -13,6 +13,7 @@ #ifdef MODPLUG_TRACKER #include "../mptrack/mainfrm.h" #include "../mptrack/moddoc.h" +#include "../mptrack/Reporting.h" #endif // MODPLUG_TRACKER #include "../common/version.h" #include "../common/serialization_utils.h" @@ -20,6 +21,7 @@ #include "tuningcollection.h" #include "../common/StringFixer.h" #include "FileReader.h" +#include <iostream> #ifndef NO_ARCHIVE_SUPPORT #include "../unarchiver/unarchiver.h" @@ -386,7 +388,8 @@ Order(*this), m_pModSpecs(&ModSpecs::itEx), m_MIDIMapper(*this), - visitedSongRows(*this) + visitedSongRows(*this), + m_pCustomLog(nullptr) #pragma warning(default : 4355) // "'this' : used in base member initializer list" //---------------------- { @@ -452,14 +455,16 @@ } -void CSoundFile::AddToLog(const std::string &text) const -//------------------------------------------------------ +void CSoundFile::AddToLog(LogLevel level, const std::string &text) const +//---------------------------------------------------------------------- { -#ifdef MODPLUG_TRACKER - if(GetpModDoc()) GetpModDoc()->AddToLog(text); -#else - Reporting::Warning(text.c_str()); -#endif + if(m_pCustomLog) + return m_pCustomLog->AddToLog(level, text); + #ifdef MODPLUG_TRACKER + if(GetpModDoc()) GetpModDoc()->AddToLog(level, text); + #else + std::clog << "openmpt: " << LogLevelToString(level) << ": " << text << std::endl; + #endif } @@ -1480,12 +1485,12 @@ bool CSoundFile::SaveStaticTunings() //---------------------------------- { - if(s_pTuningsSharedLocal->Serialize()) + if(s_pTuningsSharedLocal->Serialize() != CTuningCollection::SERIALIZATION_SUCCESS) { - ErrorBox(IDS_ERR_TUNING_SERIALISATION, NULL); - return true; + AddToLog(LogError, "Static tuning serialisation failed"); + return false; } - return false; + return true; } #endif Modified: trunk/OpenMPT/soundlib/Sndfile.h =================================================================== --- trunk/OpenMPT/soundlib/Sndfile.h 2013-04-18 20:23:43 UTC (rev 1912) +++ trunk/OpenMPT/soundlib/Sndfile.h 2013-04-18 21:21:33 UTC (rev 1913) @@ -14,6 +14,7 @@ #include "../soundlib/SoundFilePlayConfig.h" #include "../soundlib/MixerSettings.h" #include "../common/misc_util.h" +#include "../common/Logging.h" #include "mod_specifications.h" #include <vector> #include <bitset> @@ -130,6 +131,7 @@ class CModDoc; #endif // MODPLUG_TRACKER + //============== class CSoundFile //============== @@ -173,7 +175,7 @@ public: #ifdef MODPLUG_TRACKER static bool LoadStaticTunings(); - static bool SaveStaticTunings(); + bool SaveStaticTunings(); static void DeleteStaticdata(); static CTuningCollection& GetBuiltInTunings() {return *s_pTuningsSharedBuiltIn;} static CTuningCollection& GetLocalTunings() {return *s_pTuningsSharedLocal;} @@ -335,13 +337,21 @@ bool m_bIsRendering; bool m_bPatternTransitionOccurred; +private: + // logging and user interaction + ILog *m_pCustomLog; + public: CSoundFile(); ~CSoundFile(); public: + // logging and user interaction + void SetCustomLog(ILog *pLog) { m_pCustomLog = pLog; } + void AddToLog(LogLevel level, const std::string &text) const; + void AddToLog(const std::string &text) const { AddToLog(LogInformation, text); } - void AddToLog(const std::string &text) const; +public: #ifdef MODPLUG_TRACKER BOOL Create(LPCBYTE lpStream, CModDoc *pModDoc, DWORD dwMemLength=0); Modified: trunk/OpenMPT/soundlib/modsmp_ctrl.cpp =================================================================== --- trunk/OpenMPT/soundlib/modsmp_ctrl.cpp 2013-04-18 20:23:43 UTC (rev 1912) +++ trunk/OpenMPT/soundlib/modsmp_ctrl.cpp 2013-04-18 21:21:33 UTC (rev 1913) @@ -11,7 +11,6 @@ #include "stdafx.h" #include "modsmp_ctrl.h" #include "../common/AudioCriticalSection.h" -#include "../common/Reporting.h" #include "Sndfile.h" #define new DEBUG_NEW @@ -55,7 +54,7 @@ #if 0 if( GetSampleCapacity(smp) >= nNewSmpBytes ) // If sample has room to expand. { - Reporting::Notification("Not implemented: GetSampleCapacity(smp) >= nNewSmpBytes"); + sndFile.AddToLog(LogNotification, "Not implemented: GetSampleCapacity(smp) >= nNewSmpBytes"); // Not implemented, GetSampleCapacity() currently always returns length based value // even if there is unused space in the sample. } @@ -74,7 +73,7 @@ memcpy(pNewSmp, smp.pSample, nOldBytes); } else - Reporting::Notification(TEXT("Unsupported start position in InsertSilence.")); + sndFile.AddToLog(LogNotification, TEXT("Unsupported start position in InsertSilence.")); } // Set loop points automatically Modified: trunk/OpenMPT/soundlib/patternContainer.cpp =================================================================== --- trunk/OpenMPT/soundlib/patternContainer.cpp 2013-04-18 20:23:43 UTC (rev 1912) +++ trunk/OpenMPT/soundlib/patternContainer.cpp 2013-04-18 21:21:33 UTC (rev 1913) @@ -64,9 +64,7 @@ m_Patterns.push_back(MODPATTERN(*this)); else { -#ifdef MODPLUG_TRACKER - ErrorBox(IDS_ERR_TOOMANYPAT, CMainFrame::GetMainFrame()); -#endif // MODPLUG_TRACKER + GetSoundFile().AddToLog(LogError, "Too many patterns!"); return true; } } Modified: trunk/OpenMPT/soundlib/tuning.cpp =================================================================== --- trunk/OpenMPT/soundlib/tuning.cpp 2013-04-18 20:23:43 UTC (rev 1912) +++ trunk/OpenMPT/soundlib/tuning.cpp 2013-04-18 21:21:33 UTC (rev 1913) @@ -12,7 +12,9 @@ #include "tuning.h" #include "../common/serialization_utils.h" -#include "../common/Reporting.h" +#ifdef MODPLUG_TRACKER +#include "../mptrack/Reporting.h" +#endif #include <string> typedef CTuningRTI::RATIOTYPE RATIOTYPE; @@ -399,7 +401,13 @@ pTuning->m_EditMask = EM_ALLOWALL; //Allowing all while processing data. if (pTuning->ProProcessUnserializationdata()) { - Reporting::Error(("Processing loaded data for tuning \"" + pTuning->GetName() + "\" failed.").c_str(), "Tuning load failure"); +#ifdef MODPLUG_TRACKER + Reporting::Error( +#else + Log("%s (%s)\n", +#endif + ("Processing loaded data for tuning \"" + pTuning->GetName() + "\" failed.").c_str(), "Tuning load failure" + ); delete pTuning; pTuning = nullptr; } else This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <man...@us...> - 2013-04-18 22:44:44
|
Revision: 1914 http://sourceforge.net/p/modplug/code/1914 Author: manxorist Date: 2013-04-18 22:44:35 +0000 (Thu, 18 Apr 2013) Log Message: ----------- [Ref] Kill gszEmpty. Modified Paths: -------------- trunk/OpenMPT/mptrack/Mptrack.h trunk/OpenMPT/soundlib/Sndfile.cpp Modified: trunk/OpenMPT/mptrack/Mptrack.h =================================================================== --- trunk/OpenMPT/mptrack/Mptrack.h 2013-04-18 21:21:33 UTC (rev 1913) +++ trunk/OpenMPT/mptrack/Mptrack.h 2013-04-18 22:44:35 UTC (rev 1914) @@ -356,7 +356,6 @@ STATIC_ASSERT(CountOf(szSpecialNoteShortDesc) == CountOf(szSpecialNoteNames)); const LPCSTR szHexChar = "0123456789ABCDEF"; -const TCHAR gszEmpty[] = TEXT(""); // Defined in load_mid.cpp extern const LPCSTR szMidiProgramNames[128]; Modified: trunk/OpenMPT/soundlib/Sndfile.cpp =================================================================== --- trunk/OpenMPT/soundlib/Sndfile.cpp 2013-04-18 21:21:33 UTC (rev 1913) +++ trunk/OpenMPT/soundlib/Sndfile.cpp 2013-04-18 22:44:35 UTC (rev 1914) @@ -1195,7 +1195,7 @@ return m_szNames[nSample]; } else { - return gszEmpty; + return ""; } } This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <sag...@us...> - 2013-04-20 13:43:58
|
Revision: 1917 http://sourceforge.net/p/modplug/code/1917 Author: saga-games Date: 2013-04-20 13:43:47 +0000 (Sat, 20 Apr 2013) Log Message: ----------- [Var] Updated release documents. [Mod] OpenMPT: Version is now 1.22.02.00 Modified Paths: -------------- trunk/OpenMPT/common/version.h trunk/OpenMPT/packageTemplate/History.txt trunk/OpenMPT/packageTemplate/OMPT_1.22_ReleaseNotes.html trunk/OpenMPT/packageTemplate/ReleaseNotesImages/1.22/soundsettings.png Modified: trunk/OpenMPT/common/version.h =================================================================== --- trunk/OpenMPT/common/version.h 2013-04-20 12:07:56 UTC (rev 1916) +++ trunk/OpenMPT/common/version.h 2013-04-20 13:43:47 UTC (rev 1917) @@ -18,8 +18,8 @@ //Version definitions. The only thing that needs to be changed when changing version number. #define VER_MAJORMAJOR 1 #define VER_MAJOR 22 -#define VER_MINOR 01 -#define VER_MINORMINOR 04 +#define VER_MINOR 02 +#define VER_MINORMINOR 00 //Creates version number from version parts that appears in version string. //For example MAKE_VERSION_NUMERIC(1,17,02,28) gives version number of Modified: trunk/OpenMPT/packageTemplate/History.txt =================================================================== --- trunk/OpenMPT/packageTemplate/History.txt 2013-04-20 12:07:56 UTC (rev 1916) +++ trunk/OpenMPT/packageTemplate/History.txt 2013-04-20 13:43:47 UTC (rev 1917) @@ -25,6 +25,45 @@ <ks> coda / Ken Snyder +v1.22.02.00 (20 April 2013, revision 1917) +------------------------------------------ +Instrument tab + [Mod] <js> When importing DLS drum samples into an XM instrument, pick the center of the sample's assigned note range as a transpose amount instead of the lowest note of the note range (http://bugs.openmpt.org/view.php?id=376). + +VST / DMO Plugins + [Imp] <js> If a plugin editor is focussed, MIDI is now always routed to that plugin. + [Mod] <js> effBeginSetProgram and effEndSetProgram opcodes are sent when performing a program change. + [Fix] <js> audioMasterGetPreviousPlug / audioMasterGetNextPlug opcodes were not doing anything that made sense. + +VST::Specific Plugin Fixes + [Fix] <js> OpenMPT could possibly freeze when starting WASAPI output of a module that uses the Sytrus plugin (and possibly other plugins). + +IT::Compatible Playback Mode + [Fix] <js> Fixed a rather rare envelope carry bug introduced in OpenMPT 1.22.01.00. + [Fix] <js> Instrument numbers higher than the last instrument act like empty instruments. + +MOD::Loading and Saving + [Imp] SoundTracker Loader: Made file rejection heuristics a bit more strict. + [Fix] SoundTracker Loader: Fixed possible division by zero. + [Fix] Saving: Maximum sample length was off by a few bytes. + [Fix] Saving: It was still possible for samples to misalign if the saved sample was originally larger than 128 KiB and had an odd sample count. + +Other formats + [Fix] <js> PSM16 loader: Master volume was not loaded properly. + +Misc + [New] <js> Added global, always active VU meter in the main toolbar. + [Imp] <js> MIDI CC shortcuts should now work in pretty much all places. + [Imp] <jh> Boosting of audio thread priority can now be disabled in the Sound Card settings. On Windows Vista and later, MMCSS is now used for boosting. + [Imp] <js> When changing MIDI input devices, the change is applied instantly. Previously the old MIDI device was kept open. + [Imp] <jh> Support for exclusive device access has been added for WASAPI devices. + [Mod] <jh> Renamed "Use secondary buffers" option to the negated form "Use primary buffer". + [Mod] <js> Instrument previews in the tree view are now played at 0dB. + [Fix] <jh> Fixed a possible crash when stopping a Wave Out device and possible freezes with ASIO / WASAPI devices. + [Fix] <js> Time display was not updated anymore in OpenMPT 1.22.01.00 when jumping around in the order list without actually playing the module. + [Fix] <js> Options dialog: Pre-amp warning was also shown when changing stereo separation. + + v1.22.01.00 (6 April 2013, revision 1749) ----------------------------------------- Pattern tab @@ -1251,11 +1290,11 @@ Other formats [Imp] <js> MT2 Loader (MadTracker): Make use of the "lines per beat" header field. Release node is not set anymore for each and every instrument envelope. MT2 files are now loaded as IT files by default (instead of XM) because of their extended instrument properties (NNAs, filters, etc) - I wonder what this breaks, but I don't bother much because MT2 support was already 100% broken before this. :) Some MT example tunes sound a bit better now at least. [Fix] <js> PTM Loader: Fixed an unhandled null pointer exception that occured when loading some unsupported RAR files. - [Fix] <js> PSM16 Loader: Fix for note cut on tick 0 (warbot tune from Silverball) + [Fix] <js> PSM16 Loader: Fix for note cut on tick 0 (warbot tune from Silverball). [Fix] <js> Threw out the old ULT loader in favor of Storlek's loader from SchismTracker (used with permission from the author himself). This is a lot more accurate than MPT's old loader. - [Fix] <js> DBM Loader: Various fixes to increase import precision and an endianness fix + [Fix] <js> DBM Loader: Various fixes to increase import precision and an endianness fix. [Fix] <js> AMF DSM Loader: Made some changes to the pattern reader, which eliminate the strange "vC7" commands in the pattern. I have found no hints on whether my fix is correct or not, apart from the fact that those AMF files that I have play a lot better now. And it makes kind of sense... - [Fix] <js> IMF Loader: Some fixes copied from Schism (copied from MikMod) + [Fix] <js> IMF Loader: Some fixes copied from Schism (copied from MikMod). Module cleanup [Imp] <js> In the cleanup dialog, mutually exclusive items are now automatically unchecked, to avoid confusion. @@ -1311,7 +1350,7 @@ [New] <js> New paste mode "paste flood" pastes the clipboard content again and again until it hits the bottom of the pattern (overflow paste will be disabled automatically if paste flood is used, for obvious reasons). [Imp] <js> When using the MPTM format, plugin param changes are written to the pattern as Parameter Control Events (instead of smooth MIDI macros). [Imp] <js> Assume that the clipboard pattern format is IT (instead of MOD) if no information about the format is available. - [Imp] <js> Pattern C&P: Pasted Commands are converted if necessary, and commands that are invalied in the current format are removed. + [Imp] <js> Pasted Commands are converted if necessary, and commands that are invalid in the current format are removed. [Imp] <js> If "record note off" is enabled and Note Off commands are not supported by the current format, try Note Cut and volume commands. [Mod] <js> It is impossible to enter something into the volume column in MOD format now. [Mod] <js> When interpolating Parameter Control Events, the plugin number and note type won't get overridden if the note type is already PC or PCs. @@ -1368,7 +1407,7 @@ Comments tab [Imp] <js> If sample size is < 1 KB, amount of bytes is shown instead of "0 KB". - [Fix] <js> The lower part of the tab was receiving update messages that were not even meaningful to this tab (e.g. speed changes), so it was updating quite often modules that have alternating speed and the toolbar was "blinking"... Only letting in important update messages now. + [Fix] <js> The lower part of the tab was receiving update messages that were not even meaningful to this tab (e.g. speed changes), so it was updating quite often with modules that have alternating speed and the toolbar was "blinking". Tree view [New] <js> Show sequences in song tree view. Sequences can be inserted, duplicated and deleted by right-clicking the sequence items. @@ -1829,27 +1868,26 @@ [Mod] <al> Disabled pitch shifting / time stretching of 8-bit samples (didn't seem to work). (rev. 228) Instrument tab + [Mod] <js> Sample map can now map "No sample". (rev. 236) + [Mod] <al> Changed default instrument plug volume command handling from Dry/Wet to none. Also added INI setting with which one can set the default value used for new instruments. INI setting is "DefaultPlugVolumeHandling" in [Misc], possible values are 0,1,2. (rev. 238) [Fix] <js> Envelope view: Middle line will now be drawn in panning and pitch/filter envelopes even if row guidelines are enabled. (rev. 254) - [Mod] <js> Instrument tab: Sample map can now map "No sample". (rev. 236) - [Mod] <al> Changed default instrument plug volume command handling from Dry/Wet to none. Also added INI setting with which one can set the default value used for new instruments. INI setting is "DefaultPlugVolumeHandling" in [Misc], possible values are 0,1,2. (rev. 238) - MPTM [Fix] <al> Pattern cleanup: In some cases sequence wasn't cleaned properly for mptm. (rev. 239) [Mod] <al> Changed pattern/order limit for MPTm from 65000 to 4000. (rev. 212) MPTM Instrument tuning [New] <al> Added letter 'b' to drawable letters. (rev. 217) + [Mod] <al> Notes should now be drawn more clearly when using custom tunings. (rev. 217) [Fix] <al> Creating 'group geometric' was broken (perhaps since v. 1.17.02.49) (rev. 252) [Fix] <al> Loading certain old tuning objects didn't work. (rev. 238) - [Mod] <al> Notes should now be drawn more clearly when using custom tunings. (rev. 217) IT [Fix] <al, js> Macro config should now be loaded correctly also when loading IT files not made with MPT. (rev. 257) [Fix] <al> When file was saved with compatibility export, the last order was not shown in Impulse Tracker. (rev. 257) IT::Compatible Playback Mode - [Fix] <al, js> Playback fix to vibrato with ramp down waveform in IT compatibility play. (rev. 257) + [Fix] <al, js> Playback fix to vibrato with ramp down waveform. (rev. 257) XM [Fix] <js> Dxx effects that are to the left of a Bxx effect are now ignored. (http://forum.openmpt.org/index.php?topic=2769.0) (rev. 241) Modified: trunk/OpenMPT/packageTemplate/OMPT_1.22_ReleaseNotes.html =================================================================== --- trunk/OpenMPT/packageTemplate/OMPT_1.22_ReleaseNotes.html 2013-04-20 12:07:56 UTC (rev 1916) +++ trunk/OpenMPT/packageTemplate/OMPT_1.22_ReleaseNotes.html 2013-04-20 13:43:47 UTC (rev 1917) @@ -115,6 +115,7 @@ Yes, the new latency value is higher than the previous buffer length value, but that is intended, because previously, the real latency was three times the buffer length. If you are still in doubt, read the <a href="http://wiki.openmpt.org/Manual:_Frequently_Asked_Questions#OpenMPT_produces_clicks_at_a_buffer_length_that_previously_worked_just_fine">FAQ</a>.</li> <li>Added support for <strong>WASAPI output devices</strong>.</li> + <li>Added a global <strong>VU meter with clip indicator</strong> in the main toolbar.</li> <li><strong>Elapsed time display</strong> in the status bar is a lot more accurate now (no more rounding errors that pile up over time).</li> </ul> Modified: trunk/OpenMPT/packageTemplate/ReleaseNotesImages/1.22/soundsettings.png =================================================================== (Binary files differ) This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <man...@us...> - 2013-04-20 18:48:43
|
Revision: 1919 http://sourceforge.net/p/modplug/code/1919 Author: manxorist Date: 2013-04-20 18:48:30 +0000 (Sat, 20 Apr 2013) Log Message: ----------- [Imp] Show exact subversion revision and working copy state of compiled binaries in About dialog and in crash report message boxes. This depends of TortoiseSVN being installed while building. Otherwise this information is not aviablable, but compilation still works as before. Modified Paths: -------------- trunk/OpenMPT/common/version.h trunk/OpenMPT/mptrack/ExceptionHandler.cpp trunk/OpenMPT/mptrack/Mptrack.cpp trunk/OpenMPT/mptrack/dlg_misc.cpp trunk/OpenMPT/mptrack/mptrack_08.vcproj trunk/OpenMPT/mptrack/mptrack_10.vcxproj trunk/OpenMPT/mptrack/mptrack_10.vcxproj.filters Added Paths: ----------- trunk/OpenMPT/common/svn_version/ trunk/OpenMPT/common/svn_version/svn_version.template.h trunk/OpenMPT/common/svn_version_default/ trunk/OpenMPT/common/svn_version_default/svn_version.h trunk/OpenMPT/common/version.cpp Property Changed: ---------------- trunk/OpenMPT/ Index: trunk/OpenMPT =================================================================== --- trunk/OpenMPT 2013-04-20 13:45:16 UTC (rev 1918) +++ trunk/OpenMPT 2013-04-20 18:48:30 UTC (rev 1919) Property changes on: trunk/OpenMPT ___________________________________________________________________ Added: svn:ignore ## -0,0 +1,6 ## +Debug +Release +ipch +libopenmpt.sdf +libopenmpt.opensdf +libopenmpt.suo Index: trunk/OpenMPT/common/svn_version =================================================================== --- trunk/OpenMPT/common/svn_version 2013-04-20 13:45:16 UTC (rev 1918) +++ trunk/OpenMPT/common/svn_version 2013-04-20 18:48:30 UTC (rev 1919) Property changes on: trunk/OpenMPT/common/svn_version ___________________________________________________________________ Added: svn:ignore ## -0,0 +1 ## +svn_version.h Added: trunk/OpenMPT/common/svn_version/svn_version.template.h =================================================================== --- trunk/OpenMPT/common/svn_version/svn_version.template.h (rev 0) +++ trunk/OpenMPT/common/svn_version/svn_version.template.h 2013-04-20 18:48:30 UTC (rev 1919) @@ -0,0 +1,10 @@ + +#pragma once + +#define OPENMPT_VERSION_URL "$WCURL$" +#define OPENMPT_VERSION_REVISION $WCREV$ + +#define OPENMPT_VERSION_DIRTY $WCMODS?true:false$ +#define OPENMPT_VERSION_MIXEDREVISIONS $WCMIXED?true:false$ + +#define OPENMPT_VERSION_DATE "$WCNOW=%Y-%m-%d %H:%M:%S$" Property changes on: trunk/OpenMPT/common/svn_version/svn_version.template.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 Added: trunk/OpenMPT/common/svn_version_default/svn_version.h =================================================================== --- trunk/OpenMPT/common/svn_version_default/svn_version.h (rev 0) +++ trunk/OpenMPT/common/svn_version_default/svn_version.h 2013-04-20 18:48:30 UTC (rev 1919) @@ -0,0 +1,10 @@ + +#pragma once + +#define OPENMPT_VERSION_URL "" +#define OPENMPT_VERSION_REVISION 0 + +#define OPENMPT_VERSION_DIRTY false +#define OPENMPT_VERSION_MIXEDREVISIONS false + +#define OPENMPT_VERSION_DATE __DATE__ " " __TIME__ Property changes on: trunk/OpenMPT/common/svn_version_default/svn_version.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 Added: trunk/OpenMPT/common/version.cpp =================================================================== --- trunk/OpenMPT/common/version.cpp (rev 0) +++ trunk/OpenMPT/common/version.cpp 2013-04-20 18:48:30 UTC (rev 1919) @@ -0,0 +1,139 @@ +/* + * version.cpp + * ----------- + * Purpose: OpenMPT version handling. + * Notes : (currently none) + * Authors: OpenMPT Devs + * The OpenMPT source code is released under the BSD license. Read LICENSE for more details. + */ + +#include "stdafx.h" +#include "version.h" + +#include <sstream> + +#include "svn_version.h" + +namespace MptVersion { + +bool IsDebugBuild() +{ + #ifdef _DEBUG + return true; + #else + return false; + #endif +} + +std::string GetUrl() +{ + return OPENMPT_VERSION_URL; +} + +int GetRevision() +{ + return OPENMPT_VERSION_REVISION; +} + +bool IsDirty() +{ + return OPENMPT_VERSION_DIRTY; +} + +bool HasMixedRevisions() +{ + return OPENMPT_VERSION_MIXEDREVISIONS; +} + +std::string GetStateString() +{ + std::string retval; + if(OPENMPT_VERSION_MIXEDREVISIONS) + { + retval += "+mixed"; + } + if(OPENMPT_VERSION_DIRTY) + { + retval += "+dirty"; + } + return retval; +} + +std::string GetBuildDateString() +{ + return OPENMPT_VERSION_DATE; +} + +std::string GetBuildFlagsString() +{ + std::string retval; + if(IsTestBuild()) + { + retval += " TEST"; + } + if(IsDebugBuild()) + { + retval += " DEBUG"; + } + #ifdef MODPLUG_TRACKER + #ifdef NO_VST + retval += " NO_VST"; + #endif + #ifdef NO_ASIO + retval += " NO_ASIO"; + #endif + #ifdef NO_DSOUND + retval += " NO_DSOUND"; + #endif + #endif + return retval; +} + +std::string GetRevisionString() +{ + if(OPENMPT_VERSION_REVISION == 0) + { + return ""; + } + std::ostringstream str; + str << "-r" << OPENMPT_VERSION_REVISION; + if(OPENMPT_VERSION_MIXEDREVISIONS) + { + str << "!"; + } + if(OPENMPT_VERSION_DIRTY) + { + str << "+"; + } + return str.str(); +} + +std::string GetVersionStringExtended() +{ + std::string retval = MPT_VERSION_STR; + if(IsDebugBuild() || IsTestBuild() || IsDirty() || HasMixedRevisions()) + { + retval += GetRevisionString(); + retval += GetBuildFlagsString(); + } + return retval; +} + +std::string GetVersionUrlString() +{ + if(OPENMPT_VERSION_REVISION == 0) + { + return ""; + } + std::string url = OPENMPT_VERSION_URL; + std::string baseurl = "https://svn.code.sf.net/p/modplug/code/"; + if(url.substr(0, baseurl.length()) == baseurl) + { + url = url.substr(baseurl.length()); + } + std::ostringstream str; + str << url << "@" << OPENMPT_VERSION_REVISION << GetStateString(); + return str.str(); +} + +} // namespace MptVersion Property changes on: trunk/OpenMPT/common/version.cpp ___________________________________________________________________ Added: svn:mime-type ## -0,0 +1 ## +text/x-c++src \ No newline at end of property Added: svn:eol-style ## -0,0 +1 ## +native \ No newline at end of property Modified: trunk/OpenMPT/common/version.h =================================================================== --- trunk/OpenMPT/common/version.h 2013-04-20 13:45:16 UTC (rev 1918) +++ trunk/OpenMPT/common/version.h 2013-04-20 18:48:30 UTC (rev 1919) @@ -10,6 +10,8 @@ #pragma once +#include <string> + //STRINGIZE makes a string of given argument. If used with #defined value, //the string is made of the contents of the defined value. #define HELPER_STRINGIZE(x) #x @@ -44,12 +46,12 @@ int v1, v2, v3, v4; sscanf(s, "%x.%x.%x.%x", &v1, &v2, &v3, &v4); return ((v1 << 24) | (v2 << 16) | (v3 << 8) | v4); - }; + } // Returns version string from given numerical version value. - static CString ToStr(const VersionNum v) + static mpt::String ToStr(const VersionNum v) { - CString strVersion; + mpt::String strVersion; if(v == 0) { // Unknown version @@ -64,7 +66,7 @@ strVersion.Format("%X.%02X.%02X.%02X", (v >> 24) & 0xFF, (v >> 16) & 0xFF, (v >> 8) & 0xFF, (v) & 0xFF); } return strVersion; - }; + } // Return a version without build number (the last number in the version). // The current versioning scheme uses this number only for test builds, and it should be 00 for official builds, @@ -72,11 +74,26 @@ static VersionNum RemoveBuildNumber(const VersionNum num) { return (num & 0xFFFFFF00); - }; + } // Returns true if a given version number is from a test build, false if it's a release build. - static bool IsTestBuild(const VersionNum num) + static bool IsTestBuild(const VersionNum num = MPT_VERSION_NUMERIC) { return ((num > MAKE_VERSION_NUMERIC(1,17,02,54) && num < MAKE_VERSION_NUMERIC(1,18,02,00) && num != MAKE_VERSION_NUMERIC(1,18,00,00)) || (num > MAKE_VERSION_NUMERIC(1,18,02,00) && RemoveBuildNumber(num) != num)); } + + bool IsDebugBuild(); + + std::string GetUrl(); + int GetRevision(); + bool IsDirty(); + bool HasMixedRevisions(); + std::string GetStateString(); + std::string GetBuildDateString(); + + std::string GetBuildFlagsString(); + std::string GetRevisionString(); + std::string GetVersionStringExtended(); + std::string GetVersionUrlString(); + }; //namespace MptVersion Modified: trunk/OpenMPT/mptrack/ExceptionHandler.cpp =================================================================== --- trunk/OpenMPT/mptrack/ExceptionHandler.cpp 2013-04-20 13:45:16 UTC (rev 1918) +++ trunk/OpenMPT/mptrack/ExceptionHandler.cpp 2013-04-20 18:48:30 UTC (rev 1919) @@ -15,6 +15,7 @@ #include <shlwapi.h> #include "ExceptionHandler.h" #include "dbghelp.h" +#include "../common/version.h" typedef BOOL (WINAPI *MINIDUMPWRITEDUMP)(HANDLE hProcess, DWORD dwPid, HANDLE hFile, MINIDUMP_TYPE DumpType, @@ -108,6 +109,11 @@ errorMessage.AppendFormat("\n\n%d modified file%s been rescued, but it cannot be guaranteed that %s still intact.", numFiles, (numFiles == 1 ? " has" : "s have"), (numFiles == 1 ? "it is" : "they are")); } + errorMessage.AppendFormat("\n\nOpenMPT %s %s (%s)\n", + MptVersion::GetVersionStringExtended().c_str(), + MptVersion::GetVersionUrlString() + ); + Reporting::Error(errorMessage, "OpenMPT Crash", pMainFrame); } @@ -144,7 +150,7 @@ } -#ifdef NDEBUG +#ifndef _DEBUG void AlwaysAssertHandler(const char *file, int line, const char *function, const char *expr) //------------------------------------------------------------------------------------------ { Modified: trunk/OpenMPT/mptrack/Mptrack.cpp =================================================================== --- trunk/OpenMPT/mptrack/Mptrack.cpp 2013-04-20 13:45:16 UTC (rev 1918) +++ trunk/OpenMPT/mptrack/Mptrack.cpp 2013-04-20 18:48:30 UTC (rev 1919) @@ -1538,16 +1538,11 @@ BOOL CAboutDlg::OnInitDialog() //---------------------------- { - const char * const s = "Build Date: " __DATE__ " " __TIME__; CDialog::OnInitDialog(); m_bmp.SubclassDlgItem(IDC_BITMAP1, this); m_bmp.LoadBitmap(MAKEINTRESOURCE(IDB_MPTRACK)); - SetDlgItemText(IDC_EDIT2, s); - SetDlgItemText(IDC_EDIT3, CString("OpenMPT ") + MptVersion::str -#if (MPT_VERSION_NUMERIC & 0xFF) != 0 - + CString(" (Test Build)") -#endif - ); + SetDlgItemText(IDC_EDIT2, CString("Build Date: ") + MptVersion::GetBuildDateString().c_str()); + SetDlgItemText(IDC_EDIT3, CString("OpenMPT ") + MptVersion::GetVersionStringExtended().c_str()); m_heContact.SetWindowText( "Contact / Discussion:\r\n" Modified: trunk/OpenMPT/mptrack/dlg_misc.cpp =================================================================== --- trunk/OpenMPT/mptrack/dlg_misc.cpp 2013-04-20 13:45:16 UTC (rev 1918) +++ trunk/OpenMPT/mptrack/dlg_misc.cpp 2013-04-20 18:48:30 UTC (rev 1919) @@ -161,7 +161,7 @@ CString CModTypeDlg::FormatVersionNumber(DWORD version) //----------------------------------------------------- { - return MptVersion::ToStr(version) + (MptVersion::IsTestBuild(version) ? " (Test Build)" : ""); + return CString(MptVersion::ToStr(version)) + (MptVersion::IsTestBuild(version) ? " (Test Build)" : ""); } Modified: trunk/OpenMPT/mptrack/mptrack_08.vcproj =================================================================== --- trunk/OpenMPT/mptrack/mptrack_08.vcproj 2013-04-20 13:45:16 UTC (rev 1918) +++ trunk/OpenMPT/mptrack/mptrack_08.vcproj 2013-04-20 18:48:30 UTC (rev 1919) @@ -27,6 +27,7 @@ > <Tool Name="VCPreBuildEventTool" + CommandLine="subwcrev .. ..\common\svn_version\svn_version.template.h ..\common\svn_version\svn_version.h || del ..\common\svn_version\svn_version.h || true" /> <Tool Name="VCCustomBuildTool" @@ -48,7 +49,7 @@ <Tool Name="VCCLCompilerTool" Optimization="0" - AdditionalIncludeDirectories="..\common;..\soundlib;..\include;..\include\vstsdk2.4\;..\include\ASIOSDK2\common\;..\" + AdditionalIncludeDirectories="..\common;..\soundlib;..\include;..\include\vstsdk2.4\;..\include\ASIOSDK2\common\;..\;..\common\svn_version;..\common\svn_version_default" PreprocessorDefinitions="_DEBUG,WIN32,_WINDOWS,MODPLUG_TRACKER" StringPooling="true" ExceptionHandling="2" @@ -134,6 +135,7 @@ > <Tool Name="VCPreBuildEventTool" + CommandLine="subwcrev .. ..\common\svn_version\svn_version.template.h ..\common\svn_version\svn_version.h || del ..\common\svn_version\svn_version.h || true" /> <Tool Name="VCCustomBuildTool" @@ -156,7 +158,7 @@ Name="VCCLCompilerTool" Optimization="2" InlineFunctionExpansion="2" - AdditionalIncludeDirectories="..\common;..\soundlib;..\include;..\include\vstsdk2.4\;..\include\ASIOSDK2\common\;..\" + AdditionalIncludeDirectories="..\common;..\soundlib;..\include;..\include\vstsdk2.4\;..\include\ASIOSDK2\common\;..\;..\common\svn_version;..\common\svn_version_default" PreprocessorDefinitions="NDEBUG,WIN32,_WINDOWS,MODPLUG_TRACKER" StringPooling="true" ExceptionHandling="2" @@ -245,6 +247,10 @@ > </File> <File + RelativePath="..\sounddsp\AGC.cpp" + > + </File> + <File RelativePath="..\common\AudioCriticalSection.cpp" > </File> @@ -313,10 +319,18 @@ > </File> <File + RelativePath="..\sounddsp\DSP.cpp" + > + </File> + <File RelativePath=".\EffectVis.cpp" > </File> <File + RelativePath="..\sounddsp\EQ.cpp" + > + </File> + <File RelativePath=".\ExceptionHandler.cpp" > </File> @@ -381,14 +395,6 @@ > </File> <File - RelativePath="..\common\mptString.cpp" - > - </File> - <File - RelativePath="..\common\typedefs.cpp" - > - </File> - <File RelativePath="..\soundlib\MixerSettings.cpp" > </File> @@ -465,6 +471,10 @@ > </File> <File + RelativePath="..\common\mptString.cpp" + > + </File> + <File RelativePath="..\soundlib\pattern.cpp" > </File> @@ -485,6 +495,10 @@ > </File> <File + RelativePath="..\sounddsp\Reverb.cpp" + > + </File> + <File RelativePath="..\soundlib\RowVisitor.cpp" > </File> @@ -501,18 +515,6 @@ > </File> <File - RelativePath="..\sounddsp\AGC.cpp" - > - </File> - <File - RelativePath="..\sounddsp\DSP.cpp" - > - </File> - <File - RelativePath="..\sounddsp\EQ.cpp" - > - </File> - <File RelativePath="..\soundlib\snd_flt.cpp" > </File> @@ -521,22 +523,18 @@ > </File> <File - RelativePath="..\sounddsp\Reverb.cpp" + RelativePath="..\soundlib\Sndfile.cpp" > </File> <File - RelativePath="..\sounddev\SoundDevice.cpp" + RelativePath="..\soundlib\Sndmix.cpp" > </File> <File - RelativePath="..\soundlib\Sndfile.cpp" + RelativePath="..\sounddev\SoundDevice.cpp" > </File> <File - RelativePath="..\soundlib\Sndmix.cpp" - > - </File> - <File RelativePath="..\soundlib\SoundFilePlayConfig.cpp" > </File> @@ -573,6 +571,10 @@ > </File> <File + RelativePath="..\common\typedefs.cpp" + > + </File> + <File RelativePath=".\Undo.cpp" > </File> @@ -581,6 +583,10 @@ > </File> <File + RelativePath="..\common\version.cpp" + > + </File> + <File RelativePath=".\view_com.cpp" > </File> @@ -815,6 +821,10 @@ > </File> <File + RelativePath="..\sounddsp\AGC.h" + > + </File> + <File RelativePath="..\common\AudioCriticalSection.h" > </File> @@ -875,6 +885,10 @@ > </File> <File + RelativePath="..\sounddsp\DSP.h" + > + </File> + <File RelativePath=".\EffectInfo.h" > </File> @@ -883,6 +897,10 @@ > </File> <File + RelativePath="..\sounddsp\EQ.h" + > + </File> + <File RelativePath=".\ExceptionHandler.h" > </File> @@ -907,6 +925,10 @@ > </File> <File + RelativePath="..\common\Logging.h" + > + </File> + <File RelativePath=".\mainbar.h" > </File> @@ -983,6 +1005,10 @@ > </File> <File + RelativePath="..\common\mptString.h" + > + </File> + <File RelativePath="..\common\mutex.h" > </File> @@ -1007,10 +1033,6 @@ > </File> <File - RelativePath="..\common\Profiler.h" - > - </File> - <File RelativePath=".\soundlib\plugins\PluginEventQueue.h" > </File> @@ -1023,7 +1045,7 @@ > </File> <File - RelativePath="..\common\Logging.h" + RelativePath="..\common\Profiler.h" > </File> <File @@ -1035,11 +1057,11 @@ > </File> <File - RelativePath="..\sounddsp\Reverb.h" + RelativePath=".\Resource.h" > </File> <File - RelativePath=".\Resource.h" + RelativePath="..\sounddsp\Reverb.h" > </File> <File @@ -1067,42 +1089,38 @@ > </File> <File - RelativePath="..\sounddev\SoundDevice.h" + RelativePath="..\Soundlib\Sndfile.h" > </File> <File - RelativePath="..\sounddev\SoundDevices.h" + RelativePath="..\sounddev\SoundDevice.h" > </File> <File - RelativePath="..\Soundlib\Sndfile.h" + RelativePath="..\sounddev\SoundDevices.h" > </File> <File - RelativePath="..\sounddsp\AGC.h" + RelativePath="..\soundlib\SoundFilePlayConfig.h" > </File> <File - RelativePath="..\sounddsp\DSP.h" + RelativePath="..\common\stdafx.h" > </File> <File - RelativePath="..\sounddsp\EQ.h" + RelativePath="..\common\StringFixer.h" > </File> <File - RelativePath="..\soundlib\SoundFilePlayConfig.h" + RelativePath="..\common\svn_version_default\svn_version.h" > </File> <File - RelativePath="..\common\stdafx.h" + RelativePath="..\common\svn_version\svn_version.template.h" > </File> <File - RelativePath="..\common\StringFixer.h" - > - </File> - <File RelativePath=".\Tables.h" > </File> @@ -1119,10 +1137,6 @@ > </File> <File - RelativePath="..\common\mptString.h" - > - </File> - <File RelativePath=".\Undo.h" > </File> @@ -1303,10 +1317,6 @@ > </File> <File - RelativePath="..\soundlib\Message.h" - > - </File> - <File RelativePath="..\soundlib\Load_669.cpp" > </File> @@ -1423,6 +1433,10 @@ > </File> <File + RelativePath="..\soundlib\Message.h" + > + </File> + <File RelativePath="..\soundlib\WAVTools.cpp" > </File> Modified: trunk/OpenMPT/mptrack/mptrack_10.vcxproj =================================================================== --- trunk/OpenMPT/mptrack/mptrack_10.vcxproj 2013-04-20 13:45:16 UTC (rev 1918) +++ trunk/OpenMPT/mptrack/mptrack_10.vcxproj 2013-04-20 18:48:30 UTC (rev 1919) @@ -77,7 +77,7 @@ <ClCompile> <AdditionalOptions>/EHsc %(AdditionalOptions)</AdditionalOptions> <Optimization>Disabled</Optimization> - <AdditionalIncludeDirectories>..\common;..\soundlib;..\include;..\include\vstsdk2.4\;..\include\ASIOSDK2\common\;..\;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories> + <AdditionalIncludeDirectories>..\common;..\soundlib;..\include;..\include\vstsdk2.4\;..\include\ASIOSDK2\common\;..\;..\common\svn_version;..\common\svn_version_default;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories> <PreprocessorDefinitions>_DEBUG;WIN32;_WINDOWS;MODPLUG_TRACKER;%(PreprocessorDefinitions)</PreprocessorDefinitions> <StringPooling>true</StringPooling> <BasicRuntimeChecks>EnableFastChecks</BasicRuntimeChecks> @@ -121,6 +121,9 @@ <Manifest> <AdditionalManifestFiles>$(ProjectDir)res/rt_manif.bin;%(AdditionalManifestFiles)</AdditionalManifestFiles> </Manifest> + <PreBuildEvent> + <Command>subwcrev .. ..\common\svn_version\svn_version.template.h ..\common\svn_version\svn_version.h || del ..\common\svn_version\svn_version.h || true</Command> + </PreBuildEvent> </ItemDefinitionGroup> <ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'"> <Midl> @@ -133,7 +136,7 @@ <ClCompile> <Optimization>MaxSpeed</Optimization> <InlineFunctionExpansion>AnySuitable</InlineFunctionExpansion> - <AdditionalIncludeDirectories>..\common;..\soundlib;..\include;..\include\vstsdk2.4\;..\include\ASIOSDK2\common\;..\;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories> + <AdditionalIncludeDirectories>..\common;..\soundlib;..\include;..\include\vstsdk2.4\;..\include\ASIOSDK2\common\;..\;..\common\svn_version;..\common\svn_version_default;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories> <PreprocessorDefinitions>NDEBUG;WIN32;_WINDOWS;MODPLUG_TRACKER;%(PreprocessorDefinitions)</PreprocessorDefinitions> <StringPooling>true</StringPooling> <RuntimeLibrary>MultiThreaded</RuntimeLibrary> @@ -181,6 +184,9 @@ <Manifest> <AdditionalManifestFiles>$(ProjectDir)res/rt_manif.bin;%(AdditionalManifestFiles)</AdditionalManifestFiles> </Manifest> + <PreBuildEvent> + <Command>subwcrev .. ..\common\svn_version\svn_version.template.h ..\common\svn_version\svn_version.h || del ..\common\svn_version\svn_version.h || true</Command> + </PreBuildEvent> </ItemDefinitionGroup> <ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='ReleaseLTCG|Win32'"> <Midl> @@ -193,7 +199,7 @@ <ClCompile> <Optimization>MaxSpeed</Optimization> <InlineFunctionExpansion>AnySuitable</InlineFunctionExpansion> - <AdditionalIncludeDirectories>..\common;..\soundlib;..\include;..\include\vstsdk2.4\;..\include\ASIOSDK2\common\;..\;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories> + <AdditionalIncludeDirectories>..\common;..\soundlib;..\include;..\include\vstsdk2.4\;..\include\ASIOSDK2\common\;..\;..\common\svn_version;..\common\svn_version_default;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories> <PreprocessorDefinitions>NDEBUG;WIN32;_WINDOWS;MODPLUG_TRACKER;%(PreprocessorDefinitions)</PreprocessorDefinitions> <StringPooling>true</StringPooling> <RuntimeLibrary>MultiThreaded</RuntimeLibrary> @@ -242,6 +248,9 @@ <Manifest> <AdditionalManifestFiles>$(ProjectDir)res/rt_manif.bin;%(AdditionalManifestFiles)</AdditionalManifestFiles> </Manifest> + <PreBuildEvent> + <Command>subwcrev .. ..\common\svn_version\svn_version.template.h ..\common\svn_version\svn_version.h || del ..\common\svn_version\svn_version.h || true</Command> + </PreBuildEvent> </ItemDefinitionGroup> <ItemGroup> <ClCompile Include="..\common\AudioCriticalSection.cpp" /> @@ -250,6 +259,7 @@ <ClCompile Include="..\common\Profiler.cpp" /> <ClCompile Include="..\common\serialization_utils.cpp" /> <ClCompile Include="..\common\typedefs.cpp" /> + <ClCompile Include="..\common\version.cpp" /> <ClCompile Include="..\sounddev\SoundDevice.cpp" /> <ClCompile Include="..\sounddsp\AGC.cpp" /> <ClCompile Include="..\sounddsp\DSP.cpp" /> @@ -409,6 +419,8 @@ <ClInclude Include="..\common\Profiler.h" /> <ClInclude Include="..\common\serialization_utils.h" /> <ClInclude Include="..\common\StringFixer.h" /> + <ClInclude Include="..\common\svn_version\svn_version.template.h" /> + <ClInclude Include="..\common\svn_version_default\svn_version.h" /> <ClInclude Include="..\common\typedefs.h" /> <ClInclude Include="..\common\version.h" /> <ClInclude Include="..\sounddev\SoundDevice.h" /> Modified: trunk/OpenMPT/mptrack/mptrack_10.vcxproj.filters =================================================================== --- trunk/OpenMPT/mptrack/mptrack_10.vcxproj.filters 2013-04-20 13:45:16 UTC (rev 1918) +++ trunk/OpenMPT/mptrack/mptrack_10.vcxproj.filters 2013-04-20 18:48:30 UTC (rev 1919) @@ -436,6 +436,9 @@ <ClCompile Include="Reporting.cpp"> <Filter>Source Files\mptrack</Filter> </ClCompile> + <ClCompile Include="..\common\version.cpp"> + <Filter>Source Files\common</Filter> + </ClCompile> </ItemGroup> <ItemGroup> <ClInclude Include="..\soundlib\Loaders.h"> @@ -801,6 +804,12 @@ <ClInclude Include="Reporting.h"> <Filter>Header Files\mptrack</Filter> </ClInclude> + <ClInclude Include="..\common\svn_version\svn_version.template.h"> + <Filter>Header Files\common</Filter> + </ClInclude> + <ClInclude Include="..\common\svn_version_default\svn_version.h"> + <Filter>Header Files\common</Filter> + </ClInclude> </ItemGroup> <ItemGroup> <None Include="res\bitmap1.bmp"> This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <sag...@us...> - 2013-04-21 14:38:15
|
Revision: 1922 http://sourceforge.net/p/modplug/code/1922 Author: saga-games Date: 2013-04-21 14:38:08 +0000 (Sun, 21 Apr 2013) Log Message: ----------- [Ref] Added GetLength mode to seek to given time offset (for libopenmpt). Modified Paths: -------------- trunk/OpenMPT/mptrack/Moddoc.cpp trunk/OpenMPT/soundlib/Snd_fx.cpp trunk/OpenMPT/soundlib/Sndfile.cpp trunk/OpenMPT/soundlib/Sndfile.h trunk/OpenMPT/soundlib/Sndmix.cpp Modified: trunk/OpenMPT/mptrack/Moddoc.cpp =================================================================== --- trunk/OpenMPT/mptrack/Moddoc.cpp 2013-04-21 13:32:39 UTC (rev 1921) +++ trunk/OpenMPT/mptrack/Moddoc.cpp 2013-04-21 14:38:08 UTC (rev 1922) @@ -1791,7 +1791,7 @@ if(wsdlg.m_bSelectPlay) { m_SndFile.SetCurrentOrder(wsdlg.m_nMinOrder); - m_SndFile.GetLength(eAdjust, wsdlg.m_nMinOrder, 0); // adjust playback variables / visited rows vector + m_SndFile.GetLength(eAdjust, GetLengthTarget(wsdlg.m_nMinOrder, 0)); // adjust playback variables / visited rows vector m_SndFile.m_nCurrentOrder = wsdlg.m_nMinOrder; m_SndFile.m_nMaxOrderPosition = wsdlg.m_nMaxOrder + 1; m_SndFile.SetRepeatCount(0); Modified: trunk/OpenMPT/soundlib/Snd_fx.cpp =================================================================== --- trunk/OpenMPT/soundlib/Snd_fx.cpp 2013-04-21 13:32:39 UTC (rev 1921) +++ trunk/OpenMPT/soundlib/Snd_fx.cpp 2013-04-21 14:38:08 UTC (rev 1922) @@ -94,6 +94,7 @@ }; double elapsedTime; + CSoundFile::samplecount_t renderedSamples; UINT musicSpeed, musicTempo; LONG glbVol; vector<ChnSettings> chnSettings; @@ -111,6 +112,7 @@ void Reset() { elapsedTime = 0.0; + renderedSamples = 0; musicSpeed = sndFile.m_nDefaultSpeed; musicTempo = sndFile.m_nDefaultTempo; glbVol = sndFile.m_nDefaultGlobalVolume; @@ -133,8 +135,8 @@ // [out] lastRow: last parsed row (dito) // [out] endOrder: last order before module loops (UNDEFINED if a target is specified) // [out] endRow: last row before module loops (dito) -GetLengthType CSoundFile::GetLength(enmGetLengthResetMode adjustMode, ORDERINDEX endOrder, ROWINDEX endRow) -//--------------------------------------------------------------------------------------------------------- +GetLengthType CSoundFile::GetLength(enmGetLengthResetMode adjustMode, GetLengthTarget target) +//------------------------------------------------------------------------------------------- { GetLengthType retval; retval.duration = 0.0; @@ -143,7 +145,7 @@ retval.lastRow = retval.endRow = ROWINDEX_INVALID; // Are we trying to reach a certain pattern position? - const bool hasSearchTarget = (endOrder != ORDERINDEX_INVALID && endRow != ROWINDEX_INVALID); + const bool hasSearchTarget = target.mode != GetLengthTarget::NoTarget; ROWINDEX nRow = 0, nNextRow = 0; ROWINDEX nNextPatStartRow = 0; // FT2 E60 bug @@ -154,8 +156,6 @@ // Temporary visited rows vector (so that GetLength() won't interfere with the player code if the module is playing at the same time) RowVisitor visitedRows(*this); - samplecount_t renderedSamples = 0; - for (;;) { UINT rowDelay = 0, tickDelay = 0; @@ -203,7 +203,7 @@ } } // Skip non-existing patterns - if ((nPattern >= Patterns.Size()) || (!Patterns[nPattern])) + if((nPattern >= Patterns.Size()) || (!Patterns[nPattern])) { // If there isn't even a tune, we should probably stop here. if(nCurrentOrder == m_nRestartPos) @@ -223,11 +223,12 @@ continue; } // Should never happen - if (nRow >= Patterns[nPattern].GetNumRows()) + if(nRow >= Patterns[nPattern].GetNumRows()) nRow = 0; - //Check whether target reached. - if(nCurrentOrder == endOrder && nRow == endRow) + // Check whether target was reached. + if((target.mode == GetLengthTarget::SeekPosition && nCurrentOrder == target.pos.order && nRow == target.pos.row) + || (target.mode == GetLengthTarget::SeekSeconds && memory.elapsedTime >= target.time)) { retval.targetReached = true; break; @@ -534,10 +535,10 @@ const UINT rowDuration = tickDuration * (memory.musicSpeed + tickDelay) * MAX(rowDelay, 1); memory.elapsedTime += static_cast<double>(rowDuration) / static_cast<double>(m_MixerSettings.gdwMixingFreq); - renderedSamples += rowDuration; + memory.renderedSamples += rowDuration; } - if(retval.targetReached || endOrder == ORDERINDEX_INVALID || endRow == ROWINDEX_INVALID) + if(retval.targetReached || target.mode == GetLengthTarget::NoTarget) { retval.lastOrder = nCurrentOrder; retval.lastRow = nRow; @@ -547,11 +548,11 @@ // Store final variables if((adjustMode & eAdjust)) { - if(retval.targetReached || endOrder == ORDERINDEX_INVALID || endRow == ROWINDEX_INVALID) + if(retval.targetReached || target.mode == GetLengthTarget::NoTarget) { // Target found, or there is no target (i.e. play whole song)... m_nGlobalVolume = memory.glbVol; - m_lTotalSampleCount = renderedSamples; + m_lTotalSampleCount = memory.renderedSamples; m_bPositionChanged = true; if(IsCompatibleMode(TRK_IMPULSETRACKER | TRK_FASTTRACKER2)) { Modified: trunk/OpenMPT/soundlib/Sndfile.cpp =================================================================== --- trunk/OpenMPT/soundlib/Sndfile.cpp 2013-04-21 13:32:39 UTC (rev 1921) +++ trunk/OpenMPT/soundlib/Sndfile.cpp 2013-04-21 14:38:08 UTC (rev 1922) @@ -1638,7 +1638,7 @@ double CSoundFile::GetPlaybackTimeAt(ORDERINDEX ord, ROWINDEX row, bool updateVars) //--------------------------------------------------------------------------------- { - const GetLengthType t = GetLength(updateVars ? eAdjust : eNoAdjust, ord, row); + const GetLengthType t = GetLength(updateVars ? eAdjust : eNoAdjust, GetLengthTarget(ord, row)); if(t.targetReached) return t.duration; else return -1; //Given position not found from play sequence. } Modified: trunk/OpenMPT/soundlib/Sndfile.h =================================================================== --- trunk/OpenMPT/soundlib/Sndfile.h 2013-04-21 13:32:39 UTC (rev 1921) +++ trunk/OpenMPT/soundlib/Sndfile.h 2013-04-21 14:38:08 UTC (rev 1922) @@ -92,6 +92,57 @@ }; +// Target seek mode for GetLength() +struct GetLengthTarget +{ + union + { + double time; + struct + { + ROWINDEX row; + ORDERINDEX order; + } pos; + }; + + enum Mode + { + NoTarget, // Don't seek, i.e. return complete module length. + SeekPosition, // Seek to given pattern position. + SeekSeconds, // Seek to given time. + } mode; + + // Don't seek, i.e. return complete module length. + GetLengthTarget() + { + mode = NoTarget; + } + + // Seek to given pattern position if position is valid. + GetLengthTarget(ORDERINDEX order, ROWINDEX row) + { + mode = NoTarget; + if(order != ORDERINDEX_INVALID && row != ROWINDEX_INVALID) + { + mode = SeekPosition; + pos.row = row; + pos.order = order; + } + } + + // Seek to given time if t is valid (i.e. not negative). + GetLengthTarget(double t) + { + mode = NoTarget; + if(t >= 0.0) + { + mode = SeekSeconds; + time = t; + } + } +}; + + // Reset mode for GetLength() enum enmGetLengthResetMode { @@ -400,7 +451,7 @@ //Get modlength in various cases: total length, length to //specific order&row etc. Return value is in seconds. - GetLengthType GetLength(enmGetLengthResetMode adjustMode, ORDERINDEX ord = ORDERINDEX_INVALID, ROWINDEX row = ROWINDEX_INVALID); + GetLengthType GetLength(enmGetLengthResetMode adjustMode, GetLengthTarget target = GetLengthTarget()); void InitializeVisitedRows() { visitedSongRows.Initialize(true); } Modified: trunk/OpenMPT/soundlib/Sndmix.cpp =================================================================== --- trunk/OpenMPT/soundlib/Sndmix.cpp 2013-04-21 13:32:39 UTC (rev 1921) +++ trunk/OpenMPT/soundlib/Sndmix.cpp 2013-04-21 14:38:08 UTC (rev 1922) @@ -177,7 +177,7 @@ UINT CSoundFile::Read(LPVOID lpDestBuffer, UINT count) -//------------------------------------------------------- +//---------------------------------------------------- { LPBYTE lpBuffer = (LPBYTE)lpDestBuffer; LPCONVERTPROC pCvt = nullptr; @@ -436,7 +436,7 @@ m_nMusicSpeed = m_nDefaultSpeed; m_nMusicTempo = m_nDefaultTempo; m_nGlobalVolume = m_nDefaultGlobalVolume; - for (UINT i=0; i<MAX_CHANNELS; i++) + for(CHANNELINDEX i = 0; i < MAX_CHANNELS; i++) { Chn[i].dwFlags.set(CHN_NOTEFADE | CHN_KEYOFF); Chn[i].nFadeOutVol = 0; @@ -546,7 +546,7 @@ } else { // Ok, this is really dirty, but we have to update the visited rows vector... - GetLength(eAdjustOnSuccess, m_nCurrentOrder, m_nRow); + GetLength(eAdjustOnSuccess, GetLengthTarget(m_nCurrentOrder, m_nRow)); } } } @@ -1365,7 +1365,7 @@ else chn.nVibratoPos = (vibpos + chn.nVibratoSpeed) & 0x3F; } - } else if(chn.dwOldFlags & CHN_VIBRATO) + } else if(chn.dwOldFlags[CHN_VIBRATO]) { // Stop MIDI vibrato for plugins: IMixPlugin *plugin = GetChannelInstrumentPlugin(nChn); @@ -1961,7 +1961,7 @@ realvol = (pChn->nRealVolume * kChnMasterVol) >> 8; } - const forcePanningMode panningMode = m_PlayConfig.getForcePanningMode(); + const forcePanningMode panningMode = m_PlayConfig.getForcePanningMode(); if (panningMode == forceSoftPanning || (panningMode == dontForcePanningMode && (m_MixerSettings.MixerFlags & SNDMIX_SOFTPANNING))) { if (pan < 128) This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <sag...@us...> - 2013-04-21 17:14:36
|
Revision: 1923 http://sourceforge.net/p/modplug/code/1923 Author: saga-games Date: 2013-04-21 17:14:15 +0000 (Sun, 21 Apr 2013) Log Message: ----------- [Fix] Pattern Editor: Reverted playback cursor display behaviour to how it worked before OpenMPT 1.22 [Fix] FT2 Compatibility: Fixed Rxy a bit more (http://forum.openmpt.org/index.php?topic=4999.0) [Mod] OpenMPT: Version is now 1.22.02.01 Modified Paths: -------------- trunk/OpenMPT/common/version.h trunk/OpenMPT/mptrack/MainFrm.cpp trunk/OpenMPT/mptrack/View_pat.cpp trunk/OpenMPT/soundlib/Snd_fx.cpp Modified: trunk/OpenMPT/common/version.h =================================================================== --- trunk/OpenMPT/common/version.h 2013-04-21 14:38:08 UTC (rev 1922) +++ trunk/OpenMPT/common/version.h 2013-04-21 17:14:15 UTC (rev 1923) @@ -21,7 +21,7 @@ #define VER_MAJORMAJOR 1 #define VER_MAJOR 22 #define VER_MINOR 02 -#define VER_MINORMINOR 00 +#define VER_MINORMINOR 01 //Creates version number from version parts that appears in version string. //For example MAKE_VERSION_NUMERIC(1,17,02,28) gives version number of Modified: trunk/OpenMPT/mptrack/MainFrm.cpp =================================================================== --- trunk/OpenMPT/mptrack/MainFrm.cpp 2013-04-21 14:38:08 UTC (rev 1922) +++ trunk/OpenMPT/mptrack/MainFrm.cpp 2013-04-21 17:14:15 UTC (rev 1923) @@ -1637,7 +1637,7 @@ // Avoid global volume ramping when trying samples in the treeview. m_WaveFile.m_nDefaultGlobalVolume = m_WaveFile.m_nGlobalVolume = MAX_GLOBAL_VOLUME; m_WaveFile.SetMixLevels(mixLevels_117RC3); - m_WaveFile.m_nSamplePreAmp = m_WaveFile.GetPlayConfig().getNormalSamplePreAmp(); + m_WaveFile.m_nSamplePreAmp = static_cast<uint32>(m_WaveFile.GetPlayConfig().getNormalSamplePreAmp()); m_WaveFile.m_nDefaultTempo = 125; m_WaveFile.m_nDefaultSpeed = 6; m_WaveFile.m_nType = MOD_TYPE_MPT; Modified: trunk/OpenMPT/mptrack/View_pat.cpp =================================================================== --- trunk/OpenMPT/mptrack/View_pat.cpp 2013-04-21 14:38:08 UTC (rev 1922) +++ trunk/OpenMPT/mptrack/View_pat.cpp 2013-04-21 17:14:15 UTC (rev 1923) @@ -3570,6 +3570,11 @@ UpdateAllVUMeters(pnotify); } + if(pnotify->type[Notification::Stop] && ((m_Status & (psFollowSong | psDragActive)) == psFollowSong)) + { + SetPlayCursor(PATTERNINDEX_INVALID, ROWINDEX_INVALID); + } + UpdateIndicator(); return 0; Modified: trunk/OpenMPT/soundlib/Snd_fx.cpp =================================================================== --- trunk/OpenMPT/soundlib/Snd_fx.cpp 2013-04-21 14:38:08 UTC (rev 1922) +++ trunk/OpenMPT/soundlib/Snd_fx.cpp 2013-04-21 17:14:15 UTC (rev 1923) @@ -127,10 +127,9 @@ // Get mod length in various cases. Parameters: // [in] adjustMode: See enmGetLengthResetMode for possible adjust modes. -// [in] endOrder: Order which should be reached (ORDERINDEX_INVALID means whole song) -// [in] endRow: Row in that order that should be reached +// [in] target: Time or position target which should be reached, or no target to get length of the first sub song. // [out] duration: total time in seconds -// [out] targetReached: true if the specified order/row combination has been reached while going through the module. +// [out] targetReached: true if the specified target has been reached while going through the module. // [out] lastOrder: last parsed order (if no target is specified, this is the first order that is parsed twice, i.e. not the *last* played order) // [out] lastRow: last parsed row (dito) // [out] endOrder: last order before module loops (UNDEFINED if a target is specified) @@ -4109,7 +4108,7 @@ int nRetrigCount = chn.nRetrigCount; bool bDoRetrig = false; - //IT compatibility 15. Retrigger + // IT compatibility 15. Retrigger if(IsCompatibleMode(TRK_IMPULSETRACKER)) { if(m_nTickCount == 0 && chn.rowCommand.note) @@ -4123,13 +4122,13 @@ } } else if(IsCompatibleMode(TRK_FASTTRACKER2) && (param & 0x100)) { - // buggy-like-hell FT2 Rxy retrig! + // Buggy-like-hell FT2 Rxy retrig! if(m_SongFlags[SONG_FIRSTTICK]) { - // here are some really stupid things FT2 does + // Here are some really stupid things FT2 does. if(chn.rowCommand.volcmd == VOLCMD_VOLUME) return; if(chn.rowCommand.instr > 0 && chn.rowCommand.note == NOTE_NONE) nRetrigCount = 1; - if(chn.rowCommand.note != NOTE_NONE && chn.rowCommand.note <= GetModSpecifications().noteMax) nRetrigCount++; + if(chn.rowCommand.IsNote()) nRetrigCount = 1; } if (nRetrigCount >= nRetrigSpeed) { This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <sag...@us...> - 2013-04-22 16:38:33
|
Revision: 1931 http://sourceforge.net/p/modplug/code/1931 Author: saga-games Date: 2013-04-22 16:38:18 +0000 (Mon, 22 Apr 2013) Log Message: ----------- [Mod] +++ and --- entries are no longer exported to XM files. [Imp] Mod Conversion: When converting to MOD or XM, --- and +++ order items are automatically removed and pattern jump commands are updated accordingly. [Mod] OpenMPT: Version is now 1.22.02.02 Modified Paths: -------------- trunk/OpenMPT/common/version.h trunk/OpenMPT/mptrack/MPTHacks.cpp trunk/OpenMPT/mptrack/PatternClipboard.cpp trunk/OpenMPT/soundlib/Load_xm.cpp trunk/OpenMPT/soundlib/ModSequence.cpp trunk/OpenMPT/soundlib/ModSequence.h trunk/OpenMPT/soundlib/mod_specifications.cpp trunk/OpenMPT/soundlib/mod_specifications.h trunk/OpenMPT/soundlib/patternContainer.cpp Modified: trunk/OpenMPT/common/version.h =================================================================== --- trunk/OpenMPT/common/version.h 2013-04-22 15:30:53 UTC (rev 1930) +++ trunk/OpenMPT/common/version.h 2013-04-22 16:38:18 UTC (rev 1931) @@ -21,7 +21,7 @@ #define VER_MAJORMAJOR 1 #define VER_MAJOR 22 #define VER_MINOR 02 -#define VER_MINORMINOR 01 +#define VER_MINORMINOR 02 //Creates version number from version parts that appears in version string. //For example MAKE_VERSION_NUMERIC(1,17,02,28) gives version number of Modified: trunk/OpenMPT/mptrack/MPTHacks.cpp =================================================================== --- trunk/OpenMPT/mptrack/MPTHacks.cpp 2013-04-22 15:30:53 UTC (rev 1930) +++ trunk/OpenMPT/mptrack/MPTHacks.cpp 2013-04-22 16:38:18 UTC (rev 1931) @@ -101,57 +101,6 @@ } -// Functor for fixing jump commands to moved order items -struct FixJumpCommands -//==================== -{ - FixJumpCommands(const vector<PATTERNINDEX> &offsets) : jumpOffset(offsets) {}; - - void operator()(ModCommand& m) - { - if(m.command == CMD_POSITIONJUMP && m.param < jumpOffset.size()) - { - m.param = BYTE(int(m.param) - jumpOffset[m.param]); - } - } - - const vector<PATTERNINDEX> jumpOffset; -}; - - -void RemoveFromOrder(CSoundFile &rSndFile, PATTERNINDEX which) -//------------------------------------------------------------ -{ - const ORDERINDEX orderLength = rSndFile.Order.GetLengthTailTrimmed(); - ORDERINDEX currentLength = orderLength; - - // Associate order item index with jump offset (i.e. how much it moved forwards) - vector<PATTERNINDEX> jumpOffset(orderLength, 0); - PATTERNINDEX maxJump = 0; - - for(ORDERINDEX i = 0; i < currentLength; i++) - { - if(rSndFile.Order[i] == which) - { - maxJump++; - // Move order list forwards, update jump counters - for(ORDERINDEX j = i + 1; j < orderLength; j++) - { - rSndFile.Order[j - 1] = rSndFile.Order[j]; - jumpOffset[j] = maxJump; - } - rSndFile.Order[--currentLength] = rSndFile.Order.GetInvalidPatIndex(); - } - } - - rSndFile.Patterns.ForEachModCommand(FixJumpCommands(jumpOffset)); - if(rSndFile.m_nRestartPos < jumpOffset.size()) - { - rSndFile.m_nRestartPos -= jumpOffset[rSndFile.m_nRestartPos]; - } -} - - // Go through the module to find out if it contains any hacks introduced by (Open)MPT bool CModDoc::HasMPTHacks(const bool autofix) //------------------------------------------- @@ -202,21 +151,21 @@ if(autofix) { - RemoveFromOrder(m_SndFile, m_SndFile.Order.GetIgnoreIndex()); + m_SndFile.Order.RemovePattern(m_SndFile.Order.GetIgnoreIndex()); } break; } } - if((m_SndFile.GetType() & (MOD_TYPE_MOD | MOD_TYPE_XM)) && m_SndFile.Order.GetLengthFirstEmpty() != m_SndFile.Order.GetLengthTailTrimmed()) + if(!originalSpecs->hasStopIndex && m_SndFile.Order.GetLengthFirstEmpty() != m_SndFile.Order.GetLengthTailTrimmed()) { foundHacks = true; AddToLog("The pattern sequence should end after the first stop (---) index in this format."); if(autofix) { - RemoveFromOrder(m_SndFile, m_SndFile.Order.GetInvalidPatIndex()); + m_SndFile.Order.RemovePattern(m_SndFile.Order.GetInvalidPatIndex()); } } Modified: trunk/OpenMPT/mptrack/PatternClipboard.cpp =================================================================== --- trunk/OpenMPT/mptrack/PatternClipboard.cpp 2013-04-22 15:30:53 UTC (rev 1930) +++ trunk/OpenMPT/mptrack/PatternClipboard.cpp 2013-04-22 16:38:18 UTC (rev 1931) @@ -408,7 +408,9 @@ // Next order item, please pos = data.Find(",", pos + 1) + 1; - if((insertPat == sndFile.Order.GetIgnoreIndex() && !sndFile.GetModSpecifications().hasIgnoreIndex) || insertPat == PATTERNINDEX_INVALID) + if((insertPat == sndFile.Order.GetIgnoreIndex() && !sndFile.GetModSpecifications().hasIgnoreIndex) + || (insertPat == sndFile.Order.GetInvalidPatIndex() && !sndFile.GetModSpecifications().hasStopIndex) + || insertPat == PATTERNINDEX_INVALID) { continue; } Modified: trunk/OpenMPT/soundlib/Load_xm.cpp =================================================================== --- trunk/OpenMPT/soundlib/Load_xm.cpp 2013-04-22 15:30:53 UTC (rev 1930) +++ trunk/OpenMPT/soundlib/Load_xm.cpp 2013-04-22 16:38:18 UTC (rev 1931) @@ -19,12 +19,12 @@ // Allocate samples for an instrument -vector<SAMPLEINDEX> AllocateXMSamples(CSoundFile &sndFile, SAMPLEINDEX numSamples) -//-------------------------------------------------------------------------------- +static std::vector<SAMPLEINDEX> AllocateXMSamples(CSoundFile &sndFile, SAMPLEINDEX numSamples) +//-------------------------------------------------------------------------------------------- { LimitMax(numSamples, SAMPLEINDEX(32)); - vector<SAMPLEINDEX> foundSlots; + std::vector<SAMPLEINDEX> foundSlots; for(SAMPLEINDEX i = 0; i < numSamples; i++) { @@ -68,7 +68,7 @@ if(candidateSlot >= MAX_SAMPLES) { // Still couldn't find any empty sample slots, so look out for existing but unused samples. - vector<bool> usedSamples; + std::vector<bool> usedSamples; SAMPLEINDEX unusedSampleCount = sndFile.DetectUnusedSamples(usedSamples); if(unusedSampleCount > 0) @@ -275,6 +275,7 @@ StringFixer::ReadString<StringFixer::spacePadded>(m_szNames[0], fileHeader.songName); + m_nType = MOD_TYPE_NONE; // Ensure that order list items FE and FF are not converted. ChangeModTypeTo(MOD_TYPE_XM); m_nMinPeriod = 27; m_nMaxPeriod = 54784; @@ -299,7 +300,7 @@ } // In case of XM versions < 1.04, we need to memorize the sample flags for all samples, as they are not stored immediately after the sample headers. - vector<SampleIO> sampleFlags; + std::vector<SampleIO> sampleFlags; uint8 sampleReserved = 0; // Reading instruments @@ -358,7 +359,7 @@ } // Read sample headers - vector<SAMPLEINDEX> sampleSlots = AllocateXMSamples(*this, instrHeader.numSamples); + std::vector<SAMPLEINDEX> sampleSlots = AllocateXMSamples(*this, instrHeader.numSamples); // Update sample assignment map for(size_t k = 0 + 12; k < 96 + 12; k++) @@ -374,7 +375,7 @@ sampleFlags.clear(); } // Need to memorize those if we're going to skip any samples... - vector<uint32> sampleSize(instrHeader.numSamples); + std::vector<uint32> sampleSize(instrHeader.numSamples); // Early versions of Sk@le Tracker didn't set sampleHeaderSize (this fixes IFULOVE.XM) const size_t copyBytes = (instrHeader.sampleHeaderSize > 0) ? instrHeader.sampleHeaderSize : sizeof(XMSample); @@ -537,12 +538,20 @@ } } + // We no longer allow any --- or +++ items in the order list now. + if(m_dwLastSavedWithVersion && m_dwLastSavedWithVersion < MAKE_VERSION_NUMERIC(1, 22, 02, 02)) + { + if(!Patterns.IsValidPat(0xFE)) + Order.RemovePattern(0xFE); + if(!Patterns.IsValidPat(0xFF)) + Order.RemovePattern(0xFF); + } + return true; } #ifndef MODPLUG_NO_FILESAVE -#include "../mptrack/Moddoc.h" // for logging errors #define str_tooMuchPatternData (GetStrI18N((_TEXT("Warning: File format limit was reached. Some pattern data may not get written to file.")))) #define str_pattern (GetStrI18N((_TEXT("pattern")))) @@ -551,24 +560,12 @@ bool CSoundFile::SaveXM(LPCSTR lpszFileName, bool compatibilityExport) //-------------------------------------------------------------------- { - #define ASSERT_CAN_WRITE(x) \ - if(len > s.size() - x) /*Buffer running out? Make it larger.*/ \ - s.resize(s.size() + 10*1024, 0); \ - \ - if((len > uint16_max - (UINT)x) && GetpModDoc()) /*Reaching the limits of file format?*/ \ - { \ - mpt::String str; str.Format("%s (%s %u)", str_tooMuchPatternData, str_pattern, pat); \ - AddToLog(str); \ - break; \ - } - FILE *f; if(lpszFileName == nullptr || (f = fopen(lpszFileName, "wb")) == nullptr) { return false; } - vector<uint8> s(64 * 64 * 5, 0); bool addChannel = false; // avoid odd channel count for FT2 compatibility XMFileHeader fileHeader; @@ -585,7 +582,7 @@ fileHeader.restartPos = m_nRestartPos; fileHeader.channels = (m_nChannels + 1) & 0xFFFE; // avoid odd channel count for FT2 compatibility - if((m_nChannels & 1) && m_nChannels < MAX_BASECHANNELS) addChannel = true; + if((m_nChannels % 2u) && m_nChannels < MAX_BASECHANNELS) addChannel = true; if(compatibilityExport && fileHeader.channels > 32) fileHeader.channels = 32; if(fileHeader.channels > MAX_BASECHANNELS) fileHeader.channels = MAX_BASECHANNELS; @@ -593,21 +590,28 @@ // Find out number of orders and patterns used. // +++ and --- patterns are not taken into consideration as FastTracker does not support them. - ORDERINDEX nMaxOrds = 0; - PATTERNINDEX nPatterns = 0; + ORDERINDEX maxOrders = 0; + PATTERNINDEX numPatterns = Patterns.GetNumPatterns(); + bool changeOrderList = false; for(ORDERINDEX ord = 0; ord < Order.GetLengthTailTrimmed(); ord++) { - if(Patterns.IsValidIndex(Order[ord])) + if(Order[ord] == Order.GetIgnoreIndex() || Order[ord] == Order.GetInvalidPatIndex()) { - nMaxOrds++; - if(Order[ord] >= nPatterns) nPatterns = Order[ord] + 1; + changeOrderList = true; + } else + { + maxOrders++; + if(Order[ord] >= numPatterns) numPatterns = Order[ord] + 1; } } - if(!compatibilityExport) nMaxOrds = Order.GetLengthTailTrimmed(); // should really be removed at some point + if(changeOrderList) + { + AddToLog("Skip and stop order list items (+++ and ---) are not saved in XM files."); + } - fileHeader.orders = nMaxOrds; - fileHeader.patterns = nPatterns; - fileHeader.size = fileHeader.size + nMaxOrds; + fileHeader.orders = maxOrders; + fileHeader.patterns = numPatterns; + fileHeader.size = fileHeader.size + maxOrders; uint16 writeInstruments; if(m_nInstruments > 0) @@ -619,9 +623,6 @@ if(m_SongFlags[SONG_EXFILTERRANGE] && !compatibilityExport) fileHeader.flags |= XMFileHeader::extendedFilterRange; fileHeader.flags = fileHeader.flags; -// if(compatibilityExport) -// xmheader.tempo = static_cast<uint16>(Clamp(m_nDefaultTempo, 32u, 255u)); -// else // Fasttracker 2 will happily accept any tempo faster than 255 BPM. XMPlay does also support this, great! fileHeader.tempo = static_cast<uint16>(Clamp(m_nDefaultTempo, 32u, 512u)); fileHeader.speed = static_cast<uint16>(Clamp(m_nDefaultSpeed, 1u, 31u)); @@ -632,7 +633,7 @@ // write order list (without +++ and ---, explained above) for(ORDERINDEX ord = 0; ord < Order.GetLengthTailTrimmed(); ord++) { - if(Patterns.IsValidIndex(Order[ord]) || !compatibilityExport) + if(Order[ord] != Order.GetIgnoreIndex() && Order[ord] != Order.GetInvalidPatIndex()) { uint8 ordItem = static_cast<uint8>(Order[ord]); fwrite(&ordItem, 1, 1, f); @@ -640,7 +641,13 @@ } // Writing patterns - for(PATTERNINDEX pat = 0; pat < nPatterns; pat++) + +#define ASSERT_CAN_WRITE(x) \ + if(len > s.size() - x) /*Buffer running out? Make it larger.*/ \ + s.resize(s.size() + 10 * 1024, 0); + std::vector<uint8> s(64 * 64 * 5, 0); + + for(PATTERNINDEX pat = 0; pat < numPatterns; pat++) { uint8 patHead[9]; MemsetZero(patHead); @@ -757,14 +764,24 @@ len = 0; } + // Reaching the limits of file format? + if(len > uint16_max) + { + mpt::String str; str.Format("%s (%s %u)", str_tooMuchPatternData, str_pattern, pat); + AddToLog(str); + len = uint16_max; + } + patHead[7] = static_cast<uint8>(len & 0xFF); patHead[8] = static_cast<uint8>(len >> 8); fwrite(patHead, 1, 9, f); - if(len) fwrite(&s[0], 1, len, f); + if(len) fwrite(&s[0], len, 1, f); } +#undef ASSERT_CAN_WRITE + // Check which samples are referenced by which instruments (for assigning unreferenced samples to instruments) - vector<bool> sampleAssigned(GetNumSamples() + 1, false); + std::vector<bool> sampleAssigned(GetNumSamples() + 1, false); for(INSTRUMENTINDEX ins = 1; ins <= GetNumInstruments(); ins++) { if(Instruments[ins] != nullptr) @@ -777,7 +794,7 @@ for(INSTRUMENTINDEX ins = 1; ins <= writeInstruments; ins++) { XMInstrumentHeader insHeader; - vector<SAMPLEINDEX> samples; + std::vector<SAMPLEINDEX> samples; if(GetNumInstruments()) { @@ -793,14 +810,14 @@ insHeader.instrument.ApplyAutoVibratoToXM(Samples[samples[0]], GetType()); } - vector<SAMPLEINDEX> additionalSamples; + std::vector<SAMPLEINDEX> additionalSamples; // Try to save "instrument-less" samples as well by adding those after the "normal" samples of our sample. // We look for unassigned samples directly after the samples assigned to our current instrument, so if // e.g. sample 1 is assigned to instrument 1 and samples 2 to 10 aren't assigned to any instrument, // we will assign those to sample 1. Any samples before the first referenced sample are going to be lost, // but hey, I wrote this mostly for preserving instrument texts in existing modules, where we shouldn't encounter this situation... - for(vector<SAMPLEINDEX>::const_iterator sample = samples.begin(); sample != samples.end(); sample++) + for(std::vector<SAMPLEINDEX>::const_iterator sample = samples.begin(); sample != samples.end(); sample++) { SAMPLEINDEX smp = *sample; while(++smp <= GetNumSamples() @@ -832,7 +849,7 @@ insHeader.ConvertEndianness(); fwrite(&insHeader, 1, insHeaderSize, f); - vector<SampleIO> sampleFlags(samples.size()); + std::vector<SampleIO> sampleFlags(samples.size()); // Write Sample Headers for(SAMPLEINDEX smp = 0; smp < samples.size(); smp++) @@ -866,57 +883,70 @@ if(!compatibilityExport) { // Writing song comments + char magic[4]; + int32 size; if(!songMessage.empty()) { - DWORD d = 0x74786574; - fwrite(&d, 1, 4, f); - d = songMessage.length(); - fwrite(&d, 1, 4, f); - fwrite(songMessage.c_str(), 1, d, f); + memcpy(magic, "text", 4); + fwrite(magic, 1, 4, f); + + size = songMessage.length(); + SwapBytesLE(size); + fwrite(&size, 1, 4, f); + + fwrite(songMessage.c_str(), 1, songMessage.length(), f); } // Writing midi cfg - if (m_SongFlags[SONG_EMBEDMIDICFG]) + if(m_SongFlags[SONG_EMBEDMIDICFG]) { - DWORD d = 0x4944494D; - fwrite(&d, 1, 4, f); - d = sizeof(MIDIMacroConfigData); - fwrite(&d, 1, 4, f); + memcpy(magic, "MIDI", 4); + fwrite(magic, 1, 4, f); + + size = sizeof(MIDIMacroConfigData); + SwapBytesLE(size); + fwrite(&size, 1, 4, f); + fwrite(static_cast<MIDIMacroConfigData*>(&m_MidiCfg), 1, sizeof(MIDIMacroConfigData), f); } // Writing Pattern Names const PATTERNINDEX numNamedPats = Patterns.GetNumNamedPatterns(); - if (numNamedPats > 0) + if(numNamedPats > 0) { - DWORD dwLen = numNamedPats * MAX_PATTERNNAME; - DWORD d = 0x4d414e50; - fwrite(&d, 1, 4, f); - fwrite(&dwLen, 1, 4, f); + memcpy(magic, "PNAM", 4); + fwrite(magic, 1, 4, f); - for(PATTERNINDEX nPat = 0; nPat < numNamedPats; nPat++) + size = numNamedPats * MAX_PATTERNNAME; + SwapBytesLE(size); + fwrite(&size, 1, 4, f); + + for(PATTERNINDEX pat = 0; pat < numNamedPats; pat++) { char name[MAX_PATTERNNAME]; MemsetZero(name); - Patterns[nPat].GetName(name); + Patterns[pat].GetName(name); fwrite(name, 1, MAX_PATTERNNAME, f); } } // Writing Channel Names { - UINT nChnNames = 0; - for (UINT inam=0; inam<m_nChannels; inam++) + CHANNELINDEX numNamedChannels = 0; + for(CHANNELINDEX chn = 0; chn < m_nChannels; chn++) { - if (ChnSettings[inam].szName[0]) nChnNames = inam+1; + if (ChnSettings[chn].szName[0]) numNamedChannels = chn + 1; } // Do it! - if (nChnNames) + if(numNamedChannels) { - DWORD dwLen = nChnNames * MAX_CHANNELNAME; - DWORD d = 0x4d414e43; - fwrite(&d, 1, 4, f); - fwrite(&dwLen, 1, 4, f); - for (UINT inam=0; inam<nChnNames; inam++) + memcpy(magic, "CNAM", 4); + fwrite(magic, 1, 4, f); + + size = numNamedChannels * MAX_CHANNELNAME; + SwapBytesLE(size); + fwrite(&size, 1, 4, f); + + for(CHANNELINDEX chn = 0; chn < numNamedChannels; chn++) { - fwrite(ChnSettings[inam].szName, 1, MAX_CHANNELNAME, f); + fwrite(ChnSettings[chn].szName, 1, MAX_CHANNELNAME, f); } } } Modified: trunk/OpenMPT/soundlib/ModSequence.cpp =================================================================== --- trunk/OpenMPT/soundlib/ModSequence.cpp 2013-04-22 15:30:53 UTC (rev 1930) +++ trunk/OpenMPT/soundlib/ModSequence.cpp 2013-04-22 16:38:18 UTC (rev 1931) @@ -22,15 +22,18 @@ #define str_SequenceTruncationNote (GetStrI18N((_TEXT("Module has sequence of length %u; it will be truncated to maximum supported length, %u.")))) +#ifdef _DEBUG #define new DEBUG_NEW +#undef THIS_FILE +static char THIS_FILE[] = __FILE__; +#endif - -ModSequence::ModSequence(CSoundFile& rSf, +ModSequence::ModSequence(CSoundFile &rSf, PATTERNINDEX* pArray, ORDERINDEX nSize, ORDERINDEX nCapacity, const bool bDeletableArray) : - m_pSndFile(&rSf), + m_sndFile(rSf), m_pArray(pArray), m_nSize(nSize), m_nCapacity(nCapacity), @@ -42,7 +45,7 @@ ModSequence::ModSequence(CSoundFile& rSf, ORDERINDEX nSize) : - m_pSndFile(&rSf), + m_sndFile(rSf), m_bDeletableArray(true), m_nInvalidIndex(GetInvalidPatIndex(MOD_TYPE_MPT)), m_nIgnoreIndex(GetIgnoreIndex(MOD_TYPE_MPT)) @@ -56,7 +59,7 @@ ModSequence::ModSequence(const ModSequence& seq) : - m_pSndFile(seq.m_pSndFile), + m_sndFile(seq.m_sndFile), m_bDeletableArray(false), m_nInvalidIndex(0xFF), m_nIgnoreIndex(0xFE), @@ -72,7 +75,7 @@ bool ModSequence::NeedsExtraDatafield() const //------------------------------------------- { - if(m_pSndFile->GetType() == MOD_TYPE_MPT && m_pSndFile->Patterns.Size() > 0xFD) + if(m_sndFile.GetType() == MOD_TYPE_MPT && m_sndFile.Patterns.Size() > 0xFD) return true; else return false; @@ -83,9 +86,9 @@ // Functor for detecting non-valid patterns from sequence. struct IsNotValidPat { - IsNotValidPat(CSoundFile& sndFile) : rSndFile(sndFile) {} - bool operator()(PATTERNINDEX i) {return !rSndFile.Patterns.IsValidPat(i);} - CSoundFile& rSndFile; + IsNotValidPat(const CSoundFile &sf) : sndFile(sf) { } + bool operator() (PATTERNINDEX i) { return !sndFile.Patterns.IsValidPat(i); } + const CSoundFile &sndFile; }; } @@ -93,42 +96,47 @@ void ModSequence::AdjustToNewModType(const MODTYPE oldtype) //--------------------------------------------------------- { - const CModSpecifications specs = m_pSndFile->GetModSpecifications(); - const MODTYPE newtype = m_pSndFile->GetType(); + const CModSpecifications specs = m_sndFile.GetModSpecifications(); + const MODTYPE newtype = m_sndFile.GetType(); m_nInvalidIndex = GetInvalidPatIndex(newtype); m_nIgnoreIndex = GetIgnoreIndex(newtype); - // If not supported, remove "+++" separator order items. - if (specs.hasIgnoreIndex == false) + if(oldtype != MOD_TYPE_NONE) { - if (oldtype != MOD_TYPE_NONE) + // If not supported, remove "+++" separator order items. + if(specs.hasIgnoreIndex == false) { - iterator i = std::remove_if(begin(), end(), std::bind2nd(std::equal_to<PATTERNINDEX>(), GetIgnoreIndex(oldtype))); - std::fill(i, end(), GetInvalidPatIndex()); + RemovePattern(GetIgnoreIndex(oldtype)); + } else + { + Replace(GetIgnoreIndex(oldtype), GetIgnoreIndex()); } + // If not supported, remove "---" items between patterns. + if(specs.hasStopIndex == false) + { + RemovePattern(GetInvalidPatIndex(oldtype)); + } } - else - Replace(GetIgnoreIndex(oldtype), GetIgnoreIndex()); //Resize orderlist if needed. - if (specs.ordersMax < GetLength()) + if(specs.ordersMax < GetLength()) { // Order list too long? -> remove unnecessary order items first. - if (oldtype != MOD_TYPE_NONE && specs.ordersMax < GetLengthTailTrimmed()) + if(oldtype != MOD_TYPE_NONE && specs.ordersMax < GetLengthTailTrimmed()) { - iterator iter = std::remove_if(begin(), end(), IsNotValidPat(*m_pSndFile)); + iterator iter = std::remove_if(begin(), end(), IsNotValidPat(m_sndFile)); std::fill(iter, end(), GetInvalidPatIndex()); if(GetLengthTailTrimmed() > specs.ordersMax) { - m_pSndFile->AddToLog("WARNING: Order list has been trimmed!"); + m_sndFile.AddToLog("WARNING: Order list has been trimmed!"); } } resize(specs.ordersMax); } // Replace items used to denote end of song order. - Replace(GetInvalidPatIndex(oldtype), GetInvalidPatIndex()); + if(oldtype != MOD_TYPE_NONE) Replace(GetInvalidPatIndex(oldtype), GetInvalidPatIndex()); } @@ -197,16 +205,68 @@ } +// Functor for fixing jump commands to moved order items +struct FixJumpCommands +//==================== +{ + FixJumpCommands(const std::vector<ORDERINDEX> &offsets) : jumpOffset(offsets) {}; + + void operator()(ModCommand& m) + { + if(m.command == CMD_POSITIONJUMP && m.param < jumpOffset.size()) + { + m.param = ModCommand::PARAM(int(m.param) - jumpOffset[m.param]); + } + } + + const std::vector<ORDERINDEX> jumpOffset; +}; + + +// Remove all references to a given pattern index from the order list. Jump commands are updated accordingly. +void ModSequence::RemovePattern(PATTERNINDEX which) +//------------------------------------------------- +{ + const ORDERINDEX orderLength = GetLengthTailTrimmed(); + ORDERINDEX currentLength = orderLength; + + // Associate order item index with jump offset (i.e. how much it moved forwards) + std::vector<ORDERINDEX> jumpOffset(orderLength, 0); + ORDERINDEX maxJump = 0; + + for(ORDERINDEX i = 0; i < currentLength; i++) + { + if(At(i) == which) + { + maxJump++; + // Move order list forwards, update jump counters + for(ORDERINDEX j = i + 1; j < orderLength; j++) + { + At(j - 1) = At(j); + jumpOffset[j] = maxJump; + } + At(--currentLength) = GetInvalidPatIndex(); + } + } + + m_sndFile.Patterns.ForEachModCommand(FixJumpCommands(jumpOffset)); + if(m_sndFile.m_nRestartPos < jumpOffset.size()) + { + m_sndFile.m_nRestartPos -= jumpOffset[m_sndFile.m_nRestartPos]; + } +} + + ORDERINDEX ModSequence::Insert(ORDERINDEX nPos, ORDERINDEX nCount, PATTERNINDEX nFill) //------------------------------------------------------------------------------------ { - if (nPos >= m_pSndFile->GetModSpecifications().ordersMax || nCount == 0) + if (nPos >= m_sndFile.GetModSpecifications().ordersMax || nCount == 0) return (nCount = 0); const ORDERINDEX nLengthTt = GetLengthTailTrimmed(); // Limit number of orders to be inserted. - LimitMax(nCount, ORDERINDEX(m_pSndFile->GetModSpecifications().ordersMax - nPos)); + LimitMax(nCount, ORDERINDEX(m_sndFile.GetModSpecifications().ordersMax - nPos)); // Calculate new length. - const ORDERINDEX nNewLength = MIN(nLengthTt + nCount, m_pSndFile->GetModSpecifications().ordersMax); + const ORDERINDEX nNewLength = MIN(nLengthTt + nCount, m_sndFile.GetModSpecifications().ordersMax); // Resize if needed. if (nNewLength > GetLength()) resize(nNewLength); @@ -379,7 +439,7 @@ { if(GetNumSequences() == MAX_SEQUENCES) return SEQUENCEINDEX_INVALID; - m_Sequences.push_back(ModSequence(*m_pSndFile, s_nCacheSize)); + m_Sequences.push_back(ModSequence(m_sndFile, s_nCacheSize)); if (bDuplicate) { m_Sequences.back() = *this; @@ -408,7 +468,7 @@ void ModSequenceSet::OnModTypeChanged(const MODTYPE oldtype) //---------------------------------------------------------- { - const MODTYPE newtype = m_pSndFile->GetType(); + const MODTYPE newtype = m_sndFile.GetType(); const SEQUENCEINDEX nSeqs = GetNumSequences(); for(SEQUENCEINDEX n = 0; n < nSeqs; n++) { @@ -428,14 +488,14 @@ //------------------------------------------------------- { // Allow conversion only if there's only one sequence. - if(GetNumSequences() != 1 || m_pSndFile->GetType() != MOD_TYPE_MPT) + if(GetNumSequences() != 1 || m_sndFile.GetType() != MOD_TYPE_MPT) return false; bool hasSepPatterns = false; const ORDERINDEX nLengthTt = GetLengthTailTrimmed(); for(ORDERINDEX nOrd = 0; nOrd < nLengthTt; nOrd++) { - if(!m_pSndFile->Patterns.IsValidPat(At(nOrd)) && At(nOrd) != GetIgnoreIndex()) + if(!m_sndFile.Patterns.IsValidPat(At(nOrd)) && At(nOrd) != GetIgnoreIndex()) { hasSepPatterns = true; break; @@ -457,11 +517,11 @@ for(ORDERINDEX nOrd = 0; nOrd < GetLengthTailTrimmed(); nOrd++) { // end of subsong? - if(!m_pSndFile->Patterns.IsValidPat(At(nOrd)) && At(nOrd) != GetIgnoreIndex()) + if(!m_sndFile.Patterns.IsValidPat(At(nOrd)) && At(nOrd) != GetIgnoreIndex()) { ORDERINDEX oldLength = GetLengthTailTrimmed(); // remove all separator patterns between current and next subsong first - while(nOrd < oldLength && (!m_pSndFile->Patterns.IsValidIndex(At(nOrd)))) + while(nOrd < oldLength && (!m_sndFile.Patterns.IsValidIndex(At(nOrd)))) { At(nOrd) = GetInvalidPatIndex(); nOrd++; @@ -488,10 +548,10 @@ nOrd++; // is this a valid pattern? adjust pattern jump commands, if necessary. - if(m_pSndFile->Patterns.IsValidPat(copyPat)) + if(m_sndFile.Patterns.IsValidPat(copyPat)) { - ModCommand *m = m_pSndFile->Patterns[copyPat]; - for(size_t len = m_pSndFile->Patterns[copyPat].GetNumRows() * m_pSndFile->m_nChannels; len; m++, len--) + ModCommand *m = m_sndFile.Patterns[copyPat]; + for(size_t len = m_sndFile.Patterns[copyPat].GetNumRows() * m_sndFile.m_nChannels; len; m++, len--) { if(m->command == CMD_POSITIONJUMP && m->param >= startOrd) { @@ -505,7 +565,7 @@ SetSequence(newSeq); // start from beginning... nOrd = 0; - if(GetLengthTailTrimmed() == 0 || !m_pSndFile->Patterns.IsValidIndex(At(nOrd))) break; + if(GetLengthTailTrimmed() == 0 || !m_sndFile.Patterns.IsValidIndex(At(nOrd))) break; } } SetSequence(0); @@ -513,6 +573,7 @@ return modified; } + bool ModSequenceSet::MergeSequences() //----------------------------------- { @@ -524,12 +585,12 @@ resize(GetLengthTailTrimmed()); SEQUENCEINDEX removedSequences = 0; // sequence count vector <SEQUENCEINDEX> patternsFixed; // pattern fixed by other sequence already? - patternsFixed.resize(m_pSndFile->Patterns.Size(), SEQUENCEINDEX_INVALID); + patternsFixed.resize(m_sndFile.Patterns.Size(), SEQUENCEINDEX_INVALID); // Set up vector for(ORDERINDEX nOrd = 0; nOrd < GetLengthTailTrimmed(); nOrd++) { PATTERNINDEX nPat = At(nOrd); - if(!m_pSndFile->Patterns.IsValidPat(nPat)) continue; + if(!m_sndFile.Patterns.IsValidPat(nPat)) continue; patternsFixed[nPat] = 0; } @@ -537,10 +598,10 @@ { removedSequences++; const ORDERINDEX nFirstOrder = GetLengthTailTrimmed() + 1; // +1 for separator item - if(nFirstOrder + GetSequence(1).GetLengthTailTrimmed() > m_pSndFile->GetModSpecifications().ordersMax) + if(nFirstOrder + GetSequence(1).GetLengthTailTrimmed() > m_sndFile.GetModSpecifications().ordersMax) { wsprintf(s, "WARNING: Cannot merge Sequence %d (too long!)", removedSequences); - m_pSndFile->AddToLog(s); + m_sndFile.AddToLog(s); RemoveSequence(1); continue; } @@ -551,24 +612,24 @@ Append(nPat); // Try to fix patterns (Bxx commands) - if(!m_pSndFile->Patterns.IsValidPat(nPat)) continue; + if(!m_sndFile.Patterns.IsValidPat(nPat)) continue; - ModCommand *m = m_pSndFile->Patterns[nPat]; - for(size_t len = 0; len < m_pSndFile->Patterns[nPat].GetNumRows() * m_pSndFile->m_nChannels; m++, len++) + ModCommand *m = m_sndFile.Patterns[nPat]; + for(size_t len = 0; len < m_sndFile.Patterns[nPat].GetNumRows() * m_sndFile.m_nChannels; m++, len++) { if(m->command == CMD_POSITIONJUMP) { if(patternsFixed[nPat] != SEQUENCEINDEX_INVALID && patternsFixed[nPat] != removedSequences) { // Oops, some other sequence uses this pattern already. - const PATTERNINDEX nNewPat = m_pSndFile->Patterns.Insert(m_pSndFile->Patterns[nPat].GetNumRows()); + const PATTERNINDEX nNewPat = m_sndFile.Patterns.Insert(m_sndFile.Patterns[nPat].GetNumRows()); if(nNewPat != SEQUENCEINDEX_INVALID) { // could create new pattern - copy data over and continue from here. At(nFirstOrder + nOrd) = nNewPat; - ModCommand *pSrc = m_pSndFile->Patterns[nPat]; - ModCommand *pDest = m_pSndFile->Patterns[nNewPat]; - memcpy(pDest, pSrc, m_pSndFile->Patterns[nPat].GetNumRows() * m_pSndFile->m_nChannels * sizeof(ModCommand)); + ModCommand *pSrc = m_sndFile.Patterns[nPat]; + ModCommand *pDest = m_sndFile.Patterns[nNewPat]; + memcpy(pDest, pSrc, m_sndFile.Patterns[nPat].GetNumRows() * m_sndFile.m_nChannels * sizeof(ModCommand)); m = pDest + len; patternsFixed.resize(MAX(nNewPat + 1, (PATTERNINDEX)patternsFixed.size()), SEQUENCEINDEX_INVALID); nPat = nNewPat; @@ -576,7 +637,7 @@ { // cannot create new pattern: notify the user wsprintf(s, "CONFLICT: Pattern break commands in Pattern %d might be broken since it has been used in several sequences!", nPat); - m_pSndFile->AddToLog(s); + m_sndFile.AddToLog(s); } } m->param = static_cast<BYTE>(m->param + nFirstOrder); @@ -589,7 +650,7 @@ } // Remove order name + fill up with empty patterns. m_sName = ""; - const ORDERINDEX nMinLength = std::min(ModSequenceSet::s_nCacheSize, m_pSndFile->GetModSpecifications().ordersMax); + const ORDERINDEX nMinLength = std::min(ModSequenceSet::s_nCacheSize, m_sndFile.GetModSpecifications().ordersMax); if(GetLength() < nMinLength) resize(nMinLength); return true; @@ -601,8 +662,8 @@ bool ModSequence::IsPositionLocked(ORDERINDEX position) //----------------------------------------------------- { - return(m_pSndFile->m_lockOrderStart != ORDERINDEX_INVALID - && (position < m_pSndFile->m_lockOrderStart || position > m_pSndFile->m_lockOrderEnd)); + return(m_sndFile.m_lockOrderStart != ORDERINDEX_INVALID + && (position < m_sndFile.m_lockOrderStart || position > m_sndFile.m_lockOrderEnd)); } #endif // MODPLUG_TRACKER @@ -669,7 +730,7 @@ //------------------------------------------------------------------------------------- { if(howMany < 0 || howMany > memLength) return false; - if(m_pSndFile->GetType() != MOD_TYPE_MPT && howMany > MAX_ORDERS) return false; + if(m_sndFile.GetType() != MOD_TYPE_MPT && howMany > MAX_ORDERS) return false; if(GetLength() < static_cast<size_t>(howMany)) resize(ORDERINDEX(howMany)); @@ -688,7 +749,7 @@ return false; } ORDERINDEX readEntries = static_cast<ORDERINDEX>(howMany); - if(!(m_pSndFile->GetType() & MOD_TYPE_MPT)) + if(!(m_sndFile.GetType() & MOD_TYPE_MPT)) { LimitMax(readEntries, MAX_ORDERS); } @@ -715,7 +776,7 @@ if(size > ModSpecs::mptm.ordersMax) { mpt::String str; str.Format(str_SequenceTruncationNote, size, ModSpecs::mptm.ordersMax); - seq.m_pSndFile->AddToLog(str); + seq.m_sndFile.AddToLog(str); size = ModSpecs::mptm.ordersMax; } seq.resize(MAX(size, MAX_ORDERS)); @@ -811,7 +872,7 @@ LimitMax(nSeqs, MAX_SEQUENCES); ssb.ReadItem(nCurrent, "c"); if (seq.GetNumSequences() < nSeqs) - seq.m_Sequences.resize(nSeqs, ModSequence(*seq.m_pSndFile, seq.s_nCacheSize)); + seq.m_Sequences.resize(nSeqs, ModSequence(seq.m_sndFile, seq.s_nCacheSize)); for(uint8 i = 0; i < nSeqs; i++) ssb.ReadItem(seq.m_Sequences[i], &i, sizeof(i), &ReadModSequence); Modified: trunk/OpenMPT/soundlib/ModSequence.h =================================================================== --- trunk/OpenMPT/soundlib/ModSequence.h 2013-04-22 15:30:53 UTC (rev 1930) +++ trunk/OpenMPT/soundlib/ModSequence.h 2013-04-22 16:38:18 UTC (rev 1931) @@ -59,6 +59,9 @@ // Removes orders from range [nPosBegin, nPosEnd]. void Remove(ORDERINDEX nPosBegin, ORDERINDEX nPosEnd); + // Remove all references to a given pattern index from the order list. Jump commands are updated accordingly. + void RemovePattern(PATTERNINDEX which); + void clear(); void resize(ORDERINDEX nNewSize) {resize(nNewSize, GetInvalidPatIndex());} void resize(ORDERINDEX nNewSize, PATTERNINDEX nFill); @@ -91,7 +94,7 @@ // Find an order item that contains a given pattern number. ORDERINDEX FindOrder(PATTERNINDEX nPat, ORDERINDEX startFromOrder = 0, bool searchForward = true) const; - + ModSequence& operator=(const ModSequence& seq); // Read/write. @@ -124,18 +127,18 @@ mpt::String m_sName; // Sequence name. protected: - PATTERNINDEX* m_pArray; // Pointer to sequence array. + PATTERNINDEX *m_pArray; // Pointer to sequence array. ORDERINDEX m_nSize; // Sequence length. ORDERINDEX m_nCapacity; // Capacity in m_pArray. PATTERNINDEX m_nInvalidIndex; // Invalid pat index. PATTERNINDEX m_nIgnoreIndex; // Ignore pat index. bool m_bDeletableArray; // True if m_pArray points the deletable(with delete[]) array. - CSoundFile* m_pSndFile; // Pointer to associated CSoundFile. + CSoundFile &m_sndFile; // Pointer to associated CSoundFile. }; -inline PATTERNINDEX ModSequence::GetInvalidPatIndex(const MODTYPE type) {return type == MOD_TYPE_MPT ? uint16_max : 0xFF;} -inline PATTERNINDEX ModSequence::GetIgnoreIndex(const MODTYPE type) {return type == MOD_TYPE_MPT ? uint16_max - 1 : 0xFE;} +inline PATTERNINDEX ModSequence::GetInvalidPatIndex(const MODTYPE type) {return (type & (MOD_TYPE_MPT | MOD_TYPE_XM)) ? uint16_max : 0xFF;} +inline PATTERNINDEX ModSequence::GetIgnoreIndex(const MODTYPE type) {return (type & (MOD_TYPE_MPT | MOD_TYPE_XM)) ? uint16_max - 1 : 0xFE;} template<typename T, size_t arraySize> @@ -145,7 +148,7 @@ LimitMax(howMany, arraySize); ORDERINDEX readEntries = static_cast<ORDERINDEX>(howMany); - if(!(m_pSndFile->GetType() & MOD_TYPE_MPT)) + if(!(m_sndFile.GetType() & MOD_TYPE_MPT)) { LimitMax(readEntries, MAX_ORDERS); } Modified: trunk/OpenMPT/soundlib/mod_specifications.cpp =================================================================== --- trunk/OpenMPT/soundlib/mod_specifications.cpp 2013-04-22 15:30:53 UTC (rev 1930) +++ trunk/OpenMPT/soundlib/mod_specifications.cpp 2013-04-22 16:38:18 UTC (rev 1931) @@ -55,6 +55,7 @@ " JFEGHLKRXODB?CQATI?SMNVW?UY?P?Z\\:#??", // Supported Effects " vpcdabuhlrgfe?o", // Supported Volume Column commands true, // Has "+++" pattern + true, // Has "---" pattern true, // Has restart position (order) true, // Supports plugins true, // Custom pattern time signatures @@ -99,6 +100,7 @@ " 0123456789ABCD?FF?E?????????????????", // Supported Effects " ???????????????", // Supported Volume Column commands false, // Doesn't have "+++" pattern + false, // Doesn't have "---" pattern true, // Has restart position (order) false, // Doesn't support plugins false, // No custom pattern time signatures @@ -141,6 +143,7 @@ " 0123456789ABCDRFFTE???GHK??XPL??????", // Supported Effects " vpcdabuhlrg????", // Supported Volume Column commands false, // Doesn't have "+++" pattern + false, // Doesn't have "---" pattern true, // Has restart position (order) false, // Doesn't support plugins false, // No custom pattern time signatures @@ -183,6 +186,7 @@ " 0123456789ABCDRFFTE???GHK?YXPLZ\\?#??", // Supported Effects " vpcdabuhlrgfe?o", // Supported Volume Column commands false, // Doesn't have "+++" pattern + false, // Doesn't have "---" pattern true, // Has restart position (order) true, // Supports plugins false, // No custom pattern time signatures @@ -224,6 +228,7 @@ " JFEGHLKRXODB?CQATI?SMNVW?U??????????", // Supported Effects " vp?????????????", // Supported Volume Column commands true, // Has "+++" pattern + true, // Has "---" pattern false, // Doesn't have restart position (order) false, // Doesn't support plugins false, // No custom pattern time signatures @@ -266,6 +271,7 @@ " JFEGHLKRXODB?CQATI?SMNVW?UY?P?Z?????", // Supported Effects " vp?????????????", // Supported Volume Column commands true, // Has "+++" pattern + true, // Has "---" pattern false, // Doesn't have restart position (order) false, // Doesn't support plugins false, // No custom pattern time signatures @@ -307,6 +313,7 @@ " JFEGHLKRXODB?CQATI?SMNVW?UY?P?Z?????", // Supported Effects " vpcdab?h??gfe??", // Supported Volume Column commands true, // Has "+++" pattern + true, // Has "--" pattern false, // Doesn't have restart position (order) false, // Doesn't support plugins false, // No custom pattern time signatures @@ -348,6 +355,7 @@ " JFEGHLKRXODB?CQATI?SMNVW?UY?P?Z\\?#??", // Supported Effects " vpcdab?h??gfe?o", // Supported Volume Column commands true, // Has "+++" pattern + true, // Has "---" pattern false, // Doesn't have restart position (order) true, // Supports plugins false, // No custom pattern time signatures Modified: trunk/OpenMPT/soundlib/mod_specifications.h =================================================================== --- trunk/OpenMPT/soundlib/mod_specifications.h 2013-04-22 15:30:53 UTC (rev 1930) +++ trunk/OpenMPT/soundlib/mod_specifications.h 2013-04-22 16:38:18 UTC (rev 1931) @@ -64,6 +64,7 @@ char commands[MAX_EFFECTS + 1]; // An array holding all commands this format supports; commands that are not supported are marked with "?" char volcommands[MAX_VOLCMDS + 1]; // dito, but for volume column bool hasIgnoreIndex; // Does "+++" pattern exist? + bool hasStopIndex; // Does "---" pattern exist? bool hasRestartPos; // Format has an automatic restart order position bool supportsPlugins; // Format can store plugins bool hasPatternSignatures; // Can patterns have a custom time signature? Modified: trunk/OpenMPT/soundlib/patternContainer.cpp =================================================================== --- trunk/OpenMPT/soundlib/patternContainer.cpp 2013-04-22 15:30:53 UTC (rev 1930) +++ trunk/OpenMPT/soundlib/patternContainer.cpp 2013-04-22 16:38:18 UTC (rev 1931) @@ -53,20 +53,14 @@ //--------------------------------------------------------------------------- { const CModSpecifications& specs = m_rSndFile.GetModSpecifications(); - if(index >= specs.patternsMax || index > m_Patterns.size() || rows > specs.patternRowsMax || rows == 0) + if(index >= specs.patternsMax || rows > specs.patternRowsMax || rows == 0) return true; if(index < m_Patterns.size() && m_Patterns[index]) return true; - if(index == m_Patterns.size()) + if(index >= m_Patterns.size()) { - if(index < specs.patternsMax) - m_Patterns.push_back(MODPATTERN(*this)); - else - { - GetSoundFile().AddToLog(LogError, "Too many patterns!"); - return true; - } + m_Patterns.resize(index + 1, MODPATTERN(*this)); } m_Patterns[index].AllocatePattern(rows); This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <sag...@us...> - 2013-04-22 20:21:03
|
Revision: 1932 http://sourceforge.net/p/modplug/code/1932 Author: saga-games Date: 2013-04-22 20:20:55 +0000 (Mon, 22 Apr 2013) Log Message: ----------- [Mod] XM Loader: Don't trash --- patterns when importing old XMs to maintain playback compatibility (only show a warning on saving). [New] Pattern Clipboard Manager: Can now rename clipboard entries by double-clicking them. Modified Paths: -------------- trunk/OpenMPT/mptrack/PatternClipboard.cpp trunk/OpenMPT/mptrack/PatternClipboard.h trunk/OpenMPT/soundlib/Load_xm.cpp Modified: trunk/OpenMPT/mptrack/PatternClipboard.cpp =================================================================== --- trunk/OpenMPT/mptrack/PatternClipboard.cpp 2013-04-22 16:38:18 UTC (rev 1931) +++ trunk/OpenMPT/mptrack/PatternClipboard.cpp 2013-04-22 20:20:55 UTC (rev 1932) @@ -903,6 +903,7 @@ BEGIN_MESSAGE_MAP(PatternClipboardDialog, CDialog) ON_EN_UPDATE(IDC_EDIT1, OnNumClipboardsChanged) ON_LBN_SELCHANGE(IDC_LIST1, OnSelectClipboard) + ON_LBN_DBLCLK(IDC_LIST1, OnEditName) END_MESSAGE_MAP() PatternClipboardDialog PatternClipboardDialog::instance; @@ -946,6 +947,7 @@ { return; } + OnEndEdit(); PatternClipboard::SetClipboardSize(GetDlgItemInt(IDC_EDIT1, nullptr, FALSE)); UpdateList(); } @@ -981,12 +983,41 @@ } PatternClipboard::clipindex_t item = reinterpret_cast<PatternClipboard::clipindex_t>(clipList.GetItemDataPtr(clipList.GetCurSel())); PatternClipboard::SelectClipboard(item); + OnEndEdit(); } +void PatternClipboardDialog::OnOK() +//--------------------------------- +{ + const CWnd *focus = GetFocus(); + if(focus == &editNameBox) + { + // User pressed enter in clipboard name edit box => cancel editing + OnEndEdit(); + } else if(focus == &clipList) + { + // User pressed enter in the clipboard name list => start editing + OnEditName(); + } else + { + CDialog::OnOK(); + } +} + + void PatternClipboardDialog::OnCancel() //------------------------------------- { + if(GetFocus() == &editNameBox) + { + // User pressed enter in clipboard name edit box => just cancel editing + editNameBox.DestroyWindow(); + return; + } + + OnEndEdit(false); + isCreated = false; isLocked = true; @@ -997,3 +1028,58 @@ DestroyWindow(); } + + +void PatternClipboardDialog::OnEditName() +//--------------------------------------- +{ + OnEndEdit(); + + const int sel = clipList.GetCurSel(); + if(sel == LB_ERR) + { + return; + } + + CRect rect; + clipList.GetItemRect(sel, rect); + rect.InflateRect(0, 2, 0, 2); + + // Create the edit control + editNameBox.Create(WS_VISIBLE | WS_CHILD | WS_BORDER | ES_LEFT | ES_AUTOHSCROLL, rect, &clipList, 1); + editNameBox.SetFont(clipList.GetFont()); + editNameBox.SetWindowText(PatternClipboard::instance.clipboards[sel].description); + editNameBox.SetSel(0, -1, TRUE); + editNameBox.SetFocus(); + SetWindowLongPtr(editNameBox.m_hWnd, GWLP_USERDATA, (LONG_PTR)clipList.GetItemDataPtr(sel)); +} + + +void PatternClipboardDialog::OnEndEdit(bool apply) +//------------------------------------------------ +{ + if(editNameBox.GetSafeHwnd() == NULL) + { + return; + } + + if(apply) + { + size_t sel = GetWindowLongPtr(editNameBox.m_hWnd, GWLP_USERDATA); + if(sel >= PatternClipboard::instance.clipboards.size()) + { + // What happened? + return; + } + + CString newName; + editNameBox.GetWindowText(newName); + + PatternClipboard::instance.clipboards[sel].description = newName; + } + + SetWindowLongPtr(editNameBox.m_hWnd, GWLP_USERDATA, LONG_PTR(-1)); + editNameBox.DestroyWindow(); + + UpdateList(); +} Modified: trunk/OpenMPT/mptrack/PatternClipboard.h =================================================================== --- trunk/OpenMPT/mptrack/PatternClipboard.h 2013-04-22 16:38:18 UTC (rev 1931) +++ trunk/OpenMPT/mptrack/PatternClipboard.h 2013-04-22 20:20:55 UTC (rev 1932) @@ -116,6 +116,7 @@ CSpinButtonCtrl numClipboardsSpin; CListBox clipList; + CEdit editNameBox; int posX, posY; bool isLocked, isCreated; @@ -132,7 +133,13 @@ virtual void DoDataExchange(CDataExchange* pDX); DECLARE_MESSAGE_MAP(); - afx_msg void OnCancel(); + virtual void OnOK(); + virtual void OnCancel(); + afx_msg void OnNumClipboardsChanged(); afx_msg void OnSelectClipboard(); + + // Edit clipboard name + afx_msg void OnEditName(); + void OnEndEdit(bool apply = true); }; Modified: trunk/OpenMPT/soundlib/Load_xm.cpp =================================================================== --- trunk/OpenMPT/soundlib/Load_xm.cpp 2013-04-22 16:38:18 UTC (rev 1931) +++ trunk/OpenMPT/soundlib/Load_xm.cpp 2013-04-22 20:20:55 UTC (rev 1932) @@ -544,7 +544,7 @@ if(!Patterns.IsValidPat(0xFE)) Order.RemovePattern(0xFE); if(!Patterns.IsValidPat(0xFF)) - Order.RemovePattern(0xFF); + Order.Replace(0xFF, Order.GetInvalidPatIndex()); } return true; This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <sag...@us...> - 2013-04-22 20:22:09
|
Revision: 1933 http://sourceforge.net/p/modplug/code/1933 Author: saga-games Date: 2013-04-22 20:21:59 +0000 (Mon, 22 Apr 2013) Log Message: ----------- [Ref] Small changes here and there. Modified Paths: -------------- trunk/OpenMPT/mptrack/MIDIMapping.cpp trunk/OpenMPT/mptrack/MIDIMapping.h trunk/OpenMPT/mptrack/MIDIMappingDialog.cpp trunk/OpenMPT/mptrack/dlg_misc.cpp trunk/OpenMPT/mptrack/dlg_misc.h trunk/OpenMPT/mptrack/mptrack.rc trunk/OpenMPT/mptrack/mptrack_10.vcxproj trunk/OpenMPT/mptrack/mptrack_10.vcxproj.filters trunk/OpenMPT/mptrack/resource.h trunk/OpenMPT/soundlib/ModSequence.cpp Modified: trunk/OpenMPT/mptrack/MIDIMapping.cpp =================================================================== --- trunk/OpenMPT/mptrack/MIDIMapping.cpp 2013-04-22 20:20:55 UTC (rev 1932) +++ trunk/OpenMPT/mptrack/MIDIMapping.cpp 2013-04-22 20:21:59 UTC (rev 1933) @@ -14,7 +14,7 @@ #include "Mainfrm.h" -mpt::String CMIDIMappingDirective::ToString() const +const char *CMIDIMappingDirective::ToString() const //------------------------------------------------- { mpt::String str; @@ -23,7 +23,7 @@ if(m_CaptureMIDI) flags[1] = '1'; if(m_AllowPatternEdit) flags[2] = '1'; str.Format("%s:%d:%x:%d:%d:%d", flags, (int)GetChannel(), (int)GetEvent(), (int)GetController(), (int)m_PluginIndex, m_Parameter); - return str; + return str.c_str(); } Modified: trunk/OpenMPT/mptrack/MIDIMapping.h =================================================================== --- trunk/OpenMPT/mptrack/MIDIMapping.h 2013-04-22 20:20:55 UTC (rev 1932) +++ trunk/OpenMPT/mptrack/MIDIMapping.h 2013-04-22 20:21:59 UTC (rev 1933) @@ -14,9 +14,7 @@ #include <algorithm> using std::vector; -namespace mpt { class String; } - //========================= class CMIDIMappingDirective //========================= @@ -59,7 +57,7 @@ bool operator==(const CMIDIMappingDirective& d) const {return memcmp(this, &d, sizeof(CMIDIMappingDirective)) == 0;} - mpt::String ToString() const; + const char *ToString() const; BYTE GetChnEvent() const {return m_ChnEvent;} Modified: trunk/OpenMPT/mptrack/MIDIMappingDialog.cpp =================================================================== --- trunk/OpenMPT/mptrack/MIDIMappingDialog.cpp 2013-04-22 20:20:55 UTC (rev 1932) +++ trunk/OpenMPT/mptrack/MIDIMappingDialog.cpp 2013-04-22 20:21:59 UTC (rev 1933) @@ -151,8 +151,8 @@ m_ChannelCBox.SetCurSel(activeSetting.GetChannel()); if(m_Setting.GetEvent() == MIDIEvents::evControllerChange) - m_EventCBox.SetCurSel(0); - else + m_EventCBox.SetCurSel(0); + else m_EventCBox.SetCurSel(-1); Modified: trunk/OpenMPT/mptrack/dlg_misc.cpp =================================================================== --- trunk/OpenMPT/mptrack/dlg_misc.cpp 2013-04-22 20:20:55 UTC (rev 1932) +++ trunk/OpenMPT/mptrack/dlg_misc.cpp 2013-04-22 20:21:59 UTC (rev 1933) @@ -459,32 +459,11 @@ ////////////////////////////////////////////////////////////////////////////// // CShowLogDlg -BEGIN_MESSAGE_MAP(CShowLogDlg, CDialog) - //{{AFX_MSG_MAP(CShowLogDlg) - //}}AFX_MSG_MAP -END_MESSAGE_MAP() - - - -void CShowLogDlg::DoDataExchange(CDataExchange* pDX) -//-------------------------------------------------- -{ - CDialog::DoDataExchange(pDX); - //{{AFX_DATA_MAP(CShowLogDlg) - DDX_Control(pDX, IDC_EDIT_LOG, m_EditLog); - //}}AFX_DATA_MAP -} - - BOOL CShowLogDlg::OnInitDialog() //------------------------------ { CDialog::OnInitDialog(); if (m_lpszTitle) SetWindowText(m_lpszTitle); - m_EditLog.SetSel(0, -1); - m_EditLog.ReplaceSel(m_lpszLog); - m_EditLog.SetFocus(); - m_EditLog.SetSel(0, 0); return FALSE; } Modified: trunk/OpenMPT/mptrack/dlg_misc.h =================================================================== --- trunk/OpenMPT/mptrack/dlg_misc.h 2013-04-22 20:20:55 UTC (rev 1932) +++ trunk/OpenMPT/mptrack/dlg_misc.h 2013-04-22 20:21:59 UTC (rev 1933) @@ -59,18 +59,13 @@ { public: LPCSTR m_lpszLog, m_lpszTitle; - CEdit m_EditLog; public: - CShowLogDlg(CWnd *parent=NULL):CDialog(IDD_SHOWLOG, parent) { m_lpszLog = NULL; m_lpszTitle = NULL; } + CShowLogDlg(CWnd *parent = nullptr):CDialog(IDD_SHOWLOG, parent) { m_lpszLog = NULL; m_lpszTitle = NULL; } UINT ShowLog(LPCSTR pszLog, LPCSTR lpszTitle=NULL); protected: - //{{AFX_VIRTUAL(CShowLogDlg) - virtual void DoDataExchange(CDataExchange* pDX); virtual BOOL OnInitDialog(); - //}}AFX_VIRTUAL - DECLARE_MESSAGE_MAP() }; Modified: trunk/OpenMPT/mptrack/mptrack.rc =================================================================== --- trunk/OpenMPT/mptrack/mptrack.rc 2013-04-22 20:20:55 UTC (rev 1932) +++ trunk/OpenMPT/mptrack/mptrack.rc 2013-04-22 20:21:59 UTC (rev 1933) @@ -24,16 +24,6 @@ // Dialog // -IDD_MODLOADING_WARNINGS DIALOGEX 0, 0, 316, 178 -STYLE DS_SYSMODAL | DS_SETFONT | DS_MODALFRAME | DS_SETFOREGROUND | DS_FIXEDSYS | WS_POPUP | WS_VISIBLE | WS_CAPTION | WS_SYSMENU -CAPTION "module.it - Warnings" -FONT 8, "MS Shell Dlg", 400, 0, 0x1 -BEGIN - DEFPUSHBUTTON "OK",IDOK,258,156,50,14 - EDITTEXT IDC_EDIT_MODLOADING_WARNINGS,6,18,300,132,ES_MULTILINE | ES_AUTOHSCROLL | ES_READONLY - LTEXT "The following problems have been encountered when loading this module:",IDC_STATIC,6,6,237,8 -END - IDD_CLEANUP_SONG DIALOGEX 0, 0, 394, 154 STYLE DS_SETFONT | DS_MODALFRAME | DS_FIXEDSYS | WS_POPUP | WS_CAPTION | WS_SYSMENU CAPTION "Cleanup" @@ -277,14 +267,6 @@ #ifdef APSTUDIO_INVOKED GUIDELINES DESIGNINFO BEGIN - IDD_MODLOADING_WARNINGS, DIALOG - BEGIN - LEFTMARGIN, 7 - RIGHTMARGIN, 309 - TOPMARGIN, 7 - BOTTOMMARGIN, 171 - END - IDD_CLEANUP_SONG, DIALOG BEGIN LEFTMARGIN, 7 @@ -923,14 +905,12 @@ GROUPBOX "OpenMPT Version Info",IDC_FRAME_MPTVERSION,6,263,246,48 END -IDD_SHOWLOG DIALOG 0, 0, 300, 106 -STYLE DS_SETFONT | DS_MODALFRAME | DS_3DLOOK | DS_CONTEXTHELP | WS_POPUP | WS_CAPTION | WS_SYSMENU -CAPTION "Information" -FONT 8, "MS Shell Dlg" +IDD_SHOWLOG DIALOGEX 0, 0, 300, 149 +STYLE DS_SETFONT | DS_MODALFRAME | DS_3DLOOK | DS_FIXEDSYS | DS_CONTEXTHELP | WS_POPUP | WS_CAPTION | WS_SYSMENU +FONT 8, "MS Shell Dlg", 0, 0, 0x0 BEGIN - DEFPUSHBUTTON "OK",IDOK,246,7,50,14 - PUSHBUTTON "Cancel",IDCANCEL,246,24,50,14 - EDITTEXT IDC_EDIT_LOG,6,7,234,96,ES_MULTILINE | ES_AUTOHSCROLL | ES_READONLY | WS_VSCROLL + DEFPUSHBUTTON "OK",IDOK,246,132,50,14 + EDITTEXT IDC_EDIT_LOG,6,7,288,119,ES_MULTILINE | ES_AUTOHSCROLL | ES_READONLY | WS_VSCROLL END IDD_REMOVECHANNELS DIALOGEX 0, 0, 171, 221 @@ -1520,15 +1500,6 @@ LTEXT "",IDC_RENDERZONE,4,3,414,84,NOT WS_VISIBLE END -IDD_SOUNDBANK_INFO1 DIALOGEX 0, 0, 271, 167 -STYLE DS_SETFONT | DS_MODALFRAME | WS_POPUP | WS_CAPTION | WS_SYSMENU -CAPTION "Sound Bank Information" -FONT 8, "MS Shell Dlg", 0, 0, 0x1 -BEGIN - DEFPUSHBUTTON "Close",IDOK,109,149,50,14 - EDITTEXT IDC_EDIT1,7,7,257,138,ES_MULTILINE | ES_AUTOVSCROLL | ES_AUTOHSCROLL | ES_READONLY | NOT WS_BORDER | NOT WS_TABSTOP,WS_EX_STATICEDGE -END - IDD_PITCHSHIFT DIALOGEX 0, 0, 181, 124 STYLE DS_SETFONT | DS_MODALFRAME | DS_FIXEDSYS | WS_POPUP | WS_CAPTION | WS_SYSMENU CAPTION "Time-Stretch Ratio Calculator" @@ -1717,7 +1688,7 @@ LEFTMARGIN, 7 RIGHTMARGIN, 293 TOPMARGIN, 7 - BOTTOMMARGIN, 99 + BOTTOMMARGIN, 142 END IDD_REMOVECHANNELS, DIALOG @@ -1855,14 +1826,6 @@ BOTTOMMARGIN, 104 END - IDD_SOUNDBANK_INFO1, DIALOG - BEGIN - LEFTMARGIN, 7 - RIGHTMARGIN, 264 - TOPMARGIN, 7 - BOTTOMMARGIN, 163 - END - IDD_PITCHSHIFT, DIALOG BEGIN END Modified: trunk/OpenMPT/mptrack/mptrack_10.vcxproj =================================================================== --- trunk/OpenMPT/mptrack/mptrack_10.vcxproj 2013-04-22 20:20:55 UTC (rev 1932) +++ trunk/OpenMPT/mptrack/mptrack_10.vcxproj 2013-04-22 20:21:59 UTC (rev 1933) @@ -497,6 +497,7 @@ <ClInclude Include="PatternClipboard.h" /> <ClInclude Include="PatternCursor.h" /> <ClInclude Include="Reporting.h" /> + <ClInclude Include="resource.h" /> <ClInclude Include="SelectPluginDialog.h" /> <ClInclude Include="ChannelManagerDlg.h" /> <ClInclude Include="CloseMainDialog.h" /> Modified: trunk/OpenMPT/mptrack/mptrack_10.vcxproj.filters =================================================================== --- trunk/OpenMPT/mptrack/mptrack_10.vcxproj.filters 2013-04-22 20:20:55 UTC (rev 1932) +++ trunk/OpenMPT/mptrack/mptrack_10.vcxproj.filters 2013-04-22 20:21:59 UTC (rev 1933) @@ -810,6 +810,9 @@ <ClInclude Include="..\common\svn_version_default\svn_version.h"> <Filter>Header Files\common</Filter> </ClInclude> + <ClInclude Include="resource.h"> + <Filter>Header Files</Filter> + </ClInclude> </ItemGroup> <ItemGroup> <None Include="res\bitmap1.bmp"> Modified: trunk/OpenMPT/mptrack/resource.h =================================================================== --- trunk/OpenMPT/mptrack/resource.h 2013-04-22 20:20:55 UTC (rev 1932) +++ trunk/OpenMPT/mptrack/resource.h 2013-04-22 20:21:59 UTC (rev 1933) @@ -118,7 +118,6 @@ #define IDB_VISPCNODE 437 #define IDD_DEFAULTPLUGINEDITOR 438 #define IDD_CHANNELMANAGER 440 -#define IDD_SOUNDBANK_INFO1 441 #define IDD_PITCHSHIFT 442 #define IDD_OPTIONS_AUTOSAVE 443 #define IDD_EDIT_GOTO 444 @@ -133,7 +132,6 @@ #define IDD_MIDIPARAMCONTROL 515 #define IDD_MSGBOX_HIDABLE 516 #define IDD_ADDSILENCE 517 -#define IDD_MODLOADING_WARNINGS 518 #define IDR_DEFAULT_KEYBINDINGS 519 #define IDR_BUILTIN_TUNINGS 520 #define IDD_CLEANUP_SONG 521 @@ -882,7 +880,6 @@ #define IDC_RADIO_ADDSILENCE_END 2381 #define IDC_SPIN_ADDSILENCE 2382 #define IDC_RADIO_RESIZETO 2384 -#define IDC_EDIT_MODLOADING_WARNINGS 2385 #define IDC_CHECK_PATRECORD 2386 #define IDC_LOAD_COLORSCHEME 2387 #define IDC_SAVE_COLORSCHEME 2388 Modified: trunk/OpenMPT/soundlib/ModSequence.cpp =================================================================== --- trunk/OpenMPT/soundlib/ModSequence.cpp 2013-04-22 20:20:55 UTC (rev 1932) +++ trunk/OpenMPT/soundlib/ModSequence.cpp 2013-04-22 20:21:59 UTC (rev 1933) @@ -793,7 +793,7 @@ void WriteModSequenceOld(std::ostream& oStrm, const ModSequenceSet& seq) -//------------------------------------------------------------------------- +//---------------------------------------------------------------------- { const uint16 size = seq.GetLength(); srlztn::Binarywrite<uint16>(oStrm, size); This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <man...@us...> - 2013-04-22 20:32:45
|
Revision: 1935 http://sourceforge.net/p/modplug/code/1935 Author: manxorist Date: 2013-04-22 20:32:38 +0000 (Mon, 22 Apr 2013) Log Message: ----------- [Ref] Split compile time build configuration out of stdafx.h into common/BuildSettings.h Modified Paths: -------------- trunk/OpenMPT/common/stdafx.h trunk/OpenMPT/mptrack/mptrack_08.vcproj trunk/OpenMPT/mptrack/mptrack_10.vcxproj trunk/OpenMPT/mptrack/mptrack_10.vcxproj.filters Added Paths: ----------- trunk/OpenMPT/common/BuildSettings.h Added: trunk/OpenMPT/common/BuildSettings.h =================================================================== --- trunk/OpenMPT/common/BuildSettings.h (rev 0) +++ trunk/OpenMPT/common/BuildSettings.h 2013-04-22 20:32:38 UTC (rev 1935) @@ -0,0 +1,104 @@ +/* + * BuildSettings.h + * --------------- + * Purpose: Global, user settable compile time flags (and some global system header configuration) + * Notes : (currently none) + * Authors: OpenMPT Devs + * The OpenMPT source code is released under the BSD license. Read LICENSE for more details. + */ + + +#pragma once + + + +// Use inline assembly at all +#define ENABLE_ASM + +// inline assembly requires MSVC compiler +#if defined(ENABLE_ASM) && defined(_MSC_VER) + +// Generate general x86 inline assembly. +#define ENABLE_X86 + +// Generate inline assembly using MMX instructions (only used when the CPU supports it). +#define ENABLE_MMX + +// Generate inline assembly using 3DNOW instructions (only used when the CPU supports it). +#define ENABLE_3DNOW + +// Generate inline assembly using SSE instructions (only used when the CPU supports it). +#define ENABLE_SSE + +#endif // ENABLE_ASM + +// Disable any debug logging +//#define NO_LOGGING + +// Disable unarchiving support +//#define NO_ARCHIVE_SUPPORT + +// Disable the built-in reverb effect +//#define NO_REVERB + +// Disable built-in miscellaneous DSP effects (surround, mega bass, noise reduction) +//#define NO_DSP + +// Disable the built-in equalizer. +//#define NO_EQ + +// Disable the built-in automatic gain control +//#define NO_AGC + +// Define to build without ASIO support; makes build possible without ASIO SDK. +//#define NO_ASIO + +// (HACK) Define to build without VST support; makes build possible without VST SDK. +//#define NO_VST + +// Define to build without portaudio. +//#define NO_PORTAUDIO + +// Define to build without MO3 support. +//#define NO_MO3_SUPPORT + +// Define to build without DirectSound support. +//#define NO_DSOUND + +// Define to build without FLAC support +//#define NO_FLAC + +// Define to build without MP3 import support (via mpg123) +//#define NO_MP3_SAMPLES + + + +#ifdef _MSC_VER +#define VC_EXTRALEAN // Exclude rarely-used stuff from Windows headers +#endif + +#ifdef _WIN32 + +#define _WIN32_WINNT 0x0500 // 0x0500 = Windows 2000 + +// no stupid min/max macros +#define NOMINMAX +// windows excludes +#define NOMCX +// mmreg excludes +#define NOMMIDS +#define NOJPEGDIB +#define NONEWIC +#define NOBITMAP +// mmsystem excludes +#define MMNODRV +#define MMNOMCI + +#endif + +#ifdef _MSC_VER +#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 +#define _SCL_SECURE_NO_WARNINGS +#endif Property changes on: trunk/OpenMPT/common/BuildSettings.h ___________________________________________________________________ Added: svn:mime-type ## -0,0 +1 ## +text/x-chdr \ No newline at end of property Added: svn:eol-style ## -0,0 +1 ## +native \ No newline at end of property Modified: trunk/OpenMPT/common/stdafx.h =================================================================== --- trunk/OpenMPT/common/stdafx.h 2013-04-22 20:30:56 UTC (rev 1934) +++ trunk/OpenMPT/common/stdafx.h 2013-04-22 20:32:38 UTC (rev 1935) @@ -1,7 +1,7 @@ /* * StdAfx.h * -------- - * Purpose: Include file for standard system include files, or project specific include files that are used frequently, but are changed infrequently + * Purpose: Include file for standard system include files, or project specific include files that are used frequently, but are changed infrequently. Also includes the global build settings from BuildSettings.h. * Notes : (currently none) * Authors: Olivier Lapicque * OpenMPT Devs @@ -11,28 +11,8 @@ #pragma once -#define VC_EXTRALEAN // Exclude rarely-used stuff from Windows headers +#include "BuildSettings.h" -#define _WIN32_WINNT 0x0500 // 0x0500 = Windows 2000 - -// no stupid min/max macros -#define NOMINMAX -// windows excludes -#define NOMCX -// mmreg excludes -#define NOMMIDS -#define NOJPEGDIB -#define NONEWIC -#define NOBITMAP -// mmsystem excludes -#define MMNODRV -#define MMNOMCI - -#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 -#define _SCL_SECURE_NO_WARNINGS - #include <afxwin.h> // MFC core and standard components #include <afxext.h> // MFC extensions #include <afxcmn.h> // MFC support for Windows Common Controls @@ -40,76 +20,21 @@ #include <afxole.h> #include <windowsx.h> +#ifdef _MSC_VER #pragma warning(disable:4201) +#endif #include <mmsystem.h> #include <mmreg.h> #include <msacm.h> #include <afxdlgs.h> +#ifdef _MSC_VER #pragma warning(default:4201) +#endif #include <string> #include <fstream> #include <strstream> -// Use inline assembly at all -#define ENABLE_ASM - -// inline assembly requires MSVC compiler -#if defined(ENABLE_ASM) && defined(_MSC_VER) - -// Generate general x86 inline assembly. -#define ENABLE_X86 - -// Generate inline assembly using MMX instructions (only used when the CPU supports it). -#define ENABLE_MMX - -// Generate inline assembly using 3DNOW instructions (only used when the CPU supports it). -#define ENABLE_3DNOW - -// Generate inline assembly using SSE instructions (only used when the CPU supports it). -#define ENABLE_SSE - -#endif // ENABLE_ASM - -// Disable any debug logging -//#define NO_LOGGING - -// Disable unarchiving support -//#define NO_ARCHIVE_SUPPORT - -// Disable the built-in reverb effect -//#define NO_REVERB - -// Disable built-in miscellaneous DSP effects (surround, mega bass, noise reduction) -//#define NO_DSP - -// Disable the built-in equalizer. -//#define NO_EQ - -// Disable the built-in automatic gain control -//#define NO_AGC - -// Define to build without ASIO support; makes build possible without ASIO SDK. -//#define NO_ASIO - -// (HACK) Define to build without VST support; makes build possible without VST SDK. -//#define NO_VST - -// Define to build without portaudio. -//#define NO_PORTAUDIO - -// Define to build without MO3 support. -//#define NO_MO3_SUPPORT - -// Define to build without DirectSound support. -//#define NO_DSOUND - -// Define to build without FLAC support -//#define NO_FLAC - -// Define to build without MP3 import support (via mpg123) -//#define NO_MP3_SAMPLES - #include "../common/typedefs.h" // Exception type that is used to catch "operator new" exceptions. Modified: trunk/OpenMPT/mptrack/mptrack_08.vcproj =================================================================== --- trunk/OpenMPT/mptrack/mptrack_08.vcproj 2013-04-22 20:30:56 UTC (rev 1934) +++ trunk/OpenMPT/mptrack/mptrack_08.vcproj 2013-04-22 20:32:38 UTC (rev 1935) @@ -837,6 +837,10 @@ > </File> <File + RelativePath="..\common\BuildSettings.h" + > + </File> + <File RelativePath=".\ChildFrm.h" > </File> Modified: trunk/OpenMPT/mptrack/mptrack_10.vcxproj =================================================================== --- trunk/OpenMPT/mptrack/mptrack_10.vcxproj 2013-04-22 20:30:56 UTC (rev 1934) +++ trunk/OpenMPT/mptrack/mptrack_10.vcxproj 2013-04-22 20:32:38 UTC (rev 1935) @@ -411,6 +411,7 @@ </ItemGroup> <ItemGroup> <ClInclude Include="..\common\AudioCriticalSection.h" /> + <ClInclude Include="..\common\BuildSettings.h" /> <ClInclude Include="..\common\FlagSet.h" /> <ClInclude Include="..\common\Logging.h" /> <ClInclude Include="..\common\misc_util.h" /> Modified: trunk/OpenMPT/mptrack/mptrack_10.vcxproj.filters =================================================================== --- trunk/OpenMPT/mptrack/mptrack_10.vcxproj.filters 2013-04-22 20:30:56 UTC (rev 1934) +++ trunk/OpenMPT/mptrack/mptrack_10.vcxproj.filters 2013-04-22 20:32:38 UTC (rev 1935) @@ -813,6 +813,9 @@ <ClInclude Include="resource.h"> <Filter>Header Files</Filter> </ClInclude> + <ClInclude Include="..\common\BuildSettings.h"> + <Filter>Header Files\common</Filter> + </ClInclude> </ItemGroup> <ItemGroup> <None Include="res\bitmap1.bmp"> This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |