[SCM] calf/master: + JackHost: better error reporting + JackHost: better reaction to client name conflict (which causes auto-rename) + JackHost: automatic preset activation (-p or --preset option)
js at users.alioth.debian.org
js at users.alioth.debian.org
Tue May 7 15:36:53 UTC 2013
The following commit has been merged in the master branch:
commit 7e225213086d322b20952ef8efb2eb7948097c09
Author: kfoltman <kfoltman at 78b06b96-2940-0410-b7fc-879d825d01d8>
Date: Wed Jan 2 18:55:05 2008 +0000
+ JackHost: better error reporting
+ JackHost: better reaction to client name conflict (which causes auto-rename)
+ JackHost: automatic preset activation (-p or --preset option)
git-svn-id: https://calf.svn.sourceforge.net/svnroot/calf/trunk@67 78b06b96-2940-0410-b7fc-879d825d01d8
diff --git a/src/calf/jackhost.h b/src/calf/jackhost.h
index 01d9857..2715e7d 100644
--- a/src/calf/jackhost.h
+++ b/src/calf/jackhost.h
@@ -61,12 +61,17 @@ public:
jack_status_t status;
client = jack_client_open(client_name, JackNullOption, &status);
if (!client)
- throw audio_exception("Could not initialize Jack subsystem");
+ throw audio_exception("Could not initialize JACK subsystem");
sample_rate = jack_get_sample_rate(client);
jack_set_process_callback(client, do_jack_process, this);
jack_set_buffer_size_callback(client, do_jack_bufsize, this);
}
+ std::string get_name()
+ {
+ return std::string(jack_get_client_name(client));
+ }
+
void activate()
{
jack_activate(client);
@@ -80,7 +85,7 @@ public:
void connect(const std::string &p1, const std::string &p2)
{
if (jack_connect(client, p1.c_str(), p2.c_str()) != 0)
- throw audio_exception("Could not connect ports "+p1+" and "+p2);
+ throw audio_exception("Could not connect JACK ports "+p1+" and "+p2);
}
void close()
@@ -153,17 +158,23 @@ public:
inputs[i].name = buf;
inputs[i].handle = jack_port_register(client->client, buf, JACK_DEFAULT_AUDIO_TYPE, JackPortIsInput | JackPortIsTerminal, 0);
inputs[i].data = NULL;
+ if (!inputs[i].handle)
+ throw audio_exception("Could not create JACK input port");
}
for (int i=0; i<out_count; i++) {
sprintf(buf, client->output_name.c_str(), client->output_nr++);
outputs[i].name = buf;
outputs[i].handle = jack_port_register(client->client, buf, JACK_DEFAULT_AUDIO_TYPE, JackPortIsOutput | JackPortIsTerminal, 0);
outputs[i].data = NULL;
+ if (!outputs[i].handle)
+ throw audio_exception("Could not create JACK output port");
}
if (get_midi()) {
sprintf(buf, client->midi_name.c_str(), client->midi_nr++);
midi_port.name = buf;
midi_port.handle = jack_port_register(client->client, buf, JACK_DEFAULT_MIDI_TYPE, JackPortIsInput | JackPortIsTerminal, 0);
+ if (!midi_port.handle)
+ throw audio_exception("Could not create JACK MIDI port");
}
}
diff --git a/src/jackhost.cpp b/src/jackhost.cpp
index a7304ae..39321b3 100644
--- a/src/jackhost.cpp
+++ b/src/jackhost.cpp
@@ -76,7 +76,7 @@ static struct option long_options[] = {
{"version", 0, 0, 'v'},
{"client", 1, 0, 'c'},
{"effect", 0, 0, 'e'},
- {"plugin", 0, 0, 'p'},
+ {"preset", 0, 0, 'p'},
{"input", 1, 0, 'i'},
{"output", 1, 0, 'o'},
{"connect-midi", 1, 0, 'M'},
@@ -87,7 +87,7 @@ void print_help(char *argv[])
{
printf("JACK host for Calf effects\n"
"Syntax: %s [--client <name>] [--input <name>] [--output <name>] [--midi <name>]\n"
- " [--connect-midi <name>] [--help] [--version] pluginname ...\n",
+ " [--connect-midi <name|capture-index>] [--help] [--version] [!] [--preset <name>] pluginname [!] ...\n",
argv[0]);
}
@@ -113,12 +113,14 @@ int main(int argc, char *argv[])
vector<jack_host_base *> plugins;
vector<plugin_gui_window *> guis;
set<int> chains;
+ map<int, string> preset_options;
+ map<int, string> presets;
string autoconnect_midi;
gtk_init(&argc, &argv);
glade_init();
while(1) {
int option_index;
- int c = getopt_long(argc, argv, "c:i:o:m:M:ephv", long_options, &option_index);
+ int c = getopt_long(argc, argv, "c:i:o:m:M:ep:hv", long_options, &option_index);
if (c == -1)
break;
switch(c) {
@@ -130,9 +132,11 @@ int main(int argc, char *argv[])
printf("%s\n", PACKAGE_STRING);
return 0;
case 'e':
- case 'p':
fprintf(stderr, "Warning: switch -%c is deprecated!\n", c);
break;
+ case 'p':
+ preset_options[optind] = optarg;
+ break;
case 'c':
client_name = optarg;
break;
@@ -146,7 +150,10 @@ int main(int argc, char *argv[])
client.midi_name = string(optarg) + "_%d";
break;
case 'M':
- autoconnect_midi = string(optarg);
+ if (atoi(optarg))
+ autoconnect_midi = "system:midi_capture_" + string(optarg);
+ else
+ autoconnect_midi = string(optarg);
break;
}
}
@@ -154,8 +161,14 @@ int main(int argc, char *argv[])
if (!strcmp(argv[optind], "!")) {
chains.insert(names.size());
optind++;
- } else
+ } else {
+ while (!preset_options.empty() && preset_options.begin()->first < optind) {
+ presets[names.size()] = preset_options.begin()->second;
+ // printf("preset[%s] = %s\n", argv[optind], presets[names.size()].c_str());
+ preset_options.erase(preset_options.begin());
+ }
names.push_back(argv[optind++]);
+ }
}
if (!names.size()) {
print_help(argv);
@@ -171,8 +184,10 @@ int main(int argc, char *argv[])
}
try {
client.open(client_name);
- string cnp = string(client_name) + ":";
+ string cnp = client.get_name() + ":";
for (unsigned int i = 0; i < names.size(); i++) {
+ // if (presets.count(i))
+ // printf("%s : %s\n", names[i].c_str(), presets[i].c_str());
jack_host_base *jh = create_jack_host(names[i].c_str());
if (!jh) {
#ifdef ENABLE_EXPERIMENTAL
@@ -189,6 +204,24 @@ int main(int argc, char *argv[])
guis.push_back(gui_win);
plugins.push_back(jh);
client.add(jh);
+ if (presets.count(i)) {
+ string cur_plugin = names[i];
+ string preset = presets[i];
+ preset_vector &pvec = global_presets.presets;
+ bool found = false;
+ for (unsigned int i = 0; i < pvec.size(); i++) {
+ if (pvec[i].name == preset && pvec[i].plugin == cur_plugin)
+ {
+ pvec[i].activate(jh);
+ gui_win->gui->refresh();
+ found = true;
+ break;
+ }
+ }
+ if (!found) {
+ fprintf(stderr, "Warning: unknown preset %s %s\n", preset.c_str(), cur_plugin.c_str());
+ }
+ }
}
client.activate();
for (unsigned int i = 0; i < plugins.size(); i++) {
--
calf audio plugins packaging
More information about the pkg-multimedia-commits
mailing list