home *** CD-ROM | disk | FTP | other *** search
/ ST-Computer Leser-CD 2000 January / LCD_01_2000.iso / games / doom / pmdoom / src / sound / sndserv.c < prev   
Encoding:
C/C++ Source or Header  |  1999-12-17  |  2.3 KB  |  91 lines

  1. /*  Emacs style mode select   -*- C++ -*-  */
  2. /* ----------------------------------------------------------------------------- */
  3. /*  */
  4. /*  $Id:$ */
  5. /*  */
  6. /*  Copyright (C) 1993-1996 by id Software, Inc. */
  7. /*  */
  8. /*  This source is available for distribution and/or modification */
  9. /*  only under the terms of the DOOM Source Code License as */
  10. /*  published by id Software. All rights reserved. */
  11. /*  */
  12. /*  The source is distributed in the hope that it will be useful, */
  13. /*  but WITHOUT ANY WARRANTY; without even the implied warranty of */
  14. /*  FITNESS FOR A PARTICULAR PURPOSE. See the DOOM Source Code License */
  15. /*  for more details. */
  16. /*  */
  17. /*  $Log:$ */
  18. /*  */
  19. /*  DESCRIPTION: */
  20. /*     System interface for sound. */
  21. /*  */
  22. /* ----------------------------------------------------------------------------- */
  23.  
  24. #include <stdio.h>
  25. #include <stdlib.h>
  26. #include <stdarg.h>
  27. #include <string.h>
  28. #include <unistd.h>
  29.  
  30. /*  Separate sound server process. */
  31. FILE*    sndserver=0;
  32. char*    sndserver_filename = "./sndserver ";
  33.  
  34. /*  */
  35. /*  Starting a sound means adding it */
  36. /*   to the current list of active sounds */
  37. /*   in the internal channels. */
  38. /*  As the SFX info struct contains */
  39. /*   e.g. a pointer to the raw data, */
  40. /*   it is ignored. */
  41. /*  As our sound handling does not handle */
  42. /*   priority, it is ignored. */
  43. /*  Pitching (that is, increased speed of playback) */
  44. /*   is set, but currently not used by mixing. */
  45. /*  */
  46. int
  47. I_StartSound_sndserver
  48. ( int        id,
  49.   int        vol,
  50.   int        sep,
  51.   int        pitch,
  52.   int        priority )
  53. {
  54.     if (sndserver)
  55.     {
  56.         fprintf(sndserver, "p%2.2x%2.2x%2.2x%2.2x\n", id, pitch, vol, sep);
  57.         fflush(sndserver);
  58.     }
  59.     /*  warning: control reaches end of non-void function. */
  60.     return id;
  61. }
  62.  
  63. void I_ShutdownSound_sndserver(void)
  64. {    
  65.     if (sndserver)
  66.     {
  67.         /*  Send a "quit" command. */
  68.         fprintf(sndserver, "q\n");
  69.         fflush(sndserver);
  70.     }
  71. }
  72.  
  73. void I_InitSound_sndserver()
  74.     char buffer[256];
  75.   
  76.     if (getenv("DOOMWADDIR"))
  77.         sprintf(buffer, "%s/%s",getenv("DOOMWADDIR"),sndserver_filename);
  78.     else
  79.         sprintf(buffer, "%s", sndserver_filename);
  80.   
  81.     /*  start sound process */
  82.     if ( !access(buffer, X_OK) )
  83.     {
  84.         strcat(buffer, " -quiet");
  85.         sndserver = popen(buffer, "w");
  86.     }
  87.     else
  88.         fprintf(stderr, "Could not start sound server [%s]\n", buffer);
  89. }
  90.