Submits a buffer of data for a play operation initiated by adiPlayAsync.
AG
CG
DWORD adiSubmitPlayBuffer ( CTAHD ctahd, void *buffer, unsigned size, unsigned flags)
|
Argument |
Description |
|
ctahd |
Context handle returned by ctaCreateContext or ctaAttachContext. |
|
buffer |
Pointer to buffer containing voice data to be played. |
|
size |
Size of buffer (bytes). |
|
flags |
Set to ADI_PLAY_LAST_BUFFER if the given buffer is the last in the message; otherwise set to 0. |
|
Return value |
Description |
|
SUCCESS |
|
|
ADIERR_TOO_MANY_BUFFERS |
Application is out of synchronization with the play operation. Submit buffers only when requested. |
|
CTAERR_BAD_ARGUMENT |
buffer is NULL. |
|
CTAERR_BAD_SIZE |
size is not a multiple of framesize for the encoding in adiPlayAsync. |
|
CTAERR_FUNCTION_NOT_ACTIVE |
Either voice is not playing or the play operation was not initiated by calling adiPlayAsync. |
|
CTAERR_INVALID_CTAHD |
Context handle is invalid. |
|
CTAERR_INVALID_SEQUENCE |
adiStopPlaying was already invoked or the ADI_PLAY_LAST_BUFFER flag was already set in a previous call to adiSubmitPlayBuffer or adiPlayAsync. |
|
CTAERR_INVALID_STATE |
Function not available in the current port state. |
|
CTAERR_SVR_COMM |
Server communication error. |
|
Event |
Description |
|
ADIEVN_PLAY_BUFFER_REQ |
Generated by the ADI service when a buffer with voice data is required. |
|
ADIEVN_PLAY_DONE |
Generated by the ADI service when the play operation terminates with a reason (value field) of: CTAERR_xxx or ADIERR_xxx Play failed. CTA_REASON_DIGIT Aborted due to DTMF. CTA_REASON_FINISHED Application submitted buffer with ADI_PLAY_LAST_BUFFER set and the buffer was completely played. CTA_REASON_RELEASED Call terminated. CTA_REASON_STOPPED Stopped by application request. |
Use adiSubmitPlayBuffer to asynchronously submit buffers, provided that the:
Play operation was initiated by adiPlayAsync.
Play operation is currently active.
ADI_PLAY_LAST_BUFFER flag was not set for any buffer submission for the current playing instance.
ADI service issued ADIEVN_PLAY_BUFFER_REQ to the application and the application did not subsequently submit a buffer (only one buffer can be submitted to a play operation at a time).
size can be arbitrarily large, but must be an integral multiple of the frame size for the selected encoding. For optimum performance, size must be the largest frame multiple that will fit in one board buffer. You can obtain this size by calling adiGetEncodingInfo (refer to the maxbufsize argument). If size is less than or equal to the board buffer size, you can re-use the buffer as soon as this function returns.
buffer can be set to NULL and size set to 0 (zero) only if the ADI_PLAY_LAST_BUFFER flag is set. In this case, the play operation terminates when the previously submitted buffer finishes.
adiGetPlayStatus, adiStopPlaying
Refer to the playrec demonstration program.