arnaud-carre / sndh-player

ATARI-ST SNDH Archive music browser/player
39 stars 3 forks source link

Uninitialized variables causes crash #13

Closed aargirakis closed 6 months ago

aargirakis commented 6 months ago

I've added snd-player to BZR Player. I got random crashes maybe every 10th play and saw that in ym2149c.cpp the variables m_dcAdjustPos and m_dcAdjustSum is increased/decreased in dcAdjust() but they are never initialized to 0 in Reset(). After I initialized them I had no more crashes. However some files (or randomly) the sound gets distorted, I'm just guessing that there are maybe more uninitialized variable thay my cause that.

turbohz commented 6 months ago

@aargirakis

I'm having similar problems (I was developing a Godot Engine module to playback .sndh files).

In addition to initializing both m_dcAdjustPos and m_dcAdjustSum, I found that clearing the m_dcAdjustBuffer fixed some things.

memset(m_dcAdjustBuffer,0,sizeof(m_dcAdjustBuffer));

I'm a C++ noob, so that might be wrong, or be unsound advice :)

aargirakis commented 6 months ago

@turbohz Well, whaddayaknow! That fixed my issues, it seems, thanks!

arnaud-carre commented 6 months ago

good catch! I just fixed it in main branch, thanks