Development guidelines – Sundance SMT6035 v.2.2 User Manual

Page 27

Advertising
background image

Version 2.2

Page 27 of 39

SMT6035 User Manual

pHsc

Is a pointer to the HSC object.

Code

Is a value specified by the DSP.

Arg

Is a value specified by the DSP.

hCancel

Is an event that can be set at any time to signal
the handler to terminate.

The handler function needs to process control words from the DSP, and
will always take the following form:

Try {

Control = GetControlFromDSP().

If(control == HSC_CloseHanlder )

{

Cleanup

Return HSC_HANDLER_OK;

}

Process the control word.

Send reply back to DSP

}

catch( SMTExc &e)

{

cleanup

throw e

}

15.5.5 Development

guidelines

An exception mechanism is used to implement the handler code.
A handler can throw an exception of type SMTExc at any time. If your
handler has any cleanup to do, you need to catch this type of exception
and perform any cleanup necessary.

Along with the other parameters passed into the HandlerEntry()
function, a handle value of an event is passed to indicate to the handler
that it needs to terminate. Whenever you wait for an event in the
handler, you need to also wait for this cancellation handle. If this
cancellation event gets signalled, the handler needs to return
immediately with the value HSC_HANDLER_CANCEL.

Your handler code may look like this:

HANDLE h[] = {hCancel,hMyEvent};

DWORD dw = WaitForMultipleObjects( 2, h, FALSE,INFINITE);

if (dw == WAIT_OBJECT_0) return HSC_HANDLER_CANCEL;


If the handler receives a HSC_CloseHandler, it should return
HSC_HANDLER_OK.

User Manual - Version 2.2, 04/01/07; © Sundance Italia S.R.L.

Advertising