Jack2 1.9.7

JackDriver.h

00001 /*
00002  Copyright (C) 2001 Paul Davis
00003  Copyright (C) 2004-2008 Grame
00004 
00005  This program is free software; you can redistribute it and/or modify
00006  it under the terms of the GNU General Public License as published by
00007  the Free Software Foundation; either version 2 of the License, or
00008  (at your option) any later version.
00009 
00010  This program is distributed in the hope that it will be useful,
00011  but WITHOUT ANY WARRANTY; without even the implied warranty of
00012  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00013  GNU General Public License for more details.
00014 
00015  You should have received a copy of the GNU General Public License
00016  along with this program; if not, write to the Free Software
00017  Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
00018 
00019  */
00020 
00021 #ifndef __JackDriver__
00022 #define __JackDriver__
00023 
00024 #include "types.h"
00025 #include "JackClientInterface.h"
00026 #include "JackConstants.h"
00027 #include "JackPlatformPlug.h"
00028 #include "JackClientControl.h"
00029 #include <list>
00030 
00031 namespace Jack
00032 {
00033 
00034 class JackLockedEngine;
00035 class JackGraphManager;
00036 struct JackEngineControl;
00037 
00042 class SERVER_EXPORT JackDriverInterface
00043 {
00044 
00045     public:
00046 
00047         JackDriverInterface()
00048         {}
00049         virtual ~JackDriverInterface()
00050         {}
00051 
00052         virtual int Open() = 0;
00053 
00054         virtual int Open (bool capturing,
00055                      bool playing,
00056                      int inchannels,
00057                      int outchannels,
00058                      bool monitor,
00059                      const char* capture_driver_name,
00060                      const char* playback_driver_name,
00061                      jack_nframes_t capture_latency,
00062                      jack_nframes_t playback_latency) = 0;
00063 
00064         virtual int Open(jack_nframes_t buffer_size,
00065                          jack_nframes_t samplerate,
00066                          bool capturing,
00067                          bool playing,
00068                          int inchannels,
00069                          int outchannels,
00070                          bool monitor,
00071                          const char* capture_driver_name,
00072                          const char* playback_driver_name,
00073                          jack_nframes_t capture_latency,
00074                          jack_nframes_t playback_latency) = 0;
00075 
00076         virtual int Attach() = 0;
00077         virtual int Detach() = 0;
00078 
00079         virtual int Read() = 0;
00080         virtual int Write() = 0;
00081 
00082         virtual int Start() = 0;
00083         virtual int Stop() = 0;
00084 
00085         virtual bool IsFixedBufferSize() = 0;
00086         virtual int SetBufferSize(jack_nframes_t buffer_size) = 0;
00087         virtual int SetSampleRate(jack_nframes_t sample_rate) = 0;
00088 
00089         virtual int Process() = 0;
00090         virtual int ProcessNull() = 0;
00091 
00092         virtual void SetMaster(bool onoff) = 0;
00093         virtual bool GetMaster() = 0;
00094         virtual void AddSlave(JackDriverInterface* slave) = 0;
00095         virtual void RemoveSlave(JackDriverInterface* slave) = 0;
00096         virtual std::list<JackDriverInterface*> GetSlaves() = 0;
00097         virtual int ProcessSlaves() = 0;
00098 
00099         virtual bool IsRealTime() const = 0;
00100         virtual bool IsRunning() const = 0;
00101 };
00102 
00107 class SERVER_EXPORT JackDriverClientInterface : public JackDriverInterface, public JackClientInterface
00108 {};
00109 
00114 #define CaptureDriverFlags  static_cast<JackPortFlags>(JackPortIsOutput | JackPortIsPhysical | JackPortIsTerminal)
00115 #define PlaybackDriverFlags static_cast<JackPortFlags>(JackPortIsInput | JackPortIsPhysical | JackPortIsTerminal)
00116 #define MonitorDriverFlags static_cast<JackPortFlags>(JackPortIsOutput)
00117 
00118 class SERVER_EXPORT JackDriver : public JackDriverClientInterface
00119 {
00120 
00121     protected:
00122 
00123         char fCaptureDriverName[JACK_CLIENT_NAME_SIZE + 1];
00124         char fPlaybackDriverName[JACK_CLIENT_NAME_SIZE + 1];
00125         char fAliasName[JACK_CLIENT_NAME_SIZE + 1];
00126         jack_nframes_t fCaptureLatency;
00127         jack_nframes_t fPlaybackLatency;
00128         jack_time_t fBeginDateUst;
00129         jack_time_t fEndDateUst;
00130         float fDelayedUsecs;
00131         JackLockedEngine* fEngine;
00132         JackGraphManager* fGraphManager;
00133         JackSynchro* fSynchroTable;
00134         JackEngineControl* fEngineControl;
00135         JackClientControl fClientControl;
00136         std::list<JackDriverInterface*> fSlaveList;
00137         bool fIsMaster;
00138         bool fIsRunning;
00139 
00140         void CycleIncTime();
00141         void CycleTakeBeginTime();
00142         void CycleTakeEndTime();
00143 
00144         void SetupDriverSync(int ref, bool freewheel);
00145 
00146         void NotifyXRun(jack_time_t callback_usecs, float delayed_usecs);   // XRun notification sent by the driver
00147         void NotifyBufferSize(jack_nframes_t buffer_size);                  // BufferSize notification sent by the driver
00148         void NotifySampleRate(jack_nframes_t sample_rate);                  // SampleRate notification sent by the driver
00149         void NotifyFailure(int code, const char* reason);                   // Failure notification sent by the driver
00150 
00151     public:
00152 
00153         JackDriver(const char* name, const char* alias, JackLockedEngine* engine, JackSynchro* table);
00154         JackDriver();
00155         virtual ~JackDriver();
00156 
00157         void SetMaster(bool onoff);
00158         bool GetMaster();
00159 
00160         void AddSlave(JackDriverInterface* slave);
00161         void RemoveSlave(JackDriverInterface* slave);
00162         std::list<JackDriverInterface*> GetSlaves()
00163         {
00164             return fSlaveList;
00165         }
00166         int ProcessSlaves();
00167 
00168         virtual int Open();
00169 
00170         virtual int Open (bool capturing,
00171                      bool playing,
00172                      int inchannels,
00173                      int outchannels,
00174                      bool monitor,
00175                      const char* capture_driver_name,
00176                      const char* playback_driver_name,
00177                      jack_nframes_t capture_latency,
00178                      jack_nframes_t playback_latency);
00179 
00180         virtual int Open(jack_nframes_t buffer_size,
00181                          jack_nframes_t samplerate,
00182                          bool capturing,
00183                          bool playing,
00184                          int inchannels,
00185                          int outchannels,
00186                          bool monitor,
00187                          const char* capture_driver_name,
00188                          const char* playback_driver_name,
00189                          jack_nframes_t capture_latency,
00190                          jack_nframes_t playback_latency);
00191         virtual int Close();
00192 
00193         virtual int Process();
00194         virtual int ProcessNull();
00195 
00196         virtual int Attach();
00197         virtual int Detach();
00198 
00199         virtual int Read();
00200         virtual int Write();
00201 
00202         virtual int Start();
00203         virtual int StartSlaves();
00204         virtual int Stop();
00205         virtual int StopSlaves();
00206 
00207         virtual bool IsFixedBufferSize();
00208         virtual int SetBufferSize(jack_nframes_t buffer_size);
00209         virtual int SetSampleRate(jack_nframes_t sample_rate);
00210 
00211         virtual int ClientNotify(int refnum, const char* name, int notify, int sync, const char* message, int value1, int value2);
00212         virtual JackClientControl* GetClientControl() const;
00213 
00214         virtual bool IsRealTime() const;
00215         virtual bool IsRunning() const { return fIsRunning; }
00216         virtual bool Initialize();  // To be called by the wrapping thread Init method when the driver is a "blocking" one
00217 
00218 };
00219 
00220 } // end of namespace
00221 
00222 #endif

Generated for Jack2 by doxygen 1.7.3