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.
31 static int kBlockFrames
= 256;
32 static int kNumInputs
= 4;
33 static int kNumOutputs
= 4;
40 #ifndef COM_NO_WINDOWS_H
54 class JackRouter
: public IASIO
, public CUnknown
57 JackRouter(LPUNKNOWN pUnk
, HRESULT
*phr
);
61 //STDMETHODIMP QueryInterface(REFIID riid, void **ppv) { \
62 // return GetOwner()->QueryInterface(riid,ppv); \
64 //STDMETHODIMP_(ULONG) AddRef() { \
65 // return GetOwner()->AddRef(); \
67 //STDMETHODIMP_(ULONG) Release() { \
68 // return GetOwner()->Release(); \
72 static CUnknown
*CreateInstance(LPUNKNOWN pUnk
, HRESULT
*phr
);
74 virtual HRESULT STDMETHODCALLTYPE
NonDelegatingQueryInterface(REFIID riid
,void **ppvObject
);
79 //---------------------------------------------------------------------------------------------
80 class JackRouter
: public AsioDriver
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.
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();
122 long getMilliSeconds() {return fMilliSeconds
;}
124 static std::list
<std::pair
<std::string
, std::string
> > fConnections
; // Connections list
128 void bufferSwitchX();
130 double fSamplePosition
;
131 ASIOCallbacks
* fCallbacks
;
133 ASIOTimeStamp fTheSystemTime
;
135 void** fInputBuffers
;
136 void** fOutputBuffers
;
151 bool fTimeInfoMode
, fTcRead
;
152 char fErrorMessage
[128];
155 bool fAutoConnectOut
;
158 jack_client_t
* fClient
;
159 jack_port_t
** fInputPorts
;
160 jack_port_t
** fOutputPorts
;
162 ASIOSampleRate fSampleRate
;
165 void saveConnections();
166 void restoreConnections();
168 void processInputs();
169 void processOutputs();