diff options
| author | ptitSeb <sebastien.chev@gmail.com> | 2025-08-25 19:26:09 +0200 |
|---|---|---|
| committer | ptitSeb <sebastien.chev@gmail.com> | 2025-08-25 19:26:09 +0200 |
| commit | 1cddcad20a1c5c167c9be1576841605bc063737f (patch) | |
| tree | 9ee7ae55d17f715c60a14b83135546d90b77e46a /src | |
| parent | aa30e665ffc4867029eaa5952c08241d87607265 (diff) | |
| download | box64-1cddcad20a1c5c167c9be1576841605bc063737f.tar.gz box64-1cddcad20a1c5c167c9be1576841605bc063737f.zip | |
[WRAPPER] Improved pulse wrapping
Diffstat (limited to 'src')
| -rw-r--r-- | src/include/bridge.h | 1 | ||||
| -rw-r--r-- | src/steam.c | 3 | ||||
| -rw-r--r-- | src/tools/bridge.c | 14 | ||||
| -rw-r--r-- | src/wrapped/wrappedpulse.c | 55 | ||||
| -rw-r--r-- | src/wrapped/wrappedpulse_private.h | 1 |
5 files changed, 69 insertions, 5 deletions
diff --git a/src/include/bridge.h b/src/include/bridge.h index ed839d94..9d53f203 100644 --- a/src/include/bridge.h +++ b/src/include/bridge.h @@ -14,6 +14,7 @@ uintptr_t AddBridge(bridge_t* bridge, wrapper_t w, void* fnc, int N, const char* uintptr_t CheckBridged(bridge_t* bridge, void* fnc); uintptr_t AddCheckBridge(bridge_t* bridge, wrapper_t w, void* fnc, int N, const char* name); uintptr_t AddAutomaticBridge(bridge_t* bridge, wrapper_t w, void* fnc, int N, const char* name); +uintptr_t AddAutomaticBridgeAlt(bridge_t* bridge, wrapper_t w, void* fnc, void* alt, int N, const char* name); void* GetNativeFnc(uintptr_t fnc); void* GetNativeFncOrFnc(uintptr_t fnc); void* GetNativeOrAlt(void* fnc, void* alt); diff --git a/src/steam.c b/src/steam.c index ca21f9bc..2b489464 100644 --- a/src/steam.c +++ b/src/steam.c @@ -179,7 +179,8 @@ void pressure_vessel(int argc, const char** argv, int nextarg, const char* prog) //setenv("BOX64_SHOWSEGV", "1", 1); //setenv("BOX64_SHOWBT", "1", 1); //setenv("BOX64_DYNAREC_LOG", "1", 1); - + //setenv("BOX64_ROLLING_LOG", "128", 1); + printf_log(LOG_DEBUG, "Run %s %s and wait\n", x86?"i386":(x64?"x86_64":""), argv[nextarg]); pid_t v = vfork(); if(v==-1) { diff --git a/src/tools/bridge.c b/src/tools/bridge.c index ea0b99e3..17496cc7 100644 --- a/src/tools/bridge.c +++ b/src/tools/bridge.c @@ -168,6 +168,20 @@ uintptr_t AddAutomaticBridge(bridge_t* bridge, wrapper_t w, void* fnc, int N, co return ret; } +uintptr_t AddAutomaticBridgeAlt(bridge_t* bridge, wrapper_t w, void* fnc, void* alt, int N, const char* name) +{ + if(!fnc) + return 0; + uintptr_t ret = CheckBridged(bridge, alt); + if(!ret) + ret = AddBridge(bridge, w, alt, N, name); + if(!hasAlternate(fnc)) { + printf_log(LOG_DEBUG, "Adding AutomaticBridge for %p to %p\n", fnc, (void*)ret); + addAlternate(fnc, (void*)ret); + } + return ret; +} + void* GetNativeOrAlt(void* fnc, void* alt) { if(!fnc) return NULL; diff --git a/src/wrapped/wrappedpulse.c b/src/wrapped/wrappedpulse.c index 3caf5256..9ee53f95 100644 --- a/src/wrapped/wrappedpulse.c +++ b/src/wrapped/wrappedpulse.c @@ -909,6 +909,28 @@ static void* find_time_free_Fct(void* fct) printf_log(LOG_NONE, "Warning, no more slot for pulse audio time_free callback\n"); return NULL; } +// pa_time_event_destroy_cb +#define GO(A) \ +static uintptr_t my_pa_time_event_destroy_cb_fct_##A = 0; \ +static void my_pa_time_event_destroy_cb_##A(void* a, void* e, void* u) \ +{ \ + RunFunctionFmt(my_pa_time_event_destroy_cb_fct_##A, "ppp", a, e, u); \ +} +SUPER() +#undef GO +static void* find_pa_time_event_destroy_cb_Fct(void* fct) +{ + if(!fct) return fct; + if(GetNativeFnc((uintptr_t)fct)) return GetNativeFnc((uintptr_t)fct); + #define GO(A) if(my_pa_time_event_destroy_cb_fct_##A == (uintptr_t)fct) return my_pa_time_event_destroy_cb_##A; + SUPER() + #undef GO + #define GO(A) if(my_pa_time_event_destroy_cb_fct_##A == 0) {my_pa_time_event_destroy_cb_fct_##A = (uintptr_t)fct; return my_pa_time_event_destroy_cb_##A; } + SUPER() + #undef GO + printf_log(LOG_NONE, "Warning, no more slot for pulse audio pa_time_event_destroy_cb callback\n"); + return NULL; +} // time_set_destroy #define GO(A) \ static uintptr_t my_time_set_destroy_fct_##A = 0; \ @@ -931,6 +953,27 @@ static void* find_time_set_destroy_Fct(void* fct) printf_log(LOG_NONE, "Warning, no more slot for pulse audio time_set_destroy callback\n"); return NULL; } +#define GO(A) \ +static vFpp_t my_time_set_destroy_native_fct_##A = NULL; \ +static void my_time_set_destroy_native_##A(void* e, void* cb) \ +{ \ + cb = find_pa_time_event_destroy_cb_Fct(cb); \ + my_time_set_destroy_native_fct_##A (e, cb); \ +} +SUPER() +#undef GO +static void* find_time_set_destroy_native_Fct(void* fct) +{ + if(!fct) return fct; + #define GO(A) if(my_time_set_destroy_native_fct_##A == fct) return my_time_set_destroy_native_##A; + SUPER() + #undef GO + #define GO(A) if(!my_time_set_destroy_native_fct_##A) {my_time_set_destroy_native_fct_##A = fct; return my_time_set_destroy_native_##A; } + SUPER() + #undef GO + printf_log(LOG_NONE, "Warning, no more slot for pulse audio time_set_destroy native wrapper\n"); + return NULL; +} // defer_new #define GO(A) \ static uintptr_t my_defer_new_fct_##A = 0; \ @@ -1049,7 +1092,8 @@ static void UpdateautobridgeMainloopAPI(x64emu_t* emu, bridge_t* bridge, my_pa_m if(!api) { return; } - #define GO(A, W) if(api->A!=my_mainloop_api.A) {api->A=find_##A##_Fct(api->A); AddAutomaticBridge(bridge, W, api->A, 0, NULL);} + #define GO(A, W) if(api->A!=my_mainloop_api.A) {api->A=find_##A##_Fct(api->A); AddAutomaticBridge(bridge, W, api->A, 0, "pulse_" #A);} + #define GO2(A, W) if(api->A!=my_mainloop_api.A) {api->A=find_##A##_Fct(api->A); AddAutomaticBridgeAlt(bridge, W, api->A, find_##A##_native_Fct(api->A), 0, "pulse_" #A);} GO(io_new, pFpiipp); GO(io_enable, vFpi); GO(io_free, vFp); @@ -1057,13 +1101,14 @@ static void UpdateautobridgeMainloopAPI(x64emu_t* emu, bridge_t* bridge, my_pa_m GO(time_new, pFpppp); GO(time_restart, vFpp); GO(time_free, vFp); - GO(time_set_destroy, vFpp); + GO2(time_set_destroy, vFpp); GO(defer_new, pFppp); GO(defer_enable, vFpi); GO(defer_free, vFp); GO(defer_set_destroy, vFpp); GO(quit, vFpi); #undef GO + #undef GO2 memcpy(&my_mainloop_api, api, sizeof(my_mainloop_api)); return; } @@ -1073,7 +1118,8 @@ static void autobridgeMainloopAPI(x64emu_t* emu, bridge_t* bridge, my_pa_mainloo if(!api) { return; } - #define GO(A, W) if(api->A) AddAutomaticBridge(bridge, W, api->A, 0, NULL) + #define GO(A, W) if(api->A) AddAutomaticBridge(bridge, W, api->A, 0, "pulse_" #A) + #define GO2(A, W) if(api->A) AddAutomaticBridgeAlt(bridge, W, api->A, find_##A##_native_Fct(api->A), 0, "pulse_" #A) GO(io_new, pFpiipp); GO(io_enable, vFpi); GO(io_free, vFp); @@ -1081,13 +1127,14 @@ static void autobridgeMainloopAPI(x64emu_t* emu, bridge_t* bridge, my_pa_mainloo GO(time_new, pFpppp); GO(time_restart, vFpp); GO(time_free, vFp); - GO(time_set_destroy, vFpp); + GO2(time_set_destroy, vFpp); GO(defer_new, pFppp); GO(defer_enable, vFpi); GO(defer_free, vFp); GO(defer_set_destroy, vFpp); GO(quit, vFpi); #undef GO + #undef GO2 memcpy(&my_mainloop_api, api, sizeof(my_mainloop_api)); return; } diff --git a/src/wrapped/wrappedpulse_private.h b/src/wrapped/wrappedpulse_private.h index 351d73ff..032e1256 100644 --- a/src/wrapped/wrappedpulse_private.h +++ b/src/wrapped/wrappedpulse_private.h @@ -80,6 +80,7 @@ GO(pa_context_ref, pFp) //GOM(pa_context_remove_autoload_by_name, pFppupp) //GOM(pa_context_remove_sample, pFpppp) GOM(pa_context_rttime_new, pFEpUpp) +GO(pa_context_rttime_restart, vFppU) GOM(pa_context_set_card_profile_by_index, pFEpuppp) //GOM(pa_context_set_card_profile_by_name, pFppppp) GOM(pa_context_set_default_sink, pFEpppp) |