mirror of
https://github.com/libretro/gambatte-libretro.git
synced 2024-11-23 07:49:48 +00:00
fix sound on platforms where 'unsigned long' is only 32 bits wide
Commit 1d5f921d18
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.
This commit is contained in:
parent
d7172340a2
commit
60e3a04e81
@ -103,10 +103,10 @@ namespace gambatte
|
||||
uint_least32_t *const buf = buffer_ + bufferPos_;
|
||||
|
||||
std::memset(buf, 0, cycles * sizeof(uint_least32_t));
|
||||
ch1_.update(buf, (soChVol_[0] * soVol_ * 0x1999999A) >> 32, cycles);
|
||||
ch2_.update(buf, (soChVol_[1] * soVol_ * 0x1999999A) >> 32, cycles);
|
||||
ch3_.update(buf, (soChVol_[2] * soVol_ * 0x1999999A) >> 32, cycles);
|
||||
ch4_.update(buf, (soChVol_[3] * soVol_ * 0x1999999A) >> 32, cycles);
|
||||
ch1_.update(buf, (soChVol_[0] * soVol_ * 0x1999999AULL) >> 32, cycles);
|
||||
ch2_.update(buf, (soChVol_[1] * soVol_ * 0x1999999AULL) >> 32, cycles);
|
||||
ch3_.update(buf, (soChVol_[2] * soVol_ * 0x1999999AULL) >> 32, cycles);
|
||||
ch4_.update(buf, (soChVol_[3] * soVol_ * 0x1999999AULL) >> 32, cycles);
|
||||
}
|
||||
|
||||
void PSG::generateSamples(unsigned long const cycleCounter, bool const doubleSpeed)
|
||||
|
Loading…
Reference in New Issue
Block a user