From: <man...@us...> - 2013-06-08 17:35:03
|
Revision: 2325 http://sourceforge.net/p/modplug/code/2325 Author: manxorist Date: 2013-06-08 17:34:54 +0000 (Sat, 08 Jun 2013) Log Message: ----------- [Ref] Add seperate CSoundFile::ReadInterleved and ReadNonInterleaved as wrappers around Read. [Ref] Make Read and CreateStereoMix private. Modified Paths: -------------- trunk/OpenMPT/libopenmpt/libopenmpt_impl.cpp trunk/OpenMPT/mptrack/MainFrm.cpp trunk/OpenMPT/mptrack/Mod2wave.cpp trunk/OpenMPT/soundlib/Sndfile.h trunk/OpenMPT/soundlib/Sndmix.cpp Modified: trunk/OpenMPT/libopenmpt/libopenmpt_impl.cpp =================================================================== --- trunk/OpenMPT/libopenmpt/libopenmpt_impl.cpp 2013-06-08 17:20:22 UTC (rev 2324) +++ trunk/OpenMPT/libopenmpt/libopenmpt_impl.cpp 2013-06-08 17:34:54 UTC (rev 2325) @@ -166,10 +166,9 @@ std::size_t count_read = 0; while ( count > 0 ) { std::int16_t * const buffers[4] = { left + count_read, right + count_read, rear_left + count_read, rear_right + count_read }; - std::size_t count_chunk = m_sndFile->Read( - 0, - static_cast<UINT>( std::min<std::size_t>( count, std::numeric_limits<UINT>::max() / 2 / 4 / 4 ) ), // safety margin / samplesize / channels - reinterpret_cast<void*const*>( buffers ) + std::size_t count_chunk = m_sndFile->ReadNonInterleaved( + reinterpret_cast<void*const*>( buffers ), + static_cast<CSoundFile::samplecount_t>( std::min<std::uint64_t>( count, std::numeric_limits<CSoundFile::samplecount_t>::max() / 2 / 4 / 4 ) ) // safety margin / samplesize / channels ); if ( count_chunk == 0 ) { break; @@ -183,10 +182,9 @@ std::size_t count_read = 0; while ( count > 0 ) { float * const buffers[4] = { left + count_read, right + count_read, rear_left + count_read, rear_right + count_read }; - std::size_t count_chunk = m_sndFile->Read( - 0, - static_cast<UINT>( std::min<std::size_t>( count, std::numeric_limits<UINT>::max() / 2 / 4 / 4 ) ), // safety margin / samplesize / channels - reinterpret_cast<void*const*>( buffers ) + std::size_t count_chunk = m_sndFile->ReadNonInterleaved( + reinterpret_cast<void*const*>( buffers ), + static_cast<CSoundFile::samplecount_t>( std::min<std::uint64_t>( count, std::numeric_limits<CSoundFile::samplecount_t>::max() / 2 / 4 / 4 ) ) // safety margin / samplesize / channels ); if ( count_chunk == 0 ) { break; Modified: trunk/OpenMPT/mptrack/MainFrm.cpp =================================================================== --- trunk/OpenMPT/mptrack/MainFrm.cpp 2013-06-08 17:20:22 UTC (rev 2324) +++ trunk/OpenMPT/mptrack/MainFrm.cpp 2013-06-08 17:34:54 UTC (rev 2325) @@ -784,7 +784,7 @@ //------------------------------------------------------------------------------- { OPENMPT_PROFILE_FUNCTION(Profiler::Audio); - return m_pSndFile->Read(pvData, MaxSamples); + return m_pSndFile->ReadInterleaved(pvData, MaxSamples); } Modified: trunk/OpenMPT/mptrack/Mod2wave.cpp =================================================================== --- trunk/OpenMPT/mptrack/Mod2wave.cpp 2013-06-08 17:20:22 UTC (rev 2324) +++ trunk/OpenMPT/mptrack/Mod2wave.cpp 2013-06-08 17:34:54 UTC (rev 2325) @@ -778,7 +778,7 @@ CMainFrame::GetMainFrame()->InitRenderer(m_pSndFile); //rewbs.VSTTimeInfo for (UINT n = 0; ; n++) { - UINT lRead = m_pSndFile->Read(buffer, sizeof(buffer)/(m_pSndFile->m_MixerSettings.gnChannels*m_pSndFile->m_MixerSettings.GetBitsPerSample()/8)); + UINT lRead = m_pSndFile->ReadInterleaved(buffer, sizeof(buffer)/(m_pSndFile->m_MixerSettings.gnChannels*m_pSndFile->m_MixerSettings.GetBitsPerSample()/8)); // Process cue points (add base offset), if there are any to process. vector<PatternCuePoint>::reverse_iterator iter; @@ -1152,7 +1152,7 @@ UINT lRead = 0; if (!bFinished) { - lRead = m_pSndFile->Read(pcmBuffer + WAVECONVERTBUFSIZE - pcmBufSize, pcmBufSize/(m_pSndFile->m_MixerSettings.gnChannels*m_pSndFile->m_MixerSettings.GetBitsPerSample()/8)); + lRead = m_pSndFile->ReadInterleaved(pcmBuffer + WAVECONVERTBUFSIZE - pcmBufSize, pcmBufSize/(m_pSndFile->m_MixerSettings.gnChannels*m_pSndFile->m_MixerSettings.GetBitsPerSample()/8)); if (!lRead) bFinished = true; } ullSamples += lRead; Modified: trunk/OpenMPT/soundlib/Sndfile.h =================================================================== --- trunk/OpenMPT/soundlib/Sndfile.h 2013-06-08 17:20:22 UTC (rev 2324) +++ trunk/OpenMPT/soundlib/Sndfile.h 2013-06-08 17:34:54 UTC (rev 2325) @@ -587,8 +587,12 @@ void StopAllVsti(); //rewbs.VSTCompliance void RecalculateGainForAllPlugs(); void ResetChannels(); - UINT Read(LPVOID lpBuffer, UINT cbBuffer, void * const *outputBuffers = nullptr); + samplecount_t ReadInterleaved(void *outputBuffer, samplecount_t count); + samplecount_t ReadNonInterleaved(void * const *outputBuffers, samplecount_t count); +private: + UINT Read(UINT cbBuffer, LPVOID lpBuffer, void * const *outputBuffers = nullptr); void CreateStereoMix(int count); +public: BOOL FadeSong(UINT msec); BOOL GlobalFadeSong(UINT msec); void ProcessPlugins(UINT nCount); Modified: trunk/OpenMPT/soundlib/Sndmix.cpp =================================================================== --- trunk/OpenMPT/soundlib/Sndmix.cpp 2013-06-08 17:20:22 UTC (rev 2324) +++ trunk/OpenMPT/soundlib/Sndmix.cpp 2013-06-08 17:34:54 UTC (rev 2325) @@ -193,7 +193,21 @@ } -UINT CSoundFile::Read(LPVOID lpDestBuffer, UINT count, void * const *outputBuffers) +CSoundFile::samplecount_t CSoundFile::ReadInterleaved(void *outputBuffer, samplecount_t count) +//-------------------------------------------------------------------------------------------- +{ + return Read(count, outputBuffer, nullptr); +} + + +CSoundFile::samplecount_t CSoundFile::ReadNonInterleaved(void * const *outputBuffers, samplecount_t count) +//-------------------------------------------------------------------------------------------------------- +{ + return Read(count, nullptr, outputBuffers); +} + + +UINT CSoundFile::Read(UINT count, LPVOID lpDestBuffer, void * const *outputBuffers) //--------------------------------------------------------------------------------- { LPBYTE lpBuffer = (LPBYTE)lpDestBuffer; This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |