Hi All,
I'm writing an Activity that attempts to use the AudioRecord API. When I
invoke the setNotificationMarkerPosition, my activity crashes with the
following error message:
*java.lang.IllegalStateException: Unable to retrieve AudioRecord pointer for
setPositionUpdatePeriod()*
E/AndroidRuntime( 4543): at
android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2401)
E/AndroidRuntime( 4543): at
android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2417)
E/AndroidRuntime( 4543): at
android.app.ActivityThread.access$2100(ActivityThread.java:116)
E/AndroidRuntime( 4543): at
android.app.ActivityThread$H.handleMessage(ActivityThread.java:1794)
E/AndroidRuntime( 4543): at
android.os.Handler.dispatchMessage(Handler.java:99)
E/AndroidRuntime( 4543): at android.os.Looper.loop(Looper.java:123)
E/AndroidRuntime( 4543): at
android.app.ActivityThread.main(ActivityThread.java:4203)
E/AndroidRuntime( 4543): at
java.lang.reflect.Method.invokeNative(Native Method)
E/AndroidRuntime( 4543): at
java.lang.reflect.Method.invoke(Method.java:521)
E/AndroidRuntime( 4543): at
com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:791)
E/AndroidRuntime( 4543): at
com.android.internal.os.ZygoteInit.main(ZygoteInit.java:549)
E/AndroidRuntime( 4543): at dalvik.system.NativeStart.main(Native
Method)
E/AndroidRuntime( 4543): *Caused by: java.lang.IllegalStateException: Unable
to retrieve AudioRecord pointer for setPositionUpdatePeriod()*
E/AndroidRuntime( 4543): at
android.media.AudioRecord.native_set_pos_update_period(Native Method)
E/AndroidRuntime( 4543): at
android.media.AudioRecord.setPositionNotificationPeriod(AudioRecord.java:650)
E/AndroidRuntime( 4543): at
com.intentionis.ambulabilis.android.ambu.full.AmBuMain.onStart(AmBuMain.java:2069)
E/AndroidRuntime( 4543): at
android.app.Instrumentation.callActivityOnStart(Instrumentation.java:1205)
E/AndroidRuntime( 4543): at
android.app.Activity.performStart(Activity.java:3519)
E/AndroidRuntime( 4543): at
android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2373)
The code snippet that triggers this bug is as follows:
AudioRecord audiorec = new AudioRecord(
MediaRecorder.AudioSource.MIC,
11025,
AudioFormat.CHANNEL_CONFIGURATION_MONO,
AudioFormat.ENCODING_PCM_16BIT,
11025*20);
//No exception is thrown and
audiorec seems to be valid
//THIS CALL CAUSES THE CRASH (THIS HAPPENS EVEN WHEN I PLACE THE LINE BELOW
THE NEXT SENTENCE
audiorec.setPositionNotificationPeriod(4000);
audiorec.setRecordPositionUpdateListener(new
AudioRecord.OnRecordPositionUpdateListener()
{
public void onMarkerReached(AudioRecord rec) {
;
}
public void onPeriodicNotification(AudioRecord rec) {
;
}
});
Thanks for anyone's help (my thirst for noetic stimulation has some limits
and I am giving up :) ).
PS: the above code also fails when I try different sampling rate, channel
configuration.
--
You received this message because you are subscribed to the Google
Groups "Android Developers" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to
[email protected]
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en