title: Android Using tinyalsa in Java code
body: <p>I built tinyalsa lib using the sources from <a href="https://github.com/ykasidit/tinyalsa-ndk/" rel="nofollow" title="tinyalsa-ndk">tinyalsa-ndk</a> and wrapped it with JNI calls and I'm trying to use it in my code.<br></p>
  
  <p>I used <a href="http://www.swig.org/" rel="nofollow">Swig</a> to generate Java wrappers (and modified output to comply with my package)
  My native method declaration is:</p>
  
  <pre><code>public final static native long mixer_open(long jarg);
  </code></pre>
  
  <p>My JNI wrapper call is inside a wrapper class TinyAlsa.java under the root pacakge (for the example I'll use com.Example.App):</p>
  
  <pre><code>public static SWIGTYPE_p_mixer mixer_open(long card) 
  {
      long cPtr = TinyAlsaJNI.mixer_open(card);
      return (cPtr == 0) ? null : new SWIGTYPE_p_mixer(cPtr, false);
  }
  </code></pre>
  
  <p>and my wrapper c method is:</p>
  
  <pre><code>SWIGEXPORT jlong JNICALL Java_com_Example_App_Native_TinyAlsaJNI_mixer_1open(JNIEnv *jenv, jclass jcls, jlong jarg1) 
  {
      jlong jresult = 0 ;
      unsigned int arg1 ;
      struct mixer *result = 0 ;
  
      (void)jenv;
      (void)jcls;
      arg1 = (unsigned int)jarg1; 
      result = (struct mixer *)mixer_open(arg1);
      *(struct mixer **)&amp;jresult = result; 
      return jresult;
  }
  </code></pre>
  
  <p>The tinalsa library is loaded OK without exceptions but calls such as <code>mixer_open(0)</code> returns null pointers.<br>
  However If I execute the compiled tinymix mixer is open and mixer controls are listed as should.<br>
  Am I missing something? How can I make it work from my code?</p>