Index: /pjproject/trunk/pjsip/src/pjsua-lib/pjsua_core.c
===================================================================
--- /pjproject/trunk/pjsip/src/pjsua-lib/pjsua_core.c	(revision 1854)
+++ /pjproject/trunk/pjsip/src/pjsua-lib/pjsua_core.c	(revision 1855)
@@ -163,5 +163,5 @@
 
     cfg->clock_rate = PJSUA_DEFAULT_CLOCK_RATE;
-    cfg->snd_clock_rate = PJSUA_DEFAULT_CLOCK_RATE;
+    cfg->snd_clock_rate = 0;
     cfg->audio_frame_ptime = PJSUA_DEFAULT_AUDIO_FRAME_PTIME;
     cfg->max_media_ports = PJSUA_MAX_CONF_PORTS;
Index: /pjproject/trunk/pjsip/src/pjsua-lib/pjsua_media.c
===================================================================
--- /pjproject/trunk/pjsip/src/pjsua-lib/pjsua_media.c	(revision 1854)
+++ /pjproject/trunk/pjsip/src/pjsua-lib/pjsua_media.c	(revision 1855)
@@ -53,4 +53,7 @@
 
     /* Normalize configuration */
+    if (pjsua_var.media_cfg.snd_clock_rate == 0) {
+	pjsua_var.media_cfg.snd_clock_rate = pjsua_var.media_cfg.clock_rate;
+    }
 
     if (pjsua_var.media_cfg.has_ioqueue &&
@@ -185,6 +188,5 @@
 				 opt, &pjsua_var.mconf);
     if (status != PJ_SUCCESS) {
-	pjsua_perror(THIS_FILE, 
-		     "Media stack initialization has returned error", 
+	pjsua_perror(THIS_FILE, "Error creating conference bridge", 
 		     status);
 	return status;
@@ -1790,4 +1792,8 @@
 	clock_rates[0] = pjsua_var.media_cfg.clock_rate;
 
+    /* Get the port0 of the conference bridge. */
+    conf_port = pjmedia_conf_get_master_port(pjsua_var.mconf);
+    pj_assert(conf_port != NULL);
+
     /* Attempts to open the sound device with different clock rates */
     for (i=0; i<PJ_ARRAY_SIZE(clock_rates); ++i) {
@@ -1809,5 +1815,43 @@
 	if (status == PJ_SUCCESS) {
 	    selected_clock_rate = clock_rates[i];
-	    break;
+
+	    /* If there's mismatch between sound port and conference's port,
+	     * create a resample port to bridge them.
+	     */
+	    if (selected_clock_rate != pjsua_var.media_cfg.clock_rate) {
+		pjmedia_port *resample_port;
+		unsigned resample_opt = 0;
+
+		if (pjsua_var.media_cfg.quality >= 3 &&
+		    pjsua_var.media_cfg.quality <= 4)
+		{
+		    resample_opt |= PJMEDIA_CONF_SMALL_FILTER;
+		}
+		else if (pjsua_var.media_cfg.quality < 3) {
+		    resample_opt |= PJMEDIA_CONF_USE_LINEAR;
+		}
+		
+		status = pjmedia_resample_port_create(pjsua_var.pool, 
+						      conf_port,
+						      selected_clock_rate,
+						      resample_opt, 
+						      &resample_port);
+		if (status != PJ_SUCCESS) {
+		    pj_strerror(status, errmsg, sizeof(errmsg));
+		    PJ_LOG(4, (THIS_FILE, 
+			       "Error creating resample port, trying next "
+			       "clock rate", 
+			       errmsg));
+		    pjmedia_snd_port_destroy(pjsua_var.snd_port);
+		    pjsua_var.snd_port = NULL;
+		    continue;
+		} else {
+		    conf_port = resample_port;
+		    break;
+		}
+
+	    } else {
+		break;
+	    }
 	}
 
@@ -1820,8 +1864,4 @@
 	return status;
     }
-
-    /* Get the port0 of the conference bridge. */
-    conf_port = pjmedia_conf_get_master_port(pjsua_var.mconf);
-    pj_assert(conf_port != NULL);
 
     /* Set AEC */
@@ -1829,31 +1869,4 @@
 			     pjsua_var.media_cfg.ec_tail_len, 
 			     pjsua_var.media_cfg.ec_options);
-
-    /* If there's mismatch between sound port and conference's port,
-     * create a resample port to bridge them.
-     */
-    if (selected_clock_rate != pjsua_var.media_cfg.clock_rate) {
-	pjmedia_port *resample_port;
-	unsigned resample_opt = 0;
-
-	if (pjsua_var.media_cfg.quality >= 3 &&
-	    pjsua_var.media_cfg.quality <= 4)
-	{
-	    resample_opt |= PJMEDIA_CONF_SMALL_FILTER;
-	}
-	else if (pjsua_var.media_cfg.quality < 3) {
-	    resample_opt |= PJMEDIA_CONF_USE_LINEAR;
-	}
-	
-	status = pjmedia_resample_port_create(pjsua_var.pool, conf_port, 
-					      selected_clock_rate, 
-					      resample_opt, &resample_port);
-	if (status != PJ_SUCCESS) {
-	    pjsua_perror("Error creating resample port", THIS_FILE, status);
-	    return status;
-	}
-
-	conf_port = resample_port;
-    }
 
     /* Connect sound port to the bridge */ 	 
