Diff for /np2/x11/soundmng.c between versions 1.1 and 1.5

version 1.1, 2003/11/16 16:43:45 version 1.5, 2004/05/22 16:35:08
Line 94  static BOOL nosound_setup(void); Line 94  static BOOL nosound_setup(void);
   
 static void PARTSCALL (*fnmix)(SINT16* dst, const SINT32* src, UINT size);  static void PARTSCALL (*fnmix)(SINT16* dst, const SINT32* src, UINT size);
   
 #if defined(__GNUC__) && (defined(i386) || defined(__i386__))  #if defined(GCC_CPU_ARCH_IA32)
 void PARTSCALL _satuation_s16(SINT16 *dst, const SINT32 *src, UINT size);  void PARTSCALL _saturation_s16(SINT16 *dst, const SINT32 *src, UINT size);
 void PARTSCALL _satuation_s16x(SINT16 *dst, const SINT32 *src, UINT size);  void PARTSCALL _saturation_s16x(SINT16 *dst, const SINT32 *src, UINT size);
 void PARTSCALL satuation_s16mmx(SINT16 *dst, const SINT32 *src, UINT size);  void PARTSCALL saturation_s16mmx(SINT16 *dst, const SINT32 *src, UINT size);
 #endif  #endif
   
 /*  /*
Line 224  UINT Line 224  UINT
 soundmng_create(UINT rate, UINT bufmsec)  soundmng_create(UINT rate, UINT bufmsec)
 {  {
         UINT samples;          UINT samples;
 #if defined(VERMOUTH_LIB)  
         UINT num;  
 #endif  
   
         if (opened || ((rate != 11025) && (rate != 22050) && (rate != 44100))) {          if (opened || ((rate != 11025) && (rate != 22050) && (rate != 44100))) {
                 return 0;                  return 0;
         }          }
   
         snddrv_setup();          if (bufmsec < 20)
                   bufmsec = 20;
         if (bufmsec < 50) {          else if (bufmsec > 1000)
                 bufmsec = 50;  
         } else if (bufmsec > 1000) {  
                 bufmsec = 1000;                  bufmsec = 1000;
         }  
           snddrv_setup();
   
         samples = (rate * bufmsec) / 1000 / 2;          samples = (rate * bufmsec) / 1000 / 2;
         samples = calc_blocksize(samples);          samples = calc_blocksize(samples);
Line 253  soundmng_create(UINT rate, UINT bufmsec) Line 249  soundmng_create(UINT rate, UINT bufmsec)
   
 #if defined(VERMOUTH_LIB)  #if defined(VERMOUTH_LIB)
         vermouth_module = midimod_create(rate);          vermouth_module = midimod_create(rate);
         for (num = 0; num < 128; num++) {          midimod_loadall(vermouth_module);
                 midimod_loadprogram(vermouth_module, num);  
                 midimod_loadrhythm(vermouth_module, num);  
         }  
 #endif  #endif
   
         soundmng_setreverse(FALSE);          soundmng_setreverse(FALSE);
Line 293  soundmng_destroy(void) Line 286  soundmng_destroy(void)
                 (*snddrv.sndstop)();                  (*snddrv.sndstop)();
                 (*snddrv.drvterm)();                  (*snddrv.drvterm)();
                 buffer_destroy();                  buffer_destroy();
                   nosound_setup();
                 audio_fd = -1;                  audio_fd = -1;
                 opened = FALSE;                  opened = FALSE;
         }          }
Line 355  void Line 349  void
 soundmng_setreverse(BOOL reverse)  soundmng_setreverse(BOOL reverse)
 {  {
   
 #if defined(__GNUC__) && (defined(i386) || defined(__i386__))  #if defined(GCC_CPU_ARCH_IA32)
         if (!reverse) {          if (!reverse) {
                 if (mmxflag & (MMXFLAG_NOTSUPPORT|MMXFLAG_DISABLE)) {                  if (mmxflag & (MMXFLAG_NOTSUPPORT|MMXFLAG_DISABLE)) {
                         fnmix = _satuation_s16;                          fnmix = _saturation_s16;
                 } else {                  } else {
                         fnmix = satuation_s16mmx;                          fnmix = saturation_s16mmx;
                 }                  }
         } else {          } else {
                 fnmix = _satuation_s16x;                  fnmix = _saturation_s16x;
         }          }
 #else  #else
         if (!reverse) {          if (!reverse) {
Line 606  buffer_play(void *arg) Line 600  buffer_play(void *arg)
         size_t len = opna_frame;          size_t len = opna_frame;
         size_t s;          size_t s;
         ssize_t r;          ssize_t r;
           int nextbuf;
   
         UNUSED(arg);          UNUSED(arg);
   
         buf = (char *)_MALLOC(len, "sound playing buf");  
         if (buf == NULL) {  
                 fprintf(stderr, "buffer_play: can't alloc memory\n");  
                 return NULL;  
         }  
   
         is_proc = TRUE;          is_proc = TRUE;
         while (is_proc) {          while (is_proc) {
                   nextbuf = sound_nextbuf;
                 if (sound_event)                  if (sound_event)
                         memset(sound_event, 0, len);                          memset(sound_event, 0, len);
                 memcpy(buf, sound_buffer[sound_nextbuf], len);  
                 sound_nextbuf = (sound_nextbuf + 1) % NSOUNDBUFFER;                  sound_nextbuf = (sound_nextbuf + 1) % NSOUNDBUFFER;
                 sound_event = sound_buffer[sound_nextbuf];                  sound_event = sound_buffer[sound_nextbuf];
   
                   buf = sound_buffer[nextbuf];
                 s = 0;                  s = 0;
                 for (;;) {                  for (;;) {
                         r = write(audio_fd, buf + s, len - s);                          r = write(audio_fd, buf + s, len - s);
Line 633  buffer_play(void *arg) Line 623  buffer_play(void *arg)
                         }                          }
                 }                  }
         }          }
         _MFREE(buf);  
         is_proc = FALSE;          is_proc = FALSE;
   
         return NULL;          return NULL;
Line 657  snddrv_stop(void) Line 646  snddrv_stop(void)
   
 #endif  /* USE_NETBSDAUDIO || USE_OSSAUDIO || USE_ESDAUDIO */  #endif  /* USE_NETBSDAUDIO || USE_OSSAUDIO || USE_ESDAUDIO */
   
 #if defined(__GNUC__) && (defined(i386) || defined(__i386__))  #if defined(GCC_CPU_ARCH_IA32)
 void PARTSCALL  void PARTSCALL
 _satuation_s16(SINT16 *dst, const SINT32 *src, UINT size)  _saturation_s16(SINT16 *dst, const SINT32 *src, UINT size)
 {  {
         asm volatile (          asm volatile (
                 "movl   %0, %%ecx;"                  "movl   %0, %%ecx;"
Line 690  _satuation_s16(SINT16 *dst, const SINT32 Line 679  _satuation_s16(SINT16 *dst, const SINT32
 }  }
   
 void PARTSCALL  void PARTSCALL
 _satuation_s16x(SINT16 *dst, const SINT32 *src, UINT size)  _saturation_s16x(SINT16 *dst, const SINT32 *src, UINT size)
 {  {
   
         asm volatile (          asm volatile (
Line 733  _satuation_s16x(SINT16 *dst, const SINT3 Line 722  _satuation_s16x(SINT16 *dst, const SINT3
 }  }
   
 void PARTSCALL  void PARTSCALL
 satuation_s16mmx(SINT16 *dst, const SINT32 *src, UINT size)  saturation_s16mmx(SINT16 *dst, const SINT32 *src, UINT size)
 {  {
   
         asm volatile (          asm volatile (
Line 757  satuation_s16mmx(SINT16 *dst, const SINT Line 746  satuation_s16mmx(SINT16 *dst, const SINT
                 : /* output */                  : /* output */
                 : "m" (dst), "m" (src), "m" (size));                  : "m" (dst), "m" (src), "m" (size));
 }  }
 #endif  /* __GNUC__ && (i386 || __i386__) */  #endif  /* __GNUC__ && GCC_CPU_ARCH_IA32 */
   
 #endif  /* !NOSOUND */  #endif  /* !NOSOUND */

Removed from v.1.1  
changed lines
  Added in v.1.5


RetroPC.NET-CVS <cvs@retropc.net>