Initial re-upload of spice2x-24-08-24

This commit is contained in:
2024-08-28 11:10:34 -04:00
commit caa9e02285
1181 changed files with 380065 additions and 0 deletions

1073
external/asio/asio.h vendored Normal file

File diff suppressed because it is too large Load Diff

201
external/asio/asiolist.cpp vendored Normal file
View File

@@ -0,0 +1,201 @@
#include "asiolist.h"
#include <windows.h>
#include "util/logging.h"
#include "iasiodrv.h"
#define ASIODRV_DESC "description"
#define INPROC_SERVER "InprocServer32"
#define ASIO_PATH "software\\asio"
#define COM_CLSID "clsid"
static LONG find_driver_path(char *clsid_str, char *dll_path, size_t dll_path_size) {
HKEY hkEnum, hksub, hkpath;
char data_buf[512];
LONG cr, rc = -1;
DWORD data_type, data_size;
DWORD index;
OFSTRUCT ofs;
HFILE hfile;
bool found = false;
CharLowerBuffA(clsid_str, static_cast<DWORD>(strlen(clsid_str)));
if ((cr = RegOpenKeyA(HKEY_CLASSES_ROOT,COM_CLSID,&hkEnum)) == ERROR_SUCCESS) {
index = 0;
while (cr == ERROR_SUCCESS && !found) {
cr = RegEnumKeyA(hkEnum, index++, (LPTSTR)data_buf, 512);
if (cr == ERROR_SUCCESS) {
CharLowerBuffA(data_buf, static_cast<DWORD>(strlen(data_buf)));
if (!(strcmp(data_buf, clsid_str))) {
if ((cr = RegOpenKeyExA(hkEnum, (LPCTSTR)data_buf, 0, KEY_READ, &hksub)) == ERROR_SUCCESS) {
if ((cr = RegOpenKeyExA(hksub,(LPCTSTR)INPROC_SERVER,0,KEY_READ,&hkpath)) == ERROR_SUCCESS) {
data_type = REG_SZ;
data_size = static_cast<DWORD>(dll_path_size);
cr = RegQueryValueExA(hkpath, nullptr, nullptr, &data_type, (LPBYTE)dll_path, &data_size);
if (cr == ERROR_SUCCESS) {
memset(&ofs,0,sizeof(OFSTRUCT));
ofs.cBytes = sizeof(OFSTRUCT);
hfile = OpenFile(dll_path, &ofs, OF_EXIST);
if (hfile) {
rc = 0;
}
}
RegCloseKey(hkpath);
}
RegCloseKey(hksub);
}
// break out
found = true;
}
}
}
RegCloseKey(hkEnum);
}
return rc;
}
static bool new_driver_struct(HKEY hkey, char *key_name, size_t id, AsioDriver &driver) {
HKEY hksub;
char data_buffer[256];
char dll_path[MAXPATHLEN];
WORD wData[100];
CLSID clsid;
DWORD data_type, data_size;
LONG cr, rc;
if ((cr = RegOpenKeyExA(hkey, (LPCTSTR)key_name, 0, KEY_READ, &hksub)) == ERROR_SUCCESS) {
data_type = REG_SZ;
data_size = 256;
cr = RegQueryValueExA(hksub, COM_CLSID, nullptr, &data_type, (LPBYTE)data_buffer, &data_size);
if (cr == ERROR_SUCCESS) {
rc = find_driver_path(data_buffer, dll_path, MAXPATHLEN);
if (rc == 0) {
driver.id = id;
strcpy(driver.dll_path, dll_path);
MultiByteToWideChar(CP_ACP, 0, (LPCSTR)data_buffer, -1, (LPWSTR)wData, 100);
if ((cr = CLSIDFromString((LPOLESTR)wData,(LPCLSID)&clsid)) == S_OK) {
memcpy(&driver.clsid, &clsid, sizeof(CLSID));
}
data_type = REG_SZ;
data_size = 256;
cr = RegQueryValueExA(hksub, ASIODRV_DESC, nullptr, &data_type, (LPBYTE)data_buffer, &data_size);
if (cr == ERROR_SUCCESS) {
strcpy(driver.name, data_buffer);
} else {
strcpy(driver.name, key_name);
}
return true;
}
}
RegCloseKey(hksub);
}
return false;
}
static void delete_driver_struct(AsioDriver &driver) {
IAsio *iasio;
if (driver.instance) {
iasio = reinterpret_cast<IAsio *>(driver.instance);
iasio->Release();
driver.instance = nullptr;
}
}
AsioDriverList::AsioDriverList() {
HKEY hkEnum = nullptr;
char key_name[MAXDRVNAMELEN];
LONG cr;
DWORD index = 0;
cr = RegOpenKeyA(HKEY_LOCAL_MACHINE,ASIO_PATH, &hkEnum);
while (cr == ERROR_SUCCESS) {
if ((cr = RegEnumKeyA(hkEnum, index++, (LPTSTR) key_name, MAXDRVNAMELEN)) == ERROR_SUCCESS) {
auto id = this->driver_list.size();
if (!new_driver_struct(hkEnum, key_name, id, this->driver_list.emplace_back())) {
this->driver_list.pop_back();
}
}
}
if (hkEnum) {
RegCloseKey(hkEnum);
}
this->driver_list.shrink_to_fit();
if (!this->driver_list.empty()) {
// initialize COM
HRESULT hr = CoInitialize(nullptr);
if (FAILED(hr)) {
log_warning("asio::driver_list", "CoInitialize failed, hr={}", FMT_HRESULT(hr));
}
}
}
AsioDriverList::~AsioDriverList() {
if (!this->driver_list.empty()) {
for (auto &driver : this->driver_list) {
delete_driver_struct(driver);
}
}
if (this->co_initialized) {
CoUninitialize();
}
}
LONG AsioDriverList::open_driver(size_t driver_id, void **asio_driver) {
long rc;
if (!asio_driver) {
return DRVERR_INVALID_PARAM;
}
if (driver_id < this->driver_list.size()) {
auto &driver = this->driver_list[driver_id];
if (!driver.instance) {
rc = CoCreateInstance(driver.clsid, nullptr, CLSCTX_INPROC_SERVER, driver.clsid, asio_driver);
if (rc == S_OK) {
driver.instance = *asio_driver;
return 0;
}
// else if (rc == REGDB_E_CLASSNOTREG)
// strcpy (info->messageText, "Driver not registered in the Registration Database!");
} else {
rc = DRVERR_DEVICE_ALREADY_OPEN;
}
} else {
rc = DRVERR_DEVICE_NOT_FOUND;
}
return rc;
}
LONG AsioDriverList::close_driver(size_t driver_id) {
IAsio *iasio;
if (driver_id < this->driver_list.size()) {
auto &driver = this->driver_list[driver_id];
if (driver.instance) {
iasio = reinterpret_cast<IAsio *>(driver.instance);
iasio->Release();
driver.instance = nullptr;
}
}
return 0;
}

36
external/asio/asiolist.h vendored Normal file
View File

@@ -0,0 +1,36 @@
#pragma once
#include <vector>
#include <windows.h>
#define DRVERR -5000
#define DRVERR_INVALID_PARAM DRVERR-1
#define DRVERR_DEVICE_ALREADY_OPEN DRVERR-2
#define DRVERR_DEVICE_NOT_FOUND DRVERR-3
#define MAXPATHLEN 512
#define MAXDRVNAMELEN 128
struct AsioDriver {
size_t id;
char name[MAXDRVNAMELEN];
char dll_path[MAXPATHLEN];
CLSID clsid;
void *instance;
struct AsioDriver *next;
};
class AsioDriverList {
public:
AsioDriverList();
~AsioDriverList();
LONG open_driver(size_t driver_id, void **asio_driver);
LONG close_driver(size_t driver_id);
std::vector<AsioDriver> driver_list;
private:
bool co_initialized = false;
};

82
external/asio/asiosys.h vendored Normal file
View File

@@ -0,0 +1,82 @@
#ifndef __asiosys__
#define __asiosys__
#if defined(_WIN32) || defined(_WIN64)
#undef MAC
#define PPC 0
#define WINDOWS 1
#define SGI 0
#define SUN 0
#define LINUX 0
#define BEOS 0
#define NATIVE_INT64 0
#define IEEE754_64FLOAT 1
#elif BEOS
#define MAC 0
#define PPC 0
#define WINDOWS 0
#define PC 0
#define SGI 0
#define SUN 0
#define LINUX 0
#define NATIVE_INT64 0
#define IEEE754_64FLOAT 1
#ifndef DEBUG
#define DEBUG 0
#if DEBUG
void DEBUGGERMESSAGE(char *string);
#else
#define DEBUGGERMESSAGE(a)
#endif
#endif
#elif SGI
#define MAC 0
#define PPC 0
#define WINDOWS 0
#define PC 0
#define SUN 0
#define LINUX 0
#define BEOS 0
#define NATIVE_INT64 0
#define IEEE754_64FLOAT 1
#ifndef DEBUG
#define DEBUG 0
#if DEBUG
void DEBUGGERMESSAGE(char *string);
#else
#define DEBUGGERMESSAGE(a)
#endif
#endif
#else // MAC
#define MAC 1
#define PPC 1
#define WINDOWS 0
#define PC 0
#define SGI 0
#define SUN 0
#define LINUX 0
#define BEOS 0
#define NATIVE_INT64 0
#define IEEE754_64FLOAT 1
#ifndef DEBUG
#define DEBUG 0
#if DEBUG
void DEBUGGERMESSAGE(char *string);
#else
#define DEBUGGERMESSAGE(a)
#endif
#endif
#endif
#endif

22
external/asio/changes.txt vendored Normal file
View File

@@ -0,0 +1,22 @@
Changes in ASIO 2.3.3 since 2.3.2
- again, updated license text and ASIO logo usage guideline
Changes in ASIO 2.3.2 since 2.3.1
- updated license text and ASIO logo usage guideline
Changes in ASIO 2.3.1 since ASIO 2.3
- amendment of the licensing agreement
- added support for Windows 10
Changes in ASIO 2.3 since ASIO 2.2
- added host queries to detect the driver's buffering and drop-out detection capabilities
- some additional documentation on MMCSS; see page 46 of 'ASIO SDK 2.3.pdf'
- dropped support for Mac OS 8 and 9
Changes in ASIO 2.2 since ASIO 2.1
- added support for Windows 64 bit
Changes in ASIO 2.1 since ASIO 2.0
- Sony DSD support added
- fixed Windows registry sample to HKEY_LOCAL_MACHINE
- fixed a definition problem for input monitoring

39
external/asio/iasiodrv.h vendored Normal file
View File

@@ -0,0 +1,39 @@
#pragma once
#include "asiosys.h"
#include "asio.h"
#include <windows.h>
#include <combaseapi.h>
interface IAsio : public IUnknown {
virtual AsioBool __thiscall init(void *sys_handle) = 0;
virtual void __thiscall get_driver_name(char *name) = 0;
virtual long __thiscall get_driver_version() = 0;
virtual void __thiscall get_error_message(char *string) = 0;
virtual AsioError __thiscall start() = 0;
virtual AsioError __thiscall stop() = 0;
virtual AsioError __thiscall get_channels(long *num_input_channels, long *num_output_channels) = 0;
virtual AsioError __thiscall get_latencies(long *input_latency, long *output_latency) = 0;
virtual AsioError __thiscall get_buffer_size(
long *min_size,
long *max_size,
long *preferred_size,
long *granularity) = 0;
virtual AsioError __thiscall can_sample_rate(AsioSampleRate sample_rate) = 0;
virtual AsioError __thiscall get_sample_rate(AsioSampleRate *sample_rate) = 0;
virtual AsioError __thiscall set_sample_rate(AsioSampleRate sample_rate) = 0;
virtual AsioError __thiscall get_clock_sources(ASIOClockSource *clocks, long *num_sources) = 0;
virtual AsioError __thiscall set_clock_source(long reference) = 0;
virtual AsioError __thiscall get_sample_position(ASIOSamples *s_pos, ASIOTimeStamp *t_stamp) = 0;
virtual AsioError __thiscall get_channel_info(AsioChannelInfo *info) = 0;
virtual AsioError __thiscall create_buffers(
AsioBufferInfo *buffer_infos,
long num_channels,
long buffer_size,
AsioCallbacks *callbacks) = 0;
virtual AsioError __thiscall dispose_buffers() = 0;
virtual AsioError __thiscall control_panel() = 0;
virtual AsioError __thiscall future(long selector, void *opt) = 0;
virtual AsioError __thiscall output_ready() = 0;
};