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 / drivers / drv_stdout.c < prev    next >
Encoding:
C/C++ Source or Header  |  1998-12-07  |  2.1 KB  |  100 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: drv_stdout.c,v 1.16 1998/12/07 06:01:48 miod Exp $
  22.  
  23.   Output data to stdout
  24.  
  25. ==============================================================================*/
  26.  
  27. #ifdef HAVE_CONFIG_H
  28. #include "config.h"
  29. #endif
  30.  
  31. #ifdef HAVE_UNISTD_H
  32. #include <unistd.h>
  33. #endif
  34. #include <stdlib.h>
  35.  
  36. #include <mikmod_internals.h>
  37.  
  38. #define BUFFERSIZE 32768
  39.  
  40. static    SBYTE *audiobuffer=NULL;
  41.  
  42. static BOOL stdout_IsThere(void)
  43. {
  44.     /* only allow this driver on pipes */
  45.     return 1-isatty(1);
  46. }
  47.  
  48. static BOOL stdout_Init(void)
  49. {
  50.     if(!(audiobuffer=(SBYTE*)_mm_malloc(BUFFERSIZE))) return 1;
  51.     return VC_Init();
  52. }
  53.  
  54. static void stdout_Exit(void)
  55. {
  56.     VC_Exit();
  57.     if (audiobuffer) {
  58.         free(audiobuffer);
  59.         audiobuffer=NULL;
  60.     }
  61. }
  62.  
  63. static void stdout_Update(void)
  64. {
  65.     write(1,audiobuffer,VC_WriteBytes((SBYTE*)audiobuffer,BUFFERSIZE));
  66. }
  67.  
  68. static BOOL stdout_Reset(void)
  69. {
  70.     VC_Exit();
  71.     return VC_Init();
  72. }
  73.  
  74. MDRIVER drv_stdout={
  75.     NULL,
  76.     "stdout",
  77.     "Standard output driver v1.1",
  78.     0,255,
  79.     stdout_IsThere,
  80.     VC_SampleLoad,
  81.     VC_SampleUnload,
  82.     VC_SampleSpace,
  83.     VC_SampleLength,
  84.     stdout_Init,
  85.     stdout_Exit,
  86.     stdout_Reset,
  87.     VC_SetNumVoices,
  88.     VC_PlayStart,
  89.     VC_PlayStop,
  90.     stdout_Update,
  91.     VC_VoiceSetVolume,
  92.     VC_VoiceSetFrequency,
  93.     VC_VoiceSetPanning,
  94.     VC_VoicePlay,
  95.     VC_VoiceStop,
  96.     VC_VoiceStopped,
  97.     VC_VoiceGetPosition,
  98.     VC_VoiceRealVolume
  99. };
  100.