Main Page | Namespace List | Class Hierarchy | Alphabetical List | Compound List | File List | Compound Members | File Members

FileSrv.hh

Go to the documentation of this file.
00001 /*
00002 
00003     File replay server, header
00004     Copyright (C) 2002 Jussi Laako
00005 
00006     This program is free software; you can redistribute it and/or modify
00007     it under the terms of the GNU General Public License as published by
00008     the Free Software Foundation; either version 2 of the License, or
00009     (at your option) any later version.
00010 
00011     This program is distributed in the hope that it will be useful,
00012     but WITHOUT ANY WARRANTY; without even the implied warranty of
00013     MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00014     GNU General Public License for more details.
00015 
00016     You should have received a copy of the GNU General Public License
00017     along with this program; if not, write to the Free Software
00018     Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
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             /* Thread-shared */
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             /* Widgets */
00076             GtkWidget *gwWindow;
00077             GtkWidget *gwVBox;
00078             GtkWidget *gwFileSelect;
00079             // Table1
00080             GtkWidget *gwTable1;
00081             GtkWidget *gwLFile;
00082             GtkWidget *gwEFile;
00083             GtkWidget *gwBBrowse;
00084             // Table2
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

Generated on Sun Oct 26 19:11:19 2003 for HASAS by doxygen 1.3.3