Index: pjproject/trunk/pjsip-apps/src/pjsua/pjsua_app_config.c
===================================================================
--- pjproject/trunk/pjsip-apps/src/pjsua/pjsua_app_config.c	(revision 5064)
+++ pjproject/trunk/pjsip-apps/src/pjsua/pjsua_app_config.c	(revision 5065)
@@ -212,4 +212,10 @@
     puts  ("");
 
+    fflush(stdout);
+}
+
+static void log_writer_nobuf(int level, const char *buffer, int len)
+{
+    pj_log_write(level, buffer, len);
     fflush(stdout);
 }
@@ -1252,4 +1258,5 @@
 	case OPT_STDOUT_NO_BUF:
 	    setvbuf(stdout, NULL, _IONBF, 0);
+	    cfg->log_cfg.cb = &log_writer_nobuf;
 	    break;
 #endif
Index: pjproject/trunk/pjsip-apps/src/pjsua/pjsua_app_legacy.c
===================================================================
--- pjproject/trunk/pjsip-apps/src/pjsua/pjsua_app_legacy.c	(revision 5064)
+++ pjproject/trunk/pjsip-apps/src/pjsua/pjsua_app_legacy.c	(revision 5065)
@@ -24,4 +24,18 @@
 #define THIS_FILE	"pjsua_app_legacy.c"
 
+
+/* An attempt to avoid stdout buffering for python tests:
+ * - call 'fflush(stdout)' after each call to 'printf()/puts()'
+ * - apply 'setbuf(stdout, 0)', but it is not guaranteed by the standard:
+ *   http://stackoverflow.com/questions/1716296
+ */
+#if (defined(__STDC_VERSION__) && __STDC_VERSION__ >= 199901L) || \
+    (defined (_MSC_VER) && _MSC_VER >= 1400)
+/* Variadic macro is introduced in C99; MSVC supports it in since 2005. */
+#  define printf(...) {printf(__VA_ARGS__);fflush(stdout);}
+#  define puts(s) {puts(s);fflush(stdout);}
+#endif
+
+
 static pj_bool_t	cmd_echo;
 
@@ -39,7 +53,7 @@
     pjsua_enum_buddies(ids, &count);
 
-    if (count == 0)
+    if (count == 0) {
 	puts(" -none-");
-    else {
+    } else {
 	for (i=0; i<(int)count; ++i) {
 	    pjsua_buddy_info info;
@@ -1089,7 +1103,7 @@
 	}
 	if (result.nb_result != PJSUA_APP_NO_NB) {
-	    if (result.nb_result == -1 || result.nb_result == 0)
+	    if (result.nb_result == -1 || result.nb_result == 0) {
 		puts("You can't do that with transfer call!");
-	    else {
+	    } else {
 		pjsua_buddy_info binfo;
 		pjsua_buddy_get_info(result.nb_result-1, &binfo);
@@ -1670,4 +1684,5 @@
 }
 
+
 /*
  * Main "user interface" loop.
Index: pjproject/trunk/tests/pjsua/mod_call.py
===================================================================
--- pjproject/trunk/tests/pjsua/mod_call.py	(revision 5064)
+++ pjproject/trunk/tests/pjsua/mod_call.py	(revision 5065)
@@ -54,5 +54,5 @@
 
 	# Wait until call is connected in both endpoints
-	time.sleep(0.2)
+	##time.sleep(0.2)
 	caller.expect(const.STATE_CONFIRMED)
 	callee.expect(const.STATE_CONFIRMED)
@@ -61,10 +61,10 @@
 	caller.sync_stdout()
 	callee.sync_stdout()
-	time.sleep(0.1)
-	caller.sync_stdout()
-	callee.sync_stdout()
-
-	# Test that media is okay
-	time.sleep(0.3)
+	##time.sleep(0.1)
+	caller.sync_stdout()
+	callee.sync_stdout()
+
+	# Test that media is okay
+	##time.sleep(0.3)
 	check_media(caller, callee)
 	check_media(callee, caller)
@@ -74,4 +74,35 @@
 	caller.expect("INVITE sip:")
 	callee.expect("INVITE sip:")
+	callee.expect(const.MEDIA_HOLD)
+	caller.expect(const.MEDIA_HOLD)
+	
+	# Synchronize stdout
+	caller.sync_stdout()
+	callee.sync_stdout()
+
+	# Release hold
+	##time.sleep(0.5)
+	caller.send("v")
+	caller.expect("INVITE sip:")
+	callee.expect("INVITE sip:")
+	callee.expect(const.MEDIA_ACTIVE, title="waiting for media active after call hold")
+	caller.expect(const.MEDIA_ACTIVE, title="waiting for media active after call hold")
+
+	# Synchronize stdout
+	caller.sync_stdout()
+	callee.sync_stdout()
+
+	# Test that media is okay
+	check_media(caller, callee)
+	check_media(callee, caller)
+
+	# Synchronize stdout
+	caller.sync_stdout()
+	callee.sync_stdout()
+
+	# Hold call by callee
+	callee.send("H")
+	callee.expect("INVITE sip:")
+	caller.expect("INVITE sip:")
 	caller.expect(const.MEDIA_HOLD)
 	callee.expect(const.MEDIA_HOLD)
@@ -82,8 +113,8 @@
 
 	# Release hold
-	time.sleep(0.5)
-	caller.send("v")
-	caller.expect("INVITE sip:")
-	callee.expect("INVITE sip:")
+	##time.sleep(0.1)
+	callee.send("v")
+	callee.expect("INVITE sip:")
+	caller.expect("INVITE sip:")
 	caller.expect(const.MEDIA_ACTIVE, title="waiting for media active after call hold")
 	callee.expect(const.MEDIA_ACTIVE, title="waiting for media active after call hold")
@@ -94,37 +125,6 @@
 
 	# Test that media is okay
-	check_media(caller, callee)
-	check_media(callee, caller)
-
-	# Synchronize stdout
-	caller.sync_stdout()
-	callee.sync_stdout()
-
-	# Hold call by callee
-	callee.send("H")
-	callee.expect("INVITE sip:")
-	caller.expect("INVITE sip:")
-	caller.expect(const.MEDIA_HOLD)
-	callee.expect(const.MEDIA_HOLD)
-	
-	# Synchronize stdout
-	caller.sync_stdout()
-	callee.sync_stdout()
-
-	# Release hold
-	time.sleep(0.1)
-	callee.send("v")
-	callee.expect("INVITE sip:")
-	caller.expect("INVITE sip:")
-	callee.expect(const.MEDIA_ACTIVE, title="waiting for media active after call hold")
-	caller.expect(const.MEDIA_ACTIVE, title="waiting for media active after call hold")
-
-	# Synchronize stdout
-	caller.sync_stdout()
-	callee.sync_stdout()
-
-	# Test that media is okay
 	# Wait for some time for ICE negotiation
-	time.sleep(0.6)
+	##time.sleep(0.6)
 	check_media(caller, callee)
 	check_media(callee, caller)
@@ -145,5 +145,5 @@
 
 	# Test that media is okay
-	time.sleep(0.1)
+	##time.sleep(0.1)
 	check_media(caller, callee)
 	check_media(callee, caller)
@@ -161,5 +161,5 @@
 
 	# Test that media is okay
-	time.sleep(0.1)
+	##time.sleep(0.1)
 	check_media(caller, callee)
 	check_media(callee, caller)
@@ -194,5 +194,5 @@
 	
 	# Test that media is still okay
-	time.sleep(0.1)
+	##time.sleep(0.1)
 	check_media(caller, callee)
 	check_media(callee, caller)
@@ -208,10 +208,10 @@
 	
 	# Test that media is still okay
-	time.sleep(0.1)
+	##time.sleep(0.1)
 	check_media(callee, caller)
 	check_media(caller, callee)
 
 	# Hangup call
-	time.sleep(0.1)
+	##time.sleep(0.1)
 	caller.send("h")
 
Index: pjproject/trunk/tests/pjsua/scripts-call/300_ice_1_1.py
===================================================================
--- pjproject/trunk/tests/pjsua/scripts-call/300_ice_1_1.py	(revision 5064)
+++ pjproject/trunk/tests/pjsua/scripts-call/300_ice_1_1.py	(revision 5065)
@@ -7,6 +7,6 @@
 		"Callee=use ICE, caller=use ICE",
 		[
-			InstanceParam("callee", "--null-audio --use-ice --max-calls=1", enable_buffer=True),
-			InstanceParam("caller", "--null-audio --use-ice --max-calls=1", enable_buffer=True)
+			InstanceParam("callee", "--null-audio --use-ice --max-calls=1"),
+			InstanceParam("caller", "--null-audio --use-ice --max-calls=1")
 		]
 		)
Index: pjproject/trunk/tests/pjsua/scripts-call/305_ice_comp_1_2.py
===================================================================
--- pjproject/trunk/tests/pjsua/scripts-call/305_ice_comp_1_2.py	(revision 5064)
+++ pjproject/trunk/tests/pjsua/scripts-call/305_ice_comp_1_2.py	(revision 5065)
@@ -7,6 +7,6 @@
 		"Callee=use ICE, caller=use ICE",
 		[
-			InstanceParam("callee", "--null-audio --use-ice --max-calls=1 --ice-no-rtcp", enable_buffer=True),
-			InstanceParam("caller", "--null-audio --use-ice --max-calls=1", enable_buffer=True)
+			InstanceParam("callee", "--null-audio --use-ice --max-calls=1 --ice-no-rtcp"),
+			InstanceParam("caller", "--null-audio --use-ice --max-calls=1")
 		]
 		)
Index: pjproject/trunk/tests/pjsua/scripts-call/305_ice_comp_2_1.py
===================================================================
--- pjproject/trunk/tests/pjsua/scripts-call/305_ice_comp_2_1.py	(revision 5064)
+++ pjproject/trunk/tests/pjsua/scripts-call/305_ice_comp_2_1.py	(revision 5065)
@@ -7,6 +7,6 @@
 		"Callee=use ICE, caller=use ICE",
 		[
-			InstanceParam("callee", "--null-audio --use-ice --max-calls=1", enable_buffer=True),
-			InstanceParam("caller", "--null-audio --use-ice --max-calls=1 --ice-no-rtcp", enable_buffer=True)
+			InstanceParam("callee", "--null-audio --use-ice --max-calls=1"),
+			InstanceParam("caller", "--null-audio --use-ice --max-calls=1 --ice-no-rtcp")
 		]
 		)
Index: pjproject/trunk/tests/pjsua/scripts-sendto/200_ice_success_2.py
===================================================================
--- pjproject/trunk/tests/pjsua/scripts-sendto/200_ice_success_2.py	(revision 5064)
+++ pjproject/trunk/tests/pjsua/scripts-sendto/200_ice_success_2.py	(revision 5065)
@@ -32,5 +32,4 @@
 sendto_cfg = sip.SendtoCfg( "caller sends only one component", 
 			    pjsua_args=args, sdp=sdp, resp_code=200, 
-			    resp_inc=include, resp_exc=exclude,
-			    enable_buffer = True)
+			    resp_inc=include, resp_exc=exclude)
 
Index: pjproject/trunk/tests/pjsua/scripts-sendto/200_ice_success_3.py
===================================================================
--- pjproject/trunk/tests/pjsua/scripts-sendto/200_ice_success_3.py	(revision 5064)
+++ pjproject/trunk/tests/pjsua/scripts-sendto/200_ice_success_3.py	(revision 5065)
@@ -31,5 +31,4 @@
 sendto_cfg = sip.SendtoCfg( "caller sends two components without a=rtcp line", 
 			    pjsua_args=args, sdp=sdp, resp_code=200, 
-			    resp_inc=include, resp_exc=exclude,
-			    enable_buffer = True)
+			    resp_inc=include, resp_exc=exclude)
 
Index: pjproject/trunk/tests/pjsua/scripts-sendto/200_ice_success_4.py
===================================================================
--- pjproject/trunk/tests/pjsua/scripts-sendto/200_ice_success_4.py	(revision 5064)
+++ pjproject/trunk/tests/pjsua/scripts-sendto/200_ice_success_4.py	(revision 5065)
@@ -31,5 +31,4 @@
 sendto_cfg = sip.SendtoCfg( "pjsua with --ice-no-rtcp ignores RTCP things in the SDP", 
 			    pjsua_args=args, sdp=sdp, resp_code=200, 
-			    resp_inc=include, resp_exc=exclude,
-			    enable_buffer = True)
+			    resp_inc=include, resp_exc=exclude)
 
