mirror of
https://github.com/bsnes-emu/bsnes.git
synced 2025-01-17 20:58:28 +01:00
afa8ea61c5
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.
118 lines
4.4 KiB
C++
118 lines
4.4 KiB
C++
#pragma once
|
|
|
|
/* ruby
|
|
* author: byuu
|
|
* license: ISC
|
|
* version: 0.16 (2017-07-08)
|
|
*
|
|
* ruby is a cross-platform hardware abstraction layer.
|
|
* it provides a common interface to video, audio and input devices.
|
|
*/
|
|
|
|
#include <nall/nall.hpp>
|
|
|
|
namespace ruby {
|
|
|
|
struct Video {
|
|
static auto create(const nall::string& driver = "") -> Video*;
|
|
static auto optimalDriver() -> nall::string;
|
|
static auto safestDriver() -> nall::string;
|
|
static auto availableDrivers() -> nall::string_vector;
|
|
|
|
struct Information {
|
|
};
|
|
|
|
virtual ~Video() = default;
|
|
|
|
virtual auto ready() -> bool { return true; }
|
|
virtual auto information() -> Information { return {}; }
|
|
|
|
virtual auto exclusive() -> bool { return false; }
|
|
virtual auto context() -> uintptr { return 0; }
|
|
virtual auto blocking() -> bool { return false; }
|
|
virtual auto depth() -> uint { return 24; }
|
|
virtual auto smooth() -> bool { return false; }
|
|
virtual auto shader() -> nall::string { return ""; }
|
|
|
|
virtual auto setExclusive(bool exclusive) -> bool { return false; }
|
|
virtual auto setContext(uintptr context) -> bool { return false; }
|
|
virtual auto setBlocking(bool blocking) -> bool { return false; }
|
|
virtual auto setDepth(uint depth) -> bool { return false; }
|
|
virtual auto setSmooth(bool smooth) -> bool { return false; }
|
|
virtual auto setShader(nall::string shader) -> bool { return false; }
|
|
|
|
virtual auto clear() -> void {}
|
|
virtual auto lock(uint32_t*& data, uint& pitch, uint width, uint height) -> bool { return false; }
|
|
virtual auto unlock() -> void {}
|
|
virtual auto output() -> void {}
|
|
};
|
|
|
|
struct Audio {
|
|
static auto create(const nall::string& driver = "") -> Audio*;
|
|
static auto optimalDriver() -> nall::string;
|
|
static auto safestDriver() -> nall::string;
|
|
static auto availableDrivers() -> nall::string_vector;
|
|
|
|
virtual ~Audio() = default;
|
|
|
|
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"; }
|
|
virtual auto blocking() -> bool { return false; }
|
|
virtual auto channels() -> uint { return 2; }
|
|
virtual auto frequency() -> double { return 48000.0; }
|
|
virtual auto latency() -> uint { return 0; }
|
|
|
|
virtual auto setExclusive(bool exclusive) -> bool { return false; }
|
|
virtual auto setContext(uintptr context) -> bool { return false; }
|
|
virtual auto setDevice(nall::string device) -> bool { return false; }
|
|
virtual auto setBlocking(bool blocking) -> bool { return false; }
|
|
virtual auto setChannels(uint channels) -> bool { return false; }
|
|
virtual auto setFrequency(double frequency) -> bool { return false; }
|
|
virtual auto setLatency(uint latency) -> bool { return false; }
|
|
|
|
virtual auto clear() -> void {}
|
|
virtual auto output(const double samples[]) -> void {}
|
|
};
|
|
|
|
struct Input {
|
|
static auto create(const nall::string& driver = "") -> Input*;
|
|
static auto optimalDriver() -> nall::string;
|
|
static auto safestDriver() -> nall::string;
|
|
static auto availableDrivers() -> nall::string_vector;
|
|
|
|
struct Information {
|
|
};
|
|
|
|
virtual ~Input() = default;
|
|
|
|
virtual auto ready() -> bool { return true; }
|
|
virtual auto information() -> Information { return {}; }
|
|
|
|
virtual auto context() -> uintptr { return 0; }
|
|
|
|
virtual auto setContext(uintptr context) -> bool { return false; }
|
|
|
|
virtual auto acquired() -> bool { return false; }
|
|
virtual auto acquire() -> bool { return false; }
|
|
virtual auto release() -> bool { return false; }
|
|
virtual auto poll() -> nall::vector<nall::shared_pointer<nall::HID::Device>> { return {}; }
|
|
virtual auto rumble(uint64_t id, bool enable) -> bool { return false; }
|
|
|
|
auto onChange(const nall::function<void (nall::shared_pointer<nall::HID::Device>, uint, uint, int16_t, int16_t)>& callback) { _onChange = callback; }
|
|
auto doChange(nall::shared_pointer<nall::HID::Device> device, uint group, uint input, int16_t oldValue, int16_t newValue) -> void {
|
|
if(_onChange) _onChange(device, group, input, oldValue, newValue);
|
|
}
|
|
|
|
private:
|
|
nall::function<void (nall::shared_pointer<nall::HID::Device> device, uint group, uint input, int16_t oldValue, int16_t newValue)> _onChange;
|
|
};
|
|
|
|
}
|