Index: pjproject/trunk/pjsip/src/pjsua-lib/pjsua_media.c
===================================================================
--- pjproject/trunk/pjsip/src/pjsua-lib/pjsua_media.c	(revision 1393)
+++ pjproject/trunk/pjsip/src/pjsua-lib/pjsua_media.c	(revision 1403)
@@ -1106,4 +1106,17 @@
  */
 
+static char* get_basename(const char *path, unsigned len)
+{
+    char *p = ((char*)path) + len;
+
+    if (len==0)
+	return p;
+
+    for (--p; p!=path && *p!='/' && *p!='\\'; --p);
+
+    return (p==path) ? p : p+1;
+}
+
+
 /*
  * Create a file player, and automatically connect this player to
@@ -1116,4 +1129,5 @@
     unsigned slot, file_id;
     char path[PJ_MAXPATH];
+    pj_pool_t *pool;
     pjmedia_port *port;
     pj_status_t status;
@@ -1138,5 +1152,12 @@
     pj_memcpy(path, filename->ptr, filename->slen);
     path[filename->slen] = '\0';
-    status = pjmedia_wav_player_port_create(pjsua_var.pool, path,
+
+    pool = pjsua_pool_create(get_basename(path, filename->slen), 1000, 1000);
+    if (!pool) {
+	PJSUA_UNLOCK();
+	return PJ_ENOMEM;
+    }
+
+    status = pjmedia_wav_player_port_create(pool, path,
 					    pjsua_var.mconf_cfg.samples_per_frame *
 					      1000 / pjsua_var.media_cfg.clock_rate, 
@@ -1145,4 +1166,5 @@
 	PJSUA_UNLOCK();
 	pjsua_perror(THIS_FILE, "Unable to open file for playback", status);
+	pj_pool_release(pool);
 	return status;
     }
@@ -1155,8 +1177,10 @@
 	pjsua_perror(THIS_FILE, "Unable to add file to conference bridge", 
 		     status);
+	pj_pool_release(pool);
 	return status;
     }
 
     pjsua_var.player[file_id].type = 0;
+    pjsua_var.player[file_id].pool = pool;
     pjsua_var.player[file_id].port = port;
     pjsua_var.player[file_id].slot = slot;
@@ -1182,4 +1206,5 @@
 {
     unsigned slot, file_id, ptime;
+    pj_pool_t *pool;
     pjmedia_port *port;
     pj_status_t status;
@@ -1206,5 +1231,11 @@
 	    pjsua_var.media_cfg.clock_rate;
 
-    status = pjmedia_wav_playlist_create(pjsua_var.pool, label, 
+    pool = pjsua_pool_create("playlist", 1000, 1000);
+    if (!pool) {
+	PJSUA_UNLOCK();
+	return PJ_ENOMEM;
+    }
+
+    status = pjmedia_wav_playlist_create(pool, label, 
 					 file_names, file_count,
 					 ptime, options, 0, &port);
@@ -1212,8 +1243,9 @@
 	PJSUA_UNLOCK();
 	pjsua_perror(THIS_FILE, "Unable to create playlist", status);
-	return status;
-    }
-
-    status = pjmedia_conf_add_port(pjsua_var.mconf, pjsua_var.pool, 
+	pj_pool_release(pool);
+	return status;
+    }
+
+    status = pjmedia_conf_add_port(pjsua_var.mconf, pool, 
 				   port, &port->info.name, &slot);
     if (status != PJ_SUCCESS) {
@@ -1221,8 +1253,10 @@
 	PJSUA_UNLOCK();
 	pjsua_perror(THIS_FILE, "Unable to add port", status);
+	pj_pool_release(pool);
 	return status;
     }
 
     pjsua_var.player[file_id].type = 1;
+    pjsua_var.player[file_id].pool = pool;
     pjsua_var.player[file_id].port = port;
     pjsua_var.player[file_id].slot = slot;
@@ -1295,4 +1329,6 @@
 	pjsua_var.player[id].port = NULL;
 	pjsua_var.player[id].slot = 0xFFFF;
+	pj_pool_release(pjsua_var.player[id].pool);
+	pjsua_var.player[id].pool = NULL;
 	pjsua_var.player_cnt--;
     }
@@ -1329,4 +1365,5 @@
     pj_str_t ext;
     int file_format;
+    pj_pool_t *pool;
     pjmedia_port *port;
     pj_status_t status;
@@ -1376,6 +1413,12 @@
     path[filename->slen] = '\0';
 
+    pool = pjsua_pool_create(get_basename(path, filename->slen), 1000, 1000);
+    if (!pool) {
+	PJSUA_UNLOCK();
+	return PJ_ENOMEM;
+    }
+
     if (file_format == FMT_WAV) {
-	status = pjmedia_wav_writer_port_create(pjsua_var.pool, path, 
+	status = pjmedia_wav_writer_port_create(pool, path, 
 						pjsua_var.media_cfg.clock_rate, 
 						pjsua_var.mconf_cfg.channel_count,
@@ -1392,12 +1435,14 @@
 	PJSUA_UNLOCK();
 	pjsua_perror(THIS_FILE, "Unable to open file for recording", status);
-	return status;
-    }
-
-    status = pjmedia_conf_add_port(pjsua_var.mconf, pjsua_var.pool, 
+	pj_pool_release(pool);
+	return status;
+    }
+
+    status = pjmedia_conf_add_port(pjsua_var.mconf, pool, 
 				   port, filename, &slot);
     if (status != PJ_SUCCESS) {
 	pjmedia_port_destroy(port);
 	PJSUA_UNLOCK();
+	pj_pool_release(pool);
 	return status;
     }
@@ -1405,4 +1450,5 @@
     pjsua_var.recorder[file_id].port = port;
     pjsua_var.recorder[file_id].slot = slot;
+    pjsua_var.recorder[file_id].pool = pool;
 
     if (p_id) *p_id = file_id;
@@ -1459,4 +1505,6 @@
 	pjsua_var.recorder[id].port = NULL;
 	pjsua_var.recorder[id].slot = 0xFFFF;
+	pj_pool_release(pjsua_var.recorder[id].pool);
+	pjsua_var.recorder[id].pool = NULL;
 	pjsua_var.rec_cnt--;
     }
