SDL_mixer: Play the last chunk that was decoded by mpg123

From 0126a8890a227a650813ab0485df9fb9e7702539 Mon Sep 17 00:00:00 2001
From: Sam Lantinga <[EMAIL REDACTED]>
Date: Fri, 27 May 2022 13:20:24 -0700
Subject: [PATCH] Play the last chunk that was decoded by mpg123

Fixes https://github.com/libsdl-org/SDL_mixer/issues/281
---
 src/codecs/music_mpg123.c | 8 +++++++-
 1 file changed, 7 insertions(+), 1 deletion(-)

diff --git a/src/codecs/music_mpg123.c b/src/codecs/music_mpg123.c
index 0e32dc14..a8198d8a 100644
--- a/src/codecs/music_mpg123.c
+++ b/src/codecs/music_mpg123.c
@@ -360,7 +360,7 @@ static int MPG123_GetSome(void *context, void *data, int bytes, SDL_bool *done)
 {
     MPG123_Music *music = (MPG123_Music *)context;
     int filled, result;
-    size_t amount;
+    size_t amount = 0;
     long rate;
     int channels, encoding, format;
 
@@ -412,6 +412,12 @@ static int MPG123_GetSome(void *context, void *data, int bytes, SDL_bool *done)
         break;
 
     case MPG123_DONE:
+        if (amount > 0) {
+            if (SDL_AudioStreamPut(music->stream, music->buffer, (int)amount) < 0) {
+                return -1;
+            }
+            break;
+        }
         if (music->play_count == 1) {
             music->play_count = 0;
             SDL_AudioStreamFlush(music->stream);