From fd23ab2e17da6f74efdc94ed1b19ec4dd81da558 Mon Sep 17 00:00:00 2001 From: Yotam Barnoy Date: Thu, 2 Sep 2010 10:41:26 +0000 Subject: FMTOWNS AUDIO: fixed divide by zero exception from commit 52013 Also removed 1 or 2 float operations. svn-id: r52492 --- sound/softsynth/fmtowns_pc98/towns_audio.cpp | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) (limited to 'sound/softsynth') diff --git a/sound/softsynth/fmtowns_pc98/towns_audio.cpp b/sound/softsynth/fmtowns_pc98/towns_audio.cpp index 5c0961b8c3..5e1ac0201f 100644 --- a/sound/softsynth/fmtowns_pc98/towns_audio.cpp +++ b/sound/softsynth/fmtowns_pc98/towns_audio.cpp @@ -1404,8 +1404,11 @@ void TownsAudioInterface::updateOutputVolume() { // balance values for our -128 to 127 volume range // CD-AUDIO - int volume = (int)(((float)MAX(_outputLevel[12], _outputLevel[13]) * 255.0f) / 63.0f); - int balance = (int)((float)((_outputLevel[13] - _outputLevel[12]) * 127.0f) / (float)MAX(_outputLevel[12], _outputLevel[13])); + uint32 maxVol = MAX(_outputLevel[12], _outputLevel[13]); + + int volume = (int)(maxVol * (255.0f / 63.0f)); + int balance = maxVol ? (int)( ( ((int)_outputLevel[13] - _outputLevel[12]) * 127) / (float)maxVol) : 0; + AudioCD.setVolume(volume); AudioCD.setBalance(balance); } -- cgit v1.2.3