[asterisk-dev] ast_frame allocation/free question

Kevin P. Fleming kpfleming at digium.com
Tue Nov 27 14:42:22 CST 2007

Simon Perreault wrote:

> This is getting me very confused. Isn't it exactly the same situation that the 
> app faces? Once the app has fed the channel a frame of audio data, how could 
> it possibly know that the frame is no longer needed?

Because the channel driver has *ZERO* input into whether the frame is
still needed or not; the channel API explicitly defines that a frame of
data passed to it is NOT consumed. If the channel driver were to consume
it, then you wouldn't be able to write the frame to two places (for
example) without copying it.

In Asterisk, when you read a frame of data from a channel, you are
handed responsibility for controlling that frame's lifetime. That's just
how it works.

Kevin P. Fleming
Director of Software Technologies
Digium, Inc. - "The Genuine Asterisk Experience" (TM)

More information about the asterisk-dev mailing list