IOS: Brings support for FluidSynth

This commit is contained in:
Vincent Bénony 2015-12-11 14:24:29 +01:00
parent 8d9b13059b
commit c99456ecff
6 changed files with 109 additions and 25 deletions

View file

@ -31,6 +31,11 @@
#include "audio/musicplugin.h"
#include "audio/mpu401.h"
#include "audio/softsynth/emumidi.h"
#ifdef IPHONE_OFFICIAL
#include <string.h>
#include <sys/syslimits.h>
#include "backends/platform/ios7/ios7_common.h"
#endif
#include <fluidsynth.h>
@ -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);

View file

@ -25,6 +25,7 @@
#include <unistd.h>
#include <pthread.h>
#include <string.h>
#include <sys/time.h>
@ -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:

View file

@ -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();

View file

@ -29,6 +29,38 @@
#include "graphics/conversion.h"
#import "iOS7AppDelegate.h"
@interface iOS7AlertHandler : NSObject<UIAlertViewDelegate>
@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];
}

View file

@ -943,8 +943,9 @@ const Feature s_features[] = {
{ "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" },
{ "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" },

View file

@ -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 ? "\"<absolute>\"" : "\"<group>\"")); \
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");
@ -467,6 +473,8 @@ void XcodeProvider::setupFrameworksBuildPhase(const BuildSetup &setup) {
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";