diff --git a/app.c b/app.c
index 8897baaeba9dc07be727717828e146460b5b66e5..00267296e31bd9a4a7ebf611ae71d24f5579ea4b 100644
--- a/app.c
+++ b/app.c
@@ -1042,7 +1042,7 @@ int ast_app_group_get_count(const char *group, const char *category)
  		test = pbx_builtin_getvar_helper(chan, cat);
 		if (test && !strcasecmp(test, group))
  			count++;
-		ast_mutex_unlock(&chan->lock);
+		ast_channel_unlock(chan);
 	}
 
 	return count;
@@ -1072,7 +1072,7 @@ int ast_app_group_match_get_count(const char *groupmatch, const char *category)
 		test = pbx_builtin_getvar_helper(chan, cat);
 		if (test && !regexec(&regexbuf, test, 0, NULL, 0))
 			count++;
-		ast_mutex_unlock(&chan->lock);
+		ast_channel_unlock(chan);
 	}
 
 	regfree(&regexbuf);
diff --git a/cli.c b/cli.c
index d46368491e5110275be5e0d7b670008bb44f4a5c..333286dad96e0bcb3c70113c2e9483e39bc1946f 100644
--- a/cli.c
+++ b/cli.c
@@ -444,7 +444,7 @@ static int handle_chanlist(int fd, int argc, char *argv[])
 			ast_cli(fd, FORMAT_STRING, c->name, locbuf, ast_state2str(c->_state), appdata);
 		}
 		numchans++;
-		ast_mutex_unlock(&c->lock);
+		ast_channel_unlock(c);
 	}
 	if (!concise) {
 		ast_cli(fd, "%d active channel%s\n", numchans, ESS(numchans));
@@ -505,7 +505,7 @@ static int handle_softhangup(int fd, int argc, char *argv[])
 	if (c) {
 		ast_cli(fd, "Requested Hangup on channel '%s'\n", c->name);
 		ast_softhangup(c, AST_SOFTHANGUP_EXPLICIT);
-		ast_mutex_unlock(&c->lock);
+		ast_channel_unlock(c);
 	} else
 		ast_cli(fd, "%s is not a known channel\n", argv[2]);
 	return RESULT_SUCCESS;
@@ -630,7 +630,7 @@ static int handle_debugchan(int fd, int argc, char *argv[])
 			c->fout |= DEBUGCHAN_FLAG;
 			ast_cli(fd, "Debugging enabled on channel %s\n", c->name);
 		}
-		ast_mutex_unlock(&c->lock);
+		ast_channel_unlock(c);
 		if (!is_all)
 			break;
 		c = ast_channel_walk_locked(c);
@@ -662,7 +662,7 @@ static int handle_nodebugchan(int fd, int argc, char *argv[])
 			c->fout &= ~DEBUGCHAN_FLAG;
 			ast_cli(fd, "Debugging disabled on channel %s\n", c->name);
 		}
-		ast_mutex_unlock(&c->lock);
+		ast_channel_unlock(c);
 		if (!is_all)
 			break;
 		c = ast_channel_walk_locked(c);
@@ -747,7 +747,7 @@ static int handle_showchan(int fd, int argc, char *argv[])
 	if(c->cdr && ast_cdr_serialize_variables(c->cdr,buf, sizeof(buf), '=', '\n', 1))
 		ast_cli(fd,"  CDR Variables:\n%s\n",buf);
 	
-	ast_mutex_unlock(&c->lock);
+	ast_channel_unlock(c);
 	return RESULT_SUCCESS;
 }
 
@@ -790,7 +790,7 @@ char *ast_complete_channels(const char *line, const char *word, int pos, int sta
 	while (ret == &notfound && (c = ast_channel_walk_locked(c))) {
 		if (!strncasecmp(word, c->name, wordlen) && ++which > state)
 			ret = ast_strdup(c->name);
-		ast_mutex_unlock(&c->lock);
+		ast_channel_unlock(c);
 	}
 	return ret == &notfound ? NULL : ret;
 }
@@ -874,7 +874,7 @@ static int group_show_channels(int fd, int argc, char *argv[])
 			}
 		}
 		numchans++;
-		ast_mutex_unlock(&c->lock);
+		ast_channel_unlock(c);
 	}
 
 	if (havepattern)
diff --git a/devicestate.c b/devicestate.c
index 4bccfa5c3c226d97f7b3b813a524be0964a5f44d..c477f98d861f7e44bf35caa4254bac4fad3d417b 100644
--- a/devicestate.c
+++ b/devicestate.c
@@ -101,7 +101,7 @@ int ast_parse_device_state(const char *device)
 	else
 		res = AST_DEVICE_INUSE;
 	
-	ast_mutex_unlock(&chan->lock);
+	ast_channel_unlock(chan);
 
 	return res;
 }
diff --git a/manager.c b/manager.c
index 033320e87741387c64331cdccd59618a41772107..06f996ab08616ae6b95ccc486c0a46252cb37a4f 100644
--- a/manager.c
+++ b/manager.c
@@ -1053,7 +1053,7 @@ static int action_hangup(struct mansession *s, struct message *m)
 		return 0;
 	}
 	ast_softhangup(c, AST_SOFTHANGUP_EXPLICIT);
-	ast_mutex_unlock(&c->lock);
+	ast_channel_unlock(c);
 	astman_send_ack(s, m, "Channel Hungup");
 	return 0;
 }
@@ -1093,7 +1093,7 @@ static int action_setvar(struct mansession *s, struct message *m)
 	pbx_builtin_setvar_helper(c, varname, varval);
 	  
 	if (c)
-		ast_mutex_unlock(&c->lock);
+		ast_channel_unlock(c);
 
 	astman_send_ack(s, m, "Variable Set");	
 
@@ -1136,7 +1136,7 @@ static int action_getvar(struct mansession *s, struct message *m)
 	}
 
 	if (c)
-		ast_mutex_unlock(&c->lock);
+		ast_channel_unlock(c);
 	astman_append(s, "Response: Success\r\n"
 		"Variable: %s\r\nValue: %s\r\n", varname, varval);
 	if (!ast_strlen_zero(id))
@@ -1227,7 +1227,7 @@ static int action_status(struct mansession *s, struct message *m)
 			c->accountcode,
 			ast_state2str(c->_state), bridge, c->uniqueid, idText);
 		}
-		ast_mutex_unlock(&c->lock);
+		ast_channel_unlock(c);
 		if (!all)
 			break;
 		c = ast_channel_walk_locked(c);
@@ -1297,9 +1297,9 @@ static int action_redirect(struct mansession *s, struct message *m)
 	} else
 		astman_send_error(s, m, "Redirect failed");
 	if (chan)
-		ast_mutex_unlock(&chan->lock);
+		ast_channel_unlock(chan);
 	if (chan2)
-		ast_mutex_unlock(&chan2->lock);
+		ast_channel_unlock(chan2);
 	return 0;
 }
 
@@ -1363,7 +1363,7 @@ static void *fast_originate(void *data)
 
 	/* Locked by ast_pbx_outgoing_exten or ast_pbx_outgoing_app */
 	if (chan)
-		ast_mutex_unlock(&chan->lock);
+		ast_channel_unlock(chan);
 	free(in);
 	return NULL;
 }
@@ -1626,7 +1626,7 @@ static int action_timeout(struct mansession *s, struct message *m)
 		return 0;
 	}
 	ast_channel_setwhentohangup(c, timeout);
-	ast_mutex_unlock(&c->lock);
+	ast_channel_unlock(c);
 	astman_send_ack(s, m, "Timeout Set");
 	return 0;
 }
diff --git a/pbx.c b/pbx.c
index 82d8ed37d462325e88a4fb4e8bfaac7720faffd1..866967ca9209b77e5dccb75de39d8b2030681613 100644
--- a/pbx.c
+++ b/pbx.c
@@ -4147,7 +4147,7 @@ int ast_async_goto(struct ast_channel *chan, const char *context, const char *ex
 {
 	int res = 0;
 
-	ast_mutex_lock(&chan->lock);
+	ast_channel_lock(chan);
 
 	if (chan->pbx) {
 		/* This channel is currently in the PBX */
@@ -4174,9 +4174,9 @@ int ast_async_goto(struct ast_channel *chan, const char *context, const char *ex
 			ast_channel_masquerade(tmpchan, chan);
 		
 			/* Grab the locks and get going */
-			ast_mutex_lock(&tmpchan->lock);
+			ast_channel_lock(tmpchan);
 			ast_do_masquerade(tmpchan);
-			ast_mutex_unlock(&tmpchan->lock);
+			ast_channel_unlock(tmpchan);
 			/* Start the PBX going on our stolen channel */
 			if (ast_pbx_start(tmpchan)) {
 				ast_log(LOG_WARNING, "Unable to start PBX on %s\n", tmpchan->name);
@@ -4185,7 +4185,7 @@ int ast_async_goto(struct ast_channel *chan, const char *context, const char *ex
 			}
 		}
 	}
-	ast_mutex_unlock(&chan->lock);
+	ast_channel_unlock(chan);
 	return res;
 }
 
@@ -4197,7 +4197,7 @@ int ast_async_goto_by_name(const char *channame, const char *context, const char
 	chan = ast_get_channel_by_name_locked(channame);
 	if (chan) {
 		res = ast_async_goto(chan, context, exten, priority);
-		ast_mutex_unlock(&chan->lock);
+		ast_channel_unlock(chan);
 	}
 	return res;
 }
@@ -4576,7 +4576,7 @@ int ast_pbx_outgoing_exten(const char *type, int format, void *data, int timeout
 		if (channel) {
 			*channel = chan;
 			if (chan)
-				ast_mutex_lock(&chan->lock);
+				ast_channel_lock(chan);
 		}
 		if (chan) {
 			if (chan->cdr) { /* check if the channel already has a cdr record, if not give it one */
@@ -4600,7 +4600,7 @@ int ast_pbx_outgoing_exten(const char *type, int format, void *data, int timeout
 
 				if (sync > 1) {
 					if (channel)
-						ast_mutex_unlock(&chan->lock);
+						ast_channel_unlock(chan);
 					if (ast_pbx_run(chan)) {
 						ast_log(LOG_ERROR, "Unable to run PBX on %s\n", chan->name);
 						if (channel)
@@ -4613,7 +4613,7 @@ int ast_pbx_outgoing_exten(const char *type, int format, void *data, int timeout
 						ast_log(LOG_ERROR, "Unable to start PBX on %s\n", chan->name);
 						if (channel) {
 							*channel = NULL;
-							ast_mutex_unlock(&chan->lock);
+							ast_channel_unlock(chan);
 						}
 						ast_hangup(chan);
 						res = -1;
@@ -4632,7 +4632,7 @@ int ast_pbx_outgoing_exten(const char *type, int format, void *data, int timeout
 			
 				if (channel) {
 					*channel = NULL;
-					ast_mutex_unlock(&chan->lock);
+					ast_channel_unlock(chan);
 				}
 				ast_hangup(chan);
 			}
@@ -4673,7 +4673,7 @@ int ast_pbx_outgoing_exten(const char *type, int format, void *data, int timeout
 		if (channel) {
 			*channel = chan;
 			if (chan)
-				ast_mutex_lock(&chan->lock);
+				ast_channel_lock(chan);
 		}
 		if (!chan) {
 			free(as);
@@ -4694,7 +4694,7 @@ int ast_pbx_outgoing_exten(const char *type, int format, void *data, int timeout
 			free(as);
 			if (channel) {
 				*channel = NULL;
-				ast_mutex_unlock(&chan->lock);
+				ast_channel_unlock(chan);
 			}
 			ast_hangup(chan);
 			res = -1;
@@ -4783,18 +4783,18 @@ int ast_pbx_outgoing_app(const char *type, int format, void *data, int timeout,
 					tmp->chan = chan;
 					if (sync > 1) {
 						if (locked_channel)
-							ast_mutex_unlock(&chan->lock);
+							ast_channel_unlock(chan);
 						ast_pbx_run_app(tmp);
 					} else {
 						pthread_attr_init(&attr);
 						pthread_attr_setdetachstate(&attr, PTHREAD_CREATE_DETACHED);
 						if (locked_channel) 
-							ast_mutex_lock(&chan->lock);
+							ast_channel_lock(chan);
 						if (ast_pthread_create(&tmp->t, &attr, ast_pbx_run_app, tmp)) {
 							ast_log(LOG_WARNING, "Unable to spawn execute thread on %s: %s\n", chan->name, strerror(errno));
 							free(tmp);
 							if (locked_channel) 
-								ast_mutex_unlock(&chan->lock);
+								ast_channel_unlock(chan);
 							ast_hangup(chan);
 							res = -1;
 						} else {
@@ -4851,12 +4851,12 @@ int ast_pbx_outgoing_app(const char *type, int format, void *data, int timeout,
 		pthread_attr_init(&attr);
 		pthread_attr_setdetachstate(&attr, PTHREAD_CREATE_DETACHED);
 		if (locked_channel) 
-			ast_mutex_lock(&chan->lock);
+			ast_channel_lock(chan);
 		if (ast_pthread_create(&as->p, &attr, async_wait, as)) {
 			ast_log(LOG_WARNING, "Failed to start async wait\n");
 			free(as);
 			if (locked_channel) 
-				ast_mutex_unlock(&chan->lock);
+				ast_channel_unlock(chan);
 			ast_hangup(chan);
 			res = -1;
 			goto outgoing_app_cleanup;
@@ -5505,7 +5505,7 @@ int pbx_builtin_importvar(struct ast_channel *chan, void *data)
 				sprintf(s, "${%s}", value);
 				pbx_substitute_variables_helper(chan2, s, tmp, sizeof(tmp) - 1);
 			}
-			ast_mutex_unlock(&chan2->lock);
+			ast_channel_unlock(chan2);
 		}
 		pbx_builtin_setvar_helper(chan, name, tmp);
 	}
diff --git a/res/res_agi.c b/res/res_agi.c
index c1c21d707dfb25c044510db533c345bb6f36e1b0..0b88b892c6ea4832c4f22712c9dc31325efd5cea 100644
--- a/res/res_agi.c
+++ b/res/res_agi.c
@@ -1025,7 +1025,7 @@ static int handle_hangup(struct ast_channel *chan, AGI *agi, int argc, char **ar
 			/* we have a matching channel */
 			ast_softhangup(c,AST_SOFTHANGUP_EXPLICIT);
 			fdprintf(agi->fd, "200 result=1\n");
-			ast_mutex_unlock(&c->lock);
+			ast_channel_unlock(c);
 			return RESULT_SUCCESS;
 		}
 		/* if we get this far no channel name matched the argument given */
@@ -1093,7 +1093,7 @@ static int handle_channelstatus(struct ast_channel *chan, AGI *agi, int argc, ch
 		c = ast_get_channel_by_name_locked(argv[2]);
 		if (c) {
 			fdprintf(agi->fd, "200 result=%d\n", c->_state);
-			ast_mutex_unlock(&c->lock);
+			ast_channel_unlock(c);
 			return RESULT_SUCCESS;
 		}
 		/* if we get this far no channel name matched the argument given */
@@ -1155,7 +1155,7 @@ static int handle_getvariablefull(struct ast_channel *chan, AGI *agi, int argc,
 		fdprintf(agi->fd, "200 result=0\n");
 	}
 	if (chan2 && (chan2 != chan))
-		ast_mutex_unlock(&chan2->lock);
+		ast_channel_unlock(chan2);
 	return RESULT_SUCCESS;
 }
 
diff --git a/res/res_features.c b/res/res_features.c
index d2685519539dab78ee0c488cfb113ab9e5d1f511..273f311cc95260872d8db1120663b63807820a5e 100644
--- a/res/res_features.c
+++ b/res/res_features.c
@@ -1859,7 +1859,7 @@ static int manager_park(struct mansession *s, struct message *m)
 	if (!ch2) {
 		snprintf(buf, sizeof(buf), "Channel does not exist: %s", channel2);
 		astman_send_error(s, m, buf);
-		ast_mutex_unlock(&ch1->lock);
+		ast_channel_unlock(ch1);
 		return 0;
 	}
 
@@ -1875,8 +1875,8 @@ static int manager_park(struct mansession *s, struct message *m)
 		astman_send_error(s, m, "Park failure");
 	}
 
-	ast_mutex_unlock(&ch1->lock);
-	ast_mutex_unlock(&ch2->lock);
+	ast_channel_unlock(ch1);
+	ast_channel_unlock(ch2);
 
 	return 0;
 }
@@ -1895,7 +1895,7 @@ int ast_pickup_call(struct ast_channel *chan)
 			 (cur->_state == AST_STATE_RING))) {
 			 	break;
 		}
-		ast_mutex_unlock(&cur->lock);
+		ast_channel_unlock(cur);
 	}
 	if (cur) {
 		if (option_debug)
@@ -1909,7 +1909,7 @@ int ast_pickup_call(struct ast_channel *chan)
 		res = ast_channel_masquerade(cur, chan);
 		if (res)
 			ast_log(LOG_WARNING, "Unable to masquerade '%s' into '%s'\n", chan->name, cur->name);		/* Done */
-		ast_mutex_unlock(&cur->lock);
+		ast_channel_unlock(cur);
 	} else	{
 		if (option_debug)
 			ast_log(LOG_DEBUG, "No call pickup possible...\n");
diff --git a/res/res_monitor.c b/res/res_monitor.c
index e570e726b16cd903cf91588f9a4430519e9250c3..c5c8102a05ab1bb90479d2051358d717668163de 100644
--- a/res/res_monitor.c
+++ b/res/res_monitor.c
@@ -211,7 +211,7 @@ int ast_monitor_start(	struct ast_channel *chan, const char *format_spec,
 			ast_log(LOG_WARNING, "Could not create file %s\n",
 						monitor->read_filename);
 			free(monitor);
-			ast_mutex_unlock(&chan->lock);
+			ast_channel_unlock(chan);
 			return -1;
 		}
 		if (ast_fileexists(monitor->write_filename, NULL, NULL) > 0) {
@@ -224,7 +224,7 @@ int ast_monitor_start(	struct ast_channel *chan, const char *format_spec,
 						monitor->write_filename);
 			ast_closestream(monitor->read_stream);
 			free(monitor);
-			ast_mutex_unlock(&chan->lock);
+			ast_channel_unlock(chan);
 			return -1;
 		}
 		chan->monitor = monitor;
@@ -492,7 +492,7 @@ static int start_monitor_action(struct mansession *s, struct message *m)
 		/* No filename base specified, default to channel name as per CLI */		
 		if (!(fname = ast_strdup(c->name))) {
 			astman_send_error(s, m, "Could not start monitoring channel");
-			ast_mutex_unlock(&c->lock);
+			ast_channel_unlock(c);
 			return 0;
 		}
 		/* Channels have the format technology/channel_name - have to replace that /  */
@@ -503,7 +503,7 @@ static int start_monitor_action(struct mansession *s, struct message *m)
 	if (ast_monitor_start(c, format, fname, 1)) {
 		if (ast_monitor_change_fname(c, fname, 1)) {
 			astman_send_error(s, m, "Could not start monitoring channel");
-			ast_mutex_unlock(&c->lock);
+			ast_channel_unlock(c);
 			return 0;
 		}
 	}
@@ -512,7 +512,7 @@ static int start_monitor_action(struct mansession *s, struct message *m)
 		ast_monitor_setjoinfiles(c, 1);
 	}
 
-	ast_mutex_unlock(&c->lock);
+	ast_channel_unlock(c);
 	astman_send_ack(s, m, "Started monitoring channel");
 	return 0;
 }
@@ -537,7 +537,7 @@ static int stop_monitor_action(struct mansession *s, struct message *m)
 		return 0;
 	}
 	res = ast_monitor_stop(c, 1);
-	ast_mutex_unlock(&c->lock);
+	ast_channel_unlock(c);
 	if (res) {
 		astman_send_error(s, m, "Could not stop monitoring channel");
 		return 0;
@@ -574,10 +574,10 @@ static int change_monitor_action(struct mansession *s, struct message *m)
 	}
 	if (ast_monitor_change_fname(c, fname, 1)) {
 		astman_send_error(s, m, "Could not change monitored filename of channel");
-		ast_mutex_unlock(&c->lock);
+		ast_channel_unlock(c);
 		return 0;
 	}
-	ast_mutex_unlock(&c->lock);
+	ast_channel_unlock(c);
 	astman_send_ack(s, m, "Changed monitor filename");
 	return 0;
 }
@@ -617,7 +617,7 @@ static int do_pause_or_unpause(struct mansession *s, struct message *m, int acti
 	else
 		ast_monitor_unpause(c);
 	
-	ast_mutex_unlock(&c->lock);
+	ast_channel_unlock(c);
 	astman_send_ack(s, m, "Paused monitoring of the channel");
 	return 0;	
 }
diff --git a/res/snmp/agent.c b/res/snmp/agent.c
index 18260107713a402d39a233b2ac2b2a6e0ceb3f77..cb089c00741a55a98ddcf4510544b41fdf171e2c 100644
--- a/res/snmp/agent.c
+++ b/res/snmp/agent.c
@@ -216,7 +216,7 @@ static u_char *ast_var_channels_table(struct variable *vp, oid *name, size_t *le
     for (chan = ast_channel_walk_locked(NULL);
 		 chan && i;
 		 chan = ast_channel_walk_locked(chan), i--)
-		ast_mutex_unlock(&chan->lock);
+		ast_channel_unlock(chan);
     if (chan == NULL)
 		return NULL;
 	*var_len = sizeof(long_ret);
@@ -513,7 +513,7 @@ static u_char *ast_var_channels_table(struct variable *vp, oid *name, size_t *le
 		ret = NULL;
 		break;
     }
-    ast_mutex_unlock(&chan->lock);
+    ast_channel_unlock(chan);
     return ret;
 }
 
@@ -583,7 +583,7 @@ static u_char *ast_var_channel_types_table(struct variable *vp, oid *name, size_
 	case ASTCHANTYPECHANNELS:
 		long_ret = 0;
 		for (chan = ast_channel_walk_locked(NULL); chan; chan = ast_channel_walk_locked(chan)) {
-			ast_mutex_unlock(&chan->lock);
+			ast_channel_unlock(chan);
 			if (chan->tech == tech)
 				long_ret++;
 		}
diff --git a/udptl.c b/udptl.c
index 25587d90d9af219f15eb2bdbd4be0ecbd4818a0c..045c89d8f1ba057b3519a9c6c0c9fbf1482c625d 100644
--- a/udptl.c
+++ b/udptl.c
@@ -996,24 +996,24 @@ int ast_udptl_bridge(struct ast_channel *c0, struct ast_channel *c1, int flags,
 	void *pvt1;
 	int to;
 	
-	ast_mutex_lock(&c0->lock);
-	while (ast_mutex_trylock(&c1->lock)) {
-		ast_mutex_unlock(&c0->lock);
+	ast_channel_lock(c0);
+	while (ast_channel_trylock(c1)) {
+		ast_channel_unlock(c0);
 		usleep(1);
-		ast_mutex_lock(&c0->lock);
+		ast_channel_lock(c0);
 	}
 	pr0 = get_proto(c0);
 	pr1 = get_proto(c1);
 	if (!pr0) {
 		ast_log(LOG_WARNING, "Can't find native functions for channel '%s'\n", c0->name);
-		ast_mutex_unlock(&c0->lock);
-		ast_mutex_unlock(&c1->lock);
+		ast_channel_unlock(c0);
+		ast_channel_unlock(c1);
 		return -1;
 	}
 	if (!pr1) {
 		ast_log(LOG_WARNING, "Can't find native functions for channel '%s'\n", c1->name);
-		ast_mutex_unlock(&c0->lock);
-		ast_mutex_unlock(&c1->lock);
+		ast_channel_unlock(c0);
+		ast_channel_unlock(c1);
 		return -1;
 	}
 	pvt0 = c0->tech_pvt;
@@ -1022,8 +1022,8 @@ int ast_udptl_bridge(struct ast_channel *c0, struct ast_channel *c1, int flags,
 	p1 = pr1->get_udptl_info(c1);
 	if (!p0 || !p1) {
 		/* Somebody doesn't want to play... */
-		ast_mutex_unlock(&c0->lock);
-		ast_mutex_unlock(&c1->lock);
+		ast_channel_unlock(c0);
+		ast_channel_unlock(c1);
 		return -2;
 	}
 	if (pr0->set_udptl_peer(c0, p1)) {
@@ -1038,8 +1038,8 @@ int ast_udptl_bridge(struct ast_channel *c0, struct ast_channel *c1, int flags,
 		/* Store UDPTL peer */
 		ast_udptl_get_peer(p0, &ac0);
 	}
-	ast_mutex_unlock(&c0->lock);
-	ast_mutex_unlock(&c1->lock);
+	ast_channel_unlock(c0);
+	ast_channel_unlock(c1);
 	cs[0] = c0;
 	cs[1] = c1;
 	cs[2] = NULL;