OK, I've ATtest running and it plays the WAV file... in Release Mode ;-)
Now when trying to run ARTest I had to add the RunPermissions:
RP.CheckAndRequest(RP.PERMISSION_RECORD_AUDIO)
Wait for Activity_PermissionResult(permission As String, Result As Boolean)
If Result = True Then
AR.Initialize(AudioSource,SampleRate,ChannelConfig,AudioFormat,BufferSize)
Log("permission ok")
Else
Log("permission false")
Return
End If
But when I run it in Release Mode I get this log output with errors and the app quits:
** Activity (main) Create, isFirst = true **
** Activity (main) Resume **
permission ok
Pos 40
** Activity (main) Pause, UserClosed = false **
Recording...
sending message to waiting queue (rec_ended)
running waiting messages (1)
Ended false
main_rec_ended (java line: 608)
java.lang.IllegalStateException: stop() called on an uninitialized AudioRecord.
at android.media.AudioRecord.stop(AudioRecord.java:1059)
at stevel05.audiorecord.AudioRecording.Stop(AudioRecording.java:224)
at com.stevel05.artest.main._rec_ended(main.java:608)
at java.lang.reflect.Method.invoke(Native Method)
at anywheresoftware.b4a.BA.raiseEvent2(BA.java:191)
at anywheresoftware.b4a.BA$2.run(BA.java:365)
at anywheresoftware.b4a.BA.setActivityPaused(BA.java:437)
at com.stevel05.artest.main$ResumeMessage.run(main.java:306)
at android.os.Handler.handleCallback(Handler.java:790)
at android.os.Handler.dispatchMessage(Handler.java:99)
at android.os.Looper.loop(Looper.java:164)
at android.app.ActivityThread.main(ActivityThread.java:6753)
at java.lang.reflect.Method.invoke(Native Method)
at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:482)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:807)
java.lang.IllegalStateException: stop() called on an uninitialized AudioRecord.
** Activity (main) Pause, UserClosed = false **
** Activity (main) Resume **
So the programs gets passed 'recording...'
But where does the log message 'sending message to waiting queue (rec_ended) come from ?
and the lines after ?
why does it crash ?
I see that in the Sub Rec_Ended it logs Ended en then False and does not play the test.wav
But why is endedOK false ?
Sub Rec_Ended(endedOK As Boolean,Error As String)
Log("Ended " & endedOK)
'Stop recording and release resources
AR.Stop
AR.release
If endedOK Then
'Finish writing the WAVE Header
UpdateHeader
Log("Thread Rec EndedOK "&endedOK&" "&Error)
'Load the recorded file into Media player as a test
MP.Load(File.DirDefaultExternal,"test.wav")
MP.Play
End If
End Sub
When I log the error in Rec_ended: log("Ended " & endedOK & Error) it says:
Ended falseException : Attempt to read from field 'anywheresoftware.b4a.randomaccessfile.RandomAccessFile com.stevel05.artest.main._outfile' on a null object reference
thank you for your help, I realize that I am a newby fooling around trying to understand how b4a works...