shithub: cstory

Download patch

ref: e0c67b421ab592827f959d4f3bdd78a372657df6
parent: 371d66255b2c8eed667af68cb540ecbf29c29fc6
author: Clownacy <Clownacy@users.noreply.github.com>
date: Tue Jun 30 16:38:28 EDT 2020

Add constant to control number of Wii U buffers

--- a/src/Backends/Audio/WiiU-Software.cpp
+++ b/src/Backends/Audio/WiiU-Software.cpp
@@ -14,6 +14,8 @@
 
 #include "SoftwareMixer.h"
 
+#define AUDIO_BUFFERS 2	// Double-buffer
+
 #define MIN(a, b) ((a) < (b) ? (a) : (b))
 #define MAX(a, b) ((a) > (b) ? (a) : (b))
 #define CLAMP(x, y, z) MIN(MAX((x), (y)), (z))
@@ -163,11 +165,11 @@
 
 	if (stream_buffer_long != NULL)
 	{
-		stream_buffers[0] = (short*)malloc(buffer_length * sizeof(short) * 2);	// `* 2` because it's a double-buffer
+		stream_buffers[0] = (short*)malloc(buffer_length * sizeof(short) * AUDIO_BUFFERS);
 
 		if (stream_buffers[0] != NULL)
 		{
-			stream_buffers[1] = (short*)malloc(buffer_length * sizeof(short) * 2);	// `* 2` because it's a double-buffer
+			stream_buffers[1] = (short*)malloc(buffer_length * sizeof(short) * AUDIO_BUFFERS);
 
 			if (stream_buffers[1] != NULL)
 			{
@@ -203,7 +205,7 @@
 								.dataType = AX_VOICE_FORMAT_LPCM16,
 								.loopingEnabled = AX_VOICE_LOOP_ENABLED,
 								.loopOffset = 0,
-								.endOffset = (buffer_length * 2) - 1,	// -1 or else you'll get popping!
+								.endOffset = (buffer_length * AUDIO_BUFFERS) - 1,	// -1 or else you'll get popping!
 								.currentOffset = 0,
 								.data = stream_buffers[i]
 							};