Intel 05-1832-002 IP Phone User Manual


 
370 Voice API for Windows Operating Systems Library Reference — November 2003
dx_setdevuio( ) — install and retrieve user-defined I/O functions
!
!!
! Cautions
The DX_UIO structure pointed to by devuiop must not be altered until the next call to
dx_setdevuio( ) with new values for user-defined I/O functions.
For proper operation, it is the application’s responsibility to properly define the three DX_UIO
user routines: u_read, u_write and u_seek. NULL is not permitted for any function. Refer to
DX_UIO, on page 519 for more information.
On DM3 boards, user-defined I/O functions installed by dx_setdevuio( ) are called in a
different thread than the main application thread. If data is being shared among these threads,
the application must carefully protect access to this data using appropriate synchronization
mechanisms (such as mutex) to ensure data integrity.
!
!!
! Errors
If the function returns -1 to indicate an error, use the SRL Standard Attribute function
ATDV_LASTERR( ) to obtain the error code or you can use ATDV_ERRMSGP( ) to obtain a
descriptive error message. The error codes returned by ATDV_LASTERR( ) are:
EDX_BADDEV
Invalid device descriptor
EDX_BADPARM
Invalid parameter
!
!!
! Example
#include "windows.h"
#include "srllib.h"
#include "dxxxlib.h"
int chdev; /* channel descriptor */
DX_UIO devio; /* User defined I/O functions */
DX_UIO *getiop; /* Retrieve I/O functions */
int appread(fd, ptr, cnt)
int fd;
char *ptr;
unsigned cnt;
{
printf("appread: Read request\n");
return(read(fd, ptr, cnt));
}
int appwrite(fd, ptr, cnt)
int fd;
char *ptr;
unsigned cnt;
{
printf("appwrite: Write request\n");
return(write(fd, ptr, cnt));
}
int appseek(fd, offset, whence)
int fd;
long offset;
int whence;
{
printf("appseek: Seek request\n");
return(lseek(fd, offset, whence));
}