home *** CD-ROM | disk | FTP | other *** search
/ Nebula 2 / Nebula Two.iso / Apps / SoundApps / TimeWarp / Source / errors.m < prev    next >
Encoding:
Text File  |  1995-06-12  |  2.4 KB  |  98 lines

  1. /* errors.m
  2.  * Routines to simplify the checking and reporting of mach/sound kit/sound
  3.  * driver errors.
  4.  *
  5.  * !!!
  6.  * This file needs to be reworked under 3.0!!  The snd_msgs.h file has
  7.  * gone away.  The workaround is described in NeXTAnswer sound.855.
  8.  * !!!
  9.  *
  10.  * You may freely copy, distribute, and reuse the code in this example.
  11.  * NeXT disclaims any warranty of any kind, expressed or  implied, as to its
  12.  * fitness for any particular use.
  13.  *
  14.  * Written by: Robert Poor
  15.  * Created: Sep/92
  16.  */
  17.  
  18. #import "errors.h"
  19. #import <appkit/Panel.h>
  20. // #import "LanguageApp.h"
  21. #import <mach_error.h>
  22. #import <sound/sounderror.h>
  23. // #import <nextdev/snd_msgs.h>        /* for SND_NO_ERROR */
  24. #define SND_NO_ERROR    0        /* not defined in 3.0? */
  25.  
  26. static char *snddriver_error_list[] = {
  27.   "sound success",
  28.   "sound message sent to wrong port",
  29.   "unknown sound message id",
  30.   "bad parameter list in sound message",
  31.   "can't allocate memory for recording",
  32.   "sound service in use",
  33.   "sound service requires ownership",
  34.   "DSP channel not initialized",
  35.   "can't find requested sound resource",
  36.   "bad DSP mode for sending data commands",
  37.   "external pager support not implemented",
  38.   "sound data not properly aligned"
  39.   };
  40.  
  41. char *snddriver_error_string(int error)
  42. {
  43.   return ((error >= SND_NO_ERROR)?
  44.       snddriver_error_list[error-SND_NO_ERROR]:
  45.       "unrecognized sound error message");
  46. }
  47.  
  48. id checkMachError(id obj, int err, char *msg)
  49. {
  50.   if (err != KERN_SUCCESS) {
  51. #if 0
  52.     NXRunAlertPanel(NULL,
  53.             [NXApp translateString:msg fromTable:"alerts"],
  54.             [NXApp translateString:"OK" fromTable:"buttons"],
  55.             NULL,
  56.             NULL);
  57. #else
  58.     NXRunAlertPanel(NULL, msg, "OK", NULL, NULL);
  59. #endif
  60.     return nil;
  61.   }
  62.   return obj;
  63. }
  64.  
  65. id checkSnddriverError(id obj, int err, char *msg)
  66. {
  67.   if (err != KERN_SUCCESS) {
  68. #if 0
  69.     NXRunAlertPanel(NULL,
  70.             [NXApp translateString:msg fromTable:"alerts"],
  71.             [NXApp translateString:"OK" fromTable:"buttons"],
  72.             NULL,
  73.             NULL);
  74. #else
  75.     NXRunAlertPanel(NULL, msg, "OK", NULL, NULL);
  76. #endif
  77.     return nil;
  78.   }
  79.   return obj;
  80. }
  81.  
  82. id checkSNDError(id obj, int err, char *msg)
  83. {
  84.   if (err != SND_ERR_NONE) {
  85. #if 0
  86.     NXRunAlertPanel(NULL,
  87.             [NXApp translateString:msg fromTable:"alerts"],
  88.             [NXApp translateString:"OK" fromTable:"buttons"],
  89.             NULL,
  90.             NULL);
  91. #else
  92.     NXRunAlertPanel(NULL, msg, "OK", NULL, NULL);
  93. #endif
  94.     return nil;
  95.   }
  96.   return obj;
  97. }
  98.