Fix Windows build. Tweak XAudio a bit.

This commit is contained in:
Alias Letterman 2019-02-09 16:46:08 -06:00
parent 845366f139
commit b1039e7c65
5 changed files with 14 additions and 10 deletions

View File

@ -106,7 +106,8 @@ bool8 S9xMixSamples(uint8 *dest, int sample_count)
}
}
if (spc::resampler->space_empty() >= 535 * 2)
if (spc::resampler->space_empty() >= 535 * 2 || !Settings.SoundSync ||
Settings.TurboMode || Settings.Mute)
spc::sound_in_sync = true;
else
spc::sound_in_sync = false;
@ -128,7 +129,8 @@ void S9xLandSamples(void)
if (spc::callback != NULL)
spc::callback(spc::callback_data);
if (spc::resampler->space_empty() >= 535 * 2)
if (spc::resampler->space_empty() >= 535 * 2 || !Settings.SoundSync ||
Settings.TurboMode || Settings.Mute)
spc::sound_in_sync = true;
else
spc::sound_in_sync = false;

View File

@ -149,8 +149,8 @@ class Resampler
while (r_frac <= 1.0 && o_position < num_samples)
{
hermite_val[0] = hermite(r_frac, r_left[0], r_left[1], r_left[2], r_left[3]);
hermite_val[1] = hermite(r_frac, r_right[0], r_right[1], r_right[2], r_right[3]);
hermite_val[0] = (int)hermite(r_frac, r_left[0], r_left[1], r_left[2], r_left[3]);
hermite_val[1] = (int)hermite(r_frac, r_right[0], r_right[1], r_right[2], r_right[3]);
data[o_position] = short_clamp(hermite_val[0]);
data[o_position + 1] = short_clamp(hermite_val[1]);

View File

@ -8,6 +8,7 @@
#include "memmap.h"
#include "display.h"
#include "msu1.h"
#include "apu/resampler.h"
#include "apu/bapu/dsp/blargg_endian.h"
#include <fstream>
#include <sys/stat.h>

2
msu1.h
View File

@ -7,7 +7,6 @@
#ifndef _MSU1_H_
#define _MSU1_H_
#include "snes9x.h"
#include "apu/resampler.h"
#define MSU1_REVISION 0x02
@ -52,6 +51,7 @@ void S9xMSU1Generate(size_t sample_count);
uint8 S9xMSU1ReadPort(uint8 port);
void S9xMSU1WritePort(uint8 port, uint8 byte);
size_t S9xMSU1Samples(void);
class Resampler;
void S9xMSU1SetOutput(Resampler *resampler);
void S9xMSU1PostLoadState(void);

View File

@ -146,7 +146,7 @@ bool CXAudio2::InitVoices(void)
wfx.cbSize = 0;
if( FAILED(hr = pXAudio2->CreateSourceVoice(&pSourceVoice, (WAVEFORMATEX*)&wfx,
XAUDIO2_VOICE_USEFILTER, XAUDIO2_DEFAULT_FREQ_RATIO, this, NULL, NULL ) ) ) {
XAUDIO2_VOICE_NOSRC, XAUDIO2_DEFAULT_FREQ_RATIO, this, NULL, NULL ) ) ) {
DXTRACE_ERR_MSGBOX(TEXT("Unable to create source voice."),hr);
return false;
}
@ -305,11 +305,12 @@ void CXAudio2::ProcessSound()
if (partialOffset != 0) {
BYTE *offsetBuffer = soundBuffer + writeOffset + partialOffset;
UINT32 samplesleftinblock = (singleBufferBytes - partialOffset) >> (Settings.SixteenBitSound ? 1 : 0);
if (availableSamples < ((singleBufferBytes - partialOffset) >> (Settings.SixteenBitSound ? 1 : 0)))
UINT32 samplesleftinblock = (singleBufferBytes - partialOffset) >> 1;
if (availableSamples <= samplesleftinblock)
{
S9xMixSamples(offsetBuffer, availableSamples);
partialOffset += availableSamples << (Settings.SixteenBitSound ? 1 : 0);
partialOffset += availableSamples << 1;
availableSamples = 0;
}
else
@ -323,7 +324,7 @@ void CXAudio2::ProcessSound()
}
}
while (availableSamples > singleBufferSamples && bufferCount < blockCount) {
while (availableSamples >= singleBufferSamples && bufferCount < blockCount) {
BYTE *curBuffer = soundBuffer + writeOffset;
S9xMixSamples(curBuffer, singleBufferSamples);
PushBuffer(singleBufferBytes, curBuffer, NULL);