Long delays while deinitialising audio

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

 



Hello,

I have found that destroying a sound port using
pjmedia_snd_port_destroy takes quite a long time: up to 2 seconds. I'm
using the portaudio interface and ALSA. Can this time be reduced?

The delay is caused in the file pa_dev.c in the function strm_destroy
(Line 1207ff):

>    stream->quit_flag = 1;
>    for (i=0; !stream->rec_thread_exited && i<100; ++i)
>	pj_thread_sleep(10);
>    for (i=0; !stream->play_thread_exited && i<100; ++i)
>	pj_thread_sleep(10);

The quit_flag is evaluated in the callback function PaPlayerCallback
und PaRecorderCallback. They will set the flags *_thread_exited.

In my case, the audio is stopped when calling strm_destroy, which may
be the cause that the callback functions are never called, causing
the whole delay in the above loops.

My questions are: what are the risks by reducing the time in the above
loops? Is there any better (faster) way to destroy the stream?

Some background to the problem: I have to restart the stream because
the codec is changed during streaimg and with it all parameters like
frame sizes, sample rates etc. I don't see any way to restart a stream
with changed parameters without destroying it and creating new. Maybe
there is, I would welcome any hint.

Best regards,

Thomas Falk



[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