From: <man...@us...> - 2013-04-27 18:59:34
|
Revision: 1985 http://sourceforge.net/p/modplug/code/1985 Author: manxorist Date: 2013-04-27 18:59:25 +0000 (Sat, 27 Apr 2013) Log Message: ----------- [Ref] Change CSoundFile::Create to take a FileReader as parameter instead of an pointer and a length. Modified Paths: -------------- trunk/OpenMPT/mptrack/MainFrm.cpp trunk/OpenMPT/mptrack/Moddoc.cpp trunk/OpenMPT/mptrack/View_tre.cpp trunk/OpenMPT/soundlib/Sndfile.cpp trunk/OpenMPT/soundlib/Sndfile.h Modified: trunk/OpenMPT/mptrack/MainFrm.cpp =================================================================== --- trunk/OpenMPT/mptrack/MainFrm.cpp 2013-04-27 18:37:32 UTC (rev 1984) +++ trunk/OpenMPT/mptrack/MainFrm.cpp 2013-04-27 18:59:25 UTC (rev 1985) @@ -35,6 +35,7 @@ #include "SelectPluginDialog.h" #include "ExceptionHandler.h" #include "PatternClipboard.h" +#include "soundlib/FileReader.h" #include "../common/Profiler.h" #ifdef _DEBUG @@ -1633,7 +1634,7 @@ //---------------------------- { m_WaveFile.Destroy(); - m_WaveFile.Create(NULL, 0); + m_WaveFile.Create(FileReader(), nullptr); // 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); Modified: trunk/OpenMPT/mptrack/Moddoc.cpp =================================================================== --- trunk/OpenMPT/mptrack/Moddoc.cpp 2013-04-27 18:37:32 UTC (rev 1984) +++ trunk/OpenMPT/mptrack/Moddoc.cpp 2013-04-27 18:59:25 UTC (rev 1985) @@ -23,6 +23,7 @@ #include "modsmp_ctrl.h" #include "CleanupSong.h" #include "../common/StringFixer.h" +#include "soundlib/FileReader.h" #include <shlwapi.h> #ifdef _DEBUG @@ -168,7 +169,7 @@ { if (!CDocument::OnNewDocument()) return FALSE; - m_SndFile.Create(NULL, this, 0); + m_SndFile.Create(FileReader(), this); m_SndFile.ChangeModTypeTo(CTrackApp::GetDefaultDocType()); if(CTrackApp::IsProject()) @@ -213,7 +214,7 @@ LPBYTE lpStream = f.Lock(); if (lpStream) { - m_SndFile.Create(lpStream, this, dwLen); + m_SndFile.Create(FileReader(lpStream, dwLen), this); f.Unlock(); } } Modified: trunk/OpenMPT/mptrack/View_tre.cpp =================================================================== --- trunk/OpenMPT/mptrack/View_tre.cpp 2013-04-27 18:37:32 UTC (rev 1984) +++ trunk/OpenMPT/mptrack/View_tre.cpp 2013-04-27 18:59:25 UTC (rev 1985) @@ -17,6 +17,7 @@ #include "dlsbank.h" #include "dlg_misc.h" #include "vstplug.h" +#include "../soundlib/FileReader.h" CSoundFile *CModTree::m_SongFile = nullptr; @@ -274,7 +275,7 @@ } if(m_SongFile != nullptr) { - m_SongFile->Create(lpStream, NULL, dwLen); + m_SongFile->Create(FileReader(lpStream, dwLen), nullptr); // Destroy some stuff that we're not going to use anyway. m_SongFile->Patterns.DestroyPatterns(); m_SongFile->songMessage.clear(); Modified: trunk/OpenMPT/soundlib/Sndfile.cpp =================================================================== --- trunk/OpenMPT/soundlib/Sndfile.cpp 2013-04-27 18:37:32 UTC (rev 1984) +++ trunk/OpenMPT/soundlib/Sndfile.cpp 2013-04-27 18:59:25 UTC (rev 1985) @@ -509,13 +509,13 @@ #ifdef MODPLUG_TRACKER -BOOL CSoundFile::Create(LPCBYTE lpStream, CModDoc *pModDoc, DWORD dwMemLength) -//---------------------------------------------------------------------------- +BOOL CSoundFile::Create(FileReader filereader, CModDoc *pModDoc) +//-------------------------------------------------------------- { m_pModDoc = pModDoc; #else -BOOL CSoundFile::Create(LPCBYTE lpStream, void *pModDoc, DWORD dwMemLength) -//------------------------------------------------------------------------- +BOOL CSoundFile::Create(FileReader filereader, void*) +//--------------------------------------------------- { #endif // MODPLUG_TRACKER @@ -544,10 +544,13 @@ MemsetZero(m_szNames); MemsetZero(m_MixPlugins); - if(lpStream) + if(filereader.IsValid()) { - FileReader file(lpStream, dwMemLength); + FileReader file(filereader); + LPCBYTE lpStream = reinterpret_cast<const unsigned char*>(file.GetRawData()); + DWORD dwMemLength = file.GetLength(); + #ifndef NO_ARCHIVE_SUPPORT CUnarchiver unarchiver(file, GetSupportedExtensions(true)); if(unarchiver.IsArchive() && unarchiver.ExtractFile()) Modified: trunk/OpenMPT/soundlib/Sndfile.h =================================================================== --- trunk/OpenMPT/soundlib/Sndfile.h 2013-04-27 18:37:32 UTC (rev 1984) +++ trunk/OpenMPT/soundlib/Sndfile.h 2013-04-27 18:59:25 UTC (rev 1985) @@ -405,11 +405,11 @@ public: #ifdef MODPLUG_TRACKER - BOOL Create(LPCBYTE lpStream, CModDoc *pModDoc, DWORD dwMemLength=0); + BOOL Create(FileReader filereader, CModDoc *pModDoc); // Get parent CModDoc. Can be nullptr if previewing from tree view, and is always nullptr if we're not actually compiling OpenMPT. CModDoc *GetpModDoc() const { return m_pModDoc; } #else - BOOL Create(LPCBYTE lpStream, void *pModDoc, DWORD dwMemLength=0); + BOOL Create(FileReader filereader, void *pModDoc=nullptr); void *GetpModDoc() const { return nullptr; } #endif // MODPLUG_TRACKER This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |