Hi,

I need help from an expert of the audio stack.

I'm currently writting an opensource SIP application (http://
code.google.com/p/csipsimple/) based on a native sip stack (pjsip).

I've ported the audio driver for android (naive portage using JNI)
(the key file :
http://code.google.com/p/csipsimple/source/browse/trunk/pjsip_android/apps/pjsip/project/pjmedia/src/pjmedia-audiodev/android_jni_dev.cpp
).

Everything works well on HTC devices. But when run on devices from
other manufacturers things becomes instable (seems to be related to
the CPU load and/or frequency use for the stream).
The result is that on some device (sony X10, samsung galaxy spica,
galaxy S...), sometimes and after about 10 seconds of streaming, audio
track become totally blocked in its write method. No audio is streamed
anymore. And worse, flush and stop method does nothing.
AudioTrackTread is still blocked. And worse... then even if you kill
my app, no other app can use audio  : if you try to play music or
place a gsm call you'll have absolutely no sound.

After a lot of tests, and searches, I have some questions to make sure
I handle properly the stream mode.
I've read that we should always ensure AudioTrack buffer is never
empty. What will happen if audiotrack becomes empty? Can this explain
the fact it freeze audioTrack in my case? Same question when
audioTrack becomes full.

Another thing that should be clarified for me is the impact of the
audioManager settings on audio routing : I noticed that some settings
such as Bluetooth SCO is only taken into account if you stop audio
track and play it again (in my case, it's totally destroyed and re-
created, but I think that play/pause should be enough). Is there rules
about the fact we *should* pause/start stream before changing audio
settings? Other settings seems to work as expected while in streaming
(speaker, mute etc)... but I'm wondering if it's ensured in all
devices and if it is the good way.

Last thing for now, it's not really optimized in term of CPU (and some
codecs need a lot of cpu) can it be the reason of this lock in the
audio track write method?

To help you to enter my code (if you want to have a look - that would
be really nice :) ) :
It's an audio driver integrated in pjsip.
There is a method to create the stream :
    here I create an AudioTrack & a AudioRecord - taking as buffer
size the value given by minBufferSize
A method to start the stream :
    that callback a method from my app to set up audio modes
    that create a thread that play the track, goes in a while loop,
get a frame from sip stack and write it into the audio track
    that create a thread that play the record, get a record frame in a
while loop and transmit it to the sip stack
A method to stop the stream :
   that put flags to stop thread, join threads and stop track/record
A method to destroy stream :
   that release the track/record objects.


Thanks in advance for any help that you can provide :) (and sorry for
my poor english .. hope it's still understandable)



-- 
You received this message because you are subscribed to the Google
Groups "Android Developers" group.
To post to this group, send email to android-developers@googlegroups.com
To unsubscribe from this group, send email to
android-developers+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en

Reply via email to