JACKNetworkPlayer.hxx

Go to the documentation of this file.
00001 #ifndef JACKNetworkPlayer_hxx
00002 #define JACKNetworkPlayer_hxx
00003 
00004 #include <iostream>
00005 #include <string>
00006 #include <vector>
00007 #include "NetworkPlayer.hxx"
00008 #include "Network.hxx"
00009 #include <jack/jack.h>
00010 
00011 namespace CLAM
00012 {
00013 
00014 class JACKNetworkPlayer : public NetworkPlayer
00015 {
00016 private:
00017         typedef std::vector<jack_port_t*> JackPorts;
00018         const char * PortName(jack_port_t * port)
00019         {
00020                 return jack_port_name(port);
00021         }
00023         struct JackConnection
00024         {
00025                 std::string processingName;
00026                 const char ** outsideConnections;
00027         };
00028         typedef std::list<JackConnection> JackConnections;
00029 
00030 private:
00031         int _jackSampleRate;
00032         int _jackBufferSize;
00033         bool _autoConnect;
00034 
00035         JackPorts _sourceJackPorts;
00036         JackPorts _sinkJackPorts;
00037 
00038         JackConnections _incomingJackConnections;
00039         JackConnections _outgoingJackConnections;
00040 
00041         std::string _jackOutPortAutoConnectList;
00042         std::string _jackInPortAutoConnectList;
00043         
00044         //JACK CODE
00045         jack_client_t * _jackClient;
00046         std::string _jackClientName;
00047 
00048 public:
00049         JACKNetworkPlayer(const std::string & name="CLAM network player");
00050         virtual ~JACKNetworkPlayer();
00051 
00052         void InitClient();
00053         bool IsWorking();
00054 
00055         virtual bool IsRealTime() const { return true; }
00056 
00057         std::string NonWorkingReason();
00058         
00059         //JACK sever (un)registration methods
00060         void RegisterPorts();
00061         void RegisterInputPorts(const Network& net);
00062         void RegisterOutputPorts(const Network& net);
00063         void UnRegisterPorts();
00064         void OnShutdown();
00065 
00066         //Buffer copying methods
00067         void CopyJackBuffersToSources(const jack_nframes_t nframes);
00068         void CopySinksToJackBuffers(const jack_nframes_t nframes);
00069         void BlankJackBuffers(const jack_nframes_t nframes);
00070         
00071         virtual void Start();
00072         virtual void Stop();
00073         virtual void Init();
00074         
00075         virtual unsigned BackendBufferSize() 
00076         {
00077                 return _jackBufferSize; 
00078         }
00079 
00080         virtual unsigned BackendSampleRate() { return _jackSampleRate; }
00081         
00082         void Do(const jack_nframes_t nframes);
00083 
00084         //Saves/loads the connections made to our local in/out jack ports
00085         void StoreConnections();
00086         void RestoreConnections();
00087         
00088         
00089         void AutoConnectPorts();
00090 };
00091 } //namespace CLAM
00092 
00093 #endif
00094 
Generated by  doxygen 1.6.3