|
From: <sag...@us...> - 2014-10-19 22:17:15
|
Revision: 4449
http://sourceforge.net/p/modplug/code/4449
Author: saga-games
Date: 2014-10-19 22:17:05 +0000 (Sun, 19 Oct 2014)
Log Message:
-----------
[Fix] Replacing a sample didn't update the sample length properly when the sample loop was active, leading to possible garbage playback.
Modified Paths:
--------------
trunk/OpenMPT/soundlib/modsmp_ctrl.cpp
trunk/OpenMPT/soundlib/modsmp_ctrl.h
Modified: trunk/OpenMPT/soundlib/modsmp_ctrl.cpp
===================================================================
--- trunk/OpenMPT/soundlib/modsmp_ctrl.cpp 2014-10-19 20:47:50 UTC (rev 4448)
+++ trunk/OpenMPT/soundlib/modsmp_ctrl.cpp 2014-10-19 22:17:05 UTC (rev 4449)
@@ -34,7 +34,7 @@
CriticalSection cs;
- ctrlChn::ReplaceSample(sndFile.m_PlayState.Chn, &smp, pNewSample, nNewLength, setFlags, resetFlags);
+ ctrlChn::ReplaceSample(sndFile.m_PlayState.Chn, smp, pNewSample, nNewLength, setFlags, resetFlags);
smp.pSample = pNewSample;
smp.nLength = nNewLength;
ModSample::FreeSample(pOldSmp);
@@ -737,7 +737,7 @@
{
void ReplaceSample( ModChannel (&Chn)[MAX_CHANNELS],
- const ModSample * const pSample,
+ const ModSample &sample,
const void * const pNewSample,
const SmpLength nNewLength,
FlagSet<ChannelFlags> setFlags,
@@ -745,14 +745,23 @@
{
for (CHANNELINDEX i = 0; i < MAX_CHANNELS; i++)
{
- if (Chn[i].pModSample == pSample)
+ if (Chn[i].pModSample == &sample)
{
if (Chn[i].pCurrentSample != nullptr)
Chn[i].pCurrentSample = pNewSample;
if (Chn[i].nPos > nNewLength)
Chn[i].nPos = 0;
if (Chn[i].nLength > 0)
- Chn[i].nLength = nNewLength;
+ LimitMax(Chn[i].nLength, nNewLength);
+ if(Chn[i].InSustainLoop())
+ {
+ Chn[i].nLoopStart = sample.nSustainStart;
+ Chn[i].nLoopEnd = sample.nSustainEnd;
+ } else
+ {
+ Chn[i].nLoopStart = sample.nLoopStart;
+ Chn[i].nLoopEnd = sample.nLoopEnd;
+ }
Chn[i].dwFlags.set(setFlags);
Chn[i].dwFlags.reset(resetFlags);
}
Modified: trunk/OpenMPT/soundlib/modsmp_ctrl.h
===================================================================
--- trunk/OpenMPT/soundlib/modsmp_ctrl.h 2014-10-19 20:47:50 UTC (rev 4448)
+++ trunk/OpenMPT/soundlib/modsmp_ctrl.h 2014-10-19 22:17:05 UTC (rev 4449)
@@ -95,7 +95,7 @@
// Replaces sample from sound channels by given sample.
void ReplaceSample( ModChannel (&Chn)[MAX_CHANNELS],
- const ModSample * const pSample,
+ const ModSample &sample,
const void * const pNewSample,
const SmpLength nNewLength,
FlagSet<ChannelFlags> setFlags,
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|