Android Question AudioStreamer release

Philip Prins

Active Member
Licensed User
Hello

I have one specific device that gives the following error :java.lang.IllegalStateException: stop() called on uninitialized AudioTrack.

I found this code on the forum to release the AudioRecord:
B4X:
Dim r As Reflector
    r.Target = audioStreamTx
    r.Target = r.GetField("audioRecord")
    r.RunMethod("release")
How to release AudioTrack,?
I tried r.getField audioTrack but get this error :java.lang.NoSuchFieldException: No field audioTrack in class Lanywheresoftware/b4a/audio/AudioStreamer; (declaration of 'anywheresoftware.b4a.audio.AudioStreamer' appears in /data/app/comm.check.wf-2/base.apk)
 

stevel05

Expert
Licensed User
Try r.GetField("track"), but if it is uninitialized you probably won't be able to call it as it has acquired no resources and you are likely to get the same error.
 

Philip Prins

Active Member
Licensed User
Try r.GetField("track"), but if it is uninitialized you probably won't be able to call it as it has acquired no resources and you are likely to get the same error.
Hello Steve ,

Thanks but it doesn't work.
Same error .
Unable to initialise, it is on one specific device , on other devices no problems
 

stevel05

Expert
Licensed User
You need to check that the device supports audio with the settings you are initalizing the Streamer object with.
 

Philip Prins

Active Member
Licensed User
You need to check that the device supports audio with the settings you are initalizing the Streamer object with.
Yes it works in the beginning , from a service.
After a while when the screen is off the error occurs.
Partial Wake is on.
 

stevel05

Expert
Licensed User
I am a bit out of touch with the Android lifecycle in relation to services, haven't done anything like that for a while, but it sounds like the objects are being released by the system. If you can post your code (export as zip if possible) I'm sure you will get a concrete answer.
 
Top