Interrupt Handling in Audio Drivers

The MDD layer is responsible for interrupt handling. It creates and manages the audio driver’s interrupt service thread (IST). The IST calls the PDD_AudioGetInterruptType function to determine the cause of the audio interrupt. Based on the interrupt type, the MDD either performs a callback to the Wave API Manager or sends more data or buffer space to the PDD to be played or recorded.

The PDD layer can support simultaneous playing and recording with one interrupt by merging the recording and playing status in the AUDIO_STATE return value for PDD_AudioGetInterruptType. The value can represent a state change of either the playing or recording hardware, or both. The lower 4 bits of the return code represent the input status, and the upper 4 bits represent the output status. If the current interrupt is for both recording and playing, the values can be combined using the logical OR operator. However, if the interrupt requires only one operation, the other 4 bits should remain 0; otherwise, the MDD interprets this as a change or update in the hardware’s status.

If your audio device uses more than one hardware interrupt, typically one for playing and one for recording, the driver’s interrupt service routines (ISRs) should both return the interrupt ID specified by the PDD layer. When PDD_AudioGetInterruptType is called to determine the cause of the interrupt, the function can access the hardware to determine the actual playing or recording status for each interrupt event. If this mechanism is not suitable for your audio device, you must modify the sample MDD layer to handle multiple virtual interrupts and multiple ISTs.