c# - Not able to register FMOD Plugin on iOS (using Unity3d) -


i created fmod plugin on c++ , generated both dynamic library (.dylib) , static library (.a).

i able use dynamic library fmod studio gui , i’m able use in unity3d mac simulator (which picks dynamic library assets/plugins. i’m having problems getting things working on iphone.

for ios, need use static library (*.a), means have manually load plugin in unity3d (c#), generate xcode project , installed on iphone. tried implementing basic function in c , load on c# , works fine. means static library generated , can load on iphone , use it. can’t working fmod description function.

here code, when run in iphone, i’m getting error:

“fmoddescptr intptr.zero”

thanks in advanced help! i’ve been struggling 5 days , haven’t been able solve it.

c++ side:

f_declspec f_dllexport int f_stdcall aigoogetdspdescription2(fmod_dsp_description *fmoddesc) {  // defines user interface, maximum distance knob static float distance_mapping_values[] = { 0, 1, 5, 20, 100, 500, 10000 }; static float distance_mapping_scale[] = { 0, 1, 2, 3, 4, 4.5, 5 };  // defines 3d location attributes fmod_dsp_init_paramdesc_data(p_3d_attributes, "3d attributes", "",  "",  fmod_dsp_parameter_data_type_3dattributes);   fmod_dsp_description aigoo_simple_plugin_desc = {     fmod_plugin_sdk_version,     "aigoosimpleplugin6",    // name     0x00010000,     // plug-in version     1,              // number of input buffers process     1,              // number of output buffers process     aigoo_simple_plugin_dspcreate,     aigoo_simple_plugin_dsprelease,     aigoo_simple_plugin_dspreset,     aigoo_simple_plugin_dspread,     0,     0,     aigoo_simple_plugin_num_parameters,     aigoo_simple_plugin_dspparam,     aigoo_simple_plugin_dspsetparamfloat,     0, // aigoo_simple_plugin_dspsetparamint,     0, // aigoo_simple_plugin_dspsetparambool,     aigoo_simple_plugin_dspsetparamdata,     aigoo_simple_plugin_dspgetparamfloat,     0, // aigoo_simple_plugin_dspgetparamint,     0, // aigoo_simple_plugin_dspgetparambool,     aigoo_simple_plugin_dspgetparamdata,     aigoo_simple_plugin_shouldiprocess,     0,                                      // userdata     aigoo_simple_plugin_sys_register,     aigoo_simple_plugin_sys_deregister,     aigoo_simple_plugin_sys_mix };   fmoddesc = &aigoo_simple_plugin_desc;  return 9291983;  //this test i'm able value on c# , ios side } 

c# side:

public class aigoopluginhandler {     [dllimport ("__internal")]     public static extern int aigoogetdspdescription2(out intptr fmoddesc); }  public class myaigooclass : monobehaviour  {     if (application.platform == runtimeplatform.iphoneplayer) {         intptr fmoddescptr;         plugin_result = aigoopluginhandler.aigoogetdspdescription2(out fmoddescptr);         //printing plugin_result returns 9291983 value returned c          if (fmoddescptr != intptr.zero)         {             dsp_description fmoddesc = (dsp_description)marshal.ptrtostructure(fmoddescptr, typeof(dsp_description));             fmoddesc.numinputbuffers = 1;             errcheck(sys.registerdsp(ref fmoddesc, out mmdsp_handle));         }         else             console.writeline("fmoddescptr intptr.zero");         } } 

this original structure dsp_description:

[structlayout(layoutkind.sequential)] //original: public struct dsp_description {     public uint pluginsdkversion;                          /* [w] plugin sdk version plugin built for.  set fmod_plugin_sdk_version defined above. */     [marshalas(unmanagedtype.byvalarray, sizeconst = 32)]     public char[]                      name;               /* [w] name of unit displayed in network. */     public uint                        version;            /* [w] plugin writer's version number. */     public int                         numinputbuffers;    /* [w] number of input buffers process.  use 0 dsps generate sound , 1 effects process incoming sound. */     public int                         numoutputbuffers;   /* [w] number of audio output buffers.  1 output buffer supported. */     public dsp_createcallback          create;             /* [w] create callback.  called when dsp unit created.  can null. */     public dsp_releasecallback         release;            /* [w] release callback.  called before unit freed user can cleanup needed unit.  can null. */     public dsp_resetcallback           reset;              /* [w] reset callback.  called user reset history buffers may need resetting filter, when used or re-used first time initial clean state.  use avoid clicks or artifacts. */     public dsp_readcallback            read;               /* [w] read callback.  processing done here.  can null. */     public dsp_process_callback        process;            /* [w] process callback.  can specified instead of read callback if channel format changes occur between input , output.  replaces shouldiprocess , should return error if effect bypassed.  can null. */     public dsp_setpositioncallback     setposition;        /* [w] setposition callback.  called if unit wants update position info not process data.  can null. */      public int                         numparameters;      /* [w] number of parameters used in filter.  user finds dsp::getnumparameters */     public intptr                      paramdesc;          /* [w] variable number of parameter structures. */     public dsp_setparam_float_callback setparameterfloat;  /* [w] called when user calls dsp.setparameterfloat. can null. */     public dsp_setparam_int_callback   setparameterint;    /* [w] called when user calls dsp.setparameterint.   can null. */     public dsp_setparam_bool_callback  setparameterbool;   /* [w] called when user calls dsp.setparameterbool.  can null. */     public dsp_setparam_data_callback  setparameterdata;   /* [w] called when user calls dsp.setparameterdata.  can null. */     public dsp_getparam_float_callback getparameterfloat;  /* [w] called when user calls dsp.getparameterfloat. can null. */     public dsp_getparam_int_callback   getparameterint;    /* [w] called when user calls dsp.getparameterint.   can null. */     public dsp_getparam_bool_callback  getparameterbool;   /* [w] called when user calls dsp.getparameterbool.  can null. */     public dsp_getparam_data_callback  getparameterdata;   /* [w] called when user calls dsp.getparameterdata.  can null. */     public dsp_shouldiprocess_callback shouldiprocess;     /* [w] called before processing.  can detect if inputs idle , return fmod_ok process, or other error code avoid processing effect.  use count down timer allow effect tails process before idling! */     public intptr                      userdata;           /* [w] optional. specify 0 ignore. user data attached dsp unit during creation.  access via dsp::getuserdata. */ } 

thanks, carlos

looks aigoo_simple_plugin_desc being allocated on stack rather heap.

instead of:

fmod_dsp_description aigoo_simple_plugin_desc = ... 

...try following. note how fmod_dsp_description parameter has been changed pointer pointer:

f_declspec f_dllexport int f_stdcall aigoogetdspdescription2(fmod_dsp_description **ppfmoddesc) {     fmod_dsp_description* aigoo_simple_plugin_descptr = new fmod_dsp_description ();     // initialise aigoo_simple_plugin_descptr      .     .     .     *ppfmoddesc = aigoo_simple_plugin_descptr;       .     .     . 

the specified structure must blittable or have layout information

try adding [structlayout(layoutkind.explicit)] struct on c# side.


Comments

Popular posts from this blog

resizing Telegram inline keyboard -

command line - How can a Python program background itself? -

php - "cURL error 28: Resolving timed out" on Wordpress on Azure App Service on Linux -