mirror of
https://github.com/geode-sdk/geode.git
synced 2025-04-24 05:14:40 -04:00
parent
1847a47494
commit
b6d637c08f
3 changed files with 21 additions and 40 deletions
|
@ -30,13 +30,11 @@ if (GEODE_TARGET_PLATFORM STREQUAL "iOS")
|
|||
"-framework OpenGLES" # needed for CCClippingNode reimpl and ScrollLayer
|
||||
"-framework UIKit" # needed for file picking (UIApplication)
|
||||
"-framework Foundation" # needed for many things
|
||||
"-framework AVFoundation" # needed for fmod
|
||||
"-framework AudioToolbox" # needed for fmod
|
||||
"-framework AVFoundation" # needed for microphone access
|
||||
${GEODE_LOADER_PATH}/include/link/ios/libssl.a
|
||||
${GEODE_LOADER_PATH}/include/link/ios/libcrypto.a
|
||||
${GEODE_LOADER_PATH}/include/link/ios/libnghttp2.a
|
||||
${GEODE_LOADER_PATH}/include/link/ios/libcurl.a
|
||||
${GEODE_LOADER_PATH}/include/link/ios/libfmod_iphoneos.a
|
||||
)
|
||||
|
||||
target_compile_definitions(${PROJECT_NAME} INTERFACE
|
||||
|
|
Binary file not shown.
|
@ -1,46 +1,31 @@
|
|||
#include <Geode/Geode.hpp>
|
||||
|
||||
// ios does not link to fmod.
|
||||
#ifndef GEODE_IS_IOS
|
||||
#include <Geode/modify/ChannelControl.hpp>
|
||||
#include <Geode/modify/System.hpp>
|
||||
|
||||
using namespace geode::prelude;
|
||||
|
||||
// Workaround for a bug where FMOD::ChannelControl::setVolume is called with
|
||||
// uninitialized (invalid) channel pointers from FMODAudioEngine.
|
||||
// This creates a very annoying crash during load in some cases.
|
||||
|
||||
auto g_systemInitialized = false;
|
||||
|
||||
FMOD_RESULT FMOD_System_init_hook(
|
||||
FMOD::System* system, int maxChannels, FMOD_INITFLAGS flags, void* extraData
|
||||
) {
|
||||
g_systemInitialized = true;
|
||||
return system->init(maxChannels, flags, extraData);
|
||||
}
|
||||
|
||||
FMOD_RESULT FMOD_ChannelControl_setVolume_hook(FMOD::ChannelControl* channel, float volume) {
|
||||
if (!g_systemInitialized) {
|
||||
return FMOD_ERR_UNINITIALIZED;
|
||||
struct FMODSystemFix : Modify<FMODSystemFix, FMOD::System> {
|
||||
FMOD_RESULT init(int maxChannels, FMOD_INITFLAGS flags, void* extraData) {
|
||||
g_systemInitialized = true;
|
||||
return FMOD::System::init(maxChannels, flags, extraData);
|
||||
}
|
||||
};
|
||||
|
||||
return channel->setVolume(volume);
|
||||
}
|
||||
struct FMODChannelControlFix : Modify<FMODChannelControlFix, FMOD::ChannelControl> {
|
||||
FMOD_RESULT setVolume(float volume) {
|
||||
if (!g_systemInitialized) {
|
||||
return FMOD_ERR_UNINITIALIZED;
|
||||
}
|
||||
|
||||
$execute {
|
||||
// Workaround for a bug where FMOD::ChannelControl::setVolume is called with
|
||||
// uninitialized (invalid) channel pointers from FMODAudioEngine.
|
||||
// This creates a very annoying crash during load in some cases.
|
||||
|
||||
(void)geode::Mod::get()->hook(
|
||||
reinterpret_cast<void*>(geode::addresser::getNonVirtual(&FMOD::System::init)),
|
||||
&FMOD_System_init_hook,
|
||||
"FMOD::System::init"
|
||||
GEODE_WINDOWS32(, tulip::hook::TulipConvention::Stdcall)
|
||||
);
|
||||
|
||||
(void)geode::Mod::get()->hook(
|
||||
reinterpret_cast<void*>(geode::addresser::getNonVirtual(&FMOD::ChannelControl::setVolume)),
|
||||
&FMOD_ChannelControl_setVolume_hook,
|
||||
"FMOD::ChannelControl::setVolume"
|
||||
GEODE_WINDOWS32(, tulip::hook::TulipConvention::Stdcall)
|
||||
);
|
||||
}
|
||||
return FMOD::ChannelControl::setVolume(volume);
|
||||
}
|
||||
};
|
||||
|
||||
/*
|
||||
// this hook requires a tuliphook update
|
||||
|
@ -65,6 +50,4 @@ struct AndroidFMODFix : Modify<AndroidFMODFix, FMODAudioEngine> {
|
|||
FMODAudioEngine::setBackgroundMusicVolume(volume);
|
||||
}
|
||||
};
|
||||
*/
|
||||
|
||||
#endif
|
||||
*/
|
Loading…
Add table
Add a link
Reference in a new issue