Fix WiiU-Software backend buffer being 5ms
5ms is too small: it cannot be updated fast enough, resulting in crackling coming from the gamepad speakers. Now it's 10ms, as intended.
This commit is contained in:
parent
20440ff5e0
commit
cbeeb7a180
1 changed files with 12 additions and 12 deletions
|
@ -84,28 +84,28 @@ static void FrameCallback(void)
|
||||||
AXVoiceOffsets offsets;
|
AXVoiceOffsets offsets;
|
||||||
AXGetVoiceOffsets(voices[0], &offsets);
|
AXGetVoiceOffsets(voices[0], &offsets);
|
||||||
|
|
||||||
unsigned int current_buffer = offsets.currentOffset > (buffer_length / 2) ? 1 : 0; // TODO - should probably be '>='
|
unsigned int current_buffer = offsets.currentOffset > buffer_length ? 1 : 0; // TODO - should probably be '>='
|
||||||
|
|
||||||
static unsigned int last_buffer = 1;
|
static unsigned int last_buffer = 1;
|
||||||
|
|
||||||
if (current_buffer != last_buffer)
|
if (current_buffer != last_buffer)
|
||||||
{
|
{
|
||||||
// Clear the mixer buffer
|
// Clear the mixer buffer
|
||||||
for (unsigned int i = 0; i < (buffer_length / 2) * 2; ++i)
|
for (unsigned int i = 0; i < buffer_length * 2; ++i)
|
||||||
stream_buffer_float[i] = 0.0f;
|
stream_buffer_float[i] = 0.0f;
|
||||||
|
|
||||||
// Fill mixer buffer
|
// Fill mixer buffer
|
||||||
FillMixerBuffer(stream_buffer_float, buffer_length / 2);
|
FillMixerBuffer(stream_buffer_float, buffer_length;
|
||||||
|
|
||||||
// Deinterlate samples, convert them to S16, and write them to the double-buffers
|
// Deinterlate samples, convert them to S16, and write them to the double-buffers
|
||||||
short *left_output_buffer = &stream_buffers[0][(buffer_length / 2) * last_buffer];
|
short *left_output_buffer = &stream_buffers[0][buffer_length * last_buffer];
|
||||||
short *right_output_buffer = &stream_buffers[1][(buffer_length / 2) * last_buffer];
|
short *right_output_buffer = &stream_buffers[1][buffer_length * last_buffer];
|
||||||
|
|
||||||
float *mixer_buffer_pointer = stream_buffer_float;
|
float *mixer_buffer_pointer = stream_buffer_float;
|
||||||
short *left_output_buffer_pointer = left_output_buffer;
|
short *left_output_buffer_pointer = left_output_buffer;
|
||||||
short *right_output_buffer_pointer = right_output_buffer;
|
short *right_output_buffer_pointer = right_output_buffer;
|
||||||
|
|
||||||
for (unsigned int i = 0; i < buffer_length / 2; ++i)
|
for (unsigned int i = 0; i < buffer_length; ++i)
|
||||||
{
|
{
|
||||||
float left_sample = *mixer_buffer_pointer++;
|
float left_sample = *mixer_buffer_pointer++;
|
||||||
float right_sample = *mixer_buffer_pointer++;
|
float right_sample = *mixer_buffer_pointer++;
|
||||||
|
@ -127,8 +127,8 @@ static void FrameCallback(void)
|
||||||
}
|
}
|
||||||
|
|
||||||
// Make sure the sound hardware can see our data
|
// Make sure the sound hardware can see our data
|
||||||
DCStoreRange(left_output_buffer, (buffer_length / 2) * sizeof(short));
|
DCStoreRange(left_output_buffer, buffer_length * sizeof(short));
|
||||||
DCStoreRange(right_output_buffer, (buffer_length / 2) * sizeof(short));
|
DCStoreRange(right_output_buffer, buffer_length * sizeof(short));
|
||||||
|
|
||||||
last_buffer = current_buffer;
|
last_buffer = current_buffer;
|
||||||
}
|
}
|
||||||
|
@ -160,15 +160,15 @@ bool AudioBackend_Init(void)
|
||||||
|
|
||||||
// The software-mixer outputs interlaced float samples, so create
|
// The software-mixer outputs interlaced float samples, so create
|
||||||
// a buffer for it here.
|
// a buffer for it here.
|
||||||
stream_buffer_float = (float*)malloc((buffer_length / 2) * sizeof(float) * 2);
|
stream_buffer_float = (float*)malloc(buffer_length * sizeof(float) * 2); // `* 2` because it's an interlaced stereo buffer
|
||||||
|
|
||||||
if (stream_buffer_float != NULL)
|
if (stream_buffer_float != NULL)
|
||||||
{
|
{
|
||||||
stream_buffers[0] = (short*)malloc(buffer_length * sizeof(short));
|
stream_buffers[0] = (short*)malloc(buffer_length * sizeof(short) * 2); // `* 2` because it's a double-buffer
|
||||||
|
|
||||||
if (stream_buffers[0] != NULL)
|
if (stream_buffers[0] != NULL)
|
||||||
{
|
{
|
||||||
stream_buffers[1] = (short*)malloc(buffer_length * sizeof(short));
|
stream_buffers[1] = (short*)malloc(buffer_length * sizeof(short) * 2); // `* 2` because it's a double-buffer
|
||||||
|
|
||||||
if (stream_buffers[1] != NULL)
|
if (stream_buffers[1] != NULL)
|
||||||
{
|
{
|
||||||
|
@ -204,7 +204,7 @@ bool AudioBackend_Init(void)
|
||||||
.dataType = AX_VOICE_FORMAT_LPCM16,
|
.dataType = AX_VOICE_FORMAT_LPCM16,
|
||||||
.loopingEnabled = AX_VOICE_LOOP_ENABLED,
|
.loopingEnabled = AX_VOICE_LOOP_ENABLED,
|
||||||
.loopOffset = 0,
|
.loopOffset = 0,
|
||||||
.endOffset = buffer_length,
|
.endOffset = buffer_length * 2,
|
||||||
.currentOffset = 0,
|
.currentOffset = 0,
|
||||||
.data = stream_buffers[i]
|
.data = stream_buffers[i]
|
||||||
};
|
};
|
||||||
|
|
Loading…
Add table
Reference in a new issue