ec_listen( )
Cautions | Example | Errors | See Also
Name: int ec_listen(chDev, lpSlot) Inputs: int chDev
SC_TSINFO *lpSlot Returns: 0 for success -1 for failure Includes: srllib.h dxxxlib.h eclib.h Category: routing Mode: synchronous Description
The ec_listen( ) function changes the echo-reference signal from the default reference (that is, the same channel as the play) to the specified time slot on the TDM bus.
The SC_TSINFO structure is declared as follows:
typedef struct { unsigned long sc_numts; long *sc_tsarrayp; } SC_TSINFO;The sc_numts field must be initialized with the number of TDM bus time slots requested (1 for a voice channel). The sc_tsarrayp field must be initialized with a pointer to a valid array. Upon return from the function, the array contains the time slot on which the voice channel transmits.
For more information, see the SCbus Routing Function Reference.
Parameter
Description
chDev The channel device handle obtained when the CSP-capable device is opened using dx_open( ). lpSlot A pointer to the SC_TSINFO data structure. Cautions
- This function fails if you specify an invalid channel device handle.
- For SpringWare boards, if you set ec_setparm( ) parameters for use with ec_listen( ), you must do so in a specific order:
- Set DXCH_EC_TAP_LENGTH as needed. (The echo canceller, ECCH_ECHOCANCELLER, is enabled by default, so you do not need to specify this parameter in your application.)
- Call ec_listen( ).
- Set ECCH_NLP off (ECCH_NLP = 1).
- Specify other parameters as needed.
- In Linux applications that use multiple threads, you must avoid having two or more threads call functions that send commands to the same channel; otherwise, the replies can be unpredictable and cause those functions to time out. If you must do this, use semaphores to prevent concurrent access to a particular channel.
Example
#include <windows.h> /* include in Windows applications only; exclude in Linux */ #include <stdio.h> #include <srllib.h> #include <dxxxlib.h> #include <eclib.h> #include <errno.h> /* include in Linux applications only; exclude in Windows */ main() { int chdev1,chdev2; /* Channel device handles */ SC_TSINFO sc_tsinfo; /* Time slot information structure */ long scts; /* SCbus time slot */ /* Open board 1 channel 1 device */ chdev1 = dx_open("dxxxB1C1", NULL); if (chdev1 < 0) { printf("Error %d in dx_open(dxxxB1C1)\n",chdev1); exit(-1); } /* Open board 1 channel 2 device */ chdev2 = dx_open("dxxxB1C2", NULL); if (chdev2 < 0) { printf("Error %d in dx_open(dxxxB1C1)\n",chdev2); exit(-1); } /* Set DXCH_EC_TAP_LENGTH as needed */ ret = ec_setparm( ... ); /* Get second channel's vox transmit time slot */ sc_tsinfo.sc_numts = 1; sc_tsinfo.sc_tsarrayp = &scts; if (dx_getxmitslot(chdev2, &sc_tsinfo) == -1) { printf("Error in dx_getxmitslot(chdev2, &sc_tsinfo). Err Msg = %s\n", ATDV_ERRMSGP(chdev2)); } /* Make first channel's ec listen to second channel's vox transmit time slot */ if (ec_listen(chdev1, &sc_tsinfo) == -1) { printf("Error in ec_listen(chdev1, &sc_tsinfo). Err Msg = %s\n", ATDV_ERRMSGP(chdev1)); } /* Set ECCH_NLP off and set other desired parameters */ ret = ec_setparm( ... ); } }Errors
If the function returns -1, use ATDV_LASTERR( ) to return the error code and ATDV_ERRMSGP( ) to return a descriptive error message.
One of the following error codes may be returned:
Error code
Reason
EDX_BADDEV Device handle is NULL or invalid. EDX_BADPARM Time slot pointer information is NULL or invalid. EEC_UNSUPPORTED Device handle is valid but device does not support CSP. See Also
Click here to contact Dialogic Customer Engineering
Copyright 2001, Intel Corporation