Main Page | Class Hierarchy | Compound List | File List | Compound Members | File Members | Related Pages

linux_audiodrv.h

Go to the documentation of this file.
00001 //
00002 // 1997/09/27 21:38:01
00003 //
00004 
00005 #ifndef AUDIODRV_H
00006 #define AUDIODRV_H
00007 
00008 
00009 #include <unistd.h>
00010 #include <fcntl.h>
00011 #include <sys/ioctl.h>
00012 
00013 #if defined(linux)
00014   #include <linux/soundcard.h>
00015 #elif defined(__FreeBSD__)
00016   #include <machine/soundcard.h>
00017 #endif
00018 
00019 #include "mytypes.h"
00020 #include "emucfg.h"
00021 
00022 class audioDriver
00023 {
00024         
00025  public:  // --------------------------------------------------------- public
00026   
00027         bool IsThere();
00028         
00029         bool Open(udword freq, int precision, int channels,
00030                           int fragments, int fragBase);
00031         
00032         void Close();
00033         
00034         void Play(ubyte* buffer, int bufferSize);
00035 
00036         bool Reset()
00037         {
00038                 return (ioctl(audioHd,SNDCTL_DSP_RESET,0)!=(-1));
00039         }
00040         
00041         int GetAudioHandle()
00042         {
00043                 return audioHd;
00044         }
00045         
00046         udword GetFrequency()
00047     { 
00048                 return frequency;
00049     }
00050         
00051         int GetChannels()
00052     {
00053                 return channels;
00054     }
00055         
00056         int GetSamplePrecision()
00057     {
00058                 return precision;
00059     }
00060         
00061         int GetSampleEncoding()
00062     {
00063                 return encoding;
00064     }
00065         
00066         int GetBlockSize()
00067         {
00068                 return blockSize;
00069         }
00070         
00071         int GetFragments()
00072     {
00073                 return fragments;
00074     }
00075         
00076         int GetFragSizeBase()
00077         {
00078                 return fragSizeBase;
00079         }
00080         
00081         const char* GetErrorString()
00082         {
00083                 return errorString;
00084         }
00085                         
00086  private:  // ------------------------------------------------------- private
00087 
00088     const char AUDIODEVICE[] = "/dev/dsp";
00089         int audioHd;
00090         
00091         const char* errorString;
00092 
00093         int blockSize;
00094         int fragments;
00095         int fragSizeBase;
00096         
00097         udword frequency;
00098         
00099         // These are constants/enums from ``libsidplay/include/emucfg.h''.
00100         int encoding;
00101         int precision;
00102         int channels;
00103 };
00104 
00105 
00106 #endif  // AUDIODRV_H

Generated on Tue Feb 8 04:13:58 2005 for Esidplay by doxygen 1.3.3