Index: pjproject/trunk/pjmedia/include/pjmedia/config.h
===================================================================
--- pjproject/trunk/pjmedia/include/pjmedia/config.h	(revision 1714)
+++ pjproject/trunk/pjmedia/include/pjmedia/config.h	(revision 1715)
@@ -98,18 +98,10 @@
  * for the sound device, and will try to limit the delay caused
  * 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
 #   define PJMEDIA_SOUND_USE_DELAYBUF	    0
-#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
 
@@ -125,7 +117,4 @@
  * 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
  */
Index: pjproject/trunk/pjmedia/src/pjmedia/conference.c
===================================================================
--- pjproject/trunk/pjmedia/src/pjmedia/conference.c	(revision 1714)
+++ pjproject/trunk/pjmedia/src/pjmedia/conference.c	(revision 1715)
@@ -56,5 +56,11 @@
 
 #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
Index: pjproject/trunk/pjmedia/src/pjmedia/delaybuf.c
===================================================================
--- pjproject/trunk/pjmedia/src/pjmedia/delaybuf.c	(revision 1714)
+++ pjproject/trunk/pjmedia/src/pjmedia/delaybuf.c	(revision 1715)
@@ -41,6 +41,23 @@
 /* Since there are two operations performed (get & put), */
 /* these macros value must be minimum 2 and should be even number */
-#define WAITING_COUNT	8
-#define LEARN_COUNT	8
+#define WAITING_COUNT	4
+#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
@@ -134,6 +151,6 @@
 	    b->state_count++;
 	    if (b->state_count == LEARN_COUNT) {
-		/* give ONE frame compensation */
-		b->max_level += 1;
+		/* give SAFE_MARGIN compensation for added stability */
+		b->max_level += SAFE_MARGIN;
 		
 		PJ_LOG(5,(b->obj_name,"Delay buffer start running, level=%u",
Index: pjproject/trunk/pjmedia/src/pjmedia/echo_speex.c
===================================================================
--- pjproject/trunk/pjmedia/src/pjmedia/echo_speex.c	(revision 1714)
+++ pjproject/trunk/pjmedia/src/pjmedia/echo_speex.c	(revision 1715)
@@ -32,5 +32,5 @@
 
 #define THIS_FILE	"echo_speex.c"
-#define BUF_COUNT	16
+#define BUF_COUNT	PJMEDIA_SOUND_BUFFER_COUNT
 #define MIN_PREFETCH	2
 #define MAX_PREFETCH	(BUF_COUNT*2/3)
Index: pjproject/trunk/pjmedia/src/pjmedia/sound_port.c
===================================================================
--- pjproject/trunk/pjmedia/src/pjmedia/sound_port.c	(revision 1714)
+++ pjproject/trunk/pjmedia/src/pjmedia/sound_port.c	(revision 1715)
@@ -364,5 +364,6 @@
 #if PJMEDIA_SOUND_USE_DELAYBUF
     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);
 #else
Index: pjproject/trunk/pjmedia/src/pjmedia/splitcomb.c
===================================================================
--- pjproject/trunk/pjmedia/src/pjmedia/splitcomb.c	(revision 1714)
+++ pjproject/trunk/pjmedia/src/pjmedia/splitcomb.c	(revision 1715)
@@ -28,5 +28,11 @@
 #define THIS_FILE	    "splitcomb.c"
 #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
