0

My client has provided a .so pre-built shared library. Which supposed to load with libpd, since libpd controller requires m4aPlayer module to load. So I put libm4aPlayer.so inside jniLibs(also tried libs) folder under app > main and then I added this in my build.gradle

defaultConfig {
        ndk{
            moduleName "m4aPlayer"
        }
    }
    ...

sourceSets {
        main {
            jni {
                srcDirs = []
            }
            jniLibs {
                srcDir 'libs'
            }
        }
    }

And then in my AudioService class (where I initPd() and loadPatch()) I am trying to call native prebuilt library that client provided by doing this

patchFile = new File(pdFile[0].mFile.getParent(), "pd/_main.pd");

//System.loadLibrary("pd");
System.loadLibrary("m4aPlayer");

PdBase.openPatch(patchFile);
PdBase.sendFloat("fadeTime", 12f);

enter image description here

Everytime I try to open the patch file(_main.pd) I get error from PD controller saying "m4aPlayer couldn't create". But I am trying to load the library still pd throws this error. It does play other audio fine(where libpd doesnt require m4aPlayer glue.)

Stack trace

05-30 21:48:05.840 6589-6589/com.test.test I/PdUiDispatcher: print: 
05-30 21:48:05.840 6589-6589/com.test.test I/PdUiDispatcher: print:  
05-30 21:48:05.840 6589-6589/com.test.test I/PdUiDispatcher: print: m4aPlayer
05-30 21:48:05.840 6589-6589/com.test.test I/PdUiDispatcher: print: 
05-30 21:48:05.840 6589-6589/com.test.test I/PdUiDispatcher: print: error: ... couldn't create
05-30 21:48:05.840 6589-6589/com.test.test I/PdUiDispatcher: print: 
05-30 21:48:05.840 6589-6589/com.test.test I/PdUiDispatcher: print:  
05-30 21:48:05.840 6589-6589/com.test.test I/PdUiDispatcher: print: m4aPlayer
05-30 21:48:05.841 6589-6589/com.test.test I/PdUiDispatcher: print: 
05-30 21:48:05.841 6589-6589/com.test.test I/PdUiDispatcher: print: error: ... couldn't create
05-30 21:48:05.841 6589-6589/com.test.test I/PdUiDispatcher: print: 
05-30 21:48:05.841 6589-6589/com.test.test I/PdUiDispatcher: print:  
05-30 21:48:05.841 6589-6589/com.test.test I/PdUiDispatcher: print: m4aPlayer
05-30 21:48:05.841 6589-6589/com.test.test I/PdUiDispatcher: print: 
05-30 21:48:05.841 6589-6589/com.test.test I/PdUiDispatcher: print: error: ... couldn't create
05-30 21:48:05.841 6589-6589/com.test.test I/PdUiDispatcher: print: fadeTime: 12
05-30 21:48:05.841 6589-6589/com.test.test I/PdUiDispatcher: print: fadeDelay: 3
05-30 21:48:05.841 6589-6589/com.test.test I/PdUiDispatcher: print: curve: 30
05-30 21:48:05.841 6589-6589/com.test.test I/PdUiDispatcher: print: musicVol: 1.5
05-30 21:48:05.841 6589-6589/com.test.test I/PdUiDispatcher: print: voiceVol: 1.5
05-30 21:48:05.841 6589-6589/com.test.test I/PdUiDispatcher: print: voiceGender: 1
05-30 21:48:05.841 6589-6589/com.test.test I/PdUiDispatcher: print: isRandom: 1
05-30 21:48:05.841 6589-6589/com.test.test I/PdUiDispatcher: print: suggestionsVO: 1
05-30 21:48:05.841 6589-6589/com.test.test I/PdUiDispatcher: print: availableSoundscapes:
05-30 21:48:05.842 6589-6589/com.test.test I/PdUiDispatcher: print:  
05-30 21:48:05.842 6589-6589/com.test.test I/PdUiDispatcher: print: 2
05-30 21:48:05.842 6589-6589/com.test.test I/PdUiDispatcher: print:  
05-30 21:48:05.842 6589-6589/com.test.test I/PdUiDispatcher: print: 3
05-30 21:48:05.842 6589-6589/com.test.test I/PdUiDispatcher: print:  
05-30 21:48:05.842 6589-6589/com.test.test I/PdUiDispatcher: print: 4
05-30 21:48:05.842 6589-6589/com.test.test I/PdUiDispatcher: print:  
05-30 21:48:05.842 6589-6589/com.test.test I/PdUiDispatcher: print: 5
05-30 21:48:05.842 6589-6589/com.test.test I/PdUiDispatcher: print:  
05-30 21:48:05.842 6589-6589/com.test.test I/PdUiDispatcher: print: 6
05-30 21:48:05.842 6589-6589/com.test.test I/PdUiDispatcher: print:  
05-30 21:48:05.842 6589-6589/com.test.test I/PdUiDispatcher: print: 7
05-30 21:48:05.842 6589-6589/com.test.test I/PdUiDispatcher: print:  
05-30 21:48:05.842 6589-6589/com.test.test I/PdUiDispatcher: print: 8
05-30 21:48:05.842 6589-6589/com.test.test I/PdUiDispatcher: print:  
05-30 21:48:05.842 6589-6589/com.test.test I/PdUiDispatcher: print: 9
05-30 21:48:05.843 6589-6589/com.test.test I/PdUiDispatcher: print: 
05-30 21:48:05.843 6589-6589/com.test.test I/PdUiDispatcher: print: module: 2
05-30 21:48:05.843 6589-6589/com.test.test I/PdUiDispatcher: print: INTO-Q: 0
05-30 21:48:05.843 6589-6589/com.test.test I/PdUiDispatcher: print: soundscape: 5
05-30 21:48:05.843 6589-6589/com.test.test I/PdUiDispatcher: print: toApp-isThisFileOK: p5intro0

I also tried to check inside the app to make sure library is being copied or not. So I went to

data/data/package_name/lib

enter image description here

Alex
  • 1,052
  • 1
  • 11
  • 22
  • I assume the .so file you're trying to use is a pure-data external? In that case - can you get the sources from your client and build it as an external as described in the pd-for-android README instead of binding a .so file? Does the patch load properly on the desktop version of pure-data vanilla? – kirsh300 Jun 01 '16 at 08:35
  • @kirsh300 - Yes libm4aPlayer.so is a pure-data external, Which I do have in my app>main>jni directory. Once I tried to build using ndk-build command. I was also able to generate .so file (even though client already provided prebuilt .so file) and tried loading that .so file, But that also failed. Every-time I try to call _main.pd it looks for m4aPlayer module which supposed to load at runtime that's why I was doing System.loadLibrary("m4aPlayer") to load it. – Alex Jun 04 '16 at 22:25
  • Can you provide a snippet of the patch that requires m4aPlayer? – Joe Bowbeer Jun 05 '16 at 00:08

3 Answers3

0

You don't need to call System.loadLibrary() to load pure data externals.

Have a look at the PdTest example on the pd-for-android repository as a reference to how the "helloworld.c" external is used there. You could use that as a template for your own project to keep things simple at first and validate that the pure data patch can load your libm4aPlayer external correctly.

Also- you're mentioning .m files. I guess you're compiling Objective C then? I haven't seen anyone doing that with pd-for-android so I'm not sure if that will work.

kirsh300
  • 307
  • 4
  • 10
  • Hey, I was trying everything I can think of. So I tried with .h/.m file too. Just to see if it works or not. Client has provided a pre-built libm4aPlayer.so library and told us that it needs to be packaged within apk. Look at the device screenshot, that confirms that it's copying the .so within the apk. But when I read _main.pd (main audio controller) I get that error right away. – Alex Jun 06 '16 at 21:13
0

This answer may provide some clues or tips: https://stackoverflow.com/a/27523384/901597

Community
  • 1
  • 1
Joe Bowbeer
  • 3,574
  • 3
  • 36
  • 47
0

there are three options:

  • Pd cannot find the library file: try using a full path (or confirm that other externals, like [bonk~] can be loaded)

  • the binary misses some dependencies (check with some android equivalent of ldd)

  • the binary is not a Pd-external at all (despite what your customer claims)

to debug the last two options, you might want to raise verbosity and or monitor the stderr (and probably stdout) of your app as well.

Community
  • 1
  • 1
umläute
  • 28,885
  • 9
  • 68
  • 122