Some documentation in JackMessageBuffer::SetInitCallback.
[jack2.git] / windows / JackRouter / JackRouter.h
bloba50e11a8813741483683b0d3d276ed3e36668e3d
1 /*
2 Copyright (C) 2006-2011 Grame
4 Permission is hereby granted, free of charge, to any person obtaining
5 a copy of this software and associated documentation files
6 (the "Software"), to deal in the Software without restriction,
7 including without limitation the rights to use, copy, modify, merge,
8 publish, distribute, sublicense, and/or sell copies of the Software,
9 and to permit persons to whom the Software is furnished to do so,
10 subject to the following conditions:
12 The above copyright notice and this permission notice shall be
13 included in all copies or substantial portions of the Software.
15 THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
16 EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
17 MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
18 IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR
19 ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF
20 CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
21 WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
25 #ifndef _asiosmpl_
26 #define _asiosmpl_
28 #include "asiosys.h"
30 // Globals
31 static int kBlockFrames = 256;
32 static int kNumInputs = 4;
33 static int kNumOutputs = 4;
35 #if WINDOWS
37 #include "jack.h"
38 #include "rpc.h"
39 #include "rpcndr.h"
40 #ifndef COM_NO_WINDOWS_H
41 #include <windows.h>
42 #include "ole2.h"
44 #endif
46 #include "combase.h"
47 #include "iasiodrv.h"
49 #define PATH_SEP "\\"
51 #include <list>
52 #include <string>
54 class JackRouter : public IASIO, public CUnknown
56 public:
57 JackRouter(LPUNKNOWN pUnk, HRESULT *phr);
58 ~JackRouter();
60 DECLARE_IUNKNOWN
61 //STDMETHODIMP QueryInterface(REFIID riid, void **ppv) { \
62 // return GetOwner()->QueryInterface(riid,ppv); \
63 //}; \
64 //STDMETHODIMP_(ULONG) AddRef() { \
65 // return GetOwner()->AddRef(); \
66 //}; \
67 //STDMETHODIMP_(ULONG) Release() { \
68 // return GetOwner()->Release(); \
69 //};
71 // Factory method
72 static CUnknown *CreateInstance(LPUNKNOWN pUnk, HRESULT *phr);
73 // IUnknown
74 virtual HRESULT STDMETHODCALLTYPE NonDelegatingQueryInterface(REFIID riid,void **ppvObject);
75 #else
77 #include "asiodrvr.h"
79 //---------------------------------------------------------------------------------------------
80 class JackRouter : public AsioDriver
82 public:
83 JackRouter();
84 ~JackRouter();
85 #endif
87 static int processCallback(jack_nframes_t nframes, void* arg);
88 static void connectCallback(jack_port_id_t a, jack_port_id_t b, int connect, void* arg);
89 static void shutdownCallback(void* arg);
91 ASIOBool init(void* sysRef);
92 void getDriverName(char *name); // max 32 bytes incl. terminating zero
93 long getDriverVersion();
94 void getErrorMessage(char *string); // max 128 bytes incl.
96 ASIOError start();
97 ASIOError stop();
99 ASIOError getChannels(long *numInputChannels, long *numOutputChannels);
100 ASIOError getLatencies(long *inputLatency, long *outputLatency);
101 ASIOError getBufferSize(long *minSize, long *maxSize,
102 long *preferredSize, long *granularity);
104 ASIOError canSampleRate(ASIOSampleRate sampleRate);
105 ASIOError getSampleRate(ASIOSampleRate *sampleRate);
106 ASIOError setSampleRate(ASIOSampleRate sampleRate);
107 ASIOError getClockSources(ASIOClockSource *clocks, long *numSources);
108 ASIOError setClockSource(long index);
110 ASIOError getSamplePosition(ASIOSamples *sPos, ASIOTimeStamp *tStamp);
111 ASIOError getChannelInfo(ASIOChannelInfo *info);
113 ASIOError createBuffers(ASIOBufferInfo *bufferInfos, long numChannels,
114 long bufferSize, ASIOCallbacks *callbacks);
115 ASIOError disposeBuffers();
117 ASIOError controlPanel();
118 ASIOError future(long selector, void *opt);
119 ASIOError outputReady();
121 void bufferSwitch();
122 long getMilliSeconds() {return fMilliSeconds;}
124 static std::list<std::pair<std::string, std::string> > fConnections; // Connections list
126 private:
128 void bufferSwitchX();
130 double fSamplePosition;
131 ASIOCallbacks* fCallbacks;
132 ASIOTime fAsioTime;
133 ASIOTimeStamp fTheSystemTime;
135 void** fInputBuffers;
136 void** fOutputBuffers;
138 long* fInMap;
139 long* fOutMap;
141 long fInputLatency;
142 long fOutputLatency;
143 long fActiveInputs;
144 long fActiveOutputs;
145 long fToggle;
146 long fMilliSeconds;
147 bool fRunning;
148 bool fFirstActivate;
149 bool fFloatSample;
150 bool fAliasSystem;
151 bool fTimeInfoMode, fTcRead;
152 char fErrorMessage[128];
154 bool fAutoConnectIn;
155 bool fAutoConnectOut;
157 // Jack part
158 jack_client_t* fClient;
159 jack_port_t** fInputPorts;
160 jack_port_t** fOutputPorts;
161 long fBufferSize;
162 ASIOSampleRate fSampleRate;
164 void autoConnect();
165 void saveConnections();
166 void restoreConnections();
168 void processInputs();
169 void processOutputs();
173 #endif