Skip to content

Commit

Permalink
Clamp volume in cellAudioAdd/2c/6c/Data
Browse files Browse the repository at this point in the history
Same as firmware, NaN and Inf are flushed to zero.
  • Loading branch information
elad335 authored and Nekotekina committed Nov 20, 2019
1 parent cd6b6c8 commit 8d5ef2c
Showing 1 changed file with 6 additions and 0 deletions.
6 changes: 6 additions & 0 deletions rpcs3/Emu/Cell/Modules/cellAudio.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1469,6 +1469,8 @@ error_code cellAudioAddData(u32 portNum, vm::ptr<float> src, u32 samples, float

lock.unlock();

volume = std::isfinite(volume) ? std::clamp(volume, -16.f, 16.f) : 0.f;

for (u32 i = 0; i < samples * port.num_channels; i++)
{
dst[i] += src[i] * volume; // mix all channels
Expand Down Expand Up @@ -1508,6 +1510,8 @@ error_code cellAudioAdd2chData(u32 portNum, vm::ptr<float> src, u32 samples, flo

lock.unlock();

volume = std::isfinite(volume) ? std::clamp(volume, -16.f, 16.f) : 0.f;

if (port.num_channels == 2)
{
for (u32 i = 0; i < samples; i++)
Expand Down Expand Up @@ -1574,6 +1578,8 @@ error_code cellAudioAdd6chData(u32 portNum, vm::ptr<float> src, float volume)

lock.unlock();

volume = std::isfinite(volume) ? std::clamp(volume, -16.f, 16.f) : 0.f;

if (port.num_channels == 6)
{
for (u32 i = 0; i < 256; i++)
Expand Down

0 comments on commit 8d5ef2c

Please sign in to comment.