[pjsip] Segmentation fault in resample_port.c
zittix_all at xwaves.net
Tue May 13 13:47:15 EDT 2008
Thank you for your answer.
Well I'm working with mono-audio. I'm using the stock PJSUA app with my
audio driver. So I think it's mono audio.
I have just tried with the latest SVN version and it gives me exactly
the same error. I actually found the bug. I'm only allowing to open the
device at 8000 Hz. But PJSUA want a clock rate of 16000 Hz (don't know
why, seems to be config related). So there should be up/down sampling of
factor 2. When I'm playing audio, PJSUA need to downsample the audio to
8000 Hz. The frame size (mono or stereo it doesn't matter) should half
the frame size of the original audio data. The bug is here.
In resample_port.c of the latest SVN version, in function
resample_get_frame(), there is the following line:
tmp_frame.size = rport->dn_port->info.bytes_per_frame;
As I understand it tells that the size of the frame is equal to the
master conf port frame size. Actually the master conf port sampling rate
is 16000 which twice the frame size of my audio driver. After that, the
status = pjmedia_port_get_frame( rport->dn_port, &tmp_frame);
gets the frame with the wrong size (it doesn't seg fault here).
and then the down sampling process is done and the segfault appear. So I
think (I'm sure I'm missing something but what ?) there is confusion in
frame size in the down sampling stuffs.
If I allocate a buffer of twice the frame size in my audio driver it fix
the seg fault but then the audio is corrupt..
Any clues appreciated :-)!
Benny Prijono a écrit :
> On Tue, May 13, 2008 at 12:57 PM, Mathieu Monney <zittix_all at xwaves.net> wrote:
>> I'm trying to develop a gstreamer audio back-end for PJSIP but I get a
>> seg fault in the resampling stuffs When I use the rec/play examples my
>> audio driver works just fine but when I'm using pjsua it seg fault.
> Yep. The rec/play samples don't use resample.
>> I'm using PJSIP release 0.8.0. The seg fault comes from the fact that in
>> the resampling port the frame size in byte is equal to twice the frame
>> size in my audio driver.
>> In the resample_get_frame() function in file resample_port.c at line 177
>> the size is equal to 320 (for my case). In my audio driver I compute the
>> frame size as following:
>> which gives half the value above. But my computation seems correct. Is a
>> bug or am I missing something ?
> Well which one is correct is indeed the question. Are you working with
> non-mono audio?
> In version 0.8 and older, the convention about samples_per_frame value
> was not clear when channel_count is non-mono. That is, say if the
> audio is stereo, does the samples_per_frame value represent the
> combined/2-channels frame length, or does it only represent the size
> of the mono frame. If I recall correctly some objects in pjmedia used
> different convention hence probably what you saw.
> The convention that has been established now (in SVN version) is the
> samples_per_frame represents the total length of the frame, that is
> it's equal to mono_count*channel_count (Nanang can correct me if I'm
> wrong). So because of this you may be better working with the SVN
> version instead.
>> Thank you.
>> Visit our blog: http://blog.pjsip.org
>> pjsip mailing list
>> pjsip at lists.pjsip.org
> Visit our blog: http://blog.pjsip.org
> pjsip mailing list
> pjsip at lists.pjsip.org
More information about the pjsip