*nix Documentation Project
·  Home
 +   man pages
·  Linux HOWTOs
·  FreeBSD Tips
·  *niX Forums

  man pages->IRIX man pages -> audiofile/AFseterrorhandler (3d)              
Title
Content
Arch
Section
 

Contents


afSetErrorHandler(3dm)					afSetErrorHandler(3dm)


NAME    [Toc]    [Back]

     afSetErrorHandler - supply	an alternate error reporting routine to	the
     Audio File	Library

SYNOPSIS    [Toc]    [Back]

     #include <dmedia/audiofile.h>

     AFerrfunc afSetErrorHandler(AFerrfunc efunc)    [Toc]    [Back]

PARAMETER    [Toc]    [Back]

     efunc	 is a pointer to an error handling routine which is declared
		 as:

		 void errorfunc(long, const char*)

RETURNED VALUE    [Toc]    [Back]

     The returned value	is a pointer to	the previous error handling routine.

DESCRIPTION    [Toc]    [Back]

     afSetErrorHandler() 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.

EXAMPLE    [Toc]    [Back]

	 #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 */
	 ...

CAVEATS    [Toc]    [Back]

     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:





									Page 1






afSetErrorHandler(3dm)					afSetErrorHandler(3dm)



     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 -ldmedia to its link list	if it calls
     dmGetError().  See	dmGetError(3dm)	for more details on this alternative.

SEE ALSO    [Toc]    [Back]

      
      
     stdarg(5),	afIntro(3dm), dmIntro(3dm), dmGetError(3dm)
afSetErrorHandler(3dm)					afSetErrorHandler(3dm)


NAME    [Toc]    [Back]

     afSetErrorHandler - supply	an alternate error reporting routine to	the
     Audio File	Library

SYNOPSIS    [Toc]    [Back]

     #include <dmedia/audiofile.h>

     AFerrfunc afSetErrorHandler(AFerrfunc efunc)    [Toc]    [Back]

PARAMETER    [Toc]    [Back]

     efunc	 is a pointer to an error handling routine which is declared
		 as:

		 void errorfunc(long, const char*)

RETURNED VALUE    [Toc]    [Back]

     The returned value	is a pointer to	the previous error handling routine.

DESCRIPTION    [Toc]    [Back]

     afSetErrorHandler() 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.

EXAMPLE    [Toc]    [Back]

	 #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 */
	 ...

CAVEATS    [Toc]    [Back]

     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:





									Page 1






afSetErrorHandler(3dm)					afSetErrorHandler(3dm)



     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 -ldmedia to its link list	if it calls
     dmGetError().  See	dmGetError(3dm)	for more details on this alternative.

SEE ALSO    [Toc]    [Back]

      
      
     stdarg(5),	afIntro(3dm), dmIntro(3dm), dmGetError(3dm)


									PPPPaaaaggggeeee 2222
[ Back ]
 Similar pages
Name OS Title
alSetErrorHandler IRIX establish an alternate audio error handling routine
ALseterrorhandler IRIX (obsolete) establish an alternate audio error handling routine
clSetErrorHandler IRIX Select an alternate error handling routine
alGetErrorString IRIX get a string corresponding to an Audio Library error code
AFintro IRIX Introduction to the Silicon Graphics Audio File Library (AF)
afQuery IRIX retrieve static parameters associated with the Audio File Library formats
com_err OpenBSD common error display routine
com_err FreeBSD common error display routine
AFwriteframes IRIX write audio sample frames to a specified track in an audio file
AFreadframes IRIX read sample frames from a specified audio track in an audio file
Copyright © 2004-2005 DeniX Solutions SRL
newsletter delivery service