19 Jun '13 - 10:06 *
Welcome, Guest. Please login or register.
Did you miss your activation email?

Login with username, password and session length
 
   Home   Help Search Login Register  
Pages: [1]
  Reply  |  Print  
Author Topic: Load plugin in MonoTouch  (Read 722 times)
AfflatusX
Posts: 10


« on: 9 Jul '12 - 04:51 »
Reply with quoteQuote

Hi,

I am currently working on a project in MonoTouch for iOS using Bass.Net. I was able to get libbass.a working by using the mtouch arguments and Bass.BASS_Init (-1, 44100, BASSInit.BASS_DEVICE_DEFAULT, IntPtr.Zero);

However, I don't know how to get Bass.Bass_PluginLoad working under MonoTouch. The iOS post mentioned something like:

    extern void BASSFLACplugin;
    BASS_PluginLoad(&BASSFLACplugin, 0);

But that is Objective C statements. How can I do that in C#?

Any ideas would be appreciated.

Thanks
Logged
AfflatusX
Posts: 10


« Reply #1 on: 10 Jul '12 - 05:54 »
Reply with quoteQuote

Hi,

I tried .net marshaling a little bit and was able to call plugin load without crashing the app directly. However, I am keep getting Bass_version_error after the call. Since passing random pointer to Pluginload will cause immedieate crash, I suppose the pointer I got through marshaling is the right one?

Can anyone provide some thoughts on this issue or show me the correct way loading plugin in monotouch?

Thanks!

T
Logged
radio42
Posts: 4030


« Reply #2 on: 10 Jul '12 - 13:55 »
Reply with quoteQuote

I am affraid, this is currently not possible - as on iOS those libs need to be statically linked and .Net can not lookup the static symbol address (like in the C/C++ example).
However, we are looking into a way to enable this!
Stay tuned...
Logged
AfflatusX
Posts: 10


« Reply #3 on: 11 Jul '12 - 00:02 »
Reply with quoteQuote

Thanks for the reply!

Not sure if this would help you a little bit or not -  I tried to use reflection to get the pointer of the extern static function and P/Invoke PluginLoad with signature (IntPtr, int). That's when the code didn't crash but returned me BASS_ERROR_VERSION. If I pass other pointers or pass some random string into PluginLoad(string), the code would immediately crash. Maybe you can try to use unsafe context and marshal the address back to the native code?

Anyway, for now I'll take Ken's advice using BASS_FLAC_StreamCreateFile... etc. Looking forward to see you guys get it working!

T
Logged
Ian @ un4seen
Administrator
Posts: 15363


« Reply #4 on: 11 Jul '12 - 13:34 »
Reply with quoteQuote

Here's something to try...

   www.un4seen.com/stuff/libbass.a

It adds support for passing the name of an add-on to BASS_PluginLoad. For example, like this...

BASS_PluginLoad("BASSFLAC", 0); // plug in BASSFLAC
BASS_PluginLoad("BASS_APE", 0); // plug in BASS_APE

There may be a problem with loading plugins in this way though, because a linker generally won't import a library if it doesn't appear to be used. For example, when the "BASSFLACplugin" symbol is used, the linker knows that the BASSFLAC library (libbassflac.a) is needed because that's where the "BASSFLACplugin" symbol is located, but it doesn't know the BASSFLAC library is needed if a "BASSFLAC" string is just passed to BASS_PluginLoad. Hopefully the MonoTouch linker won't do that. If it isn't working (BASS_PluginLoad fails), you could try also adding a BASSFLAC function call to your app (eg. call BASS_FLAC_StreamCreateFile with an empty filename) to force MonoTouch to import the BASSFLAC library.
Logged
Pages: [1]
  Reply  |  Print  
 
Jump to:  

Powered by SMF 1.1.18 | SMF © 2013, Simple Machines