Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Merged
merged 1 commit into from
Dec 22, 2020

Conversation

stspdotname
Copy link
Contributor

Commit 1d5f921 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.

Commit 1d5f921 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
Copy link
Contributor

Good catch. Thanks for contributing.

@inactive123 inactive123 merged commit 0af99f8 into libretro:master Dec 22, 2020
@bslenul
Copy link
Contributor

bslenul commented Dec 22, 2020

Exact same issue as explained here: #167 (comment)

@inactive123
Copy link
Contributor

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants