Index: pjproject/trunk/pjsip-apps/src/pjsystest/gui.h
===================================================================
--- pjproject/trunk/pjsip-apps/src/pjsystest/gui.h	(revision 2835)
+++ pjproject/trunk/pjsip-apps/src/pjsystest/gui.h	(revision 2836)
@@ -1,2 +1,20 @@
+/* $Id$ */
+/* 
+ * Copyright (C) 2008-2009 Teluu Inc. (http://www.teluu.com)
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA 
+ */
 #ifndef __GUI_H__
 #define __GUI_H__
@@ -34,17 +52,17 @@
 
 /* Initialize GUI with the menus and stuff */
-PJ_DECL(pj_status_t) gui_init(gui_menu *menu);
+pj_status_t gui_init(gui_menu *menu);
 
 /* Run GUI main loop */
-PJ_DECL(pj_status_t) gui_start(gui_menu *menu);
+pj_status_t gui_start(gui_menu *menu);
 
 /* Signal GUI mainloop to stop */
-PJ_DECL(void) gui_destroy(void);
+void gui_destroy(void);
 
 /* AUX: display messagebox */
-PJ_DECL(enum gui_key) gui_msgbox(const char *title, const char *message, enum gui_flag flag);
+enum gui_key gui_msgbox(const char *title, const char *message, enum gui_flag flag);
 
 /* AUX: sleep */
-PJ_DECL(void) gui_sleep(unsigned sec);
+void gui_sleep(unsigned sec);
 
 
Index: pjproject/trunk/pjsip-apps/src/pjsystest/main_console.c
===================================================================
--- pjproject/trunk/pjsip-apps/src/pjsystest/main_console.c	(revision 2835)
+++ pjproject/trunk/pjsip-apps/src/pjsystest/main_console.c	(revision 2836)
@@ -1,2 +1,20 @@
+/* $Id$ */
+/* 
+ * Copyright (C) 2008-2009 Teluu Inc. (http://www.teluu.com)
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA 
+ */
 #include "systest.h"
 #include "gui.h"
@@ -6,5 +24,5 @@
 static pj_bool_t console_quit;
 
-PJ_DEF(enum gui_key) gui_msgbox(const char *title, const char *message, enum gui_flag flag)
+enum gui_key gui_msgbox(const char *title, const char *message, enum gui_flag flag)
 {
     puts(title);
@@ -31,5 +49,5 @@
 }
 
-PJ_DEF(pj_status_t) gui_init(gui_menu *menu)
+pj_status_t gui_init(gui_menu *menu)
 {
     PJ_UNUSED_ARG(menu);
@@ -58,5 +76,5 @@
 }
 
-PJ_DEF(pj_status_t) gui_start(gui_menu *menu)
+pj_status_t gui_start(gui_menu *menu)
 {
     while (!console_quit) {
@@ -104,10 +122,10 @@
 }
 
-PJ_DEF(void) gui_destroy(void)
+void gui_destroy(void)
 {
     console_quit = PJ_TRUE;
 }
 
-PJ_DEF(void) gui_sleep(unsigned sec)
+void gui_sleep(unsigned sec)
 {
     pj_thread_sleep(sec * 1000);
Index: pjproject/trunk/pjsip-apps/src/pjsystest/main_wm.c
===================================================================
--- pjproject/trunk/pjsip-apps/src/pjsystest/main_wm.c	(revision 2835)
+++ pjproject/trunk/pjsip-apps/src/pjsystest/main_wm.c	(revision 2836)
@@ -1,2 +1,20 @@
+/* $Id$ */
+/* 
+ * Copyright (C) 2008-2009 Teluu Inc. (http://www.teluu.com)
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA 
+ */
 #include "gui.h"
 #include "systest.h"
@@ -11,5 +29,5 @@
 
 #define MAINWINDOWCLASS TEXT("SysTestDlg")
-#define MAINWINDOWTITLE TEXT("SysTest")
+#define MAINWINDOWTITLE TEXT("PJSYSTEST")
 
 typedef struct menu_handler_t {
@@ -188,5 +206,5 @@
 /* === API === */
 
-PJ_DEF(pj_status_t) gui_init(gui_menu *menu)
+pj_status_t gui_init(gui_menu *menu)
 {
     WNDCLASS wc;
@@ -194,5 +212,4 @@
     RECT r;
     DWORD dwStyle;
-    unsigned log_decor;
 
     pj_status_t status  = PJ_SUCCESS;
@@ -335,5 +352,5 @@
 }
 
-PJ_DEF(enum gui_key) gui_msgbox(const char *title, const char *message, enum gui_flag flag)
+enum gui_key gui_msgbox(const char *title, const char *message, enum gui_flag flag)
 {
     wchar_t buf_title[64];
@@ -371,10 +388,10 @@
 }
 
-PJ_DEF(void) gui_sleep(unsigned sec)
+void gui_sleep(unsigned sec)
 {
     pj_thread_sleep(sec * 1000);
 }
 
-PJ_DEF(pj_status_t) gui_start(gui_menu *menu)
+pj_status_t gui_start(gui_menu *menu)
 {
     MSG msg;
@@ -390,5 +407,5 @@
 }
 
-PJ_DEF(void) gui_destroy(void)
+void gui_destroy(void)
 {
     if (g_hWndMain) {
Index: pjproject/trunk/pjsip-apps/src/pjsystest/systest.c
===================================================================
--- pjproject/trunk/pjsip-apps/src/pjsystest/systest.c	(revision 2835)
+++ pjproject/trunk/pjsip-apps/src/pjsystest/systest.c	(revision 2836)
@@ -1,2 +1,20 @@
+/* $Id$ */
+/* 
+ * Copyright (C) 2008-2009 Teluu Inc. (http://www.teluu.com)
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA 
+ */
 #include "systest.h"
 #include "gui.h"
@@ -678,5 +696,9 @@
 
 	/* Advance next loop */
-	start_pos += wav->info.clock_rate;
+	if (start_pos == 0) {
+	    start_pos = max_signal_pos + wav->info.clock_rate * 9 / 10;
+	} else {
+	    start_pos += wav->info.clock_rate;
+	}
     }
 
@@ -743,6 +765,6 @@
     /* Setup the test */
     //status = pjsua_conf_connect(0, 0);
+    status = pjsua_conf_connect(play_slot, 0);
     status = pjsua_conf_connect(0, rec_slot);
-    status = pjsua_conf_connect(play_slot, 0);
     status = pjsua_conf_connect(play_slot, rec_slot);
     
@@ -754,6 +776,6 @@
     //status = pjsua_conf_disconnect(0, 0);
     status = pjsua_conf_disconnect(play_slot, rec_slot);
+    status = pjsua_conf_disconnect(0, rec_slot);
     status = pjsua_conf_disconnect(play_slot, 0);
-    status = pjsua_conf_disconnect(0, rec_slot);
 
     pjsua_recorder_destroy(rec_id);
@@ -774,5 +796,7 @@
 	goto on_return;
 
-    status = pjsua_conf_connect(pjsua_player_get_conf_port(play_id), 0);
+    play_slot = pjsua_player_get_conf_port(play_id);
+
+    status = pjsua_conf_connect(play_slot, 0);
     if (status != PJ_SUCCESS)
 	goto on_return;
@@ -782,4 +806,8 @@
 		     "Can you hear the 'tock' echo?",
 		     WITH_YESNO);
+
+    pjsua_player_destroy(play_id);
+    play_id = PJSUA_INVALID_ID;
+
     if (key != KEY_YES)
 	goto on_return;
Index: pjproject/trunk/pjsip-apps/src/pjsystest/systest.h
===================================================================
--- pjproject/trunk/pjsip-apps/src/pjsystest/systest.h	(revision 2835)
+++ pjproject/trunk/pjsip-apps/src/pjsystest/systest.h	(revision 2836)
@@ -1,2 +1,20 @@
+/* $Id$ */
+/* 
+ * Copyright (C) 2008-2009 Teluu Inc. (http://www.teluu.com)
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA 
+ */
 #ifndef __SYSTEST_H__
 #define __SYSTEST_H__
@@ -33,4 +51,5 @@
 #endif
 
+/* API, to be called by main() */
 int	    systest_init(void);
 int	    systest_run(void);
@@ -38,4 +57,5 @@
 void	    systest_deinit(void);
 
+/* Test item is used to record the test result */
 typedef struct test_item_t
 {
