Index: pjproject/trunk/pjsip-apps/src/symsndtest/app_main.cpp
===================================================================
--- pjproject/trunk/pjsip-apps/src/symsndtest/app_main.cpp	(revision 2394)
+++ pjproject/trunk/pjsip-apps/src/symsndtest/app_main.cpp	(revision 2506)
@@ -50,5 +50,5 @@
 
     PJ_UNUSED_ARG(level);
-    
+
     pj_ansi_to_unicode(buf, len, buf16, PJ_ARRAY_SIZE(buf16));
 
@@ -58,7 +58,7 @@
 
 /* perror util */
-static void app_perror(const char *title, pj_status_t status) 
-{
-    char errmsg[PJ_ERR_MSG_SIZE];	
+static void app_perror(const char *title, pj_status_t status)
+{
+    char errmsg[PJ_ERR_MSG_SIZE];
     pj_strerror(status, errmsg, sizeof(errmsg));
     PJ_LOG(1,(THIS_FILE, "Error: %s: %s", title, errmsg));
@@ -66,14 +66,14 @@
 
 /* Application init */
-static pj_status_t app_init() 
+static pj_status_t app_init()
 {
     unsigned i, count;
     pj_status_t status;
-   
+
     /* Redirect log */
     pj_log_set_log_func((void (*)(int,const char*,int)) &log_writer);
     pj_log_set_decor(PJ_LOG_HAS_NEWLINE);
     pj_log_set_level(3);
-    
+
     /* Init pjlib */
     status = pj_init();
@@ -84,5 +84,5 @@
 
     pj_caching_pool_init(&cp, NULL, 0);
-    
+
     /* Init sound subsystem */
     status = pjmedia_snd_init(&cp.factory);
@@ -93,14 +93,14 @@
     	return status;
     }
-    
+
     count = pjmedia_snd_get_dev_count();
     PJ_LOG(3,(THIS_FILE, "Device count: %d", count));
     for (i=0; i<count; ++i) {
     	const pjmedia_snd_dev_info *info;
-    	
+
     	info = pjmedia_snd_get_dev_info(i);
     	PJ_LOG(3, (THIS_FILE, "%d: %s %d/%d %dHz",
     		   i, info->name, info->input_count, info->output_count,
-    		   info->default_samples_per_sec));	
+    		   info->default_samples_per_sec));
     }
 
@@ -115,6 +115,6 @@
 
     /* Init delay buffer */
-    status = pjmedia_delay_buf_create(pool, THIS_FILE, CLOCK_RATE, 
-				      SAMPLES_PER_FRAME, CHANNEL_COUNT, 
+    status = pjmedia_delay_buf_create(pool, THIS_FILE, CLOCK_RATE,
+				      SAMPLES_PER_FRAME, CHANNEL_COUNT,
 				      0, 0, &delaybuf);
     if (status != PJ_SUCCESS) {
@@ -124,5 +124,5 @@
     	//return status;
     }
-    
+
     return PJ_SUCCESS;
 }
@@ -130,8 +130,8 @@
 
 /* Sound capture callback */
-static pj_status_t rec_cb(void *user_data, 
+static pj_status_t rec_cb(void *user_data,
 			  pj_uint32_t timestamp,
 			  void *input,
-			  unsigned size) 
+			  unsigned size)
 {
     PJ_UNUSED_ARG(user_data);
@@ -154,26 +154,26 @@
 			   pj_uint32_t timestamp,
 			   void *output,
-			   unsigned size) 
+			   unsigned size)
 {
     PJ_UNUSED_ARG(user_data);
     PJ_UNUSED_ARG(timestamp);
     PJ_UNUSED_ARG(size);
-    
+
     pjmedia_delay_buf_get(delaybuf, (pj_int16_t*)output);
-    
+
     ++play_cnt;
-    return PJ_SUCCESS;	
+    return PJ_SUCCESS;
 }
 
 /* Start sound */
-static pj_status_t snd_start(unsigned flag) 
+static pj_status_t snd_start(unsigned flag)
 {
     pj_status_t status;
-    
+
     if (strm != NULL) {
     	app_perror("snd already open", PJ_EINVALIDOP);
     	return PJ_EINVALIDOP;
     }
-    
+
     if (flag==PJMEDIA_DIR_CAPTURE_PLAYBACK)
     	status = pjmedia_snd_open(-1, -1, CLOCK_RATE, CHANNEL_COUNT,
@@ -188,5 +188,5 @@
     					 SAMPLES_PER_FRAME, BITS_PER_SAMPLE,
     					 &play_cb, NULL, &strm);
-			 
+
     if (status != PJ_SUCCESS) {
     	app_perror("snd open", status);
@@ -211,17 +211,21 @@
 
 /* Stop sound */
-static pj_status_t snd_stop() 
+static pj_status_t snd_stop()
 {
     pj_time_val now;
     pj_status_t status;
-    
+
     if (strm == NULL) {
     	app_perror("snd not open", PJ_EINVALIDOP);
     	return PJ_EINVALIDOP;
     }
-    
+
+    status = pjmedia_snd_stream_stop(strm);
+    if (status != PJ_SUCCESS) {
+    	app_perror("snd failed to stop", status);
+    }
     status = pjmedia_snd_stream_close(strm);
     strm = NULL;
-    
+
     pj_gettimeofday(&now);
     PJ_TIME_VAL_SUB(now, t_start);
@@ -235,9 +239,9 @@
 
 /* Shutdown application */
-static void app_fini() 
+static void app_fini()
 {
     if (strm)
     	snd_stop();
-    
+
     pjmedia_snd_deinit();
     pjmedia_delay_buf_destroy(delaybuf);
@@ -254,8 +258,8 @@
 #include <e32base.h>
 
-class ConsoleUI : public CActive 
+class ConsoleUI : public CActive
 {
 public:
-    ConsoleUI(CActiveSchedulerWait *asw, CConsoleBase *con);
+    ConsoleUI(CConsoleBase *con);
 
     // Run console UI
@@ -264,5 +268,5 @@
     // Stop
     void Stop();
-    
+
 protected:
     // Cancel asynchronous read.
@@ -271,13 +275,12 @@
     // Implementation: called when read has completed.
     void RunL();
-    
+
 private:
-    CActiveSchedulerWait *asw_;
     CConsoleBase *con_;
 };
 
 
-ConsoleUI::ConsoleUI(CActiveSchedulerWait *asw, CConsoleBase *con) 
-: CActive(EPriorityHigh), asw_(asw), con_(con)
+ConsoleUI::ConsoleUI(CConsoleBase *con)
+: CActive(EPriorityUserInput), con_(con)
 {
     CActiveScheduler::Add(this);
@@ -285,5 +288,5 @@
 
 // Run console UI
-void ConsoleUI::Run() 
+void ConsoleUI::Run()
 {
     con_->Read(iStatus);
@@ -292,5 +295,5 @@
 
 // Stop console UI
-void ConsoleUI::Stop() 
+void ConsoleUI::Stop()
 {
     DoCancel();
@@ -298,10 +301,10 @@
 
 // Cancel asynchronous read.
-void ConsoleUI::DoCancel() 
+void ConsoleUI::DoCancel()
 {
     con_->ReadCancel();
 }
 
-static void PrintMenu() 
+static void PrintMenu()
 {
     PJ_LOG(3, (THIS_FILE, "\n\n"
@@ -315,12 +318,13 @@
 
 // Implementation: called when read has completed.
-void ConsoleUI::RunL() 
+void ConsoleUI::RunL()
 {
     TKeyCode kc = con_->KeyCode();
     pj_bool_t reschedule = PJ_TRUE;
-    
+
     switch (kc) {
     case 'w':
-	    asw_->AsyncStop();
+	    snd_stop();
+	    CActiveScheduler::Stop();
 	    reschedule = PJ_FALSE;
 	    break;
@@ -344,5 +348,5 @@
 
     PrintMenu();
-    
+
     if (reschedule)
 	Run();
@@ -351,21 +355,19 @@
 
 ////////////////////////////////////////////////////////////////////////////
-int app_main() 
+int app_main()
 {
     if (app_init() != PJ_SUCCESS)
         return -1;
-    
+
     // Run the UI
-    CActiveSchedulerWait *asw = new CActiveSchedulerWait;
-    ConsoleUI *con = new ConsoleUI(asw, console);
-    
+    ConsoleUI *con = new ConsoleUI(console);
+
     con->Run();
-    
+
     PrintMenu();
-    asw->Start();
-    
+    CActiveScheduler::Start();
+
     delete con;
-    delete asw;
-    
+
     app_fini();
     return 0;
