libretro / gambatte-libretro

Hard fork of Gambatte to the libretro API.
http://sourceforge.net/projects/gambatte/
GNU General Public License v2.0
105 stars 79 forks source link

fix sound on platforms where 'unsigned long' is only 32 bits wide #173

Closed stspdotname closed 3 years ago

stspdotname commented 3 years ago

Commit 1d5f921d1846a2939b83334157b30dd7a34e80c8 introduced a bit shift that is too wide on 32 bit platforms. This results in the volume of all channels being set to zero in the internal mixer.

Problem observed on a Raspberry Pi Zero W, where the compiler also complains:

libgambatte/src/sound.cpp:106:63: warning: right shift count >= width of type [-Wshift-count-overflow] ch1.update(buf, (soChVol[0] soVol_ 0x1999999A) >> 32, cycles); ^~

Fix this problem by expanding the constant 0x1999999A to unsigned long long via the 'ULL' suffix. This results in all values in the expression being promoted to 'unsigned long long', which is 64 bit wide everywhere.

inactive123 commented 3 years ago

Good catch. Thanks for contributing.

bslenul commented 3 years ago

Exact same issue as explained here: https://github.com/libretro/gambatte-libretro/pull/167#issuecomment-749486542

inactive123 commented 3 years ago

Hi there, as per @jdgleaver's recommendation, I am reverting this PR for now until the Holidays are over, and then we can properly go over this and implement it in a way so everyone is happy and all platforms work. My bad.