Trying to use code from here
Im trying to incorporate both classes so that I end up with an inputStream of ulaw audio data. So I have editted UlawEncoderInputStream like so:
private MicrophoneInputStream micIn;
public UlawEncoderInputStream() {
mMax = 0;
try {
micIn = new MicrophoneInputStream(8000, 1);
} catch (IOException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
}
Then attempt to use that UlawEncoderInputStream:
while(transmittingAudio) {
if(micInStream.available()>0) {
// byte[] data = new byte[audioDump.available()];
int bytesRead = micInStream.read(data);
os.write(data,0,bytesRead);
os.flush();
// ca.transmitAxisAudioPacket(data);
// System.out.println("read "+bytesRead);
}
However there seems to be a problem with the JNI native statement at the bottom of MicrophoneInputStream.
private static native int AudioRecordNew(int sampleRate, int fifoDepth);
Errors with this:
05-14 14:46:48.544: W/dalvikvm(28658): No implementation found for
native Lcom/avispl/nicu/audio/MicrophoneInputStream;.AudioRecordNew
(II)I05-14 14:46:48.552: W/dalvikvm(28658): threadid=10: thread exiting
with uncaught exception (group=0x40018560)05-14 14:46:48.552: E/AndroidRuntime(28658): FATAL EXCEPTION:
Thread-1205-14 14:46:48.552: E/AndroidRuntime(28658):
java.lang.UnsatisfiedLinkError: AudioRecordNew05-14 14:46:48.552: E/AndroidRuntime(28658): at
com.avispl.nicu.audio.MicrophoneInputStream.AudioRecordNew(Native
Method)05-14 14:46:48.552: E/AndroidRuntime(28658): at
com.avispl.nicu.audio.MicrophoneInputStream.(MicrophoneInputStream.java:27)05-14 14:46:48.552: E/AndroidRuntime(28658): at
com.avispl.nicu.audio.UlawEncoderInputStream.(UlawEncoderInputStream.java:111)05-14 14:46:48.552: E/AndroidRuntime(28658): at
com.avispl.nicu.audio.AudioTransmitter.run(AudioTransmitter.java:66)
Excuse me if this is far below the level of the question your asking, I’m tired and I’m finding your question hard to understand:
If you are trying to call the native method
AudioRecordNewYou will need to do a
static { System.loadLibrary("cLibraryName"); }to load the native library you construct usingandroid-ndk\Android.mk\Application.mkand your
c++file (andhfile) will need a method like so:Unless you have a native library which does all of the above, you’ll get an error telling you the native library doesn’t exist. (Which looks like the problem you have here, you don’t have the java native library used in the example).
If you can get the source code for the native library however you can follow the above to build an android version of the library and keep going.