There are buffers within DAHDI that get filled with data from Asterisk. When the driver has the ability to interrupt the CPU, it pushes the data out over the PCI bus to the Digium card.
There are times when the driver must wait for the kernel to finish whatever else it is doing, which is why there are different policies as well as the ability to change the number of buffers. Each policy does buffering differently to basically work around the issue of the driver not being able to write data out to the Digium card (due to the kernel doing something else at that time).
Note: This is seperate from the 'latency' kernel module option and also seperate from the jitter buffering than can be done on DAHDI channels within Asterisk.
If you see a debug message resembling this:
DEBUG[32165] chan_dahdi.c: Write returned -1 (Resource temporarily unavailable) on channel 94
Then you may need to raise the number of buffers and/or change the policy.
Buffer Policy Information
Immediate Buffer Policy | This policy means that as soon as data arrives in the buffer within DAHDI, it is immediately pushed out even if the kernel is doing something else. If the kernel is busy with something else, the data is lost and never gets to the Digium card.
Pros: Low latency Cons: Data loss
|
Full Buffer Policy | This policy means that DAHDI will wait until all it's buffers are full before it pushes any data out to the Digium card.
Pros: Little chance of data loss Cons: High latency |
Half Full Buffer Policy | This policy is a balance between the immediate and full policies. It will wait until half of the DAHDI buffers are filled before pushing the data out to the Digium card.
Pros: Less chance of data loss when compared to immediate. Lower latency when compared to full. Cons: More chance of data loss when compared to full. Higher latency when compared to immediate. |
Configuration
As of DAHDI-LINUX 2.2.0 there are a total of three buffer polcies: Immediate, Full and Half. The default policy that is used is the immediate policy with 4 buffers .
One method of configuring the buffers is to modify the chan_dahdi.conf file to add the entry, using the following syntax:
buffers=<num of buffers>,<policy>
An example of this configuration would look like this: buffers=10,half, please note that this line needs to be before the channel number in order to apply.
They can also be set in the Asterisk dialplan.
For Asterisk 1.6.2 and newer:
exten => s,n,Set(CHANNEL(buffers)=12,half)
For Asterisk 1.4
exten => s,n,Set(CHANNEL(buffers)="12,half")
The buffers element is a write-only CHANNEL parameter, so you cannot read back its current setting. There will also be no message generated to indicate success.
Faxing
If trying to fax G.711 over a Digium hardware card, you may need to set the buffers in order to help overcome latency issues or IRQ misses in the hardware.
Setting the buffers is one of the few things you can do to troubleshoot issues when faxing over hardware cards. The first steps are still of course to verify that audio calls pass fine with no audio issues, then to eliminate any missed IRQ issues, and to upgrade DAHDI to the latest possible version. Upgrading DAHDI is important in FAX troubleshooting because the audio path in general in newer versions of DAHDI is much cleaner and more reliable than in older versions. A lot of work went into DAHDI to resolve such issues in the base DAHDI code.