mirror of
https://github.com/bsnes-emu/bsnes.git
synced 2025-08-10 15:03:58 +02:00
Update to v094r24 release.
byuu says: Finally!! Compilation works once again on Windows. However, it's pretty buggy. Modality isn't really working right, you can still poke at other windows, but when you select ListView items, they redraw as empty boxes (need to process WM_DRAWITEM before checking modality.) The program crashes when you close it (probably a ruby driver's term() function, that's what it usually is.) The Layout::setEnabled(false) call isn't working right, so you get that annoying chiming sound and cursor movement when mapping keyboard keys to game inputs. The column sizing seems off a bit on first display for the Hotkeys tab. And probably lots more.
This commit is contained in:
@@ -3,11 +3,10 @@
|
||||
|
||||
namespace ruby {
|
||||
|
||||
class pAudioXAudio2: public IXAudio2VoiceCallback {
|
||||
public:
|
||||
IXAudio2* pXAudio2;
|
||||
IXAudio2MasteringVoice* pMasterVoice;
|
||||
IXAudio2SourceVoice* pSourceVoice;
|
||||
struct pAudioXAudio2 : public IXAudio2VoiceCallback {
|
||||
IXAudio2* pXAudio2 = nullptr;
|
||||
IXAudio2MasteringVoice* pMasterVoice = nullptr;
|
||||
IXAudio2SourceVoice* pSourceVoice = nullptr;
|
||||
|
||||
//inherited from IXAudio2VoiceCallback
|
||||
STDMETHODIMP_(void) OnBufferStart(void* pBufferContext){}
|
||||
@@ -18,51 +17,55 @@ public:
|
||||
STDMETHODIMP_(void) OnVoiceProcessingPassStart(UINT32 BytesRequired) {}
|
||||
|
||||
struct {
|
||||
unsigned buffers;
|
||||
unsigned latency;
|
||||
unsigned buffers = 0;
|
||||
unsigned latency = 0;
|
||||
|
||||
uint32_t* buffer;
|
||||
unsigned bufferoffset;
|
||||
uint32_t* buffer = nullptr;
|
||||
unsigned bufferoffset = 0;
|
||||
|
||||
volatile long submitbuffers;
|
||||
unsigned writebuffer;
|
||||
volatile long submitbuffers = 0;
|
||||
unsigned writebuffer = 0;
|
||||
} device;
|
||||
|
||||
struct {
|
||||
bool synchronize;
|
||||
unsigned frequency;
|
||||
unsigned latency;
|
||||
bool synchronize = false;
|
||||
unsigned frequency = 22050;
|
||||
unsigned latency = 120;
|
||||
} settings;
|
||||
|
||||
bool cap(const string& name) {
|
||||
~pAudioXAudio2() {
|
||||
term();
|
||||
}
|
||||
|
||||
auto cap(const string& name) -> bool {
|
||||
if(name == Audio::Synchronize) return true;
|
||||
if(name == Audio::Frequency) return true;
|
||||
if(name == Audio::Latency) return true;
|
||||
return false;
|
||||
}
|
||||
|
||||
any get(const string& name) {
|
||||
auto get(const string& name) -> any {
|
||||
if(name == Audio::Synchronize) return settings.synchronize;
|
||||
if(name == Audio::Frequency) return settings.frequency;
|
||||
if(name == Audio::Latency) return settings.latency;
|
||||
return false;
|
||||
return {};
|
||||
}
|
||||
|
||||
bool set(const string& name, const any& value) {
|
||||
if(name == Audio::Synchronize) {
|
||||
settings.synchronize = any_cast<bool>(value);
|
||||
auto set(const string& name, const any& value) -> bool {
|
||||
if(name == Audio::Synchronize && value.is<bool>()) {
|
||||
settings.synchronize = value.get<bool>();
|
||||
if(pXAudio2) clear();
|
||||
return true;
|
||||
}
|
||||
|
||||
if(name == Audio::Frequency) {
|
||||
settings.frequency = any_cast<unsigned>(value);
|
||||
if(name == Audio::Frequency && value.is<unsigned>()) {
|
||||
settings.frequency = value.get<unsigned>();
|
||||
if(pXAudio2) init();
|
||||
return true;
|
||||
}
|
||||
|
||||
if(name == Audio::Latency) {
|
||||
settings.latency = any_cast<unsigned>(value);
|
||||
if(name == Audio::Latency && value.is<unsigned>()) {
|
||||
settings.latency = value.get<unsigned>();
|
||||
if(pXAudio2) init();
|
||||
return true;
|
||||
}
|
||||
@@ -70,7 +73,7 @@ public:
|
||||
return false;
|
||||
}
|
||||
|
||||
void pushbuffer(unsigned bytes, uint32_t* pAudioData) {
|
||||
auto pushbuffer(unsigned bytes, uint32_t* pAudioData) -> void {
|
||||
XAUDIO2_BUFFER xa2buffer = {0};
|
||||
xa2buffer.AudioBytes = bytes;
|
||||
xa2buffer.pAudioData = reinterpret_cast<BYTE*>(pAudioData);
|
||||
@@ -79,7 +82,7 @@ public:
|
||||
pSourceVoice->SubmitSourceBuffer(&xa2buffer);
|
||||
}
|
||||
|
||||
void sample(uint16_t left, uint16_t right) {
|
||||
auto sample(uint16_t left, uint16_t right) -> void {
|
||||
device.buffer[device.writebuffer * device.latency + device.bufferoffset++] = left + (right << 16);
|
||||
if(device.bufferoffset < device.latency) return;
|
||||
device.bufferoffset = 0;
|
||||
@@ -100,7 +103,7 @@ public:
|
||||
device.writebuffer = (device.writebuffer + 1) % device.buffers;
|
||||
}
|
||||
|
||||
void clear() {
|
||||
auto clear() -> void {
|
||||
if(!pSourceVoice) return;
|
||||
pSourceVoice->Stop(0);
|
||||
pSourceVoice->FlushSourceBuffers(); //calls OnBufferEnd for all currently submitted buffers
|
||||
@@ -113,7 +116,7 @@ public:
|
||||
pSourceVoice->Start(0);
|
||||
}
|
||||
|
||||
bool init() {
|
||||
auto init() -> bool {
|
||||
term();
|
||||
|
||||
device.buffers = 8;
|
||||
@@ -160,7 +163,7 @@ public:
|
||||
return true;
|
||||
}
|
||||
|
||||
void term() {
|
||||
auto term() -> void {
|
||||
if(pSourceVoice) {
|
||||
pSourceVoice->Stop(0);
|
||||
pSourceVoice->DestroyVoice();
|
||||
@@ -183,21 +186,6 @@ public:
|
||||
STDMETHODIMP_(void) OnBufferEnd(void* pBufferContext) {
|
||||
InterlockedDecrement(&device.submitbuffers);
|
||||
}
|
||||
|
||||
pAudioXAudio2() {
|
||||
pXAudio2 = nullptr;
|
||||
pMasterVoice = nullptr;
|
||||
pSourceVoice = nullptr;
|
||||
|
||||
device.buffer = nullptr;
|
||||
device.bufferoffset = 0;
|
||||
device.submitbuffers = 0;
|
||||
device.writebuffer = 0;
|
||||
|
||||
settings.synchronize = false;
|
||||
settings.frequency = 22050;
|
||||
settings.latency = 120;
|
||||
}
|
||||
};
|
||||
|
||||
DeclareAudio(XAudio2)
|
||||
|
Reference in New Issue
Block a user