Skip to content

Commit 3d68bf2

Browse files
committed
goto considered useful
The `continue` statement in these error checks had no effect because the error checks are macros implemented in a `do` ... `while (false)` loop. So, use `goto`. There is precedent with other instances of `OpenAL_ErrorCheck` in the code. This may fix the issue where sound would occasionally randomly stop, requiring a pause or a screen change to get it back. This would be difficult to verify though. Thanks to Coverity for flagging this situation!
1 parent c2314f6 commit 3d68bf2

1 file changed

Lines changed: 4 additions & 2 deletions

File tree

code/sound/ds.cpp

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -772,7 +772,7 @@ int ds_get_free_channel_retail(float new_volume, int snd_id, int priority)
772772
continue;
773773
}
774774

775-
OpenAL_ErrorCheck( alGetSourcei(chp->source_id, AL_SOURCE_STATE, &status), continue );
775+
OpenAL_ErrorCheck( alGetSourcei(chp->source_id, AL_SOURCE_STATE, &status), goto continue_channels );
776776

777777
if ( (status == AL_INITIAL) || (status == AL_STOPPED) ) {
778778
ds_close_channel_fast(i);
@@ -795,6 +795,7 @@ int ds_get_free_channel_retail(float new_volume, int snd_id, int priority)
795795
lowest_vol = chp->vol;
796796
}
797797
}
798+
continue_channels: ;
798799
}
799800

800801
// If we've exceeded the limit, then maybe stop the duplicate if it is lower volume
@@ -885,7 +886,7 @@ int ds_get_free_channel_enhanced(float new_volume, int snd_id, int enhanced_prio
885886
continue;
886887
}
887888

888-
OpenAL_ErrorCheck( alGetSourcei(chp->source_id, AL_SOURCE_STATE, &status), continue );
889+
OpenAL_ErrorCheck( alGetSourcei(chp->source_id, AL_SOURCE_STATE, &status), goto continue_channels );
889890

890891
if ( (status == AL_INITIAL) || (status == AL_STOPPED) ) {
891892
ds_close_channel_fast(i);
@@ -924,6 +925,7 @@ int ds_get_free_channel_enhanced(float new_volume, int snd_id, int enhanced_prio
924925
least_important_priority = chp->priority;
925926
}
926927
}
928+
continue_channels: ;
927929
}
928930

929931
// If we've exceeded the limit, then stop the least important duplicate if it is lower or equal volume

0 commit comments

Comments
 (0)