Add "MikMod for Rockbox 0.1" from 2007-06-29
[mikmod-rockbox.git] / apps / plugins / mikmod / mmio / mmerror.c
diff --git a/apps/plugins/mikmod/mmio/mmerror.c b/apps/plugins/mikmod/mmio/mmerror.c
new file mode 100644 (file)
index 0000000..94d0122
--- /dev/null
@@ -0,0 +1,197 @@
+/*     MikMod sound library\r
+       (c) 1998, 1999, 2000 Miodrag Vallat and others - see file AUTHORS for\r
+       complete list.\r
+\r
+       This library is free software; you can redistribute it and/or modify\r
+       it under the terms of the GNU Library General Public License as\r
+       published by the Free Software Foundation; either version 2 of\r
+       the License, or (at your option) any later version.\r
\r
+       This program is distributed in the hope that it will be useful,\r
+       but WITHOUT ANY WARRANTY; without even the implied warranty of\r
+       MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the\r
+       GNU Library General Public License for more details.\r
\r
+       You should have received a copy of the GNU Library General Public\r
+       License along with this library; if not, write to the Free Software\r
+       Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA\r
+       02111-1307, USA.\r
+*/\r
+\r
+/*==============================================================================\r
+\r
+  $Id: mmerror.c,v 1.1.1.1 2004/01/21 01:36:35 raph Exp $\r
+\r
+  Error handling functions.\r
+  Register an error handler with _mm_RegisterErrorHandler() and you're all set.\r
+\r
+==============================================================================*/\r
+\r
+/*\r
+\r
+       The global variables _mm_errno, and _mm_critical are set before the error\r
+       handler in called.  See below for the values of these variables.\r
+\r
+*/\r
+\r
+#ifdef HAVE_CONFIG_H\r
+#include "config.h"\r
+#endif\r
+\r
+#include "mikmod_internals.h"\r
+\r
+CHAR *_mm_errmsg[MMERR_MAX+1] =\r
+{\r
+/* No error */\r
+\r
+       "No error",\r
+\r
+/* Generic errors */\r
+\r
+       "Could not open requested file",\r
+       "Out of memory",\r
+       "Dynamic linking failed",\r
+\r
+/* Sample errors */\r
+\r
+       "Out of memory to load sample",\r
+       "Out of sample handles to load sample",\r
+       "Sample format not recognized",\r
+\r
+/* Module errors */\r
+\r
+       "Failure loading module pattern",\r
+       "Failure loading module track",\r
+       "Failure loading module header",\r
+       "Failure loading sampleinfo",\r
+       "Module format not recognized",\r
+       "Module sample format not recognized",\r
+       "Synthsounds not supported in MED files",\r
+       "Compressed sample is invalid",\r
+\r
+/* Driver errors: */\r
+\r
+       "Sound device not detected",\r
+       "Device number out of range",\r
+       "Software mixer failure",\r
+       "Could not open sound device",\r
+       "This driver supports 8 bit linear output only",\r
+       "This driver supports 16 bit linear output only",\r
+       "This driver supports stereo output only",\r
+       "This driver supports uLaw output (8 bit mono, 8 kHz) only",\r
+       "Unable to set non-blocking mode for audio device",\r
+\r
+/* AudioFile driver errors  */\r
+\r
+       "Cannot find suitable AudioFile audio port",\r
+\r
+/* AIX driver errors */\r
+\r
+       "Configuration (init step) of audio device failed",\r
+       "Configuration (control step) of audio device failed",\r
+       "Configuration (start step) of audio device failed",\r
+\r
+/* ALSA driver errors */\r
+\r
+/* EsounD driver errors */\r
+\r
+/* Ultrasound driver errors */\r
+\r
+       "Ultrasound driver only works in 16 bit stereo 44 KHz",\r
+       "Ultrasound card could not be reset",\r
+       "Could not start Ultrasound timer",\r
+\r
+/* HP driver errors  */\r
+\r
+       "Unable to select 16bit-linear sample format",\r
+       "Could not select requested sample-rate",\r
+       "Could not select requested number of channels",\r
+       "Unable to select audio output",\r
+       "Unable to get audio description",\r
+       "Could not set transmission buffer size",\r
+\r
+/* Open Sound System driver errors */\r
+\r
+       "Could not set fragment size",\r
+       "Could not set sample size",\r
+       "Could not set mono/stereo setting",\r
+       "Could not set sample rate",\r
+\r
+/* SGI driver errors */\r
+\r
+       "Unsupported sample rate",\r
+       "Hardware does not support 16 bit sound",\r
+       "Hardware does not support 8 bit sound",\r
+       "Hardware does not support stereo sound",\r
+       "Hardware does not support mono sound",\r
+\r
+/* Sun driver errors */\r
+\r
+       "Sound device initialization failed",\r
+\r
+/* OS/2 drivers errors */\r
+\r
+       "Could not set mixing parameters",\r
+       "Could not create playback semaphores",\r
+       "Could not create playback timer",\r
+       "Could not create playback thread",\r
+\r
+/* DirectSound driver errors */\r
+\r
+       "Could not set playback priority",\r
+       "Could not create playback buffers",\r
+       "Could not set playback format",\r
+       "Could not register callback",\r
+       "Could not register event",\r
+       "Could not create playback thread",\r
+       "Could not initialize playback thread",\r
+\r
+/* Windows Multimedia API driver errors */\r
+\r
+       "Invalid device handle",\r
+       "The resource is already allocated",\r
+       "Invalid device identifier",\r
+       "Unsupported output format",\r
+       "Unknown error",\r
+\r
+/* Macintosh driver errors */\r
+\r
+       "Unsupported sample rate",\r
+       "Could not start playback",\r
+\r
+/* Invalid error */\r
+\r
+       "Invalid error code"\r
+};\r
+\r
+MIKMODAPI char *MikMod_strerror(int code)\r
+{\r
+       if ((code<0)||(code>MMERR_MAX)) code=MMERR_MAX+1;\r
+       return _mm_errmsg[code];\r
+}\r
+\r
+/* User installed error callback */\r
+MikMod_handler_t _mm_errorhandler = NULL;\r
+MIKMODAPI int  _mm_errno = 0;\r
+MIKMODAPI BOOL _mm_critical = 0;\r
+\r
+MikMod_handler_t _mm_registererrorhandler(MikMod_handler_t proc)\r
+{\r
+       MikMod_handler_t oldproc=_mm_errorhandler;\r
+\r
+       _mm_errorhandler = proc;\r
+       return oldproc;\r
+}\r
+\r
+MIKMODAPI MikMod_handler_t MikMod_RegisterErrorHandler(MikMod_handler_t proc)\r
+{\r
+       MikMod_handler_t result;\r
+\r
+       MUTEX_LOCK(vars);\r
+               result=_mm_registererrorhandler(proc);\r
+       MUTEX_UNLOCK(vars);\r
+\r
+       return result;\r
+}\r
+\r
+/* ex:set ts=4: */\r