[haiku-commits] haiku: hrev54732 - src/kits/game

  • From: Adrien Destugues <pulkomandy@xxxxxxxxx>
  • To: haiku-commits@xxxxxxxxxxxxx
  • Date: Tue, 24 Nov 2020 09:02:33 -0500 (EST)

hrev54732 adds 1 changeset to branch 'master'
old head: 15b8d49dba3eac76be0491e5183a06bdbc312948
new head: 8c78892580f132d10e624aef96f835df8d94bf19
overview: 
https://git.haiku-os.org/haiku/log/?qt=range&q=8c78892580f1+%5E15b8d49dba3e

----------------------------------------------------------------------------

8c78892580f1: BFileGameSound: don't copy garbage after track end
  
  Check for the end of track, as the stream is repositioned on the first
  frame, the start of which we were copying to the buffer if there was
  space left, whether we were looping or not.
  
  Solves #16592
  
  Change-Id: Ic49d1776577b71a4451775876597b9c9003e1d35
  Reviewed-on: https://review.haiku-os.org/c/haiku/+/3411
  Reviewed-by: Adrien Destugues <pulkomandy@xxxxxxxxx>

                                    [ Máximo Castañeda <antiswen@xxxxxxxx> ]

----------------------------------------------------------------------------

Revision:    hrev54732
Commit:      8c78892580f132d10e624aef96f835df8d94bf19
URL:         https://git.haiku-os.org/haiku/commit/?id=8c78892580f1
Author:      Máximo Castañeda <antiswen@xxxxxxxx>
Date:        Mon Nov 23 17:57:20 2020 UTC
Committer:   Adrien Destugues <pulkomandy@xxxxxxxxx>
Commit-Date: Tue Nov 24 14:02:30 2020 UTC

Ticket:      https://dev.haiku-os.org/ticket/16592

----------------------------------------------------------------------------

1 file changed, 8 insertions(+), 4 deletions(-)
src/kits/game/FileGameSound.cpp | 12 ++++++++----

----------------------------------------------------------------------------

diff --git a/src/kits/game/FileGameSound.cpp b/src/kits/game/FileGameSound.cpp
index 0882fb7a0e..7749467025 100644
--- a/src/kits/game/FileGameSound.cpp
+++ b/src/kits/game/FileGameSound.cpp
@@ -249,12 +249,14 @@ BFileGameSound::FillBuffer(void* inBuffer, size_t 
inByteCount)
        // Split or combine decoder buffers into mixer buffers
        // fPlayPosition is where we got up to in the input buffer after last 
call
 
+       char* buffer = (char*)inBuffer;
        size_t out_offset = 0;
 
        while (inByteCount > 0 && !fPaused) {
                if (!fPaused || fPausing) {
                        if (fPlayPosition == 0 || fPlayPosition >= fBufferSize) 
{
-                               Load();
+                               if (!Load())
+                                       break;
                        }
 
                        if (fPausing) {
@@ -268,7 +270,6 @@ BFileGameSound::FillBuffer(void* inBuffer, size_t 
inByteCount)
                                }
 
                                // Fill the requested buffer, stopping if the 
paused flag is set
-                               char* buffer = (char*)inBuffer;
 
                                switch(Format().format) {
                                        case gs_audio_format::B_GS_U8:
@@ -316,8 +317,6 @@ BFileGameSound::FillBuffer(void* inBuffer, size_t 
inByteCount)
                                Unlock();
                        } else {
 
-                               char* buffer = (char*)inBuffer;
-
                                // Need to be able to stop asap when the pause 
flag is flipped.
                                while (fPlayPosition < fBufferSize && (!fPaused 
|| fPausing)
                                        && (inByteCount > 0)) {
@@ -327,6 +326,10 @@ BFileGameSound::FillBuffer(void* inBuffer, size_t 
inByteCount)
                        }
                }
        }
+
+       // Fill the rest with silence
+       if (inByteCount > 0)
+               memset(&buffer[out_offset], 0, inByteCount);
 }
 
 
@@ -478,6 +481,7 @@ BFileGameSound::Load()
                        fAudioStream->stream->SeekToFrame(&frame);
                } else {
                        StopPlaying();
+                       return false;
                }
        }
 


Other related posts:

  • » [haiku-commits] haiku: hrev54732 - src/kits/game - Adrien Destugues