home *** CD-ROM | disk | FTP | other *** search
/ PC Online 1999 February / PCO_0299.ISO / filesbbs / linux / mikmod-3.000 / mikmod-3 / mikmod-3.1.2 / mmio / mmerror.c < prev    next >
Encoding:
C/C++ Source or Header  |  1998-12-07  |  3.9 KB  |  154 lines

  1. /*    MikMod sound library
  2.     (c) 1998 Miodrag Vallat and others - see file AUTHORS for complete list
  3.  
  4.     This library is free software; you can redistribute it and/or modify
  5.     it under the terms of the GNU Library General Public License as
  6.     published by the Free Software Foundation; either version 2 of
  7.     the License, or (at your option) any later version.
  8.  
  9.     This program is distributed in the hope that it will be useful,
  10.     but WITHOUT ANY WARRANTY; without even the implied warranty of
  11.     MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  12.     GNU Library General Public License for more details.
  13.  
  14.     You should have received a copy of the GNU Library General Public
  15.     License along with this library; if not, write to the Free Software
  16.     Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
  17. */
  18.  
  19. /*==============================================================================
  20.  
  21.   $Id: mmerror.c,v 1.18 1998/12/07 06:00:39 miod Exp $
  22.  
  23.   Error handling functions for use with the MMIO and MikMod libraries.
  24.   Register an error handler with _mm_RegisterErrorHandler() and you're all set.
  25.  
  26. ==============================================================================*/
  27.  
  28. /*
  29.  
  30.     The global variables _mm_errno, and _mm_critical are set before the error
  31.     handler in called.  See below for the values of these variables.
  32.  
  33. */
  34.  
  35. #ifdef HAVE_CONFIG_H
  36. #include "config.h"
  37. #endif
  38.  
  39. #include <mikmod_internals.h>
  40.  
  41. CHAR *_mm_errmsg[MMERR_MAX+1] =
  42. {
  43. /* No error */
  44.  
  45.     "No error",
  46.  
  47. /* Generic errors */
  48.  
  49.     "Could not open requested file",
  50.     "Out of memory",
  51.  
  52. /* Sample errors */
  53.  
  54.     "Out of memory to load sample",
  55.     "Out of sample handles to load sample",
  56.     "Sample format not recognized",
  57.  
  58. /* Module errors */
  59.  
  60.     "Failure loading module pattern",
  61.     "Failure loading module track",
  62.     "Failure loading module header",
  63.     "Failure loading sampleinfo",
  64.     "Module format not recognized",
  65.     "Module sample format not recognized",
  66.     "Synthsounds not supported in MED files",
  67.     "Compressed sample is invalid",
  68.  
  69. /* Driver errors: */
  70.  
  71.     "Sound device not detected",
  72.     "Device number out of range",
  73.     "Software mixer failure",
  74.     "Could not open sound device",
  75.     "This driver supports 16 bit linear output only",
  76.     "Unable to set non-blocking mode for audio device",
  77.  
  78. /* AudioFile driver errors  */
  79.  
  80.     "Cannot find suitable AudioFile audio port",
  81.  
  82. /* AIX driver errors */
  83.  
  84.     "Configuration (init step)of audio device failed",
  85.     "Configuration (control step) of audio device failed",
  86.     "Configuration (start step) of audio device failed",
  87.  
  88. /* ALSA driver errors */
  89.  
  90. /* EsounD driver errors */
  91.  
  92. /* HP driver errors  */
  93.  
  94.     "Unable to select 16bit-linear sample format",
  95.     "Could not select requested sample-rate",
  96.     "Could not select requested number of channels",
  97.     "Unable to select audio output",
  98.     "Unable to get audio description",
  99.     "Unable to get gain values",
  100.     "Unable to set gain values",
  101.     "Could not set transmission buffer size",
  102.  
  103. /* Open Sound System driver errors */
  104.  
  105.     "Could not set fragment size",
  106.     "Could not set sample size",
  107.     "Could not set mono/stereo setting",
  108.     "Could not set sample rate",
  109.  
  110. /* SGI driver errors */
  111.  
  112.     "Unsupported sample rate",
  113.     "Hardware does not support 16 bit sound",
  114.     "Hardware does not support 8 bit sound",
  115.     "Hardware does not support stereo sound",
  116.     "Hardware does not support mono sound",
  117.  
  118. /* Sun driver errors */
  119.  
  120.     "Sound device initialization failed",
  121.     "16 bit sound is not supported with uLaw encoding",
  122.  
  123. /* OS/2 drivers errors */
  124.  
  125.     "Could not set mixing parameters",
  126.     "Could not create playback semaphores",
  127.     "Could not create playback timer",
  128.     "Could not create playback thread",
  129.  
  130. /* Invalid error */
  131.  
  132.     "Invalid error code"
  133. };
  134.  
  135. char *MikMod_strerror(int code)
  136. {
  137.     if ((code<0)||(code>MMERR_MAX)) code=MMERR_MAX+1;
  138.     return _mm_errmsg[code];
  139. }
  140.  
  141. /* User installed error callback */
  142. MikMod_handler_t _mm_errorhandler = NULL;
  143. int  _mm_errno = 0;
  144. BOOL _mm_critical = 0;
  145.  
  146. MikMod_handler_t MikMod_RegisterErrorHandler(MikMod_handler_t proc)
  147. {
  148.     MikMod_handler_t oldproc=_mm_errorhandler;
  149.  
  150.     _mm_errorhandler = proc;
  151.     return oldproc;
  152. }
  153.  
  154.