mirror of
https://github.com/bsnes-emu/bsnes.git
synced 2025-01-17 20:58:28 +01:00
4129630d97
byuu says: Changelog: - ruby: rewrote the API interfaces for Video, Audio, Input - ruby/audio: can now select the number of output channels (not useful to higan, sorry) - ruby/asio: various improvements - tomoko: audio settings panel can now select separate audio devices (for ASIO, OSS so far) - tomoko: audio settings panel frequency and latency lists are dynamically populated now Note: due to the ruby API rewrite, most drivers will not compile. Right now, the following work: - video: Direct3D, XShm - audio: ASIO, OSS - input: Windows, SDL, Xlib It takes a really long time to rewrite these (six hours to do the above), so it's going to be a while before we're back at 100% functionality again. Errata: - ASIO needs device(), setDevice() - need to call setDevice() at program startup to populate frequency/latency settings properly - changing the device and/or frequency needs to update the emulator resampler rates The really hard part is going to be the last one: the only way to change the emulator frequency is to flush all the audio streams and then recompute all the coefficients for the resamplers. If this is called during emulation, all audio streams will be erased and thus no sound will be output. I'll most likely be forced to simply ignore device/frequency changes until the user loads another game. It is at least possible to toggle the latency dynamically.
122 lines
4.4 KiB
C++
122 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;
|
|
|
|
struct Information {
|
|
nall::vector<nall::string> devices;
|
|
nall::vector<uint> frequencies;
|
|
nall::vector<uint> latencies;
|
|
nall::vector<uint> channels;
|
|
};
|
|
|
|
virtual ~Audio() = default;
|
|
|
|
virtual auto ready() -> bool { return true; }
|
|
virtual auto information() -> Information { return {{"None"}, {48000}, {0}, {2}}; }
|
|
|
|
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() -> uint { return 48000; }
|
|
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(uint 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;
|
|
};
|
|
|
|
}
|