00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023 #include <Alloc.hh>
00024 #include <Condition.hh>
00025 #include <Mutex.hh>
00026 #ifdef USE_RWLOCK
00027 #include <RWLock.hh>
00028 #endif
00029 #ifdef USE_FLAC
00030 #include <FLAC/all.h>
00031 #endif
00032 #include <dsp/DSPOp.hh>
00033
00034 #include "Config.h"
00035 #include "Audio.hh"
00036 #include "CfgFile.hh"
00037 #include "LogFile.hh"
00038 #include "Messages.hh"
00039 #include "SockServ.hh"
00040 #include "SockOp.hh"
00041
00042
00043 #ifndef SOUNDSRV2_HH
00044 #define SOUNDSRV2_HH
00045
00046 #define SS2_LOGENTRY_SIZE 256
00047
00048 #define SS2_OSS_MAJOR(x) ((x >> 16) & 0xff)
00049 #define SS2_OSS_MINOR(x) ((x >> 8) & 0xff)
00050 #define SS2_OSS_PL(x) (x & 0xff)
00051
00052
00067 class clSoundSrv2
00068 {
00069 volatile bool bRun;
00070 volatile int iAudioBufSize;
00071 volatile int iBlockCntr;
00072 stSoundStart sHdr;
00073 #ifdef USE_FLAC
00074 FLAC__StreamEncoder *spFLACEnc;
00075 #endif
00076 clAlloc AudioBuf;
00077 clAlloc CompHead;
00078 clAlloc FLACFrame;
00079 clMutex MtxAudio;
00080 #ifdef USE_RWLOCK
00081 clRWLock RWLAudio;
00082 #endif
00083 clCondition CndAudio;
00084 clCfgFile Cfg;
00085 bool GetAudioCfg (char *, int *, int *, int *, int *);
00086 bool InitCompress (int, int, int, int, int);
00087 #ifdef USE_FLAC
00088 void Convert (FLAC__int32 *, const void *, long, int);
00089 #endif
00090 public:
00091 clLogFile Log;
00092 clSoundSrv2 ();
00093 ~clSoundSrv2 ();
00094 int Main (int, char **);
00095 void *AudioInThread (void *);
00096 void *ServeClientThread (void *);
00097 void Stop() { bRun = false; }
00098 #ifdef USE_FLAC
00099 FLAC__StreamEncoderWriteStatus FLACWrite (
00100 const FLAC__StreamEncoder *, const FLAC__byte *, unsigned,
00101 unsigned, unsigned);
00102 void FLACMetaData (const FLAC__StreamEncoder *,
00103 const FLAC__StreamMetadata *);
00104 #endif
00105 };
00106
00107 #endif
00108