[Cs-dev] Android Csound 6 - loading plugins
Date | 2013-06-06 14:18 |
From | Michael Gogins |
Subject | [Cs-dev] Android Csound 6 - loading plugins |
Attachments | None None |
I put the dynamically loaded shared libraries in assets/armeabi/OPCODE6DIR and in assets/armeabi-v7a/OPCODE6DIR.
I put in code to verify that the files actually are in these locations (they are).
I put in to code to call SetGlobalEnv("OPCODE6DIR", "/data/data/assets/aremabi-v7a") just before I call CsoundObj.startCsound(). I put in code to verify that the pathname is correct (it is).
No dice... any ideas? Is it that the global env gets wiped out by the CsoundAndroid.Compile() call? Is it something to do with Android permissions?
Is it something to do with dependent libraries like stlport or something? How does one debug C code running on the device? Regards,
Mike Michael Gogins Irreducible Productions http://michaelgogins.tumblr.com Michael dot Gogins at gmail dot com |
Date | 2013-06-06 14:24 |
From | Steven Yi |
Subject | Re: [Cs-dev] Android Csound 6 - loading plugins |
Hi Michael, I think the path may be wrong: "/data/data/assets/aremabi-v7a". It's been a while since I looked at the filesystem on Android, but you can usually browse it using "adb shell" with a device connected. The better things though may be to use the AssetsManager to list the paths of items in armeabi-v7a/OPCODE64DIR and then try to get the full path to that folder from there. Apps I think might be installed into main memory or sd card, so we can't count on it being in a fixed folder. Maybe check in the code and I can try it out here? Thanks! steven On Thu, Jun 6, 2013 at 9:18 AM, Michael Gogins |
Date | 2013-06-06 14:32 |
From | Michael Gogins |
Subject | Re: [Cs-dev] Android Csound 6 - loading plugins |
Attachments | None None |
There may be local shared libs I need: Regards, Mike Michael Gogins Irreducible Productions http://michaelgogins.tumblr.com Michael dot Gogins at gmail dot com On Thu, Jun 6, 2013 at 9:18 AM, Michael Gogins <michael.gogins@gmail.com> wrote:
|
Date | 2013-06-06 14:38 |
From | Steven Yi |
Subject | Re: [Cs-dev] Android Csound 6 - loading plugins |
Well we eliminate some variables. I know that the fluidsynth opcode libs built and loaded, as did the stdutil library. I had tested and got these both to load and run. If you test with just those libraries, that will eliminate some variables and just leave it to getting the correct path. On Thu, Jun 6, 2013 at 9:32 AM, Michael Gogins |
Date | 2013-06-06 14:42 |
From | Michael Gogins |
Subject | Re: [Cs-dev] Android Csound 6 - loading plugins |
Attachments | None None |
I am already doing what say, using the asset manager and the package config tool to determine the actual pathnames and files. Maybe the libs depend on libs that aren't installed... I can debug that though it's a bit difficult by pushing strace onto the phone with adb.
I'll check in the code this evening. Actually it may be that libsndfile.so is needed... I didn't install that one.
Michael Gogins Irreducible Productions http://michaelgogins.tumblr.com Michael dot Gogins at gmail dot com On Thu, Jun 6, 2013 at 9:24 AM, Steven Yi <stevenyi@gmail.com> wrote: Hi Michael, |
Date | 2013-06-06 14:43 |
From | Michael Gogins |
Subject | Re: [Cs-dev] Android Csound 6 - loading plugins |
Attachments | None None |
Yes, I was trying with fluidsynth. Michael Gogins Irreducible Productions http://michaelgogins.tumblr.com Michael dot Gogins at gmail dot com On Thu, Jun 6, 2013 at 9:38 AM, Steven Yi <stevenyi@gmail.com> wrote: Well we eliminate some variables. I know that the fluidsynth opcode |
Date | 2013-06-06 14:53 |
From | Steven Yi |
Subject | Re: [Cs-dev] Android Csound 6 - loading plugins |
Just FYI, the way libcsoundandroid.so builds (or did, haven't gotten to building since the build file changes), it linked in libsndfile statically so that that libcsoundandroid has both libcsound and libsndfile into one lib. I think that was done at the time to just make it easier to have one lib to distribute, but it'd be fine to change that to split to libs. Can't think of anything else that might be a hint. I'll wait until the code is checked in and will look at building/testing here. Hopefully it's something simple. :) On Thu, Jun 6, 2013 at 9:43 AM, Michael Gogins |
Date | 2013-06-06 15:03 |
From | Victor Lazzarini |
Subject | Re: [Cs-dev] Android Csound 6 - loading plugins |
Plugins do not normally depend on libsndfile (I changed this ages ago). I think it is more likely that the plugin library was not found. One thing to try is to use --opcode-lib= to load it from the CSDPlayer, placing the plugin in the same dir as the CSD (for convenience). On 6 Jun 2013, at 14:53, Steven Yi wrote: > Just FYI, the way libcsoundandroid.so builds (or did, haven't gotten > to building since the build file changes), it linked in libsndfile > statically so that that libcsoundandroid has both libcsound and > libsndfile into one lib. I think that was done at the time to just > make it easier to have one lib to distribute, but it'd be fine to > change that to split to libs. > > Can't think of anything else that might be a hint. I'll wait until > the code is checked in and will look at building/testing here. > Hopefully it's something simple. :) > > On Thu, Jun 6, 2013 at 9:43 AM, Michael Gogins |
Date | 2013-06-07 01:14 |
From | Michael Gogins |
Subject | Re: [Cs-dev] Android Csound 6 - loading plugins |
Attachments | None None |
I think there may be a difference in that Csound 5 has PreCompile and Csound 6 does not... Csound is acting like it forgets the global env I have set. I've booked in my code for you all to play with. Regards, Mike Michael Gogins Irreducible Productions http://michaelgogins.tumblr.com Michael dot Gogins at gmail dot com On Thu, Jun 6, 2013 at 10:03 AM, Victor Lazzarini <Victor.Lazzarini@nuim.ie> wrote: Plugins do not normally depend on libsndfile (I changed this ages ago). I think it is more likely that the |
Date | 2013-06-07 03:53 |
From | Steven Yi |
Subject | Re: [Cs-dev] Android Csound 6 - loading plugins |
Hi Michael, I took a quick look and had some questions: 1. This seems to be setting the libs to a folder different than what you're looking for with the list() calls: String OPCODE6DIR = packageInfo.applicationInfo.dataDir + "/assets/libs"; Shouldn't that be "/assets/armeabi-v7a/OPCODE6DIR" ? 2. For your generated APK file, could you to a "tar tzvf CSDPlayer.apk" to list the contents and post it here? Thanks! steven p.s. - I'm going on a long drive tomorrow and again on Sunday, so I'll be off and on the internet the next few days. On Thu, Jun 6, 2013 at 8:14 PM, Michael Gogins |
Date | 2013-06-07 04:19 |
From | Michael Gogins |
Subject | Re: [Cs-dev] Android Csound 6 - loading plugins |
Attachments | None None |
I changed the location, but in my tests it is consistent, and I verify it by printing out the directory listing from the device in the debugger. I note that if I call set global env then start Csound Then get env, it returns null. That can't be right. .. On Jun 6, 2013 10:54 PM, "Steven Yi" <stevenyi@gmail.com> wrote:
Hi Michael, |
Date | 2013-06-07 07:32 |
From | Victor Lazzarini |
Subject | Re: [Cs-dev] Android Csound 6 - loading plugins |
Attachments | None None |
Try it now with code from GIT. I made some changes that should prevent any resetting to happen when Csound is created. On 7 Jun 2013, at 04:19, Michael Gogins wrote:
Dr Victor Lazzarini Senior Lecturer Dept. of Music NUI Maynooth Ireland tel.: +353 1 708 3545 Victor dot Lazzarini AT nuim dot ie |
Date | 2013-06-07 12:41 |
From | Michael Gogins |
Subject | Re: [Cs-dev] Android Csound 6 - loading plugins |
Attachments | None None |
Thanks for the quick change. Unfortunately, it's still not working. The value of OPCODE6DIR is now returned as I expect from getEnv after starting Csound, but still no load.
Is this "float" or "double" Csound here? Should it be OPCODE6DIR64 instead of just OPCODE6DIR? Anyway, the code is cleaned up a bit, made consistent, and checked in, so you should be download and debug. In the debugger you can inspect what getAssets returns and see that the files are indeed where OPCODE6DIR says they should be.
BTW, I renamed CsoundApp.apk to Csound6.apk. Regards, Mike Michael Gogins
Irreducible Productions http://michaelgogins.tumblr.com Michael dot Gogins at gmail dot com On Fri, Jun 7, 2013 at 2:32 AM, Victor Lazzarini <Victor.Lazzarini@nuim.ie> wrote:
|
Date | 2013-06-07 14:31 |
From | Victor Lazzarini |
Subject | Re: [Cs-dev] Android Csound 6 - loading plugins |
Attachments | None None |
It's floats, so it should be OPCODE6DIR, but you could set both. I'll look again at the Csound set env code to see if I can spot anything. Could you outline here the sequence of API calls? On 7 Jun 2013, at 12:41, Michael Gogins wrote:
Dr Victor Lazzarini Senior Lecturer Dept. of Music NUI Maynooth Ireland tel.: +353 1 708 3545 Victor dot Lazzarini AT nuim dot ie |
Date | 2013-06-07 14:47 |
From | Victor Lazzarini |
Subject | Re: [Cs-dev] Android Csound 6 - loading plugins |
Attachments | None None |
Just looking at the code, if you call csoundSetGlobalEnv(name, value); to set a global var,and then call csoundGetEnv(csound, name); it will not find it, probably returning NULL, because it is not looking at the global vars list, but at the instance envrionment vars (look in envvar.c code). But if you call csoundGetEnv(NULL, name), it will look at the global var list. alternatively, use csoundSetEnv(), to use instance global vars. On 7 Jun 2013, at 14:31, Victor Lazzarini wrote:
Dr Victor Lazzarini Senior Lecturer Dept. of Music NUI Maynooth Ireland tel.: +353 1 708 3545 Victor dot Lazzarini AT nuim dot ie |
Date | 2013-06-07 14:55 |
From | Michael Gogins |
Subject | Re: [Cs-dev] Android Csound 6 - loading plugins |
Attachments | None None |
Oh dear, looks like by renaming things I removed the CsoundAppActivity.java code from Git, I won't be able to put it back till this evening...
Here's the code from the earlier revision:
Michael Gogins
Irreducible Productions http://michaelgogins.tumblr.com Michael dot Gogins at gmail dot com On Fri, Jun 7, 2013 at 9:31 AM, Victor Lazzarini <Victor.Lazzarini@nuim.ie> wrote:
|
Date | 2013-06-07 14:56 |
From | Michael Gogins |
Subject | Re: [Cs-dev] Android Csound 6 - loading plugins |
Attachments | None None |
But actually, getEnv is returning the value as set by setGlobalEnv, at least the second time the CsoundObj is created anyway. Regards, Mike Michael Gogins Irreducible Productions http://michaelgogins.tumblr.com Michael dot Gogins at gmail dot com On Fri, Jun 7, 2013 at 9:55 AM, Michael Gogins <michael.gogins@gmail.com> wrote:
|
Date | 2013-06-07 15:03 |
From | Victor Lazzarini |
Subject | Re: [Cs-dev] Android Csound 6 - loading plugins |
Attachments | None None |
I thought it was null? On 7 Jun 2013, at 14:56, Michael Gogins wrote:
Dr Victor Lazzarini Senior Lecturer Dept. of Music NUI Maynooth Ireland tel.: +353 1 708 3545 Victor dot Lazzarini AT nuim dot ie |
Date | 2013-06-07 15:06 |
From | Victor Lazzarini |
Subject | Re: [Cs-dev] Android Csound 6 - loading plugins |
Attachments | None None |
Maybe you should call csoundSetGlobalEnv(const char *name, const char *value) before creating CsoundObj()? On 7 Jun 2013, at 14:56, Michael Gogins wrote:
Dr Victor Lazzarini Senior Lecturer Dept. of Music NUI Maynooth Ireland tel.: +353 1 708 3545 Victor dot Lazzarini AT nuim dot ie |
Date | 2013-06-07 15:23 |
From | Michael Gogins |
Subject | Re: [Cs-dev] Android Csound 6 - loading plugins |
Attachments | None None |
OK, I'll try that. I've been googling for dlopen on Android. Information is spotty and I think unreliable, but my impression is certainly that dlopen the way Csound does it should work.
There was one report that dlsym would return an error but also the correct function address, so maybe we should fix up the module loading code to take that into account. I'll put in some debug printouts in that later. And do more googling...
Michael Gogins Irreducible Productions http://michaelgogins.tumblr.com Michael dot Gogins at gmail dot com On Fri, Jun 7, 2013 at 10:06 AM, Victor Lazzarini <Victor.Lazzarini@nuim.ie> wrote:
|
Date | 2013-06-07 15:29 |
From | Victor Lazzarini |
Subject | Re: [Cs-dev] Android Csound 6 - loading plugins |
Attachments | None None |
We definitely had it working with Csound 5, so dlopen should be OK. Victor On 7 Jun 2013, at 15:23, Michael Gogins wrote:
Dr Victor Lazzarini Senior Lecturer Dept. of Music NUI Maynooth Ireland tel.: +353 1 708 3545 Victor dot Lazzarini AT nuim dot ie |
Date | 2013-06-07 15:43 |
From | Michael Gogins |
Subject | Re: [Cs-dev] Android Csound 6 - loading plugins |
Attachments | None None |
I think you were using a different version of Android (I am using Ice Cream Sandwich 4.2.2). There are multiple reports of an issue with dlsym in Android, here is one: http://grokbase.com/t/gg/android-ndk/12628t0pf1/dlsym-not-working-on-ics. It looks like the problem can be solved without harm to other platforms by clearing any DL errors before each dlsym call, and/or checking if the returned function pointer is actually null. If you have an older Android, try csound6.apk from SourceForge and try create a fluidEngine in your csd. Regards, Mike Michael Gogins Irreducible Productions http://michaelgogins.tumblr.com Michael dot Gogins at gmail dot com On Fri, Jun 7, 2013 at 10:29 AM, Victor Lazzarini <Victor.Lazzarini@nuim.ie> wrote:
|