From: <sag...@us...> - 2014-03-08 18:24:00
|
Revision: 3848 http://sourceforge.net/p/modplug/code/3848 Author: saga-games Date: 2014-03-08 18:23:52 +0000 (Sat, 08 Mar 2014) Log Message: ----------- [New] General tab: Added a tempo tap buton. [Mod] OpenMPT: Version is now 1.22.07.28 Modified Paths: -------------- trunk/OpenMPT/common/versionNumber.h trunk/OpenMPT/mptrack/Ctrl_gen.cpp trunk/OpenMPT/mptrack/Ctrl_gen.h trunk/OpenMPT/mptrack/mptrack.rc Modified: trunk/OpenMPT/common/versionNumber.h =================================================================== --- trunk/OpenMPT/common/versionNumber.h 2014-03-08 00:19:39 UTC (rev 3847) +++ trunk/OpenMPT/common/versionNumber.h 2014-03-08 18:23:52 UTC (rev 3848) @@ -17,7 +17,7 @@ #define VER_MAJORMAJOR 1 #define VER_MAJOR 22 #define VER_MINOR 07 -#define VER_MINORMINOR 27 +#define VER_MINORMINOR 28 //Version string. For example "1.17.02.28" #define MPT_VERSION_STR VER_STRINGIZE(VER_MAJORMAJOR) "." VER_STRINGIZE(VER_MAJOR) "." VER_STRINGIZE(VER_MINOR) "." VER_STRINGIZE(VER_MINORMINOR) Modified: trunk/OpenMPT/mptrack/Ctrl_gen.cpp =================================================================== --- trunk/OpenMPT/mptrack/Ctrl_gen.cpp 2014-03-08 00:19:39 UTC (rev 3847) +++ trunk/OpenMPT/mptrack/Ctrl_gen.cpp 2014-03-08 18:23:52 UTC (rev 3848) @@ -29,6 +29,7 @@ BEGIN_MESSAGE_MAP(CCtrlGeneral, CModControlDlg) //{{AFX_MSG_MAP(CCtrlGeneral) ON_WM_VSCROLL() + ON_COMMAND(IDC_BUTTON1, OnTapTempo) ON_COMMAND(IDC_BUTTON_MODTYPE, OnSongProperties) ON_COMMAND(IDC_BUTTON_PLAYERPROPS, OnPlayerProperties) ON_COMMAND(IDC_CHECK_LOOPSONG, OnLoopSongChanged) @@ -160,6 +161,47 @@ } +void CCtrlGeneral::OnTapTempo() +//----------------------------- +{ + static uint32 tapLength[16], lastTap = 0; + // Shift back the previously recorded tap history + for(size_t i = CountOf(tapLength) - 1; i >= 1; i--) + { + tapLength[i] = tapLength[i - 1]; + } + const uint32 now = timeGetTime(); + tapLength[0] = now - lastTap; + lastTap = now; + + // Now average over complete tap history + uint32 numSamples = 0, delay = 0; + for(uint32 i = 0; i < CountOf(tapLength); i++) + { + if(tapLength[i] < 2000) + { + numSamples++; + delay += tapLength[i]; + } else + { + break; + } + } + if(delay) + { + CModSpecifications specs = m_sndFile.GetModSpecifications(); + uint32 newTempo = 60000 * numSamples; + if(m_sndFile.m_nTempoMode != tempo_mode_modern) + { + newTempo = (newTempo * m_sndFile.m_nDefaultSpeed * m_sndFile.m_nDefaultRowsPerBeat) / 24; + } + newTempo /= delay; + Limit(newTempo, specs.tempoMin, specs.tempoMax); + SetDlgItemInt(IDC_EDIT_TEMPO, newTempo, FALSE); + } +} + + void CCtrlGeneral::UpdateView(DWORD dwHint, CObject *pHint) //--------------------------------------------------------- { @@ -208,6 +250,7 @@ const BOOL bIsNotMOD_XM = ((bIsNotMOD) && (m_sndFile.GetType() != MOD_TYPE_XM)); m_EditTempo.EnableWindow(bIsNotMOD); m_SpinTempo.EnableWindow(bIsNotMOD); + GetDlgItem(IDC_BUTTON1)->EnableWindow(bIsNotMOD); m_SliderTempo.EnableWindow(bIsNotMOD); m_EditSpeed.EnableWindow(bIsNotMOD); m_SpinSpeed.EnableWindow(bIsNotMOD); @@ -354,7 +397,7 @@ m_sndFile.m_PlayState.m_nMusicTempo = n; m_modDoc.SetModified(); m_modDoc.UpdateAllViews(NULL, HINT_MODGENERAL, this); - UpdateView(HINT_MODGENERAL, NULL); + UpdateView(HINT_MODGENERAL, NULL); m_bEditsLocked=false; } } Modified: trunk/OpenMPT/mptrack/Ctrl_gen.h =================================================================== --- trunk/OpenMPT/mptrack/Ctrl_gen.h 2014-03-08 00:19:39 UTC (rev 3847) +++ trunk/OpenMPT/mptrack/Ctrl_gen.h 2014-03-08 18:23:52 UTC (rev 3848) @@ -84,6 +84,7 @@ //{{AFX_MSG(CCtrlGeneral) afx_msg LRESULT OnUpdatePosition(WPARAM, LPARAM); afx_msg void OnVScroll(UINT, UINT, CScrollBar *); + afx_msg void OnTapTempo(); afx_msg void OnTitleChanged(); afx_msg void OnTempoChanged(); afx_msg void OnSpeedChanged(); Modified: trunk/OpenMPT/mptrack/mptrack.rc =================================================================== --- trunk/OpenMPT/mptrack/mptrack.rc 2014-03-08 00:19:39 UTC (rev 3847) +++ trunk/OpenMPT/mptrack/mptrack.rc 2014-03-08 18:23:52 UTC (rev 3848) @@ -716,6 +716,7 @@ CONTROL "",IDC_SLIDER_SONGTEMPO,"msctls_trackbar32",TBS_VERT | TBS_BOTH | TBS_NOTICKS,11,28,15,50 EDITTEXT IDC_EDIT_TEMPO,5,78,29,12,ES_AUTOHSCROLL | ES_NUMBER CONTROL "",IDC_SPIN_TEMPO,"msctls_updown32",UDS_SETBUDDYINT | UDS_ALIGNRIGHT | UDS_AUTOBUDDY | UDS_ARROWKEYS | UDS_NOTHOUSANDS,27,76,11,14 + PUSHBUTTON "Tap",IDC_BUTTON1,54,24,24,12 LTEXT "Ticks/row:",IDC_STATIC,44,40,35,8 EDITTEXT IDC_EDIT_SPEED,44,51,30,12,ES_AUTOHSCROLL | ES_NUMBER CONTROL "Spin1",IDC_SPIN_SPEED,"msctls_updown32",UDS_SETBUDDYINT | UDS_ALIGNRIGHT | UDS_AUTOBUDDY | UDS_ARROWKEYS | UDS_NOTHOUSANDS,67,50,11,14 This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <sag...@us...> - 2014-03-09 00:51:20
|
Revision: 3850 http://sourceforge.net/p/modplug/code/3850 Author: saga-games Date: 2014-03-09 00:51:12 +0000 (Sun, 09 Mar 2014) Log Message: ----------- [Ref] Fix spelling of CHN_REVERSE [Ref] Change compatibility check with "all" trackers to really cover all module types (only interesting for libopenmpt) [Doc] Update documentation about empty "last saved with" values in IT and XM loaders Modified Paths: -------------- trunk/OpenMPT/mptrack/Ctrl_smp.cpp trunk/OpenMPT/soundlib/Load_ams.cpp trunk/OpenMPT/soundlib/Load_it.cpp trunk/OpenMPT/soundlib/Load_xm.cpp trunk/OpenMPT/soundlib/Snd_defs.h trunk/OpenMPT/soundlib/Snd_fx.cpp Modified: trunk/OpenMPT/mptrack/Ctrl_smp.cpp =================================================================== --- trunk/OpenMPT/mptrack/Ctrl_smp.cpp 2014-03-09 00:47:29 UTC (rev 3849) +++ trunk/OpenMPT/mptrack/Ctrl_smp.cpp 2014-03-09 00:51:12 UTC (rev 3850) @@ -726,7 +726,7 @@ // Loop d = 0; if (sample.uFlags[CHN_LOOP]) d = sample.uFlags[CHN_PINGPONGLOOP] ? 2 : 1; - if (sample.uFlags[CHN_REVRSE]) d |= 4; + if (sample.uFlags[CHN_REVERSE]) d |= 4; m_ComboLoopType.SetCurSel(d); wsprintf(s, "%lu", sample.nLoopStart); m_EditLoopStart.SetWindowText(s); Modified: trunk/OpenMPT/soundlib/Load_ams.cpp =================================================================== --- trunk/OpenMPT/soundlib/Load_ams.cpp 2014-03-09 00:47:29 UTC (rev 3849) +++ trunk/OpenMPT/soundlib/Load_ams.cpp 2014-03-09 00:51:12 UTC (rev 3850) @@ -712,7 +712,7 @@ } if(flags & smpReverse) { - mptSmp.uFlags.set(CHN_REVRSE); + mptSmp.uFlags.set(CHN_REVERSE); } } } Modified: trunk/OpenMPT/soundlib/Load_it.cpp =================================================================== --- trunk/OpenMPT/soundlib/Load_it.cpp 2014-03-09 00:47:29 UTC (rev 3849) +++ trunk/OpenMPT/soundlib/Load_it.cpp 2014-03-09 00:51:12 UTC (rev 3850) @@ -930,8 +930,8 @@ if(!m_dwLastSavedWithVersion && fileHeader.cwtv == 0x0888) { - // There are some files with OpenMPT extensions, but the "last saved with" field contains 0. - // Was there an OpenMPT version that wrote 0 there, or are they hacked? + // Up to OpenMPT 1.17.02.45 (r165), it was possible that the "last saved with" field was 0 + // when saving a file in OpenMPT for the first time. m_dwLastSavedWithVersion = MAKE_VERSION_NUMERIC(1, 17, 00, 00); } Modified: trunk/OpenMPT/soundlib/Load_xm.cpp =================================================================== --- trunk/OpenMPT/soundlib/Load_xm.cpp 2014-03-09 00:47:29 UTC (rev 3849) +++ trunk/OpenMPT/soundlib/Load_xm.cpp 2014-03-09 00:51:12 UTC (rev 3850) @@ -626,7 +626,9 @@ if(m_dwLastSavedWithVersion == 0) { - m_dwLastSavedWithVersion = MAKE_VERSION_NUMERIC(1, 17, 00, 00); // early versions of OpenMPT had no version indication. + // Up to OpenMPT 1.17.02.45 (r165), it was possible that the "last saved with" field was 0 + // when saving a file in OpenMPT for the first time. + m_dwLastSavedWithVersion = MAKE_VERSION_NUMERIC(1, 17, 00, 00); } } Modified: trunk/OpenMPT/soundlib/Snd_defs.h =================================================================== --- trunk/OpenMPT/soundlib/Snd_defs.h 2014-03-09 00:47:29 UTC (rev 3849) +++ trunk/OpenMPT/soundlib/Snd_defs.h 2014-03-09 00:51:12 UTC (rev 3850) @@ -133,7 +133,7 @@ #define TRK_FASTTRACKER2 (MOD_TYPE_XM) #define TRK_SCREAMTRACKER (MOD_TYPE_S3M) #define TRK_PROTRACKER (MOD_TYPE_MOD) -#define TRK_ALLTRACKERS (TRK_IMPULSETRACKER | TRK_FASTTRACKER2 | TRK_SCREAMTRACKER | TRK_PROTRACKER) +#define TRK_ALLTRACKERS (MODTYPE(~0)) // Channel flags: @@ -147,7 +147,7 @@ CHN_PINGPONGSUSTAIN = 0x10, // sample with bidi sustain loop CHN_PANNING = 0x20, // sample with forced panning CHN_STEREO = 0x40, // stereo sample - CHN_REVRSE = 0x80, // start sample playback from sample / loop end (Velvet Studio feature) - this is intentionally the same flag as CHN_PINGPONGFLAG. + CHN_REVERSE = 0x80, // start sample playback from sample / loop end (Velvet Studio feature) - this is intentionally the same flag as CHN_PINGPONGFLAG. // Channel Flags CHN_PINGPONGFLAG = 0x80, // when flag is on, sample is processed backwards CHN_MUTE = 0x100, // muted channel @@ -174,7 +174,7 @@ DECLARE_FLAGSET(ChannelFlags) -#define CHN_SAMPLEFLAGS (CHN_16BIT | CHN_LOOP | CHN_PINGPONGLOOP | CHN_SUSTAINLOOP | CHN_PINGPONGSUSTAIN | CHN_PANNING | CHN_STEREO | CHN_PINGPONGFLAG | CHN_REVRSE) +#define CHN_SAMPLEFLAGS (CHN_16BIT | CHN_LOOP | CHN_PINGPONGLOOP | CHN_SUSTAINLOOP | CHN_PINGPONGSUSTAIN | CHN_PANNING | CHN_STEREO | CHN_PINGPONGFLAG | CHN_REVERSE) #define CHN_CHANNELFLAGS (~CHN_SAMPLEFLAGS) @@ -249,7 +249,7 @@ #define DCT_NOTE 1 #define DCT_SAMPLE 2 #define DCT_INSTRUMENT 3 -#define DCT_PLUGIN 4 //rewbs.VSTiNNA +#define DCT_PLUGIN 4 // DNA types (Duplicate Note Action) #define DNA_NOTECUT 0 @@ -257,7 +257,7 @@ #define DNA_NOTEFADE 2 -// Module flags +// Module flags - note: these are written out as-is in ITP files! enum SongFlags { SONG_EMBEDMIDICFG = 0x0001, // Embed macros in file @@ -312,7 +312,6 @@ #define SNDMIX_SOFTPANNING 0x10 // soft panning mode (this is forced with mixmode RC3 and later) // Misc Flags (can safely be turned on or off) -//#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 @@ -328,7 +327,7 @@ SRCMODE_LINEAR = 1, SRCMODE_SPLINE = 2, SRCMODE_POLYPHASE = 3, - SRCMODE_FIRFILTER = 4, //rewbs.resamplerConf + SRCMODE_FIRFILTER = 4, SRCMODE_DEFAULT = 5, }; Modified: trunk/OpenMPT/soundlib/Snd_fx.cpp =================================================================== --- trunk/OpenMPT/soundlib/Snd_fx.cpp 2014-03-09 00:47:29 UTC (rev 3849) +++ trunk/OpenMPT/soundlib/Snd_fx.cpp 2014-03-09 00:51:12 UTC (rev 3850) @@ -1320,7 +1320,7 @@ if (pChn->nLength > pChn->nLoopEnd) pChn->nLength = pChn->nLoopEnd; } - if(pChn->dwFlags[CHN_REVRSE]) + if(pChn->dwFlags[CHN_REVERSE]) { pChn->dwFlags.set(CHN_PINGPONGFLAG); pChn->nPos = pChn->nLength - 1; This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <man...@us...> - 2014-03-09 15:45:57
|
Revision: 3853 http://sourceforge.net/p/modplug/code/3853 Author: manxorist Date: 2014-03-09 15:45:50 +0000 (Sun, 09 Mar 2014) Log Message: ----------- [Ref] Kill LPBYTE in soundlib/ . Modified Paths: -------------- trunk/OpenMPT/common/typedefs.h trunk/OpenMPT/soundlib/Dlsbank.cpp trunk/OpenMPT/soundlib/Dlsbank.h trunk/OpenMPT/soundlib/Load_dmf.cpp trunk/OpenMPT/soundlib/Load_med.cpp trunk/OpenMPT/soundlib/SampleFormats.cpp trunk/OpenMPT/soundlib/Sndfile.h Modified: trunk/OpenMPT/common/typedefs.h =================================================================== --- trunk/OpenMPT/common/typedefs.h 2014-03-09 14:54:24 UTC (rev 3852) +++ trunk/OpenMPT/common/typedefs.h 2014-03-09 15:45:50 UTC (rev 3853) @@ -411,7 +411,6 @@ typedef std::uint32_t DWORD; typedef std::int32_t LONG; typedef std::uint32_t UINT; -typedef BYTE * LPBYTE; #endif // !WIN32 Modified: trunk/OpenMPT/soundlib/Dlsbank.cpp =================================================================== --- trunk/OpenMPT/soundlib/Dlsbank.cpp 2014-03-09 14:54:24 UTC (rev 3852) +++ trunk/OpenMPT/soundlib/Dlsbank.cpp 2014-03-09 15:45:50 UTC (rev 3853) @@ -603,10 +603,10 @@ DWORD dwPos = 12; while (dwPos < plist->len) { - LPIFFCHUNK p = (LPIFFCHUNK)(((LPBYTE)plist) + dwPos); + LPIFFCHUNK p = (LPIFFCHUNK)(((uint8 *)plist) + dwPos); if (!(p->id & 0xFF)) { - p = (LPIFFCHUNK)( ((LPBYTE)p)+1 ); + p = (LPIFFCHUNK)( ((uint8 *)p)+1 ); dwPos++; } if (dwPos + p->len + 8 <= plist->len + 12) @@ -674,7 +674,7 @@ //Log("fulOptions=0x%04X loops=%d\n", p->fulOptions, p->cSampleLoops); if ((p->cSampleLoops) && (p->cbSize + sizeof(WSMPSAMPLELOOP) <= p->len)) { - WSMPSAMPLELOOP *ploop = (WSMPSAMPLELOOP *)(((LPBYTE)p)+8+p->cbSize); + WSMPSAMPLELOOP *ploop = (WSMPSAMPLELOOP *)(((uint8 *)p)+8+p->cbSize); //Log("looptype=%2d loopstart=%5d loopend=%5d\n", ploop->ulLoopType, ploop->ulLoopStart, ploop->ulLoopLength); if (ploop->ulLoopLength > 3) { @@ -704,7 +704,7 @@ pDlsEnv->nDefPan = 128; pDlsEnv->nVolSustainLevel = 128; //Log(" art1 (%3d bytes): cbSize=%d cConnectionBlocks=%d\n", p->len, p->cbSize, p->cConnectionBlocks); - CONNECTIONBLOCK *pblk = (CONNECTIONBLOCK *)( ((LPBYTE)p)+8+p->cbSize ); + CONNECTIONBLOCK *pblk = (CONNECTIONBLOCK *)( ((uint8 *)p)+8+p->cbSize ); for (UINT iblk=0; iblk<p->cConnectionBlocks; iblk++, pblk++) { // [4-bit transform][12-bit dest][8-bit control][8-bit source] = 32-bit ID @@ -1404,7 +1404,7 @@ } -bool CDLSBank::FreeWaveForm(LPBYTE p) +bool CDLSBank::FreeWaveForm(uint8 *p) //----------------------------------- { if (p) free(p); @@ -1412,7 +1412,7 @@ } -bool CDLSBank::ExtractWaveForm(UINT nIns, UINT nRgn, LPBYTE *ppWave, DWORD *pLen) +bool CDLSBank::ExtractWaveForm(UINT nIns, UINT nRgn, uint8 **ppWave, DWORD *pLen) //------------------------------------------------------------------------------- { DLSINSTRUMENT *pDlsIns; @@ -1458,7 +1458,7 @@ if (fseek(f, 8, SEEK_CUR) == 0) { *pLen = m_pSamplesEx[nWaveLink].dwLen; - *ppWave = (LPBYTE)calloc(1, *pLen + 8); + *ppWave = (uint8 *)calloc(1, *pLen + 8); fread((*ppWave), 1, *pLen, f); bOk = true; } @@ -1471,7 +1471,7 @@ if ((chunk.id == IFFID_LIST) && (chunk.listid == IFFID_wave) && (chunk.len > 4)) { *pLen = chunk.len + 8; - *ppWave = (LPBYTE)calloc(1, chunk.len + 8); + *ppWave = (uint8 *)calloc(1, chunk.len + 8); if (*ppWave) { memcpy((*ppWave), &chunk, 12); @@ -1521,7 +1521,7 @@ //--------------------------------------------------------------------------------------------------------- { DLSINSTRUMENT *pDlsIns; - LPBYTE pWaveForm = NULL; + uint8 *pWaveForm = NULL; DWORD dwLen = 0; bool bOk, bWaveForm; Modified: trunk/OpenMPT/soundlib/Dlsbank.h =================================================================== --- trunk/OpenMPT/soundlib/Dlsbank.h 2014-03-09 14:54:24 UTC (rev 3852) +++ trunk/OpenMPT/soundlib/Dlsbank.h 2014-03-09 15:45:50 UTC (rev 3853) @@ -145,8 +145,8 @@ DLSINSTRUMENT *GetInstrument(UINT iIns) { return (m_pInstruments) ? &m_pInstruments[iIns] : NULL; } DLSINSTRUMENT *FindInstrument(bool bDrum, UINT nBank=0xFF, DWORD dwProgram=0xFF, DWORD dwKey=0xFF, UINT *pInsNo=NULL); UINT GetRegionFromKey(UINT nIns, UINT nKey); - bool FreeWaveForm(LPBYTE p); - bool ExtractWaveForm(UINT nIns, UINT nRgn, LPBYTE *ppWave, DWORD *pLen); + bool FreeWaveForm(uint8 *p); + bool ExtractWaveForm(UINT nIns, UINT nRgn, uint8 **ppWave, DWORD *pLen); bool ExtractSample(CSoundFile &sndFile, SAMPLEINDEX nSample, UINT nIns, UINT nRgn, int transpose=0); bool ExtractInstrument(CSoundFile &sndFile, INSTRUMENTINDEX nInstr, UINT nIns, UINT nDrumRgn); const char *GetRegionName(UINT nIns, UINT nRgn) const; Modified: trunk/OpenMPT/soundlib/Load_dmf.cpp =================================================================== --- trunk/OpenMPT/soundlib/Load_dmf.cpp 2014-03-09 14:54:24 UTC (rev 3852) +++ trunk/OpenMPT/soundlib/Load_dmf.cpp 2014-03-09 15:45:50 UTC (rev 3853) @@ -1183,7 +1183,7 @@ } -uintptr_t DMFUnpack(LPBYTE psample, const uint8 *ibuf, const uint8 *ibufmax, uint32 maxlen) +uintptr_t DMFUnpack(uint8 *psample, const uint8 *ibuf, const uint8 *ibufmax, uint32 maxlen) //----------------------------------------------------------------------------------------- { DMFHTree tree; Modified: trunk/OpenMPT/soundlib/Load_med.cpp =================================================================== --- trunk/OpenMPT/soundlib/Load_med.cpp 2014-03-09 14:54:24 UTC (rev 3852) +++ trunk/OpenMPT/soundlib/Load_med.cpp 2014-03-09 15:45:50 UTC (rev 3853) @@ -864,7 +864,7 @@ if (!tracks) tracks = m_nChannels; if(Patterns.Insert(iBlk, lines)) continue; ModCommand *p = Patterns[iBlk]; - LPBYTE s = (LPBYTE)(lpStream + dwPos + 2); + const uint8 * s = (const uint8 *)(lpStream + dwPos + 2); UINT maxlen = tracks*lines*3; if (maxlen + dwPos > dwMemLength - 2) break; for (UINT y=0; y<lines; y++) @@ -929,7 +929,7 @@ } } ModCommand *p = Patterns[iBlk]; - LPBYTE s = (LPBYTE)(lpStream + dwPos + 8); + const uint8 * s = (const uint8 *)(lpStream + dwPos + 8); UINT maxlen = tracks*lines*4; if (maxlen + dwPos > dwMemLength - 8) break; for (UINT y=0; y<lines; y++) Modified: trunk/OpenMPT/soundlib/SampleFormats.cpp =================================================================== --- trunk/OpenMPT/soundlib/SampleFormats.cpp 2014-03-09 14:54:24 UTC (rev 3852) +++ trunk/OpenMPT/soundlib/SampleFormats.cpp 2014-03-09 15:45:50 UTC (rev 3853) @@ -63,16 +63,13 @@ { file.Rewind(); - const BYTE * const lpMemFile = reinterpret_cast<const BYTE*>(file.GetRawData()); - const DWORD dwFileLength = file.GetLength(); - if(!nSample || nSample >= MAX_SAMPLES) return false; if(!ReadWAVSample(nSample, file, mayNormalize) && !ReadXISample(nSample, file) && !ReadITISample(nSample, file) && !ReadAIFFSample(nSample, file, mayNormalize) && !ReadITSSample(nSample, file) - && !ReadPATSample(nSample, const_cast<BYTE*>(lpMemFile), dwFileLength) + && !ReadPATSample(nSample, reinterpret_cast<const uint8*>(file.GetRawData()), file.GetLength()) && !ReadIFFSample(nSample, file) && !ReadS3ISample(nSample, file) && !ReadFLACSample(nSample, file) @@ -94,7 +91,7 @@ { if ((!nInstr) || (nInstr >= MAX_INSTRUMENTS)) return false; file.Rewind(); - if(!ReadPATInstrument(nInstr, (const LPBYTE)file.GetRawData(), file.GetLength()) + if(!ReadPATInstrument(nInstr, reinterpret_cast<const uint8*>(file.GetRawData()), file.GetLength()) && !ReadXIInstrument(nInstr, file) && !ReadITIInstrument(nInstr, file) // Generic read @@ -619,8 +616,8 @@ } -static void PatchToSample(CSoundFile *that, SAMPLEINDEX nSample, LPBYTE lpStream, DWORD dwMemLength) -//-------------------------------------------------------------------------------------------------- +static void PatchToSample(CSoundFile *that, SAMPLEINDEX nSample, const uint8 *lpStream, DWORD dwMemLength) +//-------------------------------------------------------------------------------------------------------- { ModSample &sample = that->GetSample(nSample); DWORD dwMemPos = sizeof(GF1SAMPLEHEADER); @@ -671,8 +668,8 @@ } -bool CSoundFile::ReadPATSample(SAMPLEINDEX nSample, LPBYTE lpStream, DWORD dwMemLength) -//------------------------------------------------------------------------------------- +bool CSoundFile::ReadPATSample(SAMPLEINDEX nSample, const uint8 *lpStream, DWORD dwMemLength) +//------------------------------------------------------------------------------------------- { DWORD dwMemPos = sizeof(GF1PATCHFILEHEADER)+sizeof(GF1INSTRUMENT)+sizeof(GF1LAYER); GF1PATCHFILEHEADER *phdr = (GF1PATCHFILEHEADER *)lpStream; @@ -695,7 +692,7 @@ // PAT Instrument -bool CSoundFile::ReadPATInstrument(INSTRUMENTINDEX nInstr, const LPBYTE lpStream, DWORD dwMemLength) +bool CSoundFile::ReadPATInstrument(INSTRUMENTINDEX nInstr, const uint8 *lpStream, DWORD dwMemLength) //-------------------------------------------------------------------------------------------------- { GF1PATCHFILEHEADER *phdr = (GF1PATCHFILEHEADER *)lpStream; Modified: trunk/OpenMPT/soundlib/Sndfile.h =================================================================== --- trunk/OpenMPT/soundlib/Sndfile.h 2014-03-09 14:54:24 UTC (rev 3852) +++ trunk/OpenMPT/soundlib/Sndfile.h 2014-03-09 15:45:50 UTC (rev 3853) @@ -61,7 +61,7 @@ // Sample decompression void AMSUnpack(const int8 * const source, size_t sourceSize, void * const dest, const size_t destSize, char packCharacter); uint16 MDLReadBits(uint32 &bitbuf, uint32 &bitnum, const uint8 *(&ibuf), int8 n); -uintptr_t DMFUnpack(LPBYTE psample, const uint8 *ibuf, const uint8 *ibufmax, uint32 maxlen); +uintptr_t DMFUnpack(uint8 *psample, const uint8 *ibuf, const uint8 *ibufmax, uint32 maxlen); bool IMAADPCMUnpack16(int16 *target, SmpLength sampleLen, FileReader file, uint16 blockAlign); // Module decompression @@ -852,7 +852,7 @@ // Samples file I/O bool ReadSampleFromFile(SAMPLEINDEX nSample, FileReader &file, bool mayNormalize=false); bool ReadWAVSample(SAMPLEINDEX nSample, FileReader &file, bool mayNormalize=false, FileReader *wsmpChunk = nullptr); - bool ReadPATSample(SAMPLEINDEX nSample, const LPBYTE lpMemFile, DWORD dwFileLength); + bool ReadPATSample(SAMPLEINDEX nSample, const uint8 *lpMemFile, DWORD dwFileLength); bool ReadS3ISample(SAMPLEINDEX nSample, FileReader &file); bool ReadAIFFSample(SAMPLEINDEX nSample, FileReader &file, bool mayNormalize=false); bool ReadXISample(SAMPLEINDEX nSample, FileReader &file); @@ -871,7 +871,7 @@ bool ReadInstrumentFromFile(INSTRUMENTINDEX nInstr, FileReader &file, bool mayNormalize=false); bool ReadXIInstrument(INSTRUMENTINDEX nInstr, FileReader &file); bool ReadITIInstrument(INSTRUMENTINDEX nInstr, FileReader &file); - bool ReadPATInstrument(INSTRUMENTINDEX nInstr, const LPBYTE lpMemFile, DWORD dwFileLength); + bool ReadPATInstrument(INSTRUMENTINDEX nInstr, const uint8 *lpMemFile, DWORD dwFileLength); bool ReadSampleAsInstrument(INSTRUMENTINDEX nInstr, FileReader &file, bool mayNormalize=false); #ifndef MODPLUG_NO_FILESAVE bool SaveXIInstrument(INSTRUMENTINDEX nInstr, const mpt::PathString &filename) const; This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <sag...@us...> - 2014-03-10 18:14:06
|
Revision: 3855 http://sourceforge.net/p/modplug/code/3855 Author: saga-games Date: 2014-03-10 18:13:55 +0000 (Mon, 10 Mar 2014) Log Message: ----------- [Ref] Add sequenceMax to CModSpecifications so that we don't have to implicitely assume that only MOD_TYPE_MPT can have more than one sequence. Modified Paths: -------------- trunk/OpenMPT/mptrack/Ctrl_pat.cpp trunk/OpenMPT/mptrack/Ctrl_seq.cpp trunk/OpenMPT/mptrack/View_tre.cpp trunk/OpenMPT/soundlib/ModSequence.cpp trunk/OpenMPT/soundlib/mod_specifications.cpp trunk/OpenMPT/soundlib/mod_specifications.h Modified: trunk/OpenMPT/mptrack/Ctrl_pat.cpp =================================================================== --- trunk/OpenMPT/mptrack/Ctrl_pat.cpp 2014-03-09 17:19:57 UTC (rev 3854) +++ trunk/OpenMPT/mptrack/Ctrl_pat.cpp 2014-03-10 18:13:55 UTC (rev 3855) @@ -261,7 +261,7 @@ ::EnableWindow(::GetDlgItem(m_hWnd, IDC_PATINSTROPLUGGUI), false); // Enable/disable multisequence controls according the current modtype. - BOOL isMultiSeqAvail = (m_sndFile.GetType() == MOD_TYPE_MPT) ? TRUE : FALSE; + BOOL isMultiSeqAvail = (m_sndFile.GetModSpecifications().sequencesMax > 1) ? TRUE : FALSE; GetDlgItem(IDC_STATIC_SEQUENCE_NAME)->EnableWindow(isMultiSeqAvail); GetDlgItem(IDC_EDIT_SEQUENCE_NAME)->EnableWindow(isMultiSeqAvail); GetDlgItem(IDC_EDIT_SEQNUM)->EnableWindow(isMultiSeqAvail); Modified: trunk/OpenMPT/mptrack/Ctrl_seq.cpp =================================================================== --- trunk/OpenMPT/mptrack/Ctrl_seq.cpp 2014-03-09 17:19:57 UTC (rev 3854) +++ trunk/OpenMPT/mptrack/Ctrl_seq.cpp 2014-03-10 18:13:55 UTC (rev 3855) @@ -1004,7 +1004,7 @@ AppendMenu(hMenu, MF_SEPARATOR, NULL, ""); AppendMenu(hMenu, MF_STRING | greyed, ID_PATTERN_PROPERTIES, "&Pattern Properties..."); } - if (sndFile.GetType() == MOD_TYPE_MPT) + if (sndFile.GetModSpecifications().sequencesMax > 1) { AppendMenu(hMenu, MF_SEPARATOR, NULL, ""); Modified: trunk/OpenMPT/mptrack/View_tre.cpp =================================================================== --- trunk/OpenMPT/mptrack/View_tre.cpp 2014-03-09 17:19:57 UTC (rev 3854) +++ trunk/OpenMPT/mptrack/View_tre.cpp 2014-03-10 18:13:55 UTC (rev 3855) @@ -2097,7 +2097,7 @@ const SEQUENCEINDEX nOrigSeq = (SEQUENCEINDEX)modItemDragID; const ModSequence &origSeq = dragSndFile.Order.GetSequence(nOrigSeq); - if(pSndFile->GetType() == MOD_TYPE_MPT) + if(pSndFile->GetModSpecifications().sequencesMax > 1) { pSndFile->Order.AddSequence(false); } @@ -2483,7 +2483,7 @@ bool isCurSeq = false; CModDoc *pModDoc = GetDocumentFromItem(hItem); CSoundFile *pSndFile = (pModDoc) ? pModDoc->GetSoundFile() : nullptr; - if(pSndFile && (pSndFile->GetType() == MOD_TYPE_MPT)) + if(pSndFile && pSndFile->GetModSpecifications().sequencesMax > 1) { if(pSndFile->Order.GetSequence((SEQUENCEINDEX)modItemID).GetLength() == 0) { @@ -2507,7 +2507,7 @@ { CModDoc *pModDoc = GetDocumentFromItem(hItem); CSoundFile *pSndFile = (pModDoc) ? pModDoc->GetSoundFile() : nullptr; - if(pSndFile && (pSndFile->GetType() == MOD_TYPE_MPT)) + if(pSndFile && pSndFile->GetModSpecifications().sequencesMax > 1) { AppendMenu(hMenu, MF_STRING, ID_MODTREE_INSERT, "&Insert Sequence"); if(pSndFile->Order.GetNumSequences() == 1) // this is a sequence @@ -3473,7 +3473,7 @@ break; case MODITEM_HDR_ORDERS: - if(sndFile.Order.GetNumSequences() != 1 || sndFile.GetType() != MOD_TYPE_MPT) + if(sndFile.Order.GetNumSequences() != 1 || sndFile.GetModSpecifications().sequencesMax <= 1) { break; } Modified: trunk/OpenMPT/soundlib/ModSequence.cpp =================================================================== --- trunk/OpenMPT/soundlib/ModSequence.cpp 2014-03-09 17:19:57 UTC (rev 3854) +++ trunk/OpenMPT/soundlib/ModSequence.cpp 2014-03-10 18:13:55 UTC (rev 3855) @@ -267,7 +267,7 @@ // Limit number of orders to be inserted. LimitMax(nCount, ORDERINDEX(m_sndFile.GetModSpecifications().ordersMax - nPos)); // Calculate new length. - const ORDERINDEX nNewLength = MIN(nLengthTt + nCount, m_sndFile.GetModSpecifications().ordersMax); + const ORDERINDEX nNewLength = std::min<ORDERINDEX>(nLengthTt + nCount, m_sndFile.GetModSpecifications().ordersMax); // Resize if needed. if (nNewLength > GetLength()) resize(nNewLength); @@ -477,11 +477,11 @@ GetSequence(n).AdjustToNewModType(oldtype); } // Multisequences not suppported by other formats - if(oldtype != MOD_TYPE_NONE && newtype != MOD_TYPE_MPT) + if(oldtype != MOD_TYPE_NONE && m_sndFile.GetModSpecifications().sequencesMax <= 1) MergeSequences(); // Convert sequence with separator patterns into multiple sequences? - if(oldtype != MOD_TYPE_NONE && newtype == MOD_TYPE_MPT && GetNumSequences() == 1) + if(oldtype != MOD_TYPE_NONE && m_sndFile.GetModSpecifications().sequencesMax > 1 && GetNumSequences() == 1) ConvertSubsongsToMultipleSequences(); } @@ -489,6 +489,7 @@ bool ModSequenceSet::ConvertSubsongsToMultipleSequences() //------------------------------------------------------- { +#ifdef MODPLUG_TRACKER // Allow conversion only if there's only one sequence. if(GetNumSequences() != 1 || m_sndFile.GetType() != MOD_TYPE_MPT) return false; @@ -506,13 +507,8 @@ 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 -#else - false -#endif - ) + "Order list conversion", false, true) == cnfYes) { SetSequence(0); @@ -573,6 +569,9 @@ SetSequence(0); } return modified; +#else + return false; +#endif // MODPLUG_TRACKER } Modified: trunk/OpenMPT/soundlib/mod_specifications.cpp =================================================================== --- trunk/OpenMPT/soundlib/mod_specifications.cpp 2014-03-09 17:19:57 UTC (rev 3854) +++ trunk/OpenMPT/soundlib/mod_specifications.cpp 2014-03-10 18:13:55 UTC (rev 3855) @@ -32,6 +32,7 @@ true, // Has notefade. 4000, // Pattern max. 4000, // Order max. + MAX_SEQUENCES, // Sequences max 1, // Channel min 127, // Channel max 32, // Min tempo @@ -77,6 +78,7 @@ false, // No notefade. 128, // Pattern max. 128, // Order max. + 1, // Only one order list 4, // Channel min 99, // Channel max 32, // Min tempo @@ -120,6 +122,7 @@ false, // No notefade. 256, // Pattern max. 255, // Order max. + 1, // Only one order list 1, // Channel min 32, // Channel max 32, // Min tempo @@ -163,6 +166,7 @@ false, // No notefade. 256, // Pattern max. 255, // Order max. + 1, // Only one order list 1, // Channel min 127, // Channel max 32, // Min tempo @@ -205,6 +209,7 @@ false, // No notefade. 100, // Pattern max. 255, // Order max. + 1, // Only one order list 1, // Channel min 32, // Channel max 33, // Min tempo @@ -248,6 +253,7 @@ false, // No notefade. 100, // Pattern max. 255, // Order max. + 1, // Only one order list 1, // Channel min 32, // Channel max 33, // Min tempo @@ -290,6 +296,7 @@ true, // Has notefade. 200, // Pattern max. 256, // Order max. + 1, // Only one order list 1, // Channel min 64, // Channel max 32, // Min tempo @@ -332,6 +339,7 @@ true, // Has notefade. 240, // Pattern max. 256, // Order max. + 1, // Only one order list 1, // Channel min 127, // Channel max 32, // Min tempo Modified: trunk/OpenMPT/soundlib/mod_specifications.h =================================================================== --- trunk/OpenMPT/soundlib/mod_specifications.h 2014-03-09 17:19:57 UTC (rev 3854) +++ trunk/OpenMPT/soundlib/mod_specifications.h 2014-03-10 18:13:55 UTC (rev 3855) @@ -41,6 +41,7 @@ bool hasNoteFade; // True if format has notefade. PATTERNINDEX patternsMax; ORDERINDEX ordersMax; + SEQUENCEINDEX sequencesMax; CHANNELINDEX channelsMin; // Minimum number of editable channels in pattern. CHANNELINDEX channelsMax; // Maximum number of editable channels in pattern. TEMPO tempoMin; This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <man...@us...> - 2014-03-10 19:23:44
|
Revision: 3860 http://sourceforge.net/p/modplug/code/3860 Author: manxorist Date: 2014-03-10 19:23:36 +0000 (Mon, 10 Mar 2014) Log Message: ----------- [Ref] Add mpt::Library, a RAII wrapper around LoadLibrary/dlopen with a templated wrapper around GetProcAddress that avoids a lot of verbose casting. Handle almost all OS-specific and OpenMPT/libopenmpt-specific API and path differences of library loading in the wrapper. [Imp] Use stricter DLL search path restrictions on Windows Vista and newer with KB2533623 installed and on Windows 8. [Ref] Convert UXTheme, export codecs, unmo3, libmpg123, sounddev and SoundTouch LoadLibrary calls to mpt::Library. Do not yet convert plugin loading (for now). [Ref] Move loading of UXTheme.dll into CTrackApp. Modified Paths: -------------- trunk/OpenMPT/common/BuildSettings.h trunk/OpenMPT/common/misc_util.cpp trunk/OpenMPT/common/misc_util.h trunk/OpenMPT/mptrack/Ctrl_smp.cpp trunk/OpenMPT/mptrack/MPTrackUtil.cpp trunk/OpenMPT/mptrack/Mptrack.cpp trunk/OpenMPT/mptrack/Mptrack.h trunk/OpenMPT/mptrack/StreamEncoderMP3.cpp trunk/OpenMPT/mptrack/StreamEncoderOpus.cpp trunk/OpenMPT/mptrack/StreamEncoderVorbis.cpp trunk/OpenMPT/mptrack/View_gen.cpp trunk/OpenMPT/sounddev/SoundDeviceThread.cpp trunk/OpenMPT/sounddev/SoundDeviceThread.h trunk/OpenMPT/soundlib/Load_mo3.cpp trunk/OpenMPT/soundlib/SampleFormats.cpp Modified: trunk/OpenMPT/common/BuildSettings.h =================================================================== --- trunk/OpenMPT/common/BuildSettings.h 2014-03-10 19:17:18 UTC (rev 3859) +++ trunk/OpenMPT/common/BuildSettings.h 2014-03-10 19:23:36 UTC (rev 3860) @@ -231,11 +231,6 @@ // fixing stuff up -#if !defined(MODPLUG_TRACKER) && defined(NO_MO3) -// For library builds, windows.h is only required for LoadLibrary. -//#define NO_WINDOWS_H -#endif - #if !defined(ENABLE_MMX) && !defined(NO_REVERB) #define NO_REVERB // reverb requires mmx #endif @@ -289,8 +284,13 @@ #define MPT_WITH_CHARSET_LOCALE // PathString requires locale charset #endif +#if !defined(MODPLUG_TRACKER) && defined(MPT_WITH_DYNBIND) +// For library builds, windows.h is only required for LoadLibrary. +//#define NO_WINDOWS_H +#endif + #if MPT_COMPILER_MSVC #define VC_EXTRALEAN // Exclude rarely-used stuff from Windows headers #endif Modified: trunk/OpenMPT/common/misc_util.cpp =================================================================== --- trunk/OpenMPT/common/misc_util.cpp 2014-03-10 19:17:18 UTC (rev 3859) +++ trunk/OpenMPT/common/misc_util.cpp 2014-03-10 19:23:36 UTC (rev 3860) @@ -17,7 +17,14 @@ #include <time.h> +#if defined(MPT_WITH_DYNBIND) +#if !MPT_OS_WINDOWS +#include <dlfcn.h> +#endif +#endif + + template<typename T> inline T ConvertStrToHelper(const std::string &str) { @@ -433,3 +440,330 @@ } // namespace Util + + +#if defined(MPT_WITH_DYNBIND) + + +namespace mpt +{ + + +#if MPT_OS_WINDOWS + + +// KB2533623 / Win8 +#ifndef LOAD_LIBRARY_SEARCH_DEFAULT_DIRS +#define LOAD_LIBRARY_SEARCH_DEFAULT_DIRS 0x00001000 +#endif +#ifndef LOAD_LIBRARY_SEARCH_APPLICATION_DIR +#define LOAD_LIBRARY_SEARCH_APPLICATION_DIR 0x00000200 +#endif +#ifndef LOAD_LIBRARY_SEARCH_SYSTEM32 +#define LOAD_LIBRARY_SEARCH_SYSTEM32 0x00000800 +#endif +#ifndef LOAD_LIBRARY_SEARCH_DLL_LOAD_DIR +#define LOAD_LIBRARY_SEARCH_DLL_LOAD_DIR 0x00000100 +#endif + + +#if !defined(MODPLUG_TRACKER) +// For OpenMPT, this is defined in mptrack/MPTrackUtil.cpp . +mpt::PathString GetAppPath() +{ + return mpt::PathString(); // dummy +} +#endif + +mpt::PathString GetSystemPath() +{ + WCHAR path[MAX_PATH+1]; + MemsetZero(path); + GetSystemDirectoryW(path, MAX_PATH); + return mpt::PathString::FromNative(path) + MPT_PATHSTRING("\\"); +} + + +class LibraryHandle +{ + +private: + + HMODULE hModule; + +public: + + LibraryHandle(const mpt::LibraryPath &path) + : hModule(NULL) + { + + // Check for KB2533623: + bool hasKB2533623 = false; + if(mpt::Windows::GetWinNTVersion() >= mpt::Windows::VerWin8) + { + hasKB2533623 = true; + } else if(mpt::Windows::GetWinNTVersion() >= mpt::Windows::VerWinVista) + { + HMODULE hKernel32DLL = LoadLibraryW(L"kernel32.dll"); + if(hKernel32DLL) + { + if(::GetProcAddress(hKernel32DLL, "SetDefaultDllDirectories") != nullptr) + { + hasKB2533623 = true; + } + FreeLibrary(hKernel32DLL); + hKernel32DLL = NULL; + } + } + + if(hasKB2533623) + { + switch(path.GetSearchPath()) + { + case mpt::LibrarySearchPathDefault: + hModule = LoadLibraryExW(path.GetFileName().AsNative().c_str(), NULL, LOAD_LIBRARY_SEARCH_DEFAULT_DIRS); + break; + case mpt::LibrarySearchPathSystem: + hModule = LoadLibraryExW(path.GetFileName().AsNative().c_str(), NULL, LOAD_LIBRARY_SEARCH_SYSTEM32); + break; +#if 0 + // Using restricted search paths applies to potential DLL dependencies + // recursively. + // This fails loading for e.g. Codec or Plugin DLLs in application + // directory if they depend on the MSVC C or C++ runtime (which is + // located in the system directory). + // Just rely on the default search path here. + case mpt::LibrarySearchPathApplication: + hModule = LoadLibraryExW(path.GetFileName().AsNative().c_str(), NULL, LOAD_LIBRARY_SEARCH_APPLICATION_DIR); + break; + case mpt::LibrarySearchPathFullPath: + hModule = LoadLibraryExW(path.GetFileName().AsNative().c_str(), NULL, LOAD_LIBRARY_SEARCH_DLL_LOAD_DIR); + break; +#else + case mpt::LibrarySearchPathApplication: + hModule = LoadLibraryW((mpt::GetAppPath() + path.GetFileName()).AsNative().c_str()); + break; + case mpt::LibrarySearchPathFullPath: + hModule = LoadLibraryW(path.GetFileName().AsNative().c_str()); + break; +#endif + } + } else + { + switch(path.GetSearchPath()) + { + case mpt::LibrarySearchPathDefault: + hModule = LoadLibraryW(path.GetFileName().AsNative().c_str()); + break; + case mpt::LibrarySearchPathApplication: + hModule = LoadLibraryW((mpt::GetAppPath() + path.GetFileName()).AsNative().c_str()); + break; + case mpt::LibrarySearchPathSystem: + hModule = LoadLibraryW((mpt::GetSystemPath() + path.GetFileName()).AsNative().c_str()); + break; + case mpt::LibrarySearchPathFullPath: + hModule = LoadLibraryW(path.GetFileName().AsNative().c_str()); + break; + } + } + } + + ~LibraryHandle() + { + if(IsValid()) + { + FreeLibrary(hModule); + } + hModule = NULL; + } + +public: + + bool IsValid() const + { + return (hModule != NULL); + } + + FuncPtr GetProcAddress(const std::string &symbol) const + { + if(!IsValid()) + { + return nullptr; + } + return reinterpret_cast<FuncPtr>(::GetProcAddress(hModule, symbol.c_str())); + } + +}; + + +#else + + +class LibraryHandle +{ + +private: + + void * handle; + +public: + + LibraryHandle(const mpt::LibraryPath &path) + : handle(NULL) + { + handle = dlopen(path.GetFileName().AsNative().c_str(), RTLD_NOW); + } + + ~LibraryHandle() + { + if(IsValid()) + { + dlclose(handle); + } + handle = NULL; + } + +public: + + bool IsValid() const + { + return handle != NULL; + } + + FuncPtr GetProcAddress(const std::string &symbol) const + { + if(!IsValid()) + { + return NULL; + } + return reinterpret_cast<FuncPtr>(dlsym(handle, symbol.c_str())); + } + +}; + + +#endif + + +LibraryPath::LibraryPath(mpt::LibrarySearchPath searchPath, class mpt::PathString const &fileName) +//------------------------------------------------------------------------------------------------ + : searchPath(searchPath) + , fileName(fileName) +{ + return; +} + + +mpt::LibrarySearchPath LibraryPath::GetSearchPath() const +//------------------------------------------------------- +{ + return searchPath; +} + + +mpt::PathString LibraryPath::GetFileName() const +//---------------------------------------------- +{ + return fileName; +} + + +mpt::PathString LibraryPath::GetDefaultPrefix() +//--------------------------------------------- +{ +#if MPT_OS_WINDOWS + return MPT_PATHSTRING(""); +#elif MPT_OS_MACOSX_OR_IOS + return MPT_PATHSTRING("lib"); +#else + return MPT_PATHSTRING("lib"); +#endif +} + + +mpt::PathString LibraryPath::GetDefaultSuffix() +//--------------------------------------------- +{ +#if MPT_OS_WINDOWS + return MPT_PATHSTRING(".dll"); +#elif MPT_OS_MACOSX_OR_IOS + return MPT_PATHSTRING(".dylib"); +#else + return MPT_PATHSTRING(".so"); +#endif +} + + +LibraryPath LibraryPath::App(const mpt::PathString &basename) +//----------------------------------------------------------- +{ + return LibraryPath(mpt::LibrarySearchPathApplication, GetDefaultPrefix() + basename + GetDefaultSuffix()); +} + + +LibraryPath LibraryPath::AppFullName(const mpt::PathString &fullname) +//------------------------------------------------------------------- +{ + return LibraryPath(mpt::LibrarySearchPathApplication, fullname + GetDefaultSuffix()); +} + + +LibraryPath LibraryPath::System(const mpt::PathString &basename) +//-------------------------------------------------------------- +{ + return LibraryPath(mpt::LibrarySearchPathSystem, GetDefaultPrefix() + basename + GetDefaultSuffix()); +} + + +LibraryPath LibraryPath::FullPath(const mpt::PathString &path) +//------------------------------------------------------------ +{ + return LibraryPath(mpt::LibrarySearchPathFullPath, path); +} + + +Library::Library() +//---------------- + : m_Handle(nullptr) +{ + return; +} + + +Library::Library(const mpt::LibraryPath &path) +//-------------------------------------------- + : m_Handle(nullptr) +{ + m_Handle = MPT_SHARED_PTR<LibraryHandle>(new LibraryHandle(path)); +} + + +void Library::Unload() +//-------------------- +{ + *this = mpt::Library(); +} + + +bool Library::IsValid() const +//--------------------------- +{ + return m_Handle && m_Handle->IsValid(); +} + + +FuncPtr Library::GetProcAddress(const std::string &symbol) const +//-------------------------------------------------------------- +{ + if(!IsValid()) + { + return nullptr; + } + return m_Handle->GetProcAddress(symbol); +} + + +} // namespace mpt + + +#endif // MPT_WITH_DYNBIND Modified: trunk/OpenMPT/common/misc_util.h =================================================================== --- trunk/OpenMPT/common/misc_util.h 2014-03-10 19:17:18 UTC (rev 3859) +++ trunk/OpenMPT/common/misc_util.h 2014-03-10 19:23:36 UTC (rev 3860) @@ -684,3 +684,110 @@ #endif // WIN32 } // namespace mpt + + +#if defined(MPT_WITH_DYNBIND) + +namespace mpt +{ + + +#if MPT_OS_WINDOWS + +// Returns the application path or an empty string (if unknown), e.g. "C:\mptrack\" +mpt::PathString GetAppPath(); + +// Returns the system directory path, e.g. "C:\Windows\System32\" +mpt::PathString GetSystemPath(); + +#endif // MPT_OS_WINDOWS + + +typedef void* (*FuncPtr)(); // pointer to function returning void* + +class LibraryHandle; + +enum LibrarySearchPath +{ + LibrarySearchPathDefault, + LibrarySearchPathApplication, + LibrarySearchPathSystem, + LibrarySearchPathFullPath, +}; + +class LibraryPath +{ + +private: + + mpt::LibrarySearchPath searchPath; + mpt::PathString fileName; + +private: + + LibraryPath(mpt::LibrarySearchPath searchPath, const mpt::PathString &fileName); + +public: + + mpt::LibrarySearchPath GetSearchPath() const; + + mpt::PathString GetFileName() const; + +public: + + // "lib" on Unix-like systems, "" on Windows + static mpt::PathString GetDefaultPrefix(); + + // ".so" or ".dylib" or ".dll" + static mpt::PathString GetDefaultSuffix(); + + // Returns the library path in the application directory, with os-specific prefix and suffix added to basename. + // e.g.: basename = "unmo3" --> "libunmo3.so" / "apppath/unmo3.dll" + static LibraryPath App(const mpt::PathString &basename); + + // Returns the library path in the application directory, with os-specific suffix added to fullname. + // e.g.: fullname = "libunmo3" --> "libunmo3.so" / "apppath/libunmo3.dll" + static LibraryPath AppFullName(const mpt::PathString &fullname); + + // Returns a system library name with os-specific prefix and suffix added to basename, but without any full path in order to be searched in the default search path. + // e.g.: basename = "unmo3" --> "libunmo3.so" / "unmo3.dll" + static LibraryPath System(const mpt::PathString &basename); + + // Returns a system library name with os-specific suffix added to path. + // e.g.: path = "somepath/foo" --> "somepath/foo.so" / "somepath/foo.dll" + static LibraryPath FullPath(const mpt::PathString &path); + +}; + +class Library +{ +protected: + MPT_SHARED_PTR<LibraryHandle> m_Handle; +public: + Library(); + Library(const mpt::LibraryPath &path); +public: + void Unload(); + bool IsValid() const; + FuncPtr GetProcAddress(const std::string &symbol) const; + template <typename Tfunc> + bool Bind(Tfunc * & f, const std::string &symbol) const + { + #ifdef HAS_TYPE_TRAITS + #if (MPT_COMPILER_MSVC && MPT_MSVC_AT_LEAST(2013,0)) || !MPT_COMPILER_MSVC + // MSVC std::is_function is always false for non __cdecl functions. + // See https://connect.microsoft.com/VisualStudio/feedback/details/774720/stl-is-function-bug . + // Revisit with VS2013. + STATIC_ASSERT(std::is_function<Tfunc>::value); + #endif + #endif + const FuncPtr addr = GetProcAddress(symbol); + f = reinterpret_cast<Tfunc*>(addr); + return (addr != nullptr); + } +}; + +} // namespace mpt + +#endif // MPT_WITH_DYNBIND + Modified: trunk/OpenMPT/mptrack/Ctrl_smp.cpp =================================================================== --- trunk/OpenMPT/mptrack/Ctrl_smp.cpp 2014-03-10 19:17:18 UTC (rev 3859) +++ trunk/OpenMPT/mptrack/Ctrl_smp.cpp 2014-03-10 19:23:36 UTC (rev 3860) @@ -1830,16 +1830,15 @@ if(pitch < 0.5f) return 2 + (1<<8); if(pitch > 2.0f) return 2 + (2<<8); - HANDLE handleSt = NULL; - // Check whether the DLL file exists. - HMODULE dllHandle = LoadLibraryW((CTrackApp::GetAppDirPath() + MPT_PATHSTRING("OpenMPT_SoundTouch_f32.dll")).AsNative().c_str()); - if(dllHandle != NULL) + mpt::Library libSoundTouch = mpt::Library(mpt::LibraryPath::AppFullName(MPT_PATHSTRING("OpenMPT_SoundTouch_f32"))); + if(!libSoundTouch.IsValid()) { - FreeLibrary(dllHandle); - handleSt = soundtouch_createInstance(); + MsgBox(IDS_SOUNDTOUCH_LOADFAILURE); + return -1; } - if (handleSt == NULL) + HANDLE handleSt = soundtouch_createInstance(); + if(handleSt == NULL) { MsgBox(IDS_SOUNDTOUCH_LOADFAILURE); return -1; Modified: trunk/OpenMPT/mptrack/MPTrackUtil.cpp =================================================================== --- trunk/OpenMPT/mptrack/MPTrackUtil.cpp 2014-03-10 19:17:18 UTC (rev 3859) +++ trunk/OpenMPT/mptrack/MPTrackUtil.cpp 2014-03-10 19:23:36 UTC (rev 3860) @@ -10,11 +10,29 @@ #include "stdafx.h" #include "MPTrackUtil.h" +#include "Mptrack.h" +#include "../common/misc_util.h" #include <io.h> // for _taccess #include <time.h> + +namespace mpt +{ + + +// declared in misc_util.h +mpt::PathString GetAppPath() +//-------------------------- +{ + return theApp.GetAppDirPath(); +} + + +} // namespace mpt + + /* * Loads resource. * [in] lpName and lpType: parameters passed to FindResource(). Modified: trunk/OpenMPT/mptrack/Mptrack.cpp =================================================================== --- trunk/OpenMPT/mptrack/Mptrack.cpp 2014-03-10 19:17:18 UTC (rev 3859) +++ trunk/OpenMPT/mptrack/Mptrack.cpp 2014-03-10 19:23:36 UTC (rev 3860) @@ -615,6 +615,7 @@ //-------------------- : m_GuiThreadId(0) , m_pTrackerDirectories(nullptr) + , m_pUXThemeDLL(nullptr) , m_pSettingsIniFile(nullptr) , m_pSettings(nullptr) , m_pTrackerSettings(nullptr) @@ -870,6 +871,10 @@ // Set up paths to store configuration in SetupPaths(cmdInfo.m_bPortable); + // Load UXTheme.DLL + m_pUXThemeDLL = new mpt::Library(mpt::LibraryPath::System(MPT_PATHSTRING("uxtheme"))); + m_pUXThemeDLL->Bind(m_pEnableThemeDialogTexture, "EnableThemeDialogTexture"); + // Construct auto saver instance, class TrackerSettings expects it being available. CMainFrame::m_pAutoSaver = new CAutoSaver(); @@ -1004,6 +1009,9 @@ m_pSettings = nullptr; delete m_pSettingsIniFile; m_pSettingsIniFile = nullptr; + m_pEnableThemeDialogTexture = nullptr; + delete m_pUXThemeDLL; + m_pUXThemeDLL = nullptr; delete m_pTrackerDirectories; m_pTrackerDirectories = nullptr; Modified: trunk/OpenMPT/mptrack/Mptrack.h =================================================================== --- trunk/OpenMPT/mptrack/Mptrack.h 2014-03-10 19:17:18 UTC (rev 3859) +++ trunk/OpenMPT/mptrack/Mptrack.h 2014-03-10 19:23:36 UTC (rev 3860) @@ -189,6 +189,9 @@ DWORD m_GuiThreadId; TrackerDirectories *m_pTrackerDirectories; + mpt::Library *m_pUXThemeDLL; + typedef HRESULT (WINAPI * pfEnableThemeDialogTexture)(HWND, DWORD); + pfEnableThemeDialogTexture m_pEnableThemeDialogTexture; IniFileSettingsBackend *m_pSettingsIniFile; SettingsContainer *m_pSettings; TrackerSettings *m_pTrackerSettings; @@ -241,6 +244,7 @@ public: bool InGuiThread() const { return GetCurrentThreadId() == m_GuiThreadId; } + HRESULT EnableThemeDialogTexture(HWND hwnd, DWORD dwFlags) { if(m_pEnableThemeDialogTexture) return m_pEnableThemeDialogTexture(hwnd, dwFlags); else return S_OK; } CModDocTemplate *GetModDocTemplate() const { return m_pModTemplate; } CVstPluginManager *GetPluginManager() const { return m_pPluginManager; } SoundDevicesManager *GetSoundDevicesManager() const { return m_pSoundDevicesManager; } Modified: trunk/OpenMPT/mptrack/StreamEncoderMP3.cpp =================================================================== --- trunk/OpenMPT/mptrack/StreamEncoderMP3.cpp 2014-03-10 19:17:18 UTC (rev 3859) +++ trunk/OpenMPT/mptrack/StreamEncoderMP3.cpp 2014-03-10 19:23:36 UTC (rev 3860) @@ -255,7 +255,7 @@ struct LameDynBind { - HMODULE hLame; + mpt::Library hLame; const char* (CDECL * get_lame_version)(); const char* (CDECL * get_lame_short_version)(); @@ -316,31 +316,27 @@ void Reset() { - std::memset(this, 0, sizeof(*this)); + return; } LameDynBind() { Reset(); - if(!hLame) TryLoad(MPT_PATHSTRING("libmp3lame.dll"), true); - if(!hLame) TryLoad(MPT_PATHSTRING("liblame.dll"), true); - if(!hLame) TryLoad(MPT_PATHSTRING("mp3lame.dll"), true); - if(!hLame) TryLoad(MPT_PATHSTRING("lame.dll"), true); - if(!hLame) TryLoad(MPT_PATHSTRING("lame_enc.dll"), false); + if(!hLame.IsValid()) TryLoad(MPT_PATHSTRING("libmp3lame"), true); + if(!hLame.IsValid()) TryLoad(MPT_PATHSTRING("liblame"), true); + if(!hLame.IsValid()) TryLoad(MPT_PATHSTRING("mp3lame"), true); + if(!hLame.IsValid()) TryLoad(MPT_PATHSTRING("lame"), true); + if(!hLame.IsValid()) TryLoad(MPT_PATHSTRING("lame_enc"), false); } - void TryLoad(mpt::PathString filename, bool warn) + void TryLoad(const mpt::PathString &filename, bool warn) { - #ifdef MODPLUG_TRACKER - filename = theApp.GetAppDirPath() + filename; - #endif - hLame = LoadLibraryW(filename.AsNative().c_str()); - if(!hLame) + hLame = mpt::Library(mpt::LibraryPath::AppFullName(filename)); + if(!hLame.IsValid()) { return; } bool ok = true; #define LAME_BIND(f) do { \ - FARPROC pf = GetProcAddress(hLame, #f ); \ - if(!pf) \ + if(!hLame.Bind( f , #f )) \ { \ ok = false; \ if(warn) \ @@ -348,7 +344,6 @@ Reporting::Error(mpt::String::Format("Your '%s' is missing '%s'.\n\nPlease copy a newer 'libmp3lame.dll' into OpenMPT's root directory.", filename, #f ).c_str(), "OpenMPT - MP3 Export"); \ } \ } \ - *reinterpret_cast<void**>(& f ) = reinterpret_cast<void*>(pf); \ } while(0) LAME_BIND(get_lame_version); LAME_BIND(get_lame_short_version); @@ -391,18 +386,15 @@ #undef LAME_BIND if(!ok) { - FreeLibrary(hLame); + hLame.Unload(); Reset(); return; } } - operator bool () const { return hLame ? true : false; } + operator bool () const { return hLame.IsValid() ? true : false; } ~LameDynBind() { - if(hLame) - { - FreeLibrary(hLame); - } + hLame.Unload(); Reset(); } static void GenreEnumCallback(int num, const char *name, void *cookie) @@ -629,7 +621,7 @@ struct BladeDynBind { - HMODULE hBlade; + mpt::Library hBlade; int lame; @@ -641,40 +633,35 @@ void Reset() { - std::memset(this, 0, sizeof(*this)); + lame = 0; } BladeDynBind() { Reset(); - if(!hBlade) + if(!hBlade.IsValid()) { - TryLoad(MPT_PATHSTRING("lame_enc.dll")); - if(hBlade) lame = 1; + TryLoad(MPT_PATHSTRING("lame_enc")); + if(hBlade.IsValid()) lame = 1; } - if(!hBlade) + if(!hBlade.IsValid()) { - TryLoad(MPT_PATHSTRING("bladeenc.dll")); - if(hBlade) lame = 0; + TryLoad(MPT_PATHSTRING("bladeenc")); + if(hBlade.IsValid()) lame = 0; } } - void TryLoad(mpt::PathString filename) + void TryLoad(const mpt::PathString &filename) { - #ifdef MODPLUG_TRACKER - filename = theApp.GetAppDirPath() + filename; - #endif - hBlade = LoadLibraryW(filename.AsNative().c_str()); - if(!hBlade) + hBlade = mpt::Library(mpt::LibraryPath::AppFullName(filename)); + if(!hBlade.IsValid()) { return; } bool ok = true; #define BLADE_BIND(f) do { \ - FARPROC pf = GetProcAddress(hBlade, #f ); \ - if(!pf) \ + if(!hBlade.Bind( f , #f )) \ { \ ok = false; \ } \ - *reinterpret_cast<void**>(& f ) = reinterpret_cast<void*>(pf); \ } while(0) BLADE_BIND(beVersion); BLADE_BIND(beInitStream); @@ -684,18 +671,15 @@ #undef BLADE_BIND if(!ok) { - FreeLibrary(hBlade); + hBlade.Unload(); Reset(); return; } } - operator bool () const { return hBlade ? true : false; } + operator bool () const { return hBlade.IsValid(); } ~BladeDynBind() { - if(hBlade) - { - FreeLibrary(hBlade); - } + hBlade.Unload(); Reset(); } Encoder::Traits BuildTraits() Modified: trunk/OpenMPT/mptrack/StreamEncoderOpus.cpp =================================================================== --- trunk/OpenMPT/mptrack/StreamEncoderOpus.cpp 2014-03-10 19:17:18 UTC (rev 3859) +++ trunk/OpenMPT/mptrack/StreamEncoderOpus.cpp 2014-03-10 19:23:36 UTC (rev 3860) @@ -37,8 +37,8 @@ struct OpusDynBind { - HMODULE hOgg; - HMODULE hOpus; + mpt::Library hOgg; + mpt::Library hOpus; // ogg int (*ogg_stream_init)(ogg_stream_state *os,int serialno); @@ -62,7 +62,7 @@ void Reset() { - std::memset(this, 0, sizeof(*this)); + return; } OpusDynBind() { @@ -73,12 +73,12 @@ }; // start with trying all symbols from a single dll first static const dll_names_t dll_names[] = { - { "libopus-0.dll", "libopus-0.dll" }, - { "libopus.dll" , "libopus.dll" }, - { "opus.dll" , "opus.dll" }, - { "libogg-0.dll" , "libopus-0.dll" }, // official xiph.org builds - { "libogg.dll" , "libopus.dll" }, - { "ogg.dll" , "opus.dll" } + { "libopus-0", "libopus-0" }, + { "libopus" , "libopus" }, + { "opus" , "opus" }, + { "libogg-0" , "libopus-0" }, // official xiph.org builds + { "libogg" , "libopus" }, + { "ogg" , "opus" } }; for(std::size_t i=0; i<CountOf(dll_names); ++i) { @@ -89,34 +89,28 @@ } } } - bool TryLoad(mpt::PathString Ogg_fn, mpt::PathString Opus_fn) + bool TryLoad(const mpt::PathString &Ogg_fn, const mpt::PathString &Opus_fn) { - #ifdef MODPLUG_TRACKER - Ogg_fn = theApp.GetAppDirPath() + Ogg_fn; - Opus_fn = theApp.GetAppDirPath() + Opus_fn; - #endif - hOgg = LoadLibraryW(Ogg_fn.AsNative().c_str()); - if(!hOgg) + hOgg = mpt::Library(mpt::LibraryPath::AppFullName(Ogg_fn)); + if(!hOgg.IsValid()) { - if(hOgg) { FreeLibrary(hOgg); hOgg = NULL; } - if(hOpus) { FreeLibrary(hOpus); hOpus = NULL; } + if(hOgg.IsValid()) { hOgg.Unload(); } + if(hOpus.IsValid()) { hOpus.Unload(); } return false; } - hOpus = LoadLibraryW(Opus_fn.AsNative().c_str()); - if(!hOpus) + hOpus = mpt::Library(mpt::LibraryPath::AppFullName(Opus_fn)); + if(!hOpus.IsValid()) { - if(hOgg) { FreeLibrary(hOgg); hOgg = NULL; } - if(hOpus) { FreeLibrary(hOpus); hOpus = NULL; } + if(hOgg.IsValid()) { hOgg.Unload(); } + if(hOpus.IsValid()) { hOpus.Unload(); } return false; } bool ok = true; #define OPUS_BIND(l,f,req) do { \ - FARPROC pf = GetProcAddress( l , #f ); \ - if(!pf && req) \ + if(!l.Bind( f , #f ) && req) \ { \ ok = false; \ } \ - *reinterpret_cast<void**>(& f ) = reinterpret_cast<void*>(pf); \ } while(0) OPUS_BIND(hOgg,ogg_stream_init,true); OPUS_BIND(hOgg,ogg_stream_packetin,true); @@ -132,18 +126,18 @@ #undef OPUS_BIND if(!ok) { - if(hOgg) { FreeLibrary(hOgg); hOgg = NULL; } - if(hOpus) { FreeLibrary(hOpus); hOpus = NULL; } + if(hOgg.IsValid()) { hOgg.Unload(); } + if(hOpus.IsValid()) { hOpus.Unload(); } Reset(); return false; } return true; } - operator bool () const { return hOgg && hOpus; } + operator bool () const { return hOgg.IsValid() && hOpus.IsValid(); } ~OpusDynBind() { - if(hOgg) { FreeLibrary(hOgg); hOgg = NULL; } - if(hOpus) { FreeLibrary(hOpus); hOpus = NULL; } + if(hOgg.IsValid()) { hOgg.Unload(); } + if(hOpus.IsValid()) { hOpus.Unload(); } Reset(); } Encoder::Traits BuildTraits() Modified: trunk/OpenMPT/mptrack/StreamEncoderVorbis.cpp =================================================================== --- trunk/OpenMPT/mptrack/StreamEncoderVorbis.cpp 2014-03-10 19:17:18 UTC (rev 3859) +++ trunk/OpenMPT/mptrack/StreamEncoderVorbis.cpp 2014-03-10 19:23:36 UTC (rev 3860) @@ -22,9 +22,9 @@ struct VorbisDynBind { - HMODULE hOgg; - HMODULE hVorbis; - HMODULE hVorbisEnc; + mpt::Library hOgg; + mpt::Library hVorbis; + mpt::Library hVorbisEnc; // ogg int (*ogg_stream_init)(ogg_stream_state *os,int serialno); @@ -59,7 +59,7 @@ void Reset() { - std::memset(this, 0, sizeof(*this)); + return; } VorbisDynBind() { @@ -71,14 +71,14 @@ }; // start with trying all symbols from a single dll first static const dll_names_t dll_names[] = { - { "libvorbis.dll", "libvorbis.dll" , "libvorbis.dll" }, - { "vorbis.dll" , "vorbis.dll" , "vorbis.dll" }, - { "libogg.dll" , "libvorbis.dll" , "libvorbis.dll" }, // official xiph.org builds - { "ogg.dll" , "vorbis.dll" , "vorbis.dll" }, - { "libogg-0.dll" , "libvorbis-0.dll", "libvorbis-0.dll" }, // mingw builds - { "libogg.dll" , "libvorbis.dll" , "libvorbisenc.dll" }, - { "ogg.dll" , "vorbis.dll" , "vorbisenc.dll" }, - { "libogg-0.dll" , "libvorbis-0.dll", "libvorbisenc-0.dll"} // mingw builds + { "libvorbis", "libvorbis" , "libvorbis" }, + { "vorbis" , "vorbis" , "vorbis" }, + { "libogg" , "libvorbis" , "libvorbis" }, // official xiph.org builds + { "ogg" , "vorbis" , "vorbis" }, + { "libogg-0" , "libvorbis-0", "libvorbis-0" }, // mingw builds + { "libogg" , "libvorbis" , "libvorbisenc" }, + { "ogg" , "vorbis" , "vorbisenc" }, + { "libogg-0" , "libvorbis-0", "libvorbisenc-0"} // mingw builds }; for(std::size_t i=0; i<CountOf(dll_names); ++i) { @@ -89,49 +89,41 @@ } } } - bool TryLoad(mpt::PathString Ogg_fn, mpt::PathString Vorbis_fn, mpt::PathString VorbisEnc_fn) + bool TryLoad(const mpt::PathString &Ogg_fn, const mpt::PathString &Vorbis_fn, const mpt::PathString &VorbisEnc_fn) { - #ifdef MODPLUG_TRACKER - Ogg_fn = theApp.GetAppDirPath() + Ogg_fn; - Vorbis_fn = theApp.GetAppDirPath() + Vorbis_fn; - VorbisEnc_fn = theApp.GetAppDirPath() + VorbisEnc_fn; - #endif - hOgg = LoadLibraryW(Ogg_fn.AsNative().c_str()); - if(!hOgg) + hOgg = mpt::Library(mpt::LibraryPath::AppFullName(Ogg_fn)); + if(!hOgg.IsValid()) { - if(hOgg) { FreeLibrary(hOgg); hOgg = NULL; } - if(hVorbis) { FreeLibrary(hVorbis); hVorbis = NULL; } - if(hVorbisEnc) { FreeLibrary(hVorbisEnc); hVorbisEnc = NULL; } + if(hOgg.IsValid()) { hOgg.Unload(); } + if(hVorbis.IsValid()) { hVorbis.Unload(); } + if(hVorbisEnc.IsValid()) { hVorbisEnc.Unload(); } return false; } - hVorbis = LoadLibraryW(Vorbis_fn.AsNative().c_str()); - if(!hVorbis) + hVorbis = mpt::Library(mpt::LibraryPath::AppFullName(Vorbis_fn)); + if(!hVorbis.IsValid()) { - if(hOgg) { FreeLibrary(hOgg); hOgg = NULL; } - if(hVorbis) { FreeLibrary(hVorbis); hVorbis = NULL; } - if(hVorbisEnc) { FreeLibrary(hVorbisEnc); hVorbisEnc = NULL; } + if(hOgg.IsValid()) { hOgg.Unload(); } + if(hVorbis.IsValid()) { hVorbis.Unload(); } + if(hVorbisEnc.IsValid()) { hVorbisEnc.Unload(); } return false; } - hVorbisEnc = LoadLibraryW(VorbisEnc_fn.AsNative().c_str()); - if(!hVorbisEnc) + hVorbisEnc = mpt::Library(mpt::LibraryPath::AppFullName(VorbisEnc_fn)); + if(!hVorbisEnc.IsValid()) { - if(hOgg) { FreeLibrary(hOgg); hOgg = NULL; } - if(hVorbis) { FreeLibrary(hVorbis); hVorbis = NULL; } - if(hVorbisEnc) { FreeLibrary(hVorbisEnc); hVorbisEnc = NULL; } + if(hOgg.IsValid()) { hOgg.Unload(); } + if(hVorbis.IsValid()) { hVorbis.Unload(); } + if(hVorbisEnc.IsValid()) { hVorbisEnc.Unload(); } return false; } bool ok = true; #define VORBIS_BIND(l,f) do { \ - FARPROC pf = GetProcAddress( l , #f ); \ - if(!pf) \ + if(!l.Bind( f , #f )) \ { \ ok = false; \ } \ - *reinterpret_cast<void**>(& f ) = reinterpret_cast<void*>(pf); \ } while(0) #define VORBIS_BIND_OPTIONAL(l,f) do { \ - FARPROC pf = GetProcAddress( l , #f ); \ - *reinterpret_cast<void**>(& f ) = reinterpret_cast<void*>(pf); \ + l.Bind( f , #f ); \ } while(0) VORBIS_BIND(hOgg,ogg_stream_init); VORBIS_BIND(hOgg,ogg_stream_packetin); @@ -162,20 +154,20 @@ #undef VORBIS_BIND_OPTIONAL if(!ok) { - if(hOgg) { FreeLibrary(hOgg); hOgg = NULL; } - if(hVorbis) { FreeLibrary(hVorbis); hVorbis = NULL; } - if(hVorbisEnc) { FreeLibrary(hVorbisEnc); hVorbisEnc = NULL; } + if(hOgg.IsValid()) { hOgg.Unload(); } + if(hVorbis.IsValid()) { hVorbis.Unload(); } + if(hVorbisEnc.IsValid()) { hVorbisEnc.Unload(); } Reset(); return false; } return true; } - operator bool () const { return hOgg && hVorbis && hVorbisEnc; } + operator bool () const { return hOgg.IsValid() && hVorbis.IsValid() && hVorbisEnc.IsValid(); } ~VorbisDynBind() { - if(hOgg) { FreeLibrary(hOgg); hOgg = NULL; } - if(hVorbis) { FreeLibrary(hVorbis); hVorbis = NULL; } - if(hVorbisEnc) { FreeLibrary(hVorbisEnc); hVorbisEnc = NULL; } + if(hOgg.IsValid()) { hOgg.Unload(); } + if(hVorbis.IsValid()) { hVorbis.Unload(); } + if(hVorbisEnc.IsValid()) { hVorbisEnc.Unload(); } Reset(); } Encoder::Traits BuildTraits() Modified: trunk/OpenMPT/mptrack/View_gen.cpp =================================================================== --- trunk/OpenMPT/mptrack/View_gen.cpp 2014-03-10 19:17:18 UTC (rev 3859) +++ trunk/OpenMPT/mptrack/View_gen.cpp 2014-03-10 19:23:36 UTC (rev 3860) @@ -1491,35 +1491,16 @@ // This is used for retrieving the correct background colour for the // frames on the general tab when using WinXP Luna or Vista/Win7 Aero. -typedef HRESULT (__stdcall * ETDT)(HWND, DWORD); #include <uxtheme.h> HBRUSH CViewGlobals::OnCtlColor(CDC *pDC, CWnd* pWnd, UINT nCtlColor) //------------------------------------------------------------------- { - static bool bUxInited = false; - static ETDT hETDT = NULL; - - if(!bUxInited) - { - // retrieve path for uxtheme.dll... - WCHAR szPath[MAX_PATH]; - SHGetSpecialFolderPathW(0, szPath, CSIDL_SYSTEM, FALSE); - wcsncat(szPath, L"\\uxtheme.dll", MAX_PATH - (wcslen(szPath) + 1)); - - // ...and try to load it - HMODULE uxlib = LoadLibraryW(szPath); - if(uxlib) - hETDT = (ETDT)GetProcAddress(uxlib, "EnableThemeDialogTexture"); - bUxInited = true; - } - switch(nCtlColor) { case CTLCOLOR_DLG: - if(hETDT) - hETDT(*pWnd, ETDT_ENABLETAB); + theApp.EnableThemeDialogTexture(*pWnd, ETDT_ENABLETAB); + break; } - return CFormView::OnCtlColor(pDC, pWnd, nCtlColor); } Modified: trunk/OpenMPT/sounddev/SoundDeviceThread.cpp =================================================================== --- trunk/OpenMPT/sounddev/SoundDeviceThread.cpp 2014-03-10 19:17:18 UTC (rev 3859) +++ trunk/OpenMPT/sounddev/SoundDeviceThread.cpp 2014-03-10 19:23:36 UTC (rev 3860) @@ -26,12 +26,10 @@ m_HasXP = (mpt::Windows::GetWinNTVersion() >= mpt::Windows::VerWinXP); - m_hKernel32DLL = NULL; - pCreateWaitableTimer = nullptr; pSetWaitableTimer = nullptr; pCancelWaitableTimer = nullptr; - m_hKernel32DLL = LoadLibrary(TEXT("kernel32.dll")); + m_Kernel32DLL = mpt::Library(mpt::LibraryPath::System(MPT_PATHSTRING("kernel32"))); #if _WIN32_WINNT >= _WIN32_WINNT_WINXP m_HasXP = true; pCreateWaitableTimer = &CreateWaitableTimer; @@ -40,13 +38,18 @@ #else if(m_HasXP && m_hKernel32DLL) { - pCreateWaitableTimer = (FCreateWaitableTimer)GetProcAddress(m_hKernel32DLL, "CreateWaitableTimerA"); - pSetWaitableTimer = (FSetWaitableTimer)GetProcAddress(m_hKernel32DLL, "SetWaitableTimer"); - pCancelWaitableTimer = (FCancelWaitableTimer)GetProcAddress(m_hKernel32DLL, "CancelWaitableTimer"); - if(!pCreateWaitableTimer || !pSetWaitableTimer || !pCancelWaitableTimer) + if(!m_Kernel32DLL.Bind(pCreateWaitableTimer, "CreateWaitableTimerA")) { m_HasXP = false; } + if(!m_Kernel32DLL.Bind(pSetWaitableTimer, "SetWaitableTimer")) + { + m_HasXP = false; + } + if(!m_Kernel32DLL.Bind(pCancelWaitableTimer, "CancelWaitableTimer")) + { + m_HasXP = false; + } } #endif @@ -95,19 +98,12 @@ pSetWaitableTimer = nullptr; pCancelWaitableTimer = nullptr; - if(m_hKernel32DLL) - { - FreeLibrary(m_hKernel32DLL); - m_hKernel32DLL = NULL; - } - } CPriorityBooster::CPriorityBooster(bool boostPriority) //---------------------------------------------------- : m_HasVista(false) - , m_hAvRtDLL(NULL) , pAvSetMmThreadCharacteristics(nullptr) , pAvRevertMmThreadCharacteristics(nullptr) , m_BoostPriority(boostPriority) @@ -119,13 +115,18 @@ if(m_HasVista) { - m_hAvRtDLL = LoadLibrary(TEXT("avrt.dll")); - if(m_hAvRtDLL && m_hAvRtDLL != INVALID_HANDLE_VALUE) + m_AvRtDLL = mpt::Library(mpt::LibraryPath::System(MPT_PATHSTRING("avrt"))); + if(m_AvRtDLL.IsValid()) { - pAvSetMmThreadCharacteristics = (FAvSetMmThreadCharacteristics)GetProcAddress(m_hAvRtDLL, "AvSetMmThreadCharacteristicsA"); - pAvRevertMmThreadCharacteristics = (FAvRevertMmThreadCharacteristics)GetProcAddress(m_hAvRtDLL, "AvRevertMmThreadCharacteristics"); - } - if(!pAvSetMmThreadCharacteristics || !pAvRevertMmThreadCharacteristics) + if(!m_AvRtDLL.Bind(pAvSetMmThreadCharacteristics, "AvSetMmThreadCharacteristicsA")) + { + m_HasVista = false; + } + if(!m_AvRtDLL.Bind(pAvRevertMmThreadCharacteristics, "AvRevertMmThreadCharacteristics")) + { + m_HasVista = false; + } + } else { m_HasVista = false; } @@ -169,12 +170,6 @@ pAvRevertMmThreadCharacteristics = nullptr; pAvSetMmThreadCharacteristics = nullptr; - if(m_hAvRtDLL) - { - FreeLibrary(m_hAvRtDLL); - m_hAvRtDLL = NULL; - } - } Modified: trunk/OpenMPT/sounddev/SoundDeviceThread.h =================================================================== --- trunk/OpenMPT/sounddev/SoundDeviceThread.h 2014-03-10 19:17:18 UTC (rev 3859) +++ trunk/OpenMPT/sounddev/SoundDeviceThread.h 2014-03-10 19:23:36 UTC (rev 3860) @@ -13,7 +13,9 @@ #include "SoundDevice.h" +#include "../common/misc_util.h" + class CSoundDeviceWithThread; @@ -24,7 +26,7 @@ typedef BOOL (WINAPI *FAvRevertMmThreadCharacteristics)(HANDLE); private: bool m_HasVista; - HMODULE m_hAvRtDLL; + mpt::Library m_AvRtDLL; FAvSetMmThreadCharacteristics pAvSetMmThreadCharacteristics; FAvRevertMmThreadCharacteristics pAvRevertMmThreadCharacteristics; bool m_BoostPriority; @@ -43,7 +45,7 @@ CSoundDeviceWithThread & m_SoundDevice; bool m_HasXP; - HMODULE m_hKernel32DLL; + mpt::Library m_Kernel32DLL; typedef HANDLE (WINAPI *FCreateWaitableTimer)(LPSECURITY_ATTRIBUTES, BOOL, LPCTSTR); typedef BOOL (WINAPI *FSetWaitableTimer)(HANDLE, const LARGE_INTEGER *, LONG, PTIMERAPCROUTINE, LPVOID, BOOL); typedef BOOL (WINAPI *FCancelWaitableTimer)(HANDLE); Modified: trunk/OpenMPT/soundlib/Load_mo3.cpp =================================================================== --- trunk/OpenMPT/soundlib/Load_mo3.cpp 2014-03-10 19:17:18 UTC (rev 3859) +++ trunk/OpenMPT/soundlib/Load_mo3.cpp 2014-03-10 19:23:36 UTC (rev 3860) @@ -10,9 +10,6 @@ #include "stdafx.h" #include "Loaders.h" -#ifdef MODPLUG_TRACKER -#include "../mptrack/Mptrack.h" -#endif // MODPLUG_TRACKER bool CSoundFile::ReadMO3(FileReader &file, ModLoadingFlags loadFlags) @@ -46,58 +43,59 @@ bool result = false; // Result of trying to load the module, false == fail. // Try to load unmo3 dynamically. -#ifdef _WIN32 -#ifdef MODPLUG_TRACKER - HMODULE unmo3 = LoadLibraryW((theApp.GetAppDirPath() + MPT_PATHSTRING("unmo3.dll")).AsNative().c_str()); -#else - HMODULE unmo3 = LoadLibraryW(MPT_PATHSTRING("unmo3.dll").AsNative().c_str()); -#endif // MODPLUG_TRACKER -#else - void unmo3 = dlopen(MPT_PATHSTRING("libunmo3.so").AsNative().c_str(), RTLD_LAZY); -#endif // _WIN32 + mpt::Library unmo3 = mpt::Library(mpt::LibraryPath::App(MPT_PATHSTRING("unmo3"))); - if(unmo3 == nullptr) + if(!unmo3.IsValid()) { // Didn't succeed. AddToLog(GetStrI18N("Loading MO3 file failed because unmo3.dll could not be loaded.")); } else { // Library loaded successfully. - typedef uint32 (WINAPI * UNMO3_GETVERSION)(); + #if MPT_OS_WINDOWS + #define UNMO3_API WINAPI + #else + #define UNMO3_API + #endif + typedef uint32 (UNMO3_API * UNMO3_GETVERSION)(); // Decode a MO3 file (returns the same "exit codes" as UNMO3.EXE, eg. 0=success) // IN: data/len = MO3 data/len // OUT: data/len = decoded data/len (if successful) // flags & 1: Don't load samples - typedef int32 (WINAPI * UNMO3_DECODE_OLD)(const void **data, uint32 *len); - typedef int32 (WINAPI * UNMO3_DECODE)(const void **data, uint32 *len, uint32 flags); + typedef int32 (UNMO3_API * UNMO3_DECODE_OLD)(const void **data, uint32 *len); + typedef int32 (UNMO3_API * UNMO3_DECODE)(const void **data, uint32 *len, uint32 flags); // Free the data returned by UNMO3_Decode - typedef void (WINAPI * UNMO3_FREE)(const void *data); + typedef void (UNMO3_API * UNMO3_FREE)(const void *data); + #undef UNMO3_API -#ifdef _WIN32 - UNMO3_GETVERSION UNMO3_GetVersion = (UNMO3_GETVERSION)GetProcAddress(unmo3, "UNMO3_GetVersion"); - void *UNMO3_Decode = GetProcAddress(unmo3, "UNMO3_Decode"); - UNMO3_FREE UNMO3_Free = (UNMO3_FREE)GetProcAddress(unmo3, "UNMO3_Free"); -#else - UNMO3_DECODE UNMO3_Decode = (UNMO3_DECODE)dlsym(unmo3, "UNMO3_Decode"); - UNMO3_FREE UNMO3_Free = (UNMO3_FREE)dlsym(unmo3, "UNMO3_Free"); -#endif // _WIN32 - - if(UNMO3_Decode != nullptr && UNMO3_Free != nullptr) + UNMO3_GETVERSION UNMO3_GetVersion = nullptr; + UNMO3_DECODE_OLD UNMO3_Decode_Old = nullptr; + UNMO3_DECODE UNMO3_Decode = nullptr; + UNMO3_FREE UNMO3_Free = nullptr; + unmo3.Bind(UNMO3_GetVersion, "UNMO3_GetVersion"); + if(UNMO3_GetVersion == nullptr) { + // Old API version: No "flags" parameter. + unmo3.Bind(UNMO3_Decode_Old, "UNMO3_Decode"); + } else + { + unmo3.Bind(UNMO3_Decode, "UNMO3_Decode"); + } + unmo3.Bind(UNMO3_Free, "UNMO3_Free"); + if((UNMO3_Decode != nullptr || UNMO3_Decode_Old != nullptr) && UNMO3_Free != nullptr) + { file.Rewind(); const void *stream = file.GetRawData(); uint32 length = mpt::saturate_cast<uint32>(file.GetLength()); int32 unmo3result; -#ifdef _WIN32 - if(UNMO3_GetVersion == nullptr) + if(UNMO3_Decode != nullptr) { - // Old API version: No "flags" parameter. - unmo3result = static_cast<UNMO3_DECODE_OLD>(UNMO3_Decode)(&stream, &length); + unmo3result = UNMO3_Decode(&stream, &length, (loadFlags & loadSampleData) ? 0 : 1); } else -#endif // _WIN32 { - unmo3result = static_cast<UNMO3_DECODE>(UNMO3_Decode)(&stream, &length, (loadFlags & loadSampleData) ? 0 : 1); + // Old API version: No "flags" parameter. + unmo3result = UNMO3_Decode_Old(&stream, &length); } if(unmo3result == 0) @@ -119,11 +117,6 @@ UNMO3_Free(stream); } } -#ifdef _WIN32 - FreeLibrary(unmo3); -#else - dlclose(unmo3); -#endif // _WIN32 } return result; #endif // NO_MO3 Modified: trunk/OpenMPT/soundlib/SampleFormats.cpp =================================================================== --- trunk/OpenMPT/soundlib/SampleFormats.cpp 2014-03-10 19:17:18 UTC (rev 3859) +++ trunk/OpenMPT/soundlib/SampleFormats.cpp 2014-03-10 19:23:36 UTC (rev 3860) @@ -12,7 +12,6 @@ #include "stdafx.h" #include "Sndfile.h" #ifdef MODPLUG_TRACKER -#include "../mptrack/Mptrack.h" #include "../mptrack/Moddoc.h" #include "../mptrack/TrackerSettings.h" #endif //MODPLUG_TRACKER @@ -2294,7 +2293,6 @@ //------------------------------------------------------------------ { #ifndef NO_MP3_SAMPLES - static HMODULE mp3lib = nullptr; // Check file for validity, or else mpg123 will happily munch many files that start looking vaguely resemble an MPEG stream mid-file. file.Rewind(); @@ -2340,17 +2338,16 @@ } } -#ifdef MODPLUG_TRACKER - if(!mp3lib) mp3lib = LoadLibraryW((theApp.GetAppDirPath() + MPT_PATHSTRING("libmpg123-0.dll")).AsNative().c_str()); - if(!mp3lib) mp3lib = LoadLibraryW((theApp.GetAppDirPath() + MPT_PATHSTRING("libmpg123.dll")).AsNative().c_str()); -#else - if(!mp3lib) mp3lib = LoadLibraryW(MPT_PATHSTRING("libmpg123-0.dll").AsNative().c_str()); - if(!mp3lib) mp3lib = LoadLibraryW(MPT_PATHSTRING("libmpg123.dll").AsNative().c_str()); -#endif // MODPLUG_TRACKER - if(!mp3lib) return false; + mpt::Library mp3lib; - #define MP3_DYNAMICBIND(f) mpg123::pfn_ ## f mpg123_ ## f = (mpg123::pfn_ ## f)GetProcAddress(mp3lib, "mpg123_" #f); if(!mpg123_ ## f) return false + if(!mp3lib.IsValid()) mp3lib = mpt::Library(mpt::LibraryPath::AppFullName(MPT_PATHSTRING("libmpg123-0"))); + if(!mp3lib.IsValid()) mp3lib = mpt::Library(mpt::LibraryPath::AppFullName(MPT_PATHSTRING("libmpg123"))); + if(!mp3lib.IsValid()) mp3lib = mpt::Library(mpt::LibraryPath::AppFullName(MPT_PATHSTRING("mpg123-0"))); + if(!mp3lib.IsValid()) mp3lib = mpt::Library(mpt::LibraryPath::AppFullName(MPT_PATHSTRING("mpg123"))); + if(!mp3lib.IsValid()) return false; + #define MP3_DYNAMICBIND(f) mpg123::pfn_ ## f mpg123_ ## f = nullptr; if(!mp3lib.Bind( mpg123_ ## f , "mpg123_" #f )) return false + MP3_DYNAMICBIND(init); MP3_DYNAMICBIND(new); MP3_DYNAMICBIND(delete); This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <man...@us...> - 2014-03-10 22:32:52
|
Revision: 3863 http://sourceforge.net/p/modplug/code/3863 Author: manxorist Date: 2014-03-10 22:32:44 +0000 (Mon, 10 Mar 2014) Log Message: ----------- [Fix] VS2008 compile fixes. Modified Paths: -------------- trunk/OpenMPT/common/misc_util.cpp trunk/OpenMPT/sounddev/SoundDeviceThread.cpp Modified: trunk/OpenMPT/common/misc_util.cpp =================================================================== --- trunk/OpenMPT/common/misc_util.cpp 2014-03-10 20:16:35 UTC (rev 3862) +++ trunk/OpenMPT/common/misc_util.cpp 2014-03-10 22:32:44 UTC (rev 3863) @@ -724,7 +724,6 @@ Library::Library() //---------------- - : m_Handle(nullptr) { return; } @@ -732,7 +731,6 @@ Library::Library(const mpt::LibraryPath &path) //-------------------------------------------- - : m_Handle(nullptr) { m_Handle = MPT_SHARED_PTR<LibraryHandle>(new LibraryHandle(path)); } Modified: trunk/OpenMPT/sounddev/SoundDeviceThread.cpp =================================================================== --- trunk/OpenMPT/sounddev/SoundDeviceThread.cpp 2014-03-10 20:16:35 UTC (rev 3862) +++ trunk/OpenMPT/sounddev/SoundDeviceThread.cpp 2014-03-10 22:32:44 UTC (rev 3863) @@ -29,15 +29,15 @@ pCreateWaitableTimer = nullptr; pSetWaitableTimer = nullptr; pCancelWaitableTimer = nullptr; - m_Kernel32DLL = mpt::Library(mpt::LibraryPath::System(MPT_PATHSTRING("kernel32"))); #if _WIN32_WINNT >= _WIN32_WINNT_WINXP m_HasXP = true; pCreateWaitableTimer = &CreateWaitableTimer; pSetWaitableTimer = &SetWaitableTimer; pCancelWaitableTimer = &CancelWaitableTimer; #else - if(m_HasXP && m_hKernel32DLL) + if(m_HasXP) { + m_Kernel32DLL = mpt::Library(mpt::LibraryPath::System(MPT_PATHSTRING("kernel32"))); if(!m_Kernel32DLL.Bind(pCreateWaitableTimer, "CreateWaitableTimerA")) { m_HasXP = false; This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <sag...@us...> - 2014-03-11 17:52:11
|
Revision: 3871 http://sourceforge.net/p/modplug/code/3871 Author: saga-games Date: 2014-03-11 17:52:03 +0000 (Tue, 11 Mar 2014) Log Message: ----------- [Reg] Remove simple noise reduction DSP. Noone is going to miss this. [Mod] OpenMPT: Version is now 1.22.07.29 Modified Paths: -------------- trunk/OpenMPT/common/BuildSettings.h trunk/OpenMPT/common/versionNumber.h trunk/OpenMPT/mptrack/Mpdlgs.cpp trunk/OpenMPT/mptrack/mptrack.rc trunk/OpenMPT/sounddsp/DSP.cpp trunk/OpenMPT/sounddsp/DSP.h trunk/OpenMPT/soundlib/Snd_defs.h trunk/OpenMPT/soundlib/Sndmix.cpp Modified: trunk/OpenMPT/common/BuildSettings.h =================================================================== --- trunk/OpenMPT/common/BuildSettings.h 2014-03-11 17:16:55 UTC (rev 3870) +++ trunk/OpenMPT/common/BuildSettings.h 2014-03-11 17:52:03 UTC (rev 3871) @@ -108,7 +108,7 @@ // Disable the built-in reverb effect //#define NO_REVERB -// Disable built-in miscellaneous DSP effects (surround, mega bass, noise reduction) +// Disable built-in miscellaneous DSP effects (surround, mega bass) //#define NO_DSP // Disable the built-in equalizer. Modified: trunk/OpenMPT/common/versionNumber.h =================================================================== --- trunk/OpenMPT/common/versionNumber.h 2014-03-11 17:16:55 UTC (rev 3870) +++ trunk/OpenMPT/common/versionNumber.h 2014-03-11 17:52:03 UTC (rev 3871) @@ -17,7 +17,7 @@ #define VER_MAJORMAJOR 1 #define VER_MAJOR 22 #define VER_MINOR 07 -#define VER_MINORMINOR 28 +#define VER_MINORMINOR 29 //Version string. For example "1.17.02.28" #define MPT_VERSION_STR VER_STRINGIZE(VER_MAJORMAJOR) "." VER_STRINGIZE(VER_MAJOR) "." VER_STRINGIZE(VER_MINOR) "." VER_STRINGIZE(VER_MINORMINOR) Modified: trunk/OpenMPT/mptrack/Mpdlgs.cpp =================================================================== --- trunk/OpenMPT/mptrack/Mpdlgs.cpp 2014-03-11 17:16:55 UTC (rev 3870) +++ trunk/OpenMPT/mptrack/Mpdlgs.cpp 2014-03-11 17:52:03 UTC (rev 3871) @@ -1140,7 +1140,6 @@ ON_COMMAND(IDC_CHECK2, OnSettingsChanged) ON_COMMAND(IDC_CHECK3, OnSettingsChanged) ON_COMMAND(IDC_CHECK4, OnSettingsChanged) - ON_COMMAND(IDC_CHECK5, OnSettingsChanged) ON_COMMAND(IDC_CHECK6, OnSettingsChanged) ON_COMMAND(IDC_CHECK7, OnSettingsChanged) END_MESSAGE_MAP() @@ -1189,7 +1188,6 @@ #endif #ifndef NO_DSP if (dwQuality & SNDDSP_SURROUND) CheckDlgButton(IDC_CHECK4, MF_CHECKED); - if (dwQuality & SNDDSP_NOISEREDUCTION) CheckDlgButton(IDC_CHECK5, MF_CHECKED); #else GetDlgItem(IDC_CHECK4)->ShowWindow(SW_HIDE); GetDlgItem(IDC_CHECK5)->ShowWindow(SW_HIDE); @@ -1320,9 +1318,7 @@ #endif #ifndef NO_DSP dwQualityMask |= SNDDSP_SURROUND; - dwQualityMask |= SNDDSP_NOISEREDUCTION; if (IsDlgButtonChecked(IDC_CHECK4)) dwQuality |= SNDDSP_SURROUND; - if (IsDlgButtonChecked(IDC_CHECK5)) dwQuality |= SNDDSP_NOISEREDUCTION; #endif #ifndef NO_REVERB dwQualityMask |= SNDDSP_REVERB; Modified: trunk/OpenMPT/mptrack/mptrack.rc =================================================================== --- trunk/OpenMPT/mptrack/mptrack.rc 2014-03-11 17:16:55 UTC (rev 3870) +++ trunk/OpenMPT/mptrack/mptrack.rc 2014-03-11 17:52:03 UTC (rev 3871) @@ -499,7 +499,6 @@ LTEXT "EQ Warning Message",IDC_EQ_WARNING,12,114,264,36,0,WS_EX_TRANSPARENT GROUPBOX "",IDC_STATIC,6,156,276,120 CONTROL "Automatic Gain Control",IDC_CHECK2,"Button",BS_AUTOCHECKBOX | WS_TABSTOP,15,164,97,10 - CONTROL "Noise reduction",IDC_CHECK5,"Button",BS_AUTOCHECKBOX | WS_TABSTOP,132,164,82,10 CONTROL "Bass Expansion",IDC_CHECK1,"Button",BS_AUTOCHECKBOX | WS_TABSTOP,15,178,81,10 CONTROL "Slider1",IDC_SLIDER1,"msctls_trackbar32",TBS_BOTH | TBS_NOTICKS | WS_TABSTOP,33,191,62,15 LTEXT "Low",IDC_STATIC,17,193,14,8 Modified: trunk/OpenMPT/sounddsp/DSP.cpp =================================================================== --- trunk/OpenMPT/sounddsp/DSP.cpp 2014-03-11 17:16:55 UTC (rev 3870) +++ trunk/OpenMPT/sounddsp/DSP.cpp 2014-03-11 17:52:03 UTC (rev 3871) @@ -52,14 +52,14 @@ float gainFT2, gainDC2, gainPI2; float alpha, beta0, beta1, rho; float wT, quad; - + _asm { // wT = PI*Fc/Fs fild F_c fldpi fmulp ST(1), ST(0) fild F_s - fdivp ST(1), ST(0) + fdivp ST(1), ST(0) fstp wT // gain^2 fld gainDC @@ -76,19 +76,19 @@ quad = gainPI2 + gainDC2 - (gainFT2*2); alpha = 0; - + if (quad != 0) { float lambda = (gainPI2 - gainDC2) / quad; alpha = (float)(lambda - Sgn(lambda)*sqrt(lambda*lambda - 1.0f)); } - + beta0 = 0.5f * ((gainDC + gainPI) + (gainDC - gainPI) * alpha); beta1 = 0.5f * ((gainDC - gainPI) + (gainDC + gainPI) * alpha); rho = (float)((sin((wT*0.5f) - (PI/4.0f))) / (sin((wT*0.5f) + (PI/4.0f)))); - + quad = 1.0f / (1.0f + rho*alpha); - + b0 = ((beta0 + rho*beta1) * quad); b1 = ((beta1 + rho*beta0) * quad); a1 = - ((rho + alpha) * quad); @@ -121,10 +121,6 @@ CDSP::CDSP() { - // Noise Reduction: simple low-pass filter - nLeftNR = 0; - nRightNR = 0; - // Surround Encoding: 1 delay line + low-pass filter + high-pass filter nSurroundSize = 0; nSurroundPos = 0; @@ -162,11 +158,7 @@ //----------------------------------------------------------------- { if (!m_Settings.m_nProLogicDelay) m_Settings.m_nProLogicDelay = 20; - if (bReset) - { - // Noise Reduction - nLeftNR = nRightNR = 0; - } + // Pro-Logic Surround nSurroundPos = nSurroundSize = 0; if (DSPMask & SNDDSP_SURROUND) @@ -317,26 +309,8 @@ nXBassFlt_X1 = x1; nXBassFlt_Y1 = y1; } - // Noise Reduction - if (DSPMask & SNDDSP_NOISEREDUCTION) - { - int n1 = nLeftNR, n2 = nRightNR; - int *pnr = MixSoundBuffer; - for (int nr=count; nr; nr--) - { - int vnr = pnr[0] >> 1; - pnr[0] = vnr + n1; - n1 = vnr; - vnr = pnr[1] >> 1; - pnr[1] = vnr + n2; - n2 = vnr; - pnr += 2; - } - nLeftNR = n1; - nRightNR = n2; - } - + } else { @@ -361,19 +335,6 @@ nXBassFlt_X1 = x1; nXBassFlt_Y1 = y1; } - // Noise Reduction - if (DSPMask & SNDDSP_NOISEREDUCTION) - { - int n = nLeftNR; - int *pnr = MixSoundBuffer; - for (int nr=count; nr; pnr++, nr--) - { - int vnr = *pnr >> 1; - *pnr = vnr + n; - n = vnr; - } - nLeftNR = n; - } } @@ -507,4 +468,3 @@ #endif // NO_DSP - Modified: trunk/OpenMPT/sounddsp/DSP.h =================================================================== --- trunk/OpenMPT/sounddsp/DSP.h 2014-03-11 17:16:55 UTC (rev 3870) +++ trunk/OpenMPT/sounddsp/DSP.h 2014-03-11 17:52:03 UTC (rev 3871) @@ -40,15 +40,11 @@ CDSPSettings m_Settings; private: - // Noise Reduction: simple low-pass filter - LONG nLeftNR; - LONG nRightNR; - // Surround Encoding: 1 delay line + low-pass filter + high-pass filter LONG nSurroundSize; LONG nSurroundPos; LONG nDolbyDepth; - + // Surround Biquads LONG nDolbyHP_Y1; LONG nDolbyHP_X1; @@ -90,4 +86,4 @@ void ProcessQuadSurround(int * MixSoundBuffer, int * MixRearBuffer, int count); }; -#endif // NO_DSP +#endif // NO_DSP \ No newline at end of file Modified: trunk/OpenMPT/soundlib/Snd_defs.h =================================================================== --- trunk/OpenMPT/soundlib/Snd_defs.h 2014-03-11 17:16:55 UTC (rev 3870) +++ trunk/OpenMPT/soundlib/Snd_defs.h 2014-03-11 17:52:03 UTC (rev 3871) @@ -288,9 +288,6 @@ #define SONG_PLAY_FLAGS (~SONG_FILE_FLAGS) // Global Options (Renderer) -#ifndef NO_DSP -#define SNDDSP_NOISEREDUCTION 0x01 // reduce hiss (do not use, it's just a simple low-pass filter) -#endif // NO_DSP #ifndef NO_AGC #define SNDDSP_AGC 0x40 // automatic gain control #endif // ~NO_AGC Modified: trunk/OpenMPT/soundlib/Sndmix.cpp =================================================================== --- trunk/OpenMPT/soundlib/Sndmix.cpp 2014-03-11 17:16:55 UTC (rev 3870) +++ trunk/OpenMPT/soundlib/Sndmix.cpp 2014-03-11 17:52:03 UTC (rev 3871) @@ -286,7 +286,7 @@ //------------------------------------------------- { #ifndef NO_DSP - if(m_MixerSettings.DSPMask & (SNDDSP_SURROUND|SNDDSP_MEGABASS|SNDDSP_NOISEREDUCTION)) + if(m_MixerSettings.DSPMask & (SNDDSP_SURROUND|SNDDSP_MEGABASS)) { m_DSP.Process(MixSoundBuffer, MixRearBuffer, countChunk, m_MixerSettings.gnChannels, m_MixerSettings.DSPMask); } This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <man...@us...> - 2014-03-14 12:55:47
|
Revision: 3882 http://sourceforge.net/p/modplug/code/3882 Author: manxorist Date: 2014-03-14 12:55:35 +0000 (Fri, 14 Mar 2014) Log Message: ----------- [Fix] sounddev: Do not support "keep device open" for non-ASIO devices because they currently do not clear the remaining output buffer when stopping. [Mod] sounddev: Merge "keep device open" and "keep runnig" GUI options. Internally, keep the "keep runnig" option device-specific because the implementation is device-specific. [Mod] OpenMPT: Version is now 1.22.07.30 Modified Paths: -------------- trunk/OpenMPT/common/versionNumber.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/mptrack/resource.h trunk/OpenMPT/sounddev/SoundDevice.h trunk/OpenMPT/sounddev/SoundDeviceASIO.h Modified: trunk/OpenMPT/common/versionNumber.h =================================================================== --- trunk/OpenMPT/common/versionNumber.h 2014-03-14 11:22:52 UTC (rev 3881) +++ trunk/OpenMPT/common/versionNumber.h 2014-03-14 12:55:35 UTC (rev 3882) @@ -17,7 +17,7 @@ #define VER_MAJORMAJOR 1 #define VER_MAJOR 22 #define VER_MINOR 07 -#define VER_MINORMINOR 29 +#define VER_MINORMINOR 30 //Version string. For example "1.17.02.28" #define MPT_VERSION_STR VER_STRINGIZE(VER_MAJORMAJOR) "." VER_STRINGIZE(VER_MAJOR) "." VER_STRINGIZE(VER_MINOR) "." VER_STRINGIZE(VER_MINORMINOR) Modified: trunk/OpenMPT/mptrack/MainFrm.cpp =================================================================== --- trunk/OpenMPT/mptrack/MainFrm.cpp 2014-03-14 11:22:52 UTC (rev 3881) +++ trunk/OpenMPT/mptrack/MainFrm.cpp 2014-03-14 12:55:35 UTC (rev 3882) @@ -1215,7 +1215,7 @@ m_NotifyTimer = 0; } ResetNotificationBuffer(); - if(!TrackerSettings::Instance().m_SoundSettingsKeepDeviceOpen) + if(!gpSoundDevice->CanStopMode() || TrackerSettings::Instance().m_SoundSettingsStopMode == SoundDeviceStopModeClosed) { audioCloseDevice(); } @@ -1656,14 +1656,18 @@ BOOL CMainFrame::ResetSoundCard() //------------------------------- { - return CMainFrame::SetupSoundCard(TrackerSettings::Instance().GetSoundDeviceSettings(TrackerSettings::Instance().GetSoundDeviceID()), TrackerSettings::Instance().GetSoundDeviceID(), true); + return CMainFrame::SetupSoundCard(TrackerSettings::Instance().GetSoundDeviceSettings(TrackerSettings::Instance().GetSoundDeviceID()), TrackerSettings::Instance().GetSoundDeviceID(), TrackerSettings::Instance().m_SoundSettingsStopMode, true); } -BOOL CMainFrame::SetupSoundCard(const SoundDeviceSettings &deviceSettings, SoundDeviceID deviceID, bool forceReset) -//----------------------------------------------------------------------------------------------------------------- +BOOL CMainFrame::SetupSoundCard(SoundDeviceSettings deviceSettings, SoundDeviceID deviceID, SoundDeviceStopMode stoppedMode, bool forceReset) +//------------------------------------------------------------------------------------------------------------------------------------------- { - if(forceReset || (TrackerSettings::Instance().GetSoundDeviceID() != deviceID) || (TrackerSettings::Instance().GetSoundDeviceSettings(deviceID) != deviceSettings)) + if(forceReset + || (TrackerSettings::Instance().GetSoundDeviceID() != deviceID) + || (TrackerSettings::Instance().GetSoundDeviceSettings(deviceID) != deviceSettings) + || (TrackerSettings::Instance().m_SoundSettingsStopMode != stoppedMode) + ) { CModDoc *pActiveMod = nullptr; if(IsPlaying()) @@ -1675,6 +1679,19 @@ { gpSoundDevice->Close(); } + TrackerSettings::Instance().m_SoundSettingsStopMode = stoppedMode; + switch(stoppedMode) + { + case SoundDeviceStopModeClosed: + deviceSettings.KeepDeviceRunning = true; + break; + case SoundDeviceStopModeStopped: + deviceSettings.KeepDeviceRunning = false; + break; + case SoundDeviceStopModePlaying: + deviceSettings.KeepDeviceRunning = true; + break; + } TrackerSettings::Instance().SetSoundDeviceID(deviceID); TrackerSettings::Instance().SetSoundDeviceSettings(deviceID, deviceSettings); TrackerSettings::Instance().MixerOutputChannels = deviceSettings.Channels; Modified: trunk/OpenMPT/mptrack/Mainfrm.h =================================================================== --- trunk/OpenMPT/mptrack/Mainfrm.h 2014-03-14 11:22:52 UTC (rev 3881) +++ trunk/OpenMPT/mptrack/Mainfrm.h 2014-03-14 12:55:35 UTC (rev 3882) @@ -468,7 +468,7 @@ void IdleHandlerSounddevice(); BOOL ResetSoundCard(); - BOOL SetupSoundCard(const SoundDeviceSettings &deviceSettings, SoundDeviceID deviceID, bool forceReset = false); + BOOL SetupSoundCard(SoundDeviceSettings deviceSettings, SoundDeviceID deviceID, SoundDeviceStopMode stoppedMode, bool forceReset = false); BOOL SetupMiscOptions(); BOOL SetupPlayer(); Modified: trunk/OpenMPT/mptrack/Mpdlgs.cpp =================================================================== --- trunk/OpenMPT/mptrack/Mpdlgs.cpp 2014-03-14 11:22:52 UTC (rev 3881) +++ trunk/OpenMPT/mptrack/Mpdlgs.cpp 2014-03-14 12:55:35 UTC (rev 3882) @@ -61,9 +61,7 @@ ON_WM_VSCROLL() ON_COMMAND(IDC_CHECK4, OnSettingsChanged) ON_COMMAND(IDC_CHECK5, OnSettingsChanged) - ON_COMMAND(IDC_CHECK6, OnSettingsChanged) ON_COMMAND(IDC_CHECK7, OnSettingsChanged) - ON_COMMAND(IDC_CHECK8, OnSettingsChanged) ON_COMMAND(IDC_CHECK9, OnSettingsChanged) ON_CBN_SELCHANGE(IDC_COMBO1, OnDeviceChanged) ON_CBN_SELCHANGE(IDC_COMBO2, OnSettingsChanged) @@ -75,6 +73,7 @@ ON_CBN_SELCHANGE(IDC_COMBO10, OnSettingsChanged) ON_CBN_EDITCHANGE(IDC_COMBO2, OnSettingsChanged) ON_CBN_EDITCHANGE(IDC_COMBO_UPDATEINTERVAL, OnSettingsChanged) + ON_CBN_SELCHANGE(IDC_COMBO11, OnSettingsChanged) ON_COMMAND(IDC_BUTTON1, OnSoundCardRescan) ON_COMMAND(IDC_BUTTON2, OnSoundCardDriverPanel) ON_CBN_SELCHANGE(IDC_COMBO_CHANNEL_FRONTLEFT, OnChannel1Changed) @@ -106,6 +105,7 @@ DDX_Control(pDX, IDC_COMBO10, m_CbnDither); DDX_Control(pDX, IDC_BUTTON2, m_BtnDriverPanel); DDX_Control(pDX, IDC_COMBO6, m_CbnSampleFormat); + DDX_Control(pDX, IDC_COMBO11, m_CbnStoppedMode); DDX_Control(pDX, IDC_STATIC_CHANNEL_FRONTLEFT , m_StaticChannelMapping[0]); DDX_Control(pDX, IDC_STATIC_CHANNEL_FRONTRIGHT, m_StaticChannelMapping[1]); DDX_Control(pDX, IDC_STATIC_CHANNEL_REARLEFT , m_StaticChannelMapping[2]); @@ -217,15 +217,36 @@ } -void COptionsSoundcard::UpdateEverything() -//---------------------------------------- +void COptionsSoundcard::UpdateGeneral() +//------------------------------------- { // General { - CheckDlgButton(IDC_CHECK6, TrackerSettings::Instance().m_SoundSettingsKeepDeviceOpen ? BST_CHECKED : BST_UNCHECKED); + if(m_CurrentDeviceCaps.CanKeepDeviceRunning) + { + m_CbnStoppedMode.EnableWindow(TRUE); + m_CbnStoppedMode.ResetContent(); + m_CbnStoppedMode.AddString("Close driver"); + m_CbnStoppedMode.AddString("Pause driver"); + m_CbnStoppedMode.AddString("Play silence"); + m_CbnStoppedMode.SetCurSel(TrackerSettings::Instance().m_SoundSettingsStopMode); + } else + { + m_CbnStoppedMode.EnableWindow(FALSE); + m_CbnStoppedMode.ResetContent(); + m_CbnStoppedMode.AddString("Close driver"); + m_CbnStoppedMode.AddString("Close driver"); + m_CbnStoppedMode.AddString("Close driver"); + m_CbnStoppedMode.SetCurSel(TrackerSettings::Instance().m_SoundSettingsStopMode); + } CheckDlgButton(IDC_CHECK7, TrackerSettings::Instance().m_SoundSettingsOpenDeviceAtStartup ? BST_CHECKED : BST_UNCHECKED); } +} + +void COptionsSoundcard::UpdateEverything() +//---------------------------------------- +{ // Sound Device { m_CbnDevice.ResetContent(); @@ -311,6 +332,7 @@ void COptionsSoundcard::UpdateDevice() //------------------------------------ { + UpdateGeneral(); UpdateControls(); UpdateLatency(); UpdateUpdateInterval(); @@ -571,14 +593,12 @@ m_BtnDriverPanel.EnableWindow(m_CurrentDeviceCaps.CanDriverPanel ? TRUE : FALSE); GetDlgItem(IDC_CHECK4)->EnableWindow(m_CurrentDeviceCaps.CanExclusiveMode ? TRUE : FALSE); GetDlgItem(IDC_CHECK5)->EnableWindow(m_CurrentDeviceCaps.CanBoostThreadPriority ? TRUE : FALSE); - GetDlgItem(IDC_CHECK8)->EnableWindow(m_CurrentDeviceCaps.CanKeepDeviceRunning ? TRUE : FALSE); GetDlgItem(IDC_CHECK9)->EnableWindow(m_CurrentDeviceCaps.CanUseHardwareTiming ? TRUE : FALSE); GetDlgItem(IDC_STATIC_UPDATEINTERVAL)->EnableWindow(m_CurrentDeviceCaps.CanUpdateInterval ? TRUE : FALSE); GetDlgItem(IDC_COMBO_UPDATEINTERVAL)->EnableWindow(m_CurrentDeviceCaps.CanUpdateInterval ? TRUE : FALSE); GetDlgItem(IDC_CHECK4)->SetWindowText(mpt::ToCString(m_CurrentDeviceCaps.ExclusiveModeDescription)); CheckDlgButton(IDC_CHECK4, m_CurrentDeviceCaps.CanExclusiveMode && m_Settings.ExclusiveMode ? MF_CHECKED : MF_UNCHECKED); CheckDlgButton(IDC_CHECK5, m_CurrentDeviceCaps.CanBoostThreadPriority && m_Settings.BoostThreadPriority ? MF_CHECKED : MF_UNCHECKED); - CheckDlgButton(IDC_CHECK8, m_CurrentDeviceCaps.CanKeepDeviceRunning && m_Settings.KeepDeviceRunning ? MF_CHECKED : MF_UNCHECKED); CheckDlgButton(IDC_CHECK9, m_CurrentDeviceCaps.CanUseHardwareTiming && m_Settings.UseHardwareTiming ? MF_CHECKED : MF_UNCHECKED); } @@ -596,12 +616,10 @@ { // General { - TrackerSettings::Instance().m_SoundSettingsKeepDeviceOpen = IsDlgButtonChecked(IDC_CHECK6) ? true : false; TrackerSettings::Instance().m_SoundSettingsOpenDeviceAtStartup = IsDlgButtonChecked(IDC_CHECK7) ? true : false; } m_Settings.ExclusiveMode = IsDlgButtonChecked(IDC_CHECK4) ? true : false; m_Settings.BoostThreadPriority = IsDlgButtonChecked(IDC_CHECK5) ? true : false; - m_Settings.KeepDeviceRunning = IsDlgButtonChecked(IDC_CHECK8) ? true : false; m_Settings.UseHardwareTiming = IsDlgButtonChecked(IDC_CHECK9) ? true : false; // Mixing Freq { @@ -664,7 +682,7 @@ m_Settings.ChannelMapping = SoundChannelMapping(); } } - CMainFrame::GetMainFrame()->SetupSoundCard(m_Settings, m_CurrentDeviceInfo.id); + CMainFrame::GetMainFrame()->SetupSoundCard(m_Settings, m_CurrentDeviceInfo.id, (SoundDeviceStopMode)m_CbnStoppedMode.GetCurSel()); SetDevice(m_CurrentDeviceInfo.id, true); // Poll changed ASIO sample format and channel names UpdateDevice(); UpdateStatistics(); Modified: trunk/OpenMPT/mptrack/Mpdlgs.h =================================================================== --- trunk/OpenMPT/mptrack/Mpdlgs.h 2014-03-14 11:22:52 UTC (rev 3881) +++ trunk/OpenMPT/mptrack/Mpdlgs.h 2014-03-14 12:55:35 UTC (rev 3882) @@ -25,6 +25,8 @@ CEdit m_EditStatistics; CButton m_BtnDriverPanel; + CComboBox m_CbnStoppedMode; + CStatic m_StaticChannelMapping[NUM_CHANNELCOMBOBOXES]; CComboBox m_CbnChannelMapping[NUM_CHANNELCOMBOBOXES]; @@ -41,6 +43,7 @@ private: void UpdateEverything(); void UpdateDevice(); + void UpdateGeneral(); void UpdateLatency(); void UpdateUpdateInterval(); void UpdateSampleRates(); Modified: trunk/OpenMPT/mptrack/TrackerSettings.cpp =================================================================== --- trunk/OpenMPT/mptrack/TrackerSettings.cpp 2014-03-14 11:22:52 UTC (rev 3881) +++ trunk/OpenMPT/mptrack/TrackerSettings.cpp 2014-03-14 12:55:35 UTC (rev 3882) @@ -164,7 +164,7 @@ , m_SoundSampleRates(conf, "Sound Settings", "SampleRates", GetDefaultSampleRates()) , m_MorePortaudio(conf, "Sound Settings", "MorePortaudio", false) , m_SoundSettingsOpenDeviceAtStartup(conf, "Sound Settings", "OpenDeviceAtStartup", false) - , m_SoundSettingsKeepDeviceOpen(conf, "Sound Settings", "KeepDeviceOpen", false) + , m_SoundSettingsStopMode(conf, "Sound Settings", "StopMode", SoundDeviceStopModeClosed) , m_SoundDeviceSettingsUseOldDefaults(false) , m_SoundDeviceIdentifier(conf, "Sound Settings", "Device", std::wstring()) , MixerMaxChannels(conf, "Sound Settings", "MixChannels", MixerSettings().m_nMaxMixChannels) @@ -376,6 +376,16 @@ } // Sound Settings + if(storedVersion < MAKE_VERSION_NUMERIC(1,22,07,30)) + { + if(conf.Read<bool>("Sound Settings", "KeepDeviceOpen", false)) + { + m_SoundSettingsStopMode = SoundDeviceStopModePlaying; + } else + { + m_SoundSettingsStopMode = SoundDeviceStopModeStopped; + } + } if(storedVersion < MAKE_VERSION_NUMERIC(1,22,07,04)) { std::vector<uint32> sampleRates = m_SoundSampleRates; Modified: trunk/OpenMPT/mptrack/TrackerSettings.h =================================================================== --- trunk/OpenMPT/mptrack/TrackerSettings.h 2014-03-14 11:22:52 UTC (rev 3881) +++ trunk/OpenMPT/mptrack/TrackerSettings.h 2014-03-14 12:55:35 UTC (rev 3882) @@ -303,7 +303,16 @@ return dfFLAC; } +template<> inline SettingValue ToSettingValue(const SoundDeviceStopMode &val) +{ + return SettingValue(static_cast<int32>(val)); +} +template<> inline SoundDeviceStopMode FromSettingValue(const SettingValue &val) +{ + return static_cast<SoundDeviceStopMode>(static_cast<int32>(val)); +} + //=================== class TrackerSettings //=================== @@ -357,7 +366,7 @@ Setting<std::vector<uint32> > m_SoundSampleRates; Setting<bool> m_MorePortaudio; Setting<bool> m_SoundSettingsOpenDeviceAtStartup; - Setting<bool> m_SoundSettingsKeepDeviceOpen; + Setting<SoundDeviceStopMode> m_SoundSettingsStopMode; bool m_SoundDeviceSettingsUseOldDefaults; SoundDeviceID m_SoundDeviceID_DEPRECATED; Modified: trunk/OpenMPT/mptrack/mptrack.rc =================================================================== --- trunk/OpenMPT/mptrack/mptrack.rc 2014-03-14 11:22:52 UTC (rev 3881) +++ trunk/OpenMPT/mptrack/mptrack.rc 2014-03-14 12:55:35 UTC (rev 3882) @@ -1306,10 +1306,9 @@ COMBOBOX IDC_COMBO5,108,90,42,80,CBS_DROPDOWNLIST | WS_VSCROLL | WS_TABSTOP COMBOBOX IDC_COMBO6,156,90,42,80,CBS_DROPDOWNLIST | WS_VSCROLL | WS_TABSTOP COMBOBOX IDC_COMBO10,204,90,72,80,CBS_DROPDOWNLIST | WS_VSCROLL | WS_TABSTOP - CONTROL "Use device exclusively",IDC_CHECK4,"Button",BS_AUTOCHECKBOX | WS_TABSTOP,108,54,90,12 - CONTROL "Keep running",IDC_CHECK8,"Button",BS_AUTOCHECKBOX | WS_TABSTOP,204,54,66,12 - CONTROL "&Boost thread priority",IDC_CHECK5,"Button",BS_AUTOCHECKBOX | WS_TABSTOP,108,72,90,12 - CONTROL "Hardware timing",IDC_CHECK9,"Button",BS_AUTOCHECKBOX | WS_TABSTOP,204,72,66,12 + CONTROL "Use device exclusively",IDC_CHECK4,"Button",BS_AUTOCHECKBOX | WS_TABSTOP,108,54,84,12 + CONTROL "&Boost thread priority",IDC_CHECK5,"Button",BS_AUTOCHECKBOX | WS_TABSTOP,108,72,84,12 + CONTROL "Hardware timing",IDC_CHECK9,"Button",BS_AUTOCHECKBOX | WS_TABSTOP,198,72,66,12 LTEXT "Channel &Mapping:",IDC_STATIC,12,108,60,12,SS_CENTERIMAGE CTEXT "Front Left",IDC_STATIC_CHANNEL_FRONTLEFT,78,108,48,12,SS_CENTERIMAGE,WS_EX_STATICEDGE COMBOBOX IDC_COMBO_CHANNEL_FRONTLEFT,132,108,144,72,CBS_DROPDOWNLIST | WS_VSCROLL | WS_TABSTOP @@ -1320,11 +1319,11 @@ CTEXT "Rear Right",IDC_STATIC_CHANNEL_REARRIGHT,78,162,48,12,SS_CENTERIMAGE,WS_EX_STATICEDGE COMBOBOX IDC_COMBO_CHANNEL_REARRIGHT,132,162,144,72,CBS_DROPDOWNLIST | WS_VSCROLL | WS_TABSTOP GROUPBOX "General",IDC_STATIC,6,186,276,30 - CONTROL "Keep device &open when playback is stopped",IDC_CHECK6, - "Button",BS_AUTOCHECKBOX | WS_TABSTOP,12,198,156,12 - CONTROL "Open device at &startup",IDC_CHECK7,"Button",BS_AUTOCHECKBOX | WS_TABSTOP,180,198,90,12 + COMBOBOX IDC_COMBO11,108,198,60,80,CBS_DROPDOWNLIST | WS_VSCROLL | WS_TABSTOP + CONTROL "Open device at &startup",IDC_CHECK7,"Button",BS_AUTOCHECKBOX | WS_TABSTOP,186,198,90,12 GROUPBOX "Stat&istics",IDC_STATIC,6,222,276,55 EDITTEXT IDC_EDIT_STATISTICS,12,233,264,38,ES_MULTILINE | ES_AUTOHSCROLL | ES_READONLY | NOT WS_TABSTOP + LTEXT "When playback is &stoppped:",IDC_STATIC,12,198,90,12,SS_CENTERIMAGE END IDD_MIDIMACRO DIALOGEX 0, 0, 358, 354 Modified: trunk/OpenMPT/mptrack/resource.h =================================================================== --- trunk/OpenMPT/mptrack/resource.h 2014-03-14 11:22:52 UTC (rev 3881) +++ trunk/OpenMPT/mptrack/resource.h 2014-03-14 12:55:35 UTC (rev 3882) @@ -198,6 +198,7 @@ #define IDC_COMBO6 1206 #define IDC_COMBO9 1207 #define IDC_COMBO10 1208 +#define IDC_COMBO11 1209 #define IDC_NOTEMAP 1213 #define IDC_TEXT1 1301 #define IDC_TEXT2 1302 Modified: trunk/OpenMPT/sounddev/SoundDevice.h =================================================================== --- trunk/OpenMPT/sounddev/SoundDevice.h 2014-03-14 11:22:52 UTC (rev 3881) +++ trunk/OpenMPT/sounddev/SoundDevice.h 2014-03-14 12:55:35 UTC (rev 3882) @@ -232,6 +232,14 @@ }; +enum SoundDeviceStopMode +{ + SoundDeviceStopModeClosed = 0, + SoundDeviceStopModeStopped = 1, + SoundDeviceStopModePlaying = 2, +}; + + struct SoundDeviceSettings { HWND hWnd; @@ -458,6 +466,7 @@ std::wstring GetDeviceInternalID() const { return m_InternalID; } virtual SoundDeviceCaps GetDeviceCaps(const std::vector<uint32> &baseSampleRates); + virtual bool CanStopMode() const { return false; } bool Open(const SoundDeviceSettings &settings); bool Close(); Modified: trunk/OpenMPT/sounddev/SoundDeviceASIO.h =================================================================== --- trunk/OpenMPT/sounddev/SoundDeviceASIO.h 2014-03-14 11:22:52 UTC (rev 3881) +++ trunk/OpenMPT/sounddev/SoundDeviceASIO.h 2014-03-14 12:55:35 UTC (rev 3882) @@ -109,6 +109,7 @@ bool OnIdle() { return HandleRequests(); } SoundDeviceCaps GetDeviceCaps(const std::vector<uint32> &baseSampleRates); + bool CanStopMode() const { return true; } bool OpenDriverSettings(); This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <sag...@us...> - 2014-03-17 02:56:40
|
Revision: 3893 http://sourceforge.net/p/modplug/code/3893 Author: saga-games Date: 2014-03-17 02:56:32 +0000 (Mon, 17 Mar 2014) Log Message: ----------- [Imp] More plugin bridge improvements (SynthEdit plugs work, and time info caching) Modified Paths: -------------- trunk/OpenMPT/pluginBridge/AEffectWrapper.h trunk/OpenMPT/pluginBridge/Bridge.cpp trunk/OpenMPT/pluginBridge/Bridge.h trunk/OpenMPT/pluginBridge/BridgeCommon.h trunk/OpenMPT/pluginBridge/BridgeWrapper.cpp trunk/OpenMPT/plugins/MidiInOut/MidiInOut.vcxproj.filters trunk/OpenMPT/plugins/MidiInOut/MidiInOutEditor.cpp trunk/OpenMPT/plugins/common/CheckBox.h trunk/OpenMPT/plugins/common/ComboBox.h trunk/OpenMPT/plugins/common/Label.h trunk/OpenMPT/plugins/common/Window.h trunk/OpenMPT/plugins/common/WindowBase.h Modified: trunk/OpenMPT/pluginBridge/AEffectWrapper.h =================================================================== --- trunk/OpenMPT/pluginBridge/AEffectWrapper.h 2014-03-16 23:25:31 UTC (rev 3892) +++ trunk/OpenMPT/pluginBridge/AEffectWrapper.h 2014-03-17 02:56:32 UTC (rev 3893) @@ -129,16 +129,35 @@ // Translate bridge format (void *ptr) back to VSTEvents struct (placed in data vector) static void TranslateBridgeToVSTEvents(std::vector<char> &data, void *ptr) { - int32_t numEvents = *static_cast<const int32_t *>(ptr); + const int32_t numEvents = *static_cast<const int32_t *>(ptr); - data.resize(sizeof(VstInt32) + sizeof(VstIntPtr) + sizeof(VstEvent *) * numEvents, 0); - VstEvents *events = reinterpret_cast<VstEvents *>(&data[0]); - events->numEvents = numEvents; + const size_t headerSize = sizeof(VstInt32) + sizeof(VstIntPtr) + sizeof(VstEvent *) * numEvents; + data.reserve(headerSize + sizeof(VstEvent) * numEvents); + data.resize(headerSize, 0); - // Write pointers + // Copy over event data (this is required for dumb SynthEdit plugins that don't copy over the event data during effProcessEvents) char *offset = static_cast<char *>(ptr) + sizeof(int32_t); for(int32_t i = 0; i < numEvents; i++) { + VstEvent *event = reinterpret_cast<VstEvent *>(offset); + data.insert(data.end(), offset, offset + event->byteSize); + offset += event->byteSize; + + if(event->type == kVstSysExType) + { + // Copy over sysex dump + VstMidiSysexEvent *sysExEvent = reinterpret_cast<VstMidiSysexEvent *>(event); + data.insert(data.end(), offset, offset + sysExEvent->dumpBytes); + offset += sysExEvent->dumpBytes; + } + } + + // Write pointers + VstEvents *events = reinterpret_cast<VstEvents *>(&data[0]); + events->numEvents = numEvents; + offset = &data[headerSize]; + for(int32_t i = 0; i < numEvents; i++) + { events->events[i] = reinterpret_cast<VstEvent *>(offset); offset += events->events[i]->byteSize; if(events->events[i]->type == kVstSysExType) Modified: trunk/OpenMPT/pluginBridge/Bridge.cpp =================================================================== --- trunk/OpenMPT/pluginBridge/Bridge.cpp 2014-03-16 23:25:31 UTC (rev 3892) +++ trunk/OpenMPT/pluginBridge/Bridge.cpp 2014-03-17 02:56:32 UTC (rev 3893) @@ -15,6 +15,7 @@ // => sigThreadExit might already be an invalid handle the time it arrives in the thread // Fix deadlocks in some plugin GUIs (Synth1 sliders, triggering many notes through the M1 GUI, Electri-Q program change) // Ability to put all plugins (or all instances of the same plugin) in the same container. Necessary for plugins like SideKick v3. +// jBridged Rez3 GUI breaks // Low priority: // Speed up things like consecutive calls to CVstPlugin::GetFormattedProgramName by a custom opcode @@ -466,8 +467,9 @@ case effProcessEvents: // VstEvents* in [ptr] - TranslateBridgeToVSTEvents(extraData, ptr); - ptr = &extraData[0]; + TranslateBridgeToVSTEvents(eventCache, ptr); + ptr = &eventCache[0]; + break; case effOfflineNotify: @@ -710,16 +712,22 @@ { assert(sharedMem.processMem.Good()); ProcessMsg *msg = static_cast<ProcessMsg *>(sharedMem.processMem.view); + size_t numPtrs = msg->numInputs + msg->numOutputs; samplePointers.resize(numPtrs, 0); - buf_t *offset = reinterpret_cast<buf_t *>(msg + 1); - for(size_t i = 0; i < numPtrs; i++) + + if(numPtrs) { - samplePointers[i] = offset; - offset += msg->sampleFrames; + buf_t *offset = reinterpret_cast<buf_t *>(msg + 1); + for(size_t i = 0; i < numPtrs; i++) + { + samplePointers[i] = offset; + offset += msg->sampleFrames; + } + inPointers = reinterpret_cast<buf_t **>(&samplePointers[0]); + outPointers = reinterpret_cast<buf_t **>(&samplePointers[msg->numInputs]); } - inPointers = reinterpret_cast<buf_t **>(&samplePointers[0]); - outPointers = reinterpret_cast<buf_t **>(&samplePointers[msg->numInputs]); + return msg->sampleFrames; } @@ -727,6 +735,8 @@ // Send a message to the host. VstIntPtr PluginBridge::DispatchToHost(VstInt32 opcode, VstInt32 index, VstIntPtr value, void *ptr, float opt) { + const bool processing = InterlockedExchangeAdd(&isProcessing, 0) != 0; + std::vector<char> dispatchData(sizeof(DispatchMsg), 0); int64_t ptrOut = 0; char *ptrC = static_cast<char *>(ptr); @@ -742,6 +752,15 @@ case audioMasterGetTime: // VstTimeInfo* in [return value] + if(processing) + { + // During processing, read the cached time info if possible + VstTimeInfo &timeInfo = static_cast<ProcessMsg *>(sharedMem.processMem.view)->timeInfo; + if((timeInfo.flags & value) == value) + { + return reinterpret_cast<VstIntPtr>(&static_cast<ProcessMsg *>(sharedMem.processMem.view)->timeInfo); + } + } ptrOut = sizeof(VstTimeInfo); break; @@ -765,7 +784,7 @@ MPT_FALLTHROUGH; case audioMasterIOChanged: // We need to be sure that the new values are known to the master. - if(InterlockedExchangeAdd(&isProcessing, 0) == 0) + if(!processing) { UpdateEffectStruct(); CreateProcessingFile(dispatchData); @@ -906,8 +925,13 @@ { case audioMasterGetTime: // VstTimeInfo* in [return value] - memcpy(&host2PlugMem.timeInfo, extraData, sizeof(VstTimeInfo)); - return ToVstPtr<VstTimeInfo>(&host2PlugMem.timeInfo); + if(sharedMem.processMem.Good()) + { + VstTimeInfo *timeInfo = &static_cast<ProcessMsg *>(sharedMem.processMem.view)->timeInfo; + memcpy(timeInfo, extraData, sizeof(VstTimeInfo)); + return ToVstPtr<VstTimeInfo>(timeInfo); + } + return 0; case audioMasterGetOutputSpeakerArrangement: case audioMasterGetInputSpeakerArrangement: Modified: trunk/OpenMPT/pluginBridge/Bridge.h =================================================================== --- trunk/OpenMPT/pluginBridge/Bridge.h 2014-03-16 23:25:31 UTC (rev 3892) +++ trunk/OpenMPT/pluginBridge/Bridge.h 2014-03-17 02:56:32 UTC (rev 3893) @@ -29,9 +29,9 @@ union { VstSpeakerArrangement speakerArrangement; - VstTimeInfo timeInfo; char name[256]; } host2PlugMem; + std::vector<char> eventCache; // Cached VST (MIDI) events // Shared memory SharedMem sharedMem; Modified: trunk/OpenMPT/pluginBridge/BridgeCommon.h =================================================================== --- trunk/OpenMPT/pluginBridge/BridgeCommon.h 2014-03-16 23:25:31 UTC (rev 3892) +++ trunk/OpenMPT/pluginBridge/BridgeCommon.h 2014-03-17 02:56:32 UTC (rev 3893) @@ -167,6 +167,7 @@ int32_t numInputs; int32_t numOutputs; int32_t sampleFrames; + VstTimeInfo timeInfo; // Input and output buffers follow ProcessMsg(ProcessMsg::ProcessType processType, int32_t numInputs, int32_t numOutputs, int32_t sampleFrames) : @@ -196,10 +197,11 @@ // Message life-cycle enum BridgeMessageStatus { - empty = 0, - sent, - received, - done, + empty = 0, // Slot is usable + prepared, // Slot got acquired and is being prepared + sent, // Slot is ready to be sent + received, // Slot is being handled + done, // Slot got handled }; uint32_t status; // See BridgeMessageStatus @@ -361,11 +363,9 @@ class SharedMem { public: - //std::map<winhandle_t, SignalSlot *> threadMap; // Map thread IDs to signals - // Signals for host <-> bridge communication Signal sigToHost, sigToBridge, sigProcess; - // Signals for internal communication (wake up waiting threads). Ack() => OK, Send() => Failure + // Signals for internal communication (wake up waiting threads). Confirm() => OK, Send() => Failure Signal ackSignals[MsgQueue::queueSize]; HANDLE otherProcess; // Handle of "other" process (host handle in the bridge and vice versa) @@ -400,18 +400,22 @@ // Copy a message to shared memory and return relative position. BridgeMessage *CopyToSharedMemory(const BridgeMessage &msg, BridgeMessage *queue, bool fromMsgThread) { - assert((reinterpret_cast<intptr_t>(&writeOffset) & 3) == 0); // InterlockedExchangeAdd operand should be aligned to 32 bits - uint32_t offset = InterlockedExchangeAdd(&writeOffset, 1) % MsgQueue::queueSize; - assert(msg.header.status == MsgHeader::empty); - assert(queue[offset].header.status == MsgHeader::empty); - memcpy(queue + offset, &msg, std::min(sizeof(BridgeMessage), size_t(msg.header.size))); - - queue[offset].header.signalID = fromMsgThread ? uint32_t(-1) : offset; // Don't send signal to ourselves - - assert((reinterpret_cast<intptr_t>(&queue[offset].header.status) & 3) == 0); // InterlockedExchange operand should be aligned to 32 bits - InterlockedExchange(&queue[offset].header.status, MsgHeader::sent); - - return queue + offset; + + // Find a suitable slot to post the message into + BridgeMessage *targetMsg = queue; + for(size_t i = 0; i < MsgQueue::queueSize; i++, targetMsg++) + { + assert((reinterpret_cast<intptr_t>(&targetMsg->header.status) & 3) == 0); // InterlockedExchangeAdd operand should be aligned to 32 bits + if(InterlockedCompareExchange(&targetMsg->header.status, MsgHeader::prepared, MsgHeader::empty) == MsgHeader::empty) + { + memcpy(targetMsg, &msg, std::min(sizeof(BridgeMessage), size_t(msg.header.size))); + InterlockedExchange(&targetMsg->header.signalID, fromMsgThread ? uint32_t(-1) : i); // Don't send signal to ourselves + InterlockedExchange(&targetMsg->header.status, MsgHeader::sent); + return targetMsg; + } + } + assert(false); + return nullptr; } }; Modified: trunk/OpenMPT/pluginBridge/BridgeWrapper.cpp =================================================================== --- trunk/OpenMPT/pluginBridge/BridgeWrapper.cpp 2014-03-16 23:25:31 UTC (rev 3892) +++ trunk/OpenMPT/pluginBridge/BridgeWrapper.cpp 2014-03-17 02:56:32 UTC (rev 3893) @@ -9,6 +9,8 @@ #include "stdafx.h" + +#ifndef NO_VST #include "BridgeWrapper.h" #include "misc_util.h" #include "../mptrack/Mptrack.h" @@ -186,22 +188,6 @@ sharedMem.queueMem.Close(); delete this; return false; - /* { - sharedMem.messagePipe.WaitForClient(); - //sharedMem.messagePipe.Write(&BridgeProtocolVersion, sizeof(BridgeProtocolVersion)); - - sharedMem.otherProcess = processInfo.hProcess; - const HANDLE objects[] = { sharedMem.sigToHost.ack, sharedMem.otherProcess }; - DWORD result = WaitForMultipleObjects(CountOf(objects), objects, FALSE, 10000); - if(result == WAIT_OBJECT_0) - { - success = true; - } else if(result == WAIT_OBJECT_0 + 1) - { - // Process died - } - CloseHandle(processInfo.hThread); - }*/ } @@ -723,11 +709,22 @@ { if(!sharedMem.processMem.Good()) { + ASSERT(false); return; } - new (sharedMem.processMem.view) ProcessMsg(type, numInputs, numOutputs, sampleFrames); - buf_t *ptr = reinterpret_cast<buf_t *>(static_cast<ProcessMsg *>(sharedMem.processMem.view) + 1); + ProcessMsg *msg = static_cast<ProcessMsg *>(sharedMem.processMem.view); + const VstInt32 timeInfoFlags = msg->timeInfo.flags; + new (msg) ProcessMsg(type, numInputs, numOutputs, sampleFrames); + + // Plugin asked for time info in the past (flags are set), so we anticipate that it will do that again + // and cache the time info so that plugin doesn't have to ask for it. + if(timeInfoFlags != 0) + { + msg->timeInfo = *reinterpret_cast<VstTimeInfo *>(CVstPluginManager::MasterCallBack(sharedMem.effectPtr, audioMasterGetTime, 0, timeInfoFlags, nullptr, 0.0f)); + } + + buf_t *ptr = reinterpret_cast<buf_t *>(msg + 1); for(VstInt32 i = 0; i < numInputs; i++) { memcpy(ptr, inputs[i], sampleFrames * sizeof(buf_t)); @@ -746,4 +743,6 @@ outputs[i] = ptr; // Exactly what you don't want plugins to do usually (bend your output pointers)... muahahaha! ptr += sampleFrames; } -} \ No newline at end of file +} + +#endif //NO_VST Modified: trunk/OpenMPT/plugins/MidiInOut/MidiInOut.vcxproj.filters =================================================================== --- trunk/OpenMPT/plugins/MidiInOut/MidiInOut.vcxproj.filters 2014-03-16 23:25:31 UTC (rev 3892) +++ trunk/OpenMPT/plugins/MidiInOut/MidiInOut.vcxproj.filters 2014-03-17 02:56:32 UTC (rev 3893) @@ -11,6 +11,9 @@ <Filter Include="Interfaces"> <UniqueIdentifier>{b0c52021-7533-4599-b23f-605c5676b73f}</UniqueIdentifier> </Filter> + <Filter Include="Source Files\GUI"> + <UniqueIdentifier>{877d7a3d-a6b8-451f-807d-4af1699dc061}</UniqueIdentifier> + </Filter> </ItemGroup> <ItemGroup> <ClCompile Include="MidiInOut.cpp"> @@ -30,12 +33,6 @@ </ClCompile> </ItemGroup> <ItemGroup> - <ClInclude Include="..\common\ComboBox.h"> - <Filter>Source Files</Filter> - </ClInclude> - <ClInclude Include="..\common\Label.h"> - <Filter>Source Files</Filter> - </ClInclude> <ClInclude Include="MidiInOut.h"> <Filter>Source Files</Filter> </ClInclude> @@ -60,14 +57,20 @@ <ClInclude Include="..\..\include\vstsdk2.4\public.sdk\source\vst2.x\audioeffectx.h"> <Filter>Source Files\vst2.x</Filter> </ClInclude> + <ClInclude Include="..\common\CheckBox.h"> + <Filter>Source Files\GUI</Filter> + </ClInclude> + <ClInclude Include="..\common\Label.h"> + <Filter>Source Files\GUI</Filter> + </ClInclude> + <ClInclude Include="..\common\ComboBox.h"> + <Filter>Source Files\GUI</Filter> + </ClInclude> <ClInclude Include="..\common\Window.h"> - <Filter>Source Files</Filter> + <Filter>Source Files\GUI</Filter> </ClInclude> - <ClInclude Include="..\common\CheckBox.h"> - <Filter>Source Files</Filter> - </ClInclude> <ClInclude Include="..\common\WindowBase.h"> - <Filter>Source Files</Filter> + <Filter>Source Files\GUI</Filter> </ClInclude> </ItemGroup> </Project> \ No newline at end of file Modified: trunk/OpenMPT/plugins/MidiInOut/MidiInOutEditor.cpp =================================================================== --- trunk/OpenMPT/plugins/MidiInOut/MidiInOutEditor.cpp 2014-03-16 23:25:31 UTC (rev 3892) +++ trunk/OpenMPT/plugins/MidiInOut/MidiInOutEditor.cpp 2014-03-17 02:56:32 UTC (rev 3893) @@ -38,7 +38,7 @@ //----------------------------------- { AEffEditor::open(ptr); - InitializeWindow(ptr); + Create(ptr); HWND parent = static_cast<HWND>(ptr); @@ -68,7 +68,7 @@ outputLabel.Destroy(); outputCombo.Destroy(); - DestroyWindow(); + Destroy(); AEffEditor::close(); } @@ -174,6 +174,16 @@ } break; + case CBN_DROPDOWN: + if(hwnd == inputCombo.GetHwnd() || hwnd == outputCombo.GetHwnd()) + { + // Combo box is about to drop down -> dynamically size the dropdown list + bool isInputBox = hwnd == inputCombo.GetHwnd(); + ComboBox &combo = isInputBox ? inputCombo : outputCombo; + combo.SizeDropdownList(); + } + break; + case BN_CLICKED: if(hwnd == latencyCheck.GetHwnd()) { Modified: trunk/OpenMPT/plugins/common/CheckBox.h =================================================================== --- trunk/OpenMPT/plugins/common/CheckBox.h 2014-03-16 23:25:31 UTC (rev 3892) +++ trunk/OpenMPT/plugins/common/CheckBox.h 2014-03-17 02:56:32 UTC (rev 3893) @@ -45,10 +45,7 @@ { if(hwnd != nullptr) { - SendMessage(hwnd, - BM_SETCHECK, - state ? BST_CHECKED : BST_UNCHECKED, - 0); + Button_SetCheck(hwnd, state ? BST_CHECKED : BST_UNCHECKED); } } @@ -58,10 +55,7 @@ { if(hwnd != nullptr) { - return SendMessage(hwnd, - BM_GETCHECK, - 0, - 0) != BST_UNCHECKED; + return Button_GetCheck(hwnd) != BST_UNCHECKED; } return false; } Modified: trunk/OpenMPT/plugins/common/ComboBox.h =================================================================== --- trunk/OpenMPT/plugins/common/ComboBox.h 2014-03-16 23:25:31 UTC (rev 3892) +++ trunk/OpenMPT/plugins/common/ComboBox.h 2014-03-17 02:56:32 UTC (rev 3893) @@ -57,10 +57,7 @@ { if(hwnd != nullptr) { - SendMessage(hwnd, - CB_RESETCONTENT, - 0, - 0); + ComboBox_ResetContent(hwnd); } } @@ -70,19 +67,11 @@ { if(hwnd != nullptr) { - LRESULT result = SendMessage(hwnd, - CB_ADDSTRING, - 0, - reinterpret_cast<LPARAM>(text)); - + int result = ComboBox_AddString(hwnd, text); if(result != CB_ERR) { - SendMessage(hwnd, - CB_SETITEMDATA, - result, - reinterpret_cast<LPARAM>(data) - ); - return static_cast<int>(result); + ComboBox_SetItemData(hwnd, result, data); + return result; } } return -1; @@ -94,10 +83,7 @@ { if(hwnd != nullptr) { - return static_cast<int>(SendMessage(hwnd, - CB_GETCOUNT, - 0, - 0)); + return ComboBox_GetCount(hwnd); } return 0; } @@ -108,10 +94,7 @@ { if(hwnd != nullptr) { - SendMessage(hwnd, - CB_SETCURSEL, - index, - 0); + ComboBox_SetCurSel(hwnd, index); } } @@ -121,10 +104,7 @@ { if(hwnd != nullptr) { - return SendMessage(hwnd, - CB_GETCURSEL, - 0, - 0); + return ComboBox_GetCurSel(hwnd); } return -1; } @@ -142,12 +122,34 @@ { if(hwnd != nullptr) { - return reinterpret_cast<void *>(SendMessage(hwnd, - CB_GETITEMDATA, - index, - 0)); + return reinterpret_cast<void *>(ComboBox_GetItemData(hwnd, index)); } return 0; } + // Dynamically resize the dropdown list to cover as many items as possible. + void SizeDropdownList() + { + int itemHeight = ComboBox_GetItemHeight(hwnd); + int numItems = GetCount(); + if(numItems < 2) numItems = 2; + + RECT rect; + GetWindowRect(hwnd, &rect); + + SIZE sz; + sz.cx = rect.right - rect.left; + sz.cy = itemHeight * (numItems + 2); + + if(rect.top - sz.cy < 0 || rect.bottom + sz.cy > GetSystemMetrics(SM_CYSCREEN)) + { + // Dropdown exceeds screen height - clamp it. + int k = (GetSystemMetrics(SM_CYSCREEN) - rect.bottom) / itemHeight; + if(k < rect.top / itemHeight) k = rect.top / itemHeight; + if(itemHeight * k < sz.cy) sz.cy = itemHeight * k; + } + + SetWindowPos(hwnd, NULL, 0, 0, sz.cx, sz.cy, SWP_NOMOVE | SWP_NOZORDER); + } + }; Modified: trunk/OpenMPT/plugins/common/Label.h =================================================================== --- trunk/OpenMPT/plugins/common/Label.h 2014-03-16 23:25:31 UTC (rev 3892) +++ trunk/OpenMPT/plugins/common/Label.h 2014-03-17 02:56:32 UTC (rev 3893) @@ -38,15 +38,4 @@ SendMessage(hwnd, WM_SETFONT, reinterpret_cast<WPARAM>(GetStockObject(DEFAULT_GUI_FONT)), TRUE); } - - - // Destroy the combo box. - void Destroy() - { - if(hwnd != nullptr) - { - DestroyWindow(hwnd); - } - hwnd = nullptr; - } -}; +}; Modified: trunk/OpenMPT/plugins/common/Window.h =================================================================== --- trunk/OpenMPT/plugins/common/Window.h 2014-03-16 23:25:31 UTC (rev 3892) +++ trunk/OpenMPT/plugins/common/Window.h 2014-03-17 02:56:32 UTC (rev 3893) @@ -24,9 +24,9 @@ Window() : originalWinProc(nullptr) { }; // Register window callback function and initialize window - void InitializeWindow(void *windowHandle) + void Create(void *windowHandle) { - DestroyWindow(); + Destroy(); hwnd = static_cast<HWND>(windowHandle); @@ -41,8 +41,8 @@ } - // Destroy the combo box. - void DestroyWindow() + // Destroy the window. + void Destroy() { // Restore original window processing function. if(hwnd != nullptr) Modified: trunk/OpenMPT/plugins/common/WindowBase.h =================================================================== --- trunk/OpenMPT/plugins/common/WindowBase.h 2014-03-16 23:25:31 UTC (rev 3892) +++ trunk/OpenMPT/plugins/common/WindowBase.h 2014-03-17 02:56:32 UTC (rev 3893) @@ -14,6 +14,7 @@ #define VC_EXTRALEAN #define NOMINMAX #include <windows.h> +#include <WindowsX.h> #include <tchar.h> This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <man...@us...> - 2014-03-18 08:56:27
|
Revision: 3897 http://sourceforge.net/p/modplug/code/3897 Author: manxorist Date: 2014-03-18 08:56:19 +0000 (Tue, 18 Mar 2014) Log Message: ----------- [Ref] Rename FileReader::GetChunk(len) to FileReader::ReadChunk(len) in order to make naming consistent because it actually advances the stream position. All other read functions also advance the stream position and the other GetChunk overload (GetChunk(pos, len)) does not. Additionally it's just totally confusing for a member named Get*** to mutate the observable object state. Modified Paths: -------------- trunk/OpenMPT/mptrack/VstPresets.cpp trunk/OpenMPT/soundlib/ChunkReader.h trunk/OpenMPT/soundlib/FileReader.h trunk/OpenMPT/soundlib/ITCompression.cpp trunk/OpenMPT/soundlib/Load_amf.cpp trunk/OpenMPT/soundlib/Load_ams.cpp trunk/OpenMPT/soundlib/Load_dbm.cpp trunk/OpenMPT/soundlib/Load_digi.cpp trunk/OpenMPT/soundlib/Load_dmf.cpp trunk/OpenMPT/soundlib/Load_dsm.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_mtm.cpp trunk/OpenMPT/soundlib/Load_okt.cpp trunk/OpenMPT/soundlib/Load_psm.cpp trunk/OpenMPT/soundlib/Load_ptm.cpp trunk/OpenMPT/soundlib/Load_umx.cpp trunk/OpenMPT/soundlib/Load_xm.cpp trunk/OpenMPT/soundlib/load_j2b.cpp Modified: trunk/OpenMPT/mptrack/VstPresets.cpp =================================================================== --- trunk/OpenMPT/mptrack/VstPresets.cpp 2014-03-18 01:54:33 UTC (rev 3896) +++ trunk/OpenMPT/mptrack/VstPresets.cpp 2014-03-18 08:56:19 UTC (rev 3897) @@ -76,7 +76,7 @@ } } else { - FileReader chunk = file.GetChunk(file.ReadUint32BE()); + FileReader chunk = file.ReadChunk(file.ReadUint32BE()); plugin.Dispatch(effSetChunk, 1, chunk.GetLength(), const_cast<char *>(chunk.GetRawData()), 0); } } else if((header.fxMagic == bankMagic || header.fxMagic == chunkBankMagic) && firstChunk) @@ -101,7 +101,7 @@ plugin.SetCurrentProgram(oldCurrentProgram); } else { - FileReader chunk = file.GetChunk(file.ReadUint32BE()); + FileReader chunk = file.ReadChunk(file.ReadUint32BE()); plugin.Dispatch(effSetChunk, 0, chunk.GetLength(), const_cast<char *>(chunk.GetRawData()), 0); } if(header.version >= 2) Modified: trunk/OpenMPT/soundlib/ChunkReader.h =================================================================== --- trunk/OpenMPT/soundlib/ChunkReader.h 2014-03-18 01:54:33 UTC (rev 3896) +++ trunk/OpenMPT/soundlib/ChunkReader.h 2014-03-18 08:56:19 UTC (rev 3897) @@ -113,7 +113,7 @@ } size_t dataSize = chunkHeader.GetLength(); - ChunkListItem<T> resultItem(chunkHeader, GetChunk(dataSize)); + ChunkListItem<T> resultItem(chunkHeader, ReadChunk(dataSize)); result.push_back(resultItem); // Skip padding bytes Modified: trunk/OpenMPT/soundlib/FileReader.h =================================================================== --- trunk/OpenMPT/soundlib/FileReader.h 2014-03-18 01:54:33 UTC (rev 3896) +++ trunk/OpenMPT/soundlib/FileReader.h 2014-03-18 08:56:19 UTC (rev 3897) @@ -530,15 +530,15 @@ return FileReader(); } #ifndef NO_FILEREADER_STD_ISTREAM - return FileReader(MPT_SHARED_PTR<IFileDataContainer>(new FileDataContainerWindow(data, position, (std::min)(length, DataContainer().GetLength() - position)))); + return FileReader(MPT_SHARED_PTR<IFileDataContainer>(new FileDataContainerWindow(data, position, std::min(length, DataContainer().GetLength() - position)))); #else - return FileReader(DataContainer().GetRawData() + position, (std::min)(length, DataContainer().GetLength() - position)); + return FileReader(DataContainer().GetRawData() + position, std::min(length, DataContainer().GetLength() - position)); #endif } // Create a new FileReader object for parsing a sub chunk at the current position with a given length. // The file cursor is advanced by "length" bytes. - FileReader GetChunk(off_t length) + FileReader ReadChunk(off_t length) { off_t position = streamPos; Skip(length); Modified: trunk/OpenMPT/soundlib/ITCompression.cpp =================================================================== --- trunk/OpenMPT/soundlib/ITCompression.cpp 2014-03-18 01:54:33 UTC (rev 3896) +++ trunk/OpenMPT/soundlib/ITCompression.cpp 2014-03-18 08:56:19 UTC (rev 3897) @@ -315,7 +315,7 @@ writtenSamples = writePos = 0; while(writtenSamples < sample.nLength && file.AreBytesLeft()) { - chunk = file.GetChunk(file.ReadUint16LE()); + chunk = file.ReadChunk(file.ReadUint16LE()); // Initialise bit reader dataPos = 0; Modified: trunk/OpenMPT/soundlib/Load_amf.cpp =================================================================== --- trunk/OpenMPT/soundlib/Load_amf.cpp 2014-03-18 01:54:33 UTC (rev 3896) +++ trunk/OpenMPT/soundlib/Load_amf.cpp 2014-03-18 08:56:19 UTC (rev 3897) @@ -526,7 +526,7 @@ { // Track size is a 24-Bit value describing the number of byte triplets in this track. uint32 trackSize = file.ReadUint16LE() | (file.ReadUint8() << 16); - trackData[i] = file.GetChunk(trackSize * 3); + trackData[i] = file.ReadChunk(trackSize * 3); } if(loadFlags & loadSampleData) Modified: trunk/OpenMPT/soundlib/Load_ams.cpp =================================================================== --- trunk/OpenMPT/soundlib/Load_ams.cpp 2014-03-18 01:54:33 UTC (rev 3896) +++ trunk/OpenMPT/soundlib/Load_ams.cpp 2014-03-18 08:56:19 UTC (rev 3897) @@ -486,7 +486,7 @@ for(PATTERNINDEX pat = 0; pat < fileHeader.numPats; pat++) { uint32 patLength = file.ReadUint32LE(); - FileReader patternChunk = file.GetChunk(patLength); + FileReader patternChunk = file.ReadChunk(patLength); if(loadFlags & loadPatternData) { @@ -954,7 +954,7 @@ for(PATTERNINDEX pat = 0; pat < fileHeader.numPats; pat++) { uint32 patLength = file.ReadUint32LE(); - FileReader patternChunk = file.GetChunk(patLength); + FileReader patternChunk = file.ReadChunk(patLength); if(loadFlags & loadPatternData) { Modified: trunk/OpenMPT/soundlib/Load_dbm.cpp =================================================================== --- trunk/OpenMPT/soundlib/Load_dbm.cpp 2014-03-18 01:54:33 UTC (rev 3896) +++ trunk/OpenMPT/soundlib/Load_dbm.cpp 2014-03-18 08:56:19 UTC (rev 3897) @@ -425,7 +425,7 @@ { uint16 numRows = patternChunk.ReadUint16BE(); uint32 packedSize = patternChunk.ReadUint32BE(); - FileReader chunk = patternChunk.GetChunk(packedSize); + FileReader chunk = patternChunk.ReadChunk(packedSize); if(Patterns.Insert(pat, numRows)) { Modified: trunk/OpenMPT/soundlib/Load_digi.cpp =================================================================== --- trunk/OpenMPT/soundlib/Load_digi.cpp 2014-03-18 01:54:33 UTC (rev 3896) +++ trunk/OpenMPT/soundlib/Load_digi.cpp 2014-03-18 08:56:19 UTC (rev 3897) @@ -150,10 +150,10 @@ FileReader patternChunk; if(fileHeader.packEnable) { - patternChunk = file.GetChunk(file.ReadUint16BE()); + patternChunk = file.ReadChunk(file.ReadUint16BE()); } else { - patternChunk = file.GetChunk(4 * 64 * GetNumChannels()); + patternChunk = file.ReadChunk(4 * 64 * GetNumChannels()); } if(!(loadFlags & loadPatternData) || Patterns.Insert(pat, 64)) Modified: trunk/OpenMPT/soundlib/Load_dmf.cpp =================================================================== --- trunk/OpenMPT/soundlib/Load_dmf.cpp 2014-03-18 01:54:33 UTC (rev 3896) +++ trunk/OpenMPT/soundlib/Load_dmf.cpp 2014-03-18 08:56:19 UTC (rev 3897) @@ -1018,7 +1018,7 @@ DMFPatternHeader header; chunk.ReadConvertEndianness(header); chunk.SkipBack(sizeof(header)); - patternChunks.push_back(chunk.GetChunk(sizeof(header) + header.patternLength)); + patternChunks.push_back(chunk.ReadChunk(sizeof(header) + header.patternLength)); } // Now go through the order list and load them. @@ -1078,7 +1078,7 @@ chunk.Skip(sizeof(DMFSampleHeaderTail)); // Now read the sample data from the data chunk - FileReader sampleData = sampleDataChunk.GetChunk(sampleDataChunk.ReadUint32LE()); + FileReader sampleData = sampleDataChunk.ReadChunk(sampleDataChunk.ReadUint32LE()); if(sampleData.IsValid() && (loadFlags & loadSampleData)) { SampleIO( Modified: trunk/OpenMPT/soundlib/Load_dsm.cpp =================================================================== --- trunk/OpenMPT/soundlib/Load_dsm.cpp 2014-03-18 01:54:33 UTC (rev 3896) +++ trunk/OpenMPT/soundlib/Load_dsm.cpp 2014-03-18 08:56:19 UTC (rev 3897) @@ -201,7 +201,7 @@ PATTERNINDEX patNum = 0; while(file.ReadConvertEndianness(chunkHeader)) { - FileReader chunk = file.GetChunk(chunkHeader.size); + FileReader chunk = file.ReadChunk(chunkHeader.size); if(!memcmp(chunkHeader.magic, "PATT", 4) && (loadFlags & loadPatternData)) { Modified: trunk/OpenMPT/soundlib/Load_far.cpp =================================================================== --- trunk/OpenMPT/soundlib/Load_far.cpp 2014-03-18 01:54:33 UTC (rev 3896) +++ trunk/OpenMPT/soundlib/Load_far.cpp 2014-03-18 08:56:19 UTC (rev 3897) @@ -214,7 +214,7 @@ continue; } - FileReader patternChunk = file.GetChunk(orderHeader.patternSize[pat]); + FileReader patternChunk = file.ReadChunk(orderHeader.patternSize[pat]); // Calculate pattern length in rows (every event is 4 bytes, and we have 16 channels) ROWINDEX numRows = (orderHeader.patternSize[pat] - 2) / (16 * 4); Modified: trunk/OpenMPT/soundlib/Load_gdm.cpp =================================================================== --- trunk/OpenMPT/soundlib/Load_gdm.cpp 2014-03-18 01:54:33 UTC (rev 3896) +++ trunk/OpenMPT/soundlib/Load_gdm.cpp 2014-03-18 08:56:19 UTC (rev 3897) @@ -298,7 +298,7 @@ // Huh, no pattern data present? continue; } - FileReader chunk = file.GetChunk(patternLength - 2); + FileReader chunk = file.ReadChunk(patternLength - 2); if(!(loadFlags & loadPatternData) || !chunk.IsValid() || Patterns.Insert(pat, 64)) { Modified: trunk/OpenMPT/soundlib/Load_imf.cpp =================================================================== --- trunk/OpenMPT/soundlib/Load_imf.cpp 2014-03-18 01:54:33 UTC (rev 3896) +++ trunk/OpenMPT/soundlib/Load_imf.cpp 2014-03-18 08:56:19 UTC (rev 3897) @@ -477,7 +477,7 @@ for(PATTERNINDEX pat = 0; pat < fileHeader.patNum; pat++) { const uint16 length = file.ReadUint16LE(), numRows = file.ReadUint16LE(); - FileReader patternChunk = file.GetChunk(length - 4); + FileReader patternChunk = file.ReadChunk(length - 4); if(!(loadFlags & loadPatternData) || Patterns.Insert(pat, numRows)) { @@ -606,7 +606,7 @@ if(sampleHeader.length) { - FileReader sampleChunk = file.GetChunk(sampleHeader.length); + FileReader sampleChunk = file.ReadChunk(sampleHeader.length); if(loadFlags & loadSampleData) { SampleIO( Modified: trunk/OpenMPT/soundlib/Load_it.cpp =================================================================== --- trunk/OpenMPT/soundlib/Load_it.cpp 2014-03-18 01:54:33 UTC (rev 3896) +++ trunk/OpenMPT/soundlib/Load_it.cpp 2014-03-18 08:56:19 UTC (rev 3897) @@ -578,14 +578,14 @@ FileReader patNames; if(file.ReadMagic("PNAM")) { - patNames = file.GetChunk(file.ReadUint32LE()); + patNames = file.ReadChunk(file.ReadUint32LE()); } m_nChannels = GetModSpecifications().channelsMin; // Read channel names: "CNAM" if(file.ReadMagic("CNAM")) { - FileReader chnNames = file.GetChunk(file.ReadUint32LE()); + FileReader chnNames = file.ReadChunk(file.ReadUint32LE()); const CHANNELINDEX readChns = std::min(MAX_BASECHANNELS, static_cast<CHANNELINDEX>(chnNames.GetLength() / MAX_CHANNELNAME)); m_nChannels = readChns; @@ -695,7 +695,7 @@ || !file.Skip(4)) continue; - FileReader patternData = file.GetChunk(len); + FileReader patternData = file.ReadChunk(len); ROWINDEX row = 0; std::vector<uint8> chnMask(GetNumChannels()); @@ -785,7 +785,7 @@ || Patterns.Insert(pat, numRows)) continue; - FileReader patternData = file.GetChunk(len); + FileReader patternData = file.ReadChunk(len); // Now (after the Insert() call), we can read the pattern name. CopyPatternName(Patterns[pat], patNames); @@ -1796,7 +1796,7 @@ file.SkipBack(8); return; } - FileReader chunk = file.GetChunk(chunkSize); + FileReader chunk = file.ReadChunk(chunkSize); // Channel FX if(!memcmp(code, "CHFX", 4)) @@ -1823,7 +1823,7 @@ //data for VST setchunk? size lies just after standard plugin data. const uint32 pluginDataChunkSize = chunk.ReadUint32LE(); - FileReader pluginDataChunk = chunk.GetChunk(pluginDataChunkSize); + FileReader pluginDataChunk = chunk.ReadChunk(pluginDataChunkSize); if(pluginDataChunk.IsValid()) { @@ -1837,7 +1837,7 @@ } //rewbs.modularPlugData - FileReader modularData = chunk.GetChunk(chunk.ReadUint32LE()); + FileReader modularData = chunk.ReadChunk(chunk.ReadUint32LE()); //if dwMPTExtra is positive and there are dwMPTExtra bytes left in nPluginSize, we have some more data! if(modularData.IsValid()) @@ -2156,7 +2156,7 @@ break; } - FileReader chunk = file.GetChunk(size); + FileReader chunk = file.ReadChunk(size); switch (code) // interpret field code { @@ -2284,7 +2284,7 @@ return 0; } //...the next piece of data must be the total size of the modular data - FileReader modularData = file.GetChunk(file.ReadUint32LE()); + FileReader modularData = file.ReadChunk(file.ReadUint32LE()); // Handle chunks while(modularData.AreBytesLeft()) Modified: trunk/OpenMPT/soundlib/Load_itp.cpp =================================================================== --- trunk/OpenMPT/soundlib/Load_itp.cpp 2014-03-18 01:54:33 UTC (rev 3896) +++ trunk/OpenMPT/soundlib/Load_itp.cpp 2014-03-18 08:56:19 UTC (rev 3897) @@ -119,7 +119,7 @@ // Song mix plugins { - FileReader plugChunk = file.GetChunk(file.ReadUint32LE()); + FileReader plugChunk = file.ReadChunk(file.ReadUint32LE()); LoadMixPlugins(plugChunk); } @@ -172,7 +172,7 @@ const PATTERNINDEX numPats = static_cast<PATTERNINDEX>(file.ReadUint32LE()); const PATTERNINDEX numNamedPats = static_cast<PATTERNINDEX>(file.ReadUint32LE()); size_t patNameLen = file.ReadUint32LE(); // Size of each pattern name - FileReader pattNames = file.GetChunk(numNamedPats * patNameLen); + FileReader pattNames = file.ReadChunk(numNamedPats * patNameLen); // modcommand data length @@ -186,7 +186,7 @@ { // Patterns[npat].GetNumRows() const ROWINDEX numRows = file.ReadUint32LE(); - FileReader patternChunk = file.GetChunk(numRows * size * GetNumChannels()); + FileReader patternChunk = file.ReadChunk(numRows * size * GetNumChannels()); // Allocate pattern if(!(loadFlags & loadPatternData) || numRows == 0 || numRows > MAX_PATTERN_ROWS || Patterns.Insert(pat, numRows)) Modified: trunk/OpenMPT/soundlib/Load_mtm.cpp =================================================================== --- trunk/OpenMPT/soundlib/Load_mtm.cpp 2014-03-18 01:54:33 UTC (rev 3896) +++ trunk/OpenMPT/soundlib/Load_mtm.cpp 2014-03-18 08:56:19 UTC (rev 3897) @@ -147,7 +147,7 @@ // Reading Patterns const ROWINDEX rowsPerPat = std::min(ROWINDEX(fileHeader.beatsPerTrack), MAX_PATTERN_ROWS); - FileReader tracks = file.GetChunk(192 * fileHeader.numTracks); + FileReader tracks = file.ReadChunk(192 * fileHeader.numTracks); for(PATTERNINDEX pat = 0; pat <= fileHeader.lastPattern; pat++) { Modified: trunk/OpenMPT/soundlib/Load_okt.cpp =================================================================== --- trunk/OpenMPT/soundlib/Load_okt.cpp 2014-03-18 01:54:33 UTC (rev 3896) +++ trunk/OpenMPT/soundlib/Load_okt.cpp 2014-03-18 08:56:19 UTC (rev 3897) @@ -307,7 +307,7 @@ break; } - FileReader chunk = file.GetChunk(iffHead.chunksize); + FileReader chunk = file.ReadChunk(iffHead.chunksize); if(!chunk.IsValid()) { break; Modified: trunk/OpenMPT/soundlib/Load_psm.cpp =================================================================== --- trunk/OpenMPT/soundlib/Load_psm.cpp 2014-03-18 01:54:33 UTC (rev 3896) +++ trunk/OpenMPT/soundlib/Load_psm.cpp 2014-03-18 08:56:19 UTC (rev 3897) @@ -329,7 +329,7 @@ } patternIDs.push_back(ConvertStrTo<uint32>(&patternID[newFormat ? 0 : 1])); // We're going to read the rest of the pattern data later. - patternChunks.push_back(chunk.GetChunk(chunk.BytesLeft())); + patternChunks.push_back(chunk.ReadChunk(chunk.BytesLeft())); // Convert later as we have to know how many channels there are. } @@ -686,7 +686,7 @@ continue; } - FileReader rowChunk = patternChunk.GetChunk(rowSize - 2); + FileReader rowChunk = patternChunk.ReadChunk(rowSize - 2); while(rowChunk.AreBytesLeft()) { @@ -1179,7 +1179,7 @@ // Read samples if(fileHeader.smpOffset > 4 && file.Seek(fileHeader.smpOffset - 4) && file.ReadUint32LE() == PSM16FileHeader::idPSAH) { - FileReader sampleChunk = file.GetChunk(file.BytesLeft()); + FileReader sampleChunk = file.ReadChunk(file.BytesLeft()); for(SAMPLEINDEX fileSample = 0; fileSample < fileHeader.numSamples; fileSample++) { @@ -1221,7 +1221,7 @@ } // Patterns are padded to 16 Bytes - FileReader patternChunk = file.GetChunk(((patternHeader.size + 15) & ~15) - sizeof(PSM16PatternHeader)); + FileReader patternChunk = file.ReadChunk(((patternHeader.size + 15) & ~15) - sizeof(PSM16PatternHeader)); if(Patterns.Insert(pat, patternHeader.numRows)) { Modified: trunk/OpenMPT/soundlib/Load_ptm.cpp =================================================================== --- trunk/OpenMPT/soundlib/Load_ptm.cpp 2014-03-18 01:54:33 UTC (rev 3896) +++ trunk/OpenMPT/soundlib/Load_ptm.cpp 2014-03-18 08:56:19 UTC (rev 3897) @@ -178,7 +178,7 @@ } // Reading samples - FileReader sampleHeaderChunk = file.GetChunk(fileHeader.numSamples * sizeof(PTMSampleHeader)); + FileReader sampleHeaderChunk = file.ReadChunk(fileHeader.numSamples * sizeof(PTMSampleHeader)); for(SAMPLEINDEX smp = 0; smp < m_nSamples; smp++) { PTMSampleHeader sampleHeader; Modified: trunk/OpenMPT/soundlib/Load_umx.cpp =================================================================== --- trunk/OpenMPT/soundlib/Load_umx.cpp 2014-03-18 01:54:33 UTC (rev 3896) +++ trunk/OpenMPT/soundlib/Load_umx.cpp 2014-03-18 08:56:19 UTC (rev 3897) @@ -303,7 +303,7 @@ } int32 size = ReadUMXIndex(chunk); - FileReader fileChunk = chunk.GetChunk(size); + FileReader fileChunk = chunk.ReadChunk(size); if(isMusic) { Modified: trunk/OpenMPT/soundlib/Load_xm.cpp =================================================================== --- trunk/OpenMPT/soundlib/Load_xm.cpp 2014-03-18 01:54:33 UTC (rev 3896) +++ trunk/OpenMPT/soundlib/Load_xm.cpp 2014-03-18 08:56:19 UTC (rev 3897) @@ -147,7 +147,7 @@ } file.Seek(curPos + headerSize); - FileReader patternChunk = file.GetChunk(packedSize); + FileReader patternChunk = file.ReadChunk(packedSize); if(sndFile.Patterns.Insert(pat, numRows) || packedSize == 0) { @@ -476,7 +476,7 @@ { // Sample 15 in dirtysex.xm by J/M/T/M is a 16-bit sample with an odd size of 0x18B according to the header, while the real sample size would be 0x18A. // Always read as many bytes as specified in the header, even if the sample reader would probably read less bytes. - FileReader sampleChunk = file.GetChunk(sampleSize[sample]); + FileReader sampleChunk = file.ReadChunk(sampleSize[sample]); if(sample < sampleSlots.size()) { sampleFlags[sample].ReadSample(Samples[sampleSlots[sample]], sampleChunk); Modified: trunk/OpenMPT/soundlib/load_j2b.cpp =================================================================== --- trunk/OpenMPT/soundlib/load_j2b.cpp 2014-03-18 01:54:33 UTC (rev 3896) +++ trunk/OpenMPT/soundlib/load_j2b.cpp 2014-03-18 08:56:19 UTC (rev 3897) @@ -833,7 +833,7 @@ FileReader chunk(*patternIter); PATTERNINDEX pat = chunk.ReadUint8(); size_t patternSize = chunk.ReadUint32LE(); - ConvertAMPattern(chunk.GetChunk(patternSize), pat, isAM, *this); + ConvertAMPattern(chunk.ReadChunk(patternSize), pat, isAM, *this); } } @@ -953,7 +953,7 @@ break; } - FileReader sampleFileChunk = sampleChunk.GetChunk(sampleHeaderChunk.length); + FileReader sampleFileChunk = sampleChunk.ReadChunk(sampleHeaderChunk.length); AMSampleHeader sampleHeader; if(!sampleFileChunk.ReadConvertEndianness(sampleHeader)) This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <man...@us...> - 2014-03-18 10:17:48
|
Revision: 3900 http://sourceforge.net/p/modplug/code/3900 Author: manxorist Date: 2014-03-18 10:17:40 +0000 (Tue, 18 Mar 2014) Log Message: ----------- [Ref] Replace all CLAMP with Clamp and kill CLAMP. Modified Paths: -------------- trunk/OpenMPT/common/misc_util.h trunk/OpenMPT/mptrack/Ctrl_gen.cpp trunk/OpenMPT/mptrack/Ctrl_ins.cpp trunk/OpenMPT/mptrack/Ctrl_smp.cpp trunk/OpenMPT/mptrack/EffectInfo.cpp trunk/OpenMPT/mptrack/MPTHacks.cpp trunk/OpenMPT/mptrack/Mpdlgs.cpp trunk/OpenMPT/mptrack/ScaleEnvPointsDlg.cpp trunk/OpenMPT/sounddev/SoundDevice.h Modified: trunk/OpenMPT/common/misc_util.h =================================================================== --- trunk/OpenMPT/common/misc_util.h 2014-03-18 09:53:02 UTC (rev 3899) +++ trunk/OpenMPT/common/misc_util.h 2014-03-18 10:17:40 UTC (rev 3900) @@ -296,12 +296,6 @@ } -// Like Limit, but returns value -#ifndef CLAMP -#define CLAMP(number, low, high) MIN(high, MAX(low, number)) -#endif - - // Greatest Common Divisor. template <class T> T gcd(T a, T b) Modified: trunk/OpenMPT/mptrack/Ctrl_gen.cpp =================================================================== --- trunk/OpenMPT/mptrack/Ctrl_gen.cpp 2014-03-18 09:53:02 UTC (rev 3899) +++ trunk/OpenMPT/mptrack/Ctrl_gen.cpp 2014-03-18 10:17:40 UTC (rev 3900) @@ -388,7 +388,7 @@ if (s[0]) { UINT n = atoi(s); - n = CLAMP(n, m_sndFile.GetModSpecifications().tempoMin, m_sndFile.GetModSpecifications().tempoMax); + n = Clamp(n, m_sndFile.GetModSpecifications().tempoMin, m_sndFile.GetModSpecifications().tempoMax); if (n != m_sndFile.m_nDefaultTempo) { m_bEditsLocked=true; @@ -415,7 +415,7 @@ if (s[0]) { UINT n = atoi(s); - n = CLAMP(n, m_sndFile.GetModSpecifications().speedMin, m_sndFile.GetModSpecifications().speedMax); + n = Clamp(n, m_sndFile.GetModSpecifications().speedMin, m_sndFile.GetModSpecifications().speedMax); if (n != m_sndFile.m_nDefaultSpeed) { m_bEditsLocked=true; Modified: trunk/OpenMPT/mptrack/Ctrl_ins.cpp =================================================================== --- trunk/OpenMPT/mptrack/Ctrl_ins.cpp 2014-03-18 09:53:02 UTC (rev 3899) +++ trunk/OpenMPT/mptrack/Ctrl_ins.cpp 2014-03-18 10:17:40 UTC (rev 3900) @@ -473,7 +473,7 @@ int n = pIns->NoteMap[i]; if ((n > NOTE_MIN && nAmount < 0) || (n < NOTE_MAX && nAmount > 0)) { - n = CLAMP(n + nAmount, NOTE_MIN, NOTE_MAX); + n = Clamp(n + nAmount, NOTE_MIN, NOTE_MAX); pIns->NoteMap[i] = (BYTE)n; bModified = true; } Modified: trunk/OpenMPT/mptrack/Ctrl_smp.cpp =================================================================== --- trunk/OpenMPT/mptrack/Ctrl_smp.cpp 2014-03-18 09:53:02 UTC (rev 3899) +++ trunk/OpenMPT/mptrack/Ctrl_smp.cpp 2014-03-18 10:17:40 UTC (rev 3900) @@ -3022,12 +3022,12 @@ // MOD finetune range -8 to 7 translates to -128 to 112 if(m_sndFile.GetType() & MOD_TYPE_MOD) { - ftune = CLAMP((ftune >> 4) + pos, -8, 7); + ftune = Clamp((ftune >> 4) + pos, -8, 7); sample.nFineTune = MOD2XMFineTune((signed char)ftune); } else { - ftune = CLAMP(ftune + pos, -128, 127); + ftune = Clamp(ftune + pos, -128, 127); sample.nFineTune = (signed char)ftune; } SetDlgItemInt(IDC_EDIT5, ftune, TRUE); Modified: trunk/OpenMPT/mptrack/EffectInfo.cpp =================================================================== --- trunk/OpenMPT/mptrack/EffectInfo.cpp 2014-03-18 09:53:02 UTC (rev 3899) +++ trunk/OpenMPT/mptrack/EffectInfo.cpp 2014-03-18 10:17:40 UTC (rev 3900) @@ -402,7 +402,7 @@ case CMD_PANNING8: if(sndFile.GetType() == MOD_TYPE_S3M) { - pos = CLAMP(param, 0, 0x80); + pos = Clamp(param, 0u, 0x80u); if(param == 0xA4) pos = 0x81; } Modified: trunk/OpenMPT/mptrack/MPTHacks.cpp =================================================================== --- trunk/OpenMPT/mptrack/MPTHacks.cpp 2014-03-18 09:53:02 UTC (rev 3899) +++ trunk/OpenMPT/mptrack/MPTHacks.cpp 2014-03-18 10:17:40 UTC (rev 3900) @@ -368,7 +368,7 @@ AddToLog(mpt::String::Format("Found incompatible default tempo (must be between %d and %d)", originalSpecs->tempoMin, originalSpecs->tempoMax)); foundHacks = true; if(autofix) - m_SndFile.m_nDefaultTempo = CLAMP(m_SndFile.m_nDefaultTempo, originalSpecs->tempoMin, originalSpecs->tempoMax); + m_SndFile.m_nDefaultTempo = Clamp(m_SndFile.m_nDefaultTempo, originalSpecs->tempoMin, originalSpecs->tempoMax); } // Check for invalid default speed @@ -377,7 +377,7 @@ AddToLog(mpt::String::Format("Found incompatible default speed (must be between %d and %d)", originalSpecs->speedMin, originalSpecs->speedMax)); foundHacks = true; if(autofix) - m_SndFile.m_nDefaultSpeed = CLAMP(m_SndFile.m_nDefaultSpeed, originalSpecs->speedMin, originalSpecs->speedMax); + m_SndFile.m_nDefaultSpeed = Clamp(m_SndFile.m_nDefaultSpeed, originalSpecs->speedMin, originalSpecs->speedMax); } // Check for invalid rows per beat / measure values @@ -387,8 +387,8 @@ foundHacks = true; if(autofix) { - m_SndFile.m_nDefaultRowsPerBeat = CLAMP(m_SndFile.m_nDefaultRowsPerBeat, 1, (originalSpecs->patternRowsMax - 1)); - m_SndFile.m_nDefaultRowsPerMeasure = CLAMP(m_SndFile.m_nDefaultRowsPerMeasure, m_SndFile.m_nDefaultRowsPerBeat, (originalSpecs->patternRowsMax - 1)); + m_SndFile.m_nDefaultRowsPerBeat = Clamp(m_SndFile.m_nDefaultRowsPerBeat, 1u, (originalSpecs->patternRowsMax - 1)); + m_SndFile.m_nDefaultRowsPerMeasure = Clamp(m_SndFile.m_nDefaultRowsPerMeasure, m_SndFile.m_nDefaultRowsPerBeat, (originalSpecs->patternRowsMax - 1)); } } Modified: trunk/OpenMPT/mptrack/Mpdlgs.cpp =================================================================== --- trunk/OpenMPT/mptrack/Mpdlgs.cpp 2014-03-18 09:53:02 UTC (rev 3899) +++ trunk/OpenMPT/mptrack/Mpdlgs.cpp 2014-03-18 10:17:40 UTC (rev 3900) @@ -651,7 +651,7 @@ m_CbnLatencyMS.GetWindowText(s, sizeof(s)); m_Settings.LatencyMS = atoi(s); //Check given value. - m_Settings.LatencyMS = CLAMP(m_Settings.LatencyMS, SNDDEV_MINLATENCY_MS, SNDDEV_MAXLATENCY_MS); + m_Settings.LatencyMS = Clamp(m_Settings.LatencyMS, SNDDEV_MINLATENCY_MS, SNDDEV_MAXLATENCY_MS); wsprintf(s, "%d ms", m_Settings.LatencyMS); m_CbnLatencyMS.SetWindowText(s); } @@ -661,7 +661,7 @@ m_CbnUpdateIntervalMS.GetWindowText(s, sizeof(s)); m_Settings.UpdateIntervalMS = atoi(s); //Check given value. - m_Settings.UpdateIntervalMS = CLAMP(m_Settings.UpdateIntervalMS, SNDDEV_MINUPDATEINTERVAL_MS, SNDDEV_MAXUPDATEINTERVAL_MS); + m_Settings.UpdateIntervalMS = Clamp(m_Settings.UpdateIntervalMS, SNDDEV_MINUPDATEINTERVAL_MS, SNDDEV_MAXUPDATEINTERVAL_MS); wsprintf(s, "%d ms", m_Settings.UpdateIntervalMS); m_CbnUpdateIntervalMS.SetWindowText(s); } Modified: trunk/OpenMPT/mptrack/ScaleEnvPointsDlg.cpp =================================================================== --- trunk/OpenMPT/mptrack/ScaleEnvPointsDlg.cpp 2014-03-18 09:53:02 UTC (rev 3899) +++ trunk/OpenMPT/mptrack/ScaleEnvPointsDlg.cpp 2014-03-18 10:17:40 UTC (rev 3900) @@ -59,7 +59,7 @@ { for(uint32 i = 0; i < m_Env.nNodes; i++) { - m_Env.Values[i] = CLAMP(static_cast<BYTE>((m_fFactorY * ((int)m_Env.Values[i] - m_nCenter)) + m_nCenter), ENVELOPE_MIN, ENVELOPE_MAX); + m_Env.Values[i] = Clamp(static_cast<uint8>((m_fFactorY * ((int)m_Env.Values[i] - m_nCenter)) + m_nCenter), uint8(ENVELOPE_MIN), uint8(ENVELOPE_MAX)); } } Modified: trunk/OpenMPT/sounddev/SoundDevice.h =================================================================== --- trunk/OpenMPT/sounddev/SoundDevice.h 2014-03-18 09:53:02 UTC (rev 3899) +++ trunk/OpenMPT/sounddev/SoundDevice.h 2014-03-18 10:17:40 UTC (rev 3900) @@ -159,10 +159,10 @@ #define SNDDEV_MAXBUFFERS 256 #define SNDDEV_MAXBUFFERSIZE (1024*1024) -#define SNDDEV_MINLATENCY_MS 1 -#define SNDDEV_MAXLATENCY_MS 500 -#define SNDDEV_MINUPDATEINTERVAL_MS 1 -#define SNDDEV_MAXUPDATEINTERVAL_MS 200 +#define SNDDEV_MINLATENCY_MS 1u +#define SNDDEV_MAXLATENCY_MS 500u +#define SNDDEV_MINUPDATEINTERVAL_MS 1u +#define SNDDEV_MAXUPDATEINTERVAL_MS 200u struct SoundChannelMapping This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <man...@us...> - 2014-03-18 18:53:47
|
Revision: 3901 http://sourceforge.net/p/modplug/code/3901 Author: manxorist Date: 2014-03-18 18:53:38 +0000 (Tue, 18 Mar 2014) Log Message: ----------- [Ref] sounddev: Split SoundDeviceCaps structure into the static part (which does not depend on a particular device but only on the device type) and the dynamic part. [Ref] sounddev: Kill duplicated information via ISoundDevice::CanStopMode(), this can now be implemented using ISoundDevice::GetDeviceCaps().CanKeepDeviceRunning . Modified Paths: -------------- trunk/OpenMPT/mptrack/MainFrm.cpp trunk/OpenMPT/mptrack/Mpdlgs.cpp trunk/OpenMPT/mptrack/Mpdlgs.h trunk/OpenMPT/sounddev/SoundDevice.cpp trunk/OpenMPT/sounddev/SoundDevice.h trunk/OpenMPT/sounddev/SoundDeviceASIO.cpp trunk/OpenMPT/sounddev/SoundDeviceASIO.h trunk/OpenMPT/sounddev/SoundDeviceDirectSound.cpp trunk/OpenMPT/sounddev/SoundDeviceDirectSound.h trunk/OpenMPT/sounddev/SoundDevicePortAudio.cpp trunk/OpenMPT/sounddev/SoundDevicePortAudio.h Modified: trunk/OpenMPT/mptrack/MainFrm.cpp =================================================================== --- trunk/OpenMPT/mptrack/MainFrm.cpp 2014-03-18 10:17:40 UTC (rev 3900) +++ trunk/OpenMPT/mptrack/MainFrm.cpp 2014-03-18 18:53:38 UTC (rev 3901) @@ -252,7 +252,7 @@ // If no mixing rate is specified and we're using ASIO, get a mixing rate supported by the device. if(TrackerSettings::Instance().GetSoundDeviceID().GetType() == SNDDEV_ASIO) { - TrackerSettings::Instance().MixerSamplerate = theApp.GetSoundDevicesManager()->GetDeviceCaps(TrackerSettings::Instance().GetSoundDeviceID(), TrackerSettings::Instance().GetSampleRates(), CMainFrame::GetMainFrame(), CMainFrame::GetMainFrame()->gpSoundDevice).currentSampleRate; + TrackerSettings::Instance().MixerSamplerate = theApp.GetSoundDevicesManager()->GetDeviceDynamicCaps(TrackerSettings::Instance().GetSoundDeviceID(), TrackerSettings::Instance().GetSampleRates(), CMainFrame::GetMainFrame(), CMainFrame::GetMainFrame()->gpSoundDevice).currentSampleRate; } #endif // NO_ASIO } @@ -1215,7 +1215,7 @@ m_NotifyTimer = 0; } ResetNotificationBuffer(); - if(!gpSoundDevice->CanStopMode() || TrackerSettings::Instance().m_SoundSettingsStopMode == SoundDeviceStopModeClosed) + if(!gpSoundDevice->GetDeviceCaps().CanKeepDeviceRunning || TrackerSettings::Instance().m_SoundSettingsStopMode == SoundDeviceStopModeClosed) { audioCloseDevice(); } Modified: trunk/OpenMPT/mptrack/Mpdlgs.cpp =================================================================== --- trunk/OpenMPT/mptrack/Mpdlgs.cpp 2014-03-18 10:17:40 UTC (rev 3900) +++ trunk/OpenMPT/mptrack/Mpdlgs.cpp 2014-03-18 18:53:38 UTC (rev 3901) @@ -123,7 +123,8 @@ //----------------------------------------------------- : CPropertyPage(IDD_OPTIONS_SOUNDCARD) , m_CurrentDeviceInfo(theApp.GetSoundDevicesManager()->FindDeviceInfo(dev)) - , m_CurrentDeviceCaps(theApp.GetSoundDevicesManager()->GetDeviceCaps(dev, TrackerSettings::Instance().GetSampleRates(), CMainFrame::GetMainFrame(), CMainFrame::GetMainFrame()->gpSoundDevice, true)) + , m_CurrentDeviceCaps(theApp.GetSoundDevicesManager()->GetDeviceCaps(dev, CMainFrame::GetMainFrame()->gpSoundDevice)) + , m_CurrentDeviceDynamicCaps(theApp.GetSoundDevicesManager()->GetDeviceDynamicCaps(dev, TrackerSettings::Instance().GetSampleRates(), CMainFrame::GetMainFrame(), CMainFrame::GetMainFrame()->gpSoundDevice, true)) , m_Settings(TrackerSettings::Instance().GetSoundDeviceSettings(dev)) { return; @@ -135,7 +136,8 @@ { bool deviceChanged = (dev != m_CurrentDeviceInfo.id); m_CurrentDeviceInfo = theApp.GetSoundDevicesManager()->FindDeviceInfo(dev); - m_CurrentDeviceCaps = theApp.GetSoundDevicesManager()->GetDeviceCaps(dev, TrackerSettings::Instance().GetSampleRates(), CMainFrame::GetMainFrame(), CMainFrame::GetMainFrame()->gpSoundDevice, true); + m_CurrentDeviceCaps = theApp.GetSoundDevicesManager()->GetDeviceCaps(dev, CMainFrame::GetMainFrame()->gpSoundDevice); + m_CurrentDeviceDynamicCaps = theApp.GetSoundDevicesManager()->GetDeviceDynamicCaps(dev, TrackerSettings::Instance().GetSampleRates(), CMainFrame::GetMainFrame(), CMainFrame::GetMainFrame()->gpSoundDevice, true); if(deviceChanged || forceReload) { m_Settings = TrackerSettings::Instance().GetSoundDeviceSettings(dev); @@ -349,9 +351,9 @@ { m_CbnChannels.ResetContent(); UINT maxChannels = 0; - if(m_CurrentDeviceCaps.channelNames.size() > 0) + if(m_CurrentDeviceDynamicCaps.channelNames.size() > 0) { - maxChannels = std::min<std::size_t>(4, m_CurrentDeviceCaps.channelNames.size()); + maxChannels = std::min<std::size_t>(4, m_CurrentDeviceDynamicCaps.channelNames.size()); } else { maxChannels = 4; @@ -458,9 +460,9 @@ combo->SetCurSel(0); if(mch < usedChannels) { - for(size_t dch = 0; dch < m_CurrentDeviceCaps.channelNames.size(); dch++) // Device channels + for(size_t dch = 0; dch < m_CurrentDeviceDynamicCaps.channelNames.size(); dch++) // Device channels { - const int pos = (int)::SendMessageW(combo->m_hWnd, CB_ADDSTRING, 0, (LPARAM)m_CurrentDeviceCaps.channelNames[dch].c_str()); + const int pos = (int)::SendMessageW(combo->m_hWnd, CB_ADDSTRING, 0, (LPARAM)m_CurrentDeviceDynamicCaps.channelNames[dch].c_str()); combo->SetItemData(pos, (DWORD_PTR)dch); if(dch == m_Settings.ChannelMapping.ToDevice(mch)) { @@ -521,7 +523,7 @@ // find an unused channel bool found = false; std::size_t deviceChannel = 0; - for(; deviceChannel < m_CurrentDeviceCaps.channelNames.size(); ++deviceChannel) + for(; deviceChannel < m_CurrentDeviceDynamicCaps.channelNames.size(); ++deviceChannel) { bool used = false; for(int hostChannel = 0; hostChannel < NUM_CHANNELCOMBOBOXES; ++hostChannel) @@ -559,7 +561,7 @@ { m_CbnMixingFreq.ResetContent(); - std::vector<uint32> samplerates = m_CurrentDeviceCaps.supportedSampleRates; + std::vector<uint32> samplerates = m_CurrentDeviceDynamicCaps.supportedSampleRates; if(samplerates.empty()) { Modified: trunk/OpenMPT/mptrack/Mpdlgs.h =================================================================== --- trunk/OpenMPT/mptrack/Mpdlgs.h 2014-03-18 10:17:40 UTC (rev 3900) +++ trunk/OpenMPT/mptrack/Mpdlgs.h 2014-03-18 18:53:38 UTC (rev 3901) @@ -33,6 +33,7 @@ void SetDevice(SoundDeviceID dev, bool forceReload=false); SoundDeviceInfo m_CurrentDeviceInfo; SoundDeviceCaps m_CurrentDeviceCaps; + SoundDeviceDynamicCaps m_CurrentDeviceDynamicCaps; SoundDeviceSettings m_Settings; public: Modified: trunk/OpenMPT/sounddev/SoundDevice.cpp =================================================================== --- trunk/OpenMPT/sounddev/SoundDevice.cpp 2014-03-18 10:17:40 UTC (rev 3900) +++ trunk/OpenMPT/sounddev/SoundDevice.cpp 2014-03-18 18:53:38 UTC (rev 3901) @@ -147,10 +147,18 @@ } -SoundDeviceCaps ISoundDevice::GetDeviceCaps(const std::vector<uint32> &baseSampleRates) -//------------------------------------------------------------------------------------- +SoundDeviceCaps ISoundDevice::GetDeviceCaps() +//------------------------------------------- { SoundDeviceCaps result; + return result; +} + + +SoundDeviceDynamicCaps ISoundDevice::GetDeviceDynamicCaps(const std::vector<uint32> &baseSampleRates) +//--------------------------------------------------------------------------------------------------- +{ + SoundDeviceDynamicCaps result; result.supportedSampleRates = baseSampleRates; return result; } @@ -585,21 +593,20 @@ } -SoundDeviceCaps SoundDevicesManager::GetDeviceCaps(SoundDeviceID id, const std::vector<uint32> &baseSampleRates, ISoundMessageReceiver *messageReceiver, ISoundDevice *currentSoundDevice, bool update) -//----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- +SoundDeviceCaps SoundDevicesManager::GetDeviceCaps(SoundDeviceID id, ISoundDevice *currentSoundDevice) +//---------------------------------------------------------------------------------------------------- { - if((m_DeviceCaps.find(id) == m_DeviceCaps.end()) || update) + if(m_DeviceCaps.find(id) == m_DeviceCaps.end()) { if(currentSoundDevice && FindDeviceInfo(id).IsValid() && (currentSoundDevice->GetDeviceID() == id) && (currentSoundDevice->GetDeviceInternalID() == FindDeviceInfo(id).internalID)) { - m_DeviceCaps[id] = currentSoundDevice->GetDeviceCaps(baseSampleRates); + m_DeviceCaps[id] = currentSoundDevice->GetDeviceCaps(); } else { ISoundDevice *dummy = CreateSoundDevice(id); if(dummy) { - dummy->SetMessageReceiver(messageReceiver); - m_DeviceCaps[id] = dummy->GetDeviceCaps(baseSampleRates); + m_DeviceCaps[id] = dummy->GetDeviceCaps(); } delete dummy; } @@ -608,6 +615,29 @@ } +SoundDeviceDynamicCaps SoundDevicesManager::GetDeviceDynamicCaps(SoundDeviceID id, const std::vector<uint32> &baseSampleRates, ISoundMessageReceiver *messageReceiver, ISoundDevice *currentSoundDevice, bool update) +//------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- +{ + if((m_DeviceDynamicCaps.find(id) == m_DeviceDynamicCaps.end()) || update) + { + if(currentSoundDevice && FindDeviceInfo(id).IsValid() && (currentSoundDevice->GetDeviceID() == id) && (currentSoundDevice->GetDeviceInternalID() == FindDeviceInfo(id).internalID)) + { + m_DeviceDynamicCaps[id] = currentSoundDevice->GetDeviceDynamicCaps(baseSampleRates); + } else + { + ISoundDevice *dummy = CreateSoundDevice(id); + if(dummy) + { + dummy->SetMessageReceiver(messageReceiver); + m_DeviceDynamicCaps[id] = dummy->GetDeviceDynamicCaps(baseSampleRates); + } + delete dummy; + } + } + return m_DeviceDynamicCaps[id]; +} + + ISoundDevice * SoundDevicesManager::CreateSoundDevice(SoundDeviceID id) //--------------------------------------------------------------------- { Modified: trunk/OpenMPT/sounddev/SoundDevice.h =================================================================== --- trunk/OpenMPT/sounddev/SoundDevice.h 2014-03-18 10:17:40 UTC (rev 3900) +++ trunk/OpenMPT/sounddev/SoundDevice.h 2014-03-18 18:53:38 UTC (rev 3901) @@ -322,9 +322,6 @@ struct SoundDeviceCaps { - uint32 currentSampleRate; - std::vector<uint32> supportedSampleRates; // Which samplerates are actually supported by the device. Currently only implemented properly for ASIO, DirectSound and PortAudio. - std::vector<std::wstring> channelNames; bool CanUpdateInterval; bool CanSampleFormat; bool CanExclusiveMode; @@ -336,8 +333,7 @@ bool HasInternalDither; std::wstring ExclusiveModeDescription; SoundDeviceCaps() - : currentSampleRate(0) - , CanUpdateInterval(true) + : CanUpdateInterval(true) , CanSampleFormat(true) , CanExclusiveMode(false) , CanBoostThreadPriority(true) @@ -353,6 +349,19 @@ }; +struct SoundDeviceDynamicCaps +{ + uint32 currentSampleRate; + std::vector<uint32> supportedSampleRates; // Which samplerates are actually supported by the device. Currently only implemented properly for ASIO, DirectSound and PortAudio. + std::vector<std::wstring> channelNames; + SoundDeviceDynamicCaps() + : currentSampleRate(0) + { + return; + } +}; + + class SoundDevicesManager; @@ -465,8 +474,8 @@ SoundDeviceIndex GetDeviceIndex() const { return m_ID.GetIndex(); } std::wstring GetDeviceInternalID() const { return m_InternalID; } - virtual SoundDeviceCaps GetDeviceCaps(const std::vector<uint32> &baseSampleRates); - virtual bool CanStopMode() const { return false; } + virtual SoundDeviceCaps GetDeviceCaps(); + virtual SoundDeviceDynamicCaps GetDeviceDynamicCaps(const std::vector<uint32> &baseSampleRates); bool Open(const SoundDeviceSettings &settings); bool Close(); @@ -555,6 +564,7 @@ private: std::vector<SoundDeviceInfo> m_SoundDevices; std::map<SoundDeviceID, SoundDeviceCaps> m_DeviceCaps; + std::map<SoundDeviceID, SoundDeviceDynamicCaps> m_DeviceDynamicCaps; public: SoundDevicesManager(); @@ -574,7 +584,8 @@ bool OpenDriverSettings(SoundDeviceID id, ISoundMessageReceiver *messageReceiver = nullptr, ISoundDevice *currentSoundDevice = nullptr); - SoundDeviceCaps GetDeviceCaps(SoundDeviceID id, const std::vector<uint32> &baseSampleRates, ISoundMessageReceiver *messageReceiver = nullptr, ISoundDevice *currentSoundDevice = nullptr, bool update = false); + SoundDeviceCaps GetDeviceCaps(SoundDeviceID id, ISoundDevice *currentSoundDevice = nullptr); + SoundDeviceDynamicCaps GetDeviceDynamicCaps(SoundDeviceID id, const std::vector<uint32> &baseSampleRates, ISoundMessageReceiver *messageReceiver = nullptr, ISoundDevice *currentSoundDevice = nullptr, bool update = false); ISoundDevice * CreateSoundDevice(SoundDeviceID id); Modified: trunk/OpenMPT/sounddev/SoundDeviceASIO.cpp =================================================================== --- trunk/OpenMPT/sounddev/SoundDeviceASIO.cpp 2014-03-18 10:17:40 UTC (rev 3900) +++ trunk/OpenMPT/sounddev/SoundDeviceASIO.cpp 2014-03-18 18:53:38 UTC (rev 3901) @@ -1311,8 +1311,8 @@ } -SoundDeviceCaps CASIODevice::GetDeviceCaps(const std::vector<uint32> &baseSampleRates) -//------------------------------------------------------------------------------------ +SoundDeviceCaps CASIODevice::GetDeviceCaps() +//------------------------------------------ { SoundDeviceCaps caps; @@ -1325,6 +1325,15 @@ caps.CanChannelMapping = true; caps.CanDriverPanel = true; + return caps; +} + + +SoundDeviceDynamicCaps CASIODevice::GetDeviceDynamicCaps(const std::vector<uint32> &baseSampleRates) +//-------------------------------------------------------------------------------------------------- +{ + SoundDeviceDynamicCaps caps; + TemporaryASIODriverOpener opener(*this); if(!IsDriverOpen()) { Modified: trunk/OpenMPT/sounddev/SoundDeviceASIO.h =================================================================== --- trunk/OpenMPT/sounddev/SoundDeviceASIO.h 2014-03-18 10:17:40 UTC (rev 3900) +++ trunk/OpenMPT/sounddev/SoundDeviceASIO.h 2014-03-18 18:53:38 UTC (rev 3901) @@ -108,8 +108,8 @@ bool OnIdle() { return HandleRequests(); } - SoundDeviceCaps GetDeviceCaps(const std::vector<uint32> &baseSampleRates); - bool CanStopMode() const { return true; } + SoundDeviceCaps GetDeviceCaps(); + SoundDeviceDynamicCaps GetDeviceDynamicCaps(const std::vector<uint32> &baseSampleRates); bool OpenDriverSettings(); Modified: trunk/OpenMPT/sounddev/SoundDeviceDirectSound.cpp =================================================================== --- trunk/OpenMPT/sounddev/SoundDeviceDirectSound.cpp 2014-03-18 10:17:40 UTC (rev 3900) +++ trunk/OpenMPT/sounddev/SoundDeviceDirectSound.cpp 2014-03-18 18:53:38 UTC (rev 3901) @@ -110,8 +110,8 @@ } -SoundDeviceCaps CDSoundDevice::GetDeviceCaps(const std::vector<uint32> &baseSampleRates) -//-------------------------------------------------------------------------------------- +SoundDeviceCaps CDSoundDevice::GetDeviceCaps() +//-------------------------------------------- { SoundDeviceCaps caps; caps.CanUpdateInterval = true; @@ -122,6 +122,14 @@ caps.CanChannelMapping = false; caps.CanDriverPanel = false; caps.ExclusiveModeDescription = L"Use primary buffer"; + return caps; +} + + +SoundDeviceDynamicCaps CDSoundDevice::GetDeviceDynamicCaps(const std::vector<uint32> &baseSampleRates) +//---------------------------------------------------------------------------------------------------- +{ + SoundDeviceDynamicCaps caps; IDirectSound *dummy = nullptr; IDirectSound *ds = nullptr; if(m_piDS) Modified: trunk/OpenMPT/sounddev/SoundDeviceDirectSound.h =================================================================== --- trunk/OpenMPT/sounddev/SoundDeviceDirectSound.h 2014-03-18 10:17:40 UTC (rev 3900) +++ trunk/OpenMPT/sounddev/SoundDeviceDirectSound.h 2014-03-18 18:53:38 UTC (rev 3901) @@ -48,7 +48,8 @@ void StopFromSoundThread(); bool InternalIsOpen() const { return (m_pMixBuffer != NULL); } double GetCurrentLatency() const { return 1.0 * m_dwLatency / m_Settings.GetBytesPerSecond(); } - SoundDeviceCaps GetDeviceCaps(const std::vector<uint32> &baseSampleRates); + SoundDeviceCaps GetDeviceCaps(); + SoundDeviceDynamicCaps GetDeviceDynamicCaps(const std::vector<uint32> &baseSampleRates); protected: DWORD LockBuffer(DWORD dwBytes, LPVOID *lpBuf1, LPDWORD lpSize1, LPVOID *lpBuf2, LPDWORD lpSize2); Modified: trunk/OpenMPT/sounddev/SoundDevicePortAudio.cpp =================================================================== --- trunk/OpenMPT/sounddev/SoundDevicePortAudio.cpp 2014-03-18 10:17:40 UTC (rev 3900) +++ trunk/OpenMPT/sounddev/SoundDevicePortAudio.cpp 2014-03-18 18:53:38 UTC (rev 3901) @@ -194,8 +194,8 @@ } -SoundDeviceCaps CPortaudioDevice::GetDeviceCaps(const std::vector<uint32> &baseSampleRates) -//----------------------------------------------------------------------------------------- +SoundDeviceCaps CPortaudioDevice::GetDeviceCaps() +//----------------------------------------------- { SoundDeviceCaps caps; caps.CanUpdateInterval = true; @@ -214,6 +214,14 @@ { caps.CanUpdateInterval = false; } + return caps; +} + + +SoundDeviceDynamicCaps CPortaudioDevice::GetDeviceDynamicCaps(const std::vector<uint32> &baseSampleRates) +//------------------------------------------------------------------------------------------------------- +{ + SoundDeviceDynamicCaps caps; PaDeviceIndex device = HostApiOutputIndexToGlobalDeviceIndex(GetDeviceIndex(), m_HostApi); if(device == -1) { Modified: trunk/OpenMPT/sounddev/SoundDevicePortAudio.h =================================================================== --- trunk/OpenMPT/sounddev/SoundDevicePortAudio.h 2014-03-18 10:17:40 UTC (rev 3900) +++ trunk/OpenMPT/sounddev/SoundDevicePortAudio.h 2014-03-18 18:53:38 UTC (rev 3901) @@ -53,7 +53,8 @@ double GetCurrentLatency() const; bool InternalHasGetStreamPosition() const { return false; } int64 InternalGetStreamPositionFrames() const; - SoundDeviceCaps GetDeviceCaps(const std::vector<uint32> &baseSampleRates); + SoundDeviceCaps GetDeviceCaps(); + SoundDeviceDynamicCaps GetDeviceDynamicCaps(const std::vector<uint32> &baseSampleRates); bool OpenDriverSettings(); int StreamCallback( This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <sag...@us...> - 2014-03-19 02:18:07
|
Revision: 3906 http://sourceforge.net/p/modplug/code/3906 Author: saga-games Date: 2014-03-19 02:17:58 +0000 (Wed, 19 Mar 2014) Log Message: ----------- Apparently TSVN got confused and some files were not marked as modified, thus were missing in the previous commit... [Reg] Removed native JBridge support. [Mod] OpenMPT: Version is now 1.22.07.31 Modified Paths: -------------- trunk/OpenMPT/common/versionNumber.h trunk/OpenMPT/mptrack/Vstplug.h trunk/OpenMPT/soundlib/plugins/PlugInterface.h trunk/OpenMPT/soundlib/plugins/PluginManager.cpp Removed Paths: ------------- trunk/OpenMPT/soundlib/plugins/JBridge.cpp trunk/OpenMPT/soundlib/plugins/JBridge.h Modified: trunk/OpenMPT/common/versionNumber.h =================================================================== --- trunk/OpenMPT/common/versionNumber.h 2014-03-19 02:06:01 UTC (rev 3905) +++ trunk/OpenMPT/common/versionNumber.h 2014-03-19 02:17:58 UTC (rev 3906) @@ -17,7 +17,7 @@ #define VER_MAJORMAJOR 1 #define VER_MAJOR 22 #define VER_MINOR 07 -#define VER_MINORMINOR 30 +#define VER_MINORMINOR 31 //Version string. For example "1.17.02.28" #define MPT_VERSION_STR VER_STRINGIZE(VER_MAJORMAJOR) "." VER_STRINGIZE(VER_MAJOR) "." VER_STRINGIZE(VER_MINOR) "." VER_STRINGIZE(VER_MINORMINOR) Modified: trunk/OpenMPT/mptrack/Vstplug.h =================================================================== --- trunk/OpenMPT/mptrack/Vstplug.h 2014-03-19 02:06:01 UTC (rev 3905) +++ trunk/OpenMPT/mptrack/Vstplug.h 2014-03-19 02:17:58 UTC (rev 3906) @@ -80,7 +80,7 @@ // Check whether a plugin can be hosted inside OpenMPT or requires bridging int8 GetDllBits(); - bool IsNative() { return GetDllBits() == sizeof(void *); } + bool IsNative() { return GetDllBits() == sizeof(void *) * 8; } void WriteToCache() const; Deleted: trunk/OpenMPT/soundlib/plugins/JBridge.cpp =================================================================== --- trunk/OpenMPT/soundlib/plugins/JBridge.cpp 2014-03-19 02:06:01 UTC (rev 3905) +++ trunk/OpenMPT/soundlib/plugins/JBridge.cpp 2014-03-19 02:17:58 UTC (rev 3906) @@ -1,113 +0,0 @@ -/* - * JBridge.cpp - * ----------- - * Purpose: Native support for the JBridge VST plugin bridge. - * Notes : (currently none) - * Authors: OpenMPT Devs - * Bridge code borrowed from http://jstuff.wordpress.com/jbridge/how-to-add-direct-support-for-jbridge-in-your-host/ - * The OpenMPT source code is released under the BSD license. Read LICENSE for more details. - */ - - -#include "stdafx.h" - -#include "JBridge.h" - -#ifdef ENABLE_JBRIDGE - -#include <pluginterfaces/vst2.x/aeffectx.h> - -namespace JBridge -{ - -// Name of the proxy DLL to load -static const char *proxyRegKey = "Software\\JBridge"; - -#ifdef _M_X64 -static const char *proxyRegVal = "Proxy64"; //use this for x64 builds -static_assert(sizeof(void *) == 8, "Wrong platform!"); -#else -static const char *proxyRegVal = "Proxy32"; //use this for x86 builds -static_assert(sizeof(void *) == 4, "Wrong platform!"); -#endif - -// Typedef for BridgeMain proc -typedef AEffect * (*PFNBRIDGEMAIN)(audioMasterCallback audioMaster, const char *pluginPath); - - -//Check if it's a plugin_name.xx.dll -bool IsBootStrapDll(const mpt::PathString &path) -//---------------------------------------------- -{ - bool ret = false; - - HMODULE hModule = LoadLibraryW(path.ToWide().c_str()); - if(!hModule) - { - // Some error... - return ret; - } - - //Exported dummy function to identify this as a bootstrap dll. - if(GetProcAddress(hModule, "JBridgeBootstrap")) - { - //it's a bootstrap dll - ret = true; - } - - FreeLibrary(hModule); - - return ret; -} - - -AEffect *LoadBridgedPlugin(audioMasterCallback audioMaster, const mpt::PathString &pluginPath) -//-------------------------------------------------------------------------------------------- -{ - // Ignore JBridge bootstrap DLLs - if(IsBootStrapDll(pluginPath)) - { - return nullptr; - } - - // Get path to JBridge proxy - char proxyPath[MAX_PATH]; - proxyPath[0] = '\0'; - HKEY hKey; - if(RegOpenKey(HKEY_LOCAL_MACHINE, proxyRegKey, &hKey) == ERROR_SUCCESS) - { - DWORD dw = sizeof(proxyPath); - RegQueryValueEx(hKey, proxyRegVal, nullptr, nullptr, reinterpret_cast<LPBYTE>(proxyPath), &dw); - RegCloseKey(hKey); - } - - // Check key found and file exists - if(proxyPath[0] == '\0') - { - //MessageBox(GetActiveWindow(), "Unable to locate proxy DLL", "Warning", MB_OK | MB_ICONHAND); - return nullptr; - } - - // Load proxy DLL - HMODULE hModuleProxy = LoadLibrary(proxyPath); - if(!hModuleProxy) - { - //MessageBox(GetActiveWindow(), "Failed to load proxy", "Warning", MB_OK | MB_ICONHAND); - return nullptr; - } - - // Get entry point - PFNBRIDGEMAIN pfnBridgeMain = (PFNBRIDGEMAIN)GetProcAddress(hModuleProxy, "BridgeMain"); - if(pfnBridgeMain == nullptr) - { - FreeLibrary(hModuleProxy); - //MessageBox(GetActiveWindow(), "BridgeMain entry point not found", "JBridge", MB_OK | MB_ICONHAND); - return nullptr; - } - - return pfnBridgeMain(audioMaster, pluginPath.ToLocale().c_str()); -} - -} - -#endif // ENABLE_JBRIDGE Deleted: trunk/OpenMPT/soundlib/plugins/JBridge.h =================================================================== --- trunk/OpenMPT/soundlib/plugins/JBridge.h 2014-03-19 02:06:01 UTC (rev 3905) +++ trunk/OpenMPT/soundlib/plugins/JBridge.h 2014-03-19 02:17:58 UTC (rev 3906) @@ -1,25 +0,0 @@ -/* - * JBridge.h - * --------- - * Purpose: Native support for the JBridge VST plugin bridge. - * Notes : (currently none) - * Authors: OpenMPT Devs - * The OpenMPT source code is released under the BSD license. Read LICENSE for more details. - */ - - -#pragma once - -#if !defined(NO_VST) && (defined(WIN32) || (defined(WINDOWS) && WINDOWS == 1)) -#define ENABLE_JBRIDGE -#include <pluginterfaces/vst2.x/aeffectx.h> -#endif - -namespace JBridge -{ -#ifdef ENABLE_JBRIDGE - AEffect *LoadBridgedPlugin(audioMasterCallback audioMaster, const mpt::PathString &pluginPath); -#else - inline void *LoadBridgedPlugin(void *, const mpt::PathString &) { return nullptr; } -#endif // ENABLE_JBRIDGE -} Modified: trunk/OpenMPT/soundlib/plugins/PlugInterface.h =================================================================== --- trunk/OpenMPT/soundlib/plugins/PlugInterface.h 2014-03-19 02:06:01 UTC (rev 3905) +++ trunk/OpenMPT/soundlib/plugins/PlugInterface.h 2014-03-19 02:17:58 UTC (rev 3906) @@ -60,7 +60,7 @@ virtual void AutomateParameter(PlugParamIndex param) = 0; virtual VstIntPtr Dispatch(VstInt32 opCode, VstInt32 index, VstIntPtr value, void *ptr, float opt) =0; //rewbs.VSTCompliance virtual void NotifySongPlaying(bool) = 0; //rewbs.VSTCompliance - virtual bool IsSongPlaying() = 0; + virtual bool IsSongPlaying() const = 0; virtual bool IsResumed() = 0; virtual void Resume() = 0; virtual void Suspend() = 0; Modified: trunk/OpenMPT/soundlib/plugins/PluginManager.cpp =================================================================== --- trunk/OpenMPT/soundlib/plugins/PluginManager.cpp 2014-03-19 02:06:01 UTC (rev 3905) +++ trunk/OpenMPT/soundlib/plugins/PluginManager.cpp 2014-03-19 02:17:58 UTC (rev 3906) @@ -19,7 +19,7 @@ #include "../../common/AudioCriticalSection.h" #include "../../common/StringFixer.h" #include "../Sndfile.h" -#include "JBridge.h" +#include "../../pluginBridge/BridgeWrapper.h" // For CRC32 calculation (to tell plugins with same UID apart in our cache file) #if !defined(NO_ZLIB) @@ -44,30 +44,41 @@ static const wchar_t *const cacheSectionW = L"PluginCache"; +int8 VSTPluginLib::GetDllBits() +//----------------------------- +{ + if(dllBits == -1) + { + dllBits = BridgeWrapper::IsPluginNative(dllPath) * 8; + } + return dllBits != 0; +} + + // PluginCache format: // LibraryName = <ID1><ID2><CRC32> (hex-encoded) // <ID1><ID2><CRC32> = FullDllPath // <ID1><ID2><CRC32>.Flags = Plugin Flags (set VSTPluginLib::DecodeCacheFlags). -static void WriteToCache(const VSTPluginLib &lib) -//----------------------------------------------- +void VSTPluginLib::WriteToCache() const +//------------------------------------- { SettingsContainer &cacheFile = theApp.GetPluginCache(); - const std::string libName = lib.libraryName.ToUTF8(); + const std::string libName = libraryName.ToUTF8(); const uint32 crc = crc32(0, reinterpret_cast<const Bytef *>(&libName[0]), libName.length()); - const std::string IDs = mpt::String::Format("%08X%08X%08X", SwapBytesReturnLE(lib.pluginId1), SwapBytesReturnLE(lib.pluginId2), SwapBytesReturnLE(crc)); + const std::string IDs = mpt::String::Format("%08X%08X%08X", SwapBytesReturnLE(pluginId1), SwapBytesReturnLE(pluginId2), SwapBytesReturnLE(crc)); const std::string flagsKey = IDs + ".Flags"; - mpt::PathString writePath = lib.dllPath; + mpt::PathString writePath = dllPath; if(theApp.IsPortableMode()) { writePath = theApp.AbsolutePathToRelative(writePath); } - cacheFile.Write<std::string>(cacheSectionW, lib.libraryName.ToWide(), IDs); + cacheFile.Write<std::string>(cacheSectionW, libraryName.ToWide(), IDs); cacheFile.Write<mpt::PathString>(cacheSection, IDs, writePath); - cacheFile.Write<int32>(cacheSection, flagsKey, lib.EncodeCacheFlags()); + cacheFile.Write<int32>(cacheSection, flagsKey, EncodeCacheFlags()); } @@ -180,12 +191,23 @@ } -AEffect *CVstPluginManager::LoadPlugin(const mpt::PathString &pluginPath, HINSTANCE &library) -//------------------------------------------------------------------------------------------- +AEffect *CVstPluginManager::LoadPlugin(const VSTPluginLib &plugin, HINSTANCE &library, bool forceBridge) +//------------------------------------------------------------------------------------------------------ { + const mpt::PathString &pluginPath = plugin.dllPath; + AEffect *effect = nullptr; library = nullptr; + if(forceBridge || plugin.useBridge || !BridgeWrapper::IsPluginNative(pluginPath)) + { + effect = BridgeWrapper::Create(plugin); + if(effect != nullptr) + { + return effect; + } + } + try { library = LoadLibraryW(pluginPath.AsNative().c_str()); @@ -205,7 +227,7 @@ if(error == ERROR_MOD_NOT_FOUND) { - // No point in trying with JBride, either... + // No point in trying bridging, either... return nullptr; } } @@ -236,10 +258,11 @@ if(effect == nullptr) { - // Try loading the plugin using JBridge instead. + // Re-try loading the plugin using our bridge instead. FreeLibrary(library); library = nullptr; - effect = JBridge::LoadBridgedPlugin(MasterCallBack, pluginPath); + + effect = BridgeWrapper::Create(plugin); } return effect; } @@ -350,7 +373,8 @@ try { - pEffect = LoadPlugin(dllPath, hLib); + // Always scan plugins in a separate process + pEffect = LoadPlugin(*plug, hLib, true); if(pEffect != nullptr && pEffect->magic == kEffectMagic && pEffect->dispatcher != nullptr) { @@ -389,7 +413,7 @@ if(validPlug) { pluginList.push_back(plug); - WriteToCache(*plug); + plug->WriteToCache(); } else { delete plug; @@ -511,7 +535,7 @@ try { - pEffect = LoadPlugin(pFound->dllPath, hLibrary); + pEffect = LoadPlugin(*pFound, hLibrary, TrackerSettings::Instance().bridgeAllPlugins); if(pEffect != nullptr && pEffect->dispatcher != nullptr && pEffect->magic == kEffectMagic) { @@ -525,7 +549,7 @@ if(oldIsInstrument != pFound->isInstrument || oldCategory != pFound->category) { // Update cached information - WriteToCache(*pFound); + pFound->WriteToCache(); } CVstPlugin *pVstPlug = new (std::nothrow) CVstPlugin(hLibrary, *pFound, mixPlugin, *pEffect, sndFile); @@ -561,6 +585,7 @@ { for(const_iterator pFactory = begin(); pFactory != end(); pFactory++) { + // Note: bridged plugins won't receive these messages and generate their own idle messages. CVstPlugin *p = (**pFactory).pPluginsList; while (p) { @@ -571,13 +596,14 @@ p->m_bNeedIdle=false; } //We need to update all open editors - if ((p->m_pEditor) && (p->m_pEditor->m_hWnd)) + CAbstractVstEditor *editor = p->GetEditor(); + if (editor && editor->m_hWnd) { - p->m_pEditor->UpdateParamDisplays(); + editor->UpdateParamDisplays(); } //end rewbs. VSTCompliance: - p = p->m_pNext; + p = p->GetNextInstance(); } } This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <sag...@us...> - 2014-03-19 02:30:04
|
Revision: 3907 http://sourceforge.net/p/modplug/code/3907 Author: saga-games Date: 2014-03-19 02:29:56 +0000 (Wed, 19 Mar 2014) Log Message: ----------- [Fix] This bitness detection stuff was all backwards. [Mod] Changed plugin manager's default size to be more sensible. Modified Paths: -------------- trunk/OpenMPT/mptrack/TrackerSettings.cpp trunk/OpenMPT/pluginBridge/BridgeWrapper.h trunk/OpenMPT/soundlib/plugins/PluginManager.cpp Modified: trunk/OpenMPT/mptrack/TrackerSettings.cpp =================================================================== --- trunk/OpenMPT/mptrack/TrackerSettings.cpp 2014-03-19 02:17:58 UTC (rev 3906) +++ trunk/OpenMPT/mptrack/TrackerSettings.cpp 2014-03-19 02:29:56 UTC (rev 3907) @@ -147,8 +147,8 @@ , glGraphWindowHeight(conf, "Display", "MDIGraphHeight", 288) , gnPlugWindowX(conf, "Display", "PlugSelectWindowX", 243) , gnPlugWindowY(conf, "Display", "PlugSelectWindowY", 273) - , gnPlugWindowWidth(conf, "Display", "PlugSelectWindowWidth", 370) - , gnPlugWindowHeight(conf, "Display", "PlugSelectWindowHeight", 332) + , gnPlugWindowWidth(conf, "Display", "PlugSelectWindowWidth", 400) + , gnPlugWindowHeight(conf, "Display", "PlugSelectWindowHeight", 450) , gnPlugWindowLast(conf, "Display", "PlugSelectWindowLast", 0) , gnMsgBoxVisiblityFlags(conf, "Display", "MDIGraphHeight", uint32_max) , GUIUpdateInterval(conf, "Display", "GUIUpdateInterval", 0) Modified: trunk/OpenMPT/pluginBridge/BridgeWrapper.h =================================================================== --- trunk/OpenMPT/pluginBridge/BridgeWrapper.h 2014-03-19 02:17:58 UTC (rev 3906) +++ trunk/OpenMPT/pluginBridge/BridgeWrapper.h 2014-03-19 02:29:56 UTC (rev 3907) @@ -24,13 +24,13 @@ enum BinaryType { binUnknown = 0, - bin32Bit = 4, - bin64Bit = 8, + bin32Bit = 32, + bin64Bit = 64, }; public: static BinaryType GetPluginBinaryType(const mpt::PathString &pluginPath); - static bool IsPluginNative(const mpt::PathString &pluginPath) { return GetPluginBinaryType(pluginPath) == sizeof(void *); } + static bool IsPluginNative(const mpt::PathString &pluginPath) { return GetPluginBinaryType(pluginPath) == sizeof(void *) * 8; } static uint64 GetFileVersion(const WCHAR *exePath); static AEffect *Create(const VSTPluginLib &plugin); Modified: trunk/OpenMPT/soundlib/plugins/PluginManager.cpp =================================================================== --- trunk/OpenMPT/soundlib/plugins/PluginManager.cpp 2014-03-19 02:17:58 UTC (rev 3906) +++ trunk/OpenMPT/soundlib/plugins/PluginManager.cpp 2014-03-19 02:29:56 UTC (rev 3907) @@ -49,7 +49,7 @@ { if(dllBits == -1) { - dllBits = BridgeWrapper::IsPluginNative(dllPath) * 8; + dllBits = BridgeWrapper::GetPluginBinaryType(dllPath) * 8; } return dllBits != 0; } This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <sag...@us...> - 2014-03-19 02:36:56
|
Revision: 3909 http://sourceforge.net/p/modplug/code/3909 Author: saga-games Date: 2014-03-19 02:36:50 +0000 (Wed, 19 Mar 2014) Log Message: ----------- [Fix] I will test my stuff before I commit. I will test my stuff before I commit. I will test my stuff before I commit. I will test my stuff before I commit. I will test my stuff before I commit. Modified Paths: -------------- trunk/OpenMPT/mptrack/Vstplug.h trunk/OpenMPT/soundlib/plugins/PluginManager.cpp Modified: trunk/OpenMPT/mptrack/Vstplug.h =================================================================== --- trunk/OpenMPT/mptrack/Vstplug.h 2014-03-19 02:31:21 UTC (rev 3908) +++ trunk/OpenMPT/mptrack/Vstplug.h 2014-03-19 02:36:50 UTC (rev 3909) @@ -65,7 +65,7 @@ bool isInstrument; bool useBridge, shareBridgeInstance; protected: - int8 dllBits; + uint8 dllBits; public: VSTPluginLib(const mpt::PathString &dllPath, const mpt::PathString &libraryName) @@ -74,12 +74,12 @@ pluginId1(0), pluginId2(0), category(catUnknown), isInstrument(false), useBridge(false), shareBridgeInstance(false), - dllBits(-1) + dllBits(0) { } // Check whether a plugin can be hosted inside OpenMPT or requires bridging - int8 GetDllBits(); + uint8 GetDllBits(); bool IsNative() { return GetDllBits() == sizeof(void *) * 8; } void WriteToCache() const; Modified: trunk/OpenMPT/soundlib/plugins/PluginManager.cpp =================================================================== --- trunk/OpenMPT/soundlib/plugins/PluginManager.cpp 2014-03-19 02:31:21 UTC (rev 3908) +++ trunk/OpenMPT/soundlib/plugins/PluginManager.cpp 2014-03-19 02:36:50 UTC (rev 3909) @@ -44,14 +44,14 @@ static const wchar_t *const cacheSectionW = L"PluginCache"; -int8 VSTPluginLib::GetDllBits() -//----------------------------- +uint8 VSTPluginLib::GetDllBits() +//------------------------------ { - if(dllBits == -1) + if(!dllBits) { - dllBits = BridgeWrapper::GetPluginBinaryType(dllPath); + dllBits = static_cast<uint8>(BridgeWrapper::GetPluginBinaryType(dllPath)); } - return dllBits != 0; + return dllBits; } This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <man...@us...> - 2014-03-19 11:58:54
|
Revision: 3912 http://sourceforge.net/p/modplug/code/3912 Author: manxorist Date: 2014-03-19 11:58:47 +0000 (Wed, 19 Mar 2014) Log Message: ----------- [New] Add separate solution file for PluginBridge alone. [Imp] build: Add PluginBridge32.exe and PluginBridge64.exe to buildbot-generated packages. Modified Paths: -------------- trunk/OpenMPT/build/auto/package_openmpt_win32.cmd trunk/OpenMPT/build/auto/package_openmpt_win64.cmd trunk/OpenMPT/build/auto/vs2010_openmpt_win32.cmd trunk/OpenMPT/build/auto/vs2010_openmpt_win64.cmd Added Paths: ----------- trunk/OpenMPT/pluginBridge/PluginBridge.sln Property Changed: ---------------- trunk/OpenMPT/pluginBridge/ Modified: trunk/OpenMPT/build/auto/package_openmpt_win32.cmd =================================================================== --- trunk/OpenMPT/build/auto/package_openmpt_win32.cmd 2014-03-19 11:52:36 UTC (rev 3911) +++ trunk/OpenMPT/build/auto/package_openmpt_win32.cmd 2014-03-19 11:58:47 UTC (rev 3912) @@ -9,7 +9,7 @@ del /f /q openmpt-win32.tar del /f /q openmpt-win32-r%GOT_REVISION%.7z copy /y ..\..\LICENSE .\ || goto error -"C:\Program Files\7-Zip\7z.exe" a -t7z -mx=9 openmpt-win32-r%GOT_REVISION%.7z mptrack.exe OpenMPT_SoundTouch_f32.dll "MIDI Input Output.dll" LICENSE || goto error +"C:\Program Files\7-Zip\7z.exe" a -t7z -mx=9 openmpt-win32-r%GOT_REVISION%.7z mptrack.exe OpenMPT_SoundTouch_f32.dll "MIDI Input Output.dll" PluginBridge32.exe PluginBridge64.exe LICENSE || goto error "C:\Program Files\7-Zip\7z.exe" a -ttar openmpt-win32.tar openmpt-win32-r%GOT_REVISION%.7z || goto error del /f /q openmpt-win32-r%GOT_REVISION%.7z cd ..\.. || goto error Modified: trunk/OpenMPT/build/auto/package_openmpt_win64.cmd =================================================================== --- trunk/OpenMPT/build/auto/package_openmpt_win64.cmd 2014-03-19 11:52:36 UTC (rev 3911) +++ trunk/OpenMPT/build/auto/package_openmpt_win64.cmd 2014-03-19 11:58:47 UTC (rev 3912) @@ -9,7 +9,7 @@ del /f /q openmpt-win64.tar del /f /q openmpt-win64-r%GOT_REVISION%.7z copy /y ..\..\LICENSE .\ || goto error -"C:\Program Files\7-Zip\7z.exe" a -t7z -mx=9 openmpt-win64-r%GOT_REVISION%.7z mptrack.exe OpenMPT_SoundTouch_f32.dll "MIDI Input Output.dll" LICENSE || goto error +"C:\Program Files\7-Zip\7z.exe" a -t7z -mx=9 openmpt-win64-r%GOT_REVISION%.7z mptrack.exe OpenMPT_SoundTouch_f32.dll "MIDI Input Output.dll" PluginBridge32.exe PluginBridge64.exe LICENSE || goto error "C:\Program Files\7-Zip\7z.exe" a -ttar openmpt-win64.tar openmpt-win64-r%GOT_REVISION%.7z || goto error del /f /q openmpt-win64-r%GOT_REVISION%.7z cd ..\.. || goto error Modified: trunk/OpenMPT/build/auto/vs2010_openmpt_win32.cmd =================================================================== --- trunk/OpenMPT/build/auto/vs2010_openmpt_win32.cmd 2014-03-19 11:52:36 UTC (rev 3911) +++ trunk/OpenMPT/build/auto/vs2010_openmpt_win32.cmd 2014-03-19 11:58:47 UTC (rev 3912) @@ -10,8 +10,17 @@ cd mptrack || goto error devenv MPTRACK_10.sln /clean "Release|Win32" || goto error +cd .. || goto error +cd pluginBridge || goto error +devenv PluginBridge.sln /clean "Release|x64" || goto error +cd .. || goto error + +cd mptrack || goto error devenv MPTRACK_10.sln /build "Release|Win32" || goto error cd .. || goto error +cd pluginBridge || goto error +devenv PluginBridge.sln /build "Release|x64" || goto error +cd .. || goto error Modified: trunk/OpenMPT/build/auto/vs2010_openmpt_win64.cmd =================================================================== --- trunk/OpenMPT/build/auto/vs2010_openmpt_win64.cmd 2014-03-19 11:52:36 UTC (rev 3911) +++ trunk/OpenMPT/build/auto/vs2010_openmpt_win64.cmd 2014-03-19 11:58:47 UTC (rev 3912) @@ -10,8 +10,17 @@ cd mptrack || goto error devenv MPTRACK_10.sln /clean "Release|x64" || goto error +cd .. || goto error +cd pluginBridge || goto error +devenv PluginBridge.sln /clean "Release|Win32" || goto error +cd .. || goto error + +cd mptrack || goto error devenv MPTRACK_10.sln /build "Release|x64" || goto error cd .. || goto error +cd pluginBridge || goto error +devenv PluginBridge.sln /build "Release|Win32" || goto error +cd .. || goto error Index: trunk/OpenMPT/pluginBridge =================================================================== --- trunk/OpenMPT/pluginBridge 2014-03-19 11:52:36 UTC (rev 3911) +++ trunk/OpenMPT/pluginBridge 2014-03-19 11:58:47 UTC (rev 3912) Property changes on: trunk/OpenMPT/pluginBridge ___________________________________________________________________ Modified: svn:ignore ## -1,4 +1,6 ## *.aps *.user Debug +PluginBridge.sdf Release +PluginBridge.suo Added: trunk/OpenMPT/pluginBridge/PluginBridge.sln =================================================================== --- trunk/OpenMPT/pluginBridge/PluginBridge.sln (rev 0) +++ trunk/OpenMPT/pluginBridge/PluginBridge.sln 2014-03-19 11:58:47 UTC (rev 3912) @@ -0,0 +1,26 @@ + +Microsoft Visual Studio Solution File, Format Version 11.00 +# Visual Studio 2010 +Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "PluginBridge", "PluginBridge.vcxproj", "{8D55AB6B-DAB3-4EFB-9169-7EAF995D5C10}" +EndProject +Global + GlobalSection(SolutionConfigurationPlatforms) = preSolution + Debug|Win32 = Debug|Win32 + Debug|x64 = Debug|x64 + Release|Win32 = Release|Win32 + Release|x64 = Release|x64 + EndGlobalSection + GlobalSection(ProjectConfigurationPlatforms) = postSolution + {8D55AB6B-DAB3-4EFB-9169-7EAF995D5C10}.Debug|Win32.ActiveCfg = Debug|Win32 + {8D55AB6B-DAB3-4EFB-9169-7EAF995D5C10}.Debug|Win32.Build.0 = Debug|Win32 + {8D55AB6B-DAB3-4EFB-9169-7EAF995D5C10}.Debug|x64.ActiveCfg = Debug|x64 + {8D55AB6B-DAB3-4EFB-9169-7EAF995D5C10}.Debug|x64.Build.0 = Debug|x64 + {8D55AB6B-DAB3-4EFB-9169-7EAF995D5C10}.Release|Win32.ActiveCfg = Release|Win32 + {8D55AB6B-DAB3-4EFB-9169-7EAF995D5C10}.Release|Win32.Build.0 = Release|Win32 + {8D55AB6B-DAB3-4EFB-9169-7EAF995D5C10}.Release|x64.ActiveCfg = Release|x64 + {8D55AB6B-DAB3-4EFB-9169-7EAF995D5C10}.Release|x64.Build.0 = Release|x64 + EndGlobalSection + GlobalSection(SolutionProperties) = preSolution + HideSolutionNode = FALSE + EndGlobalSection +EndGlobal Property changes on: trunk/OpenMPT/pluginBridge/PluginBridge.sln ___________________________________________________________________ Added: svn:mime-type ## -0,0 +1 ## +text/x-ms-sln \ No newline at end of property Added: svn:eol-style ## -0,0 +1 ## +CRLF \ 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...> - 2014-03-19 13:44:31
|
Revision: 3916 http://sourceforge.net/p/modplug/code/3916 Author: manxorist Date: 2014-03-19 13:44:21 +0000 (Wed, 19 Mar 2014) Log Message: ----------- [New] libopenmpt: Add a C API example that writes PCM data to STDOUT instead of streaming via PortAudio. Modified Paths: -------------- trunk/OpenMPT/Makefile trunk/OpenMPT/libopenmpt/libopenmpt.h Added Paths: ----------- trunk/OpenMPT/libopenmpt/examples/libopenmpt_example_c_stdout.c Modified: trunk/OpenMPT/Makefile =================================================================== --- trunk/OpenMPT/Makefile 2014-03-19 13:26:11 UTC (rev 3915) +++ trunk/OpenMPT/Makefile 2014-03-19 13:44:21 UTC (rev 3916) @@ -322,11 +322,7 @@ LDFLAGS_OPENMPT123 += $(LDFLAGS_SDL) $(LDFLAGS_PORTAUDIO) $(LDFLAGS_FLAC) $(LDFLAGS_WAVPACK) $(LDFLAGS_SNDFILE) LDLIBS_OPENMPT123 += $(LDLIBS_SDL) $(LDLIBS_PORTAUDIO) $(LDLIBS_FLAC) $(LDLIBS_WAVPACK) $(LDLIBS_SNDFILE) -CPPFLAGS_EXAMPLES += $(CPPFLAGS_PORTAUDIO) -LDFLAGS_EXAMPLES += $(LDFLAGS_PORTAUDIO) -LDLIBS_EXAMPLES += $(LDLIBS_PORTAUDIO) - %: %.o $(INFO) [LD] $@ $(SILENT)$(LINK.cc) $^ $(LOADLIBES) $(LDLIBS) -o $@ @@ -478,11 +474,15 @@ ifeq ($(NO_PORTAUDIO),1) else ifeq ($(EXAMPLES),1) +ifeq ($(NO_PORTAUDIO),1) +else OUTPUTS += bin/libopenmpt_example_c$(EXESUFFIX) OUTPUTS += bin/libopenmpt_example_c_mem$(EXESUFFIX) OUTPUTS += bin/libopenmpt_example_cxx$(EXESUFFIX) endif +OUTPUTS += bin/libopenmpt_example_c_stdout$(EXESUFFIX) endif +endif ifeq ($(TEST),1) OUTPUTS += bin/libopenmpt_test$(EXESUFFIX) endif @@ -592,6 +592,7 @@ $(INSTALL_DATA) TODO $(DESTDIR)$(PREFIX)/share/doc/libopenmpt/TODO $(INSTALL_DATA) libopenmpt/examples/libopenmpt_example_c.c $(DESTDIR)$(PREFIX)/share/doc/libopenmpt/examples/libopenmpt_example_c.c $(INSTALL_DATA) libopenmpt/examples/libopenmpt_example_c_mem.c $(DESTDIR)$(PREFIX)/share/doc/libopenmpt/examples/libopenmpt_example_c_mem.c + $(INSTALL_DATA) libopenmpt/examples/libopenmpt_example_c_stdout.c $(DESTDIR)$(PREFIX)/share/doc/libopenmpt/examples/libopenmpt_example_c_stdout.c $(INSTALL_DATA) libopenmpt/examples/libopenmpt_example_cxx.cpp $(DESTDIR)$(PREFIX)/share/doc/libopenmpt/examples/libopenmpt_example_cxx.cpp .PHONY: install-doc @@ -749,39 +750,51 @@ libopenmpt/examples/libopenmpt_example_c.o: libopenmpt/examples/libopenmpt_example_c.c $(INFO) [CC] $< - $(VERYSILENT)$(CC) $(CFLAGS) $(CFLAGS_EXAMPLES) $(CPPFLAGS) $(CPPFLAGS_EXAMPLES) $(TARGET_ARCH) -M -MT$@ $< > $*.d - $(SILENT)$(COMPILE.c) $(CFLAGS_EXAMPLES) $(CPPFLAGS_EXAMPLES) $(OUTPUT_OPTION) $< + $(VERYSILENT)$(CC) $(CFLAGS) $(CFLAGS_PORTAUDIO) $(CPPFLAGS) $(CPPFLAGS_PORTAUDIO) $(TARGET_ARCH) -M -MT$@ $< > $*.d + $(SILENT)$(COMPILE.c) $(CFLAGS_PORTAUDIO) $(CPPFLAGS_PORTAUDIO) $(OUTPUT_OPTION) $< libopenmpt/examples/libopenmpt_example_c_mem.o: libopenmpt/examples/libopenmpt_example_c_mem.c $(INFO) [CC] $< - $(VERYSILENT)$(CC) $(CFLAGS) $(CFLAGS_EXAMPLES) $(CPPFLAGS) $(CPPFLAGS_EXAMPLES) $(TARGET_ARCH) -M -MT$@ $< > $*.d - $(SILENT)$(COMPILE.c) $(CFLAGS_EXAMPLES) $(CPPFLAGS_EXAMPLES) $(OUTPUT_OPTION) $< + $(VERYSILENT)$(CC) $(CFLAGS) $(CFLAGS_PORTAUDIO) $(CPPFLAGS) $(CPPFLAGS_PORTAUDIO) $(TARGET_ARCH) -M -MT$@ $< > $*.d + $(SILENT)$(COMPILE.c) $(CFLAGS_PORTAUDIO) $(CPPFLAGS_PORTAUDIO) $(OUTPUT_OPTION) $< +libopenmpt/examples/libopenmpt_example_c_stdout.o: libopenmpt/examples/libopenmpt_example_c_stdout.c + $(INFO) [CC] $< + $(VERYSILENT)$(CC) $(CFLAGS) $(CPPFLAGS) $(TARGET_ARCH) -M -MT$@ $< > $*.d + $(SILENT)$(COMPILE.c) $(OUTPUT_OPTION) $< libopenmpt/examples/libopenmpt_example_cxx.o: libopenmpt/examples/libopenmpt_example_cxx.cpp $(INFO) [CXX] $< - $(VERYSILENT)$(CXX) $(CXXFLAGS) $(CXXFLAGS_EXAMPLES) $(CPPFLAGS) $(CPPFLAGS_EXAMPLES) $(TARGET_ARCH) -M -MT$@ $< > $*.d - $(SILENT)$(COMPILE.cc) $(CXXFLAGS_EXAMPLES) $(CPPFLAGS_EXAMPLES) $(OUTPUT_OPTION) $< + $(VERYSILENT)$(CXX) $(CXXFLAGS) $(CXXFLAGS_PORTAUDIO) $(CPPFLAGS) $(CPPFLAGS_PORTAUDIO) $(TARGET_ARCH) -M -MT$@ $< > $*.d + $(SILENT)$(COMPILE.cc) $(CXXFLAGS_PORTAUDIO) $(CPPFLAGS_PORTAUDIO) $(OUTPUT_OPTION) $< bin/libopenmpt_example_c$(EXESUFFIX): libopenmpt/examples/libopenmpt_example_c.o $(OBJECTS_LIBOPENMPT) $(OUTPUT_LIBOPENMPT) $(INFO) [LD] $@ - $(SILENT)$(LINK.cc) $(LDFLAGS_LIBOPENMPT) $(LDFLAGS_EXAMPLES) libopenmpt/examples/libopenmpt_example_c.o $(OBJECTS_LIBOPENMPT) $(LOADLIBES) $(LDLIBS) $(LDLIBS_LIBOPENMPT) $(LDLIBS_EXAMPLES) -o $@ + $(SILENT)$(LINK.cc) $(LDFLAGS_LIBOPENMPT) $(LDFLAGS_PORTAUDIO) libopenmpt/examples/libopenmpt_example_c.o $(OBJECTS_LIBOPENMPT) $(LOADLIBES) $(LDLIBS) $(LDLIBS_LIBOPENMPT) $(LDLIBS_PORTAUDIO) -o $@ ifeq ($(HOST),unix) $(SILENT)mv $@ $@.norpath $(INFO) [LD] $@ - $(SILENT)$(LINK.cc) $(LDFLAGS_RPATH) $(LDFLAGS_LIBOPENMPT) $(LDFLAGS_EXAMPLES) libopenmpt/examples/libopenmpt_example_c.o $(OBJECTS_LIBOPENMPT) $(LOADLIBES) $(LDLIBS) $(LDLIBS_LIBOPENMPT) $(LDLIBS_EXAMPLES) -o $@ + $(SILENT)$(LINK.cc) $(LDFLAGS_RPATH) $(LDFLAGS_LIBOPENMPT) $(LDFLAGS_PORTAUDIO) libopenmpt/examples/libopenmpt_example_c.o $(OBJECTS_LIBOPENMPT) $(LOADLIBES) $(LDLIBS) $(LDLIBS_LIBOPENMPT) $(LDLIBS_PORTAUDIO) -o $@ endif bin/libopenmpt_example_c_mem$(EXESUFFIX): libopenmpt/examples/libopenmpt_example_c_mem.o $(OBJECTS_LIBOPENMPT) $(OUTPUT_LIBOPENMPT) $(INFO) [LD] $@ - $(SILENT)$(LINK.cc) $(LDFLAGS_LIBOPENMPT) $(LDFLAGS_EXAMPLES) libopenmpt/examples/libopenmpt_example_c_mem.o $(OBJECTS_LIBOPENMPT) $(LOADLIBES) $(LDLIBS) $(LDLIBS_LIBOPENMPT) $(LDLIBS_EXAMPLES) -o $@ + $(SILENT)$(LINK.cc) $(LDFLAGS_LIBOPENMPT) $(LDFLAGS_PORTAUDIO) libopenmpt/examples/libopenmpt_example_c_mem.o $(OBJECTS_LIBOPENMPT) $(LOADLIBES) $(LDLIBS) $(LDLIBS_LIBOPENMPT) $(LDLIBS_PORTAUDIO) -o $@ ifeq ($(HOST),unix) $(SILENT)mv $@ $@.norpath $(INFO) [LD] $@ - $(SILENT)$(LINK.cc) $(LDFLAGS_RPATH) $(LDFLAGS_LIBOPENMPT) $(LDFLAGS_EXAMPLES) libopenmpt/examples/libopenmpt_example_c_mem.o $(OBJECTS_LIBOPENMPT) $(LOADLIBES) $(LDLIBS) $(LDLIBS_LIBOPENMPT) $(LDLIBS_EXAMPLES) -o $@ + $(SILENT)$(LINK.cc) $(LDFLAGS_RPATH) $(LDFLAGS_LIBOPENMPT) $(LDFLAGS_PORTAUDIO) libopenmpt/examples/libopenmpt_example_c_mem.o $(OBJECTS_LIBOPENMPT) $(LOADLIBES) $(LDLIBS) $(LDLIBS_LIBOPENMPT) $(LDLIBS_PORTAUDIO) -o $@ endif +bin/libopenmpt_example_c_stdout$(EXESUFFIX): libopenmpt/examples/libopenmpt_example_c_stdout.o $(OBJECTS_LIBOPENMPT) $(OUTPUT_LIBOPENMPT) + $(INFO) [LD] $@ + $(SILENT)$(LINK.cc) $(LDFLAGS_LIBOPENMPT) libopenmpt/examples/libopenmpt_example_c_stdout.o $(OBJECTS_LIBOPENMPT) $(LOADLIBES) $(LDLIBS) $(LDLIBS_LIBOPENMPT) -o $@ +ifeq ($(HOST),unix) + $(SILENT)mv $@ $@.norpath + $(INFO) [LD] $@ + $(SILENT)$(LINK.cc) $(LDFLAGS_RPATH) $(LDFLAGS_LIBOPENMPT) libopenmpt/examples/libopenmpt_example_c_stdout.o $(OBJECTS_LIBOPENMPT) $(LOADLIBES) $(LDLIBS) $(LDLIBS_LIBOPENMPT) -o $@ +endif bin/libopenmpt_example_cxx$(EXESUFFIX): libopenmpt/examples/libopenmpt_example_cxx.o $(OBJECTS_LIBOPENMPT) $(OUTPUT_LIBOPENMPT) $(INFO) [LD] $@ - $(SILENT)$(LINK.cc) $(LDFLAGS_LIBOPENMPT) $(LDFLAGS_EXAMPLES) libopenmpt/examples/libopenmpt_example_cxx.o $(OBJECTS_LIBOPENMPT) $(LOADLIBES) $(LDLIBS) $(LDLIBS_LIBOPENMPT) $(LDLIBS_EXAMPLES) -o $@ + $(SILENT)$(LINK.cc) $(LDFLAGS_LIBOPENMPT) $(LDFLAGS_PORTAUDIO) libopenmpt/examples/libopenmpt_example_cxx.o $(OBJECTS_LIBOPENMPT) $(LOADLIBES) $(LDLIBS) $(LDLIBS_LIBOPENMPT) $(LDLIBS_PORTAUDIO) -o $@ ifeq ($(HOST),unix) $(SILENT)mv $@ $@.norpath $(INFO) [LD] $@ - $(SILENT)$(LINK.cc) $(LDFLAGS_RPATH) $(LDFLAGS_LIBOPENMPT) $(LDFLAGS_EXAMPLES) libopenmpt/examples/libopenmpt_example_cxx.o $(OBJECTS_LIBOPENMPT) $(LOADLIBES) $(LDLIBS) $(LDLIBS_LIBOPENMPT) $(LDLIBS_EXAMPLES) -o $@ + $(SILENT)$(LINK.cc) $(LDFLAGS_RPATH) $(LDFLAGS_LIBOPENMPT) $(LDFLAGS_PORTAUDIO) libopenmpt/examples/libopenmpt_example_cxx.o $(OBJECTS_LIBOPENMPT) $(LOADLIBES) $(LDLIBS) $(LDLIBS_LIBOPENMPT) $(LDLIBS_PORTAUDIO) -o $@ endif .PHONY: clean Added: trunk/OpenMPT/libopenmpt/examples/libopenmpt_example_c_stdout.c =================================================================== --- trunk/OpenMPT/libopenmpt/examples/libopenmpt_example_c_stdout.c (rev 0) +++ trunk/OpenMPT/libopenmpt/examples/libopenmpt_example_c_stdout.c 2014-03-19 13:44:21 UTC (rev 3916) @@ -0,0 +1,70 @@ +/* + * libopenmpt_example_c_stdout.c + * ----------------------------- + * Purpose: libopenmpt C API simple example + * Notes : (currently none) + * Authors: OpenMPT Devs + * The OpenMPT source code is released under the BSD license. Read LICENSE for more details. + */ + +/* + * This example write raw 48000Hz / stereo / 16bit native endian PCM data to stdout. + * + * Use for example (on little endian platforms): + * + * bin/libopenmpt_example_c_stdout SOMEMODULE | aplay --file-type raw --format=dat + * + */ + +#include <memory.h> +#include <stdint.h> +#include <stdio.h> +#include <stdlib.h> +#include <string.h> + +#include <errno.h> +#include <unistd.h> + +#include <libopenmpt/libopenmpt.h> +#include <libopenmpt/libopenmpt_stream_callbacks_file.h> + +#define BUFFERSIZE 480 +#define SAMPLERATE 48000 + +static ssize_t xwrite(int fd, const void* buffer, size_t size){ + size_t written = 0; + ssize_t retval = 0; + while(written<size){ + retval = write(fd,(const char*)buffer+written,size-written); + if(retval<0){ + if(errno!=EINTR){ + break; + } + retval = 0; + } + written += retval; + } + return written; +} + +static int16_t buffer[BUFFERSIZE*2]; + +int main(int argc,char* argv[]){ + FILE* file = 0; + openmpt_module* mod = 0; + size_t count = 0; + (void)argc; + file = fopen(argv[1],"rb"); + mod = openmpt_module_create(openmpt_stream_get_file_callbacks(),file,NULL,NULL,NULL); + fclose(file); + while(1){ + count = openmpt_module_read_interleaved_stereo(mod,SAMPLERATE,BUFFERSIZE,buffer); + if(count==0){ + break; + } + xwrite(STDOUT_FILENO,buffer,count*2*sizeof(int16_t)); + } + openmpt_module_destroy(mod); + return 0; +} + Property changes on: trunk/OpenMPT/libopenmpt/examples/libopenmpt_example_c_stdout.c ___________________________________________________________________ Added: svn:mime-type ## -0,0 +1 ## +text/x-csrc \ No newline at end of property Added: svn:eol-style ## -0,0 +1 ## +native \ No newline at end of property Modified: trunk/OpenMPT/libopenmpt/libopenmpt.h =================================================================== --- trunk/OpenMPT/libopenmpt/libopenmpt.h 2014-03-19 13:26:11 UTC (rev 3915) +++ trunk/OpenMPT/libopenmpt/libopenmpt.h 2014-03-19 13:44:21 UTC (rev 3916) @@ -57,6 +57,8 @@ * \include libopenmpt_example_c.c * \subsection libopenmpt_c_example_inmemory in memory * \include libopenmpt_example_c_mem.c + * \subsection libopenmpt_c_example_stdout reading FILE* and writing PCM data to STDOUT (usable without PortAudio) + * \include libopenmpt_example_c_stdout.c * */ This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <sag...@us...> - 2014-03-20 20:00:58
|
Revision: 3921 http://sourceforge.net/p/modplug/code/3921 Author: saga-games Date: 2014-03-20 20:00:47 +0000 (Thu, 20 Mar 2014) Log Message: ----------- [Mod] Plugin bridge: Remove periodic redraw. This harms many plugin GUIs and is usually not necessary anyway. [Imp] Plugin bridge: Pass keys back to the editor to trigger notes and indicate bridging status in window title. Modified Paths: -------------- trunk/OpenMPT/mptrack/AbstractVstEditor.cpp trunk/OpenMPT/pluginBridge/Bridge.cpp trunk/OpenMPT/pluginBridge/BridgeCommon.h trunk/OpenMPT/pluginBridge/BridgeWrapper.cpp Modified: trunk/OpenMPT/mptrack/AbstractVstEditor.cpp =================================================================== --- trunk/OpenMPT/mptrack/AbstractVstEditor.cpp 2014-03-20 16:48:09 UTC (rev 3920) +++ trunk/OpenMPT/mptrack/AbstractVstEditor.cpp 2014-03-20 20:00:47 UTC (rev 3921) @@ -386,6 +386,8 @@ Title.Append(m_VstPlugin.m_pMixStruct->GetName()); else Title.Append(mpt::ToLocale(mpt::CharsetUTF8, m_VstPlugin.m_pMixStruct->GetLibraryName()).c_str()); + if(m_VstPlugin.isBridged) + Title.Append(" (Bridged)"); SetWindowText(Title); } @@ -449,8 +451,9 @@ { if(m_VstPlugin.CanRecieveMidiEvents()) { + SetForegroundWindow(); // Might have to steal focus from plugin bridge child window if(!m_VstPlugin.isInstrument() || m_VstPlugin.GetSoundFile().GetModSpecifications().instrumentsMax == 0 || - Reporting::Confirm(_T("You need to assign an instrument to this plugin before you can play notes from here.\nCreate a new instrument and assign this plugin to the instrument?"), false, false, false, this) == cnfNo) + Reporting::Confirm(_T("You need to assign an instrument to this plugin before you can play notes from here.\nCreate a new instrument and assign this plugin to the instrument?"), false, false, this) == cnfNo) { return false; } else Modified: trunk/OpenMPT/pluginBridge/Bridge.cpp =================================================================== --- trunk/OpenMPT/pluginBridge/Bridge.cpp 2014-03-20 16:48:09 UTC (rev 3920) +++ trunk/OpenMPT/pluginBridge/Bridge.cpp 2014-03-20 20:00:47 UTC (rev 3921) @@ -60,7 +60,7 @@ { if(argc != 2) { - MessageBox(NULL, _T("This executable is part of OpenMPT. You do not need to run it by yourself."), _T("Plugin Bridge"), 0); + MessageBox(NULL, _T("This executable is part of OpenMPT. You do not need to run it by yourself."), _T("OpenMPT Plugin Bridge"), 0); return -1; } @@ -112,10 +112,11 @@ if(!queueMem.Open(memName) || !CreateSignals(memName)) { - MessageBox(NULL, _T("Could not connect to host."), _T("Plugin Bridge"), 0); + MessageBox(NULL, _T("Could not connect to OpenMPT."), _T("OpenMPT Plugin Bridge"), 0); delete this; return; } + sharedMem = reinterpret_cast<SharedMemLayout *>(queueMem.view); // Store parent process handle so that we can terminate the bridge process when OpenMPT closes (e.g. through a crash). @@ -124,17 +125,13 @@ sigThreadExit.Create(true); otherThread = mpt::thread_member<PluginBridge, &PluginBridge::RenderThread>(this); - // Tell the parent process that we've initialized the shared memory and are ready to go. - sigToHost.Confirm(); - mpt::thread_member<PluginBridge, &PluginBridge::MessageThread>(this); } PluginBridge::~PluginBridge() { - sigThreadExit.Trigger(); - WaitForSingleObject(otherThread, INFINITE); + SignalObjectAndWait(sigThreadExit, otherThread, INFINITE, FALSE); sharedMem = nullptr; queueMem.Close(); @@ -480,8 +477,6 @@ windowClass.hInstance, NULL); - // Periodically update the window, in case redrawing failed. - SetTimer(window, 0x1337, 1000, nullptr); windowParent = reinterpret_cast<HWND>(msg->ptr); } break; @@ -1026,36 +1021,34 @@ LRESULT CALLBACK PluginBridge::WindowProc(HWND hwnd, UINT uMsg, WPARAM wParam, LPARAM lParam) { + PluginBridge *that = reinterpret_cast<PluginBridge *>(GetProp(hwnd, _T("MPT"))); + if(that == nullptr) + { + return DefWindowProc(hwnd, uMsg, wParam, lParam); + } + switch(uMsg) { case WM_NCACTIVATE: if(wParam == TRUE) { // Window is activated - put the plugin window into foreground - PluginBridge *that = reinterpret_cast<PluginBridge *>(GetProp(hwnd, _T("MPT"))); - if(that != nullptr) - { - SetForegroundWindow(that->windowParent); - SetForegroundWindow(that->window); - } + SetForegroundWindow(that->windowParent); + SetForegroundWindow(that->window); } break; + case WM_SYSKEYUP: + case WM_SYSKEYDOWN: + case WM_KEYUP: + case WM_KEYDOWN: + // Let the host handle these keys, too. + PostMessage(GetParent(that->windowParent), uMsg, wParam, lParam); + break; + case WM_ERASEBKGND: // Pretend that we erased the background - if(GetProp(hwnd, _T("MPT")) != nullptr) - { - return 1; - } - break; - - case WM_TIMER: - if(wParam == 0x1337) - { - // Fix failed plugin window redrawing by periodically forcing a redraw - RedrawWindow(hwnd, nullptr, nullptr, RDW_INVALIDATE | RDW_ALLCHILDREN); - } - break; + return 1; } return DefWindowProc(hwnd, uMsg, wParam, lParam); Modified: trunk/OpenMPT/pluginBridge/BridgeCommon.h =================================================================== --- trunk/OpenMPT/pluginBridge/BridgeCommon.h 2014-03-20 16:48:09 UTC (rev 3920) +++ trunk/OpenMPT/pluginBridge/BridgeCommon.h 2014-03-20 20:00:47 UTC (rev 3921) @@ -40,11 +40,12 @@ public: Event() : handle(nullptr) { } - ~Event() { CloseHandle(handle); } + ~Event() { Close(); } // Create a new event bool Create(bool manual = false, const wchar_t *name = nullptr) { + Close(); handle = CreateEventW(nullptr, manual ? TRUE : FALSE, FALSE, name); return handle != nullptr; } @@ -52,9 +53,15 @@ // Duplicate a local event bool DuplicateFrom(HANDLE source) { + Close(); return DuplicateHandle(GetCurrentProcess(), source, GetCurrentProcess(), &handle, 0, FALSE, DUPLICATE_SAME_ACCESS) != FALSE; } + void Close() + { + CloseHandle(handle); + } + void Trigger() { SetEvent(handle); Modified: trunk/OpenMPT/pluginBridge/BridgeWrapper.cpp =================================================================== --- trunk/OpenMPT/pluginBridge/BridgeWrapper.cpp 2014-03-20 16:48:09 UTC (rev 3920) +++ trunk/OpenMPT/pluginBridge/BridgeWrapper.cpp 2014-03-20 20:00:47 UTC (rev 3921) @@ -198,12 +198,6 @@ sharedMem->effect.process = Process; memcpy(&(sharedMem->effect.resvd2), "OMPT", 4); - if(WaitForSingleObject(sigToHost.ack, 5000) != WAIT_OBJECT_0) - { - Reporting::Error("Plugin bridge timed out."); - return false; - } - sigThreadExit.Create(true); sigAutomation.Create(true); @@ -231,8 +225,7 @@ BridgeWrapper::~BridgeWrapper() { - sigThreadExit.Trigger(); - WaitForSingleObject(otherThread, INFINITE); + SignalObjectAndWait(sigThreadExit, otherThread, INFINITE, FALSE); } This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <sag...@us...> - 2014-03-21 00:40:10
|
Revision: 3922 http://sourceforge.net/p/modplug/code/3922 Author: saga-games Date: 2014-03-21 00:40:00 +0000 (Fri, 21 Mar 2014) Log Message: ----------- [Imp] Plugin editor: For bridged plugin editors, ensure that the "create instrument" popup has proper focus [Imp] Plugin bridge: Prevent plugins from loading with the native plugin loader if something bad happened (or at least ask the user if he really wants to do that) Modified Paths: -------------- trunk/OpenMPT/mptrack/AbstractVstEditor.cpp trunk/OpenMPT/pluginBridge/BridgeWrapper.cpp trunk/OpenMPT/pluginBridge/BridgeWrapper.h trunk/OpenMPT/soundlib/plugins/PluginManager.cpp Modified: trunk/OpenMPT/mptrack/AbstractVstEditor.cpp =================================================================== --- trunk/OpenMPT/mptrack/AbstractVstEditor.cpp 2014-03-20 20:00:47 UTC (rev 3921) +++ trunk/OpenMPT/mptrack/AbstractVstEditor.cpp 2014-03-21 00:40:00 UTC (rev 3922) @@ -451,9 +451,22 @@ { if(m_VstPlugin.CanRecieveMidiEvents()) { - SetForegroundWindow(); // Might have to steal focus from plugin bridge child window + CWnd *parent = this; + if(m_VstPlugin.isBridged) + { + // AllowSetForegroundWindow won't work reliably when calling it right when sending + // key messages from the bridged plugin, so stealing focus from plugin bridge child window + // can be kinda difficult. To prevent the following message box from not being focussed, + // we simply make it a child of the bridge window... + parent = GetWindow(GW_CHILD | GW_HWNDFIRST); // Plug container in custom GUIs + if(parent) parent = parent->GetWindow(GW_CHILD | GW_HWNDFIRST); // Bridge container + if(!parent) + { + parent = this; + } + } if(!m_VstPlugin.isInstrument() || m_VstPlugin.GetSoundFile().GetModSpecifications().instrumentsMax == 0 || - Reporting::Confirm(_T("You need to assign an instrument to this plugin before you can play notes from here.\nCreate a new instrument and assign this plugin to the instrument?"), false, false, this) == cnfNo) + Reporting::Confirm(_T("You need to assign an instrument to this plugin before you can play notes from here.\nCreate a new instrument and assign this plugin to the instrument?"), false, false, parent) == cnfNo) { return false; } else Modified: trunk/OpenMPT/pluginBridge/BridgeWrapper.cpp =================================================================== --- trunk/OpenMPT/pluginBridge/BridgeWrapper.cpp 2014-03-20 20:00:47 UTC (rev 3921) +++ trunk/OpenMPT/pluginBridge/BridgeWrapper.cpp 2014-03-21 00:40:00 UTC (rev 3922) @@ -79,7 +79,7 @@ // Create a plugin bridge object AEffect *BridgeWrapper::Create(const VSTPluginLib &plugin) { - BridgeWrapper *wrapper = new BridgeWrapper(); + BridgeWrapper *wrapper = new (std::nothrow) BridgeWrapper(); BridgeWrapper *sharedInstance = nullptr; // Should we share instances? @@ -98,12 +98,19 @@ } } - if(wrapper->Init(plugin.dllPath, sharedInstance) && wrapper->queueMem.Good()) + try { - return &wrapper->sharedMem->effect; + if(wrapper != nullptr && wrapper->Init(plugin.dllPath, sharedInstance) && wrapper->queueMem.Good()) + { + return &wrapper->sharedMem->effect; + } + delete wrapper; + return nullptr; + } catch(BridgeException &) + { + delete wrapper; + throw; } - delete wrapper; - return nullptr; } @@ -120,8 +127,7 @@ if(!queueMem.Create(mapName.c_str(), sizeof(SharedMemLayout)) || !CreateSignals(mapName.c_str())) { - Reporting::Error("Could not initialize plugin bridge memory."); - return false; + throw BridgeException("Could not initialize plugin bridge memory."); } sharedMem = reinterpret_cast<SharedMemLayout *>(queueMem.view); @@ -149,12 +155,11 @@ if(bridgeVersion == 0) { // Silently fail if bridge is missing. - //Reporting::Error("Could not open the plugin bridge executable."); - return false; + throw BridgeNotFoundException(); } else if(bridgeVersion != mptVersion) { - Reporting::Error("The plugin bridge version does not match your OpenMPT version."); - return false; + throw BridgeException("The plugin bridge version does not match your OpenMPT version."); + return nullptr; } otherPtrSize = binType; @@ -171,8 +176,7 @@ if(!CreateProcessW(exeName.AsNative().c_str(), cmdLine, NULL, NULL, FALSE, /*CREATE_NO_WINDOW */0, NULL, NULL, &info, &processInfo)) { - Reporting::Error("Failed to launch plugin bridge."); - return false; + throw BridgeException("Failed to launch plugin bridge."); } otherProcess = processInfo.hProcess; } else @@ -208,10 +212,10 @@ if(!SendToBridge(initMsg)) { - Reporting::Error("Could not initialize plugin bridge, it probably crashed."); + throw BridgeException("Could not initialize plugin bridge, it probably crashed."); } else if(initMsg.init.result != 1) { - Reporting::Error(mpt::ToLocale(initMsg.init.str).c_str()); + throw BridgeException(mpt::ToLocale(initMsg.init.str).c_str()); } else { if(sharedMem->effect.flags & effFlagsCanReplacing) sharedMem->effect.processReplacing = ProcessReplacing; Modified: trunk/OpenMPT/pluginBridge/BridgeWrapper.h =================================================================== --- trunk/OpenMPT/pluginBridge/BridgeWrapper.h 2014-03-20 20:00:47 UTC (rev 3921) +++ trunk/OpenMPT/pluginBridge/BridgeWrapper.h 2014-03-21 00:40:00 UTC (rev 3922) @@ -31,6 +31,14 @@ bin64Bit = 64, }; + class BridgeException : public std::exception + { + public: + BridgeException(const char *str) : std::exception(str) { } + BridgeException() { } + }; + class BridgeNotFoundException : public BridgeException { }; + public: static BinaryType GetPluginBinaryType(const mpt::PathString &pluginPath); static bool IsPluginNative(const mpt::PathString &pluginPath) { return GetPluginBinaryType(pluginPath) == sizeof(void *) * 8; } Modified: trunk/OpenMPT/soundlib/plugins/PluginManager.cpp =================================================================== --- trunk/OpenMPT/soundlib/plugins/PluginManager.cpp 2014-03-20 20:00:47 UTC (rev 3921) +++ trunk/OpenMPT/soundlib/plugins/PluginManager.cpp 2014-03-21 00:40:00 UTC (rev 3922) @@ -199,12 +199,38 @@ AEffect *effect = nullptr; library = nullptr; - if(forceBridge || plugin.useBridge || !BridgeWrapper::IsPluginNative(pluginPath)) + const bool isNative = BridgeWrapper::IsPluginNative(pluginPath); + if(forceBridge || plugin.useBridge || !isNative) { - effect = BridgeWrapper::Create(plugin); - if(effect != nullptr) + try { - return effect; + effect = BridgeWrapper::Create(plugin); + if(effect != nullptr) + { + return effect; + } + } catch(BridgeWrapper::BridgeNotFoundException &) + { + // Try normal loading + if(!isNative) + { + Reporting::Error("Could not locate the plugin bridge executable, which is required for running non-native plugins.", "OpenMPT Plugin Bridge"); + return false; + } + } catch(BridgeWrapper::BridgeException &e) + { + // If there was some error, don't try normal loading as well... unless the user really wants it. + if(isNative) + { + if(Reporting::Confirm((std::string(e.what()) + "\n\nDo you want to try to load the plugin natively?").c_str(), "OpenMPT Plugin Bridge", false, true) == cnfNo) + { + return nullptr; + } + } else + { + Reporting::Error(e.what(), "OpenMPT Plugin Bridge"); + return nullptr; + } } } @@ -256,14 +282,6 @@ } } - if(effect == nullptr) - { - // Re-try loading the plugin using our bridge instead. - FreeLibrary(library); - library = nullptr; - - effect = BridgeWrapper::Create(plugin); - } return effect; } This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <man...@us...> - 2014-03-21 15:17:17
|
Revision: 3929 http://sourceforge.net/p/modplug/code/3929 Author: manxorist Date: 2014-03-21 15:17:06 +0000 (Fri, 21 Mar 2014) Log Message: ----------- [Mod] sounddev: SetWaitable timer is actually supported on all windows version. MSDN is sometimes really confusing. Use SetWaitable timer for all NT based kernels and timeSetEvent only for ancient Win98. This changes behaviour on Win2000, does anybody care? Modified Paths: -------------- trunk/OpenMPT/common/misc_util.h trunk/OpenMPT/sounddev/SoundDeviceThread.cpp trunk/OpenMPT/sounddev/SoundDeviceThread.h Modified: trunk/OpenMPT/common/misc_util.h =================================================================== --- trunk/OpenMPT/common/misc_util.h 2014-03-21 10:22:26 UTC (rev 3928) +++ trunk/OpenMPT/common/misc_util.h 2014-03-21 15:17:06 UTC (rev 3929) @@ -654,6 +654,9 @@ enum WinNTVersion { + VerWinNT4 = 0x0400, + VerWin98 = 0x040a, + VerWinME = 0x045a, VerWin2000 = 0x0500, VerWinXP = 0x0501, VerWinXPSP2 = 0x0502, @@ -673,6 +676,16 @@ return ((uint32)mpt::saturate_cast<uint8>(versioninfo.dwMajorVersion) << 8) | (uint32)mpt::saturate_cast<uint8>(versioninfo.dwMinorVersion); } +static inline bool IsWinNT() +//-------------------------- +{ + OSVERSIONINFO versioninfo; + MemsetZero(versioninfo); + versioninfo.dwOSVersionInfoSize = sizeof(versioninfo); + GetVersionEx(&versioninfo); + return (versioninfo.dwPlatformId == VER_PLATFORM_WIN32_NT); +} + } // namespace Windows #endif // WIN32 Modified: trunk/OpenMPT/sounddev/SoundDeviceThread.cpp =================================================================== --- trunk/OpenMPT/sounddev/SoundDeviceThread.cpp 2014-03-21 10:22:26 UTC (rev 3928) +++ trunk/OpenMPT/sounddev/SoundDeviceThread.cpp 2014-03-21 15:17:06 UTC (rev 3929) @@ -24,35 +24,8 @@ //------------------------------------------------------------------------------------------ { - m_HasXP = (mpt::Windows::GetWinNTVersion() >= mpt::Windows::VerWinXP); + m_HasNTKernel = mpt::Windows::IsWinNT(); - pCreateWaitableTimer = nullptr; - pSetWaitableTimer = nullptr; - pCancelWaitableTimer = nullptr; - #if _WIN32_WINNT >= _WIN32_WINNT_WINXP - m_HasXP = true; - pCreateWaitableTimer = &CreateWaitableTimer; - pSetWaitableTimer = &SetWaitableTimer; - pCancelWaitableTimer = &CancelWaitableTimer; - #else - if(m_HasXP) - { - m_Kernel32DLL = mpt::Library(mpt::LibraryPath::System(MPT_PATHSTRING("kernel32"))); - if(!m_Kernel32DLL.Bind(pCreateWaitableTimer, "CreateWaitableTimerA")) - { - m_HasXP = false; - } - if(!m_Kernel32DLL.Bind(pSetWaitableTimer, "SetWaitableTimer")) - { - m_HasXP = false; - } - if(!m_Kernel32DLL.Bind(pCancelWaitableTimer, "CancelWaitableTimer")) - { - m_HasXP = false; - } - } - #endif - m_WakeupInterval = 0.0; m_hPlayThread = NULL; m_dwPlayThreadId = 0; @@ -93,11 +66,6 @@ CloseHandle(m_hAudioWakeUp); m_hAudioWakeUp = NULL; } - - pCreateWaitableTimer = nullptr; - pSetWaitableTimer = nullptr; - pCancelWaitableTimer = nullptr; - } @@ -184,8 +152,8 @@ Util::MultimediaClock clock_noxp; - bool period_noxp_set; - bool periodic_xp_timer; + bool period_nont_set; + bool periodic_nt_timer; HANDLE sleepEvent; @@ -200,28 +168,28 @@ if(sleepMilliseconds < 1) sleepMilliseconds = 1; if(sleep100Nanoseconds < 1) sleep100Nanoseconds = 1; - period_noxp_set = false; - periodic_xp_timer = (sleep100Nanoseconds >= 10000); // can be represented as a millisecond period, otherwise use non-periodic timers which allow higher precision but might me slower because we have to set them again in each period + period_nont_set = false; + periodic_nt_timer = (sleep100Nanoseconds >= 10000); // can be represented as a millisecond period, otherwise use non-periodic timers which allow higher precision but might me slower because we have to set them again in each period sleepEvent = NULL; - if(self.m_HasXP) + if(self.m_HasNTKernel) { - if(periodic_xp_timer) + if(periodic_nt_timer) { - sleepEvent = self.pCreateWaitableTimer(NULL, FALSE, NULL); + sleepEvent = CreateWaitableTimer(NULL, FALSE, NULL); LARGE_INTEGER dueTime; dueTime.QuadPart = 0 - sleep100Nanoseconds; // negative time means relative - self.pSetWaitableTimer(sleepEvent, &dueTime, sleepMilliseconds, NULL, NULL, FALSE); + SetWaitableTimer(sleepEvent, &dueTime, sleepMilliseconds, NULL, NULL, FALSE); } else { - sleepEvent = self.pCreateWaitableTimer(NULL, TRUE, NULL); + sleepEvent = CreateWaitableTimer(NULL, TRUE, NULL); } } else { sleepEvent = CreateEvent(NULL, FALSE, FALSE, NULL); clock_noxp.SetResolution(1); // increase resolution of multimedia timer - period_noxp_set = true; + period_nont_set = true; } } @@ -241,13 +209,13 @@ void Retrigger() //-------------- { - if(self.m_HasXP) + if(self.m_HasNTKernel) { - if(!periodic_xp_timer) + if(!periodic_nt_timer) { LARGE_INTEGER dueTime; dueTime.QuadPart = 0 - sleep100Nanoseconds; // negative time means relative - self.pSetWaitableTimer(sleepEvent, &dueTime, 0, NULL, NULL, FALSE); + SetWaitableTimer(sleepEvent, &dueTime, 0, NULL, NULL, FALSE); } } else { @@ -258,20 +226,20 @@ CPeriodicWaker::~CPeriodicWaker() //------------------------------- { - if(self.m_HasXP) + if(self.m_HasNTKernel) { - if(periodic_xp_timer) + if(periodic_nt_timer) { - self.pCancelWaitableTimer(sleepEvent); + CancelWaitableTimer(sleepEvent); } CloseHandle(sleepEvent); sleepEvent = NULL; } else { - if(period_noxp_set) + if(period_nont_set) { clock_noxp.SetResolution(0); - period_noxp_set = false; + period_nont_set = false; } CloseHandle(sleepEvent); sleepEvent = NULL; Modified: trunk/OpenMPT/sounddev/SoundDeviceThread.h =================================================================== --- trunk/OpenMPT/sounddev/SoundDeviceThread.h 2014-03-21 10:22:26 UTC (rev 3928) +++ trunk/OpenMPT/sounddev/SoundDeviceThread.h 2014-03-21 15:17:06 UTC (rev 3929) @@ -44,14 +44,7 @@ private: CSoundDeviceWithThread & m_SoundDevice; - bool m_HasXP; - mpt::Library m_Kernel32DLL; - typedef HANDLE (WINAPI *FCreateWaitableTimer)(LPSECURITY_ATTRIBUTES, BOOL, LPCTSTR); - typedef BOOL (WINAPI *FSetWaitableTimer)(HANDLE, const LARGE_INTEGER *, LONG, PTIMERAPCROUTINE, LPVOID, BOOL); - typedef BOOL (WINAPI *FCancelWaitableTimer)(HANDLE); - FCreateWaitableTimer pCreateWaitableTimer; - FSetWaitableTimer pSetWaitableTimer; - FCancelWaitableTimer pCancelWaitableTimer; + bool m_HasNTKernel; double m_WakeupInterval; HANDLE m_hAudioWakeUp; This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <sag...@us...> - 2014-03-22 01:09:20
|
Revision: 3931 http://sourceforge.net/p/modplug/code/3931 Author: saga-games Date: 2014-03-22 01:09:09 +0000 (Sat, 22 Mar 2014) Log Message: ----------- [Mod] Plugin bridge: Saner focus stealing implementation and replacement of Local\foo aux memory files. Modified Paths: -------------- trunk/OpenMPT/mptrack/AbstractVstEditor.cpp trunk/OpenMPT/pluginBridge/Bridge.cpp trunk/OpenMPT/pluginBridge/Bridge.h trunk/OpenMPT/pluginBridge/BridgeWrapper.cpp Modified: trunk/OpenMPT/mptrack/AbstractVstEditor.cpp =================================================================== --- trunk/OpenMPT/mptrack/AbstractVstEditor.cpp 2014-03-21 15:18:01 UTC (rev 3930) +++ trunk/OpenMPT/mptrack/AbstractVstEditor.cpp 2014-03-22 01:09:09 UTC (rev 3931) @@ -451,22 +451,11 @@ { if(m_VstPlugin.CanRecieveMidiEvents()) { - CWnd *parent = this; - if(m_VstPlugin.isBridged) - { - // AllowSetForegroundWindow won't work reliably when calling it right when sending - // key messages from the bridged plugin, so stealing focus from plugin bridge child window - // can be kinda difficult. To prevent the following message box from not being focussed, - // we simply make it a child of the bridge window... - parent = GetWindow(GW_CHILD | GW_HWNDFIRST); // Plug container in custom GUIs - if(parent) parent = parent->GetWindow(GW_CHILD | GW_HWNDFIRST); // Bridge container - if(!parent) - { - parent = this; - } - } + // We might need to steal the focus from the plugin bridge. This is going to work + // as the plugin bridge will call AllowSetForegroundWindow on key messages. + SetForegroundWindow(); if(!m_VstPlugin.isInstrument() || m_VstPlugin.GetSoundFile().GetModSpecifications().instrumentsMax == 0 || - Reporting::Confirm(_T("You need to assign an instrument to this plugin before you can play notes from here.\nCreate a new instrument and assign this plugin to the instrument?"), false, false, parent) == cnfNo) + Reporting::Confirm(_T("You need to assign an instrument to this plugin before you can play notes from here.\nCreate a new instrument and assign this plugin to the instrument?"), false, false, this) == cnfNo) { return false; } else Modified: trunk/OpenMPT/pluginBridge/Bridge.cpp =================================================================== --- trunk/OpenMPT/pluginBridge/Bridge.cpp 2014-03-21 15:18:01 UTC (rev 3930) +++ trunk/OpenMPT/pluginBridge/Bridge.cpp 2014-03-22 01:09:09 UTC (rev 3931) @@ -9,20 +9,19 @@ // TODO -// Replace Local\\foo :) // Translate VstIntPtr size in remaining structs!!! VstFileSelect, VstVariableIo, VstOfflineTask, VstAudioFile, VstWindow, VstFileSelect // ProteusVX, TriDirt sometimes flickers because of timed redraws // ProteusVX GUI stops working after closing it once and the plugin crashes when unloading it when the GUI was open at least once // Fix Purity Demo GUI freeze more nicely // Optimize out effProcessEvents (audioMasterProcessEvents?) by using a buffer that's sent along with the process call, just like we do it with automation -// Occasional time-outs when loading plugins into shared instances // Refactoring maybe move the "constructors" of all message types into these types? -// When scanning plugins, forbid loading them natively unless the bridge itself cannot be launched +// Find a nice solution for audioMasterIdle that doesn't break TAL-Elek7ro-II +// KaramFX EQ breaks sound +// Maybe don't keep opening and closing aux mem files - they are rarely needed, so would this actually be worth it? // Low priority: -// Speed up things like consecutive calls to CVstPlugin::GetFormattedProgramName by a custom opcode +// Speed up things like consecutive calls to CVstPlugin::GetFormattedProgramName by a custom opcode (is this necessary?) // Re-enable DEP in OpenMPT? -// Remove native jBridge support // Clean up code :) #define _CRT_SECURE_NO_WARNINGS @@ -49,8 +48,7 @@ Event PluginBridge::sigQuit; // This is kind of a back-up pointer in case we couldn't sneak our pointer into the AEffect struct yet. -// It always points to the last intialized PluginBridge object. Right now there's just one, but we might -// have to initialize more than one plugin in a container at some point to get plugins like SideKickv3 to work. +// It always points to the last intialized PluginBridge object. PluginBridge *PluginBridge::latestInstance = nullptr; WNDCLASSEX PluginBridge::windowClass; #define WINDOWCLASSNAME _T("OpenMPTPluginBridge") @@ -64,11 +62,11 @@ return -1; } - PluginBridge::RegisterWindowClass(); + uint32_t parentProcessId = _ttoi(argv[1]); - PluginBridge::sigQuit.Create(); + PluginBridge::InitializeStaticVariables(); - new PluginBridge(argv[0], OpenProcess(SYNCHRONIZE, FALSE, _ttoi(argv[1]))); + new PluginBridge(argv[0], OpenProcess(SYNCHRONIZE, FALSE, parentProcessId)); WaitForSingleObject(PluginBridge::sigQuit, INFINITE); return 0; @@ -84,8 +82,8 @@ } -// Register the editor window class -void PluginBridge::RegisterWindowClass() +// Initialize static stuff like the editor window class +void PluginBridge::InitializeStaticVariables() { windowClass.cbSize = sizeof(WNDCLASSEX); windowClass.style = CS_HREDRAW | CS_VREDRAW; @@ -100,6 +98,8 @@ windowClass.lpszClassName = WINDOWCLASSNAME; windowClass.hIconSm = NULL; RegisterClassEx(&windowClass); + + sigQuit.Create(); } @@ -430,7 +430,7 @@ void *ptr = (msg->ptr != 0) ? (msg + 1) : nullptr; if(msg->size > sizeof(BridgeMessage)) { - if(!auxMem.Open(L"Local\\foo")) + if(!auxMem.Open(static_cast<const wchar_t *>(ptr))) { return; } @@ -687,6 +687,8 @@ { ProcessMsg *msg = static_cast<ProcessMsg *>(processMem.view); InterlockedExchange(&isProcessing, 1); + AutomateParameters(); + switch(msg->processType) { case ProcessMsg::process: @@ -764,8 +766,6 @@ template<typename buf_t> int32_t PluginBridge::BuildProcessPointers(buf_t **(&inPointers), buf_t **(&outPointers)) { - AutomateParameters(); - assert(processMem.Good()); ProcessMsg *msg = static_cast<ProcessMsg *>(processMem.view); @@ -946,15 +946,24 @@ } uint32_t extraSize = static_cast<uint32_t>(dispatchData.size() - sizeof(DispatchMsg)); + + // Create message header + BridgeMessage *msg = reinterpret_cast<BridgeMessage *>(&dispatchData[0]); + msg->Dispatch(opcode, index, value, ptrOut, opt, extraSize); + + const bool useAuxMem = dispatchData.size() > sizeof(BridgeMessage); MappedMemory auxMem; - if(dispatchData.size() > sizeof(BridgeMessage)) + if(useAuxMem) { - //that->extraMemPipe.Write(&dispatchData[sizeof(DispatchMsg)], extraSize); - //dispatchData.resize(sizeof(DispatchMsg)); - if(auxMem.Create(L"Local\\foo2", extraSize)) + // Extra data doesn't fit in message - use secondary memory + wchar_t auxMemName[64]; + static_assert(sizeof(DispatchMsg) + sizeof(auxMemName) <= sizeof(BridgeMessage), "Check message sizes, this will crash!"); + swprintf(auxMemName, CountOf(auxMemName), L"Local\\openmpt-%d-auxmem-%d", GetCurrentProcessId(), GetCurrentThreadId()); + if(auxMem.Create(auxMemName, extraSize)) { + // Move message data to shared memory and then move shared memory name to message data memcpy(auxMem.view, &dispatchData[sizeof(DispatchMsg)], extraSize); - dispatchData.resize(sizeof(DispatchMsg)); + memcpy(&dispatchData[sizeof(DispatchMsg)], auxMemName, sizeof(auxMemName)); } else { return 0; @@ -963,19 +972,14 @@ //std::cout << "about to dispatch " << opcode << " to host..."; //std::flush(std::cout); - const DispatchMsg *resultMsg; + if(!SendToHost(*msg)) { - BridgeMessage *msg = reinterpret_cast<BridgeMessage *>(&dispatchData[0]); - msg->Dispatch(opcode, index, value, ptrOut, opt, extraSize); - if(!SendToHost(*msg)) - { - return 0; - } - resultMsg = &msg->dispatch; + return 0; } //std::cout << "done." << std::endl; + const DispatchMsg *resultMsg = &msg->dispatch; - const char *extraData = dispatchData.size() == sizeof(DispatchMsg) ? static_cast<const char *>(auxMem.view) : reinterpret_cast<const char *>(resultMsg + 1); + const char *extraData = useAuxMem ? static_cast<const char *>(auxMem.view) : reinterpret_cast<const char *>(resultMsg + 1); // Post-fix some opcodes switch(opcode) { @@ -1043,6 +1047,8 @@ case WM_KEYUP: case WM_KEYDOWN: // Let the host handle these keys, too. + // Allow focus stealing as the host might show a message box as a response to a key shortcut. + AllowSetForegroundWindow(ASFW_ANY); PostMessage(GetParent(that->windowParent), uMsg, wParam, lParam); break; Modified: trunk/OpenMPT/pluginBridge/Bridge.h =================================================================== --- trunk/OpenMPT/pluginBridge/Bridge.h 2014-03-21 15:18:01 UTC (rev 3930) +++ trunk/OpenMPT/pluginBridge/Bridge.h 2014-03-22 01:09:09 UTC (rev 3931) @@ -16,10 +16,10 @@ class PluginBridge : protected BridgeCommon { public: - static LONG instanceCount; static Event sigQuit; protected: + static LONG instanceCount; static PluginBridge *latestInstance; static WNDCLASSEX windowClass; @@ -48,7 +48,7 @@ public: PluginBridge(const wchar_t *memName, HANDLE otherProcess); ~PluginBridge(); - static void RegisterWindowClass(); + static void InitializeStaticVariables(); protected: void MessageThread(); Modified: trunk/OpenMPT/pluginBridge/BridgeWrapper.cpp =================================================================== --- trunk/OpenMPT/pluginBridge/BridgeWrapper.cpp 2014-03-21 15:18:01 UTC (rev 3930) +++ trunk/OpenMPT/pluginBridge/BridgeWrapper.cpp 2014-03-22 01:09:09 UTC (rev 3931) @@ -174,7 +174,7 @@ PROCESS_INFORMATION processInfo; MemsetZero(processInfo); - if(!CreateProcessW(exeName.AsNative().c_str(), cmdLine, NULL, NULL, FALSE, /*CREATE_NO_WINDOW */0, NULL, NULL, &info, &processInfo)) + if(!CreateProcessW(exeName.AsNative().c_str(), cmdLine, NULL, NULL, FALSE, 0, NULL, NULL, &info, &processInfo)) { throw BridgeException("Failed to launch plugin bridge."); } @@ -376,7 +376,7 @@ void *ptr = (msg->ptr != 0) ? (msg + 1) : nullptr; if(msg->size > sizeof(BridgeMessage)) { - if(!auxMem.Open(L"Local\\foo2")) + if(!auxMem.Open(static_cast<const wchar_t *>(ptr))) { return; } @@ -624,33 +624,40 @@ } uint32_t extraSize = static_cast<uint32_t>(dispatchData.size() - sizeof(DispatchMsg)); + + // Create message header + BridgeMessage *msg = reinterpret_cast<BridgeMessage *>(&dispatchData[0]); + msg->Dispatch(opcode, index, value, ptrOut, opt, extraSize); + + const bool useAuxMem = dispatchData.size() > sizeof(BridgeMessage); MappedMemory auxMem; - if(dispatchData.size() > sizeof(BridgeMessage)) + if(useAuxMem) { - //that->extraMemPipe.Write(&dispatchData[sizeof(DispatchMsg)], extraSize); - //dispatchData.resize(sizeof(DispatchMsg)); - if(auxMem.Create(L"Local\\foo", extraSize)) + // Extra data doesn't fit in message - use secondary memory + wchar_t auxMemName[64]; + static_assert(sizeof(DispatchMsg) + sizeof(auxMemName) <= sizeof(BridgeMessage), "Check message sizes, this will crash!"); + swprintf(auxMemName, CountOf(auxMemName), L"Local\\openmpt-%d-auxmem-%d", GetCurrentProcessId(), GetCurrentThreadId()); + if(auxMem.Create(auxMemName, extraSize)) { + // Move message data to shared memory and then move shared memory name to message data memcpy(auxMem.view, &dispatchData[sizeof(DispatchMsg)], extraSize); - dispatchData.resize(sizeof(DispatchMsg)); + memcpy(&dispatchData[sizeof(DispatchMsg)], auxMemName, sizeof(auxMemName)); } else { return 0; } } - - const DispatchMsg *resultMsg; + + //std::cout << "about to dispatch " << opcode << " to host..."; + //std::flush(std::cout); + if(!that->SendToBridge(*msg)) { - BridgeMessage *msg = reinterpret_cast<BridgeMessage *>(&dispatchData[0]); - msg->Dispatch(opcode, index, value, ptrOut, opt, extraSize); - if(!that->SendToBridge(*msg) && opcode != effClose) - { - return false; - } - resultMsg = &msg->dispatch; + return 0; } + //std::cout << "done." << std::endl; + const DispatchMsg *resultMsg = &msg->dispatch; - const char *extraData = dispatchData.size() == sizeof(DispatchMsg) ? static_cast<const char *>(auxMem.view) : reinterpret_cast<const char *>(resultMsg + 1); + const char *extraData = useAuxMem ? static_cast<const char *>(auxMem.view) : reinterpret_cast<const char *>(resultMsg + 1); // Post-fix some opcodes switch(opcode) { This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <man...@us...> - 2014-03-22 15:45:13
|
Revision: 3933 http://sourceforge.net/p/modplug/code/3933 Author: manxorist Date: 2014-03-22 15:45:04 +0000 (Sat, 22 Mar 2014) Log Message: ----------- [Ref] Small header dependencies cleanup. Modified Paths: -------------- trunk/OpenMPT/common/misc_util.cpp trunk/OpenMPT/common/stdafx.h trunk/OpenMPT/mptrack/Ctrl_smp.cpp trunk/OpenMPT/mptrack/StreamEncoderMP3.cpp trunk/OpenMPT/sounddev/SoundDevice.cpp trunk/OpenMPT/sounddev/SoundDevice.h trunk/OpenMPT/sounddev/SoundDeviceDirectSound.cpp trunk/OpenMPT/sounddev/SoundDeviceThread.cpp trunk/OpenMPT/sounddev/SoundDeviceWaveout.cpp Modified: trunk/OpenMPT/common/misc_util.cpp =================================================================== --- trunk/OpenMPT/common/misc_util.cpp 2014-03-22 10:16:47 UTC (rev 3932) +++ trunk/OpenMPT/common/misc_util.cpp 2014-03-22 15:45:04 UTC (rev 3933) @@ -23,6 +23,9 @@ #endif #endif +#if defined(MODPLUG_TRACKER) +#include <mmsystem.h> +#endif template<typename T> Modified: trunk/OpenMPT/common/stdafx.h =================================================================== --- trunk/OpenMPT/common/stdafx.h 2014-03-22 10:16:47 UTC (rev 3932) +++ trunk/OpenMPT/common/stdafx.h 2014-03-22 15:45:04 UTC (rev 3933) @@ -28,23 +28,13 @@ #include <windows.h> #include <windowsx.h> #include <shlwapi.h> - -#if MPT_COMPILER_MSVC -#pragma warning(disable:4201) -#endif #include <mmsystem.h> -#include <mmreg.h> -#include <msacm.h> -#if MPT_COMPILER_MSVC -#pragma warning(default:4201) -#endif #endif // MODPLUG_TRACKER #ifndef NO_PCH -#include <string> #include <vector> #endif // NO_PCH Modified: trunk/OpenMPT/mptrack/Ctrl_smp.cpp =================================================================== --- trunk/OpenMPT/mptrack/Ctrl_smp.cpp 2014-03-22 10:16:47 UTC (rev 3932) +++ trunk/OpenMPT/mptrack/Ctrl_smp.cpp 2014-03-22 15:45:04 UTC (rev 3933) @@ -30,7 +30,6 @@ #include "MemoryMappedFile.h" #include "../soundlib/FileReader.h" #include "../soundlib/SampleFormatConverters.h" -#include <Shlwapi.h> #include "FileDialog.h" #ifdef _DEBUG Modified: trunk/OpenMPT/mptrack/StreamEncoderMP3.cpp =================================================================== --- trunk/OpenMPT/mptrack/StreamEncoderMP3.cpp 2014-03-22 10:16:47 UTC (rev 3932) +++ trunk/OpenMPT/mptrack/StreamEncoderMP3.cpp 2014-03-22 15:45:04 UTC (rev 3933) @@ -58,7 +58,8 @@ #endif // MPT_MP3ENCODER_BLADE #ifdef MPT_MP3ENCODER_ACM -#include <MSAcm.h> +#include <mmreg.h> +#include <msacm.h> #endif // MPT_MP3ENCODER_ACM Modified: trunk/OpenMPT/sounddev/SoundDevice.cpp =================================================================== --- trunk/OpenMPT/sounddev/SoundDevice.cpp 2014-03-22 10:16:47 UTC (rev 3932) +++ trunk/OpenMPT/sounddev/SoundDevice.cpp 2014-03-22 15:45:04 UTC (rev 3933) @@ -24,7 +24,9 @@ #include <algorithm> #include <iterator> +#include <mmreg.h> + std::wstring SoundDeviceTypeToString(SoundDeviceType type) //-------------------------------------------------------- { @@ -164,8 +166,8 @@ } -bool ISoundDevice::FillWaveFormatExtensible(WAVEFORMATEXTENSIBLE &WaveFormat) -//--------------------------------------------------------------------------- +bool FillWaveFormatExtensible(WAVEFORMATEXTENSIBLE &WaveFormat, const SoundDeviceSettings &m_Settings) +//---------------------------------------------------------------------------------------------------- { MemsetZero(WaveFormat); if(!m_Settings.sampleFormat.IsValid()) return false; Modified: trunk/OpenMPT/sounddev/SoundDevice.h =================================================================== --- trunk/OpenMPT/sounddev/SoundDevice.h 2014-03-22 10:16:47 UTC (rev 3932) +++ trunk/OpenMPT/sounddev/SoundDevice.h 2014-03-22 15:45:04 UTC (rev 3933) @@ -438,8 +438,6 @@ protected: - bool FillWaveFormatExtensible(WAVEFORMATEXTENSIBLE &WaveFormat); - const Util::MultimediaClock & Clock() const { return m_Clock; } void UpdateBufferAttributes(SoundBufferAttributes attributes); Modified: trunk/OpenMPT/sounddev/SoundDeviceDirectSound.cpp =================================================================== --- trunk/OpenMPT/sounddev/SoundDeviceDirectSound.cpp 2014-03-22 10:16:47 UTC (rev 3932) +++ trunk/OpenMPT/sounddev/SoundDeviceDirectSound.cpp 2014-03-22 15:45:04 UTC (rev 3933) @@ -19,7 +19,12 @@ #include "../common/misc_util.h" #include "../common/StringFixer.h" +#include <mmreg.h> + +bool FillWaveFormatExtensible(WAVEFORMATEXTENSIBLE &WaveFormat, const SoundDeviceSettings &m_Settings); + + //////////////////////////////////////////////////////////////////////////////////// // // DirectSound device @@ -182,7 +187,7 @@ //-------------------------------- { WAVEFORMATEXTENSIBLE wfext; - if(!FillWaveFormatExtensible(wfext)) return false; + if(!FillWaveFormatExtensible(wfext, m_Settings)) return false; WAVEFORMATEX *pwfx = &wfext.Format; const std::size_t bytesPerFrame = m_Settings.GetBytesPerFrame(); Modified: trunk/OpenMPT/sounddev/SoundDeviceThread.cpp =================================================================== --- trunk/OpenMPT/sounddev/SoundDeviceThread.cpp 2014-03-22 10:16:47 UTC (rev 3932) +++ trunk/OpenMPT/sounddev/SoundDeviceThread.cpp 2014-03-22 15:45:04 UTC (rev 3933) @@ -19,7 +19,9 @@ #include <algorithm> #include <iterator> +#include <mmsystem.h> + CAudioThread::CAudioThread(CSoundDeviceWithThread &SoundDevice) : m_SoundDevice(SoundDevice) //------------------------------------------------------------------------------------------ { Modified: trunk/OpenMPT/sounddev/SoundDeviceWaveout.cpp =================================================================== --- trunk/OpenMPT/sounddev/SoundDeviceWaveout.cpp 2014-03-22 10:16:47 UTC (rev 3932) +++ trunk/OpenMPT/sounddev/SoundDeviceWaveout.cpp 2014-03-22 15:45:04 UTC (rev 3933) @@ -18,7 +18,12 @@ #include "../common/misc_util.h" +#include <mmreg.h> + +bool FillWaveFormatExtensible(WAVEFORMATEXTENSIBLE &WaveFormat, const SoundDeviceSettings &m_Settings); + + /////////////////////////////////////////////////////////////////////////////////////// // // MMSYSTEM WaveOut Device @@ -54,7 +59,7 @@ //------------------------------ { WAVEFORMATEXTENSIBLE wfext; - if(!FillWaveFormatExtensible(wfext)) + if(!FillWaveFormatExtensible(wfext, m_Settings)) { return false; } This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <man...@us...> - 2014-03-22 19:18:30
|
Revision: 3935 http://sourceforge.net/p/modplug/code/3935 Author: manxorist Date: 2014-03-22 19:18:22 +0000 (Sat, 22 Mar 2014) Log Message: ----------- [Ref] Remove superfluous <cstdlib> includes. [Ref] Tiny header cleanups. Modified Paths: -------------- trunk/OpenMPT/common/Profiler.cpp trunk/OpenMPT/common/misc_util.cpp trunk/OpenMPT/common/misc_util.h trunk/OpenMPT/common/version.cpp trunk/OpenMPT/mptrack/StreamEncoderMP3.cpp Modified: trunk/OpenMPT/common/Profiler.cpp =================================================================== --- trunk/OpenMPT/common/Profiler.cpp 2014-03-22 16:23:39 UTC (rev 3934) +++ trunk/OpenMPT/common/Profiler.cpp 2014-03-22 19:18:22 UTC (rev 3935) @@ -10,7 +10,6 @@ #include "stdafx.h" #include "Profiler.h" -#include <stdlib.h> #ifdef USE_PROFILER Modified: trunk/OpenMPT/common/misc_util.cpp =================================================================== --- trunk/OpenMPT/common/misc_util.cpp 2014-03-22 16:23:39 UTC (rev 3934) +++ trunk/OpenMPT/common/misc_util.cpp 2014-03-22 19:18:22 UTC (rev 3935) @@ -13,7 +13,6 @@ #include <locale> #include <sstream> -#include <string> #include <time.h> Modified: trunk/OpenMPT/common/misc_util.h =================================================================== --- trunk/OpenMPT/common/misc_util.h 2014-03-22 16:23:39 UTC (rev 3934) +++ trunk/OpenMPT/common/misc_util.h 2014-03-22 19:18:22 UTC (rev 3935) @@ -12,20 +12,17 @@ #include <limits> #include <string> +#if defined(HAS_TYPE_TRAITS) +#include <type_traits> +#endif #include <vector> #include <cmath> -#include <cstdlib> #include <cstring> #include <time.h> -#include "typedefs.h" -#if defined(HAS_TYPE_TRAITS) -#include <type_traits> -#endif - bool ConvertStrToBool(const std::string &str); signed char ConvertStrToSignedChar(const std::string &str); unsigned char ConvertStrToUnsignedChar(const std::string &str); Modified: trunk/OpenMPT/common/version.cpp =================================================================== --- trunk/OpenMPT/common/version.cpp 2014-03-22 16:23:39 UTC (rev 3934) +++ trunk/OpenMPT/common/version.cpp 2014-03-22 19:18:22 UTC (rev 3935) @@ -14,8 +14,6 @@ #include <locale> #include <sstream> -#include <cstdlib> - #include "versionNumber.h" #include "svn_version.h" Modified: trunk/OpenMPT/mptrack/StreamEncoderMP3.cpp =================================================================== --- trunk/OpenMPT/mptrack/StreamEncoderMP3.cpp 2014-03-22 16:23:39 UTC (rev 3934) +++ trunk/OpenMPT/mptrack/StreamEncoderMP3.cpp 2014-03-22 19:18:22 UTC (rev 3935) @@ -26,8 +26,6 @@ #include <locale> #include <sstream> -#include <cstdlib> - // For ACM debugging purposes #define ACMLOG(x, ...) //#define ACMLOG Log This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <man...@us...> - 2014-03-23 14:46:47
|
Revision: 3937 http://sourceforge.net/p/modplug/code/3937 Author: manxorist Date: 2014-03-23 14:46:39 +0000 (Sun, 23 Mar 2014) Log Message: ----------- [Ref] serialization_utils: Avoid dragging in the whole iostream library in the header. Use a std::string instead of a std::ostringstream to cache the map data when writing. Modified Paths: -------------- trunk/OpenMPT/common/serialization_utils.cpp trunk/OpenMPT/common/serialization_utils.h trunk/OpenMPT/soundlib/Sndfile.cpp Modified: trunk/OpenMPT/common/serialization_utils.cpp =================================================================== --- trunk/OpenMPT/common/serialization_utils.cpp 2014-03-22 19:54:16 UTC (rev 3936) +++ trunk/OpenMPT/common/serialization_utils.cpp 2014-03-23 14:46:39 UTC (rev 3937) @@ -12,7 +12,10 @@ #include "serialization_utils.h" +#include <istream> #include <iterator> // for back_inserter +#include <ostream> +#include <sstream> #include "misc_util.h" @@ -365,24 +368,29 @@ rposDataStart, nDatasize); + std::ostringstream mapStream; + if(m_nIdbytes > 0) { if (m_nIdbytes != IdSizeVariable && nIdSize != m_nIdbytes) { AddWriteNote(SNW_CHANGING_IDSIZE_WITH_FIXED_IDSIZESETTING); return; } if (m_nIdbytes == IdSizeVariable) //Variablesize ID? - WriteAdaptive12(m_MapStream, static_cast<uint16>(nIdSize)); + WriteAdaptive12(mapStream, static_cast<uint16>(nIdSize)); if(nIdSize > 0) - m_MapStream.write(pId, nIdSize); + mapStream.write(pId, nIdSize); } if (GetFlag(RwfWMapStartPosEntry)) //Startpos - WriteAdaptive1248(m_MapStream, rposDataStart); + WriteAdaptive1248(mapStream, rposDataStart); if (GetFlag(RwfWMapSizeEntry)) //Entrysize - WriteAdaptive1248(m_MapStream, nDatasize); + WriteAdaptive1248(mapStream, nDatasize); if (GetFlag(RwfWMapDescEntry)) //Entry descriptions - WriteAdaptive12String(m_MapStream, std::string(pszDesc)); + WriteAdaptive12String(mapStream, std::string(pszDesc)); + + m_MapStreamString.append(mapStream.str()); + } @@ -827,7 +835,6 @@ { std::ostream& oStrm = *m_pOstrm; const Postype posDataEnd = oStrm.tellp(); - std::string mapStreamStr = m_MapStream.str(); Postype posMapStart = oStrm.tellp(); @@ -836,7 +843,7 @@ if (GetFlag(RwfRwHasMap)) //Write map { - oStrm.write(mapStreamStr.c_str(), mapStreamStr.length()); + oStrm.write(m_MapStreamString.c_str(), m_MapStreamString.length()); } const Postype posMapEnd = oStrm.tellp(); Modified: trunk/OpenMPT/common/serialization_utils.h =================================================================== --- trunk/OpenMPT/common/serialization_utils.h 2014-03-22 19:54:16 UTC (rev 3936) +++ trunk/OpenMPT/common/serialization_utils.h 2014-03-23 14:46:39 UTC (rev 3937) @@ -12,11 +12,9 @@ #include <algorithm> #include <bitset> -#include <istream> +#include <iosfwd> #include <limits> -#include <sstream> #include <string> -#include <ostream> #include <vector> #ifdef HAS_TYPE_TRAITS @@ -474,7 +472,7 @@ Postype m_posEntrycount; // Write: Pos of entrycount field. Postype m_posMapPosField; // Write: Pos of map position field. - std::ostringstream m_MapStream; // Write: Map stream. + std::string m_MapStreamString; // Write: Map stream string. }; Modified: trunk/OpenMPT/soundlib/Sndfile.cpp =================================================================== --- trunk/OpenMPT/soundlib/Sndfile.cpp 2014-03-22 19:54:16 UTC (rev 3936) +++ trunk/OpenMPT/soundlib/Sndfile.cpp 2014-03-23 14:46:39 UTC (rev 3937) @@ -23,7 +23,7 @@ #include "tuningcollection.h" #include "../common/StringFixer.h" #include "FileReader.h" -#include <iostream> +#include <sstream> #include <time.h> #ifndef NO_ARCHIVE_SUPPORT This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <man...@us...> - 2014-03-23 15:02:29
|
Revision: 3938 http://sourceforge.net/p/modplug/code/3938 Author: manxorist Date: 2014-03-23 15:02:20 +0000 (Sun, 23 Mar 2014) Log Message: ----------- [Fix] Compile fix. Modified Paths: -------------- trunk/OpenMPT/common/serialization_utils.h trunk/OpenMPT/soundlib/Sndfile.cpp Modified: trunk/OpenMPT/common/serialization_utils.h =================================================================== --- trunk/OpenMPT/common/serialization_utils.h 2014-03-23 14:46:39 UTC (rev 3937) +++ trunk/OpenMPT/common/serialization_utils.h 2014-03-23 15:02:20 UTC (rev 3938) @@ -12,8 +12,9 @@ #include <algorithm> #include <bitset> -#include <iosfwd> +#include <istream> #include <limits> +#include <ostream> #include <string> #include <vector> @@ -28,7 +29,7 @@ namespace srlztn //SeRiaLiZaTioN { -typedef std::ostream::off_type Offtype; +typedef std::ios::off_type Offtype; typedef Offtype Postype; typedef uintptr_t DataSize; // Data size type. Modified: trunk/OpenMPT/soundlib/Sndfile.cpp =================================================================== --- trunk/OpenMPT/soundlib/Sndfile.cpp 2014-03-23 14:46:39 UTC (rev 3937) +++ trunk/OpenMPT/soundlib/Sndfile.cpp 2014-03-23 15:02:20 UTC (rev 3938) @@ -23,6 +23,7 @@ #include "tuningcollection.h" #include "../common/StringFixer.h" #include "FileReader.h" +#include <iostream> #include <sstream> #include <time.h> This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |