home *** CD-ROM | disk | FTP | other *** search
-
-
-
- aaaaffffSSSSeeeettttEEEErrrrrrrroooorrrrHHHHaaaannnnddddlllleeeerrrr((((3333ddddmmmm)))) aaaaffffSSSSeeeettttEEEErrrrrrrroooorrrrHHHHaaaannnnddddlllleeeerrrr((((3333ddddmmmm))))
-
-
-
- NNNNAAAAMMMMEEEE
- afSetErrorHandler - supply an alternate error reporting routine to the
- Audio File Library
-
- SSSSYYYYNNNNOOOOPPPPSSSSIIIISSSS
- ####iiiinnnncccclllluuuuddddeeee <<<<ddddmmmmeeeeddddiiiiaaaa////aaaauuuuddddiiiiooooffffiiiilllleeee....hhhh>>>>
-
- AAAAFFFFeeeerrrrrrrrffffuuuunnnncccc aaaaffffSSSSeeeettttEEEErrrrrrrroooorrrrHHHHaaaannnnddddlllleeeerrrr((((AAAAFFFFeeeerrrrrrrrffffuuuunnnncccc eeeeffffuuuunnnncccc))))
-
- PPPPAAAARRRRAAAAMMMMEEEETTTTEEEERRRR
- _e_f_u_n_c is a pointer to an error handling routine which is declared
- as:
-
- vvvvooooiiiidddd eeeerrrrrrrroooorrrrffffuuuunnnncccc((((lllloooonnnngggg,,,, ccccoooonnnnsssstttt cccchhhhaaaarrrr****))))
-
- RRRREEEETTTTUUUURRRRNNNNEEEEDDDD VVVVAAAALLLLUUUUEEEE
- The returned value is a pointer to the previous error handling routine.
-
- DDDDEEEESSSSCCCCRRRRIIIIPPPPTTTTIIIIOOOONNNN
- aaaaffffSSSSeeeettttEEEErrrrrrrroooorrrrHHHHaaaannnnddddlllleeeerrrr(((()))) allows you to override the default error handling
- routine.
-
- The arguments that are passed to the error handling routine are an error
- code and a string containing a description of the error.
-
- EEEEXXXXAAAAMMMMPPPPLLLLEEEE
- #include <dmedia/audiofile.h>
- AFerrfunc defaultErrorHandler;
- void silentAFerror(long errnum, const char* fmt)
- {
- /* suppress AF errors here */
- }
- ...
- /* supply a new error handler */
- defaultErrorHandler = afSetErrorHandler(silentAFerror);
- /* AF errors won't be reported here */
- ...
- /* restore the default error handler */
- afSetErrorHandler(originalErrorHandler);
- /* AF errors will be reported by the default error handler */
- ...
-
- CCCCAAAAVVVVEEEEAAAATTTTSSSS
- The AF library error handler function pointer is declared as a global
- variable, and therefor is not safe for use in multi-threaded
- applications. Specifically, a core dump may result if more than one
- thread attempts to use the error handler simultaneously. This can be
- avoided by calling afSetErrorHandler(NULL) to disable the feature
- entirely. The current version of the AF library has a MT-safe
- alternative to the AFerrorhandler:
-
-
-
-
-
- PPPPaaaaggggeeee 1111
-
-
-
-
-
-
- aaaaffffSSSSeeeettttEEEErrrrrrrroooorrrrHHHHaaaannnnddddlllleeeerrrr((((3333ddddmmmm)))) aaaaffffSSSSeeeettttEEEErrrrrrrroooorrrrHHHHaaaannnnddddlllleeeerrrr((((3333ddddmmmm))))
-
-
-
- After disabling the internal error handler as shown above, an application
- should handle errors as in the example below:
- #include <dmedia/dmedia.h>
-
- AFfilehandle handle;
-
- handle = afOpenFile("some_filename", "r", NULL); /* attempt to open */
-
- if(handle == NULL) {
- char detail[DM_MAX_ERROR_DETAIL]; /* storage for error detail */
- int errorNumber; /* error token storage */
- char *msg; /* short error message */
- msg = dmGetError(&errorNumber, detail);
- if(msg != NULL) /* if NULL, no error was reported */
- fprintf(stderr, "%s [error number %d]\n", detail, errorNumber);
-
- exit(1); /* or whatever */
- }
- The application must add ----llllddddmmmmeeeeddddiiiiaaaa to its link list if it calls
- dmGetError(). See ddddmmmmGGGGeeeettttEEEErrrrrrrroooorrrr(3dm) for more details on this alternative.
-
- SSSSEEEEEEEE AAAALLLLSSSSOOOO
- stdarg(5), afIntro(3dm), dmIntro(3dm), dmGetError(3dm)
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
- PPPPaaaaggggeeee 2222
-
-
-
-