Skip to content

Commit

Permalink
MSVC: Fix SID (#4505)
Browse files Browse the repository at this point in the history
Use the provided working buffer instead of a local one to avoid use of VLA
  • Loading branch information
lukas-w authored and tresf committed Jan 7, 2019
1 parent 5ebe0e0 commit a0ace86
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 4 deletions.
2 changes: 0 additions & 2 deletions plugins/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -91,8 +91,6 @@ ENDIF("${PLUGIN_LIST}" STREQUAL "")
IF(MSVC)
SET(MSVC_INCOMPATIBLE_PLUGINS
LadspaEffect
sid
#VstEffect
zynaddsubfx
)
message(WARNING "Compiling with MSVC. The following plugins are not available: ${MSVC_INCOMPATIBLE_PLUGINS}")
Expand Down
6 changes: 4 additions & 2 deletions plugins/sid/sid_instrument.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -324,7 +324,8 @@ void sidInstrument::playNote( NotePlayHandle * _n,

cSID *sid = static_cast<cSID *>( _n->m_pluginData );
int delta_t = clockrate * frames / samplerate + 4;
short buf[frames];
// avoid variable length array for msvc compat
short* buf = reinterpret_cast<short*>(_working_buffer + offset);
unsigned char sidreg[NUMSIDREGS];

for (int c = 0; c < NUMSIDREGS; c++)
Expand Down Expand Up @@ -429,7 +430,8 @@ void sidInstrument::playNote( NotePlayHandle * _n,
if(num!=frames)
printf("!!!Not enough samples\n");

for( fpp_t frame = 0; frame < frames; ++frame )
// loop backwards to avoid overwriting data in the short-to-float conversion
for( fpp_t frame = frames - 1; frame >= 0; frame-- )
{
sample_t s = float(buf[frame])/32768.0;
for( ch_cnt_t ch = 0; ch < DEFAULT_CHANNELS; ++ch )
Expand Down

0 comments on commit a0ace86

Please sign in to comment.