Update to v094r28 release.

byuu says:

This WIP substantially restructures the ruby API for the first time
since that project started.

It is my hope that with this restructuring, destruction of the ruby
objects should now be deterministic, which should fix the crashing on
closing the emulator on Linux. We'll see I guess ... either way, it
removed two layers of wrappers from ruby, so it's a pretty nice code
cleanup.

It won't compile on Windows due to a few issues I didn't see until
uploading the WIP, too lazy to upload another. But I fixed all the
compilation issues locally, so it'll work on Windows again with the next
WIP (unless I break something else.)

(Kind of annoying that Linux defines glActiveTexture but Windows
doesn't.)
This commit is contained in:
Tim Allen
2015-06-20 15:44:05 +10:00
parent 20cc6148cb
commit e0815b55b9
58 changed files with 485 additions and 890 deletions

View File

@@ -1,8 +1,8 @@
#include <alsa/asoundlib.h>
namespace ruby {
struct AudioALSA : Audio {
~AudioALSA() { term(); }
struct pAudioALSA {
struct {
snd_pcm_t* handle = nullptr;
snd_pcm_format_t format = SND_PCM_FORMAT_S16_LE;
@@ -23,10 +23,6 @@ struct pAudioALSA {
unsigned latency = 60;
} settings;
~pAudioALSA() {
term();
}
auto cap(const string& name) -> bool {
if(name == Audio::Synchronize) return true;
if(name == Audio::Frequency) return true;
@@ -127,8 +123,6 @@ struct pAudioALSA {
}
auto init() -> bool {
term();
if(snd_pcm_open(&device.handle, device.name, SND_PCM_STREAM_PLAYBACK, SND_PCM_NONBLOCK) < 0) {
term();
return false;
@@ -216,7 +210,3 @@ struct pAudioALSA {
}
}
};
DeclareAudio(ALSA)
};

View File

@@ -1,8 +1,8 @@
#include <ao/ao.h>
namespace ruby {
struct AudioAO : Audio {
~AudioAO() { term(); }
struct pAudioAO {
int driver_id;
ao_sample_format driver_format;
ao_device* audio_device = nullptr;
@@ -11,15 +11,6 @@ struct pAudioAO {
unsigned frequency = 22050;
} settings;
pAudioAO() {
ao_initialize();
}
~pAudioAO() {
term();
//ao_shutdown(); //FIXME: this is causing a segfault for some reason when called ...
}
auto cap(const string& name) -> bool {
if(name == Audio::Frequency) return true;
return false;
@@ -49,7 +40,7 @@ struct pAudioAO {
}
auto init() -> bool {
term();
ao_initialize();
driver_id = ao_default_driver_id(); //ao_driver_id((const char*)driver)
if(driver_id < 0) return false;
@@ -77,9 +68,6 @@ struct pAudioAO {
ao_close(audio_device);
audio_device = nullptr;
}
ao_shutdown();
}
};
DeclareAudio(AO)
};

View File

@@ -1,8 +1,8 @@
#include <dsound.h>
namespace ruby {
struct AudioDS : Audio {
~AudioDS() { term(); }
struct pAudioDS {
LPDIRECTSOUND ds = nullptr;
LPDIRECTSOUNDBUFFER dsb_p = nullptr;
LPDIRECTSOUNDBUFFER dsb_b = nullptr;
@@ -28,14 +28,6 @@ struct pAudioDS {
unsigned latency = 120;
} settings;
pAudioDS() {
settings.handle = GetDesktopWindow();
}
~pAudioDS() {
term();
}
auto cap(const string& name) -> bool {
if(name == Audio::Handle) return true;
if(name == Audio::Synchronize) return true;
@@ -138,7 +130,7 @@ struct pAudioDS {
}
auto init() -> bool {
term();
settings.handle = GetDesktopWindow();
device.rings = 8;
device.latency = settings.frequency * settings.latency / device.rings / 1000.0 + 0.5;
@@ -189,7 +181,3 @@ struct pAudioDS {
if(ds) { ds->Release(); ds = 0; }
}
};
DeclareAudio(DS)
};

View File

@@ -6,9 +6,9 @@
#include <AL/alc.h>
#endif
namespace ruby {
struct AudioOpenAL : Audio {
~AudioOpenAL() { term(); }
struct pAudioOpenAL {
struct {
ALCdevice* handle = nullptr;
ALCcontext* context = nullptr;
@@ -30,10 +30,6 @@ struct pAudioOpenAL {
unsigned latency = 40;
} settings;
~pAudioOpenAL() {
term();
}
auto cap(const string& name) -> bool {
if(name == Audio::Synchronize) return true;
if(name == Audio::Frequency) return true;
@@ -196,7 +192,3 @@ private:
buffer.data = new uint32_t[buffer.size]();
}
};
DeclareAudio(OpenAL)
};

View File

@@ -18,9 +18,9 @@
#define SNDCTL_DSP_POLICY _IOW('P', 45, signed)
#endif
namespace ruby {
struct AudioOSS : Audio {
~AudioOSS() { term(); }
struct pAudioOSS {
struct {
signed fd = -1;
signed format = AFMT_S16_LE;
@@ -33,10 +33,6 @@ struct pAudioOSS {
unsigned frequency = 22050;
} settings;
~pAudioOSS() {
term();
}
auto cap(const string& name) -> bool {
if(name == Audio::Device) return true;
if(name == Audio::Synchronize) return true;
@@ -82,8 +78,6 @@ struct pAudioOSS {
}
auto init() -> bool {
term();
device.fd = open(settings.device, O_WRONLY, O_NONBLOCK);
if(device.fd < 0) return false;
@@ -119,7 +113,3 @@ private:
fcntl(device.fd, F_SETFL, flags);
}
};
DeclareAudio(OSS)
};

View File

@@ -1,8 +1,8 @@
#include <pulse/pulseaudio.h>
namespace ruby {
struct AudioPulseAudio : Audio {
~AudioPulseAudio() { term(); }
struct pAudioPulseAudio {
struct {
pa_mainloop* mainloop = nullptr;
pa_context* context = nullptr;
@@ -24,10 +24,6 @@ struct pAudioPulseAudio {
unsigned latency = 60;
} settings;
~pAudioPulseAudio() {
term();
}
auto cap(const string& name) -> bool {
if(name == Audio::Synchronize) return true;
if(name == Audio::Frequency) return true;
@@ -161,7 +157,3 @@ struct pAudioPulseAudio {
}
}
};
DeclareAudio(PulseAudio)
}

View File

@@ -1,9 +1,9 @@
#include <pulse/simple.h>
#include <pulse/error.h>
namespace ruby {
struct AudioPulseAudioSimple : Audio {
~AudioPulseAudioSimple() { term(); }
struct pAudioPulseAudioSimple {
struct {
pa_simple* handle = nullptr;
pa_sample_spec spec;
@@ -18,10 +18,6 @@ struct pAudioPulseAudioSimple {
unsigned frequency = 22050;
} settings;
~pAudioPulseAudioSimple() {
term();
}
auto cap(const string& name) -> bool {
if(name == Audio::Frequency) return true;
return false;
@@ -57,8 +53,6 @@ struct pAudioPulseAudioSimple {
}
auto init() -> bool {
term();
device.spec.format = PA_SAMPLE_S16LE;
device.spec.channels = 2;
device.spec.rate = settings.frequency;
@@ -99,7 +93,3 @@ struct pAudioPulseAudioSimple {
}
}
};
DeclareAudio(PulseAudioSimple)
};

View File

@@ -1,9 +1,9 @@
#include "xaudio2.hpp"
#include <windows.h>
namespace ruby {
struct AudioXAudio2 : Audio, public IXAudio2VoiceCallback {
AudioXAudio2() { term(); }
struct pAudioXAudio2 : public IXAudio2VoiceCallback {
IXAudio2* pXAudio2 = nullptr;
IXAudio2MasteringVoice* pMasterVoice = nullptr;
IXAudio2SourceVoice* pSourceVoice = nullptr;
@@ -33,10 +33,6 @@ struct pAudioXAudio2 : public IXAudio2VoiceCallback {
unsigned latency = 120;
} settings;
~pAudioXAudio2() {
term();
}
auto cap(const string& name) -> bool {
if(name == Audio::Synchronize) return true;
if(name == Audio::Frequency) return true;
@@ -117,8 +113,6 @@ struct pAudioXAudio2 : public IXAudio2VoiceCallback {
}
auto init() -> bool {
term();
device.buffers = 8;
device.latency = settings.frequency * settings.latency / device.buffers / 1000.0 + 0.5;
device.buffer = new uint32_t[device.latency * device.buffers];
@@ -187,7 +181,3 @@ struct pAudioXAudio2 : public IXAudio2VoiceCallback {
InterlockedDecrement(&device.submitbuffers);
}
};
DeclareAudio(XAudio2)
};