More work on ticket #438: Workaround for frame bursts from audio devices. See the ticket for more information
git-svn-id: https://svn.pjsip.org/repos/pjproject/trunk@1715 74dad513-b988-da41-8d7b-12977e46ad98
This commit is contained in:
parent
0cc83f0633
commit
684ab41b57
|
@ -97,23 +97,15 @@
|
||||||
* The delay buffer also performs the best delay calculation
|
* The delay buffer also performs the best delay calculation
|
||||||
* for the sound device, and will try to limit the delay caused
|
* for the sound device, and will try to limit the delay caused
|
||||||
* by uneven callback calls to this delay.
|
* by uneven callback calls to this delay.
|
||||||
|
*
|
||||||
|
* When this setting is enabled, the PJMEDIA_SOUND_BUFFER_COUNT
|
||||||
|
* macro will specify the maximum size of the delay buffer.
|
||||||
*/
|
*/
|
||||||
#ifndef PJMEDIA_SOUND_USE_DELAYBUF
|
#ifndef PJMEDIA_SOUND_USE_DELAYBUF
|
||||||
# define PJMEDIA_SOUND_USE_DELAYBUF 0
|
# define PJMEDIA_SOUND_USE_DELAYBUF 0
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Whenever delay buffer is enabled for sound device,
|
|
||||||
* PJMEDIA_SOUND_BUFFER_COUNT is better to be set to 1,
|
|
||||||
* because sound callbacks will be called evenly thus
|
|
||||||
* there's no need to have this buffer.
|
|
||||||
*/
|
|
||||||
#if defined(PJMEDIA_SOUND_USE_DELAYBUF) && PJMEDIA_SOUND_USE_DELAYBUF!=0
|
|
||||||
# define PJMEDIA_SOUND_BUFFER_COUNT 1
|
|
||||||
#endif
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Specify number of sound buffers. Larger number is better for sound
|
* Specify number of sound buffers. Larger number is better for sound
|
||||||
* stability and to accommodate sound devices that are unable to send frames
|
* stability and to accommodate sound devices that are unable to send frames
|
||||||
|
@ -124,9 +116,6 @@
|
||||||
* The setting here currently is used by the conference bridge, the splitter
|
* The setting here currently is used by the conference bridge, the splitter
|
||||||
* combiner port, and dsound.c.
|
* combiner port, and dsound.c.
|
||||||
*
|
*
|
||||||
* Note that when PJMEDIA_SOUND_USE_DELAYBUF is enabled, it's best to
|
|
||||||
* set PJMEDIA_SOUND_BUFFER_COUNT to 1 to reduce voice latency.
|
|
||||||
*
|
|
||||||
* Default: 6
|
* Default: 6
|
||||||
*/
|
*/
|
||||||
#ifndef PJMEDIA_SOUND_BUFFER_COUNT
|
#ifndef PJMEDIA_SOUND_BUFFER_COUNT
|
||||||
|
|
|
@ -55,7 +55,13 @@ static FILE *fhnd_rec;
|
||||||
|
|
||||||
|
|
||||||
#define THIS_FILE "conference.c"
|
#define THIS_FILE "conference.c"
|
||||||
#define RX_BUF_COUNT PJMEDIA_SOUND_BUFFER_COUNT
|
|
||||||
|
/* When delay buffer is used, we only need 1 frame buffering */
|
||||||
|
#if defined(PJMEDIA_SOUND_USE_DELAYBUF) && PJMEDIA_SOUND_USE_DELAYBUF!=0
|
||||||
|
# define RX_BUF_COUNT 1
|
||||||
|
#else
|
||||||
|
# define RX_BUF_COUNT PJMEDIA_SOUND_BUFFER_COUNT
|
||||||
|
#endif
|
||||||
|
|
||||||
#define BYTES_PER_SAMPLE 2
|
#define BYTES_PER_SAMPLE 2
|
||||||
|
|
||||||
|
|
|
@ -40,8 +40,25 @@ enum OP
|
||||||
/* The following macros represent cycles of test. */
|
/* The following macros represent cycles of test. */
|
||||||
/* Since there are two operations performed (get & put), */
|
/* Since there are two operations performed (get & put), */
|
||||||
/* these macros value must be minimum 2 and should be even number */
|
/* these macros value must be minimum 2 and should be even number */
|
||||||
#define WAITING_COUNT 8
|
#define WAITING_COUNT 4
|
||||||
#define LEARN_COUNT 8
|
#define LEARN_COUNT 16
|
||||||
|
|
||||||
|
/* Number of buffers to add to learnt level for additional stability */
|
||||||
|
#define SAFE_MARGIN 2
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Some experimental data (with SAFE_MARGIN=1):
|
||||||
|
*
|
||||||
|
* System 1:
|
||||||
|
* - XP, WMME, 10ms ptime,
|
||||||
|
* - Sennheiser Headset+USB sound card
|
||||||
|
* - Stable delaybuf level: 6, on WAITING_COUNT=4 and LEARNING_COUNT=48
|
||||||
|
*
|
||||||
|
* System 2:
|
||||||
|
* - XP, WMME, 10ms ptime
|
||||||
|
* - Onboard SoundMAX Digital Audio
|
||||||
|
* - Stable delaybuf level: 6, on WAITING_COUNT=4 and LEARNING_COUNT=48
|
||||||
|
*/
|
||||||
|
|
||||||
struct pjmedia_delay_buf
|
struct pjmedia_delay_buf
|
||||||
{
|
{
|
||||||
|
@ -133,8 +150,8 @@ static void update(pjmedia_delay_buf *b, enum OP op)
|
||||||
b->op[other].level = 0;
|
b->op[other].level = 0;
|
||||||
b->state_count++;
|
b->state_count++;
|
||||||
if (b->state_count == LEARN_COUNT) {
|
if (b->state_count == LEARN_COUNT) {
|
||||||
/* give ONE frame compensation */
|
/* give SAFE_MARGIN compensation for added stability */
|
||||||
b->max_level += 1;
|
b->max_level += SAFE_MARGIN;
|
||||||
|
|
||||||
PJ_LOG(5,(b->obj_name,"Delay buffer start running, level=%u",
|
PJ_LOG(5,(b->obj_name,"Delay buffer start running, level=%u",
|
||||||
b->max_level));
|
b->max_level));
|
||||||
|
|
|
@ -31,7 +31,7 @@
|
||||||
#include "echo_internal.h"
|
#include "echo_internal.h"
|
||||||
|
|
||||||
#define THIS_FILE "echo_speex.c"
|
#define THIS_FILE "echo_speex.c"
|
||||||
#define BUF_COUNT 16
|
#define BUF_COUNT PJMEDIA_SOUND_BUFFER_COUNT
|
||||||
#define MIN_PREFETCH 2
|
#define MIN_PREFETCH 2
|
||||||
#define MAX_PREFETCH (BUF_COUNT*2/3)
|
#define MAX_PREFETCH (BUF_COUNT*2/3)
|
||||||
|
|
||||||
|
|
|
@ -363,7 +363,8 @@ PJ_DEF(pj_status_t) pjmedia_snd_port_create( pj_pool_t *pool,
|
||||||
|
|
||||||
#if PJMEDIA_SOUND_USE_DELAYBUF
|
#if PJMEDIA_SOUND_USE_DELAYBUF
|
||||||
status = pjmedia_delay_buf_create(pool, "snd_buff", samples_per_frame,
|
status = pjmedia_delay_buf_create(pool, "snd_buff", samples_per_frame,
|
||||||
16, -1, &snd_port->delay_buf);
|
PJMEDIA_SOUND_BUFFER_COUNT, -1,
|
||||||
|
&snd_port->delay_buf);
|
||||||
PJ_ASSERT_RETURN(status == PJ_SUCCESS, status);
|
PJ_ASSERT_RETURN(status == PJ_SUCCESS, status);
|
||||||
#else
|
#else
|
||||||
PJ_UNUSED_ARG(status);
|
PJ_UNUSED_ARG(status);
|
||||||
|
|
|
@ -27,7 +27,13 @@
|
||||||
#define SIGNATURE_PORT PJMEDIA_PORT_SIGNATURE('S', 'p', 'C', 'P')
|
#define SIGNATURE_PORT PJMEDIA_PORT_SIGNATURE('S', 'p', 'C', 'P')
|
||||||
#define THIS_FILE "splitcomb.c"
|
#define THIS_FILE "splitcomb.c"
|
||||||
#define TMP_SAMP_TYPE pj_int16_t
|
#define TMP_SAMP_TYPE pj_int16_t
|
||||||
#define MAX_BUF_CNT PJMEDIA_SOUND_BUFFER_COUNT
|
|
||||||
|
/* When delay buffer is used, we only need 1 frame buffering */
|
||||||
|
#if defined(PJMEDIA_SOUND_USE_DELAYBUF) && PJMEDIA_SOUND_USE_DELAYBUF!=0
|
||||||
|
# define MAX_BUF_CNT 1
|
||||||
|
#else
|
||||||
|
# define MAX_BUF_CNT PJMEDIA_SOUND_BUFFER_COUNT
|
||||||
|
#endif
|
||||||
|
|
||||||
#if 0
|
#if 0
|
||||||
# define TRACE_UP_(x) PJ_LOG(5,x)
|
# define TRACE_UP_(x) PJ_LOG(5,x)
|
||||||
|
|
Loading…
Reference in New Issue