Skip to content

Commit

Permalink
Fix running timedemo if sound is disabled (s_noSound 1), fix #163
Browse files Browse the repository at this point in the history
By adding some nullpointer checks
  • Loading branch information
DanielGibson committed Jan 19, 2025
1 parent eefdd83 commit 92310f6
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 4 deletions.
3 changes: 2 additions & 1 deletion neo/sound/snd_emitter.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -952,7 +952,8 @@ void idSoundEmitterLocal::StopSound( const s_channelType channel ) {
chan->ALStop();

// if this was an onDemand sound, purge the sample now
if ( chan->leadinSample->onDemand ) {
// Note: if sound is disabled (s_noSound 1), leadinSample can be NULL
if ( chan->leadinSample && chan->leadinSample->onDemand ) {
chan->leadinSample->PurgeSoundSample();
}

Expand Down
9 changes: 6 additions & 3 deletions neo/sound/snd_world.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2148,10 +2148,13 @@ float idSoundWorldLocal::FindAmplitude( idSoundEmitterLocal *sound, const int lo
sourceBuffer[j] = j & 1 ? 32767.0f : -32767.0f;
}
} else {
int offset = (localTime - localTriggerTimes); // offset in samples
int size = ( looping ? chan->soundShader->entries[0]->LengthIn44kHzSamples() : chan->leadinSample->LengthIn44kHzSamples() );
short *amplitudeData = (short *)( looping ? chan->soundShader->entries[0]->amplitudeData : chan->leadinSample->amplitudeData );
idSoundSample* sample = looping ? chan->soundShader->entries[0] : chan->leadinSample;
if ( sample == NULL ) // DG: this happens if sound is disabled (s_noSound 1)
continue;

int offset = (localTime - localTriggerTimes); // offset in samples
int size = sample->LengthIn44kHzSamples();
short *amplitudeData = (short *)( sample->amplitudeData );
if ( amplitudeData ) {
// when the amplitudeData is present use that fill a dummy sourceBuffer
// this is to allow for amplitude based effect on hardware audio solutions
Expand Down

0 comments on commit 92310f6

Please sign in to comment.