simplify server initialization code
parent
1ec4c35ae4
commit
db9ac578e3
|
@ -10,59 +10,23 @@
|
|||
#include "arch.h"
|
||||
#include "config.h"
|
||||
#include "ipc_memory_info.h"
|
||||
|
||||
#define MEM_FILE_NAME "Local\\BROKENITHM_SHARED_BUFFER"
|
||||
|
||||
struct IPCMemoryInfo *chuni_io_file_mapping;
|
||||
#include "util/dprintf.h"
|
||||
|
||||
#ifdef ENV32BIT
|
||||
#include "servers/android.h"
|
||||
#include "servers/common.h"
|
||||
#include "servers/ios.h"
|
||||
|
||||
HRESULT server_start() {
|
||||
HANDLE hMapFile = OpenFileMappingA(FILE_MAP_ALL_ACCESS, false, MEM_FILE_NAME);
|
||||
|
||||
if (hMapFile == NULL) {
|
||||
hMapFile = CreateFileMappingA(INVALID_HANDLE_VALUE, NULL, PAGE_READWRITE, 0,
|
||||
1024, MEM_FILE_NAME);
|
||||
if (hMapFile == NULL) {
|
||||
print_err("[ERROR] CreateFileMapping failed! error: %lu\n", GetLastError());
|
||||
return E_FAIL;
|
||||
}
|
||||
}
|
||||
|
||||
struct IPCMemoryInfo *memory =
|
||||
MapViewOfFileEx(hMapFile, FILE_MAP_ALL_ACCESS, 0, 0, 1024, NULL);
|
||||
chuni_io_file_mapping = memory;
|
||||
|
||||
HRESULT result;
|
||||
|
||||
if ((result = android_init_server(memory))) {
|
||||
print_err("[ERROR] Android server intialization failed: %ld", result);
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
if ((result = ios_init_server(memory))) {
|
||||
print_err("[ERROR] iOS server initialization failed: %ld", result);
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
return S_OK;
|
||||
}
|
||||
#endif
|
||||
|
||||
#ifdef ENV64BIT
|
||||
#include "util/dprintf.h"
|
||||
#define MEM_FILE_NAME "Local\\BROKENITHM_SHARED_BUFFER"
|
||||
|
||||
static HANDLE chuni_io_file_mapping_handle;
|
||||
struct IPCMemoryInfo *chuni_io_file_mapping;
|
||||
|
||||
void chuni_io_init_shared_memory() {
|
||||
HRESULT chuni_io_init_shared_memory() {
|
||||
if (chuni_io_file_mapping) {
|
||||
dprintf("chuni_io_init_shared_memory: shared memory already exists\n");
|
||||
return;
|
||||
return E_FAIL;
|
||||
}
|
||||
|
||||
if ((chuni_io_file_mapping_handle =
|
||||
|
@ -70,7 +34,7 @@ void chuni_io_init_shared_memory() {
|
|||
sizeof(struct IPCMemoryInfo), MEM_FILE_NAME)) == 0) {
|
||||
dprintf("chuni_io_init_shared_memory: could not create file mapping: %ld\n",
|
||||
GetLastError());
|
||||
return;
|
||||
return E_FAIL;
|
||||
}
|
||||
|
||||
if ((chuni_io_file_mapping = (struct IPCMemoryInfo *)MapViewOfFile(
|
||||
|
@ -78,13 +42,14 @@ void chuni_io_init_shared_memory() {
|
|||
sizeof(struct IPCMemoryInfo))) == 0) {
|
||||
dprintf("chuni_io_init_shared_memory: could not get view of file: %ld\n",
|
||||
GetLastError());
|
||||
return;
|
||||
return E_FAIL;
|
||||
}
|
||||
|
||||
memset(chuni_io_file_mapping, 0, sizeof(struct IPCMemoryInfo));
|
||||
SetThreadExecutionState(ES_DISPLAY_REQUIRED | ES_CONTINUOUS);
|
||||
|
||||
return S_OK;
|
||||
}
|
||||
#endif
|
||||
|
||||
static unsigned int __stdcall chuni_io_slider_thread_proc(void *ctx);
|
||||
|
||||
|
@ -100,14 +65,24 @@ uint16_t chuni_io_get_api_version() { return 0x0102; }
|
|||
HRESULT chuni_io_jvs_init() {
|
||||
chuni_io_config_load(&chuni_io_cfg, L".\\segatools.ini");
|
||||
|
||||
#ifdef ENV32BIT
|
||||
HRESULT result = server_start();
|
||||
if (result != S_OK) {
|
||||
HRESULT result;
|
||||
|
||||
if ((result = chuni_io_init_shared_memory())) {
|
||||
return result;
|
||||
}
|
||||
|
||||
#ifdef ENV32BIT
|
||||
if ((result = android_init_server(chuni_io_file_mapping))) {
|
||||
print_err("[ERROR] Android server intialization failed: %ld", result);
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
if ((result = ios_init_server(chuni_io_file_mapping))) {
|
||||
print_err("[ERROR] iOS server initialization failed: %ld", result);
|
||||
|
||||
return result;
|
||||
}
|
||||
#endif
|
||||
#ifdef ENV64BIT
|
||||
chuni_io_init_shared_memory();
|
||||
#endif
|
||||
|
||||
return S_OK;
|
||||
|
|
Loading…
Reference in New Issue