You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
122 lines
3.3 KiB
122 lines
3.3 KiB
/* |
|
* Copyright (C) 2021 Alexandros Theodotou <alex at zrythm dot org> |
|
* |
|
* This program is free software: you can redistribute it and/or modify |
|
* it under the terms of the GNU Affero General Public License as published by |
|
* the Free Software Foundation, either version 3 of the License, or |
|
* (at your option) any later version. |
|
* |
|
* This program is distributed in the hope that it will be useful, |
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of |
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
|
* GNU Affero General Public License for more details. |
|
* |
|
* You should have received a copy of the GNU Affero General Public License |
|
* along with this program. If not, see <https://www.gnu.org/licenses/>. |
|
*/ |
|
|
|
#include "config.h" |
|
|
|
#include <stdbool.h> |
|
#include <stdio.h> |
|
|
|
#include <carla_api_tester_app.h> |
|
|
|
#define PROJECT_NAME "carla-api-tester" |
|
|
|
static char * arg0 = NULL; |
|
static char * format = NULL; |
|
static char * plugin = NULL; |
|
static char * bridge = NULL; |
|
static bool woe32_binary = false; |
|
|
|
int main(int argc, char **argv) |
|
{ |
|
arg0 = argv[0]; |
|
|
|
GOptionEntry entries[] = |
|
{ |
|
{ "format", 0, G_OPTION_FLAG_NONE, |
|
G_OPTION_ARG_STRING, &format, |
|
"Plugin format (lv2/vst2/vst3/au)", |
|
"FORMAT" }, |
|
{ "plugin", 0, G_OPTION_FLAG_NONE, |
|
G_OPTION_ARG_STRING, &plugin, |
|
"Path to plugin, or URI/identifier", |
|
"PLUGIN" }, |
|
{ "bridge", 0, G_OPTION_FLAG_NONE, |
|
G_OPTION_ARG_STRING, &bridge, |
|
"Bridge type (none/ui/full)", |
|
"BRIDGE-TYPE" }, |
|
{ "woe32-binary", 0, G_OPTION_FLAG_NONE, |
|
G_OPTION_ARG_NONE, &woe32_binary, |
|
"Whether the plugin is a Windows 32-bit " |
|
"binary", |
|
NULL }, |
|
{ NULL }, |
|
}; |
|
|
|
/* parse options */ |
|
GError *error = NULL; |
|
char context_str[500]; |
|
sprintf ( |
|
context_str, "[PROJECT-FILE] - Run %s", |
|
PROJECT_NAME); |
|
GOptionContext * context = |
|
g_option_context_new (context_str); |
|
g_option_context_add_main_entries ( |
|
context, entries, NULL); |
|
g_option_context_add_group ( |
|
context, gtk_get_option_group (false)); |
|
char examples[8000]; |
|
sprintf ( |
|
examples, |
|
"Examples:\n" |
|
" --plugin=urn:zamaudio:ZamComp --bridge=none --format=lv2\n" |
|
"Please report issues to %s\n", |
|
ISSUE_TRACKER_URL); |
|
g_option_context_set_description ( |
|
context, examples); |
|
char * null_terminated_args[argc + 1]; |
|
for (int i = 0; i < argc; i++) |
|
{ |
|
null_terminated_args[i] = argv[i]; |
|
} |
|
null_terminated_args[argc] = NULL; |
|
char ** allocated_args = |
|
g_strdupv (null_terminated_args); |
|
if (!g_option_context_parse_strv ( |
|
context, &allocated_args, &error)) |
|
{ |
|
g_error ( |
|
"option parsing failed: %s", |
|
error->message); |
|
} |
|
|
|
char * cur_dir = g_get_current_dir (); |
|
g_message ( |
|
"Running in %s", cur_dir); |
|
g_free (cur_dir); |
|
|
|
g_message ("GTK_THEME=%s", getenv ("GTK_THEME")); |
|
|
|
/* init random */ |
|
g_message ("Initing random..."); |
|
#ifdef _WOE32 |
|
srand ((unsigned int) time (NULL)); |
|
#else |
|
srandom ((unsigned int) time (NULL)); |
|
#endif |
|
|
|
carla_api_tester_app = |
|
carla_api_tester_app_new ( |
|
plugin, format, bridge, woe32_binary); |
|
|
|
g_message ("running app..."); |
|
int ret = |
|
g_application_run ( |
|
G_APPLICATION (carla_api_tester_app), 0, NULL); |
|
g_object_unref (carla_api_tester_app); |
|
|
|
return ret; |
|
}
|
|
|