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

audiodrv.h

Go to the documentation of this file.
00001 //
00002 // $Date: 2001/09/10 20:36:56 $
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   audioDriver();
00028         bool IsThere();
00029         
00030         bool Open(udword freq, int precision, int channels,
00031                           int fragments, int fragBase);
00032         
00033         void Close();
00034         
00035         void Play(ubyte* buffer, int bufferSize);
00036 
00037         bool Reset()
00038         {
00039                 return (ioctl(audioHd,SNDCTL_DSP_RESET,0)!=(-1));
00040         }
00041         
00042         int GetAudioHandle()
00043         {
00044                 return audioHd;
00045         }
00046         
00047         udword GetFrequency()
00048     { 
00049                 return frequency;
00050     }
00051         
00052         int GetChannels()
00053     {
00054                 return channels;
00055     }
00056         
00057         int GetSamplePrecision()
00058     {
00059                 return precision;
00060     }
00061         
00062         int GetSampleEncoding()
00063     {
00064                 return encoding;
00065     }
00066         
00067         int GetBlockSize()
00068         {
00069                 return blockSize;
00070         }
00071         
00072         int GetFragments()
00073     {
00074                 return fragments;
00075     }
00076         
00077         int GetFragSizeBase()
00078         {
00079                 return fragSizeBase;
00080         }
00081         
00082         const char* GetErrorString()
00083         {
00084                 return errorString;
00085         }
00086                         
00087  private:  // ------------------------------------------------------- private
00088 
00089         static const char AUDIODEVICE[] = "/dev/dsp";
00090         int audioHd;
00091         
00092         const char* errorString;
00093 
00094         int blockSize;
00095         int fragments;
00096         int fragSizeBase;
00097         
00098         udword frequency;
00099         
00100         // These are constants/enums from ``libsidplay/include/emucfg.h''.
00101         int encoding;
00102         int precision;
00103         int channels;
00104 };
00105 
00106 
00107 #endif  // AUDIODRV_H

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