mirror of https://github.com/snes9xgit/snes9x.git
Ensure all MSU-1 reads are stereo channel aligned
This commit is contained in:
parent
3fba3492d2
commit
15f76f7eca
|
@ -530,7 +530,7 @@ bool8 S9xInitSound (int buffer_ms, int lag_ms)
|
||||||
return (FALSE);
|
return (FALSE);
|
||||||
if (msu::landing_buffer)
|
if (msu::landing_buffer)
|
||||||
delete[] msu::landing_buffer;
|
delete[] msu::landing_buffer;
|
||||||
msu::landing_buffer = new uint8[msu::buffer_size * 2];
|
msu::landing_buffer = (uint8*) new uint32[msu::buffer_size / 2]; // Ensure 4-byte alignment
|
||||||
if (!msu::landing_buffer)
|
if (!msu::landing_buffer)
|
||||||
return (FALSE);
|
return (FALSE);
|
||||||
|
|
||||||
|
|
26
msu1.cpp
26
msu1.cpp
|
@ -420,21 +420,27 @@ bool S9xMSU1ROMExists(void)
|
||||||
|
|
||||||
void S9xMSU1Generate(size_t sample_count)
|
void S9xMSU1Generate(size_t sample_count)
|
||||||
{
|
{
|
||||||
partial_samples += 4410 * sample_count;
|
partial_samples += 4410 * ((sample_count + 1) &~(size_t)(1));
|
||||||
|
bufPos = (int16*)(((long long)bufPos + 1) &~(long long)(3));
|
||||||
|
|
||||||
while (((uintptr_t)bufPos < (uintptr_t)bufEnd) && partial_samples > 3204)
|
while (((uintptr_t)bufPos < (uintptr_t)bufEnd) && partial_samples > 6408)
|
||||||
{
|
{
|
||||||
if (MSU1.MSU1_STATUS & AudioPlaying && audioStream)
|
if (MSU1.MSU1_STATUS & AudioPlaying && audioStream)
|
||||||
{
|
{
|
||||||
int16 sample;
|
int32 sample;
|
||||||
int bytes_read = READ_STREAM((char *)&sample, 2, audioStream);
|
int16* left = (int16*)&sample;
|
||||||
if (bytes_read == 2)
|
int16* right = left + 1;
|
||||||
{
|
|
||||||
sample = (int16)((double)(int16)GET_LE16(&sample) * (double)MSU1.MSU1_VOLUME / 255.0);
|
|
||||||
|
|
||||||
*(bufPos++) = sample;
|
int bytes_read = READ_STREAM((char *)&sample, 4, audioStream);
|
||||||
MSU1.MSU1_AUDIO_POS += 2;
|
if (bytes_read == 4)
|
||||||
partial_samples -= 3204;
|
{
|
||||||
|
*left = (int16)((double)(int16)GET_LE16(left) * (double)MSU1.MSU1_VOLUME / 255.0);
|
||||||
|
*right = (int16)((double)(int16)GET_LE16(right) * (double)MSU1.MSU1_VOLUME / 255.0);
|
||||||
|
|
||||||
|
*(bufPos++) = *left;
|
||||||
|
*(bufPos++) = *right;
|
||||||
|
MSU1.MSU1_AUDIO_POS += 4;
|
||||||
|
partial_samples -= 6408;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
if (bytes_read >= 0)
|
if (bytes_read >= 0)
|
||||||
|
|
Loading…
Reference in New Issue