Update to v104r06 release.

byuu says:

Changelog:

  - gba,ws: removed Thread::step() override¹
  - processor/m68k: move.b (a7)+ and move.b (a7)- adjust a7 by two, not
    by one²
  - tomoko: created new initialize(Video,Audio,Input)Driver() functions³
  - ruby/audio: split Audio::information into
    Audio::available(Devices,Frequencies,Latencies,Channels)³
  - ws: added Model::(WonderSwan,WonderSwanColor,SwanCrystal)()
    functions for consistency with other cores

¹: this should hopefully fix GBA Pokemon Pinball. Thanks to
SuperMikeMan for pointing out the underlying cause.

²: this fixes A Ressaha de Ikou, Mega Bomberman, and probably more
games.

³: this is the big change: so there was a problem with WASAPI where
you might change your device under the audio settings panel. And your
new device may not support the frequency that your old device used. This
would end up not updating the frequency, and the pitch would be
distorted.

The old Audio::information() couldn't tell you what frequencies,
latencies, or channels were available for all devices simultaneously, so
I had to split them up. The new initializeAudioDriver() function
validates you have a correct driver, or it defaults to none. Then it
validates a correct device name, or it defaults to the first entry in
the list. Then it validates a correct frequency, or defaults to the
first in the list. Then finally it validates a correct latency, or
defaults to the first in the list.

In this way ... we have a clear path now with no API changes required to
select default devices, frequencies, latencies, channel counts: they
need to be the first items in their respective lists.

So, what we need to do now is go through and for every audio driver that
enumerates devices, we need to make sure the default device gets added
to the top of the list. I'm ... not really sure how to do this with most
drivers, so this is definitely going to take some time.

Also, when you change a device, initializeAudioDriver() is called again,
so if it's a bad device, it will disable the audio driver instead of
continuing to send samples at it and hoping that the driver blocked
those API calls when it failed to initialize properly.

Now then ... since it was a decently-sized API change, it's possible
I've broken compilation of the Linux drivers, so please report any
compilation errors so that I can fix them.
This commit is contained in:
Tim Allen 2017-08-26 11:15:49 +10:00
parent ea3c2dafda
commit afa8ea61c5
28 changed files with 302 additions and 193 deletions

View File

@ -12,7 +12,7 @@ using namespace nall;
namespace Emulator {
static const string Name = "higan";
static const string Version = "104.05";
static const string Version = "104.06";
static const string Author = "byuu";
static const string License = "GPLv3";
static const string Website = "http://byuu.org/";

View File

@ -36,10 +36,6 @@ namespace GameBoyAdvance {
inline auto synchronize(Thread& thread) -> void {
if(clock() >= thread.clock()) scheduler.resume(thread);
}
inline auto step(uint clocks) -> void {
_clock += clocks;
}
};
#include <gba/memory/memory.hpp>

View File

@ -86,14 +86,16 @@ template<uint Size, bool Hold> auto M68K::read(EffectiveAddress& ea) -> uint32 {
}
case AddressRegisterIndirectWithPostIncrement: {
auto address = ea.address + (ea.reg == 7 && Size == Byte ? bytes<Word>() : bytes<Size>());
auto data = read<Size>(ea.address);
if(!Hold) write(AddressRegister{ea.reg}, ea.address += bytes<Size>());
if(!Hold) write(AddressRegister{ea.reg}, ea.address = address);
return data;
}
case AddressRegisterIndirectWithPreDecrement: {
auto data = read<Size>(ea.address - bytes<Size>());
if(!Hold) write(AddressRegister{ea.reg}, ea.address -= bytes<Size>());
auto address = ea.address - (ea.reg == 7 && Size == Byte ? bytes<Word>() : bytes<Size>());
auto data = read<Size>(address);
if(!Hold) write(AddressRegister{ea.reg}, ea.address = address);
return data;
}
@ -148,14 +150,16 @@ template<uint Size, bool Hold> auto M68K::write(EffectiveAddress& ea, uint32 dat
}
case AddressRegisterIndirectWithPostIncrement: {
auto address = ea.address + (ea.reg == 7 && Size == Byte ? bytes<Word>() : bytes<Size>());
write<Size>(ea.address, data);
if(!Hold) write(AddressRegister{ea.reg}, ea.address += bytes<Size>());
if(!Hold) write(AddressRegister{ea.reg}, ea.address = address);
return;
}
case AddressRegisterIndirectWithPreDecrement: {
write<Size, Reverse>(ea.address - bytes<Size>(), data);
if(!Hold) write(AddressRegister{ea.reg}, ea.address -= bytes<Size>());
auto address = ea.address - (ea.reg == 7 && Size == Byte ? bytes<Word>() : bytes<Size>());
write<Size, Reverse>(address, data);
if(!Hold) write(AddressRegister{ea.reg}, ea.address = address);
return;
}

View File

@ -43,33 +43,9 @@ Program::Program(string_vector args) {
settings["Crashed"].setValue(true);
settings.save();
if(!Video::availableDrivers().find(settings["Video/Driver"].text())) {
settings["Video/Driver"].setValue("None");
}
video = Video::create(settings["Video/Driver"].text());
video->setContext(presentation->viewport.handle());
video->setBlocking(settings["Video/Synchronize"].boolean());
if(!video->ready()) MessageDialog().setText("Failed to initialize video driver").warning();
presentation->clearViewport();
if(!Audio::availableDrivers().find(settings["Audio/Driver"].text())) {
settings["Audio/Driver"].setValue("None");
}
audio = Audio::create(settings["Audio/Driver"].text());
audio->setExclusive(settings["Audio/Exclusive"].boolean());
audio->setContext(presentation->viewport.handle());
audio->setDevice(settings["Audio/Device"].text());
audio->setBlocking(settings["Audio/Synchronize"].boolean());
audio->setChannels(2);
if(!audio->ready()) MessageDialog().setText("Failed to initialize audio driver").warning();
if(!Input::availableDrivers().find(settings["Input/Driver"].text())) {
settings["Input/Driver"].setValue("None");
}
input = Input::create(settings["Input/Driver"].text());
input->setContext(presentation->viewport.handle());
input->onChange({&InputManager::onChange, &inputManager()});
if(!input->ready()) MessageDialog().setText("Failed to initialize input driver").warning();
initializeVideoDriver();
initializeAudioDriver();
initializeInputDriver();
settings["Crashed"].setValue(false);
settings.save();

View File

@ -26,6 +26,10 @@ struct Program : Emulator::Platform {
auto saveState(uint slot, bool managed = false) -> bool;
//utility.cpp
auto initializeVideoDriver() -> void;
auto initializeAudioDriver() -> void;
auto initializeInputDriver() -> void;
auto powerCycle() -> void;
auto rotateDisplay() -> void;
auto connectDevices() -> void;

View File

@ -1,3 +1,69 @@
auto Program::initializeVideoDriver() -> void {
if(!Video::availableDrivers().find(settings["Video/Driver"].text())) {
settings["Video/Driver"].setValue("None");
}
video = Video::create(settings["Video/Driver"].text());
video->setContext(presentation->viewport.handle());
video->setBlocking(settings["Video/Synchronize"].boolean());
if(!video->ready()) {
MessageDialog().setText("Failed to initialize video driver").warning();
video = Video::create("None");
}
presentation->clearViewport();
}
auto Program::initializeAudioDriver() -> void {
if(!Audio::availableDrivers().find(settings["Audio/Driver"].text())) {
settings["Audio/Driver"].setValue("None");
}
audio = Audio::create(settings["Audio/Driver"].text());
audio->setContext(presentation->viewport.handle());
if(!audio->availableDevices().find(settings["Audio/Device"].text())) {
settings["Audio/Device"].setValue(audio->availableDevices()(0));
}
audio->setDevice(settings["Audio/Device"].text());
if(!audio->availableFrequencies().find(settings["Audio/Frequency"].real())) {
settings["Audio/Frequency"].setValue(audio->availableFrequencies()(0));
}
audio->setFrequency(settings["Audio/Frequency"].real());
if(!audio->availableLatencies().find(settings["Audio/Latency"].natural())) {
settings["Audio/Latency"].setValue(audio->availableLatencies()(0));
}
audio->setLatency(settings["Audio/Latency"].real());
audio->setChannels(2);
audio->setExclusive(settings["Audio/Exclusive"].boolean());
audio->setBlocking(settings["Audio/Synchronize"].boolean());
if(!audio->ready()) {
MessageDialog().setText("Failed to initialize audio driver").warning();
audio = Audio::create("None");
}
Emulator::audio.setFrequency(settings["Audio/Frequency"].real());
}
auto Program::initializeInputDriver() -> void {
if(!Input::availableDrivers().find(settings["Input/Driver"].text())) {
settings["Input/Driver"].setValue("None");
}
input = Input::create(settings["Input/Driver"].text());
input->setContext(presentation->viewport.handle());
input->onChange({&InputManager::onChange, &inputManager()});
if(!input->ready()) {
MessageDialog().setText("Failed to initialize input driver").warning();
input = Input::create("None");
}
}
auto Program::powerCycle() -> void {
if(!emulator) return;
emulator->power();
@ -78,7 +144,6 @@ auto Program::updateVideoShader() -> void {
auto Program::updateAudioDriver() -> void {
if(!audio) return;
audio->clear();
audio->setDevice(settings["Audio/Device"].text());
audio->setExclusive(settings["Audio/Exclusive"].boolean());
audio->setFrequency(settings["Audio/Frequency"].real());
audio->setLatency(settings["Audio/Latency"].natural());

View File

@ -7,11 +7,13 @@ AudioSettings::AudioSettings(TabFrame* parent) : TabFrameItem(parent) {
driverLabel.setFont(Font().setBold()).setText("Driver");
deviceLabel.setText("Device:");
deviceList.onChange([&] { updateDevice(); updateDriver(); });
deviceList.onChange([&] {
settings["Audio/Device"].setValue(deviceList.selected().text());
program->initializeAudioDriver();
updateDevice();
});
//the device list never changes once a driver is activated;
//however, the available frequencies and latencies may change when the active device is changed
for(auto& device : audio->information().devices) {
for(auto& device : audio->availableDevices()) {
deviceList.append(ComboButtonItem().setText(device));
if(device == settings["Audio/Device"].text()) {
deviceList.item(deviceList.itemCount() - 1).setSelected();
@ -19,13 +21,22 @@ AudioSettings::AudioSettings(TabFrame* parent) : TabFrameItem(parent) {
}
frequencyLabel.setText("Frequency:");
frequencyList.onChange([&] { updateDriver(); });
frequencyList.onChange([&] {
settings["Audio/Frequency"].setValue(frequencyList.selected().text());
program->updateAudioDriver();
});
latencyLabel.setText("Latency:");
latencyList.onChange([&] { updateDriver(); });
latencyList.onChange([&] {
settings["Audio/Latency"].setValue(latencyList.selected().text());
program->updateAudioDriver();
});
exclusiveMode.setText("Exclusive mode");
exclusiveMode.setChecked(settings["Audio/Exclusive"].boolean()).onToggle([&] { updateDriver(); });
exclusiveMode.setChecked(settings["Audio/Exclusive"].boolean()).onToggle([&] {
settings["Audio/Exclusive"].setValue(exclusiveMode.checked());
program->updateAudioDriver();
});
effectsLabel.setFont(Font().setBold()).setText("Effects");
@ -40,13 +51,12 @@ AudioSettings::AudioSettings(TabFrame* parent) : TabFrameItem(parent) {
reverbEnable.setText("Reverb").setChecked(settings["Audio/Reverb/Enable"].boolean()).onToggle([&] { updateEffects(); });
updateDevice();
updateDriver(true);
updateEffects(true);
}
auto AudioSettings::updateDevice() -> void {
frequencyList.reset();
for(auto& frequency : audio->information().frequencies) {
for(auto& frequency : audio->availableFrequencies()) {
frequencyList.append(ComboButtonItem().setText(frequency));
if(frequency == settings["Audio/Frequency"].real()) {
frequencyList.item(frequencyList.itemCount() - 1).setSelected();
@ -54,7 +64,7 @@ auto AudioSettings::updateDevice() -> void {
}
latencyList.reset();
for(auto& latency : audio->information().latencies) {
for(auto& latency : audio->availableLatencies()) {
latencyList.append(ComboButtonItem().setText(latency));
if(latency == settings["Audio/Latency"].natural()) {
latencyList.item(latencyList.itemCount() - 1).setSelected();
@ -62,15 +72,6 @@ auto AudioSettings::updateDevice() -> void {
}
}
auto AudioSettings::updateDriver(bool initializing) -> void {
settings["Audio/Device"].setValue(deviceList.selected().text());
settings["Audio/Frequency"].setValue(frequencyList.selected().text());
settings["Audio/Latency"].setValue(latencyList.selected().text());
settings["Audio/Exclusive"].setValue(exclusiveMode.checked());
if(!initializing) program->updateAudioDriver();
}
auto AudioSettings::updateEffects(bool initializing) -> void {
settings["Audio/Volume"].setValue(volumeSlider.position());
volumeValue.setText({volumeSlider.position(), "%"});

View File

@ -64,7 +64,6 @@ struct AudioSettings : TabFrameItem {
CheckLabel reverbEnable{&layout, Size{~0, 0}};
auto updateDevice() -> void;
auto updateDriver(bool initializing = false) -> void;
auto updateEffects(bool initializing = false) -> void;
};

View File

@ -44,18 +44,16 @@ auto Cartridge::power() -> void {
auto Cartridge::load() -> bool {
information = {};
switch(system.model()) {
case Model::WonderSwan:
if(Model::WonderSwan()) {
if(auto loaded = platform->load(ID::WonderSwan, "WonderSwan", "ws")) {
information.pathID = loaded.pathID();
} else return false;
break;
case Model::WonderSwanColor:
case Model::SwanCrystal:
}
if(Model::WonderSwanColor() || Model::SwanCrystal()) {
if(auto loaded = platform->load(ID::WonderSwanColor, "WonderSwan Color", "wsc")) {
information.pathID = loaded.pathID();
} else return false;
break;
}
if(auto fp = platform->open(pathID(), "manifest.bml", File::Read, File::Required)) {

View File

@ -51,7 +51,7 @@ auto CPU::power() -> void {
bus.map(this, 0x00a0);
bus.map(this, 0x00b0, 0x00b6);
if(system.model() != Model::WonderSwan) {
if(!Model::WonderSwan()) {
bus.map(this, 0x0040, 0x0049);
bus.map(this, 0x0062);
}

View File

@ -43,15 +43,15 @@ auto CPU::portRead(uint16 addr) -> uint8 {
//WSC_SYSTEM
if(addr == 0x0062) return (
(system.model() == Model::SwanCrystal) << 7
Model::SwanCrystal() << 7
);
//HW_FLAGS
if(addr == 0x00a0) {
bool model = system.model() != Model::WonderSwan;
bool color = !Model::WonderSwan();
return (
1 << 0 //0 = BIOS mapped; 1 = cartridge mapped
| model << 1 //0 = WonderSwan; 1 = WonderSwan Color or SwanCrystal
| color << 1 //0 = WonderSwan; 1 = WonderSwan Color or SwanCrystal
| 1 << 2 //0 = 8-bit bus width; 1 = 16-bit bus width
| 1 << 7 //1 = built-in self-test passed
);
@ -59,7 +59,7 @@ auto CPU::portRead(uint16 addr) -> uint8 {
//INT_BASE
if(addr == 0x00b0) return (
r.interruptBase | (system.model() == Model::WonderSwan ? 3 : 0)
r.interruptBase | (Model::WonderSwan() ? 3 : 0)
);
//SER_DATA
@ -122,7 +122,7 @@ auto CPU::portWrite(uint16 addr, uint8 data) -> void {
//INT_BASE
if(addr == 0x00b0) {
r.interruptBase = (system.model() == Model::WonderSwan) ? data & ~7 : data & ~1;
r.interruptBase = Model::WonderSwan() ? data & ~7 : data & ~1;
}
//SER_DATA

View File

@ -32,6 +32,6 @@ auto WonderSwanColorInterface::videoColor(uint32 color) -> uint64 {
}
auto WonderSwanColorInterface::load(uint id) -> bool {
if(id == ID::WonderSwanColor) return system.load(this, Model::WonderSwanColor);
if(id == ID::WonderSwanColor) return system.load(this, System::Model::WonderSwanColor);
return false;
}

View File

@ -35,6 +35,6 @@ auto WonderSwanInterface::videoColor(uint32 color) -> uint64 {
}
auto WonderSwanInterface::load(uint id) -> bool {
if(id == ID::WonderSwan) return system.load(this, Model::WonderSwan);
if(id == ID::WonderSwan) return system.load(this, System::Model::WonderSwan);
return false;
}

View File

@ -10,7 +10,7 @@ auto InternalRAM::power() -> void {
}
auto InternalRAM::serialize(serializer& s) -> void {
s.array(memory, system.model() == Model::WonderSwan ? 0x4000 : 0x10000);
s.array(memory, Model::WonderSwan() ? 0x4000 : 0x10000);
}
auto InternalRAM::read(uint16 addr, uint size) -> uint32 {

View File

@ -209,11 +209,11 @@ auto PPU::portWrite(uint16 addr, uint8 data) -> void {
r.lcdContrast = data.bit (1);
r.lcdUnknown = data.bits(2,7);
if(system.model() == Model::WonderSwanColor) {
if(Model::WonderSwanColor()) {
r.lcdUnknown &= 0b111100;
}
if(system.model() == Model::SwanCrystal) {
if(Model::SwanCrystal()) {
r.lcdContrast = 0;
r.lcdUnknown = 0;
}

View File

@ -1,4 +1,6 @@
struct System : IO {
enum class Model : uint { WonderSwan, WonderSwanColor, SwanCrystal };
auto loaded() const -> bool { return _loaded; }
auto model() const -> Model { return _model; }
auto color() const -> bool { return r.color; }
@ -61,3 +63,7 @@ private:
};
extern System system;
auto Model::WonderSwan() -> bool { return system.model() == System::Model::WonderSwan; }
auto Model::WonderSwanColor() -> bool { return system.model() == System::Model::WonderSwanColor; }
auto Model::SwanCrystal() -> bool { return system.model() == System::Model::SwanCrystal; }

View File

@ -18,12 +18,6 @@ namespace WonderSwan {
extern Scheduler scheduler;
extern Cheat cheat;
enum class Model : uint {
WonderSwan, //SW-001 (ASWAN)
WonderSwanColor, //WSC-001 (SPHINX)
SwanCrystal, //SCT-001 (SPHINX2)
};
enum : uint { Byte = 1, Word = 2, Long = 4 };
struct Thread : Emulator::Thread {
@ -35,10 +29,12 @@ namespace WonderSwan {
inline auto synchronize(Thread& thread) -> void {
if(clock() >= thread.clock()) scheduler.resume(thread);
}
};
inline auto step(uint clocks) -> void {
_clock += clocks;
}
struct Model {
inline static auto WonderSwan() -> bool; //SW-001 (ASWAN)
inline static auto WonderSwanColor() -> bool; //WSC-001 (SPHINX)
inline static auto SwanCrystal() -> bool; //SCT-001 (SPHINX2)
};
#include <ws/memory/memory.hpp>

View File

@ -4,17 +4,23 @@ struct AudioALSA : Audio {
AudioALSA() { initialize(); }
~AudioALSA() { terminate(); }
auto ready() -> bool { return _ready; }
auto information() -> Information {
Information information;
information.devices = queryDevices();
information.frequencies = {44100.0, 48000.0, 96000.0};
information.latencies = {20, 40, 60, 80, 100};
information.channels = {2};
return information;
auto availableDevices() -> string_vector {
return queryDevices();
}
auto availableFrequencies() -> vector<double> {
return {44100.0, 48000.0, 96000.0};
}
auto availableLatencies() -> vector<uint> {
return {20, 40, 60, 80, 100};
}
auto availableChannels() -> vector<uint> {
return {2};
}
auto ready() -> bool { return _ready; }
auto device() -> string { return _device; }
auto blocking() -> bool { return _blocking; }
auto channels() -> uint { return 2; }

View File

@ -4,17 +4,23 @@ struct AudioAO : Audio {
AudioAO() { initialize(); }
~AudioAO() { terminate(); }
auto ready() -> bool { return _ready; }
auto information() -> Information {
Information information;
information.devices = {_device};
information.frequencies = {44100.0, 48000.0, 96000.0};
information.latencies = {100};
information.channels = {2};
return information;
auto availableDevices() -> string_vector {
return {"Default"};
}
auto availableFrequencies() -> vector<double> {
return {44100.0, 48000.0, 96000.0};
}
auto availableLatencies() -> vector<uint> {
return {100};
}
auto availableChannels() -> vector<uint> {
return {2};
}
auto ready() -> bool { return _ready; }
auto blocking() -> bool { return true; }
auto channels() -> uint { return 2; }
auto frequency() -> double { return _frequency; }

View File

@ -5,22 +5,32 @@ struct AudioASIO : Audio {
AudioASIO() { self = this; initialize(); }
~AudioASIO() { terminate(); }
auto ready() -> bool { return _ready; }
auto information() -> Information {
Information information;
for(auto& device : _devices) information.devices.append(device.name);
information.frequencies = {_frequency};
uint latencies[] = {64, 96, 128, 192, 256, 384, 512, 768, 1024, 1536, 2048, 3072, 6144}; //factors of 6144
for(auto& latency : latencies) {
if(latency < _active.minimumBufferSize) continue;
if(latency > _active.maximumBufferSize) continue;
information.latencies.append(latency);
}
information.channels = {1, 2};
return information;
auto availableDevices() -> string_vector {
string_vector devices;
for(auto& device : _devices) devices.append(device.name);
return devices;
}
auto availableFrequencies() -> vector<double> {
return {_frequency};
}
auto availableLatencies() -> vector<uint> {
vector<uint> latencies;
uint latencyList[] = {64, 96, 128, 192, 256, 384, 512, 768, 1024, 1536, 2048, 3072, 6144}; //factors of 6144
for(auto& latency : latencyList) {
if(latency < _active.minimumBufferSize) continue;
if(latency > _active.maximumBufferSize) continue;
latencies.append(latency);
}
return latencies;
}
auto availableChannels() -> vector<uint> {
return {1, 2};
}
auto ready() -> bool { return _ready; }
auto context() -> uintptr { return _context; }
auto device() -> string { return _device; }
auto blocking() -> bool { return _blocking; }

View File

@ -4,17 +4,23 @@ struct AudioDirectSound : Audio {
AudioDirectSound() { initialize(); }
~AudioDirectSound() { terminate(); }
auto ready() -> bool { return _ready; }
auto information() -> Information {
Information information;
information.devices = {"Default"};
information.frequencies = {44100.0, 48000.0, 96000.0};
information.latencies = {40, 60, 80, 100};
information.channels = {2};
return information;
auto availableDevices() -> string_vector {
return {"Default"};
}
auto availableFrequencies() -> vector<double> {
return {44100.0, 48000.0, 96000.0};
}
auto availableLatencies() -> vector<uint> {
return {40, 60, 80, 100};
}
auto availableChannels() -> vector<uint> {
return {2};
}
auto ready() -> bool { return _ready; }
auto blocking() -> bool { return _blocking; }
auto channels() -> uint { return _channels; }
auto frequency() -> double { return _frequency; }

View File

@ -10,17 +10,25 @@ struct AudioOpenAL : Audio {
AudioOpenAL() { initialize(); }
~AudioOpenAL() { terminate(); }
auto ready() -> bool { return _ready; }
auto information() -> Information {
Information information;
for(auto& device : queryDevices()) information.devices.append(device);
information.channels = {2};
information.frequencies = {44100.0, 48000.0, 96000.0};
information.latencies = {20, 40, 60, 80, 100};
return information;
auto availableDevices() -> string_vector {
string_vector devices;
for(auto& device : queryDevices()) devices.append(device);
return devices;
}
auto availableFrequencies() -> vector<double> {
return {44100.0, 48000.0, 96000.0};
}
auto availableLatencies() -> vector<uint> {
return {20, 40, 60, 80, 100};
}
auto availableChannels() -> vector<uint> {
return {2};
}
auto ready() -> bool { return _ready; }
auto device() -> string { return _device; }
auto blocking() -> bool { return _blocking; }
auto channels() -> uint { return _channels; }

View File

@ -17,18 +17,26 @@ struct AudioOSS : Audio {
AudioOSS() { initialize(); }
~AudioOSS() { terminate(); }
auto ready() -> bool { return _ready; }
auto information() -> Information {
Information information;
information.devices = {"/dev/dsp"};
for(auto& device : directory::files("/dev/", "dsp?*")) information.devices.append(string{"/dev/", device});
information.frequencies = {44100.0, 48000.0, 96000.0};
information.latencies = {0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10};
information.channels = {1, 2};
return information;
auto availableDevices() -> string_vector {
string_vector devices;
devices.append("/dev/dsp");
for(auto& device : directory::files("/dev/", "dsp?*")) devices.append(string{"/dev/", device});
return devices;
}
auto availableFrequencies() -> vector<double> {
return {44100.0, 48000.0, 96000.0};
}
auto availableLatencies() -> vector<uint> {
return {0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10};
}
auto availableChannels() -> vector<uint> {
return {1, 2};
}
auto ready() -> bool { return _ready; }
auto device() -> string { return _device; }
auto blocking() -> bool { return _blocking; }
auto channels() -> uint { return _channels; }
@ -78,8 +86,8 @@ private:
auto initialize() -> bool {
terminate();
if(!information().devices.find(_device)) {
_device = information().devices.left();
if(!availableDevices().find(_device)) {
_device = availableDevices().left();
}
_fd = open(_device, O_WRONLY, O_NONBLOCK);

View File

@ -4,17 +4,23 @@ struct AudioPulseAudio : Audio {
AudioPulseAudio() { initialize(); }
~AudioPulseAudio() { terminate(); }
auto ready() -> bool { return _ready; }
auto information() -> Information {
Information information;
information.devices = {"Default"};
information.frequencies = {44100.0, 48000.0, 96000.0};
information.latencies = {20, 40, 60, 80, 100};
information.channels = {2};
return information;
auto availableDevices() -> string_vector {
return {"Default"};
}
auto availableFrequencies() -> vector<double> {
return {44100.0, 48000.0, 96000.0};
}
auto availableLatencies() -> vector<uint> {
return {20, 40, 60, 80, 100};
}
auto availableChannels() -> vector<uint> {
return {2};
}
auto ready() -> bool { return _ready; }
auto blocking() -> bool { return _blocking; }
auto channels() -> uint { return 2; }
auto frequency() -> double { return _frequency; }

View File

@ -5,17 +5,23 @@ struct AudioPulseAudioSimple : Audio {
AudioPulseAudioSimple() { initialize(); }
~AudioPulseAudioSimple() { terminate(); }
auto ready() -> bool { return _ready; }
auto information() -> Information {
Information information;
information.devices = {"Default"};
information.frequencies = {44100.0, 48000.0, 96000.0};
information.latencies = {40};
information.channels = {2};
return information;
auto availableDevices() -> string_vector {
return {"Default"};
}
auto availableFrequencies() -> vector<double> {
return {44100.0, 48000.0, 96000.0};
}
auto availableLatencies() -> vector<uint> {
return {40};
}
auto availableChannels() -> vector<uint> {
return {2};
}
auto ready() -> bool { return _ready; }
auto blocking() -> bool { return true; }
auto channels() -> uint { return 2; }
auto frequency() -> double { return _frequency; }

View File

@ -10,17 +10,23 @@ struct AudioWASAPI : Audio {
AudioWASAPI() { initialize(); }
~AudioWASAPI() { terminate(); }
auto ready() -> bool { return _ready; }
auto information() -> Information {
Information information;
for(auto& device : _devices) information.devices.append(device);
information.channels = {2};
information.frequencies = {(double)_frequency};
information.latencies = {0, 20, 40, 60, 80, 100};
return information;
auto availableDevices() -> string_vector {
return _devices;
}
auto availableFrequencies() -> vector<double> {
return {(double)_frequency};
}
auto availableLatencies() -> vector<uint> {
return {0, 20, 40, 60, 80, 100};
}
auto availableChannels() -> vector<uint> {
return {2};
}
auto ready() -> bool { return _ready; }
auto exclusive() -> bool { return _exclusive; }
auto device() -> string { return _device; }
auto blocking() -> bool { return _blocking; }
@ -239,7 +245,7 @@ private:
} _queue;
IMMDeviceEnumerator* _enumerator = nullptr;
vector<string> _devices;
string_vector _devices;
IMMDevice* _audioDevice = nullptr;
IAudioClient* _audioClient = nullptr;
IAudioRenderClient* _renderClient = nullptr;

View File

@ -5,17 +5,23 @@ struct AudioXAudio2 : Audio, public IXAudio2VoiceCallback {
AudioXAudio2() { initialize(); }
~AudioXAudio2() { terminate(); }
auto ready() -> bool { return _ready; }
auto information() -> Information {
Information information;
information.devices = {"Default"};
information.channels = {2};
information.frequencies = {44100.0, 48000.0, 96000.0};
information.latencies = {20, 40, 60, 80, 100};
return information;
auto availableDevices() -> string_vector {
return {"Default"};
}
auto availableFrequencies() -> vector<double> {
return {44100.0, 48000.0, 96000.0};
}
auto availableLatencies() -> vector<uint> {
return {20, 40, 60, 80, 100};
}
auto availableChannels() -> vector<uint> {
return {2};
}
auto ready() -> bool { return _ready; }
auto blocking() -> bool { return _blocking; }
auto channels() -> uint { return _channels; }
auto frequency() -> double { return _frequency; }

View File

@ -53,18 +53,14 @@ struct Audio {
static auto safestDriver() -> nall::string;
static auto availableDrivers() -> nall::string_vector;
struct Information {
nall::string_vector devices;
nall::vector<double> frequencies;
nall::vector<uint> latencies;
nall::vector<uint> channels;
};
virtual ~Audio() = default;
virtual auto ready() -> bool { return true; }
virtual auto information() -> Information { return {{"Default"}, {48000.0}, {0}, {2}}; }
virtual auto availableDevices() -> nall::string_vector { return {"Default"}; }
virtual auto availableFrequencies() -> nall::vector<double> { return {44100.0}; }
virtual auto availableLatencies() -> nall::vector<uint> { return {0}; }
virtual auto availableChannels() -> nall::vector<uint> { return {2}; }
virtual auto ready() -> bool { return true; }
virtual auto exclusive() -> bool { return false; }
virtual auto context() -> uintptr { return 0; }
virtual auto device() -> nall::string { return "None"; }