[asterisk-dev] when to lock a channel

lumen lumen at bulma.net
Wed May 7 11:16:33 CDT 2008

On Wednesday 07 May 2008 05:36:09 pm Russell Bryant wrote:
> lumen wrote:
> > There is a way or notation to know if a function in channel.h, features.h
> > or whatever needs a channel lock previous to be called?
> The doxygen documentation _should_ indicate that.  However, in most cases
> it does not.  I have added it in some places, but there is more to do. 
> Patches to improve the documentation are certainly welcome!

Ok. That question comes to me becouse I'm modifiying PlayDtmf manager action 
(app_senddtmf.c) to support a sequence of dtmf characters to be send to a 
channel, instead of accepting only on digit at a time. I do this calling 
ast_stream_dtmf instead ast_send_digit in the code of PlayDtmf. 

Original code of PlayDtmf manager action, lock the channel previous to call 
ast_send_digit, and I don't know if I have to do the same with 

> > There is a problem if many threads call ast_write(chan,frame) in the same
> > channel ?
> No, ast_write() locks the channel.  However, I do wonder why you would ever
> write code such that multiple threads are writing to the same channel ...

When a channel get bridged to another using Bridge manager action, a thread is 
created to manage that bridge. That thread calls ast_write on both channels 
to transfer frames between them.

I was wondering if it's possible from PlayDtmf manager action to, instead of 
locking the channel and call ast_stream_dtmf, queuing dtmf frames to channel 
throung ast_write.

Maybe that idea seams stupid. I'm browsing the asterisk source code only for 
few days.

More information about the asterisk-dev mailing list