adiPlayFromMemory

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

Supported board types

Prototype

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

Argument

Description

ctahd

Context handle returned by ctaCreateContext or ctaAttachContext.

encoding

Encoding type. See Voice encoding formats for a complete list.

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 following structure (NULL uses default values):

typedef struct
{                 /* parms related to adiStartPlaying*/
  DWORD size ;    /* size of this structure          */
  DWORD DTMFabort;/* abort on DTMF;                  */
  INT32 gain;     /* Recording gain in dB            */
  DWORD speed;    /* initial speed in percent        */
  DWORD maxspeed; /* maximum play speed in percent   */

} ADI_PLAY_PARMS;

Note: Fields in bold are not applicable to the native play and record feature.

Refer to ADI_PLAY_PARMS for field descriptions and valid values.

Return values

Return value

Description

SUCCESS

 

ADIERR_INVALID_CALL_STATE

Function not valid in the current call state.

CTAERR_BAD_ARGUMENT

Either invalid encoding or NULL buffer.

CTAERR_FUNCTION_ACTIVE

Function already started.

CTAERR_INVALID_CTAHD

Context handle is invalid.

CTAERR_INVALID_STATE

Function not valid in the current port state.

CTAERR_OUTPUT_ACTIVE

Play failed because there is another active output function.

CTAERR_SVR_COMM

Server communication error.

Events

Event

Description

ADIEVN_PLAY_DONE

Generated by the ADI service when playing terminates. The event size field contains the total number of bytes played during the function instance. The event value field contains one of the following terminating conditions, or an error code:

CTA_REASON_DIGIT

Aborted due to DTMF.

CTA_REASON_FINISHED

Complete buffer played.

CTA_REASON_RECOGNITION

Aborted because of speech recognition.

CTA_REASON_RELEASED

Call terminated.

CTA_REASON_STOPPED

Stopped by application request.

Details

When recording or playing speech files on AG boards, a specific DSP file must be loaded for each encoding type. For more information, refer to Voice encoding formats.

When recording or playing speech files on CG boards, a specific DSP file must be loaded for each encoding type except when using the native play and record feature. The native play and record feature combines an ADI port with an MSPP endpoint and plays or records speech data directly to or from an IP endpoint with no transcoding. For information on the native play and record feature, refer to Performing NMS native play and record.

For more information, see Encoding formats and DSP files. The table lists the DSP files that must be loaded on the AG and CG boards. Refer to the board installation and developer's manual for MIPS usage.

adiPlayFromMemory starts playing a single memory-resident buffer of bufsize bytes. The ADI service generates ADIEVN_PLAY_DONE when the function terminates. To avoid unintentionally modifying data, the application must not modify the buffer until it receives the DONE event.

For more information, refer to Playing.

See also

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

Example

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

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

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

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