Mercurial > hg > svapp
comparison audioio/AudioJACKTarget.cpp @ 56:75ad3f8f65aa
* use jack_client_open
author | Chris Cannam |
---|---|
date | Thu, 08 Nov 2007 16:14:32 +0000 |
parents | 3c5756fb6a68 |
children | eb596ef12041 |
comparison
equal
deleted
inserted
replaced
55:9fa273598830 | 56:75ad3f8f65aa |
---|---|
63 } | 63 } |
64 symbols[name] = symbol; | 64 symbols[name] = symbol; |
65 return symbol; | 65 return symbol; |
66 } | 66 } |
67 | 67 |
68 static jack_client_t *dynamic_jack_client_open(const char *client_name, | |
69 jack_options_t options, | |
70 jack_status_t *status, ...) | |
71 { | |
72 typedef jack_client_t (*func)(const char *client_name, | |
73 jack_options_t options, | |
74 jack_status_t *status, ...); | |
75 void *s = symbol("jack_client_open"); | |
76 if (!s) return 0; | |
77 func f = (func)s; | |
78 return f(client_name, options, status); // varargs not supported here | |
79 } | |
80 | |
68 static int dynamic_jack_set_process_callback(jack_client_t *client, | 81 static int dynamic_jack_set_process_callback(jack_client_t *client, |
69 JackProcessCallback process_callback, | 82 JackProcessCallback process_callback, |
70 void *arg) | 83 void *arg) |
71 { | 84 { |
72 typedef int (*func)(jack_client_t *client, | 85 typedef int (*func)(jack_client_t *client, |
173 dynamic1(int, jack_client_close, jack_client_t *, 1); | 186 dynamic1(int, jack_client_close, jack_client_t *, 1); |
174 dynamic1(jack_nframes_t, jack_port_get_latency, jack_port_t *, 0); | 187 dynamic1(jack_nframes_t, jack_port_get_latency, jack_port_t *, 0); |
175 dynamic1(const char *, jack_port_name, const jack_port_t *, 0); | 188 dynamic1(const char *, jack_port_name, const jack_port_t *, 0); |
176 | 189 |
177 #define jack_client_new dynamic_jack_client_new | 190 #define jack_client_new dynamic_jack_client_new |
191 #define jack_client_open dynamic_jack_client_open | |
178 #define jack_get_buffer_size dynamic_jack_get_buffer_size | 192 #define jack_get_buffer_size dynamic_jack_get_buffer_size |
179 #define jack_get_sample_rate dynamic_jack_get_sample_rate | 193 #define jack_get_sample_rate dynamic_jack_get_sample_rate |
180 #define jack_set_process_callback dynamic_jack_set_process_callback | 194 #define jack_set_process_callback dynamic_jack_set_process_callback |
181 #define jack_set_xrun_callback dynamic_jack_set_xrun_callback | 195 #define jack_set_xrun_callback dynamic_jack_set_xrun_callback |
182 #define jack_activate dynamic_jack_activate | 196 #define jack_activate dynamic_jack_activate |
197 AudioCallbackPlayTarget(source), | 211 AudioCallbackPlayTarget(source), |
198 m_client(0), | 212 m_client(0), |
199 m_bufferSize(0), | 213 m_bufferSize(0), |
200 m_sampleRate(0) | 214 m_sampleRate(0) |
201 { | 215 { |
202 char name[100]; | 216 JackOptions options = JackNullOption; |
203 strcpy(name, "Sonic Visualiser"); | 217 #ifdef HAVE_PORTAUDIO |
204 m_client = jack_client_new(name); | 218 options = JackNoStartServer; |
219 #endif | |
220 | |
221 JackStatus status = JackStatus(0); | |
222 m_client = jack_client_open("Sonic Visualiser", options, &status); | |
205 | 223 |
206 if (!m_client) { | 224 if (!m_client) { |
207 sprintf(name, "Sonic Visualiser (%d)", (int)getpid()); | 225 std::cerr << "AudioJACKTarget: Failed to connect to JACK server: status code " |
208 m_client = jack_client_new(name); | 226 << status << std::endl; |
209 if (!m_client) { | 227 return; |
210 std::cerr | 228 } |
211 << "ERROR: AudioJACKTarget: Failed to connect to JACK server" | |
212 << std::endl; | |
213 } | |
214 } | |
215 | |
216 if (!m_client) return; | |
217 | 229 |
218 m_bufferSize = jack_get_buffer_size(m_client); | 230 m_bufferSize = jack_get_buffer_size(m_client); |
219 m_sampleRate = jack_get_sample_rate(m_client); | 231 m_sampleRate = jack_get_sample_rate(m_client); |
220 | 232 |
221 jack_set_xrun_callback(m_client, xrunStatic, this); | 233 jack_set_xrun_callback(m_client, xrunStatic, this); |