home *** CD-ROM | disk | FTP | other *** search
/ Complete Linux / Complete Linux.iso / docs / apps / sound / players / maplay_t.z / maplay_t / obuffer.h < prev    next >
Encoding:
C/C++ Source or Header  |  1994-02-21  |  3.0 KB  |  114 lines

  1. /*
  2.  *  @(#) obuffer.h 1.6, last edit: 2/21/94 18:10:14
  3.  *  @(#) Copyright (C) 1993, 1994 Tobias Bading (bading@cs.tu-berlin.de)
  4.  *  @(#) Berlin University of Technology
  5.  *
  6.  *  This program is free software; you can redistribute it and/or modify
  7.  *  it under the terms of the GNU General Public License as published by
  8.  *  the Free Software Foundation; either version 2 of the License, or
  9.  *  (at your option) any later version.
  10.  *
  11.  *  This program is distributed in the hope that it will be useful,
  12.  *  but WITHOUT ANY WARRANTY; without even the implied warranty of
  13.  *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  14.  *  GNU General Public License for more details.
  15.  *
  16.  *  You should have received a copy of the GNU General Public License
  17.  *  along with this program; if not, write to the Free Software
  18.  *  Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
  19.  */
  20.  
  21. #ifndef OBUFFER_H
  22. #define OBUFFER_H
  23.  
  24. #include <iostream.h>
  25. #include <unistd.h>
  26. #include <stdlib.h>
  27. #include "all.h"
  28. #include "header.h"
  29. #include "audio_includes.h"
  30.  
  31.  
  32. static const uint32 OBUFFERSIZE = 2 * 1152;    // max. 2 * 1152 samples per frame
  33. static const uint32 MAXCHANNELS = 2;        // max. number of channels
  34.  
  35.  
  36. // abstract base class for audio output classes:
  37. class Obuffer
  38. {
  39. public:
  40.   virtual     ~Obuffer (void) {}        // dummy
  41.   virtual void append (uint32 channel, int16 value) = 0;
  42.            // this function takes a 16 Bit PCM sample
  43.   virtual void write_buffer (int fd) = 0;
  44.            // this function should write the samples to the filedescriptor
  45.            // or directly to the audio hardware
  46. };
  47.  
  48.  
  49. // audio output class for raw pcm output:
  50. class ShortObuffer : public Obuffer
  51. {
  52. private:
  53.   int16 buffer[OBUFFERSIZE];
  54.   int16 *bufferp[MAXCHANNELS];
  55.   uint32 channels;
  56.  
  57. public:
  58.     ShortObuffer (uint32 number_of_channels);
  59.        ~ShortObuffer (void) {}
  60.   void    append (uint32 channel, int16 value);
  61.   void    write_buffer (int fd);
  62. };
  63.  
  64.  
  65. #ifdef Indigo
  66. // a class for direct sound output on SGI machines:
  67. class IndigoObuffer : public Obuffer
  68. {
  69. private:
  70.   int16 buffer[OBUFFERSIZE];
  71.   int16 *bufferp[MAXCHANNELS];
  72.   uint32 channels;
  73.   ALport port;
  74.  
  75. public:
  76.     IndigoObuffer (uint32 number_of_channels, Header *);
  77.        ~IndigoObuffer (void);
  78.   void    append (uint32 channel, int16 value);
  79.   void    write_buffer (int dummy);
  80. };
  81. #endif    // Indigo
  82.  
  83.  
  84. #ifdef SPARC
  85. // a class for direct sound output on SPARC 10 machines: (dbri device)
  86. class SparcObuffer : public Obuffer
  87. {
  88. private:
  89.   int16 buffer[OBUFFERSIZE];
  90.   int16 *bufferp[MAXCHANNELS];
  91.   uint32 channels;
  92.   static int audio_fd;
  93.  
  94.   static int open_audio_device (void);
  95. #ifdef Solaris
  96.   static void get_device_type (int fd, audio_device *);
  97. #else
  98.   static int get_device_type (int fd);
  99. #endif
  100.  
  101. public:
  102.     SparcObuffer (uint32 number_of_channels, Header *,
  103.                bool use_speaker, bool use_headphone, bool use_line_out);
  104.        ~SparcObuffer (void);
  105.   void    append (uint32 channel, int16 value);
  106.   void    write_buffer (int dummy);
  107.  
  108.   static bool class_suitable (void);
  109.     // returnvalue == False: no 16-bit output possible (class unsuitable)
  110. };
  111. #endif    // SPARC
  112.  
  113. #endif
  114.