[alsa-devel] Voip Application with ALSA OSS Emulation ==> voice delay

Akio akioolin at gmail.com
Mon Aug 20 09:22:43 CEST 2007

Clemens Ladisch <cladisch <at> fastmail.net> writes:

> Akio wrote:
> > Right now, we are using a arm box with linux kernel 2.6.14 to
> > develop a voip  solution. After the rtp connection was 
> > connected at first 20 secs, there is no delay. As the timing passing
> > by, the delay will going longer and longer.  After 16 hours, the 
> > delay will up to 12 secs.
> If the sending and the receiving computers don't use the same clock,
> there will be a small difference in the sample rate.  You have to
> measure this and adjust the data accordingly (by re-sampling or just
> adding/dropping some samples).

    Thank you very much. I think the CPU power is so tight, there is no room to
do that

> > Because the alsa lib application can't detect any alsa device,
> I'd guess that either the device nodes in /dev/snd/ or the configuration
> files in /use/share/alsa/ are missing.

   Could you can show me how to build the right structure to make alsa lib to work?
   May be this is the right way to void voice delay.

> Clemens

   BTW, after many tests. I find the following combination that seems make the
delay disappear
   in read direction, but in write direction, there will be some extra space
been added. Right now,
   I find two points to suppress voice delay via the following method.

   1. in sound/core/oss/pcm_oss.c, in snd_pcm_oss_read3(), mark the break branch
       after snd_pcm_oss_capture_position_fixup().
       the original code is like :
       ret =  snd_pcm_oss_capture_position_fixup();
       if (ret < 0)

       to the following one:
       ret =  snd_pcm_oss_capture_position_fixup();
       //if (ret < 0)
       //    break;

    2.in snd_pcm_oss_capture_position_fixup(), change the delay calculation
method. from the original
       if (*delay <= (snd_pcm_sframes_t)runtime->buffer_size)  break;
       frames = (*delay - runtime->buffer_size) + runtime->period_size - 1;
       frames /= runtime->period_size;
       frames *= runtime->period_size;

       to the following one:
       if (*delay <= (snd_pcm_sframes_t)runtime->period_size)  break;
       frames = (((*delay + runtime->period_size - 1) / runtime->period_size)) *

       Does the modification will cause other side effect or not?
       How to solve the extra space in write space? 

       Thanks in advance.

Best Regards,

More information about the Alsa-devel mailing list