Sound shutters - buffer mismatch in android jni dev - armv7 cortex m5

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Hi there,

I'am using PJSIP on an arm-cortex M5 architecture. (C1 from Hardkernel)
But I've some trouble with the sound.

System: 	Android 4.4.2 on ARMv7 Cortex-M5 
PJSIP:		Version 2.3
 
I'd like to use the android_jni_dev and the libpjsua.so .
When I start an outgoing call I get frequently errors via logcat out from the android_jni_dev.c .

    "D/PJSUA Native( 1559): 17:55:02.479 android_jni_de  Record thread : error 640 reading data"

According to this error I expanded the corresponding log message.
	
=======================================================
	...
        bytesRead = (*jni_env)->CallIntMethod(jni_env, stream->record,
					 read_method, inputBuffer,
					  0, size);

        if (bytesRead <= 0 || bytesRead != size) {
            	PJ_LOG (4, (THIS_FILE, "Record thread : error %d reading 
			data Bytes read: (%d), size(rec_buf_size): (%d)",
			bytesRead, bytesRead, (int) size));
            	continue;
        }
	...
=======================================================
Code: android_jni_dev::AndroidRecorderCallback(...)

So I could see a buffer mismatch:

	D/PJSUA Native( 1559): 17:55:02.525 android_jni_de  Record thread : error 640 reading data Bytes read: (640), size(rec_buf_size): (1764)

A fast but bad fix for this would be to set the 'inputBuffSizeRec' to 1764
within the following piece of code:
==============================================
...
	stream->record =  (*jni_env)->NewObject(jni_env,
					stream->record_class,
					constructor_method,
					mic_source, 
					param->clock_rate,
					channelInCfg,
					sampleFormat,
					inputBuffSizeRec);   // ==> 1764
...
==============================================
Code: android_jni_dev::android_create_stream(...)

The right size should be calculated by:
===============================================================================
...
	inputBuffSizeRec = (*jni_env)->CallStaticIntMethod(jni_env,
				   	stream->record_class,
				   	bufsize_method,
				   	param->clock_rate,
				   	channelInCfg,
				   	sampleFormat);

...
===============================================================================
Code: android_jni_dev::android_create_stream(...)

The 'size' var is also calculated near this code by the following:
==================================================================
...
	buffSize = stream->param.samples_per_frame*stream->param.bits_per_sample/8;
		stream->rec_buf_size = stream->play_buf_size = buffSize;
...
==================================================================
Code: android_jni_dev::android_create_stream(...)
	
	
After setting the 'inputBuffSizeRec' to the fix value 1764
the error message doesn't appear anymore.

But now the sound shutters' from time to time.
AudioFlinger has some overflows and PJSUA has some underflows.
Furthermore messages with 'buffer adjustments' will be printed out.

I measured the output signal with an oscilloscope and printed the
pcm stream within the 'conference.c' to a file.

Both show me the same:
	 
During the shutter phase the same signal will be repeated. So I think if this happens,
pjsua will send the same frame again and again.


I'am wondering why the buffer size will not be calculated correctly?
Now I need some help to figure out what's going wrong.

Regards,


Ralf Zeuka

Callom GmbH
Neue Stra?e 97-99
89073 Ulm

Tel.: +49 731 140015 0
Fax: +49 731 140015 15

eMail:? ralf.zeuka at callom.com
www.callom.com 
Gesch?ftsf?hrer:
Marcus Brachert, Timo Weith?ner - Registergericht Ulm HRB 72968



[Index of Archives]     [Asterisk Users]     [Asterisk App Development]     [Linux ARM Kernel]     [Linux ARM]     [Linux Omap]     [Fedora ARM]     [IETF Annouce]     [Security]     [Bugtraq]     [Linux]     [Linux OMAP]     [Linux MIPS]     [Linux API]
  Powered by Linux