1.1.3.8.2 DRV_GENERICCODEC_BUFFER_EVENT_HANDLER Type
Pointer to a Generic Codec Driver Buffer Event handler function
Description
Generic Codec Driver Buffer Event Handler Function
This data type defines the required function signature for the Generic Codec driver buffer event handling callback function. A client must register a pointer to a buffer event handling function who's function signature (parameter and return value types) match the types specified by this function pointer in order to receive buffer related event calls back from the driver.
The parameters and return values are described here and a partial example implementation is provided.
Parameters
Parameters | Description |
---|---|
event | Identifies the type of event |
bufferHandle | Handle identifying the buffer to which the event relates |
context | Value identifying the context of the application that registered the event handling function. |
Returns
None.
Remarks
If the event is DRV_GENERICCODEC_BUFFER_EVENT_COMPLETE, this means that the data was transferred successfully.
If the event is DRV_GENERICCODEC_BUFFER_EVENT_ERROR, this means that the data was not transferred successfully.
The bufferHandle parameter contains the buffer handle of the buffer that failed. The DRV_GENERICCODEC_BufferProcessedSizeGet() function can be called to find out how many bytes were processed.
The bufferHandle parameter contains the buffer handle of the buffer that associated with the event.
The context parameter contains a handle to the client context, provided at the time the event handling function was registered using the DRV_GENERICCODEC_BufferEventHandlerSet function. This context handle value is passed back to the client as the "context" parameter. It can be any value necessary to identify the client context or instance (such as a pointer to the client's data) instance of the client that made the buffer add request.
The buffer handle in bufferHandle expires after this event handler exits. In that the buffer object that was allocated is deallocated by the driver after the event handler exits.
The event handler function executes in the data driver(i2S) peripheral's interrupt context when the driver is configured for interrupt mode operation. It is recommended of the application to not perform process intensive or blocking operations with in this function.
DRV_GENERICCODEC_BufferAddWrite function can be called in the event handler to add a buffer to the driver queue.
Example
void DRV_GENERICCODECBufferEventHandler( DRV_GENERICCODEC_BUFFER_EVENT event, DRV_GENERICCODEC_BUFFER_HANDLE bufferHandle, uintptr_t context ) {
MY_APP_DATA_STRUCT pAppData = (MY_APP_DATA_STRUCT) context; switch(event) { case DRV_GENERICCODEC_BUFFER_EVENT_COMPLETE: _// Handle the completed buffer._ break; case DRV_GENERICCODEC_BUFFER_EVENT_ERROR: default: _// Handle error._ break; }
}
C
typedef void (* DRV_GENERICCODEC_BUFFER_EVENT_HANDLER)(DRV_GENERICCODEC_BUFFER_EVENT event, DRV_GENERICCODEC_BUFFER_HANDLE bufferHandle, uintptr_t contextHandle);