(Page 38 of 80 in this chapter)


adiPlayFromMemory

Description

Initiates a voice play operation using data from a single memory-resident buffer.

Prototype

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

ctahd Context handle returned by adiOpenPort.

encoding Encoding type (refer to adidef.h for a complete list of ADI_ENCODING_xxx values).

buffer Pointer to voice data buffer.

bufsize Number of bytes stored at the address in buffer (bufsize can be arbitrarily large).

parms Pointer to play parameters according to the structure below (NULL uses default values):

typedef struct
{     /* parms related to adiStartPlaying:           */
 DWORD size ;    /* size of this structure           */
 DWORD DTMFabort; /* abort on DTMF;              */
 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,24,32,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

The adiPlayFromMemory starts playing a single memory-resident buffer of bufsize bytes. AG Access generates an ADIEVN_PLAY_DONE event when the function terminates. To avoid unintentionally modifying data, the application should not attempt to modify the buffer until it receives the DONE event.

See Also

adiStartPlaying, adiPlayAsync, adiStopPlaying, adiGetPlayStatus, adiGetEncodingInfo, adiModifyPlayGain, adiModifyPlaySpeed

Example


int myPlayMemory( CTAHD ctahd, unsigned encoding,
                  void *buffer, unsigned bufsize )
{
    ADI_EVENT event;

    if( adiPlayFromMemory( ctahd, encoding, buffer, bufsize, NULL ) != SUCCESS)
        return MYFAILURE;

    do 
    {
        myGetEvent( &event );           /* see adiFetchAndProcess example */
    } while( event.id != ADIEVN_PLAY_DONE );

    if( event.value == CTA_REASON_RELEASED )
        return MYDISCONNECT;            /* call has been terminated */
    else if( IS_ADI_ERROR( event.value ) )
        return MYFAILURE;               /* API error */
    else
        return SUCCESS;                 /* stopped normally */
}




(Page 38 of 80 in this chapter)


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