ctaLoadParameterFile

Loads and changes parameter default values.

Prototype

DWORD ctaLoadParameterFile ( CTAHD ctahd, char *filename)

Argument

Description

ctahd

Context handle that specifies the server on which commands are executed. ctahd can be a void context handle.

filename

Pointer to the full or partial file name of the file. If a path is specified, only that path is searched. If the filename is specified without a path, the path specified in the CTA_DPATH environment variable is searched.


Return values

Return value

Description

SUCCESS

 

CTAERR_BAD_ARGUMENT

filename is NULL or is too long.

CTAERR_FILE_NOT_FOUND

filename is not found.

CTAERR_INVALID_CTAHD

An invalid context handle was passed as an argument to a function, or the context was destroyed by another thread.

CTAERR_INVALID_SYNTAX

Syntax error occurred in the parameter file. To debug the error, use ctdaemon.

CTAERR_NOT_FOUND

Specified parameter name is not found in the file. To debug the error, use ctdaemon.

CTAERR_NOT_INITIALIZED

Natural Access is not initialized. Call ctaInitialize first.

CTAERR_SVR_COMM

Server communication error.


Details

ctaLoadParameterFile loads and changes parameter default values specified in filename to the specified ctahd. Default values can be changed on a context specific-basis or on an application-wide basis anytime after a service is initialized, the event queue and the context are created, and services are opened.

The file parameter default syntax is: ServiceName.ParameterName.FieldName = Value.

For example:

adi.play.speed = 125
adi.play.gain = 50

If a file contains a section header, default parameter overrides must be preceded by [ctapar]. Use this value for placing parameter overrides in cta.cfg. For example:

[ctasys]
Service = adi, adimgr
Service = swi, swimgr
Service = vce, vcemgr
[ctapar]
adi.play.speed = 125
adi.play.gain = 50

If a file does not contain a section header, the entire file is considered to be a default parameter override file. For example:

adi.play.mask = 0x0FC0
adi.play.gain = 50
adi.play.speed = 125
adi.play.maxspeed = 200

Refer to Natural Access configuration file for more information about cta.cfg.

If ctahd is a valid context, this function modifies the parameters from the context defaults.

ctahd can be a void context handle. A void context handle refers only to the server on which the commands are executed and not to any real context object. Each server has a unique void context handle. If the void context handle is equal to NULL_CTAHD, it refers to the default server.

If a void context handle is used for ctahd, this function retrieves parameters from the global defaults and executes on the server specified by the void context handle. Global defaults are either statically defined values maintained within a process or dynamically defined values maintained by the Natural Access Server.

If the application needs to change default values on all contexts, call ctaLoadParameterFile with NULL as ctahd before calling ctaCreateContext.

Refer to Managing parameters for more information.

See also

ctaGetEventSources, ctaGetParmID, ctaGetParmInfo, ctaGetParms, ctaRefreshParms, ctaSetEventSources

Example

     [ctapar]
     vce.play.gain = 10
     vce.play.speed = 200
     vce.play.maxspeed = 200

myPlayVoxFileWithCfg plays the content of a VOX file at twice normal speed with 10 dB gain.

/*
*   play a message at the speed and
*   gain specified in filename.
*   Also wait for completion.
*/
extern CTAHD      CtaHd;
extern CTAQUEUEHD CtaQueueHd;

void myPlayVoxFileWithCfg( char *voxfile, DWORD encoding, char *cfgfile)
{
    VCEHD vh;
    CTA_EVENT event;
    unsigned message = VCE_ALL_MESSAGES;

    /* Change vce play defaults specified in filename */
    ctaLoadParameterFile( CtaHd,  cfgfile );

    vceOpenFile(CtaHd, voxfile, VCE_FILETYPE_VOX, VCE_PLAY_ONLY, encoding,
                                                                        &vh);
    vcePlayMessage (vh, message, NULL) ;
    do
    {
        ctaWaitEvent( CtaQueueHd, &event, CTA_WAIT_FOREVER);
    } while (event.id != VCEEVN_PLAY_DONE); /* Ignore other events */
}