[asterisk-commits] branch crichter/0.4.0 r32544 - in /team/crichter/0.4.0: ./ apps/ channels/ ch...

asterisk-commits at lists.digium.com asterisk-commits at lists.digium.com
Tue Jun 6 03:34:17 MST 2006


Author: crichter
Date: Tue Jun  6 05:34:17 2006
New Revision: 32544

URL: http://svn.digium.com/view/asterisk?rev=32544&view=rev
Log:
Merged revisions 31526,31560,31743,31781,31926,32377,32523 via svnmerge from 
https://origsvn.digium.com/svn/asterisk/team/crichter/0.3.0

........
r31526 | root | 2006-06-01 23:00:46 +0200 (Do, 01 Jun 2006) | 1 line

automerge commit
........
r31560 | root | 2006-06-02 00:00:45 +0200 (Fr, 02 Jun 2006) | 1 line

automerge commit
........
r31743 | root | 2006-06-03 17:00:50 +0200 (Sa, 03 Jun 2006) | 1 line

automerge commit
........
r31781 | root | 2006-06-03 20:00:44 +0200 (Sa, 03 Jun 2006) | 1 line

automerge commit
........
r31926 | root | 2006-06-04 06:00:47 +0200 (So, 04 Jun 2006) | 1 line

automerge commit
........
r32377 | root | 2006-06-05 22:00:48 +0200 (Mo, 05 Jun 2006) | 1 line

automerge commit
........
r32523 | crichter | 2006-06-06 11:36:25 +0200 (Di, 06 Jun 2006) | 1 line

added select before write to avoid deadlock on full buffer. added some defines for deadlock debugging. added code snippet for generating silence if we don't have data to write.
........

Modified:
    team/crichter/0.4.0/   (props changed)
    team/crichter/0.4.0/apps/app_queue.c
    team/crichter/0.4.0/channel.c
    team/crichter/0.4.0/channels/chan_iax2.c
    team/crichter/0.4.0/channels/chan_misdn.c
    team/crichter/0.4.0/channels/misdn/isdn_lib.c
    team/crichter/0.4.0/include/asterisk/channel.h
    team/crichter/0.4.0/include/asterisk/linkedlists.h
    team/crichter/0.4.0/res/res_musiconhold.c

Propchange: team/crichter/0.4.0/
------------------------------------------------------------------------------
--- svnmerge-integrated (original)
+++ svnmerge-integrated Tue Jun  6 05:34:17 2006
@@ -1,1 +1,1 @@
-/team/crichter/0.3.0:1-31439
+/team/crichter/0.3.0:1-32524

Modified: team/crichter/0.4.0/apps/app_queue.c
URL: http://svn.digium.com/view/asterisk/team/crichter/0.4.0/apps/app_queue.c?rev=32544&r1=32543&r2=32544&view=diff
==============================================================================
--- team/crichter/0.4.0/apps/app_queue.c (original)
+++ team/crichter/0.4.0/apps/app_queue.c Tue Jun  6 05:34:17 2006
@@ -2431,7 +2431,7 @@
 		if (bridge != AST_PBX_NO_HANGUP_PEER)
 			ast_hangup(peer);
 		update_queue(qe->parent, member);
-		res = bridge ? -1 : 0;
+		res = bridge ? bridge : 1;
 	}	
 out:
 	hangupcalls(outgoing, NULL);

Modified: team/crichter/0.4.0/channel.c
URL: http://svn.digium.com/view/asterisk/team/crichter/0.4.0/channel.c?rev=32544&r1=32543&r2=32544&view=diff
==============================================================================
--- team/crichter/0.4.0/channel.c (original)
+++ team/crichter/0.4.0/channel.c Tue Jun  6 05:34:17 2006
@@ -2736,6 +2736,14 @@
 	struct ast_frame null = { AST_FRAME_NULL, };
 	int res = -1;
 
+	/* each of these channels may be sitting behind a channel proxy (i.e. chan_agent)
+	   and if so, we don't really want to masquerade it, but its proxy */
+	if (original->_bridge && (original->_bridge != ast_bridged_channel(original)))
+		original = original->_bridge;
+
+	if (clone->_bridge && (clone->_bridge != ast_bridged_channel(clone)))
+		clone = clone->_bridge;
+
 	if (original == clone) {
 		ast_log(LOG_WARNING, "Can't masquerade channel '%s' into itself!\n", original->name);
 		return -1;

Modified: team/crichter/0.4.0/channels/chan_iax2.c
URL: http://svn.digium.com/view/asterisk/team/crichter/0.4.0/channels/chan_iax2.c?rev=32544&r1=32543&r2=32544&view=diff
==============================================================================
--- team/crichter/0.4.0/channels/chan_iax2.c (original)
+++ team/crichter/0.4.0/channels/chan_iax2.c Tue Jun  6 05:34:17 2006
@@ -6323,27 +6323,28 @@
 			return 1;
  
 	}
-	if (res < sizeof(struct ast_iax2_mini_hdr)) {
-		ast_log(LOG_WARNING, "midget packet received (%d of %d min)\n", res, (int)sizeof(struct ast_iax2_mini_hdr));
+	if (res < sizeof(*mh)) {
+		ast_log(LOG_WARNING, "midget packet received (%d of %zd min)\n", res, sizeof(*mh));
 		return 1;
 	}
-	if ((vh->zeros == 0) && (ntohs(vh->callno) & 0x8000)) {
+	if ((res >= sizeof(*vh)) && ((vh->zeros == 0) && (ntohs(vh->callno) & 0x8000))) {
 		/* This is a video frame, get call number */
 		fr->callno = find_callno(ntohs(vh->callno) & ~0x8000, dcallno, &sin, new, 1, fd);
 		minivid = 1;
-	} else if (meta->zeros == 0) {
+	} else if ((res >= sizeof(*meta)) && (meta->zeros == 0) && !(ntohs(meta->metacmd) & 0x8000)) {
 		unsigned char metatype;
 		/* This is a meta header */
 		switch(meta->metacmd) {
 		case IAX_META_TRUNK:
-			if (res < sizeof(struct ast_iax2_meta_hdr) + sizeof(struct ast_iax2_meta_trunk_hdr)) {
-				ast_log(LOG_WARNING, "midget meta trunk packet received (%d of %d min)\n", res, (int)sizeof(struct ast_iax2_mini_hdr));
+			if (res < (sizeof(*meta) + sizeof(*mth))) {
+				ast_log(LOG_WARNING, "midget meta trunk packet received (%d of %zd min)\n", res,
+					sizeof(*meta) + sizeof(*mth));
 				return 1;
 			}
 			mth = (struct ast_iax2_meta_trunk_hdr *)(meta->data);
 			ts = ntohl(mth->ts);
 			metatype = meta->cmddata;
-			res -= (sizeof(struct ast_iax2_meta_hdr) + sizeof(struct ast_iax2_meta_trunk_hdr));
+			res -= (sizeof(*meta) + sizeof(*mth));
 			ptr = mth->data;
 			tpeer = find_tpeer(&sin, fd);
 			if (!tpeer) {
@@ -6355,21 +6356,21 @@
 				tpeer->rxtrunktime = tpeer->trunkact;
 			rxtrunktime = tpeer->rxtrunktime;
 			ast_mutex_unlock(&tpeer->lock);
-			while(res >= sizeof(struct ast_iax2_meta_trunk_entry)) {
+			while(res >= sizeof(*mte)) {
 				/* Process channels */
 				unsigned short callno, trunked_ts, len;
 
-				if(metatype == IAX_META_TRUNK_MINI) {
+				if (metatype == IAX_META_TRUNK_MINI) {
 					mtm = (struct ast_iax2_meta_trunk_mini *)ptr;
-					ptr += sizeof(struct ast_iax2_meta_trunk_mini);
-					res -= sizeof(struct ast_iax2_meta_trunk_mini);
+					ptr += sizeof(*mtm);
+					res -= sizeof(*mtm);
 					len = ntohs(mtm->len);
 					callno = ntohs(mtm->mini.callno);
 					trunked_ts = ntohs(mtm->mini.ts);
-				} else if ( metatype == IAX_META_TRUNK_SUPERMINI ) {
+				} else if (metatype == IAX_META_TRUNK_SUPERMINI) {
 					mte = (struct ast_iax2_meta_trunk_entry *)ptr;
-					ptr += sizeof(struct ast_iax2_meta_trunk_entry);
-					res -= sizeof(struct ast_iax2_meta_trunk_entry);
+					ptr += sizeof(*mte);
+					res -= sizeof(*mte);
 					len = ntohs(mte->len);
 					callno = ntohs(mte->callno);
 					trunked_ts = 0;
@@ -6452,11 +6453,21 @@
 		}
 		return 1;
 	}
+
+	/* if we got here and ->zeros contains zeros, this cannot be a valid
+	   miniframe or full frame but it wasn't a valid video frame or meta
+	   frame either, so we reject it
+	*/
+	if (vh->zeros == 0) {
+		ast_log(LOG_WARNING, "Rejecting packet from '%s.%d' that is flagged as a video or meta frame but is not properly formatted\n", ast_inet_ntoa(iabuf, sizeof(iabuf), sin.sin_addr), ntohs(sin.sin_port));
+		return 1;
+	}
+
 #ifdef DEBUG_SUPPORT
-	if (iaxdebug)
-		iax_showframe(NULL, fh, 1, &sin, res - sizeof(struct ast_iax2_full_hdr));
+	if (iaxdebug && (res >= sizeof(*fh)))
+		iax_showframe(NULL, fh, 1, &sin, res - sizeof(*fh));
 #endif
-	if (ntohs(mh->callno) & IAX_FLAG_FULL) {
+	if ((res >= sizeof(*fh)) && ntohs(mh->callno) & IAX_FLAG_FULL) {
 		/* Get the destination call number */
 		dcallno = ntohs(fh->dcallno) & ~IAX_FLAG_RETRANS;
 		/* Retrieve the type and subclass */
@@ -6507,7 +6518,7 @@
 		}
 #ifdef DEBUG_SUPPORT
 		else if (iaxdebug)
-			iax_showframe(NULL, fh, 3, &sin, res - sizeof(struct ast_iax2_full_hdr));
+			iax_showframe(NULL, fh, 3, &sin, res - sizeof(*fh));
 #endif
 	}
 
@@ -6592,12 +6603,12 @@
 				iaxs[fr->callno]->iseqno++;
 		}
 		/* A full frame */
-		if (res < sizeof(struct ast_iax2_full_hdr)) {
-			ast_log(LOG_WARNING, "midget packet received (%d of %d min)\n", res, (int)sizeof(struct ast_iax2_full_hdr));
+		if (res < sizeof(*fh)) {
+			ast_log(LOG_WARNING, "midget packet received (%d of %zd min)\n", res, sizeof(*fh));
 			ast_mutex_unlock(&iaxsl[fr->callno]);
 			return 1;
 		}
-		f.datalen = res - sizeof(struct ast_iax2_full_hdr);
+		f.datalen = res - sizeof(*fh);
 
 		/* Handle implicit ACKing unless this is an INVAL, and only if this is 
 		   from the real peer, not the transfer peer */
@@ -6655,14 +6666,14 @@
 
 		if (f.datalen) {
 			if (f.frametype == AST_FRAME_IAX) {
-				if (iax_parse_ies(&ies, buf + sizeof(struct ast_iax2_full_hdr), f.datalen)) {
+				if (iax_parse_ies(&ies, buf + sizeof(*fh), f.datalen)) {
 					ast_log(LOG_WARNING, "Undecodable frame received from '%s'\n", ast_inet_ntoa(iabuf, sizeof(iabuf), sin.sin_addr));
 					ast_mutex_unlock(&iaxsl[fr->callno]);
 					return 1;
 				}
 				f.data = NULL;
 			} else
-				f.data = buf + sizeof(struct ast_iax2_full_hdr);
+				f.data = buf + sizeof(*fh);
 		} else {
 			if (f.frametype == AST_FRAME_IAX)
 				f.data = NULL;
@@ -7540,9 +7551,9 @@
 			ast_mutex_unlock(&iaxsl[fr->callno]);
 			return 1;
 		}
-		f.datalen = res - sizeof(struct ast_iax2_video_hdr);
+		f.datalen = res - sizeof(*vh);
 		if (f.datalen)
-			f.data = buf + sizeof(struct ast_iax2_video_hdr);
+			f.data = buf + sizeof(*vh);
 		else
 			f.data = NULL;
 #ifdef IAXTESTS
@@ -7569,7 +7580,7 @@
 			return 1;
 		}
 		if (f.datalen)
-			f.data = buf + sizeof(struct ast_iax2_mini_hdr);
+			f.data = buf + sizeof(*mh);
 		else
 			f.data = NULL;
 #ifdef IAXTESTS

Modified: team/crichter/0.4.0/channels/chan_misdn.c
URL: http://svn.digium.com/view/asterisk/team/crichter/0.4.0/channels/chan_misdn.c?rev=32544&r1=32543&r2=32544&view=diff
==============================================================================
--- team/crichter/0.4.0/channels/chan_misdn.c (original)
+++ team/crichter/0.4.0/channels/chan_misdn.c Tue Jun  6 05:34:17 2006
@@ -2299,7 +2299,6 @@
 		break;
 	case TONE_FILE:
 		break;
-
 	case TONE_NONE:
 		chan_misdn_log(3,cl->bc->port," --> None\n");
 		misdn_lib_tone_generator_stop(cl->bc);
@@ -3279,7 +3278,6 @@
 				
 				ast_queue_frame(ch->ast, &fr);
 			}
-			
 		}
 	}
 	break;
@@ -3688,7 +3686,7 @@
 		int (*generate)(struct ast_channel *chan, void *tmp, int datalen, int samples);
 
 		chan_misdn_log(9,bc->port,"TONE_GEN: len:%d\n");
-		
+
 		if (!ast->generator) break;
 		
 		tmp = ast->generatordata;
@@ -3696,13 +3694,13 @@
 		generate = ast->generator->generate;
 		res = generate(ast, tmp, tone_len, tone_len);
 		ast->generatordata = tmp;
+		
 		if (res) {
 			ast_log(LOG_WARNING, "Auto-deactivating generator\n");
 			ast_deactivate_generator(ast);
 		} else {
 			bc->tone_cnt=0;
 		}
-		
 	}
 	break;
 		
@@ -3722,10 +3720,35 @@
 			
 			ast_queue_frame(ch->ast,&frame);
 		} else {
-			int ret=write(ch->pipe[1], bc->bframe, bc->bframe_len);
-
-			if (ret<=0) {
-				chan_misdn_log(1, bc->port, "Write returned <=0 (err=%s)\n",strerror(errno));
+			fd_set wrfs;
+			struct timeval tv;
+			tv.tv_sec=0;
+			tv.tv_usec=0;
+			
+			
+			FD_ZERO(&wrfs);
+			FD_SET(ch->pipe[1],&wrfs);
+			
+			int t=select(FD_SETSIZE,NULL,&wrfs,NULL,&tv);
+
+			if (!t) {
+				chan_misdn_log(9, bc->port, "Select Timed out\n");
+				break;
+			}
+			
+			if (t<0) {
+				chan_misdn_log(-1, bc->port, "Select Error (err=%s)\n",strerror(errno));
+				break;
+			}
+			
+			if (FD_ISSET(ch->pipe[1],&wrfs)) {
+				int ret=write(ch->pipe[1], bc->bframe, bc->bframe_len);
+				
+				if (ret<=0) {
+					chan_misdn_log(-1, bc->port, "Write returned <=0 (err=%s)\n",strerror(errno));
+				}
+			} else {
+				chan_misdn_log(1, bc->port, "Wripe Pipe full!\n");
 			}
 		}
 	}

Modified: team/crichter/0.4.0/channels/misdn/isdn_lib.c
URL: http://svn.digium.com/view/asterisk/team/crichter/0.4.0/channels/misdn/isdn_lib.c?rev=32544&r1=32543&r2=32544&view=diff
==============================================================================
--- team/crichter/0.4.0/channels/misdn/isdn_lib.c (original)
+++ team/crichter/0.4.0/channels/misdn/isdn_lib.c Tue Jun  6 05:34:17 2006
@@ -599,7 +599,7 @@
 	cb_log(3, stack->port, "$$$ CLEARING STACK\n");
 	
 	ret=mISDN_clear_stack(stack->midev,bc->b_stid);
-	if (ret<0) {
+	if (ret<0 && errno) {
 		cb_log(-1,stack->port,"clear stack failed [%s]\n",strerror(errno));
 	}
 
@@ -1988,7 +1988,7 @@
 	
 	if (bc->generate_tone) {
 		cb_event(EVENT_TONE_GENERATE, bc, glob_mgr->user_data);
-
+		
 		if ( !bc->nojitter ) {
 			misdn_tx_jitter(bc,len);
 		}
@@ -2004,13 +2004,14 @@
 void misdn_tx_jitter(struct misdn_bchannel *bc, int len)
 {
 	char buf[4096 + mISDN_HEADER_LEN];
+	char *data=&buf[mISDN_HEADER_LEN];
 	iframe_t *txfrm= (iframe_t*)buf;
 	int jlen, r;
 	
-	jlen=cb_jb_empty(bc,&buf[mISDN_HEADER_LEN],len);
+	jlen=cb_jb_empty(bc,data,len);
 	
 	if (jlen) {
-		flip_buf_bits( &buf[mISDN_HEADER_LEN], jlen);
+		flip_buf_bits( data, jlen);
 		
 		if (jlen < len) {
 			cb_log(5,bc->port,"Jitterbuffer Underrun.\n");
@@ -2027,6 +2028,31 @@
 		
 		r=mISDN_write( glob_mgr->midev, buf, txfrm->len + mISDN_HEADER_LEN, 8000 );
 	} else {
+#ifdef MISDN_GEN_SILENCE
+		int cnt=len/TONE_SILENCE_SIZE;
+		int rest=len%TONE_SILENCE_SIZE;
+		int i;
+		
+		for (i=0; i<cnt; i++) {
+			memcpy(data, tone_silence_flip, TONE_SILENCE_SIZE );
+			data +=TONE_SILENCE_SIZE;
+		}
+		
+		if (rest) {
+			memcpy(data, tone_silence_flip, rest);
+		}
+		
+		txfrm->prim = DL_DATA|REQUEST;
+		
+		txfrm->dinfo = 0;
+		
+		txfrm->addr = bc->addr|FLG_MSG_DOWN; /*  | IF_DOWN; */
+		
+		txfrm->len =len;
+		cb_log(9, bc->port, "Transmitting %d samples 2 misdn\n", txfrm->len);
+		
+		r=mISDN_write( glob_mgr->midev, buf, txfrm->len + mISDN_HEADER_LEN, 8000 );
+#endif
 	}
 }
 
@@ -2204,15 +2230,39 @@
 #endif
 		
 		if ( (bc->bc_state == BCHAN_ACTIVATED) && frm->len > 0) {
-			if (  !do_tone(bc, frm->len)   ) {
+			int t;
+
+#ifdef MISDN_B_DEBUG
+			cb_log(0,bc->port,"do_tone START\n");
+#endif
+			t=do_tone(bc,frm->len);
+
+#ifdef MISDN_B_DEBUG
+			cb_log(0,bc->port,"do_tone STOP (%d)\n",t);
+#endif
+			if (  !t ) {
 				
 				if ( misdn_cap_is_speech(bc->capability)) {
 					if ( !bc->nojitter ) {
+#ifdef MISDN_B_DEBUG
+						cb_log(0,bc->port,"tx_jitter START\n");
+#endif
 						misdn_tx_jitter(bc,frm->len);
+#ifdef MISDN_B_DEBUG
+						cb_log(0,bc->port,"tx_jitter STOP\n");
+#endif
 					}
 				}
+
+#ifdef MISDN_B_DEBUG	
+				cb_log(0,bc->port,"EVENT_B_DATA START\n");
+#endif
 				
 				int i=cb_event( EVENT_BCHAN_DATA, bc, glob_mgr->user_data);
+#ifdef MISDN_B_DEBUG	
+				cb_log(0,bc->port,"EVENT_B_DATA STOP\n");
+#endif
+				
 				if (i<0) {
 					cb_log(10,stack->port,"cb_event returned <0\n");
 					/*clean_up_bc(bc);*/
@@ -2265,7 +2315,8 @@
 	if (!stack || !stack->nt) {
 		return 0;
 	}
-  
+
+	
 	if ((err=stack->nst.l1_l2(&stack->nst,msg))) {
     
 		if (nt_err_cnt > 0 ) {
@@ -2522,6 +2573,8 @@
 		case SSTATUS_L1_DEACTIVATED:
 			cb_log(1, stack->port, "MGMT: SSTATUS: L1_DEACTIVATED \n");
 			stack->l1link=0;
+
+			clear_l3(stack);
 			
 			break;
 
@@ -3099,10 +3152,20 @@
 	}
 
 	if ( ((frm->addr | ISDN_PID_BCHANNEL_BIT )>> 28 ) == 0x5) {
-		if (handle_bchan(msg)) 
+#ifdef MISDN_HANDLER_DEBUG
+		cb_log(0,0,"handle_bchan START\n");
+#endif
+		if (handle_bchan(msg)) {
+#ifdef MISDN_HANDLER_DEBUG
+			cb_log(0,0,"handle_bchan STOP\n");
+#endif
 			return 0 ;
+		}
+#ifdef MISDN_HANDLER_DEBUG
+		cb_log(0,0,"handle_bchan NOTSTOP\n");
+#endif	
 	}	
-
+	
 	if (handle_timers(msg)) 
 		return 0 ;
 	
@@ -3115,16 +3178,46 @@
 	/* Its important to handle l1 AFTER l2  */
 	if (handle_l1(msg)) 
 		return 0 ;
-
-	if (handle_frm_nt(msg)) 
+	
+#ifdef MISDN_HANDLER_DEBUG
+	cb_log(0,0,"handle_frm_nt START\n");
+#endif
+	if (handle_frm_nt(msg)) {
+#ifdef MISDN_HANDLER_DEBUG
+		cb_log(0,0,"handle_frm_nt STOP\n");
+#endif
 		return 0;
-
-	if (handle_frm(msg))
+	}
+#ifdef MISDN_HANDLER_DEBUG
+	cb_log(0,0,"handle_frm_nt NOTSTOP\n");
+	
+	cb_log(0,0,"handle_frm START\n");
+#endif
+	
+	if (handle_frm(msg)) {
+#ifdef MISDN_HANDLER_DEBUG
+		cb_log(0,0,"handle_frm STOP\n");
+#endif
+		
 		return 0;
-
-	if (handle_err(msg)) 
+	}
+#ifdef MISDN_HANDLER_DEBUG
+	cb_log(0,0,"handle_frm NOTSTOP\n");	
+	
+	cb_log(0,0,"handle_err START\n");
+#endif
+	
+	if (handle_err(msg)) {
+#ifdef MISDN_HANDLER_DEBUG
+		cb_log(0,0,"handle_err STOP\n");
+#endif
 		return 0 ;
-
+	}
+#ifdef MISDN_HANDLER_DEBUG
+	cb_log(0,0,"handle_err NOTSTOP\n");
+#endif
+
+	
 	cb_log(-1, 0, "Unhandled Message: prim %x len %d from addr %x, dinfo %x on this port.\n",frm->prim, frm->len, frm->addr, frm->dinfo);		
 	free_msg(msg);
 	

Modified: team/crichter/0.4.0/include/asterisk/channel.h
URL: http://svn.digium.com/view/asterisk/team/crichter/0.4.0/include/asterisk/channel.h?rev=32544&r1=32543&r2=32544&view=diff
==============================================================================
--- team/crichter/0.4.0/include/asterisk/channel.h (original)
+++ team/crichter/0.4.0/include/asterisk/channel.h Tue Jun  6 05:34:17 2006
@@ -275,8 +275,9 @@
 	/*! Current active data generator */
 	struct ast_generator *generator;
 
-	/*! Who are we bridged to, if we're bridged  Do not access directly,
-	    use ast_bridged_channel(chan) */
+	/*! Who are we bridged to, if we're bridged. Who is proxying for us,
+	  if we are proxied (i.e. chan_agent).
+	  Do not access directly, use ast_bridged_channel(chan) */
 	struct ast_channel *_bridge;
 	/*! Channel that will masquerade as us */
 	struct ast_channel *masq;		

Modified: team/crichter/0.4.0/include/asterisk/linkedlists.h
URL: http://svn.digium.com/view/asterisk/team/crichter/0.4.0/include/asterisk/linkedlists.h?rev=32544&r1=32543&r2=32544&view=diff
==============================================================================
--- team/crichter/0.4.0/include/asterisk/linkedlists.h (original)
+++ team/crichter/0.4.0/include/asterisk/linkedlists.h Tue Jun  6 05:34:17 2006
@@ -370,7 +370,8 @@
   \param head This is a pointer to the list head structure
 
   This macro initializes a list head structure by setting the head
-  entry to \a NULL (empty list) and recreating the embedded lock.
+  entry to \a NULL (empty list). There is no embedded lock handling
+  with this macro.
 */
 #define AST_LIST_HEAD_INIT_NOLOCK(head) {				\
 	(head)->first = NULL;						\

Modified: team/crichter/0.4.0/res/res_musiconhold.c
URL: http://svn.digium.com/view/asterisk/team/crichter/0.4.0/res/res_musiconhold.c?rev=32544&r1=32543&r2=32544&view=diff
==============================================================================
--- team/crichter/0.4.0/res/res_musiconhold.c (original)
+++ team/crichter/0.4.0/res/res_musiconhold.c Tue Jun  6 05:34:17 2006
@@ -212,6 +212,8 @@
 			if (ast_test_flag(state->class, MOH_RANDOMIZE))
 				state->pos = rand();
 
+			state->pos %= state->class->total_files;
+
 			/* check to see if this file's format can be opened */
 			if (ast_fileexists(state->class->filearray[state->pos], NULL, NULL) != -1)
 				break;
@@ -221,10 +223,6 @@
 
 	state->pos = state->pos % state->class->total_files;
 	
-	if (ast_set_write_format(chan, AST_FORMAT_SLINEAR)) {
-		ast_log(LOG_WARNING, "Unable to set '%s' to linear format (write)\n", chan->name);
-		return -1;
-	}
 	if (!ast_openstream_full(chan, state->class->filearray[state->pos], chan->language, 1)) {
 		ast_log(LOG_WARNING, "Unable to open file '%s': %s\n", state->class->filearray[state->pos], strerror(errno));
 		state->pos++;
@@ -299,14 +297,8 @@
 
 		state->origwfmt = chan->writeformat;
 
-		if (ast_set_write_format(chan, AST_FORMAT_SLINEAR)) {
-			ast_log(LOG_WARNING, "Unable to set '%s' to linear format (write)\n", chan->name);
-			free(chan->music_state);
-			chan->music_state = NULL;
-		} else {
-			if (option_verbose > 2)
-				ast_verbose(VERBOSE_PREFIX_3 "Started music on hold, class '%s', on %s\n", class->name, chan->name);
-		}
+		if (option_verbose > 2)
+			ast_verbose(VERBOSE_PREFIX_3 "Started music on hold, class '%s', on %s\n", class->name, chan->name);
 	}
 	
 	return chan->music_state;



More information about the asterisk-commits mailing list