(Page 37 of 80 in this chapter)


adiPlayAsync

Description

Initiates a voice play operation with asynchronous buffer submission.

Prototype

DWORD adiPlayAsync( CTAHD ctahd,
unsigned encoding,
void *buffer,
unsigned bufsize,
unsigned flags,
ADI_PLAY_PARMS *parms )

ctahd Context handle returned by adiOpenPort.

encoding Data encoding format (a complete list of ADI_ENCODING_xxx values is in adidef.h.)

buffer Pointer to initial voice data buffer.

bufsize Number of bytes stored at the address in buffer.

flags Signifies if the specified buffer is the only buffer to be played (can be set to ADI_PLAY_LAST_BUFFER or 0).

parms Pointer to play parameters according to the following structure (NULL value uses the default play parameters)

typedef struct
{
DWORD size; /* size of this structure */
DWORD DTMFabort; /* abort on DTMF; */
INT32 gain; /* playing gain in dB */
DWORD speed; /* initial speed in percent */
DWORD maxspeed; /* maximum play speed in percent */
} ADI_PLAY_PARMS;

Return Values

Events

DSP File Requirement

Each encoding rate of this function requires a specific DSP file to be loaded by agmon as shown in the following table:

DSP File

Encoding Rate

voice.dsp/voxp.dsp

ADI_ENCODE_NMS_16,

ADI_ENCODE_NMS_24,

ADI_ENCODE_NMS_32,

ADI_ENCODE_NMS_64

rvoice.dsp

ADI_ENCODE_MULAW, ADI_ENCODE_ALAW, ADI_ENCODE_PCM8M16

okiply.dsp

ADI_ENCODE_OKI_24, ADI_ENCODE_OKI_32

waveply.dsp

ADI_ENCODE_PCM11M8, ADI_ENCODE_PCM11M16

g726p.dsp

ADI_ENCODE_G726

Details

This function initiates a voice playback operation. The voice data is supplied in a sequence of buffers. The application has complete latitude and responsibility for allocating, filling, and submitting buffers to AG Access.

The bufsize can be arbitrarily large but must be an integral multiple of framesize bytes for the selected encoding. For optimum performance, the bufsize should be the largest frame multiple that will fit in one AG board buffer. You can obtain this size by calling adiGetEncodingInfo (see the maxbufsize argument). If bufsize is less than or equal to the board buffer size, you can re-use the buffer as soon as this function returns. Otherwise, to avoid overwriting data, you must wait for the second ADIEVN_PLAY_BUFFER_REQ before you can re-use the buffer.

After play initiates, AG Access sends ADIEVN_PLAY_BUFFER_REQ events to the application whenever more data is needed. The application responds to this event by submitting a filled voice buffer via adiSubmitPlayBuffer. The application should only submit buffers in response to ADIEVN_PLAY_BUFFER_REQ events.

The application "gracefully" terminates play by submitting a buffer with the flags argument set to ADI_PLAY_LAST_BUFFER. After AG Access has played the buffer that was submitted with the flag set, it generates an ADIEVN_PLAY_DONE event with the value set to CTA_REASON_FINISHED.

See the AG Access Developer's Manual for more details about play operations in asynchronous mode.

See Also

adiSubmitPlayBuffer, adiPlayFromMemory, adiStartPlaying, adiStopPlaying, adiGetEncodingInfo, adiModifyPlayGain, adiModifyPlaySpeed

Example

See the playrec demonstration program.



(Page 37 of 80 in this chapter)


Tech_Support@nmss.com
Copyright © 1996, Natural MicroSystems, Inc. All rights reserved.