From 671fe092d31a47b312da238ebdf1a4defca0c655 Mon Sep 17 00:00:00 2001 From: Stefano Ceccherini Date: Tue, 23 Sep 2008 12:28:18 +0000 Subject: [PATCH] Added missing break(s) in switch block in GameSoundBuffer::GetAttributes(). Added missing default case. Avoid double calculation of buffer size git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@27706 a95241bf-73f2-0310-859d-f6bbb57e9c96 --- src/kits/game/GameSoundBuffer.cpp | 15 +++++++++++---- 1 file changed, 11 insertions(+), 4 deletions(-) diff --git a/src/kits/game/GameSoundBuffer.cpp b/src/kits/game/GameSoundBuffer.cpp index 9a5b1939b9..51f7e45b2f 100644 --- a/src/kits/game/GameSoundBuffer.cpp +++ b/src/kits/game/GameSoundBuffer.cpp @@ -198,7 +198,7 @@ GameSoundBuffer::GetAttributes(gs_attribute * attributes, size_t attributeCount) { for (size_t i = 0; i < attributeCount; i++) { - switch(attributes[i].attribute) { + switch (attributes[i].attribute) { case B_GS_GAIN: attributes[i].value = fGain; if (fGainRamp) @@ -209,14 +209,17 @@ GameSoundBuffer::GetAttributes(gs_attribute * attributes, attributes[i].value = fPan; if (fPanRamp) attributes[i].duration = fGainRamp->duration; - + break; + case B_GS_LOOPING: attributes[i].value = (fLooping) ? -1.0 : 0.0; attributes[i].duration = bigtime_t(0); + break; default: attributes[i].value = 0.0; attributes[i].duration = bigtime_t(0); + break; } } @@ -242,6 +245,10 @@ GameSoundBuffer::SetAttributes(gs_attribute * attributes, case B_GS_LOOPING: fLooping = bool(attributes[i].value); + break; + + default: + break; } } @@ -465,9 +472,9 @@ SimpleSoundBuffer::SimpleSoundBuffer(const gs_audio_format * format, fPosition(0) { - fBuffer = new char[frames * fFrameSize]; fBufferSize = frames * fFrameSize; - + fBuffer = new char[fBufferSize]; + memcpy(fBuffer, data, fBufferSize); }