# adiStopToneDetector

Stops a precise tone detector.

#### Supported board types

- AG

- CG

#### Prototype

DWORD adiStopToneDetector ( CTAHD ctahd, unsigned toneid)

Argument | Description
ctahd | Context handle returned by ctaCreateContext or ctaAttachContext.
toneid | A specified instance of the detector to stop. Current range is 1 through 6, and corresponds to the toneid passed to adiStartToneDetector.

#### Return values

Return value | Description
SUCCESS |
CTAERR_FUNCTION_NOT_ACTIVE | Attempt made to stop a function that was not running.
CTAERR_INVALID_CTAHD | Context handle is invalid.
CTAERR_INVALID_SEQUENCE | Attempt made to stop a function that is already being stopped.
CTAERR_INVALID_STATE | Function not available in the current port state.
CTAERR_SVR_COMM | Server communication error.

#### Events

Event | Description
ADIEVN_TONE_1_DETECT_DONE | Precise tone detector 1 terminated.
ADIEVN_TONE_2_DETECT_DONE | Precise tone detector 2 terminated.
ADIEVN_TONE_3_DETECT_DONE | Precise tone detector 3 terminated.
ADIEVN_TONE_4_DETECT_DONE | Precise tone detector 4 terminated.
ADIEVN_TONE_5_DETECT_DONE | Precise tone detector 5 terminated.
ADIEVN_TONE_6_DETECT_DONE | Precise tone detector 6 terminated.

#### Details

Use adiStopToneDetector to deactivate a precise tone detector. When the detector stops, the ADI service generates a DONE event with the value field set to CTA_REASON_STOPPED. A specific DONE event is defined for each of six precise tone detectors.

You can restart the tone detector specified by the toneid when you receive the DONE event.

For more information, refer to Detecting tones.

#### Example

int myStopToneDetector( CTAHD ctahd ) /* stop detector #2 */
{
CTA_EVENT event;
if( adiStopToneDetector( ctahd, 2 ) != SUCCESS )
return MYFAILURE;
while( 1 )
{
myGetEvent( &event ); /* see ctaWaitEvent example */
switch( event.id )
{
case ADIEVN_TONE_2_DETECT_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 */
break;
/* might include cases to handle disconnect, DTMFs, etc. */
}
}
}