From c99456ecff9ae645385ea5a8aa423d0115dce08e Mon Sep 17 00:00:00 2001 From: Vincent Bénony Date: Fri, 11 Dec 2015 14:24:29 +0100 Subject: IOS: Brings support for FluidSynth --- audio/softsynth/fluidsynth.cpp | 14 +++++++++ backends/platform/ios7/ios7_osys_main.cpp | 15 +++++++--- backends/platform/ios7/ios7_osys_main.h | 5 ++++ backends/platform/ios7/ios7_osys_video.mm | 32 ++++++++++++++++++++ devtools/create_project/create_project.cpp | 21 ++++++------- devtools/create_project/xcode.cpp | 47 +++++++++++++++++++++++------- 6 files changed, 109 insertions(+), 25 deletions(-) diff --git a/audio/softsynth/fluidsynth.cpp b/audio/softsynth/fluidsynth.cpp index 9b64d70f2b..372a370db4 100644 --- a/audio/softsynth/fluidsynth.cpp +++ b/audio/softsynth/fluidsynth.cpp @@ -31,6 +31,11 @@ #include "audio/musicplugin.h" #include "audio/mpu401.h" #include "audio/softsynth/emumidi.h" +#ifdef IPHONE_OFFICIAL +#include +#include +#include "backends/platform/ios7/ios7_common.h" +#endif #include @@ -179,7 +184,16 @@ int MidiDriver_FluidSynth::open() { const char *soundfont = ConfMan.get("soundfont").c_str(); +#ifdef IPHONE_OFFICIAL + char *soundfont_fullpath[PATH_MAX]; + const char *document_path = iOS7_getDocumentsDir(); + strcpy((char *) soundfont_fullpath, document_path); + strcat((char *) soundfont_fullpath, soundfont); + _soundFont = fluid_synth_sfload(_synth, (const char *) soundfont_fullpath, 1); +#else _soundFont = fluid_synth_sfload(_synth, soundfont, 1); +#endif + if (_soundFont == -1) error("Failed loading custom sound font '%s'", soundfont); diff --git a/backends/platform/ios7/ios7_osys_main.cpp b/backends/platform/ios7/ios7_osys_main.cpp index 76739423c1..cb712b9c38 100644 --- a/backends/platform/ios7/ios7_osys_main.cpp +++ b/backends/platform/ios7/ios7_osys_main.cpp @@ -25,6 +25,7 @@ #include #include +#include #include @@ -80,7 +81,7 @@ OSystem_iOS7::OSystem_iOS7() : _screenOrientation(kScreenOrientationFlippedLandscape), _mouseClickAndDragEnabled(false), _gestureStartX(-1), _gestureStartY(-1), _fullScreenIsDirty(false), _fullScreenOverlayIsDirty(false), _mouseDirty(false), _timeSuspended(0), _lastDragPosX(-1), _lastDragPosY(-1), _screenChangeCount(0), - _mouseCursorPaletteEnabled(false), _gfxTransactionError(kTransactionSuccess) { + _lastErrorMessage(NULL), _mouseCursorPaletteEnabled(false), _gfxTransactionError(kTransactionSuccess) { _queuedInputEvent.type = Common::EVENT_INVALID; _touchpadModeEnabled = !iOS7_isBigDevice(); #ifdef IPHONE_OFFICIAL @@ -275,8 +276,9 @@ Audio::Mixer *OSystem_iOS7::getMixer() { return _mixer; } -OSystem *OSystem_iOS7_create() { - return new OSystem_iOS7(); +OSystem_iOS7 *OSystem_iOS7::sharedInstance() { + static OSystem_iOS7 *instance = new OSystem_iOS7(); + return instance; } Common::String OSystem_iOS7::getDefaultConfigFileName() { @@ -318,6 +320,11 @@ void OSystem_iOS7::logMessage(LogMessageType::Type type, const char *message) { else output = stderr; + if (type == LogMessageType::kError) { + free(_lastErrorMessage); + _lastErrorMessage = strdup(message); + } + fputs(message, output); fflush(output); } @@ -353,7 +360,7 @@ void iOS7_main(int argc, char **argv) { chdir("/var/mobile/"); #endif - g_system = OSystem_iOS7_create(); + g_system = OSystem_iOS7::sharedInstance(); assert(g_system); // Invoke the actual ScummVM main entry point: diff --git a/backends/platform/ios7/ios7_osys_main.h b/backends/platform/ios7/ios7_osys_main.h index 26b147e2a1..eadb49e5ac 100644 --- a/backends/platform/ios7/ios7_osys_main.h +++ b/backends/platform/ios7/ios7_osys_main.h @@ -109,11 +109,15 @@ protected: bool _fullScreenOverlayIsDirty; int _screenChangeCount; + char *_lastErrorMessage; + public: OSystem_iOS7(); virtual ~OSystem_iOS7(); + static OSystem_iOS7 *sharedInstance(); + virtual void initBackend(); virtual bool hasFeature(Feature f); @@ -192,6 +196,7 @@ public: virtual Common::String getDefaultConfigFileName(); virtual void logMessage(LogMessageType::Type type, const char *message); + virtual void fatalError() override; protected: void initVideoContext(); diff --git a/backends/platform/ios7/ios7_osys_video.mm b/backends/platform/ios7/ios7_osys_video.mm index 7cce56c800..0d183ce834 100644 --- a/backends/platform/ios7/ios7_osys_video.mm +++ b/backends/platform/ios7/ios7_osys_video.mm @@ -29,6 +29,38 @@ #include "graphics/conversion.h" #import "iOS7AppDelegate.h" +@interface iOS7AlertHandler : NSObject +@end + +@implementation iOS7AlertHandler + +- (void)alertView:(UIAlertView *)alertView willDismissWithButtonIndex:(NSInteger)buttonIndex { + OSystem_iOS7::sharedInstance()->quit(); + exit(1); +} + +@end + +static void displayAlert(void *ctx) { + UIAlertView *alert = [[UIAlertView alloc] initWithTitle:@"Fatal Error" + message:[NSString stringWithCString:(const char *)ctx encoding:NSUTF8StringEncoding] + delegate:[[iOS7AlertHandler alloc] init] + cancelButtonTitle:@"OK" + otherButtonTitles:nil]; + [alert show]; + [alert autorelease]; +} + +void OSystem_iOS7::fatalError() { + if (_lastErrorMessage) { + dispatch_async_f(dispatch_get_main_queue(), _lastErrorMessage, displayAlert); + for(;;); + } + else { + OSystem::fatalError(); + } +} + void OSystem_iOS7::initVideoContext() { _videoContext = [[iOS7AppDelegate iPhoneView] getVideoContext]; } diff --git a/devtools/create_project/create_project.cpp b/devtools/create_project/create_project.cpp index 2faf39a340..65b7601a54 100644 --- a/devtools/create_project/create_project.cpp +++ b/devtools/create_project/create_project.cpp @@ -935,16 +935,17 @@ TokenList tokenize(const std::string &input, char separator) { namespace { const Feature s_features[] = { // Libraries - { "libz", "USE_ZLIB", "zlib", true, "zlib (compression) support" }, - { "mad", "USE_MAD", "libmad", true, "libmad (MP3) support" }, - { "vorbis", "USE_VORBIS", "libvorbisfile_static libvorbis_static libogg_static", true, "Ogg Vorbis support" }, - { "flac", "USE_FLAC", "libFLAC_static win_utf8_io_static", true, "FLAC support" }, - { "png", "USE_PNG", "libpng", true, "libpng support" }, - { "faad", "USE_FAAD", "libfaad", false, "AAC support" }, - { "mpeg2", "USE_MPEG2", "libmpeg2", false, "MPEG-2 support" }, - { "theora", "USE_THEORADEC", "libtheora_static", true, "Theora decoding support" }, - {"freetype", "USE_FREETYPE2", "freetype", true, "FreeType support" }, - { "jpeg", "USE_JPEG", "jpeg-static", true, "libjpeg support" }, + { "libz", "USE_ZLIB", "zlib", true, "zlib (compression) support" }, + { "mad", "USE_MAD", "libmad", true, "libmad (MP3) support" }, + { "vorbis", "USE_VORBIS", "libvorbisfile_static libvorbis_static libogg_static", true, "Ogg Vorbis support" }, + { "flac", "USE_FLAC", "libFLAC_static win_utf8_io_static", true, "FLAC support" }, + { "png", "USE_PNG", "libpng", true, "libpng support" }, + { "faad", "USE_FAAD", "libfaad", false, "AAC support" }, + { "mpeg2", "USE_MPEG2", "libmpeg2", false, "MPEG-2 support" }, + { "theora", "USE_THEORADEC", "libtheora_static", true, "Theora decoding support" }, + { "freetype", "USE_FREETYPE2", "freetype", true, "FreeType support" }, + { "jpeg", "USE_JPEG", "jpeg-static", true, "libjpeg support" }, + {"fluidsynth", "USE_FLUIDSYNTH", "libfluidsynth", true, "FluidSynth support" }, // Feature flags { "bink", "USE_BINK", "", true, "Bink video support" }, diff --git a/devtools/create_project/xcode.cpp b/devtools/create_project/xcode.cpp index a0521d041e..9fddf8af3f 100644 --- a/devtools/create_project/xcode.cpp +++ b/devtools/create_project/xcode.cpp @@ -401,6 +401,9 @@ void XcodeProvider::setupCopyFilesBuildPhase() { #define DEF_SYSFRAMEWORK(framework) properties[framework".framework"] = FileProperty("wrapper.framework", framework".framework", "System/Library/Frameworks/" framework ".framework", "SDKROOT"); \ ADD_SETTING_ORDER_NOVALUE(children, getHash(framework".framework"), framework".framework", fwOrder++); +#define DEF_SYSTBD(lib) properties[lib".tbd"] = FileProperty("sourcecode.text-based-dylib-definition", lib".tbd", "usr/lib/" lib ".tbd", "SDKROOT"); \ + ADD_SETTING_ORDER_NOVALUE(children, getHash(lib".tbd"), lib".tbd", fwOrder++); + #define DEF_LOCALLIB_STATIC_PATH(path,lib,absolute) properties[lib".a"] = FileProperty("archive.ar", lib ".a", path, (absolute ? "\"\"" : "\"\"")); \ ADD_SETTING_ORDER_NOVALUE(children, getHash(lib".a"), lib".a", fwOrder++); @@ -432,6 +435,7 @@ void XcodeProvider::setupFrameworksBuildPhase(const BuildSetup &setup) { DEF_SYSFRAMEWORK("Carbon"); DEF_SYSFRAMEWORK("Cocoa"); DEF_SYSFRAMEWORK("CoreAudio"); + DEF_SYSFRAMEWORK("CoreMIDI"); DEF_SYSFRAMEWORK("CoreGraphics"); DEF_SYSFRAMEWORK("CoreFoundation"); DEF_SYSFRAMEWORK("CoreMIDI"); @@ -441,6 +445,8 @@ void XcodeProvider::setupFrameworksBuildPhase(const BuildSetup &setup) { DEF_SYSFRAMEWORK("QuartzCore"); DEF_SYSFRAMEWORK("QuickTime"); DEF_SYSFRAMEWORK("UIKit"); + DEF_SYSTBD("libiconv"); + // Optionals: DEF_SYSFRAMEWORK("OpenGL"); @@ -461,12 +467,14 @@ void XcodeProvider::setupFrameworksBuildPhase(const BuildSetup &setup) { absoluteOutputDir = "lib"; #endif - DEF_LOCALLIB_STATIC_PATH(absoluteOutputDir + "/libFLACiOS.a", "libFLACiOS", true); - DEF_LOCALLIB_STATIC_PATH(absoluteOutputDir + "/libFreetype2.a", "libFreetype2", true); - DEF_LOCALLIB_STATIC_PATH(absoluteOutputDir + "/libogg.a", "libogg", true); - DEF_LOCALLIB_STATIC_PATH(absoluteOutputDir + "/libpng.a", "libpng", true); - DEF_LOCALLIB_STATIC_PATH(absoluteOutputDir + "/libvorbis.a", "libvorbis", true); - DEF_LOCALLIB_STATIC_PATH(absoluteOutputDir + "/libmad.a", "libmad", true); + DEF_LOCALLIB_STATIC_PATH(absoluteOutputDir + "/libFLACiOS.a", "libFLACiOS", true); + DEF_LOCALLIB_STATIC_PATH(absoluteOutputDir + "/libFreetype2.a", "libFreetype2", true); + DEF_LOCALLIB_STATIC_PATH(absoluteOutputDir + "/libogg.a", "libogg", true); + DEF_LOCALLIB_STATIC_PATH(absoluteOutputDir + "/libpng.a", "libpng", true); + DEF_LOCALLIB_STATIC_PATH(absoluteOutputDir + "/libvorbis.a", "libvorbis", true); + DEF_LOCALLIB_STATIC_PATH(absoluteOutputDir + "/libmad.a", "libmad", true); + DEF_LOCALLIB_STATIC_PATH(absoluteOutputDir + "/libfluidsynth.a", "libfluidsynth", true); + DEF_LOCALLIB_STATIC_PATH(absoluteOutputDir + "/libglib.a", "libglib", true); frameworksGroup->properties["children"] = children; _groups.add(frameworksGroup); @@ -499,11 +507,28 @@ void XcodeProvider::setupFrameworksBuildPhase(const BuildSetup &setup) { frameworks_iOS.push_back("QuartzCore.framework"); frameworks_iOS.push_back("OpenGLES.framework"); - if (CONTAINS_DEFINE(setup.defines, "USE_FLAC")) frameworks_iOS.push_back("libFLACiOS.a"); - if (CONTAINS_DEFINE(setup.defines, "USE_FREETYPE2")) frameworks_iOS.push_back("libFreetype2.a"); - if (CONTAINS_DEFINE(setup.defines, "USE_PNG")) frameworks_iOS.push_back("libpng.a"); - if (CONTAINS_DEFINE(setup.defines, "USE_VORBIS")) { frameworks_iOS.push_back("libogg.a"); frameworks_iOS.push_back("libvorbis.a"); } - if (CONTAINS_DEFINE(setup.defines, "USE_MAD")) frameworks_iOS.push_back("libmad.a"); + if (CONTAINS_DEFINE(setup.defines, "USE_FLAC")) { + frameworks_iOS.push_back("libFLACiOS.a"); + } + if (CONTAINS_DEFINE(setup.defines, "USE_FREETYPE2")) { + frameworks_iOS.push_back("libFreetype2.a"); + } + if (CONTAINS_DEFINE(setup.defines, "USE_PNG")) { + frameworks_iOS.push_back("libpng.a"); + } + if (CONTAINS_DEFINE(setup.defines, "USE_VORBIS")) { + frameworks_iOS.push_back("libogg.a"); + frameworks_iOS.push_back("libvorbis.a"); + } + if (CONTAINS_DEFINE(setup.defines, "USE_MAD")) { + frameworks_iOS.push_back("libmad.a"); + } + if (CONTAINS_DEFINE(setup.defines, "USE_FLUIDSYNTH")) { + frameworks_iOS.push_back("libfluidsynth.a"); + frameworks_iOS.push_back("libglib.a"); + frameworks_iOS.push_back("CoreMIDI.framework"); + frameworks_iOS.push_back("libiconv.tbd"); + } for (ValueList::iterator framework = frameworks_iOS.begin(); framework != frameworks_iOS.end(); framework++) { std::string id = "Frameworks_" + *framework + "_iphone"; -- cgit v1.2.3