- fixed endless loop in replay gain analyzer when getting passed music with an unhandled sample rate.

This commit is contained in:
Christoph Oelckers 2021-07-11 09:11:59 +02:00
parent 1b45c83d59
commit a98507f737
2 changed files with 12 additions and 8 deletions

View file

@ -618,8 +618,10 @@ static void CheckReplayGain(const char *musicname, EMidiDevice playertype, const
ZMusic_Close(handle); ZMusic_Close(handle);
GainAnalyzer analyzer; GainAnalyzer analyzer;
analyzer.InitGainAnalysis(fmt.mSampleRate); int result = analyzer.InitGainAnalysis(fmt.mSampleRate);
int result = analyzer.AnalyzeSamples(lbuffer.Data(), rbuffer.Size() == 0 ? nullptr : rbuffer.Data(), lbuffer.Size(), rbuffer.Size() == 0? 1: 2); if (result == GAIN_ANALYSIS_OK)
{
result = analyzer.AnalyzeSamples(lbuffer.Data(), rbuffer.Size() == 0 ? nullptr : rbuffer.Data(), lbuffer.Size(), rbuffer.Size() == 0 ? 1 : 2);
if (result == GAIN_ANALYSIS_OK) if (result == GAIN_ANALYSIS_OK)
{ {
auto gain = analyzer.GetTitleGain(); auto gain = analyzer.GetTitleGain();
@ -630,6 +632,7 @@ static void CheckReplayGain(const char *musicname, EMidiDevice playertype, const
mus_playing.replayGainFactor = dBToAmplitude(mus_playing.replayGain + mus_gainoffset); mus_playing.replayGainFactor = dBToAmplitude(mus_playing.replayGain + mus_gainoffset);
SaveGains(); SaveGains();
} }
}
} }
bool S_ChangeMusic(const char* musicname, int order, bool looping, bool force) bool S_ChangeMusic(const char* musicname, int order, bool looping, bool force)

View file

@ -251,6 +251,7 @@ GainAnalyzer::ResetSampleFrequency(int samplefreq) {
freqindex = 9; freqindex = 9;
break; break;
case 11025: case 11025:
case 11111: // SW shareware tries to play a VOC with this frequency as music. This is close enough to 11025 to use the same table.
freqindex = 10; freqindex = 10;
break; break;
case 8000: case 8000: