00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023 #include <time.h>
00024 #include <sys/time.h>
00025 #include <gtk/gtk.h>
00026 #include <sndfile.h>
00027 #ifdef USE_FLAC
00028 #include <FLAC/all.h>
00029 #endif
00030
00031 #include <Alloc.hh>
00032 #include <Mutex.hh>
00033 #include <Condition.hh>
00034 #include <dsp/ReBufferT.hh>
00035
00036 #include "Config.h"
00037 #include "CfgFile.hh"
00038 #include "GtkUtils.hh"
00039 #include "Messages.hh"
00040 #include "SockServ.hh"
00041 #include "SockOp.hh"
00042
00043
00044 #ifndef FILESRV_HH
00045 #define FILESRV_HH
00046
00047 #define FS_VER_MAJ GLOBAL_VERSMAJ
00048 #define FS_VER_MIN GLOBAL_VERSMIN
00049 #define FS_VER_PL GLOBAL_VERSPL
00050 #define FS_WSPACING 8
00051 #define FS_ACCEPT_TIMEOUT 250
00052
00053
00057 class clFileSrv
00058 {
00059
00060 volatile bool bRun;
00061 struct timeval sTimeStamp;
00062 SNDFILE *sndfileFile;
00063 SF_INFO sFileInfo;
00064 # ifdef USE_FLAC
00065 FLAC__FileDecoder *flacDecoder;
00066 # endif
00067 clAlloc AudioBlock;
00068 clCondition CndReady;
00069 clMutex MtxAudio;
00070 clReBufferT<double> StreamBuf;
00071
00072 long lEpoch;
00073 clAlloc ConvBuf;
00074 clCfgFile Cfg;
00075
00076 GtkWidget *gwWindow;
00077 GtkWidget *gwVBox;
00078 GtkWidget *gwFileSelect;
00079
00080 GtkWidget *gwTable1;
00081 GtkWidget *gwLFile;
00082 GtkWidget *gwEFile;
00083 GtkWidget *gwBBrowse;
00084
00085 GtkObject *gaPosition;
00086 GtkWidget *gwTable2;
00087 GtkWidget *gwTBPlayStop;
00088 GtkWidget *gwLPosition;
00089 GtkWidget *gwHSPosition;
00090
00091 bool Build ();
00092 bool BuildTable1 ();
00093 bool BuildTable2 ();
00094 bool ConnectSignals ();
00095 double GetTime ();
00096 void ShortSleep (long);
00097 # ifdef USE_FLAC
00098 bool OpenFLAC (const char *);
00099 void CloseFLAC ();
00100 # endif
00101 public:
00102 clFileSrv ();
00103 ~clFileSrv ();
00104 int Main (int *, char ***);
00105 gboolean OnDelete (GtkWidget *, GdkEvent *, gpointer);
00106 void OnFileSelectOkClick (GtkButton *, gpointer);
00107 void OnFileSelectCancelClick (GtkButton *, gpointer);
00108 void OnBrowseClick (GtkButton *, gpointer);
00109 void OnPlayStopToggle (GtkToggleButton *, gpointer);
00110 void OnPositionChange (GtkAdjustment *, gpointer);
00111 void *ReaderThread (void *);
00112 void *ServerThread (void *);
00113 void *ServeClientThread (void *);
00114 # ifdef USE_FLAC
00115 FLAC__StreamDecoderWriteStatus FLACWriteCB (
00116 const FLAC__FileDecoder *, const FLAC__Frame *,
00117 const FLAC__int32 * const *);
00118 void FLACMetadataCB (const FLAC__FileDecoder *,
00119 const FLAC__StreamMetadata *);
00120 void FLACErrorCB (const FLAC__FileDecoder *,
00121 FLAC__StreamDecoderErrorStatus);
00122 # endif
00123 };
00124
00125 #endif