git-svn-id: http://subversion.jackaudio.org/jack/jack2/trunk/jackmp@2340 0c269be4-1314-0410-8aa9-9f06e86f4224tags/1.90
| @@ -0,0 +1,921 @@ | |||
| /* -*- Mode: C++ ; c-basic-offset: 4 -*- */ | |||
| /* | |||
| JACK control API implementation | |||
| Copyright (C) 2008 Nedko Arnaudov | |||
| This program is free software; you can redistribute it and/or modify | |||
| it under the terms of the GNU General Public License as published by | |||
| the Free Software Foundation; version 2 of the License. | |||
| 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 General Public License for more details. | |||
| You should have received a copy of the GNU General Public License | |||
| along with this program; if not, write to the Free Software | |||
| Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. | |||
| */ | |||
| #ifndef WIN32 | |||
| #include <stdbool.h> | |||
| #include <stdint.h> | |||
| #include <dirent.h> | |||
| #include <pthread.h> | |||
| #endif | |||
| #include "types.h" | |||
| #include <string.h> | |||
| #include <errno.h> | |||
| #include <stdio.h> | |||
| #include <assert.h> | |||
| #include <signal.h> | |||
| #include "jslist.h" | |||
| #include "driver_interface.h" | |||
| #include "JackError.h" | |||
| #include "JackServer.h" | |||
| #include "shm.h" | |||
| #include "JackTools.h" | |||
| #include "control_types.h" | |||
| using namespace Jack; | |||
| struct jackctl_server | |||
| { | |||
| JSList * drivers; | |||
| JSList * parameters; | |||
| class JackServer * engine; | |||
| /* string, server name */ | |||
| union jackctl_parameter_value name; | |||
| union jackctl_parameter_value default_name; | |||
| /* bool, whether to be "realtime" */ | |||
| union jackctl_parameter_value realtime; | |||
| union jackctl_parameter_value default_realtime; | |||
| /* int32_t */ | |||
| union jackctl_parameter_value realtime_priority; | |||
| union jackctl_parameter_value default_realtime_priority; | |||
| /* bool, whether to exit once all clients have closed their connections */ | |||
| union jackctl_parameter_value temporary; | |||
| union jackctl_parameter_value default_temporary; | |||
| /* bool, whether to be verbose */ | |||
| union jackctl_parameter_value verbose; | |||
| union jackctl_parameter_value default_verbose; | |||
| /* int32_t, msecs; if zero, use period size. */ | |||
| union jackctl_parameter_value client_timeout; | |||
| union jackctl_parameter_value default_client_timeout; | |||
| /* uint32_t, ports of the loopback driver */ | |||
| union jackctl_parameter_value loopback_ports; | |||
| union jackctl_parameter_value default_loopback_ports; | |||
| /* bool */ | |||
| union jackctl_parameter_value replace_registry; | |||
| union jackctl_parameter_value default_replace_registry; | |||
| /* bool, synchronous or asynchronous engine mode */ | |||
| union jackctl_parameter_value sync; | |||
| union jackctl_parameter_value default_sync; | |||
| }; | |||
| struct jackctl_driver | |||
| { | |||
| jack_driver_desc_t * desc_ptr; | |||
| JSList * parameters; | |||
| JSList * set_parameters; | |||
| }; | |||
| struct jackctl_parameter | |||
| { | |||
| const char * name; | |||
| const char * short_description; | |||
| const char * long_description; | |||
| jackctl_param_type_t type; | |||
| bool is_set; | |||
| union jackctl_parameter_value * value_ptr; | |||
| union jackctl_parameter_value * default_value_ptr; | |||
| union jackctl_parameter_value value; | |||
| union jackctl_parameter_value default_value; | |||
| struct jackctl_driver * driver_ptr; | |||
| char id; | |||
| jack_driver_param_t * driver_parameter_ptr; | |||
| }; | |||
| static | |||
| struct jackctl_parameter * | |||
| jackctl_add_parameter( | |||
| JSList ** parameters_list_ptr_ptr, | |||
| const char * name, | |||
| const char * short_description, | |||
| const char * long_description, | |||
| jackctl_param_type_t type, | |||
| union jackctl_parameter_value * value_ptr, | |||
| union jackctl_parameter_value * default_value_ptr, | |||
| union jackctl_parameter_value value) | |||
| { | |||
| struct jackctl_parameter * parameter_ptr; | |||
| parameter_ptr = (struct jackctl_parameter *)malloc(sizeof(struct jackctl_parameter)); | |||
| if (parameter_ptr == NULL) | |||
| { | |||
| jack_error("Cannot allocate memory for jackctl_parameter structure."); | |||
| goto fail; | |||
| } | |||
| parameter_ptr->name = name; | |||
| parameter_ptr->short_description = short_description; | |||
| parameter_ptr->long_description = long_description; | |||
| parameter_ptr->type = type; | |||
| parameter_ptr->is_set = false; | |||
| if (value_ptr == NULL) | |||
| { | |||
| value_ptr = ¶meter_ptr->value; | |||
| } | |||
| if (default_value_ptr == NULL) | |||
| { | |||
| default_value_ptr = ¶meter_ptr->default_value; | |||
| } | |||
| parameter_ptr->value_ptr = value_ptr; | |||
| parameter_ptr->default_value_ptr = default_value_ptr; | |||
| *value_ptr = *default_value_ptr = value; | |||
| parameter_ptr->driver_ptr = NULL; | |||
| parameter_ptr->driver_parameter_ptr = NULL; | |||
| parameter_ptr->id = 0; | |||
| *parameters_list_ptr_ptr = jack_slist_append(*parameters_list_ptr_ptr, parameter_ptr); | |||
| return parameter_ptr; | |||
| fail: | |||
| return NULL; | |||
| } | |||
| static | |||
| void | |||
| jackctl_free_driver_parameters( | |||
| struct jackctl_driver * driver_ptr) | |||
| { | |||
| JSList * next_node_ptr; | |||
| while (driver_ptr->parameters) | |||
| { | |||
| next_node_ptr = driver_ptr->parameters->next; | |||
| free(driver_ptr->parameters->data); | |||
| free(driver_ptr->parameters); | |||
| driver_ptr->parameters = next_node_ptr; | |||
| } | |||
| while (driver_ptr->set_parameters) | |||
| { | |||
| next_node_ptr = driver_ptr->set_parameters->next; | |||
| free(driver_ptr->set_parameters->data); | |||
| free(driver_ptr->set_parameters); | |||
| driver_ptr->set_parameters = next_node_ptr; | |||
| } | |||
| } | |||
| static | |||
| bool | |||
| jackctl_add_driver_parameters( | |||
| struct jackctl_driver * driver_ptr) | |||
| { | |||
| uint32_t i; | |||
| union jackctl_parameter_value jackctl_value; | |||
| jackctl_param_type_t jackctl_type; | |||
| struct jackctl_parameter * parameter_ptr; | |||
| jack_driver_param_desc_t * descriptor_ptr; | |||
| for (i = 0 ; i < driver_ptr->desc_ptr->nparams ; i++) | |||
| { | |||
| descriptor_ptr = driver_ptr->desc_ptr->params + i; | |||
| switch (descriptor_ptr->type) | |||
| { | |||
| case JackDriverParamInt: | |||
| jackctl_type = JackParamInt; | |||
| jackctl_value.i = descriptor_ptr->value.i; | |||
| break; | |||
| case JackDriverParamUInt: | |||
| jackctl_type = JackParamUInt; | |||
| jackctl_value.ui = descriptor_ptr->value.ui; | |||
| break; | |||
| case JackDriverParamChar: | |||
| jackctl_type = JackParamChar; | |||
| jackctl_value.c = descriptor_ptr->value.c; | |||
| break; | |||
| case JackDriverParamString: | |||
| jackctl_type = JackParamString; | |||
| strcpy(jackctl_value.str, descriptor_ptr->value.str); | |||
| break; | |||
| case JackDriverParamBool: | |||
| jackctl_type = JackParamBool; | |||
| jackctl_value.b = descriptor_ptr->value.i; | |||
| break; | |||
| default: | |||
| jack_error("unknown driver parameter type %i", (int)descriptor_ptr->type); | |||
| assert(0); | |||
| goto fail; | |||
| } | |||
| parameter_ptr = jackctl_add_parameter( | |||
| &driver_ptr->parameters, | |||
| descriptor_ptr->name, | |||
| descriptor_ptr->short_desc, | |||
| descriptor_ptr->long_desc, | |||
| jackctl_type, | |||
| NULL, | |||
| NULL, | |||
| jackctl_value); | |||
| if (parameter_ptr == NULL) | |||
| { | |||
| goto fail; | |||
| } | |||
| parameter_ptr->driver_ptr = driver_ptr; | |||
| parameter_ptr->id = descriptor_ptr->character; | |||
| } | |||
| return true; | |||
| fail: | |||
| jackctl_free_driver_parameters(driver_ptr); | |||
| return false; | |||
| } | |||
| static int | |||
| jackctl_drivers_load( | |||
| struct jackctl_server * server_ptr) | |||
| { | |||
| struct jackctl_driver * driver_ptr; | |||
| JSList *node_ptr; | |||
| JSList *descriptor_node_ptr; | |||
| descriptor_node_ptr = jack_drivers_load(NULL); | |||
| if (descriptor_node_ptr == NULL) | |||
| { | |||
| jack_error("could not find any drivers in direver directory!"); | |||
| return false; | |||
| } | |||
| while (descriptor_node_ptr != NULL) | |||
| { | |||
| driver_ptr = (struct jackctl_driver *)malloc(sizeof(struct jackctl_driver)); | |||
| if (driver_ptr == NULL) | |||
| { | |||
| jack_error("memory allocation of jackctl_driver structure failed."); | |||
| goto next; | |||
| } | |||
| driver_ptr->desc_ptr = (jack_driver_desc_t *)descriptor_node_ptr->data; | |||
| driver_ptr->parameters = NULL; | |||
| driver_ptr->set_parameters = NULL; | |||
| if (!jackctl_add_driver_parameters(driver_ptr)) | |||
| { | |||
| assert(driver_ptr->parameters == NULL); | |||
| free(driver_ptr); | |||
| goto next; | |||
| } | |||
| server_ptr->drivers = jack_slist_append(server_ptr->drivers, driver_ptr); | |||
| next: | |||
| node_ptr = descriptor_node_ptr; | |||
| descriptor_node_ptr = descriptor_node_ptr->next; | |||
| free(node_ptr); | |||
| } | |||
| return true; | |||
| } | |||
| static | |||
| void | |||
| jackctl_server_free_drivers( | |||
| struct jackctl_server * server_ptr) | |||
| { | |||
| JSList * next_node_ptr; | |||
| struct jackctl_driver * driver_ptr; | |||
| while (server_ptr->drivers) | |||
| { | |||
| next_node_ptr = server_ptr->drivers->next; | |||
| driver_ptr = (struct jackctl_driver *)server_ptr->drivers->data; | |||
| jackctl_free_driver_parameters(driver_ptr); | |||
| free(driver_ptr->desc_ptr->params); | |||
| free(driver_ptr->desc_ptr); | |||
| free(driver_ptr); | |||
| free(server_ptr->drivers); | |||
| server_ptr->drivers = next_node_ptr; | |||
| } | |||
| } | |||
| static | |||
| void | |||
| jackctl_server_free_parameters( | |||
| struct jackctl_server * server_ptr) | |||
| { | |||
| JSList * next_node_ptr; | |||
| while (server_ptr->parameters) | |||
| { | |||
| next_node_ptr = server_ptr->parameters->next; | |||
| free(server_ptr->parameters->data); | |||
| free(server_ptr->parameters); | |||
| server_ptr->parameters = next_node_ptr; | |||
| } | |||
| } | |||
| #ifdef WIN32 | |||
| static HANDLE waitEvent; | |||
| static void do_nothing_handler(int signum) | |||
| { | |||
| printf("jack main caught signal %d\n", signum); | |||
| (void) signal(SIGINT, SIG_DFL); | |||
| SetEvent(waitEvent); | |||
| } | |||
| sigset_t | |||
| jackctl_setup_signals( | |||
| unsigned int flags) | |||
| { | |||
| if ((waitEvent = CreateEvent(NULL, FALSE, FALSE, NULL)) == NULL) { | |||
| jack_error("CreateEvent fails err = %ld", GetLastError()); | |||
| return 0; | |||
| } | |||
| (void) signal(SIGINT, do_nothing_handler); | |||
| (void) signal(SIGABRT, do_nothing_handler); | |||
| (void) signal(SIGTERM, do_nothing_handler); | |||
| return waitEvent; | |||
| } | |||
| void jackctl_wait_signals(sigset_t signals) | |||
| { | |||
| if (WaitForSingleObject(waitEvent, INFINITE) != WAIT_OBJECT_0) { | |||
| jack_error("WaitForSingleObject fails err = %ld", GetLastError()); | |||
| } | |||
| } | |||
| #else | |||
| static | |||
| void | |||
| do_nothing_handler(int sig) | |||
| { | |||
| /* this is used by the child (active) process, but it never | |||
| gets called unless we are already shutting down after | |||
| another signal. | |||
| */ | |||
| char buf[64]; | |||
| snprintf (buf, sizeof(buf), | |||
| "received signal %d during shutdown (ignored)\n", sig); | |||
| write (1, buf, strlen (buf)); | |||
| } | |||
| EXPORT sigset_t | |||
| jackctl_setup_signals( | |||
| unsigned int flags) | |||
| { | |||
| sigset_t signals; | |||
| sigset_t allsignals; | |||
| struct sigaction action; | |||
| int i; | |||
| /* ensure that we are in our own process group so that | |||
| kill (SIG, -pgrp) does the right thing. | |||
| */ | |||
| setsid(); | |||
| pthread_setcanceltype(PTHREAD_CANCEL_ASYNCHRONOUS, NULL); | |||
| /* what's this for? | |||
| POSIX says that signals are delivered like this: | |||
| * if a thread has blocked that signal, it is not | |||
| a candidate to receive the signal. | |||
| * of all threads not blocking the signal, pick | |||
| one at random, and deliver the signal. | |||
| this means that a simple-minded multi-threaded program can | |||
| expect to get POSIX signals delivered randomly to any one | |||
| of its threads, | |||
| here, we block all signals that we think we might receive | |||
| and want to catch. all "child" threads will inherit this | |||
| setting. if we create a thread that calls sigwait() on the | |||
| same set of signals, implicitly unblocking all those | |||
| signals. any of those signals that are delivered to the | |||
| process will be delivered to that thread, and that thread | |||
| alone. this makes cleanup for a signal-driven exit much | |||
| easier, since we know which thread is doing it and more | |||
| importantly, we are free to call async-unsafe functions, | |||
| because the code is executing in normal thread context | |||
| after a return from sigwait(). | |||
| */ | |||
| sigemptyset(&signals); | |||
| sigaddset(&signals, SIGHUP); | |||
| sigaddset(&signals, SIGINT); | |||
| sigaddset(&signals, SIGQUIT); | |||
| sigaddset(&signals, SIGPIPE); | |||
| sigaddset(&signals, SIGTERM); | |||
| sigaddset(&signals, SIGUSR1); | |||
| sigaddset(&signals, SIGUSR2); | |||
| /* all child threads will inherit this mask unless they | |||
| * explicitly reset it | |||
| */ | |||
| pthread_sigmask(SIG_BLOCK, &signals, 0); | |||
| /* install a do-nothing handler because otherwise pthreads | |||
| behaviour is undefined when we enter sigwait. | |||
| */ | |||
| sigfillset(&allsignals); | |||
| action.sa_handler = do_nothing_handler; | |||
| action.sa_mask = allsignals; | |||
| action.sa_flags = SA_RESTART|SA_RESETHAND; | |||
| for (i = 1; i < NSIG; i++) | |||
| { | |||
| if (sigismember (&signals, i)) | |||
| { | |||
| sigaction(i, &action, 0); | |||
| } | |||
| } | |||
| return signals; | |||
| } | |||
| EXPORT void | |||
| jackctl_wait_signals(sigset_t signals) | |||
| { | |||
| int sig; | |||
| bool waiting = true; | |||
| while (waiting) { | |||
| sigwait(&signals, &sig); | |||
| fprintf(stderr, "jack main caught signal %d\n", sig); | |||
| switch (sig) { | |||
| case SIGUSR1: | |||
| //jack_dump_configuration(engine, 1); | |||
| break; | |||
| case SIGUSR2: | |||
| // driver exit | |||
| waiting = false; | |||
| break; | |||
| default: | |||
| waiting = false; | |||
| break; | |||
| } | |||
| } | |||
| if (sig != SIGSEGV) { | |||
| // unblock signals so we can see them during shutdown. | |||
| // this will help prod developers not to lose sight of | |||
| // bugs that cause segfaults etc. during shutdown. | |||
| sigprocmask(SIG_UNBLOCK, &signals, 0); | |||
| } | |||
| } | |||
| #endif | |||
| EXPORT jackctl_server_t * jackctl_server_create() | |||
| { | |||
| struct jackctl_server * server_ptr; | |||
| union jackctl_parameter_value value; | |||
| server_ptr = (struct jackctl_server *)malloc(sizeof(struct jackctl_server)); | |||
| if (server_ptr == NULL) | |||
| { | |||
| jack_error("Cannot allocate memory for jackctl_server structure."); | |||
| goto fail; | |||
| } | |||
| server_ptr->drivers = NULL; | |||
| server_ptr->parameters = NULL; | |||
| server_ptr->engine = NULL; | |||
| strcpy(value.str, JACK_DEFAULT_SERVER_NAME); | |||
| if (jackctl_add_parameter( | |||
| &server_ptr->parameters, | |||
| "name", | |||
| "server name to use", | |||
| "", | |||
| JackParamString, | |||
| &server_ptr->name, | |||
| &server_ptr->default_name, | |||
| value) == NULL) | |||
| { | |||
| goto fail_free_parameters; | |||
| } | |||
| value.b = false; | |||
| if (jackctl_add_parameter( | |||
| &server_ptr->parameters, | |||
| "realtime", | |||
| "Whether to use realtime mode", | |||
| "Use realtime scheduling. This is needed for reliable low-latency performance. On most systems, it requires JACK to run with special scheduler and memory allocation privileges, which may be obtained in several ways. On Linux you should use PAM.", | |||
| JackParamBool, | |||
| &server_ptr->realtime, | |||
| &server_ptr->default_realtime, | |||
| value) == NULL) | |||
| { | |||
| goto fail_free_parameters; | |||
| } | |||
| value.i = 10; | |||
| if (jackctl_add_parameter( | |||
| &server_ptr->parameters, | |||
| "realtime-priority", | |||
| "Scheduler priority when running in realtime mode.", | |||
| "", | |||
| JackParamInt, | |||
| &server_ptr->realtime_priority, | |||
| &server_ptr->default_realtime_priority, | |||
| value) == NULL) | |||
| { | |||
| goto fail_free_parameters; | |||
| } | |||
| value.b = false; | |||
| if (jackctl_add_parameter( | |||
| &server_ptr->parameters, | |||
| "temporary", | |||
| "Exit once all clients have closed their connections.", | |||
| "", | |||
| JackParamBool, | |||
| &server_ptr->temporary, | |||
| &server_ptr->default_temporary, | |||
| value) == NULL) | |||
| { | |||
| goto fail_free_parameters; | |||
| } | |||
| value.b = false; | |||
| if (jackctl_add_parameter( | |||
| &server_ptr->parameters, | |||
| "verbose", | |||
| "Verbose mode.", | |||
| "", | |||
| JackParamBool, | |||
| &server_ptr->verbose, | |||
| &server_ptr->default_verbose, | |||
| value) == NULL) | |||
| { | |||
| goto fail_free_parameters; | |||
| } | |||
| value.i = 0; | |||
| if (jackctl_add_parameter( | |||
| &server_ptr->parameters, | |||
| "client-timeout", | |||
| "Client timeout limit in milliseconds", | |||
| "", | |||
| JackParamInt, | |||
| &server_ptr->client_timeout, | |||
| &server_ptr->default_client_timeout, | |||
| value) == NULL) | |||
| { | |||
| goto fail_free_parameters; | |||
| } | |||
| value.ui = 0; | |||
| if (jackctl_add_parameter( | |||
| &server_ptr->parameters, | |||
| "loopback-ports", | |||
| "Number of loopback ports", | |||
| "", | |||
| JackParamUInt, | |||
| &server_ptr->loopback_ports, | |||
| &server_ptr->default_loopback_ports, | |||
| value) == NULL) | |||
| { | |||
| goto fail_free_parameters; | |||
| } | |||
| value.b = false; | |||
| if (jackctl_add_parameter( | |||
| &server_ptr->parameters, | |||
| "replace-registry", | |||
| "Replace registry", | |||
| "", | |||
| JackParamBool, | |||
| &server_ptr->replace_registry, | |||
| &server_ptr->default_replace_registry, | |||
| value) == NULL) | |||
| { | |||
| goto fail_free_parameters; | |||
| } | |||
| value.b = false; | |||
| if (jackctl_add_parameter( | |||
| &server_ptr->parameters, | |||
| "sync", | |||
| "Use synchronous mode", | |||
| "", | |||
| JackParamBool, | |||
| &server_ptr->sync, | |||
| &server_ptr->default_sync, | |||
| value) == NULL) | |||
| { | |||
| goto fail_free_parameters; | |||
| } | |||
| if (!jackctl_drivers_load(server_ptr)) | |||
| { | |||
| goto fail_free_parameters; | |||
| } | |||
| return server_ptr; | |||
| fail_free_parameters: | |||
| jackctl_server_free_parameters(server_ptr); | |||
| free(server_ptr); | |||
| fail: | |||
| return NULL; | |||
| } | |||
| EXPORT void jackctl_server_destroy(jackctl_server *server_ptr) | |||
| { | |||
| jackctl_server_free_drivers(server_ptr); | |||
| jackctl_server_free_parameters(server_ptr); | |||
| free(server_ptr); | |||
| } | |||
| EXPORT const JSList * jackctl_server_get_drivers_list(jackctl_server *server_ptr) | |||
| { | |||
| return server_ptr->drivers; | |||
| } | |||
| EXPORT bool jackctl_server_stop(jackctl_server *server_ptr) | |||
| { | |||
| server_ptr->engine->Stop(); | |||
| server_ptr->engine->Close(); | |||
| delete server_ptr->engine; | |||
| /* clean up shared memory and files from this server instance */ | |||
| jack_log("cleaning up shared memory"); | |||
| jack_cleanup_shm(); | |||
| jack_log("cleaning up files"); | |||
| JackTools::CleanupFiles(server_ptr->name.str); | |||
| jack_log("unregistering server `%s'", server_ptr->name.str); | |||
| jack_unregister_server(server_ptr->name.str); | |||
| server_ptr->engine = NULL; | |||
| return true; | |||
| } | |||
| EXPORT const JSList * jackctl_server_get_parameters(jackctl_server *server_ptr) | |||
| { | |||
| return server_ptr->parameters; | |||
| } | |||
| EXPORT bool | |||
| jackctl_server_start( | |||
| jackctl_server *server_ptr, | |||
| jackctl_driver *driver_ptr) | |||
| { | |||
| int rc; | |||
| rc = jack_register_server(server_ptr->name.str, server_ptr->replace_registry.b); | |||
| switch (rc) | |||
| { | |||
| case EEXIST: | |||
| jack_error("`%s' server already active", server_ptr->name.str); | |||
| goto fail; | |||
| case ENOSPC: | |||
| jack_error("too many servers already active"); | |||
| goto fail; | |||
| case ENOMEM: | |||
| jack_error("no access to shm registry"); | |||
| goto fail; | |||
| } | |||
| jack_log("server `%s' registered", server_ptr->name.str); | |||
| /* clean up shared memory and files from any previous | |||
| * instance of this server name */ | |||
| jack_cleanup_shm(); | |||
| JackTools::CleanupFiles(server_ptr->name.str); | |||
| if (!server_ptr->realtime.b && server_ptr->client_timeout.i == 0) | |||
| server_ptr->client_timeout.i = 500; /* 0.5 sec; usable when non realtime. */ | |||
| /* get the engine/driver started */ | |||
| server_ptr->engine = new JackServer( | |||
| server_ptr->sync.b, | |||
| server_ptr->temporary.b, | |||
| server_ptr->client_timeout.i, | |||
| server_ptr->realtime.b, | |||
| server_ptr->realtime_priority.i, | |||
| server_ptr->loopback_ports.ui, | |||
| server_ptr->verbose.b, | |||
| server_ptr->name.str); | |||
| if (server_ptr->engine == NULL) | |||
| { | |||
| jack_error("Failed to create new JackServer object"); | |||
| goto fail_unregister; | |||
| } | |||
| rc = server_ptr->engine->Open(driver_ptr->desc_ptr, driver_ptr->set_parameters); | |||
| if (rc < 0) | |||
| { | |||
| jack_error("JackServer::Open() failed with %d", rc); | |||
| goto fail_delete; | |||
| } | |||
| rc = server_ptr->engine->Start(); | |||
| if (rc < 0) | |||
| { | |||
| jack_error("JackServer::Start() failed with %d", rc); | |||
| goto fail_close; | |||
| } | |||
| return true; | |||
| fail_close: | |||
| server_ptr->engine->Close(); | |||
| fail_delete: | |||
| delete server_ptr->engine; | |||
| server_ptr->engine = NULL; | |||
| fail_unregister: | |||
| jack_log("cleaning up shared memory"); | |||
| jack_cleanup_shm(); | |||
| jack_log("cleaning up files"); | |||
| JackTools::CleanupFiles(server_ptr->name.str); | |||
| jack_log("unregistering server `%s'", server_ptr->name.str); | |||
| jack_unregister_server(server_ptr->name.str); | |||
| fail: | |||
| return false; | |||
| } | |||
| EXPORT const char * jackctl_driver_get_name(jackctl_driver *driver_ptr) | |||
| { | |||
| return driver_ptr->desc_ptr->name; | |||
| } | |||
| EXPORT const JSList * jackctl_driver_get_parameters(jackctl_driver *driver_ptr) | |||
| { | |||
| return driver_ptr->parameters; | |||
| } | |||
| EXPORT jack_driver_desc_t * jackctl_driver_get_desc(jackctl_driver_t * driver_ptr) | |||
| { | |||
| return driver_ptr->desc_ptr; | |||
| } | |||
| EXPORT const char * jackctl_parameter_get_name(jackctl_parameter *parameter_ptr) | |||
| { | |||
| return parameter_ptr->name; | |||
| } | |||
| EXPORT const char * jackctl_parameter_get_short_description(jackctl_parameter *parameter_ptr) | |||
| { | |||
| return parameter_ptr->short_description; | |||
| } | |||
| EXPORT const char * jackctl_parameter_get_long_description(jackctl_parameter *parameter_ptr) | |||
| { | |||
| return parameter_ptr->long_description; | |||
| } | |||
| EXPORT jackctl_param_type_t jackctl_parameter_get_type(jackctl_parameter *parameter_ptr) | |||
| { | |||
| return parameter_ptr->type; | |||
| } | |||
| EXPORT char jackctl_parameter_get_id(jackctl_parameter_t * parameter_ptr) | |||
| { | |||
| return parameter_ptr->id; | |||
| } | |||
| EXPORT bool jackctl_parameter_is_set(jackctl_parameter *parameter_ptr) | |||
| { | |||
| return parameter_ptr->is_set; | |||
| } | |||
| EXPORT union jackctl_parameter_value jackctl_parameter_get_value(jackctl_parameter *parameter_ptr) | |||
| { | |||
| return *parameter_ptr->value_ptr; | |||
| } | |||
| EXPORT bool jackctl_parameter_reset_value(jackctl_parameter *parameter_ptr) | |||
| { | |||
| if (!parameter_ptr->is_set) | |||
| { | |||
| return true; | |||
| } | |||
| parameter_ptr->is_set = true; | |||
| *parameter_ptr->value_ptr = *parameter_ptr->default_value_ptr; | |||
| return true; | |||
| } | |||
| EXPORT bool jackctl_parameter_set_value(jackctl_parameter *parameter_ptr, const union jackctl_parameter_value * value_ptr) | |||
| { | |||
| bool new_driver_parameter; | |||
| /* for driver parameters, set the parameter by adding jack_driver_param_t in the set_parameters list */ | |||
| if (parameter_ptr->driver_ptr != NULL) | |||
| { | |||
| /* jack_info("setting driver parameter %p ...", parameter_ptr); */ | |||
| new_driver_parameter = parameter_ptr->driver_parameter_ptr == NULL; | |||
| if (new_driver_parameter) | |||
| { | |||
| /* jack_info("new driver parameter..."); */ | |||
| parameter_ptr->driver_parameter_ptr = (jack_driver_param_t *)malloc(sizeof(jack_driver_param_t)); | |||
| if (parameter_ptr->driver_parameter_ptr == NULL) | |||
| { | |||
| jack_error ("Allocation of jack_driver_param_t structure failed"); | |||
| return false; | |||
| } | |||
| parameter_ptr->driver_parameter_ptr->character = parameter_ptr->id; | |||
| parameter_ptr->driver_ptr->set_parameters = jack_slist_append(parameter_ptr->driver_ptr->set_parameters, parameter_ptr->driver_parameter_ptr); | |||
| } | |||
| switch (parameter_ptr->type) | |||
| { | |||
| case JackParamInt: | |||
| parameter_ptr->driver_parameter_ptr->value.i = value_ptr->i; | |||
| break; | |||
| case JackParamUInt: | |||
| parameter_ptr->driver_parameter_ptr->value.ui = value_ptr->ui; | |||
| break; | |||
| case JackParamChar: | |||
| parameter_ptr->driver_parameter_ptr->value.c = value_ptr->c; | |||
| break; | |||
| case JackParamString: | |||
| strcpy(parameter_ptr->driver_parameter_ptr->value.str, value_ptr->str); | |||
| break; | |||
| case JackParamBool: | |||
| parameter_ptr->driver_parameter_ptr->value.i = value_ptr->b; | |||
| break; | |||
| default: | |||
| jack_error("unknown parameter type %i", (int)parameter_ptr->type); | |||
| assert(0); | |||
| if (new_driver_parameter) | |||
| { | |||
| parameter_ptr->driver_ptr->set_parameters = jack_slist_remove(parameter_ptr->driver_ptr->set_parameters, parameter_ptr->driver_parameter_ptr); | |||
| } | |||
| return false; | |||
| } | |||
| } | |||
| parameter_ptr->is_set = true; | |||
| *parameter_ptr->value_ptr = *value_ptr; | |||
| return true; | |||
| } | |||
| EXPORT union jackctl_parameter_value jackctl_parameter_get_default_value(jackctl_parameter *parameter_ptr) | |||
| { | |||
| return *parameter_ptr->default_value_ptr; | |||
| } | |||
| @@ -0,0 +1,134 @@ | |||
| /* | |||
| Copyright (C) 2001 Paul Davis | |||
| Copyright (C) 2004-2008 Grame | |||
| Copyright (C) 2008 Nedko Arnaudov | |||
| This program is free software; you can redistribute it and/or modify | |||
| it under the terms of the GNU General Public License as published by | |||
| the Free Software Foundation; either version 2 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 General Public License for more details. | |||
| You should have received a copy of the GNU General Public License | |||
| along with this program; if not, write to the Free Software | |||
| Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. | |||
| */ | |||
| #include <stdarg.h> | |||
| #include <stdio.h> | |||
| #include "JackError.h" | |||
| #include "JackGlobals.h" | |||
| #include "JackMessageBuffer.h" | |||
| int jack_verbose = 0; | |||
| void change_thread_log_function(jack_log_function_t log_function) | |||
| { | |||
| if (!jack_tls_set(g_key_log_function, (void*)log_function)) | |||
| { | |||
| jack_error("failed to set thread log function"); | |||
| } | |||
| } | |||
| EXPORT void set_threaded_log_function() | |||
| { | |||
| change_thread_log_function(Jack::JackMessageBufferAdd); | |||
| } | |||
| void jack_log_function(int level, const char *message) | |||
| { | |||
| void (* log_callback)(const char *); | |||
| switch (level) | |||
| { | |||
| case LOG_LEVEL_INFO: | |||
| log_callback = jack_info_callback; | |||
| break; | |||
| case LOG_LEVEL_ERROR: | |||
| log_callback = jack_error_callback; | |||
| break; | |||
| default: | |||
| return; | |||
| } | |||
| log_callback(message); | |||
| } | |||
| static | |||
| void | |||
| jack_format_and_log(int level, const char *prefix, const char *fmt, va_list ap) | |||
| { | |||
| char buffer[300]; | |||
| size_t len; | |||
| jack_log_function_t log_function; | |||
| if (prefix != NULL) { | |||
| len = strlen(prefix); | |||
| memcpy(buffer, prefix, len); | |||
| } else { | |||
| len = 0; | |||
| } | |||
| vsnprintf(buffer + len, sizeof(buffer) - len, fmt, ap); | |||
| log_function = (jack_log_function_t)jack_tls_get(g_key_log_function); | |||
| /* if log function is not overriden for thread, use default one */ | |||
| if (log_function == NULL) | |||
| { | |||
| log_function = jack_log_function; | |||
| //log_function(LOG_LEVEL_INFO, "------ Using default log function"); | |||
| } | |||
| else | |||
| { | |||
| //log_function(LOG_LEVEL_INFO, "++++++ Using thread-specific log function"); | |||
| } | |||
| log_function(level, buffer); | |||
| } | |||
| EXPORT void jack_error(const char *fmt, ...) | |||
| { | |||
| va_list ap; | |||
| va_start(ap, fmt); | |||
| jack_format_and_log(LOG_LEVEL_ERROR, NULL, fmt, ap); | |||
| va_end(ap); | |||
| } | |||
| EXPORT void jack_info(const char *fmt, ...) | |||
| { | |||
| va_list ap; | |||
| va_start(ap, fmt); | |||
| jack_format_and_log(LOG_LEVEL_INFO, NULL, fmt, ap); | |||
| va_end(ap); | |||
| } | |||
| EXPORT void jack_log(const char *fmt,...) | |||
| { | |||
| if (jack_verbose) { | |||
| va_list ap; | |||
| va_start(ap, fmt); | |||
| jack_format_and_log(LOG_LEVEL_INFO, "Jack: ", fmt, ap); | |||
| va_end(ap); | |||
| } | |||
| } | |||
| static void default_jack_error_callback(const char *desc) | |||
| { | |||
| fprintf(stderr, "%s\n", desc); | |||
| fflush(stderr); | |||
| } | |||
| static void default_jack_info_callback (const char *desc) | |||
| { | |||
| fprintf(stdout, "%s\n", desc); | |||
| fflush(stdout); | |||
| } | |||
| void (*jack_error_callback)(const char *desc) = &default_jack_error_callback; | |||
| void (*jack_info_callback)(const char *desc) = &default_jack_info_callback; | |||
| @@ -0,0 +1,120 @@ | |||
| /* | |||
| * messagebuffer.h -- realtime-safe message interface for jackd. | |||
| * | |||
| * This function is included in libjack so backend drivers can use | |||
| * it, *not* for external client processes. The VERBOSE() and | |||
| * MESSAGE() macros are realtime-safe. | |||
| */ | |||
| /* | |||
| * Copyright (C) 2004 Rui Nuno Capela, Steve Harris | |||
| * Copyright (C) 2008 Nedko Arnaudov | |||
| * Copyright (C) 2008 Grame | |||
| * | |||
| * This program is free software; you can redistribute it and/or modify | |||
| * it under the terms of the GNU Lesser General Public License as published by | |||
| * the Free Software Foundation; either version 2.1 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 Lesser General Public License for more details. | |||
| * | |||
| * You should have received a copy of the GNU Lesser General Public License | |||
| * along with this program; if not, write to the Free Software | |||
| * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. | |||
| * | |||
| */ | |||
| #include "JackMessageBuffer.h" | |||
| #include "JackGlobals.h" | |||
| #include "JackError.h" | |||
| namespace Jack | |||
| { | |||
| JackMessageBuffer* JackMessageBuffer::fInstance = NULL; | |||
| JackMessageBuffer::JackMessageBuffer():fInBuffer(0),fOutBuffer(0),fOverruns(0) | |||
| { | |||
| fThread = JackGlobals::MakeThread(this); | |||
| fSignal = JackGlobals::MakeInterProcessSync(); | |||
| fMutex = new JackMutex(); | |||
| fThread->Start(); | |||
| } | |||
| JackMessageBuffer::~JackMessageBuffer() | |||
| { | |||
| if (fOverruns > 0) { | |||
| jack_error("WARNING: %d message buffer overruns!", fOverruns); | |||
| } else { | |||
| jack_info("no message buffer overruns"); | |||
| } | |||
| fThread->SetStatus(JackThread::kIdle); | |||
| fSignal->SignalAll(); | |||
| fThread->Stop(); | |||
| Flush(); | |||
| delete fThread; | |||
| delete fMutex; | |||
| delete fSignal; | |||
| } | |||
| void JackMessageBuffer::Flush() | |||
| { | |||
| while (fOutBuffer != fInBuffer) { | |||
| jack_log_function(fBuffers[fOutBuffer].level, fBuffers[fOutBuffer].message); | |||
| fOutBuffer = MB_NEXT(fOutBuffer); | |||
| } | |||
| } | |||
| void JackMessageBuffer::AddMessage(int level, const char *message) | |||
| { | |||
| if (fMutex->Trylock()) { | |||
| fBuffers[fInBuffer].level = level; | |||
| strncpy(fBuffers[fInBuffer].message, message, MB_BUFFERSIZE); | |||
| fInBuffer = MB_NEXT(fInBuffer); | |||
| fSignal->SignalAll(); | |||
| fMutex->Unlock(); | |||
| } else { /* lock collision */ | |||
| INC_ATOMIC(&fOverruns); | |||
| } | |||
| } | |||
| bool JackMessageBuffer::Execute() | |||
| { | |||
| fSignal->Wait(); | |||
| fMutex->Lock(); | |||
| Flush(); | |||
| fMutex->Unlock(); | |||
| return true; | |||
| } | |||
| void JackMessageBuffer::Create() | |||
| { | |||
| if (fInstance == NULL) { | |||
| fInstance = new JackMessageBuffer(); | |||
| } | |||
| } | |||
| void JackMessageBuffer::Destroy() | |||
| { | |||
| if (fInstance != NULL) { | |||
| delete fInstance; | |||
| fInstance = NULL; | |||
| } | |||
| } | |||
| void JackMessageBufferAdd(int level, const char *message) | |||
| { | |||
| if (Jack::JackMessageBuffer::fInstance == NULL) { | |||
| /* Unable to print message with realtime safety. | |||
| * Complain and print it anyway. */ | |||
| jack_log_function(LOG_LEVEL_ERROR, "messagebuffer not initialized, skip message"); | |||
| } else { | |||
| Jack::JackMessageBuffer::fInstance->AddMessage(level, message); | |||
| } | |||
| } | |||
| }; | |||
| @@ -0,0 +1,192 @@ | |||
| /* | |||
| * messagebuffer.h -- realtime-safe message interface for jackd. | |||
| * | |||
| * This function is included in libjack so backend drivers can use | |||
| * it, *not* for external client processes. The VERBOSE() and | |||
| * MESSAGE() macros are realtime-safe. | |||
| */ | |||
| /* | |||
| * Copyright (C) 2004 Rui Nuno Capela, Steve Harris | |||
| * Copyright (C) 2008 Nedko Arnaudov | |||
| * Copyright (C) 2008 Grame | |||
| * | |||
| * This program is free software; you can redistribute it and/or modify | |||
| * it under the terms of the GNU Lesser General Public License as published by | |||
| * the Free Software Foundation; either version 2.1 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 Lesser General Public License for more details. | |||
| * | |||
| * You should have received a copy of the GNU Lesser General Public License | |||
| * along with this program; if not, write to the Free Software | |||
| * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. | |||
| * | |||
| */ | |||
| #ifndef __JackMessageBuffer__ | |||
| #define __JackMessageBuffer__ | |||
| #include "JackThread.h" | |||
| #include "JackMutex.h" | |||
| #include "JackAtomic.h" | |||
| #include "JackSyncInterface.h" | |||
| namespace Jack | |||
| { | |||
| /* MB_NEXT() relies on the fact that MB_BUFFERS is a power of two */ | |||
| #define MB_BUFFERS 128 | |||
| #define MB_NEXT(index) ((index+1) & (MB_BUFFERS-1)) | |||
| #define MB_BUFFERSIZE 256 /* message length limit */ | |||
| struct JackMessage | |||
| { | |||
| int level; | |||
| char message[MB_BUFFERSIZE]; | |||
| }; | |||
| class JackMessageBuffer : public JackRunnableInterface | |||
| { | |||
| private: | |||
| JackMessage fBuffers[MB_BUFFERS]; | |||
| JackMutex* fMutex; | |||
| JackThread* fThread; | |||
| JackSyncInterface* fSignal; | |||
| volatile unsigned int fInBuffer; | |||
| volatile unsigned int fOutBuffer; | |||
| SInt32 fOverruns; | |||
| void Flush(); | |||
| public: | |||
| JackMessageBuffer(); | |||
| ~JackMessageBuffer(); | |||
| // JackRunnableInterface interface | |||
| bool Execute(); | |||
| void static Create(); | |||
| void static Destroy(); | |||
| void AddMessage(int level, const char *message); | |||
| static JackMessageBuffer* fInstance; | |||
| }; | |||
| #ifdef __cplusplus | |||
| extern "C" | |||
| { | |||
| #endif | |||
| void JackMessageBufferAdd(int level, const char *message); | |||
| #ifdef __cplusplus | |||
| } | |||
| #endif | |||
| }; | |||
| #endif | |||
| /* | |||
| * messagebuffer.h -- realtime-safe message interface for jackd. | |||
| * | |||
| * This function is included in libjack so backend drivers can use | |||
| * it, *not* for external client processes. The VERBOSE() and | |||
| * MESSAGE() macros are realtime-safe. | |||
| */ | |||
| /* | |||
| * Copyright (C) 2004 Rui Nuno Capela, Steve Harris | |||
| * Copyright (C) 2008 Nedko Arnaudov | |||
| * Copyright (C) 2008 Grame | |||
| * | |||
| * This program is free software; you can redistribute it and/or modify | |||
| * it under the terms of the GNU Lesser General Public License as published by | |||
| * the Free Software Foundation; either version 2.1 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 Lesser General Public License for more details. | |||
| * | |||
| * You should have received a copy of the GNU Lesser General Public License | |||
| * along with this program; if not, write to the Free Software | |||
| * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. | |||
| * | |||
| */ | |||
| #ifndef __JackMessageBuffer__ | |||
| #define __JackMessageBuffer__ | |||
| #include "JackThread.h" | |||
| #include "JackMutex.h" | |||
| #include "JackAtomic.h" | |||
| #include "JackSyncInterface.h" | |||
| namespace Jack | |||
| { | |||
| /* MB_NEXT() relies on the fact that MB_BUFFERS is a power of two */ | |||
| #define MB_BUFFERS 128 | |||
| #define MB_NEXT(index) ((index+1) & (MB_BUFFERS-1)) | |||
| #define MB_BUFFERSIZE 256 /* message length limit */ | |||
| struct JackMessage | |||
| { | |||
| int level; | |||
| char message[MB_BUFFERSIZE]; | |||
| }; | |||
| class JackMessageBuffer : public JackRunnableInterface | |||
| { | |||
| private: | |||
| JackMessage fBuffers[MB_BUFFERS]; | |||
| JackMutex* fMutex; | |||
| JackThread* fThread; | |||
| JackSyncInterface* fSignal; | |||
| volatile unsigned int fInBuffer; | |||
| volatile unsigned int fOutBuffer; | |||
| SInt32 fOverruns; | |||
| void Flush(); | |||
| public: | |||
| JackMessageBuffer(); | |||
| ~JackMessageBuffer(); | |||
| // JackRunnableInterface interface | |||
| bool Execute(); | |||
| void static Create(); | |||
| void static Destroy(); | |||
| void AddMessage(int level, const char *message); | |||
| static JackMessageBuffer* fInstance; | |||
| }; | |||
| #ifdef __cplusplus | |||
| extern "C" | |||
| { | |||
| #endif | |||
| void JackMessageBufferAdd(int level, const char *message); | |||
| #ifdef __cplusplus | |||
| } | |||
| #endif | |||
| }; | |||
| #endif | |||
| @@ -0,0 +1,75 @@ | |||
| /* | |||
| Copyright (C) 2004-2006 Grame | |||
| This program is free software; you can redistribute it and/or modify | |||
| it under the terms of the GNU General Public License as published by | |||
| the Free Software Foundation; either version 2 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 General Public License for more details. | |||
| You should have received a copy of the GNU General Public License | |||
| along with this program; if not, write to the Free Software | |||
| Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. | |||
| */ | |||
| #include "JackProcessSync.h" | |||
| #include "JackError.h" | |||
| namespace Jack | |||
| { | |||
| bool JackProcessSync::TimedWait(long usec) | |||
| { | |||
| struct timeval T0, T1; | |||
| timespec time; | |||
| struct timeval now; | |||
| int res; | |||
| pthread_mutex_lock(&fLock); | |||
| jack_log("JackProcessSync::TimedWait time out = %ld", usec); | |||
| gettimeofday(&T0, 0); | |||
| gettimeofday(&now, 0); | |||
| unsigned int next_date_usec = now.tv_usec + usec; | |||
| time.tv_sec = now.tv_sec + (next_date_usec / 1000000); | |||
| time.tv_nsec = (next_date_usec % 1000000) * 1000; | |||
| res = pthread_cond_timedwait(&fCond, &fLock, &time); | |||
| if (res != 0) | |||
| jack_error("pthread_cond_timedwait error usec = %ld err = %s", usec, strerror(res)); | |||
| gettimeofday(&T1, 0); | |||
| pthread_mutex_unlock(&fLock); | |||
| jack_log("JackProcessSync::TimedWait finished delta = %5.1lf", | |||
| (1e6 * T1.tv_sec - 1e6 * T0.tv_sec + T1.tv_usec - T0.tv_usec)); | |||
| return (res == 0); | |||
| } | |||
| void JackProcessSync::Wait() | |||
| { | |||
| int res; | |||
| pthread_mutex_lock(&fLock); | |||
| //jack_log("JackProcessSync::Wait..."); | |||
| if ((res = pthread_cond_wait(&fCond, &fLock)) != 0) | |||
| jack_error("pthread_cond_wait error err = %s", strerror(errno)); | |||
| pthread_mutex_unlock(&fLock); | |||
| //jack_log("JackProcessSync::Wait finished"); | |||
| } | |||
| bool JackInterProcessSync::TimedWait(long usec) | |||
| { | |||
| struct timeval T0, T1; | |||
| //jack_log("JackInterProcessSync::TimedWait..."); | |||
| gettimeofday(&T0, 0); | |||
| bool res = fSynchro->TimedWait(usec); | |||
| gettimeofday(&T1, 0); | |||
| //jack_log("JackInterProcessSync::TimedWait finished delta = %5.1lf", (1e6 * T1.tv_sec - 1e6 * T0.tv_sec + T1.tv_usec - T0.tv_usec)); | |||
| return res; | |||
| } | |||
| } // end of namespace | |||
| @@ -0,0 +1,648 @@ | |||
| /* | |||
| JACK control API | |||
| Copyright (C) 2008 Nedko Arnaudov | |||
| This program is free software; you can redistribute it and/or modify | |||
| it under the terms of the GNU General Public License as published by | |||
| the Free Software Foundation; version 2 of the License. | |||
| 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 General Public License for more details. | |||
| You should have received a copy of the GNU General Public License | |||
| along with this program; if not, write to the Free Software | |||
| Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. | |||
| */ | |||
| #ifndef __control_types__ | |||
| #define __control_types__ | |||
| #include "jslist.h" | |||
| #include "JackExports.h" | |||
| #ifdef WIN32 | |||
| typedef HANDLE sigset_t; | |||
| #endif | |||
| /** Parameter types, intentionally similar to jack_driver_param_type_t */ | |||
| typedef enum | |||
| { | |||
| JackParamInt = 1, /**< @brief value type is a signed integer */ | |||
| JackParamUInt, /**< @brief value type is an unsigned integer */ | |||
| JackParamChar, /**< @brief value type is a char */ | |||
| JackParamString, /**< @brief value type is a string with max size of ::JACK_PARAM_STRING_MAX+1 chars */ | |||
| JackParamBool, /**< @brief value type is a boolean */ | |||
| } jackctl_param_type_t; | |||
| /** @brief Max value that jackctl_param_type_t type can have */ | |||
| #define JACK_PARAM_MAX (JackParamBool + 1) | |||
| /** @brief Max length of string parameter value, excluding terminating nul char */ | |||
| #define JACK_PARAM_STRING_MAX 63 | |||
| /** @brief Type for parameter value */ | |||
| /* intentionally similar to jack_driver_param_value_t */ | |||
| union jackctl_parameter_value | |||
| { | |||
| uint32_t ui; /**< @brief member used for ::JackParamUInt */ | |||
| int32_t i; /**< @brief member used for ::JackParamInt */ | |||
| char c; /**< @brief member used for ::JackParamChar */ | |||
| char str[JACK_PARAM_STRING_MAX + 1]; /**< @brief member used for ::JackParamString */ | |||
| bool b; /**< @brief member used for ::JackParamBool */ | |||
| }; | |||
| /** opaque type for server object */ | |||
| typedef struct jackctl_server jackctl_server_t; | |||
| /** opaque type for driver object */ | |||
| typedef struct jackctl_driver jackctl_driver_t; | |||
| /** opaque type for parameter object */ | |||
| typedef struct jackctl_parameter jackctl_parameter_t; | |||
| #ifdef __cplusplus | |||
| extern "C" { | |||
| #endif | |||
| #if 0 | |||
| } /* Adjust editor indent */ | |||
| #endif | |||
| EXPORT sigset_t | |||
| jackctl_setup_signals( | |||
| unsigned int flags); | |||
| EXPORT void | |||
| jackctl_wait_signals( | |||
| sigset_t signals); | |||
| EXPORT jackctl_server_t * | |||
| jackctl_server_create(); | |||
| EXPORT void | |||
| jackctl_server_destroy( | |||
| jackctl_server_t * server); | |||
| EXPORT const JSList * | |||
| jackctl_server_get_drivers_list( | |||
| jackctl_server_t * server); | |||
| EXPORT bool | |||
| jackctl_server_start( | |||
| jackctl_server_t * server, | |||
| jackctl_driver_t * driver); | |||
| EXPORT bool | |||
| jackctl_server_stop( | |||
| jackctl_server_t * server); | |||
| EXPORT const JSList * | |||
| jackctl_server_get_parameters( | |||
| jackctl_server_t * server); | |||
| EXPORT const char * | |||
| jackctl_driver_get_name( | |||
| jackctl_driver_t * driver); | |||
| EXPORT const JSList * | |||
| jackctl_driver_get_parameters( | |||
| jackctl_driver_t * driver); | |||
| EXPORT const char * | |||
| jackctl_parameter_get_name( | |||
| jackctl_parameter_t * parameter); | |||
| EXPORT const char * | |||
| jackctl_parameter_get_short_description( | |||
| jackctl_parameter_t * parameter); | |||
| EXPORT const char * | |||
| jackctl_parameter_get_long_description( | |||
| jackctl_parameter_t * parameter); | |||
| EXPORT jackctl_param_type_t | |||
| jackctl_parameter_get_type( | |||
| jackctl_parameter_t * parameter); | |||
| EXPORT char | |||
| jackctl_parameter_get_id( | |||
| jackctl_parameter_t * parameter); | |||
| EXPORT bool | |||
| jackctl_parameter_is_set( | |||
| jackctl_parameter_t * parameter); | |||
| EXPORT bool | |||
| jackctl_parameter_reset( | |||
| jackctl_parameter_t * parameter); | |||
| EXPORT union jackctl_parameter_value | |||
| jackctl_parameter_get_value( | |||
| jackctl_parameter_t * parameter); | |||
| EXPORT bool | |||
| jackctl_parameter_set_value( | |||
| jackctl_parameter_t * parameter, | |||
| const union jackctl_parameter_value * value_ptr); | |||
| EXPORT union jackctl_parameter_value | |||
| jackctl_parameter_get_default_value( | |||
| jackctl_parameter_t * parameter); | |||
| #if 0 | |||
| { /* Adjust editor indent */ | |||
| #endif | |||
| #ifdef __cplusplus | |||
| } /* extern "C" */ | |||
| #endif | |||
| #endif | |||
| /* | |||
| JACK control API | |||
| Copyright (C) 2008 Nedko Arnaudov | |||
| This program is free software; you can redistribute it and/or modify | |||
| it under the terms of the GNU General Public License as published by | |||
| the Free Software Foundation; version 2 of the License. | |||
| 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 General Public License for more details. | |||
| You should have received a copy of the GNU General Public License | |||
| along with this program; if not, write to the Free Software | |||
| Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. | |||
| */ | |||
| #ifndef __control_types__ | |||
| #define __control_types__ | |||
| #include "jslist.h" | |||
| #include "JackExports.h" | |||
| #ifdef WIN32 | |||
| typedef HANDLE sigset_t; | |||
| #endif | |||
| /** Parameter types, intentionally similar to jack_driver_param_type_t */ | |||
| typedef enum | |||
| { | |||
| JackParamInt = 1, /**< @brief value type is a signed integer */ | |||
| JackParamUInt, /**< @brief value type is an unsigned integer */ | |||
| JackParamChar, /**< @brief value type is a char */ | |||
| JackParamString, /**< @brief value type is a string with max size of ::JACK_PARAM_STRING_MAX+1 chars */ | |||
| JackParamBool, /**< @brief value type is a boolean */ | |||
| } jackctl_param_type_t; | |||
| /** @brief Max value that jackctl_param_type_t type can have */ | |||
| #define JACK_PARAM_MAX (JackParamBool + 1) | |||
| /** @brief Max length of string parameter value, excluding terminating nul char */ | |||
| #define JACK_PARAM_STRING_MAX 63 | |||
| /** @brief Type for parameter value */ | |||
| /* intentionally similar to jack_driver_param_value_t */ | |||
| union jackctl_parameter_value | |||
| { | |||
| uint32_t ui; /**< @brief member used for ::JackParamUInt */ | |||
| int32_t i; /**< @brief member used for ::JackParamInt */ | |||
| char c; /**< @brief member used for ::JackParamChar */ | |||
| char str[JACK_PARAM_STRING_MAX + 1]; /**< @brief member used for ::JackParamString */ | |||
| bool b; /**< @brief member used for ::JackParamBool */ | |||
| }; | |||
| /** opaque type for server object */ | |||
| typedef struct jackctl_server jackctl_server_t; | |||
| /** opaque type for driver object */ | |||
| typedef struct jackctl_driver jackctl_driver_t; | |||
| /** opaque type for parameter object */ | |||
| typedef struct jackctl_parameter jackctl_parameter_t; | |||
| #ifdef __cplusplus | |||
| extern "C" { | |||
| #endif | |||
| #if 0 | |||
| } /* Adjust editor indent */ | |||
| #endif | |||
| EXPORT sigset_t | |||
| jackctl_setup_signals( | |||
| unsigned int flags); | |||
| EXPORT void | |||
| jackctl_wait_signals( | |||
| sigset_t signals); | |||
| EXPORT jackctl_server_t * | |||
| jackctl_server_create(); | |||
| EXPORT void | |||
| jackctl_server_destroy( | |||
| jackctl_server_t * server); | |||
| EXPORT const JSList * | |||
| jackctl_server_get_drivers_list( | |||
| jackctl_server_t * server); | |||
| EXPORT bool | |||
| jackctl_server_start( | |||
| jackctl_server_t * server, | |||
| jackctl_driver_t * driver); | |||
| EXPORT bool | |||
| jackctl_server_stop( | |||
| jackctl_server_t * server); | |||
| EXPORT const JSList * | |||
| jackctl_server_get_parameters( | |||
| jackctl_server_t * server); | |||
| EXPORT const char * | |||
| jackctl_driver_get_name( | |||
| jackctl_driver_t * driver); | |||
| EXPORT const JSList * | |||
| jackctl_driver_get_parameters( | |||
| jackctl_driver_t * driver); | |||
| EXPORT const char * | |||
| jackctl_parameter_get_name( | |||
| jackctl_parameter_t * parameter); | |||
| EXPORT const char * | |||
| jackctl_parameter_get_short_description( | |||
| jackctl_parameter_t * parameter); | |||
| EXPORT const char * | |||
| jackctl_parameter_get_long_description( | |||
| jackctl_parameter_t * parameter); | |||
| EXPORT jackctl_param_type_t | |||
| jackctl_parameter_get_type( | |||
| jackctl_parameter_t * parameter); | |||
| EXPORT char | |||
| jackctl_parameter_get_id( | |||
| jackctl_parameter_t * parameter); | |||
| EXPORT bool | |||
| jackctl_parameter_is_set( | |||
| jackctl_parameter_t * parameter); | |||
| EXPORT bool | |||
| jackctl_parameter_reset( | |||
| jackctl_parameter_t * parameter); | |||
| EXPORT union jackctl_parameter_value | |||
| jackctl_parameter_get_value( | |||
| jackctl_parameter_t * parameter); | |||
| EXPORT bool | |||
| jackctl_parameter_set_value( | |||
| jackctl_parameter_t * parameter, | |||
| const union jackctl_parameter_value * value_ptr); | |||
| EXPORT union jackctl_parameter_value | |||
| jackctl_parameter_get_default_value( | |||
| jackctl_parameter_t * parameter); | |||
| #if 0 | |||
| { /* Adjust editor indent */ | |||
| #endif | |||
| #ifdef __cplusplus | |||
| } /* extern "C" */ | |||
| #endif | |||
| #endif | |||
| /* | |||
| JACK control API | |||
| Copyright (C) 2008 Nedko Arnaudov | |||
| This program is free software; you can redistribute it and/or modify | |||
| it under the terms of the GNU General Public License as published by | |||
| the Free Software Foundation; version 2 of the License. | |||
| 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 General Public License for more details. | |||
| You should have received a copy of the GNU General Public License | |||
| along with this program; if not, write to the Free Software | |||
| Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. | |||
| */ | |||
| #ifndef __control_types__ | |||
| #define __control_types__ | |||
| #include "jslist.h" | |||
| #include "JackExports.h" | |||
| #ifdef WIN32 | |||
| typedef HANDLE sigset_t; | |||
| #endif | |||
| /** Parameter types, intentionally similar to jack_driver_param_type_t */ | |||
| typedef enum | |||
| { | |||
| JackParamInt = 1, /**< @brief value type is a signed integer */ | |||
| JackParamUInt, /**< @brief value type is an unsigned integer */ | |||
| JackParamChar, /**< @brief value type is a char */ | |||
| JackParamString, /**< @brief value type is a string with max size of ::JACK_PARAM_STRING_MAX+1 chars */ | |||
| JackParamBool, /**< @brief value type is a boolean */ | |||
| } jackctl_param_type_t; | |||
| /** @brief Max value that jackctl_param_type_t type can have */ | |||
| #define JACK_PARAM_MAX (JackParamBool + 1) | |||
| /** @brief Max length of string parameter value, excluding terminating nul char */ | |||
| #define JACK_PARAM_STRING_MAX 63 | |||
| /** @brief Type for parameter value */ | |||
| /* intentionally similar to jack_driver_param_value_t */ | |||
| union jackctl_parameter_value | |||
| { | |||
| uint32_t ui; /**< @brief member used for ::JackParamUInt */ | |||
| int32_t i; /**< @brief member used for ::JackParamInt */ | |||
| char c; /**< @brief member used for ::JackParamChar */ | |||
| char str[JACK_PARAM_STRING_MAX + 1]; /**< @brief member used for ::JackParamString */ | |||
| bool b; /**< @brief member used for ::JackParamBool */ | |||
| }; | |||
| /** opaque type for server object */ | |||
| typedef struct jackctl_server jackctl_server_t; | |||
| /** opaque type for driver object */ | |||
| typedef struct jackctl_driver jackctl_driver_t; | |||
| /** opaque type for parameter object */ | |||
| typedef struct jackctl_parameter jackctl_parameter_t; | |||
| #ifdef __cplusplus | |||
| extern "C" { | |||
| #endif | |||
| #if 0 | |||
| } /* Adjust editor indent */ | |||
| #endif | |||
| EXPORT sigset_t | |||
| jackctl_setup_signals( | |||
| unsigned int flags); | |||
| EXPORT void | |||
| jackctl_wait_signals( | |||
| sigset_t signals); | |||
| EXPORT jackctl_server_t * | |||
| jackctl_server_create(); | |||
| EXPORT void | |||
| jackctl_server_destroy( | |||
| jackctl_server_t * server); | |||
| EXPORT const JSList * | |||
| jackctl_server_get_drivers_list( | |||
| jackctl_server_t * server); | |||
| EXPORT bool | |||
| jackctl_server_start( | |||
| jackctl_server_t * server, | |||
| jackctl_driver_t * driver); | |||
| EXPORT bool | |||
| jackctl_server_stop( | |||
| jackctl_server_t * server); | |||
| EXPORT const JSList * | |||
| jackctl_server_get_parameters( | |||
| jackctl_server_t * server); | |||
| EXPORT const char * | |||
| jackctl_driver_get_name( | |||
| jackctl_driver_t * driver); | |||
| EXPORT const JSList * | |||
| jackctl_driver_get_parameters( | |||
| jackctl_driver_t * driver); | |||
| EXPORT const char * | |||
| jackctl_parameter_get_name( | |||
| jackctl_parameter_t * parameter); | |||
| EXPORT const char * | |||
| jackctl_parameter_get_short_description( | |||
| jackctl_parameter_t * parameter); | |||
| EXPORT const char * | |||
| jackctl_parameter_get_long_description( | |||
| jackctl_parameter_t * parameter); | |||
| EXPORT jackctl_param_type_t | |||
| jackctl_parameter_get_type( | |||
| jackctl_parameter_t * parameter); | |||
| EXPORT char | |||
| jackctl_parameter_get_id( | |||
| jackctl_parameter_t * parameter); | |||
| EXPORT bool | |||
| jackctl_parameter_is_set( | |||
| jackctl_parameter_t * parameter); | |||
| EXPORT bool | |||
| jackctl_parameter_reset( | |||
| jackctl_parameter_t * parameter); | |||
| EXPORT union jackctl_parameter_value | |||
| jackctl_parameter_get_value( | |||
| jackctl_parameter_t * parameter); | |||
| EXPORT bool | |||
| jackctl_parameter_set_value( | |||
| jackctl_parameter_t * parameter, | |||
| const union jackctl_parameter_value * value_ptr); | |||
| EXPORT union jackctl_parameter_value | |||
| jackctl_parameter_get_default_value( | |||
| jackctl_parameter_t * parameter); | |||
| #if 0 | |||
| { /* Adjust editor indent */ | |||
| #endif | |||
| #ifdef __cplusplus | |||
| } /* extern "C" */ | |||
| #endif | |||
| #endif | |||
| /* | |||
| JACK control API | |||
| Copyright (C) 2008 Nedko Arnaudov | |||
| This program is free software; you can redistribute it and/or modify | |||
| it under the terms of the GNU General Public License as published by | |||
| the Free Software Foundation; version 2 of the License. | |||
| 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 General Public License for more details. | |||
| You should have received a copy of the GNU General Public License | |||
| along with this program; if not, write to the Free Software | |||
| Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. | |||
| */ | |||
| #ifndef __control_types__ | |||
| #define __control_types__ | |||
| #include "jslist.h" | |||
| #include "JackExports.h" | |||
| #ifdef WIN32 | |||
| typedef HANDLE sigset_t; | |||
| #endif | |||
| /** Parameter types, intentionally similar to jack_driver_param_type_t */ | |||
| typedef enum | |||
| { | |||
| JackParamInt = 1, /**< @brief value type is a signed integer */ | |||
| JackParamUInt, /**< @brief value type is an unsigned integer */ | |||
| JackParamChar, /**< @brief value type is a char */ | |||
| JackParamString, /**< @brief value type is a string with max size of ::JACK_PARAM_STRING_MAX+1 chars */ | |||
| JackParamBool, /**< @brief value type is a boolean */ | |||
| } jackctl_param_type_t; | |||
| /** @brief Max value that jackctl_param_type_t type can have */ | |||
| #define JACK_PARAM_MAX (JackParamBool + 1) | |||
| /** @brief Max length of string parameter value, excluding terminating nul char */ | |||
| #define JACK_PARAM_STRING_MAX 63 | |||
| /** @brief Type for parameter value */ | |||
| /* intentionally similar to jack_driver_param_value_t */ | |||
| union jackctl_parameter_value | |||
| { | |||
| uint32_t ui; /**< @brief member used for ::JackParamUInt */ | |||
| int32_t i; /**< @brief member used for ::JackParamInt */ | |||
| char c; /**< @brief member used for ::JackParamChar */ | |||
| char str[JACK_PARAM_STRING_MAX + 1]; /**< @brief member used for ::JackParamString */ | |||
| bool b; /**< @brief member used for ::JackParamBool */ | |||
| }; | |||
| /** opaque type for server object */ | |||
| typedef struct jackctl_server jackctl_server_t; | |||
| /** opaque type for driver object */ | |||
| typedef struct jackctl_driver jackctl_driver_t; | |||
| /** opaque type for parameter object */ | |||
| typedef struct jackctl_parameter jackctl_parameter_t; | |||
| #ifdef __cplusplus | |||
| extern "C" { | |||
| #endif | |||
| #if 0 | |||
| } /* Adjust editor indent */ | |||
| #endif | |||
| EXPORT sigset_t | |||
| jackctl_setup_signals( | |||
| unsigned int flags); | |||
| EXPORT void | |||
| jackctl_wait_signals( | |||
| sigset_t signals); | |||
| EXPORT jackctl_server_t * | |||
| jackctl_server_create(); | |||
| EXPORT void | |||
| jackctl_server_destroy( | |||
| jackctl_server_t * server); | |||
| EXPORT const JSList * | |||
| jackctl_server_get_drivers_list( | |||
| jackctl_server_t * server); | |||
| EXPORT bool | |||
| jackctl_server_start( | |||
| jackctl_server_t * server, | |||
| jackctl_driver_t * driver); | |||
| EXPORT bool | |||
| jackctl_server_stop( | |||
| jackctl_server_t * server); | |||
| EXPORT const JSList * | |||
| jackctl_server_get_parameters( | |||
| jackctl_server_t * server); | |||
| EXPORT const char * | |||
| jackctl_driver_get_name( | |||
| jackctl_driver_t * driver); | |||
| EXPORT const JSList * | |||
| jackctl_driver_get_parameters( | |||
| jackctl_driver_t * driver); | |||
| EXPORT const char * | |||
| jackctl_parameter_get_name( | |||
| jackctl_parameter_t * parameter); | |||
| EXPORT const char * | |||
| jackctl_parameter_get_short_description( | |||
| jackctl_parameter_t * parameter); | |||
| EXPORT const char * | |||
| jackctl_parameter_get_long_description( | |||
| jackctl_parameter_t * parameter); | |||
| EXPORT jackctl_param_type_t | |||
| jackctl_parameter_get_type( | |||
| jackctl_parameter_t * parameter); | |||
| EXPORT char | |||
| jackctl_parameter_get_id( | |||
| jackctl_parameter_t * parameter); | |||
| EXPORT bool | |||
| jackctl_parameter_is_set( | |||
| jackctl_parameter_t * parameter); | |||
| EXPORT bool | |||
| jackctl_parameter_reset( | |||
| jackctl_parameter_t * parameter); | |||
| EXPORT union jackctl_parameter_value | |||
| jackctl_parameter_get_value( | |||
| jackctl_parameter_t * parameter); | |||
| EXPORT bool | |||
| jackctl_parameter_set_value( | |||
| jackctl_parameter_t * parameter, | |||
| const union jackctl_parameter_value * value_ptr); | |||
| EXPORT union jackctl_parameter_value | |||
| jackctl_parameter_get_default_value( | |||
| jackctl_parameter_t * parameter); | |||
| #if 0 | |||
| { /* Adjust editor indent */ | |||
| #endif | |||
| #ifdef __cplusplus | |||
| } /* extern "C" */ | |||
| #endif | |||
| #endif | |||
| @@ -0,0 +1,702 @@ | |||
| /* -*- Mode: C ; c-basic-offset: 4 -*- */ | |||
| /* | |||
| JACK control API | |||
| Copyright (C) 2008 Nedko Arnaudov | |||
| This program is free software; you can redistribute it and/or modify | |||
| it under the terms of the GNU General Public License as published by | |||
| the Free Software Foundation; version 2 of the License. | |||
| 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 General Public License for more details. | |||
| You should have received a copy of the GNU General Public License | |||
| along with this program; if not, write to the Free Software | |||
| Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. | |||
| */ | |||
| /** | |||
| * @file jack/control.h | |||
| * @ingroup publicheader | |||
| * @brief JACK control API | |||
| * | |||
| */ | |||
| #ifndef JACKCTL_H__2EEDAD78_DF4C_4B26_83B7_4FF1A446A47E__INCLUDED | |||
| #define JACKCTL_H__2EEDAD78_DF4C_4B26_83B7_4FF1A446A47E__INCLUDED | |||
| #include <jack/jslist.h> | |||
| #ifdef WIN32 | |||
| typedef unsigned long sigset_t; | |||
| #endif | |||
| /** Parameter types, intentionally similar to jack_driver_param_type_t */ | |||
| typedef enum | |||
| { | |||
| JackParamInt = 1, /**< @brief value type is a signed integer */ | |||
| JackParamUInt, /**< @brief value type is an unsigned integer */ | |||
| JackParamChar, /**< @brief value type is a char */ | |||
| JackParamString, /**< @brief value type is a string with max size of ::JACK_PARAM_STRING_MAX+1 chars */ | |||
| JackParamBool, /**< @brief value type is a boolean */ | |||
| } jackctl_param_type_t; | |||
| /** @brief Max value that jackctl_param_type_t type can have */ | |||
| #define JACK_PARAM_MAX (JackParamBool + 1) | |||
| /** @brief Max length of string parameter value, excluding terminating nul char */ | |||
| #define JACK_PARAM_STRING_MAX 63 | |||
| /** @brief Type for parameter value */ | |||
| /* intentionally similar to jack_driver_param_value_t */ | |||
| union jackctl_parameter_value | |||
| { | |||
| uint32_t ui; /**< @brief member used for ::JackParamUInt */ | |||
| int32_t i; /**< @brief member used for ::JackParamInt */ | |||
| char c; /**< @brief member used for ::JackParamChar */ | |||
| char str[JACK_PARAM_STRING_MAX + 1]; /**< @brief member used for ::JackParamString */ | |||
| bool b; /**< @brief member used for ::JackParamBool */ | |||
| }; | |||
| /** opaque type for server object */ | |||
| typedef struct jackctl_server jackctl_server_t; | |||
| /** opaque type for driver object */ | |||
| typedef struct jackctl_driver jackctl_driver_t; | |||
| /** opaque type for parameter object */ | |||
| typedef struct jackctl_parameter jackctl_parameter_t; | |||
| #ifdef __cplusplus | |||
| extern "C" { | |||
| #endif | |||
| #if 0 | |||
| } /* Adjust editor indent */ | |||
| #endif | |||
| /** | |||
| * Call this function to setup process signal handling. As a general | |||
| * rule, it is required for proper operation for the server object. | |||
| * | |||
| * @param flags signals setup flags, use 0 for none. Currently no | |||
| * flags are defined | |||
| * | |||
| * @return the configurated signal set. | |||
| */ | |||
| sigset_t | |||
| jackctl_setup_signals( | |||
| unsigned int flags); | |||
| /** | |||
| * Call this function to wait on a signal set. | |||
| * | |||
| * @param signals signals set to wait on | |||
| */ | |||
| void | |||
| jackctl_wait_signals( | |||
| sigset_t signals); | |||
| /** | |||
| * Call this function to create server object. | |||
| * | |||
| * @return server object handle, NULL if creation of server object | |||
| * failed. Successfully created server object must be destroyed with | |||
| * paired call to ::jackctl_server_destroy | |||
| */ | |||
| jackctl_server_t * | |||
| jackctl_server_create(); | |||
| /** | |||
| * Call this function to destroy server object. | |||
| * | |||
| * @param server server object handle to destroy | |||
| */ | |||
| void | |||
| jackctl_server_destroy( | |||
| jackctl_server_t * server); | |||
| /** | |||
| * Call this function to get list of available drivers. List node data | |||
| * pointers is a driver object handle (::jackctl_driver_t). | |||
| * | |||
| * @param server server object handle to get drivers for | |||
| * | |||
| * @return Single linked list of driver object handles. Must not be | |||
| * modified. Always same for same server object. | |||
| */ | |||
| const JSList * | |||
| jackctl_server_get_drivers_list( | |||
| jackctl_server_t * server); | |||
| /** | |||
| * Call this function to start JACK server | |||
| * | |||
| * @param server server object handle | |||
| * @param driver driver to use | |||
| * | |||
| * @return success status: true - success, false - fail | |||
| */ | |||
| bool | |||
| jackctl_server_start( | |||
| jackctl_server_t * server, | |||
| jackctl_driver_t * driver); | |||
| /** | |||
| * Call this function to stop JACK server | |||
| * | |||
| * @param server server object handle | |||
| * | |||
| * @return success status: true - success, false - fail | |||
| */ | |||
| bool | |||
| jackctl_server_stop( | |||
| jackctl_server_t * server); | |||
| /** | |||
| * Call this function to get list of server parameters. List node data | |||
| * pointers is a parameter object handle (::jackctl_parameter_t). | |||
| * | |||
| * @param server server object handle to get parameters for | |||
| * | |||
| * @return Single linked list of parameter object handles. Must not be | |||
| * modified. Always same for same server object. | |||
| */ | |||
| const JSList * | |||
| jackctl_server_get_parameters( | |||
| jackctl_server_t * server); | |||
| /** | |||
| * Call this function to get name of driver. | |||
| * | |||
| * @param driver driver object handle to get name of | |||
| * | |||
| * @return driver name. Must not be modified. Always same for same | |||
| * driver object. | |||
| */ | |||
| const char * | |||
| jackctl_driver_get_name( | |||
| jackctl_driver_t * driver); | |||
| /** | |||
| * Call this function to get list of driver parameters. List node data | |||
| * pointers is a parameter object handle (::jackctl_parameter_t). | |||
| * | |||
| * @param driver driver object handle to get parameters for | |||
| * | |||
| * @return Single linked list of parameter object handles. Must not be | |||
| * modified. Always same for same driver object. | |||
| */ | |||
| const JSList * | |||
| jackctl_driver_get_parameters( | |||
| jackctl_driver_t * driver); | |||
| /** | |||
| * Call this function to get parameter name. | |||
| * | |||
| * @param parameter parameter object handle to get name of | |||
| * | |||
| * @return parameter name. Must not be modified. Always same for same | |||
| * parameter object. | |||
| */ | |||
| const char * | |||
| jackctl_parameter_get_name( | |||
| jackctl_parameter_t * parameter); | |||
| /** | |||
| * Call this function to get parameter short description. | |||
| * | |||
| * @param parameter parameter object handle to get short description of | |||
| * | |||
| * @return parameter short description. Must not be modified. Always | |||
| * same for same parameter object. | |||
| */ | |||
| const char * | |||
| jackctl_parameter_get_short_description( | |||
| jackctl_parameter_t * parameter); | |||
| /** | |||
| * Call this function to get parameter long description. | |||
| * | |||
| * @param parameter parameter object handle to get long description of | |||
| * | |||
| * @return parameter long description. Must not be modified. Always | |||
| * same for same parameter object. | |||
| */ | |||
| const char * | |||
| jackctl_parameter_get_long_description( | |||
| jackctl_parameter_t * parameter); | |||
| /** | |||
| * Call this function to get parameter type. | |||
| * | |||
| * @param parameter parameter object handle to get type of | |||
| * | |||
| * @return parameter type. Always same for same parameter object. | |||
| */ | |||
| jackctl_param_type_t | |||
| jackctl_parameter_get_type( | |||
| jackctl_parameter_t * parameter); | |||
| /** | |||
| * Call this function to get parameter character. | |||
| * | |||
| * @param parameter parameter object handle to get character of | |||
| * | |||
| * @return character. | |||
| */ | |||
| char | |||
| jackctl_parameter_get_id( | |||
| jackctl_parameter_t * parameter); | |||
| /** | |||
| * Call this function to check whether parameter has been set, or its | |||
| * default value is being used. | |||
| * | |||
| * @param parameter parameter object handle to check | |||
| * | |||
| * @return true - parameter is set, false - parameter is using default | |||
| * value. | |||
| */ | |||
| bool | |||
| jackctl_parameter_is_set( | |||
| jackctl_parameter_t * parameter); | |||
| /** | |||
| * Call this function to reset parameter to its default value. | |||
| * | |||
| * @param parameter parameter object handle to reset value of | |||
| * | |||
| * @return success status: true - success, false - fail | |||
| */ | |||
| bool | |||
| jackctl_parameter_reset( | |||
| jackctl_parameter_t * parameter); | |||
| /** | |||
| * Call this function to get parameter value. | |||
| * | |||
| * @param parameter parameter object handle to get value of | |||
| * | |||
| * @return parameter value. | |||
| */ | |||
| union jackctl_parameter_value | |||
| jackctl_parameter_get_value( | |||
| jackctl_parameter_t * parameter); | |||
| /** | |||
| * Call this function to set parameter value. | |||
| * | |||
| * @param parameter parameter object handle to get value of | |||
| * @param value_ptr pointer to variable containing parameter value | |||
| * | |||
| * @return success status: true - success, false - fail | |||
| */ | |||
| bool | |||
| jackctl_parameter_set_value( | |||
| jackctl_parameter_t * parameter, | |||
| const union jackctl_parameter_value * value_ptr); | |||
| /** | |||
| * Call this function to get parameter default value. | |||
| * | |||
| * @param parameter parameter object handle to get default value of | |||
| * | |||
| * @return parameter default value. | |||
| */ | |||
| union jackctl_parameter_value | |||
| jackctl_parameter_get_default_value( | |||
| jackctl_parameter_t * parameter); | |||
| /** | |||
| * Call this function to log an error message. | |||
| * | |||
| * @param format string | |||
| */ | |||
| void | |||
| jack_error( | |||
| const char *format, | |||
| ...); | |||
| /** | |||
| * Call this function to log an information message. | |||
| * | |||
| * @param format string | |||
| */ | |||
| void | |||
| jack_info( | |||
| const char *format, | |||
| ...); | |||
| /** | |||
| * Call this function to log an information message but only when | |||
| * verbose mode is enabled. | |||
| * | |||
| * @param format string | |||
| */ | |||
| void | |||
| jack_log( | |||
| const char *format, | |||
| ...); | |||
| #if 0 | |||
| { /* Adjust editor indent */ | |||
| #endif | |||
| #ifdef __cplusplus | |||
| } /* extern "C" */ | |||
| #endif | |||
| #endif /* #ifndef JACKCTL_H__2EEDAD78_DF4C_4B26_83B7_4FF1A446A47E__INCLUDED */ | |||
| /* -*- Mode: C ; c-basic-offset: 4 -*- */ | |||
| /* | |||
| JACK control API | |||
| Copyright (C) 2008 Nedko Arnaudov | |||
| This program is free software; you can redistribute it and/or modify | |||
| it under the terms of the GNU General Public License as published by | |||
| the Free Software Foundation; version 2 of the License. | |||
| 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 General Public License for more details. | |||
| You should have received a copy of the GNU General Public License | |||
| along with this program; if not, write to the Free Software | |||
| Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. | |||
| */ | |||
| /** | |||
| * @file jack/control.h | |||
| * @ingroup publicheader | |||
| * @brief JACK control API | |||
| * | |||
| */ | |||
| #ifndef JACKCTL_H__2EEDAD78_DF4C_4B26_83B7_4FF1A446A47E__INCLUDED | |||
| #define JACKCTL_H__2EEDAD78_DF4C_4B26_83B7_4FF1A446A47E__INCLUDED | |||
| #include <jack/jslist.h> | |||
| #ifdef WIN32 | |||
| typedef unsigned long sigset_t; | |||
| #endif | |||
| /** Parameter types, intentionally similar to jack_driver_param_type_t */ | |||
| typedef enum | |||
| { | |||
| JackParamInt = 1, /**< @brief value type is a signed integer */ | |||
| JackParamUInt, /**< @brief value type is an unsigned integer */ | |||
| JackParamChar, /**< @brief value type is a char */ | |||
| JackParamString, /**< @brief value type is a string with max size of ::JACK_PARAM_STRING_MAX+1 chars */ | |||
| JackParamBool, /**< @brief value type is a boolean */ | |||
| } jackctl_param_type_t; | |||
| /** @brief Max value that jackctl_param_type_t type can have */ | |||
| #define JACK_PARAM_MAX (JackParamBool + 1) | |||
| /** @brief Max length of string parameter value, excluding terminating nul char */ | |||
| #define JACK_PARAM_STRING_MAX 63 | |||
| /** @brief Type for parameter value */ | |||
| /* intentionally similar to jack_driver_param_value_t */ | |||
| union jackctl_parameter_value | |||
| { | |||
| uint32_t ui; /**< @brief member used for ::JackParamUInt */ | |||
| int32_t i; /**< @brief member used for ::JackParamInt */ | |||
| char c; /**< @brief member used for ::JackParamChar */ | |||
| char str[JACK_PARAM_STRING_MAX + 1]; /**< @brief member used for ::JackParamString */ | |||
| bool b; /**< @brief member used for ::JackParamBool */ | |||
| }; | |||
| /** opaque type for server object */ | |||
| typedef struct jackctl_server jackctl_server_t; | |||
| /** opaque type for driver object */ | |||
| typedef struct jackctl_driver jackctl_driver_t; | |||
| /** opaque type for parameter object */ | |||
| typedef struct jackctl_parameter jackctl_parameter_t; | |||
| #ifdef __cplusplus | |||
| extern "C" { | |||
| #endif | |||
| #if 0 | |||
| } /* Adjust editor indent */ | |||
| #endif | |||
| /** | |||
| * Call this function to setup process signal handling. As a general | |||
| * rule, it is required for proper operation for the server object. | |||
| * | |||
| * @param flags signals setup flags, use 0 for none. Currently no | |||
| * flags are defined | |||
| * | |||
| * @return the configurated signal set. | |||
| */ | |||
| sigset_t | |||
| jackctl_setup_signals( | |||
| unsigned int flags); | |||
| /** | |||
| * Call this function to wait on a signal set. | |||
| * | |||
| * @param signals signals set to wait on | |||
| */ | |||
| void | |||
| jackctl_wait_signals( | |||
| sigset_t signals); | |||
| /** | |||
| * Call this function to create server object. | |||
| * | |||
| * @return server object handle, NULL if creation of server object | |||
| * failed. Successfully created server object must be destroyed with | |||
| * paired call to ::jackctl_server_destroy | |||
| */ | |||
| jackctl_server_t * | |||
| jackctl_server_create(); | |||
| /** | |||
| * Call this function to destroy server object. | |||
| * | |||
| * @param server server object handle to destroy | |||
| */ | |||
| void | |||
| jackctl_server_destroy( | |||
| jackctl_server_t * server); | |||
| /** | |||
| * Call this function to get list of available drivers. List node data | |||
| * pointers is a driver object handle (::jackctl_driver_t). | |||
| * | |||
| * @param server server object handle to get drivers for | |||
| * | |||
| * @return Single linked list of driver object handles. Must not be | |||
| * modified. Always same for same server object. | |||
| */ | |||
| const JSList * | |||
| jackctl_server_get_drivers_list( | |||
| jackctl_server_t * server); | |||
| /** | |||
| * Call this function to start JACK server | |||
| * | |||
| * @param server server object handle | |||
| * @param driver driver to use | |||
| * | |||
| * @return success status: true - success, false - fail | |||
| */ | |||
| bool | |||
| jackctl_server_start( | |||
| jackctl_server_t * server, | |||
| jackctl_driver_t * driver); | |||
| /** | |||
| * Call this function to stop JACK server | |||
| * | |||
| * @param server server object handle | |||
| * | |||
| * @return success status: true - success, false - fail | |||
| */ | |||
| bool | |||
| jackctl_server_stop( | |||
| jackctl_server_t * server); | |||
| /** | |||
| * Call this function to get list of server parameters. List node data | |||
| * pointers is a parameter object handle (::jackctl_parameter_t). | |||
| * | |||
| * @param server server object handle to get parameters for | |||
| * | |||
| * @return Single linked list of parameter object handles. Must not be | |||
| * modified. Always same for same server object. | |||
| */ | |||
| const JSList * | |||
| jackctl_server_get_parameters( | |||
| jackctl_server_t * server); | |||
| /** | |||
| * Call this function to get name of driver. | |||
| * | |||
| * @param driver driver object handle to get name of | |||
| * | |||
| * @return driver name. Must not be modified. Always same for same | |||
| * driver object. | |||
| */ | |||
| const char * | |||
| jackctl_driver_get_name( | |||
| jackctl_driver_t * driver); | |||
| /** | |||
| * Call this function to get list of driver parameters. List node data | |||
| * pointers is a parameter object handle (::jackctl_parameter_t). | |||
| * | |||
| * @param driver driver object handle to get parameters for | |||
| * | |||
| * @return Single linked list of parameter object handles. Must not be | |||
| * modified. Always same for same driver object. | |||
| */ | |||
| const JSList * | |||
| jackctl_driver_get_parameters( | |||
| jackctl_driver_t * driver); | |||
| /** | |||
| * Call this function to get parameter name. | |||
| * | |||
| * @param parameter parameter object handle to get name of | |||
| * | |||
| * @return parameter name. Must not be modified. Always same for same | |||
| * parameter object. | |||
| */ | |||
| const char * | |||
| jackctl_parameter_get_name( | |||
| jackctl_parameter_t * parameter); | |||
| /** | |||
| * Call this function to get parameter short description. | |||
| * | |||
| * @param parameter parameter object handle to get short description of | |||
| * | |||
| * @return parameter short description. Must not be modified. Always | |||
| * same for same parameter object. | |||
| */ | |||
| const char * | |||
| jackctl_parameter_get_short_description( | |||
| jackctl_parameter_t * parameter); | |||
| /** | |||
| * Call this function to get parameter long description. | |||
| * | |||
| * @param parameter parameter object handle to get long description of | |||
| * | |||
| * @return parameter long description. Must not be modified. Always | |||
| * same for same parameter object. | |||
| */ | |||
| const char * | |||
| jackctl_parameter_get_long_description( | |||
| jackctl_parameter_t * parameter); | |||
| /** | |||
| * Call this function to get parameter type. | |||
| * | |||
| * @param parameter parameter object handle to get type of | |||
| * | |||
| * @return parameter type. Always same for same parameter object. | |||
| */ | |||
| jackctl_param_type_t | |||
| jackctl_parameter_get_type( | |||
| jackctl_parameter_t * parameter); | |||
| /** | |||
| * Call this function to get parameter character. | |||
| * | |||
| * @param parameter parameter object handle to get character of | |||
| * | |||
| * @return character. | |||
| */ | |||
| char | |||
| jackctl_parameter_get_id( | |||
| jackctl_parameter_t * parameter); | |||
| /** | |||
| * Call this function to check whether parameter has been set, or its | |||
| * default value is being used. | |||
| * | |||
| * @param parameter parameter object handle to check | |||
| * | |||
| * @return true - parameter is set, false - parameter is using default | |||
| * value. | |||
| */ | |||
| bool | |||
| jackctl_parameter_is_set( | |||
| jackctl_parameter_t * parameter); | |||
| /** | |||
| * Call this function to reset parameter to its default value. | |||
| * | |||
| * @param parameter parameter object handle to reset value of | |||
| * | |||
| * @return success status: true - success, false - fail | |||
| */ | |||
| bool | |||
| jackctl_parameter_reset( | |||
| jackctl_parameter_t * parameter); | |||
| /** | |||
| * Call this function to get parameter value. | |||
| * | |||
| * @param parameter parameter object handle to get value of | |||
| * | |||
| * @return parameter value. | |||
| */ | |||
| union jackctl_parameter_value | |||
| jackctl_parameter_get_value( | |||
| jackctl_parameter_t * parameter); | |||
| /** | |||
| * Call this function to set parameter value. | |||
| * | |||
| * @param parameter parameter object handle to get value of | |||
| * @param value_ptr pointer to variable containing parameter value | |||
| * | |||
| * @return success status: true - success, false - fail | |||
| */ | |||
| bool | |||
| jackctl_parameter_set_value( | |||
| jackctl_parameter_t * parameter, | |||
| const union jackctl_parameter_value * value_ptr); | |||
| /** | |||
| * Call this function to get parameter default value. | |||
| * | |||
| * @param parameter parameter object handle to get default value of | |||
| * | |||
| * @return parameter default value. | |||
| */ | |||
| union jackctl_parameter_value | |||
| jackctl_parameter_get_default_value( | |||
| jackctl_parameter_t * parameter); | |||
| /** | |||
| * Call this function to log an error message. | |||
| * | |||
| * @param format string | |||
| */ | |||
| void | |||
| jack_error( | |||
| const char *format, | |||
| ...); | |||
| /** | |||
| * Call this function to log an information message. | |||
| * | |||
| * @param format string | |||
| */ | |||
| void | |||
| jack_info( | |||
| const char *format, | |||
| ...); | |||
| /** | |||
| * Call this function to log an information message but only when | |||
| * verbose mode is enabled. | |||
| * | |||
| * @param format string | |||
| */ | |||
| void | |||
| jack_log( | |||
| const char *format, | |||
| ...); | |||
| #if 0 | |||
| { /* Adjust editor indent */ | |||
| #endif | |||
| #ifdef __cplusplus | |||
| } /* extern "C" */ | |||
| #endif | |||
| #endif /* #ifndef JACKCTL_H__2EEDAD78_DF4C_4B26_83B7_4FF1A446A47E__INCLUDED */ | |||
| @@ -0,0 +1,574 @@ | |||
| /* | |||
| Based on gslist.c from glib-1.2.9 (LGPL). | |||
| Adaption to JACK, Copyright (C) 2002 Kai Vehmanen. | |||
| - replaced use of gtypes with normal ANSI C types | |||
| - glib's memory allocation routines replaced with | |||
| malloc/free calls | |||
| This program is free software; you can redistribute it and/or modify | |||
| it under the terms of the GNU Lesser General Public License as published by | |||
| the Free Software Foundation; either version 2.1 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 Lesser General Public License for more details. | |||
| You should have received a copy of the GNU Lesser General Public License | |||
| along with this program; if not, write to the Free Software | |||
| Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. | |||
| */ | |||
| #ifndef __jack_jslist_h__ | |||
| #define __jack_jslist_h__ | |||
| #include <stdlib.h> | |||
| #ifdef WIN32 | |||
| #define __inline__ inline | |||
| #endif | |||
| typedef struct _JSList JSList; | |||
| typedef int (*JCompareFunc) (void* a, void* b); | |||
| struct _JSList | |||
| { | |||
| void *data; | |||
| JSList *next; | |||
| }; | |||
| static __inline__ | |||
| JSList* | |||
| jack_slist_alloc (void) | |||
| { | |||
| JSList *new_list; | |||
| new_list = (JSList*)malloc(sizeof(JSList)); | |||
| new_list->data = NULL; | |||
| new_list->next = NULL; | |||
| return new_list; | |||
| } | |||
| static __inline__ | |||
| JSList* | |||
| jack_slist_prepend (JSList* list, void* data) | |||
| { | |||
| JSList *new_list; | |||
| new_list = (JSList*)malloc(sizeof(JSList)); | |||
| new_list->data = data; | |||
| new_list->next = list; | |||
| return new_list; | |||
| } | |||
| #define jack_slist_next(slist) ((slist) ? (((JSList *)(slist))->next) : NULL) | |||
| static __inline__ | |||
| JSList* | |||
| jack_slist_last (JSList *list) | |||
| { | |||
| if (list) { | |||
| while (list->next) | |||
| list = list->next; | |||
| } | |||
| return list; | |||
| } | |||
| static __inline__ | |||
| JSList* | |||
| jack_slist_remove_link (JSList *list, | |||
| JSList *link) | |||
| { | |||
| JSList *tmp; | |||
| JSList *prev; | |||
| prev = NULL; | |||
| tmp = list; | |||
| while (tmp) { | |||
| if (tmp == link) { | |||
| if (prev) | |||
| prev->next = tmp->next; | |||
| if (list == tmp) | |||
| list = list->next; | |||
| tmp->next = NULL; | |||
| break; | |||
| } | |||
| prev = tmp; | |||
| tmp = tmp->next; | |||
| } | |||
| return list; | |||
| } | |||
| static __inline__ | |||
| void | |||
| jack_slist_free (JSList *list) | |||
| { | |||
| while (list) { | |||
| JSList *next = list->next; | |||
| free(list); | |||
| list = next; | |||
| } | |||
| } | |||
| static __inline__ | |||
| void | |||
| jack_slist_free_1 (JSList *list) | |||
| { | |||
| if (list) { | |||
| free(list); | |||
| } | |||
| } | |||
| static __inline__ | |||
| JSList* | |||
| jack_slist_remove (JSList *list, | |||
| void *data) | |||
| { | |||
| JSList *tmp; | |||
| JSList *prev; | |||
| prev = NULL; | |||
| tmp = list; | |||
| while (tmp) { | |||
| if (tmp->data == data) { | |||
| if (prev) | |||
| prev->next = tmp->next; | |||
| if (list == tmp) | |||
| list = list->next; | |||
| tmp->next = NULL; | |||
| jack_slist_free (tmp); | |||
| break; | |||
| } | |||
| prev = tmp; | |||
| tmp = tmp->next; | |||
| } | |||
| return list; | |||
| } | |||
| static __inline__ | |||
| unsigned int | |||
| jack_slist_length (JSList *list) | |||
| { | |||
| unsigned int length; | |||
| length = 0; | |||
| while (list) { | |||
| length++; | |||
| list = list->next; | |||
| } | |||
| return length; | |||
| } | |||
| static __inline__ | |||
| JSList* | |||
| jack_slist_find (JSList *list, | |||
| void *data) | |||
| { | |||
| while (list) { | |||
| if (list->data == data) | |||
| break; | |||
| list = list->next; | |||
| } | |||
| return list; | |||
| } | |||
| static __inline__ | |||
| JSList* | |||
| jack_slist_copy (JSList *list) | |||
| { | |||
| JSList *new_list = NULL; | |||
| if (list) { | |||
| JSList *last; | |||
| new_list = jack_slist_alloc (); | |||
| new_list->data = list->data; | |||
| last = new_list; | |||
| list = list->next; | |||
| while (list) { | |||
| last->next = jack_slist_alloc (); | |||
| last = last->next; | |||
| last->data = list->data; | |||
| list = list->next; | |||
| } | |||
| } | |||
| return new_list; | |||
| } | |||
| static __inline__ | |||
| JSList* | |||
| jack_slist_append (JSList *list, | |||
| void *data) | |||
| { | |||
| JSList *new_list; | |||
| JSList *last; | |||
| new_list = jack_slist_alloc (); | |||
| new_list->data = data; | |||
| if (list) { | |||
| last = jack_slist_last (list); | |||
| last->next = new_list; | |||
| return list; | |||
| } else | |||
| return new_list; | |||
| } | |||
| static __inline__ | |||
| JSList* | |||
| jack_slist_sort_merge (JSList *l1, | |||
| JSList *l2, | |||
| JCompareFunc compare_func) | |||
| { | |||
| JSList list, *l; | |||
| l = &list; | |||
| while (l1 && l2) { | |||
| if (compare_func(l1->data, l2->data) < 0) { | |||
| l = l->next = l1; | |||
| l1 = l1->next; | |||
| } else { | |||
| l = l->next = l2; | |||
| l2 = l2->next; | |||
| } | |||
| } | |||
| l->next = l1 ? l1 : l2; | |||
| return list.next; | |||
| } | |||
| static __inline__ | |||
| JSList* | |||
| jack_slist_sort (JSList *list, | |||
| JCompareFunc compare_func) | |||
| { | |||
| JSList *l1, *l2; | |||
| if (!list) | |||
| return NULL; | |||
| if (!list->next) | |||
| return list; | |||
| l1 = list; | |||
| l2 = list->next; | |||
| while ((l2 = l2->next) != NULL) { | |||
| if ((l2 = l2->next) == NULL) | |||
| break; | |||
| l1 = l1->next; | |||
| } | |||
| l2 = l1->next; | |||
| l1->next = NULL; | |||
| return jack_slist_sort_merge (jack_slist_sort (list, compare_func), | |||
| jack_slist_sort (l2, compare_func), | |||
| compare_func); | |||
| } | |||
| #endif /* __jack_jslist_h__ */ | |||
| /* | |||
| Based on gslist.c from glib-1.2.9 (LGPL). | |||
| Adaption to JACK, Copyright (C) 2002 Kai Vehmanen. | |||
| - replaced use of gtypes with normal ANSI C types | |||
| - glib's memory allocation routines replaced with | |||
| malloc/free calls | |||
| This program is free software; you can redistribute it and/or modify | |||
| it under the terms of the GNU Lesser General Public License as published by | |||
| the Free Software Foundation; either version 2.1 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 Lesser General Public License for more details. | |||
| You should have received a copy of the GNU Lesser General Public License | |||
| along with this program; if not, write to the Free Software | |||
| Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. | |||
| */ | |||
| #ifndef __jack_jslist_h__ | |||
| #define __jack_jslist_h__ | |||
| #include <stdlib.h> | |||
| #ifdef WIN32 | |||
| #define __inline__ inline | |||
| #endif | |||
| typedef struct _JSList JSList; | |||
| typedef int (*JCompareFunc) (void* a, void* b); | |||
| struct _JSList | |||
| { | |||
| void *data; | |||
| JSList *next; | |||
| }; | |||
| static __inline__ | |||
| JSList* | |||
| jack_slist_alloc (void) | |||
| { | |||
| JSList *new_list; | |||
| new_list = (JSList*)malloc(sizeof(JSList)); | |||
| new_list->data = NULL; | |||
| new_list->next = NULL; | |||
| return new_list; | |||
| } | |||
| static __inline__ | |||
| JSList* | |||
| jack_slist_prepend (JSList* list, void* data) | |||
| { | |||
| JSList *new_list; | |||
| new_list = (JSList*)malloc(sizeof(JSList)); | |||
| new_list->data = data; | |||
| new_list->next = list; | |||
| return new_list; | |||
| } | |||
| #define jack_slist_next(slist) ((slist) ? (((JSList *)(slist))->next) : NULL) | |||
| static __inline__ | |||
| JSList* | |||
| jack_slist_last (JSList *list) | |||
| { | |||
| if (list) { | |||
| while (list->next) | |||
| list = list->next; | |||
| } | |||
| return list; | |||
| } | |||
| static __inline__ | |||
| JSList* | |||
| jack_slist_remove_link (JSList *list, | |||
| JSList *link) | |||
| { | |||
| JSList *tmp; | |||
| JSList *prev; | |||
| prev = NULL; | |||
| tmp = list; | |||
| while (tmp) { | |||
| if (tmp == link) { | |||
| if (prev) | |||
| prev->next = tmp->next; | |||
| if (list == tmp) | |||
| list = list->next; | |||
| tmp->next = NULL; | |||
| break; | |||
| } | |||
| prev = tmp; | |||
| tmp = tmp->next; | |||
| } | |||
| return list; | |||
| } | |||
| static __inline__ | |||
| void | |||
| jack_slist_free (JSList *list) | |||
| { | |||
| while (list) { | |||
| JSList *next = list->next; | |||
| free(list); | |||
| list = next; | |||
| } | |||
| } | |||
| static __inline__ | |||
| void | |||
| jack_slist_free_1 (JSList *list) | |||
| { | |||
| if (list) { | |||
| free(list); | |||
| } | |||
| } | |||
| static __inline__ | |||
| JSList* | |||
| jack_slist_remove (JSList *list, | |||
| void *data) | |||
| { | |||
| JSList *tmp; | |||
| JSList *prev; | |||
| prev = NULL; | |||
| tmp = list; | |||
| while (tmp) { | |||
| if (tmp->data == data) { | |||
| if (prev) | |||
| prev->next = tmp->next; | |||
| if (list == tmp) | |||
| list = list->next; | |||
| tmp->next = NULL; | |||
| jack_slist_free (tmp); | |||
| break; | |||
| } | |||
| prev = tmp; | |||
| tmp = tmp->next; | |||
| } | |||
| return list; | |||
| } | |||
| static __inline__ | |||
| unsigned int | |||
| jack_slist_length (JSList *list) | |||
| { | |||
| unsigned int length; | |||
| length = 0; | |||
| while (list) { | |||
| length++; | |||
| list = list->next; | |||
| } | |||
| return length; | |||
| } | |||
| static __inline__ | |||
| JSList* | |||
| jack_slist_find (JSList *list, | |||
| void *data) | |||
| { | |||
| while (list) { | |||
| if (list->data == data) | |||
| break; | |||
| list = list->next; | |||
| } | |||
| return list; | |||
| } | |||
| static __inline__ | |||
| JSList* | |||
| jack_slist_copy (JSList *list) | |||
| { | |||
| JSList *new_list = NULL; | |||
| if (list) { | |||
| JSList *last; | |||
| new_list = jack_slist_alloc (); | |||
| new_list->data = list->data; | |||
| last = new_list; | |||
| list = list->next; | |||
| while (list) { | |||
| last->next = jack_slist_alloc (); | |||
| last = last->next; | |||
| last->data = list->data; | |||
| list = list->next; | |||
| } | |||
| } | |||
| return new_list; | |||
| } | |||
| static __inline__ | |||
| JSList* | |||
| jack_slist_append (JSList *list, | |||
| void *data) | |||
| { | |||
| JSList *new_list; | |||
| JSList *last; | |||
| new_list = jack_slist_alloc (); | |||
| new_list->data = data; | |||
| if (list) { | |||
| last = jack_slist_last (list); | |||
| last->next = new_list; | |||
| return list; | |||
| } else | |||
| return new_list; | |||
| } | |||
| static __inline__ | |||
| JSList* | |||
| jack_slist_sort_merge (JSList *l1, | |||
| JSList *l2, | |||
| JCompareFunc compare_func) | |||
| { | |||
| JSList list, *l; | |||
| l = &list; | |||
| while (l1 && l2) { | |||
| if (compare_func(l1->data, l2->data) < 0) { | |||
| l = l->next = l1; | |||
| l1 = l1->next; | |||
| } else { | |||
| l = l->next = l2; | |||
| l2 = l2->next; | |||
| } | |||
| } | |||
| l->next = l1 ? l1 : l2; | |||
| return list.next; | |||
| } | |||
| static __inline__ | |||
| JSList* | |||
| jack_slist_sort (JSList *list, | |||
| JCompareFunc compare_func) | |||
| { | |||
| JSList *l1, *l2; | |||
| if (!list) | |||
| return NULL; | |||
| if (!list->next) | |||
| return list; | |||
| l1 = list; | |||
| l2 = list->next; | |||
| while ((l2 = l2->next) != NULL) { | |||
| if ((l2 = l2->next) == NULL) | |||
| break; | |||
| l1 = l1->next; | |||
| } | |||
| l2 = l1->next; | |||
| l1->next = NULL; | |||
| return jack_slist_sort_merge (jack_slist_sort (list, compare_func), | |||
| jack_slist_sort (l2, compare_func), | |||
| compare_func); | |||
| } | |||
| #endif /* __jack_jslist_h__ */ | |||
| @@ -0,0 +1,518 @@ | |||
| #!/usr/bin/env python | |||
| name_base = 'org.jackaudio' | |||
| control_interface_name = name_base + '.JackControl' | |||
| configure_interface_name = name_base + '.JackConfigure' | |||
| service_name = name_base + '.service' | |||
| import sys | |||
| import os | |||
| from traceback import print_exc | |||
| import dbus | |||
| def bool_convert(str_value): | |||
| if str_value.lower() == "false": | |||
| return False | |||
| if str_value.lower() == "off": | |||
| return False | |||
| if str_value.lower() == "no": | |||
| return False | |||
| if str_value == "0": | |||
| return False | |||
| if str_value.lower() == "(null)": | |||
| return False | |||
| return bool(str_value) | |||
| def dbus_type_to_python_type(dbus_value): | |||
| if type(dbus_value) == dbus.Boolean: | |||
| return bool(dbus_value) | |||
| if type(dbus_value) == dbus.Int32 or type(dbus_value) == dbus.UInt32: | |||
| return int(dbus_value) | |||
| return dbus_value | |||
| def python_type_to_jackdbus_type(value, type_char): | |||
| type_char = str(type_char) | |||
| if type_char == "b": | |||
| return bool_convert(value); | |||
| elif type_char == "y": | |||
| return dbus.Byte(value); | |||
| elif type_char == "i": | |||
| return dbus.Int32(value) | |||
| elif type_char == "u": | |||
| return dbus.UInt32(value) | |||
| return value | |||
| def dbus_type_to_type_string(dbus_value): | |||
| if type(dbus_value) == dbus.Boolean: | |||
| return "bool" | |||
| if type(dbus_value) == dbus.Int32: | |||
| return "sint" | |||
| if type(dbus_value) == dbus.UInt32: | |||
| return "uint" | |||
| if type(dbus_value) == dbus.Byte: | |||
| return "char" | |||
| if type(dbus_value) == dbus.String: | |||
| return "str" | |||
| return None # throw exception here? | |||
| def dbus_typesig_to_type_string(type_char): | |||
| type_char = str(type_char) | |||
| if type_char == 'i': | |||
| return "sint" | |||
| if type_char == 'u': | |||
| return "uint" | |||
| if type_char == 'y': | |||
| return "char" | |||
| if type_char == 's': | |||
| return "str" | |||
| if type_char == 'b': | |||
| return "bool" | |||
| print 'shit' | |||
| return None # throw exception here? | |||
| def main(): | |||
| if len(sys.argv) == 1: | |||
| print "Usage: %s [command] [command] ..." % os.path.basename(sys.argv[0]) | |||
| print "Commands:" | |||
| print " exit - exit jack dbus service (stops jack server if currently running)" | |||
| print " status - check whether jack server is started, return value is 0 if runing and 1 otherwise" | |||
| print " start - start jack server if not currently started" | |||
| print " stop - stop jack server if currenly started" | |||
| print " dl - get list of available drivers" | |||
| print " dg - get currently selected driver" | |||
| print " ds <driver> - select driver" | |||
| print " dp - get parameters of currently selected driver" | |||
| print " dpd <param> - get long description for driver parameter" | |||
| print " dps <param> <value> - set driver parameter" | |||
| print " ep - get engine parameters" | |||
| print " epd <param> - get long description for engine parameter" | |||
| print " eps <param> <value> - set engine parameter" | |||
| sys.exit(0) | |||
| bus = dbus.SessionBus() | |||
| controller = bus.get_object(service_name, "/org/jackaudio/Controller") | |||
| control_iface = dbus.Interface(controller, control_interface_name) | |||
| configure_iface = dbus.Interface(controller, configure_interface_name) | |||
| # check arguments | |||
| index = 1 | |||
| while index < len(sys.argv): | |||
| arg = sys.argv[index] | |||
| index += 1 | |||
| try: | |||
| if arg == "exit": | |||
| print "--- exit" | |||
| control_iface.Exit() | |||
| elif arg == "status": | |||
| print "--- status" | |||
| if control_iface.IsStarted(): | |||
| print "started" | |||
| sys.exit(0) | |||
| else: | |||
| print "stopped" | |||
| sys.exit(1) | |||
| elif arg == 'start': | |||
| print "--- start" | |||
| control_iface.StartServer() | |||
| elif arg == 'stop': | |||
| print "--- stop" | |||
| control_iface.StopServer() | |||
| elif arg == 'ism': | |||
| if control_iface.IsManuallyActivated(): | |||
| print "Manually activated" | |||
| else: | |||
| print "Automatically activated" | |||
| elif arg == 'dl': | |||
| print "--- drivers list" | |||
| drivers = configure_iface.GetAvailableDrivers() | |||
| for driver in drivers: | |||
| print driver | |||
| elif arg == 'dg': | |||
| print "--- get selected driver" | |||
| driver = configure_iface.GetSelectedDriver() | |||
| if not driver: | |||
| print "no driver selected" | |||
| else: | |||
| print driver | |||
| elif arg == 'ds': | |||
| if index >= len(sys.argv): | |||
| print "driver select command requires driver name argument" | |||
| sys.exit() | |||
| arg = sys.argv[index] | |||
| index += 1 | |||
| print "--- driver select \"%s\"" % arg | |||
| configure_iface.SelectDriver(arg) | |||
| elif arg == 'dp': | |||
| print "--- get driver parameters (type:isset:default:value)" | |||
| params = configure_iface.GetDriverParametersInfo() | |||
| #print params | |||
| for param in params: | |||
| typestr = dbus_typesig_to_type_string(param[0]) | |||
| name = param[1] | |||
| #print name | |||
| descr = param[2] | |||
| #print descr | |||
| isset, default, value = configure_iface.GetDriverParameterValue(name) | |||
| #print typestr | |||
| if bool(isset): | |||
| isset = "set" | |||
| else: | |||
| isset = "notset" | |||
| value = dbus_type_to_python_type(value) | |||
| default = dbus_type_to_python_type(default) | |||
| print "%20s: %s (%s:%s:%s:%s)" %(name, descr, typestr, isset, default, value) | |||
| elif arg == 'dpd': | |||
| if index >= len(sys.argv): | |||
| print "get driver parameter long description command requires driver name argument" | |||
| sys.exit() | |||
| param = sys.argv[index] | |||
| index += 1 | |||
| print "--- get driver parameter description (%s)" % param | |||
| type_char, name, short_descr, long_descr = configure_iface.GetDriverParameterInfo(param) | |||
| print long_descr, | |||
| elif arg == 'dps': | |||
| if index + 1 >= len(sys.argv): | |||
| print "driver parameter set command requires parametr name and value arguments" | |||
| sys.exit() | |||
| param = sys.argv[index] | |||
| index += 1 | |||
| value = sys.argv[index] | |||
| index += 1 | |||
| print "--- driver param set \"%s\" -> \"%s\"" % (param, value) | |||
| type_char, name, short_descr, long_descr = configure_iface.GetDriverParameterInfo(param) | |||
| configure_iface.SetDriverParameterValue(param, python_type_to_jackdbus_type(value, type_char)) | |||
| elif arg == 'ep': | |||
| print "--- get engine parameters (type:isset:default:value)" | |||
| params = configure_iface.GetEngineParametersInfo() | |||
| #print params | |||
| for param in params: | |||
| typestr = dbus_typesig_to_type_string(param[0]) | |||
| name = param[1] | |||
| #print name | |||
| descr = param[2] | |||
| #print descr | |||
| isset, default, value = configure_iface.GetEngineParameterValue(name) | |||
| #print typestr | |||
| if bool(isset): | |||
| isset = "set" | |||
| else: | |||
| isset = "notset" | |||
| value = dbus_type_to_python_type(value) | |||
| default = dbus_type_to_python_type(default) | |||
| print "%20s: %s (%s:%s:%s:%s)" %(name, descr, typestr, isset, default, value) | |||
| elif arg == 'epd': | |||
| if index >= len(sys.argv): | |||
| print "get engine parameter long description command requires driver name argument" | |||
| sys.exit() | |||
| param_name = sys.argv[index] | |||
| index += 1 | |||
| print "--- get engine parameter description (%s)" % param_name | |||
| type_char, name, short_descr, long_descr = configure_iface.GetEngineParameterInfo(param_name) | |||
| print long_descr, | |||
| elif arg == 'eps': | |||
| if index + 1 >= len(sys.argv): | |||
| print "engine parameter set command requires parametr name and value arguments" | |||
| sys.exit() | |||
| param = sys.argv[index] | |||
| index += 1 | |||
| value = sys.argv[index] | |||
| index += 1 | |||
| print "--- engine param set \"%s\" -> \"%s\"" % (param, value) | |||
| type_char, name, short_descr, long_descr = configure_iface.GetEngineParameterInfo(param) | |||
| configure_iface.SetEngineParameterValue(param, python_type_to_jackdbus_type(value, type_char)) | |||
| else: | |||
| print "Unknown command '%s'" % arg | |||
| except dbus.DBusException, e: | |||
| print "DBus exception: %s" % str(e) | |||
| if __name__ == '__main__': | |||
| main() | |||
| #!/usr/bin/env python | |||
| name_base = 'org.jackaudio' | |||
| control_interface_name = name_base + '.JackControl' | |||
| configure_interface_name = name_base + '.JackConfigure' | |||
| service_name = name_base + '.service' | |||
| import sys | |||
| import os | |||
| from traceback import print_exc | |||
| import dbus | |||
| def bool_convert(str_value): | |||
| if str_value.lower() == "false": | |||
| return False | |||
| if str_value.lower() == "off": | |||
| return False | |||
| if str_value.lower() == "no": | |||
| return False | |||
| if str_value == "0": | |||
| return False | |||
| if str_value.lower() == "(null)": | |||
| return False | |||
| return bool(str_value) | |||
| def dbus_type_to_python_type(dbus_value): | |||
| if type(dbus_value) == dbus.Boolean: | |||
| return bool(dbus_value) | |||
| if type(dbus_value) == dbus.Int32 or type(dbus_value) == dbus.UInt32: | |||
| return int(dbus_value) | |||
| return dbus_value | |||
| def python_type_to_jackdbus_type(value, type_char): | |||
| type_char = str(type_char) | |||
| if type_char == "b": | |||
| return bool_convert(value); | |||
| elif type_char == "y": | |||
| return dbus.Byte(value); | |||
| elif type_char == "i": | |||
| return dbus.Int32(value) | |||
| elif type_char == "u": | |||
| return dbus.UInt32(value) | |||
| return value | |||
| def dbus_type_to_type_string(dbus_value): | |||
| if type(dbus_value) == dbus.Boolean: | |||
| return "bool" | |||
| if type(dbus_value) == dbus.Int32: | |||
| return "sint" | |||
| if type(dbus_value) == dbus.UInt32: | |||
| return "uint" | |||
| if type(dbus_value) == dbus.Byte: | |||
| return "char" | |||
| if type(dbus_value) == dbus.String: | |||
| return "str" | |||
| return None # throw exception here? | |||
| def dbus_typesig_to_type_string(type_char): | |||
| type_char = str(type_char) | |||
| if type_char == 'i': | |||
| return "sint" | |||
| if type_char == 'u': | |||
| return "uint" | |||
| if type_char == 'y': | |||
| return "char" | |||
| if type_char == 's': | |||
| return "str" | |||
| if type_char == 'b': | |||
| return "bool" | |||
| print 'shit' | |||
| return None # throw exception here? | |||
| def main(): | |||
| if len(sys.argv) == 1: | |||
| print "Usage: %s [command] [command] ..." % os.path.basename(sys.argv[0]) | |||
| print "Commands:" | |||
| print " exit - exit jack dbus service (stops jack server if currently running)" | |||
| print " status - check whether jack server is started, return value is 0 if runing and 1 otherwise" | |||
| print " start - start jack server if not currently started" | |||
| print " stop - stop jack server if currenly started" | |||
| print " dl - get list of available drivers" | |||
| print " dg - get currently selected driver" | |||
| print " ds <driver> - select driver" | |||
| print " dp - get parameters of currently selected driver" | |||
| print " dpd <param> - get long description for driver parameter" | |||
| print " dps <param> <value> - set driver parameter" | |||
| print " ep - get engine parameters" | |||
| print " epd <param> - get long description for engine parameter" | |||
| print " eps <param> <value> - set engine parameter" | |||
| sys.exit(0) | |||
| bus = dbus.SessionBus() | |||
| controller = bus.get_object(service_name, "/org/jackaudio/Controller") | |||
| control_iface = dbus.Interface(controller, control_interface_name) | |||
| configure_iface = dbus.Interface(controller, configure_interface_name) | |||
| # check arguments | |||
| index = 1 | |||
| while index < len(sys.argv): | |||
| arg = sys.argv[index] | |||
| index += 1 | |||
| try: | |||
| if arg == "exit": | |||
| print "--- exit" | |||
| control_iface.Exit() | |||
| elif arg == "status": | |||
| print "--- status" | |||
| if control_iface.IsStarted(): | |||
| print "started" | |||
| sys.exit(0) | |||
| else: | |||
| print "stopped" | |||
| sys.exit(1) | |||
| elif arg == 'start': | |||
| print "--- start" | |||
| control_iface.StartServer() | |||
| elif arg == 'stop': | |||
| print "--- stop" | |||
| control_iface.StopServer() | |||
| elif arg == 'ism': | |||
| if control_iface.IsManuallyActivated(): | |||
| print "Manually activated" | |||
| else: | |||
| print "Automatically activated" | |||
| elif arg == 'dl': | |||
| print "--- drivers list" | |||
| drivers = configure_iface.GetAvailableDrivers() | |||
| for driver in drivers: | |||
| print driver | |||
| elif arg == 'dg': | |||
| print "--- get selected driver" | |||
| driver = configure_iface.GetSelectedDriver() | |||
| if not driver: | |||
| print "no driver selected" | |||
| else: | |||
| print driver | |||
| elif arg == 'ds': | |||
| if index >= len(sys.argv): | |||
| print "driver select command requires driver name argument" | |||
| sys.exit() | |||
| arg = sys.argv[index] | |||
| index += 1 | |||
| print "--- driver select \"%s\"" % arg | |||
| configure_iface.SelectDriver(arg) | |||
| elif arg == 'dp': | |||
| print "--- get driver parameters (type:isset:default:value)" | |||
| params = configure_iface.GetDriverParametersInfo() | |||
| #print params | |||
| for param in params: | |||
| typestr = dbus_typesig_to_type_string(param[0]) | |||
| name = param[1] | |||
| #print name | |||
| descr = param[2] | |||
| #print descr | |||
| isset, default, value = configure_iface.GetDriverParameterValue(name) | |||
| #print typestr | |||
| if bool(isset): | |||
| isset = "set" | |||
| else: | |||
| isset = "notset" | |||
| value = dbus_type_to_python_type(value) | |||
| default = dbus_type_to_python_type(default) | |||
| print "%20s: %s (%s:%s:%s:%s)" %(name, descr, typestr, isset, default, value) | |||
| elif arg == 'dpd': | |||
| if index >= len(sys.argv): | |||
| print "get driver parameter long description command requires driver name argument" | |||
| sys.exit() | |||
| param = sys.argv[index] | |||
| index += 1 | |||
| print "--- get driver parameter description (%s)" % param | |||
| type_char, name, short_descr, long_descr = configure_iface.GetDriverParameterInfo(param) | |||
| print long_descr, | |||
| elif arg == 'dps': | |||
| if index + 1 >= len(sys.argv): | |||
| print "driver parameter set command requires parametr name and value arguments" | |||
| sys.exit() | |||
| param = sys.argv[index] | |||
| index += 1 | |||
| value = sys.argv[index] | |||
| index += 1 | |||
| print "--- driver param set \"%s\" -> \"%s\"" % (param, value) | |||
| type_char, name, short_descr, long_descr = configure_iface.GetDriverParameterInfo(param) | |||
| configure_iface.SetDriverParameterValue(param, python_type_to_jackdbus_type(value, type_char)) | |||
| elif arg == 'ep': | |||
| print "--- get engine parameters (type:isset:default:value)" | |||
| params = configure_iface.GetEngineParametersInfo() | |||
| #print params | |||
| for param in params: | |||
| typestr = dbus_typesig_to_type_string(param[0]) | |||
| name = param[1] | |||
| #print name | |||
| descr = param[2] | |||
| #print descr | |||
| isset, default, value = configure_iface.GetEngineParameterValue(name) | |||
| #print typestr | |||
| if bool(isset): | |||
| isset = "set" | |||
| else: | |||
| isset = "notset" | |||
| value = dbus_type_to_python_type(value) | |||
| default = dbus_type_to_python_type(default) | |||
| print "%20s: %s (%s:%s:%s:%s)" %(name, descr, typestr, isset, default, value) | |||
| elif arg == 'epd': | |||
| if index >= len(sys.argv): | |||
| print "get engine parameter long description command requires driver name argument" | |||
| sys.exit() | |||
| param_name = sys.argv[index] | |||
| index += 1 | |||
| print "--- get engine parameter description (%s)" % param_name | |||
| type_char, name, short_descr, long_descr = configure_iface.GetEngineParameterInfo(param_name) | |||
| print long_descr, | |||
| elif arg == 'eps': | |||
| if index + 1 >= len(sys.argv): | |||
| print "engine parameter set command requires parametr name and value arguments" | |||
| sys.exit() | |||
| param = sys.argv[index] | |||
| index += 1 | |||
| value = sys.argv[index] | |||
| index += 1 | |||
| print "--- engine param set \"%s\" -> \"%s\"" % (param, value) | |||
| type_char, name, short_descr, long_descr = configure_iface.GetEngineParameterInfo(param) | |||
| configure_iface.SetEngineParameterValue(param, python_type_to_jackdbus_type(value, type_char)) | |||
| else: | |||
| print "Unknown command '%s'" % arg | |||
| except dbus.DBusException, e: | |||
| print "DBus exception: %s" % str(e) | |||
| if __name__ == '__main__': | |||
| main() | |||
| @@ -0,0 +1,316 @@ | |||
| # | |||
| # Copyright (C) 2008 Nedko Arnaudov | |||
| # | |||
| # This program is free software: you can redistribute it and/or modify | |||
| # it under the terms of the GNU General Public License as published by | |||
| # the Free Software Foundation, version 2 of the License. | |||
| # | |||
| # 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 General Public License for more details. | |||
| # | |||
| # You should have received a copy of the GNU General Public License | |||
| # along with this program. If not, see <http://www.gnu.org/licenses/>. | |||
| # | |||
| import os | |||
| from string import Template | |||
| from SCons.Script.SConscript import SConsEnvironment | |||
| def pkg_config_get_value(module, args): | |||
| return env.backtick('pkg-config ' + args + ' ' + module).strip() | |||
| def merge_pkg_config_append_string(env, envvar, module, args): | |||
| value = pkg_config_get_value(module, args) | |||
| #print value | |||
| if env._dict.has_key(envvar): | |||
| env._dict[envvar] += value | |||
| else: | |||
| env._dict[envvar] = value | |||
| def merge_pkg_config_libs(env, module): | |||
| for lib in pkg_config_get_value(module, "--libs").split(' '): | |||
| if lib[:2] == '-l': | |||
| env._dict['LIBS'].append(lib[2:]) | |||
| elif lib[:2] == '-L': | |||
| env._dict['LIBPATH'].append(lib[2:]) | |||
| def merge_pkg_config_variable(env, envvar, module, pkgvar): | |||
| merge_pkg_config_append_string(env, envvar, module, '--variable=' + pkgvar) | |||
| def merge_pkg_config_std(env, module): | |||
| merge_pkg_config_append_string(env, 'CCFLAGS', module, '--cflags') | |||
| merge_pkg_config_libs(env, module) | |||
| Import('env') | |||
| jackenv = env.Copy() | |||
| #print "LIBS (orig): " + repr(jackenv['LIBS']) | |||
| #print "SERVERLIB: " + repr(jackenv['SERVERLIB']) | |||
| jackenv.Append(LIBS=[jackenv['SERVERLIB'], 'dl', 'expat']) | |||
| merge_pkg_config_variable(jackenv, 'DBUS_SERVICES_DIR', 'dbus-1', 'session_bus_services_dir') | |||
| merge_pkg_config_std(jackenv, 'dbus-1') | |||
| #print "CFLAGS: " + jackenv['CFLAGS'] | |||
| #print "CCFLAGS: " + jackenv['CCFLAGS'] | |||
| #print "LINKFLAGS: " + repr(jackenv['LINKFLAGS']) | |||
| #print "LIBPATH: " + repr(jackenv['LIBPATH']) | |||
| #print "LIBS: " + repr(jackenv['LIBS']) | |||
| #print "DBUS_SERVICES_DIR: " + jackenv['DBUS_SERVICES_DIR'] | |||
| jackenv.Install(env['BINDIR'], jackenv.Program('jackdbus', [ | |||
| 'jackdbus.c', | |||
| 'controller.c', | |||
| 'controller_iface_configure.c', | |||
| 'controller_iface_control.c', | |||
| 'controller_iface_introspectable.c', | |||
| 'controller_iface_patchbay.c', | |||
| 'controller_iface_transport.c', | |||
| 'xml.c', | |||
| 'xml_expat.c', | |||
| # 'xml_libxml.c', | |||
| # 'xml_nop.c', | |||
| 'xml_write_raw.c', | |||
| ])) | |||
| jackenv.Alias('install', env['BINDIR']) | |||
| jackenv.ScanReplace('org.jackaudio.service.in') | |||
| jackenv.Install(jackenv['DBUS_SERVICES_DIR'], 'org.jackaudio.service') | |||
| jackenv.Alias('install', jackenv['DBUS_SERVICES_DIR']) | |||
| # | |||
| # Copyright (C) 2008 Nedko Arnaudov | |||
| # | |||
| # This program is free software: you can redistribute it and/or modify | |||
| # it under the terms of the GNU General Public License as published by | |||
| # the Free Software Foundation, version 2 of the License. | |||
| # | |||
| # 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 General Public License for more details. | |||
| # | |||
| # You should have received a copy of the GNU General Public License | |||
| # along with this program. If not, see <http://www.gnu.org/licenses/>. | |||
| # | |||
| import os | |||
| from string import Template | |||
| from SCons.Script.SConscript import SConsEnvironment | |||
| def pkg_config_get_value(module, args): | |||
| return env.backtick('pkg-config ' + args + ' ' + module).strip() | |||
| def merge_pkg_config_append_string(env, envvar, module, args): | |||
| value = pkg_config_get_value(module, args) | |||
| #print value | |||
| if env._dict.has_key(envvar): | |||
| env._dict[envvar] += value | |||
| else: | |||
| env._dict[envvar] = value | |||
| def merge_pkg_config_libs(env, module): | |||
| for lib in pkg_config_get_value(module, "--libs").split(' '): | |||
| if lib[:2] == '-l': | |||
| env._dict['LIBS'].append(lib[2:]) | |||
| elif lib[:2] == '-L': | |||
| env._dict['LIBPATH'].append(lib[2:]) | |||
| def merge_pkg_config_variable(env, envvar, module, pkgvar): | |||
| merge_pkg_config_append_string(env, envvar, module, '--variable=' + pkgvar) | |||
| def merge_pkg_config_std(env, module): | |||
| merge_pkg_config_append_string(env, 'CCFLAGS', module, '--cflags') | |||
| merge_pkg_config_libs(env, module) | |||
| Import('env') | |||
| jackenv = env.Copy() | |||
| #print "LIBS (orig): " + repr(jackenv['LIBS']) | |||
| #print "SERVERLIB: " + repr(jackenv['SERVERLIB']) | |||
| jackenv.Append(LIBS=[jackenv['SERVERLIB'], 'dl', 'expat']) | |||
| merge_pkg_config_variable(jackenv, 'DBUS_SERVICES_DIR', 'dbus-1', 'session_bus_services_dir') | |||
| merge_pkg_config_std(jackenv, 'dbus-1') | |||
| #print "CFLAGS: " + jackenv['CFLAGS'] | |||
| #print "CCFLAGS: " + jackenv['CCFLAGS'] | |||
| #print "LINKFLAGS: " + repr(jackenv['LINKFLAGS']) | |||
| #print "LIBPATH: " + repr(jackenv['LIBPATH']) | |||
| #print "LIBS: " + repr(jackenv['LIBS']) | |||
| #print "DBUS_SERVICES_DIR: " + jackenv['DBUS_SERVICES_DIR'] | |||
| jackenv.Install(env['BINDIR'], jackenv.Program('jackdbus', [ | |||
| 'jackdbus.c', | |||
| 'controller.c', | |||
| 'controller_iface_configure.c', | |||
| 'controller_iface_control.c', | |||
| 'controller_iface_introspectable.c', | |||
| 'controller_iface_patchbay.c', | |||
| 'controller_iface_transport.c', | |||
| 'xml.c', | |||
| 'xml_expat.c', | |||
| # 'xml_libxml.c', | |||
| # 'xml_nop.c', | |||
| 'xml_write_raw.c', | |||
| ])) | |||
| jackenv.Alias('install', env['BINDIR']) | |||
| jackenv.ScanReplace('org.jackaudio.service.in') | |||
| jackenv.Install(jackenv['DBUS_SERVICES_DIR'], 'org.jackaudio.service') | |||
| jackenv.Alias('install', jackenv['DBUS_SERVICES_DIR']) | |||
| # | |||
| # Copyright (C) 2008 Nedko Arnaudov | |||
| # | |||
| # This program is free software: you can redistribute it and/or modify | |||
| # it under the terms of the GNU General Public License as published by | |||
| # the Free Software Foundation, version 2 of the License. | |||
| # | |||
| # 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 General Public License for more details. | |||
| # | |||
| # You should have received a copy of the GNU General Public License | |||
| # along with this program. If not, see <http://www.gnu.org/licenses/>. | |||
| # | |||
| import os | |||
| from string import Template | |||
| from SCons.Script.SConscript import SConsEnvironment | |||
| def pkg_config_get_value(module, args): | |||
| return env.backtick('pkg-config ' + args + ' ' + module).strip() | |||
| def merge_pkg_config_append_string(env, envvar, module, args): | |||
| value = pkg_config_get_value(module, args) | |||
| #print value | |||
| if env._dict.has_key(envvar): | |||
| env._dict[envvar] += value | |||
| else: | |||
| env._dict[envvar] = value | |||
| def merge_pkg_config_libs(env, module): | |||
| for lib in pkg_config_get_value(module, "--libs").split(' '): | |||
| if lib[:2] == '-l': | |||
| env._dict['LIBS'].append(lib[2:]) | |||
| elif lib[:2] == '-L': | |||
| env._dict['LIBPATH'].append(lib[2:]) | |||
| def merge_pkg_config_variable(env, envvar, module, pkgvar): | |||
| merge_pkg_config_append_string(env, envvar, module, '--variable=' + pkgvar) | |||
| def merge_pkg_config_std(env, module): | |||
| merge_pkg_config_append_string(env, 'CCFLAGS', module, '--cflags') | |||
| merge_pkg_config_libs(env, module) | |||
| Import('env') | |||
| jackenv = env.Copy() | |||
| #print "LIBS (orig): " + repr(jackenv['LIBS']) | |||
| #print "SERVERLIB: " + repr(jackenv['SERVERLIB']) | |||
| jackenv.Append(LIBS=[jackenv['SERVERLIB'], 'dl', 'expat']) | |||
| merge_pkg_config_variable(jackenv, 'DBUS_SERVICES_DIR', 'dbus-1', 'session_bus_services_dir') | |||
| merge_pkg_config_std(jackenv, 'dbus-1') | |||
| #print "CFLAGS: " + jackenv['CFLAGS'] | |||
| #print "CCFLAGS: " + jackenv['CCFLAGS'] | |||
| #print "LINKFLAGS: " + repr(jackenv['LINKFLAGS']) | |||
| #print "LIBPATH: " + repr(jackenv['LIBPATH']) | |||
| #print "LIBS: " + repr(jackenv['LIBS']) | |||
| #print "DBUS_SERVICES_DIR: " + jackenv['DBUS_SERVICES_DIR'] | |||
| jackenv.Install(env['BINDIR'], jackenv.Program('jackdbus', [ | |||
| 'jackdbus.c', | |||
| 'controller.c', | |||
| 'controller_iface_configure.c', | |||
| 'controller_iface_control.c', | |||
| 'controller_iface_introspectable.c', | |||
| 'controller_iface_patchbay.c', | |||
| 'controller_iface_transport.c', | |||
| 'xml.c', | |||
| 'xml_expat.c', | |||
| # 'xml_libxml.c', | |||
| # 'xml_nop.c', | |||
| 'xml_write_raw.c', | |||
| ])) | |||
| jackenv.Alias('install', env['BINDIR']) | |||
| jackenv.ScanReplace('org.jackaudio.service.in') | |||
| jackenv.Install(jackenv['DBUS_SERVICES_DIR'], 'org.jackaudio.service') | |||
| jackenv.Alias('install', jackenv['DBUS_SERVICES_DIR']) | |||
| # | |||
| # Copyright (C) 2008 Nedko Arnaudov | |||
| # | |||
| # This program is free software: you can redistribute it and/or modify | |||
| # it under the terms of the GNU General Public License as published by | |||
| # the Free Software Foundation, version 2 of the License. | |||
| # | |||
| # 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 General Public License for more details. | |||
| # | |||
| # You should have received a copy of the GNU General Public License | |||
| # along with this program. If not, see <http://www.gnu.org/licenses/>. | |||
| # | |||
| import os | |||
| from string import Template | |||
| from SCons.Script.SConscript import SConsEnvironment | |||
| def pkg_config_get_value(module, args): | |||
| return env.backtick('pkg-config ' + args + ' ' + module).strip() | |||
| def merge_pkg_config_append_string(env, envvar, module, args): | |||
| value = pkg_config_get_value(module, args) | |||
| #print value | |||
| if env._dict.has_key(envvar): | |||
| env._dict[envvar] += value | |||
| else: | |||
| env._dict[envvar] = value | |||
| def merge_pkg_config_libs(env, module): | |||
| for lib in pkg_config_get_value(module, "--libs").split(' '): | |||
| if lib[:2] == '-l': | |||
| env._dict['LIBS'].append(lib[2:]) | |||
| elif lib[:2] == '-L': | |||
| env._dict['LIBPATH'].append(lib[2:]) | |||
| def merge_pkg_config_variable(env, envvar, module, pkgvar): | |||
| merge_pkg_config_append_string(env, envvar, module, '--variable=' + pkgvar) | |||
| def merge_pkg_config_std(env, module): | |||
| merge_pkg_config_append_string(env, 'CCFLAGS', module, '--cflags') | |||
| merge_pkg_config_libs(env, module) | |||
| Import('env') | |||
| jackenv = env.Copy() | |||
| #print "LIBS (orig): " + repr(jackenv['LIBS']) | |||
| #print "SERVERLIB: " + repr(jackenv['SERVERLIB']) | |||
| jackenv.Append(LIBS=[jackenv['SERVERLIB'], 'dl', 'expat']) | |||
| merge_pkg_config_variable(jackenv, 'DBUS_SERVICES_DIR', 'dbus-1', 'session_bus_services_dir') | |||
| merge_pkg_config_std(jackenv, 'dbus-1') | |||
| #print "CFLAGS: " + jackenv['CFLAGS'] | |||
| #print "CCFLAGS: " + jackenv['CCFLAGS'] | |||
| #print "LINKFLAGS: " + repr(jackenv['LINKFLAGS']) | |||
| #print "LIBPATH: " + repr(jackenv['LIBPATH']) | |||
| #print "LIBS: " + repr(jackenv['LIBS']) | |||
| #print "DBUS_SERVICES_DIR: " + jackenv['DBUS_SERVICES_DIR'] | |||
| jackenv.Install(env['BINDIR'], jackenv.Program('jackdbus', [ | |||
| 'jackdbus.c', | |||
| 'controller.c', | |||
| 'controller_iface_configure.c', | |||
| 'controller_iface_control.c', | |||
| 'controller_iface_introspectable.c', | |||
| 'controller_iface_patchbay.c', | |||
| 'controller_iface_transport.c', | |||
| 'xml.c', | |||
| 'xml_expat.c', | |||
| # 'xml_libxml.c', | |||
| # 'xml_nop.c', | |||
| 'xml_write_raw.c', | |||
| ])) | |||
| jackenv.Alias('install', env['BINDIR']) | |||
| jackenv.ScanReplace('org.jackaudio.service.in') | |||
| jackenv.Install(jackenv['DBUS_SERVICES_DIR'], 'org.jackaudio.service') | |||
| jackenv.Alias('install', jackenv['DBUS_SERVICES_DIR']) | |||
| @@ -0,0 +1,124 @@ | |||
| /* -*- Mode: C ; c-basic-offset: 4 -*- */ | |||
| /* | |||
| Copyright (C) 2007 Nedko Arnaudov | |||
| This program is free software; you can redistribute it and/or modify | |||
| it under the terms of the GNU General Public License as published by | |||
| the Free Software Foundation; either version 2 of the License. | |||
| 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 General Public License for more details. | |||
| You should have received a copy of the GNU General Public License | |||
| along with this program; if not, write to the Free Software | |||
| Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. | |||
| */ | |||
| #ifndef CONTROLLER_H__2CC80B1E_8D5D_45E3_A9D8_9086DDF68BB5__INCLUDED | |||
| #define CONTROLLER_H__2CC80B1E_8D5D_45E3_A9D8_9086DDF68BB5__INCLUDED | |||
| void * | |||
| jack_controller_create( | |||
| DBusConnection *connection); | |||
| void | |||
| jack_controller_destroy( | |||
| void *controller_ptr); | |||
| #endif /* #ifndef CONTROLLER_H__2CC80B1E_8D5D_45E3_A9D8_9086DDF68BB5__INCLUDED */ | |||
| /* -*- Mode: C ; c-basic-offset: 4 -*- */ | |||
| /* | |||
| Copyright (C) 2007 Nedko Arnaudov | |||
| This program is free software; you can redistribute it and/or modify | |||
| it under the terms of the GNU General Public License as published by | |||
| the Free Software Foundation; either version 2 of the License. | |||
| 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 General Public License for more details. | |||
| You should have received a copy of the GNU General Public License | |||
| along with this program; if not, write to the Free Software | |||
| Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. | |||
| */ | |||
| #ifndef CONTROLLER_H__2CC80B1E_8D5D_45E3_A9D8_9086DDF68BB5__INCLUDED | |||
| #define CONTROLLER_H__2CC80B1E_8D5D_45E3_A9D8_9086DDF68BB5__INCLUDED | |||
| void * | |||
| jack_controller_create( | |||
| DBusConnection *connection); | |||
| void | |||
| jack_controller_destroy( | |||
| void *controller_ptr); | |||
| #endif /* #ifndef CONTROLLER_H__2CC80B1E_8D5D_45E3_A9D8_9086DDF68BB5__INCLUDED */ | |||
| /* -*- Mode: C ; c-basic-offset: 4 -*- */ | |||
| /* | |||
| Copyright (C) 2007 Nedko Arnaudov | |||
| This program is free software; you can redistribute it and/or modify | |||
| it under the terms of the GNU General Public License as published by | |||
| the Free Software Foundation; either version 2 of the License. | |||
| 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 General Public License for more details. | |||
| You should have received a copy of the GNU General Public License | |||
| along with this program; if not, write to the Free Software | |||
| Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. | |||
| */ | |||
| #ifndef CONTROLLER_H__2CC80B1E_8D5D_45E3_A9D8_9086DDF68BB5__INCLUDED | |||
| #define CONTROLLER_H__2CC80B1E_8D5D_45E3_A9D8_9086DDF68BB5__INCLUDED | |||
| void * | |||
| jack_controller_create( | |||
| DBusConnection *connection); | |||
| void | |||
| jack_controller_destroy( | |||
| void *controller_ptr); | |||
| #endif /* #ifndef CONTROLLER_H__2CC80B1E_8D5D_45E3_A9D8_9086DDF68BB5__INCLUDED */ | |||
| /* -*- Mode: C ; c-basic-offset: 4 -*- */ | |||
| /* | |||
| Copyright (C) 2007 Nedko Arnaudov | |||
| This program is free software; you can redistribute it and/or modify | |||
| it under the terms of the GNU General Public License as published by | |||
| the Free Software Foundation; either version 2 of the License. | |||
| 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 General Public License for more details. | |||
| You should have received a copy of the GNU General Public License | |||
| along with this program; if not, write to the Free Software | |||
| Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. | |||
| */ | |||
| #ifndef CONTROLLER_H__2CC80B1E_8D5D_45E3_A9D8_9086DDF68BB5__INCLUDED | |||
| #define CONTROLLER_H__2CC80B1E_8D5D_45E3_A9D8_9086DDF68BB5__INCLUDED | |||
| void * | |||
| jack_controller_create( | |||
| DBusConnection *connection); | |||
| void | |||
| jack_controller_destroy( | |||
| void *controller_ptr); | |||
| #endif /* #ifndef CONTROLLER_H__2CC80B1E_8D5D_45E3_A9D8_9086DDF68BB5__INCLUDED */ | |||
| @@ -0,0 +1,916 @@ | |||
| /* -*- Mode: C ; c-basic-offset: 4 -*- */ | |||
| /* | |||
| Copyright (C) 2007,2008 Nedko Arnaudov | |||
| Copyright (C) 2007-2008 Juuso Alasuutari | |||
| This program is free software; you can redistribute it and/or modify | |||
| it under the terms of the GNU General Public License as published by | |||
| the Free Software Foundation; either version 2 of the License. | |||
| 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 General Public License for more details. | |||
| You should have received a copy of the GNU General Public License | |||
| along with this program; if not, write to the Free Software | |||
| Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. | |||
| */ | |||
| #include <stdint.h> | |||
| #include <string.h> | |||
| #include <stdio.h> | |||
| #include <assert.h> | |||
| #include <dbus/dbus.h> | |||
| #include "jackdbus.h" | |||
| #include "controller_internal.h" | |||
| #define controller_ptr ((struct jack_controller *)call->context) | |||
| /* | |||
| * Check if the supplied method name exists in org.jackaudio.JackControl, | |||
| * if it does execute it and return true. Otherwise return false. | |||
| */ | |||
| static | |||
| bool | |||
| jack_control_run_method( | |||
| struct jack_dbus_method_call * call, | |||
| const struct jack_dbus_interface_method_descriptor * methods) | |||
| { | |||
| int ret; | |||
| int type; | |||
| message_arg_t arg; | |||
| /* use empty reply if not overriden in the code that follows */ | |||
| type = DBUS_TYPE_INVALID; | |||
| if (strcmp (call->method_name, "Exit") == 0) | |||
| { | |||
| g_exit_command = TRUE; | |||
| } | |||
| else if (strcmp (call->method_name, "IsStarted") == 0) | |||
| { | |||
| type = DBUS_TYPE_BOOLEAN; | |||
| arg.boolean = (dbus_bool_t) (controller_ptr->started ? TRUE : FALSE); | |||
| } | |||
| else if (strcmp (call->method_name, "StartServer") == 0) | |||
| { | |||
| if (!jack_controller_start_server(controller_ptr, call)) | |||
| { | |||
| jack_error ("Failed to start server"); | |||
| } | |||
| } | |||
| else if (strcmp (call->method_name, "StopServer") == 0) | |||
| { | |||
| if (!jack_controller_stop_server(controller_ptr, call)) | |||
| { | |||
| jack_error ("Failed to stop server"); | |||
| } | |||
| } | |||
| else if (strcmp (call->method_name, "GetLoad") == 0) | |||
| { | |||
| if (!controller_ptr->started) | |||
| { | |||
| goto not_started; | |||
| } | |||
| type = DBUS_TYPE_DOUBLE; | |||
| arg.doubl = jack_cpu_load(controller_ptr->client); | |||
| } | |||
| else if (strcmp (call->method_name, "GetXruns") == 0) | |||
| { | |||
| type = DBUS_TYPE_UINT32; | |||
| arg.uint32 = controller_ptr->xruns; | |||
| } | |||
| else if (strcmp (call->method_name, "GetSampleRate") == 0) | |||
| { | |||
| if (!controller_ptr->started) | |||
| { | |||
| goto not_started; | |||
| } | |||
| type = DBUS_TYPE_UINT32; | |||
| arg.uint32 = jack_get_sample_rate(controller_ptr->client); | |||
| } | |||
| else if (strcmp (call->method_name, "GetLatency") == 0) | |||
| { | |||
| if (!controller_ptr->started) | |||
| { | |||
| goto not_started; | |||
| } | |||
| type = DBUS_TYPE_DOUBLE; | |||
| arg.doubl = ((float)jack_get_buffer_size(controller_ptr->client) / (float)jack_get_sample_rate(controller_ptr->client)) * 1000.0f; | |||
| } | |||
| else if (strcmp (call->method_name, "GetBufferSize") == 0) | |||
| { | |||
| if (!controller_ptr->started) | |||
| { | |||
| goto not_started; | |||
| } | |||
| type = DBUS_TYPE_UINT32; | |||
| arg.uint32 = jack_get_buffer_size(controller_ptr->client); | |||
| } | |||
| else if (strcmp (call->method_name, "SetBufferSize") == 0) | |||
| { | |||
| dbus_uint32_t buffer_size; | |||
| if (!controller_ptr->started) | |||
| { | |||
| goto not_started; | |||
| } | |||
| if (!jack_dbus_get_method_args(call, DBUS_TYPE_UINT32, &buffer_size, DBUS_TYPE_INVALID)) | |||
| { | |||
| /* jack_dbus_get_method_args() has set reply for us */ | |||
| goto exit; | |||
| } | |||
| ret = jack_set_buffer_size(controller_ptr->client, buffer_size); | |||
| if (ret != 0) | |||
| { | |||
| jack_dbus_error( | |||
| call, | |||
| JACK_DBUS_ERROR_GENERIC, | |||
| "jack_set_buffer_size(%u) failed with error %d", (unsigned int)buffer_size, ret); | |||
| goto exit; | |||
| } | |||
| } | |||
| else if (strcmp (call->method_name, "IsRealtime") == 0) | |||
| { | |||
| type = DBUS_TYPE_BOOLEAN; | |||
| arg.boolean = jack_is_realtime(controller_ptr->client) ? TRUE : FALSE; | |||
| } | |||
| else if (strcmp (call->method_name, "ResetXruns") == 0) | |||
| { | |||
| controller_ptr->xruns = 0; | |||
| } | |||
| else | |||
| { | |||
| return false; | |||
| } | |||
| jack_dbus_construct_method_return_single(call, type, arg); | |||
| return true; | |||
| not_started: | |||
| jack_dbus_error (call, JACK_DBUS_ERROR_SERVER_NOT_RUNNING, | |||
| "Can't execute method '%s' with stopped JACK server", call->method_name); | |||
| exit: | |||
| return true; | |||
| } | |||
| #undef controller_ptr | |||
| JACK_DBUS_METHOD_ARGUMENTS_BEGIN(IsStarted) | |||
| JACK_DBUS_METHOD_ARGUMENT("started", "b", true) | |||
| JACK_DBUS_METHOD_ARGUMENTS_END | |||
| JACK_DBUS_METHOD_ARGUMENTS_BEGIN(StartServer) | |||
| JACK_DBUS_METHOD_ARGUMENTS_END | |||
| JACK_DBUS_METHOD_ARGUMENTS_BEGIN(StopServer) | |||
| JACK_DBUS_METHOD_ARGUMENTS_END | |||
| JACK_DBUS_METHOD_ARGUMENTS_BEGIN(GetLoad) | |||
| JACK_DBUS_METHOD_ARGUMENT("load", "d", true) | |||
| JACK_DBUS_METHOD_ARGUMENTS_END | |||
| JACK_DBUS_METHOD_ARGUMENTS_BEGIN(GetXruns) | |||
| JACK_DBUS_METHOD_ARGUMENT("xruns_count", "u", true) | |||
| JACK_DBUS_METHOD_ARGUMENTS_END | |||
| JACK_DBUS_METHOD_ARGUMENTS_BEGIN(GetSampleRate) | |||
| JACK_DBUS_METHOD_ARGUMENT("sample_rate", "u", true) | |||
| JACK_DBUS_METHOD_ARGUMENTS_END | |||
| JACK_DBUS_METHOD_ARGUMENTS_BEGIN(GetLatency) | |||
| JACK_DBUS_METHOD_ARGUMENT("latency_ms", "d", true) | |||
| JACK_DBUS_METHOD_ARGUMENTS_END | |||
| JACK_DBUS_METHOD_ARGUMENTS_BEGIN(GetBufferSize) | |||
| JACK_DBUS_METHOD_ARGUMENT("buffer_size_frames", "u", true) | |||
| JACK_DBUS_METHOD_ARGUMENTS_END | |||
| JACK_DBUS_METHOD_ARGUMENTS_BEGIN(SetBufferSize) | |||
| JACK_DBUS_METHOD_ARGUMENT("buffer_size_frames", "u", false) | |||
| JACK_DBUS_METHOD_ARGUMENTS_END | |||
| JACK_DBUS_METHOD_ARGUMENTS_BEGIN(IsRealtime) | |||
| JACK_DBUS_METHOD_ARGUMENT("realtime", "b", true) | |||
| JACK_DBUS_METHOD_ARGUMENTS_END | |||
| JACK_DBUS_METHOD_ARGUMENTS_BEGIN(ResetXruns) | |||
| JACK_DBUS_METHOD_ARGUMENTS_END | |||
| JACK_DBUS_METHODS_BEGIN | |||
| JACK_DBUS_METHOD_DESCRIBE(IsStarted, NULL) | |||
| JACK_DBUS_METHOD_DESCRIBE(StartServer, NULL) | |||
| JACK_DBUS_METHOD_DESCRIBE(StopServer, NULL) | |||
| JACK_DBUS_METHOD_DESCRIBE(GetLoad, NULL) | |||
| JACK_DBUS_METHOD_DESCRIBE(GetXruns, NULL) | |||
| JACK_DBUS_METHOD_DESCRIBE(GetSampleRate, NULL) | |||
| JACK_DBUS_METHOD_DESCRIBE(GetLatency, NULL) | |||
| JACK_DBUS_METHOD_DESCRIBE(GetBufferSize, NULL) | |||
| JACK_DBUS_METHOD_DESCRIBE(SetBufferSize, NULL) | |||
| JACK_DBUS_METHOD_DESCRIBE(IsRealtime, NULL) | |||
| JACK_DBUS_METHOD_DESCRIBE(ResetXruns, NULL) | |||
| JACK_DBUS_METHODS_END | |||
| JACK_DBUS_IFACE_BEGIN(g_jack_controller_iface_control, "org.jackaudio.JackControl") | |||
| JACK_DBUS_IFACE_HANDLER(jack_control_run_method) | |||
| JACK_DBUS_IFACE_EXPOSE_METHODS | |||
| JACK_DBUS_IFACE_END | |||
| /* -*- Mode: C ; c-basic-offset: 4 -*- */ | |||
| /* | |||
| Copyright (C) 2007,2008 Nedko Arnaudov | |||
| Copyright (C) 2007-2008 Juuso Alasuutari | |||
| This program is free software; you can redistribute it and/or modify | |||
| it under the terms of the GNU General Public License as published by | |||
| the Free Software Foundation; either version 2 of the License. | |||
| 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 General Public License for more details. | |||
| You should have received a copy of the GNU General Public License | |||
| along with this program; if not, write to the Free Software | |||
| Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. | |||
| */ | |||
| #include <stdint.h> | |||
| #include <string.h> | |||
| #include <stdio.h> | |||
| #include <assert.h> | |||
| #include <dbus/dbus.h> | |||
| #include "jackdbus.h" | |||
| #include "controller_internal.h" | |||
| #define controller_ptr ((struct jack_controller *)call->context) | |||
| /* | |||
| * Check if the supplied method name exists in org.jackaudio.JackControl, | |||
| * if it does execute it and return true. Otherwise return false. | |||
| */ | |||
| static | |||
| bool | |||
| jack_control_run_method( | |||
| struct jack_dbus_method_call * call, | |||
| const struct jack_dbus_interface_method_descriptor * methods) | |||
| { | |||
| int ret; | |||
| int type; | |||
| message_arg_t arg; | |||
| /* use empty reply if not overriden in the code that follows */ | |||
| type = DBUS_TYPE_INVALID; | |||
| if (strcmp (call->method_name, "Exit") == 0) | |||
| { | |||
| g_exit_command = TRUE; | |||
| } | |||
| else if (strcmp (call->method_name, "IsStarted") == 0) | |||
| { | |||
| type = DBUS_TYPE_BOOLEAN; | |||
| arg.boolean = (dbus_bool_t) (controller_ptr->started ? TRUE : FALSE); | |||
| } | |||
| else if (strcmp (call->method_name, "StartServer") == 0) | |||
| { | |||
| if (!jack_controller_start_server(controller_ptr, call)) | |||
| { | |||
| jack_error ("Failed to start server"); | |||
| } | |||
| } | |||
| else if (strcmp (call->method_name, "StopServer") == 0) | |||
| { | |||
| if (!jack_controller_stop_server(controller_ptr, call)) | |||
| { | |||
| jack_error ("Failed to stop server"); | |||
| } | |||
| } | |||
| else if (strcmp (call->method_name, "GetLoad") == 0) | |||
| { | |||
| if (!controller_ptr->started) | |||
| { | |||
| goto not_started; | |||
| } | |||
| type = DBUS_TYPE_DOUBLE; | |||
| arg.doubl = jack_cpu_load(controller_ptr->client); | |||
| } | |||
| else if (strcmp (call->method_name, "GetXruns") == 0) | |||
| { | |||
| type = DBUS_TYPE_UINT32; | |||
| arg.uint32 = controller_ptr->xruns; | |||
| } | |||
| else if (strcmp (call->method_name, "GetSampleRate") == 0) | |||
| { | |||
| if (!controller_ptr->started) | |||
| { | |||
| goto not_started; | |||
| } | |||
| type = DBUS_TYPE_UINT32; | |||
| arg.uint32 = jack_get_sample_rate(controller_ptr->client); | |||
| } | |||
| else if (strcmp (call->method_name, "GetLatency") == 0) | |||
| { | |||
| if (!controller_ptr->started) | |||
| { | |||
| goto not_started; | |||
| } | |||
| type = DBUS_TYPE_DOUBLE; | |||
| arg.doubl = ((float)jack_get_buffer_size(controller_ptr->client) / (float)jack_get_sample_rate(controller_ptr->client)) * 1000.0f; | |||
| } | |||
| else if (strcmp (call->method_name, "GetBufferSize") == 0) | |||
| { | |||
| if (!controller_ptr->started) | |||
| { | |||
| goto not_started; | |||
| } | |||
| type = DBUS_TYPE_UINT32; | |||
| arg.uint32 = jack_get_buffer_size(controller_ptr->client); | |||
| } | |||
| else if (strcmp (call->method_name, "SetBufferSize") == 0) | |||
| { | |||
| dbus_uint32_t buffer_size; | |||
| if (!controller_ptr->started) | |||
| { | |||
| goto not_started; | |||
| } | |||
| if (!jack_dbus_get_method_args(call, DBUS_TYPE_UINT32, &buffer_size, DBUS_TYPE_INVALID)) | |||
| { | |||
| /* jack_dbus_get_method_args() has set reply for us */ | |||
| goto exit; | |||
| } | |||
| ret = jack_set_buffer_size(controller_ptr->client, buffer_size); | |||
| if (ret != 0) | |||
| { | |||
| jack_dbus_error( | |||
| call, | |||
| JACK_DBUS_ERROR_GENERIC, | |||
| "jack_set_buffer_size(%u) failed with error %d", (unsigned int)buffer_size, ret); | |||
| goto exit; | |||
| } | |||
| } | |||
| else if (strcmp (call->method_name, "IsRealtime") == 0) | |||
| { | |||
| type = DBUS_TYPE_BOOLEAN; | |||
| arg.boolean = jack_is_realtime(controller_ptr->client) ? TRUE : FALSE; | |||
| } | |||
| else if (strcmp (call->method_name, "ResetXruns") == 0) | |||
| { | |||
| controller_ptr->xruns = 0; | |||
| } | |||
| else | |||
| { | |||
| return false; | |||
| } | |||
| jack_dbus_construct_method_return_single(call, type, arg); | |||
| return true; | |||
| not_started: | |||
| jack_dbus_error (call, JACK_DBUS_ERROR_SERVER_NOT_RUNNING, | |||
| "Can't execute method '%s' with stopped JACK server", call->method_name); | |||
| exit: | |||
| return true; | |||
| } | |||
| #undef controller_ptr | |||
| JACK_DBUS_METHOD_ARGUMENTS_BEGIN(IsStarted) | |||
| JACK_DBUS_METHOD_ARGUMENT("started", "b", true) | |||
| JACK_DBUS_METHOD_ARGUMENTS_END | |||
| JACK_DBUS_METHOD_ARGUMENTS_BEGIN(StartServer) | |||
| JACK_DBUS_METHOD_ARGUMENTS_END | |||
| JACK_DBUS_METHOD_ARGUMENTS_BEGIN(StopServer) | |||
| JACK_DBUS_METHOD_ARGUMENTS_END | |||
| JACK_DBUS_METHOD_ARGUMENTS_BEGIN(GetLoad) | |||
| JACK_DBUS_METHOD_ARGUMENT("load", "d", true) | |||
| JACK_DBUS_METHOD_ARGUMENTS_END | |||
| JACK_DBUS_METHOD_ARGUMENTS_BEGIN(GetXruns) | |||
| JACK_DBUS_METHOD_ARGUMENT("xruns_count", "u", true) | |||
| JACK_DBUS_METHOD_ARGUMENTS_END | |||
| JACK_DBUS_METHOD_ARGUMENTS_BEGIN(GetSampleRate) | |||
| JACK_DBUS_METHOD_ARGUMENT("sample_rate", "u", true) | |||
| JACK_DBUS_METHOD_ARGUMENTS_END | |||
| JACK_DBUS_METHOD_ARGUMENTS_BEGIN(GetLatency) | |||
| JACK_DBUS_METHOD_ARGUMENT("latency_ms", "d", true) | |||
| JACK_DBUS_METHOD_ARGUMENTS_END | |||
| JACK_DBUS_METHOD_ARGUMENTS_BEGIN(GetBufferSize) | |||
| JACK_DBUS_METHOD_ARGUMENT("buffer_size_frames", "u", true) | |||
| JACK_DBUS_METHOD_ARGUMENTS_END | |||
| JACK_DBUS_METHOD_ARGUMENTS_BEGIN(SetBufferSize) | |||
| JACK_DBUS_METHOD_ARGUMENT("buffer_size_frames", "u", false) | |||
| JACK_DBUS_METHOD_ARGUMENTS_END | |||
| JACK_DBUS_METHOD_ARGUMENTS_BEGIN(IsRealtime) | |||
| JACK_DBUS_METHOD_ARGUMENT("realtime", "b", true) | |||
| JACK_DBUS_METHOD_ARGUMENTS_END | |||
| JACK_DBUS_METHOD_ARGUMENTS_BEGIN(ResetXruns) | |||
| JACK_DBUS_METHOD_ARGUMENTS_END | |||
| JACK_DBUS_METHODS_BEGIN | |||
| JACK_DBUS_METHOD_DESCRIBE(IsStarted, NULL) | |||
| JACK_DBUS_METHOD_DESCRIBE(StartServer, NULL) | |||
| JACK_DBUS_METHOD_DESCRIBE(StopServer, NULL) | |||
| JACK_DBUS_METHOD_DESCRIBE(GetLoad, NULL) | |||
| JACK_DBUS_METHOD_DESCRIBE(GetXruns, NULL) | |||
| JACK_DBUS_METHOD_DESCRIBE(GetSampleRate, NULL) | |||
| JACK_DBUS_METHOD_DESCRIBE(GetLatency, NULL) | |||
| JACK_DBUS_METHOD_DESCRIBE(GetBufferSize, NULL) | |||
| JACK_DBUS_METHOD_DESCRIBE(SetBufferSize, NULL) | |||
| JACK_DBUS_METHOD_DESCRIBE(IsRealtime, NULL) | |||
| JACK_DBUS_METHOD_DESCRIBE(ResetXruns, NULL) | |||
| JACK_DBUS_METHODS_END | |||
| JACK_DBUS_IFACE_BEGIN(g_jack_controller_iface_control, "org.jackaudio.JackControl") | |||
| JACK_DBUS_IFACE_HANDLER(jack_control_run_method) | |||
| JACK_DBUS_IFACE_EXPOSE_METHODS | |||
| JACK_DBUS_IFACE_END | |||
| /* -*- Mode: C ; c-basic-offset: 4 -*- */ | |||
| /* | |||
| Copyright (C) 2007,2008 Nedko Arnaudov | |||
| Copyright (C) 2007-2008 Juuso Alasuutari | |||
| This program is free software; you can redistribute it and/or modify | |||
| it under the terms of the GNU General Public License as published by | |||
| the Free Software Foundation; either version 2 of the License. | |||
| 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 General Public License for more details. | |||
| You should have received a copy of the GNU General Public License | |||
| along with this program; if not, write to the Free Software | |||
| Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. | |||
| */ | |||
| #include <stdint.h> | |||
| #include <string.h> | |||
| #include <stdio.h> | |||
| #include <assert.h> | |||
| #include <dbus/dbus.h> | |||
| #include "jackdbus.h" | |||
| #include "controller_internal.h" | |||
| #define controller_ptr ((struct jack_controller *)call->context) | |||
| /* | |||
| * Check if the supplied method name exists in org.jackaudio.JackControl, | |||
| * if it does execute it and return true. Otherwise return false. | |||
| */ | |||
| static | |||
| bool | |||
| jack_control_run_method( | |||
| struct jack_dbus_method_call * call, | |||
| const struct jack_dbus_interface_method_descriptor * methods) | |||
| { | |||
| int ret; | |||
| int type; | |||
| message_arg_t arg; | |||
| /* use empty reply if not overriden in the code that follows */ | |||
| type = DBUS_TYPE_INVALID; | |||
| if (strcmp (call->method_name, "Exit") == 0) | |||
| { | |||
| g_exit_command = TRUE; | |||
| } | |||
| else if (strcmp (call->method_name, "IsStarted") == 0) | |||
| { | |||
| type = DBUS_TYPE_BOOLEAN; | |||
| arg.boolean = (dbus_bool_t) (controller_ptr->started ? TRUE : FALSE); | |||
| } | |||
| else if (strcmp (call->method_name, "StartServer") == 0) | |||
| { | |||
| if (!jack_controller_start_server(controller_ptr, call)) | |||
| { | |||
| jack_error ("Failed to start server"); | |||
| } | |||
| } | |||
| else if (strcmp (call->method_name, "StopServer") == 0) | |||
| { | |||
| if (!jack_controller_stop_server(controller_ptr, call)) | |||
| { | |||
| jack_error ("Failed to stop server"); | |||
| } | |||
| } | |||
| else if (strcmp (call->method_name, "GetLoad") == 0) | |||
| { | |||
| if (!controller_ptr->started) | |||
| { | |||
| goto not_started; | |||
| } | |||
| type = DBUS_TYPE_DOUBLE; | |||
| arg.doubl = jack_cpu_load(controller_ptr->client); | |||
| } | |||
| else if (strcmp (call->method_name, "GetXruns") == 0) | |||
| { | |||
| type = DBUS_TYPE_UINT32; | |||
| arg.uint32 = controller_ptr->xruns; | |||
| } | |||
| else if (strcmp (call->method_name, "GetSampleRate") == 0) | |||
| { | |||
| if (!controller_ptr->started) | |||
| { | |||
| goto not_started; | |||
| } | |||
| type = DBUS_TYPE_UINT32; | |||
| arg.uint32 = jack_get_sample_rate(controller_ptr->client); | |||
| } | |||
| else if (strcmp (call->method_name, "GetLatency") == 0) | |||
| { | |||
| if (!controller_ptr->started) | |||
| { | |||
| goto not_started; | |||
| } | |||
| type = DBUS_TYPE_DOUBLE; | |||
| arg.doubl = ((float)jack_get_buffer_size(controller_ptr->client) / (float)jack_get_sample_rate(controller_ptr->client)) * 1000.0f; | |||
| } | |||
| else if (strcmp (call->method_name, "GetBufferSize") == 0) | |||
| { | |||
| if (!controller_ptr->started) | |||
| { | |||
| goto not_started; | |||
| } | |||
| type = DBUS_TYPE_UINT32; | |||
| arg.uint32 = jack_get_buffer_size(controller_ptr->client); | |||
| } | |||
| else if (strcmp (call->method_name, "SetBufferSize") == 0) | |||
| { | |||
| dbus_uint32_t buffer_size; | |||
| if (!controller_ptr->started) | |||
| { | |||
| goto not_started; | |||
| } | |||
| if (!jack_dbus_get_method_args(call, DBUS_TYPE_UINT32, &buffer_size, DBUS_TYPE_INVALID)) | |||
| { | |||
| /* jack_dbus_get_method_args() has set reply for us */ | |||
| goto exit; | |||
| } | |||
| ret = jack_set_buffer_size(controller_ptr->client, buffer_size); | |||
| if (ret != 0) | |||
| { | |||
| jack_dbus_error( | |||
| call, | |||
| JACK_DBUS_ERROR_GENERIC, | |||
| "jack_set_buffer_size(%u) failed with error %d", (unsigned int)buffer_size, ret); | |||
| goto exit; | |||
| } | |||
| } | |||
| else if (strcmp (call->method_name, "IsRealtime") == 0) | |||
| { | |||
| type = DBUS_TYPE_BOOLEAN; | |||
| arg.boolean = jack_is_realtime(controller_ptr->client) ? TRUE : FALSE; | |||
| } | |||
| else if (strcmp (call->method_name, "ResetXruns") == 0) | |||
| { | |||
| controller_ptr->xruns = 0; | |||
| } | |||
| else | |||
| { | |||
| return false; | |||
| } | |||
| jack_dbus_construct_method_return_single(call, type, arg); | |||
| return true; | |||
| not_started: | |||
| jack_dbus_error (call, JACK_DBUS_ERROR_SERVER_NOT_RUNNING, | |||
| "Can't execute method '%s' with stopped JACK server", call->method_name); | |||
| exit: | |||
| return true; | |||
| } | |||
| #undef controller_ptr | |||
| JACK_DBUS_METHOD_ARGUMENTS_BEGIN(IsStarted) | |||
| JACK_DBUS_METHOD_ARGUMENT("started", "b", true) | |||
| JACK_DBUS_METHOD_ARGUMENTS_END | |||
| JACK_DBUS_METHOD_ARGUMENTS_BEGIN(StartServer) | |||
| JACK_DBUS_METHOD_ARGUMENTS_END | |||
| JACK_DBUS_METHOD_ARGUMENTS_BEGIN(StopServer) | |||
| JACK_DBUS_METHOD_ARGUMENTS_END | |||
| JACK_DBUS_METHOD_ARGUMENTS_BEGIN(GetLoad) | |||
| JACK_DBUS_METHOD_ARGUMENT("load", "d", true) | |||
| JACK_DBUS_METHOD_ARGUMENTS_END | |||
| JACK_DBUS_METHOD_ARGUMENTS_BEGIN(GetXruns) | |||
| JACK_DBUS_METHOD_ARGUMENT("xruns_count", "u", true) | |||
| JACK_DBUS_METHOD_ARGUMENTS_END | |||
| JACK_DBUS_METHOD_ARGUMENTS_BEGIN(GetSampleRate) | |||
| JACK_DBUS_METHOD_ARGUMENT("sample_rate", "u", true) | |||
| JACK_DBUS_METHOD_ARGUMENTS_END | |||
| JACK_DBUS_METHOD_ARGUMENTS_BEGIN(GetLatency) | |||
| JACK_DBUS_METHOD_ARGUMENT("latency_ms", "d", true) | |||
| JACK_DBUS_METHOD_ARGUMENTS_END | |||
| JACK_DBUS_METHOD_ARGUMENTS_BEGIN(GetBufferSize) | |||
| JACK_DBUS_METHOD_ARGUMENT("buffer_size_frames", "u", true) | |||
| JACK_DBUS_METHOD_ARGUMENTS_END | |||
| JACK_DBUS_METHOD_ARGUMENTS_BEGIN(SetBufferSize) | |||
| JACK_DBUS_METHOD_ARGUMENT("buffer_size_frames", "u", false) | |||
| JACK_DBUS_METHOD_ARGUMENTS_END | |||
| JACK_DBUS_METHOD_ARGUMENTS_BEGIN(IsRealtime) | |||
| JACK_DBUS_METHOD_ARGUMENT("realtime", "b", true) | |||
| JACK_DBUS_METHOD_ARGUMENTS_END | |||
| JACK_DBUS_METHOD_ARGUMENTS_BEGIN(ResetXruns) | |||
| JACK_DBUS_METHOD_ARGUMENTS_END | |||
| JACK_DBUS_METHODS_BEGIN | |||
| JACK_DBUS_METHOD_DESCRIBE(IsStarted, NULL) | |||
| JACK_DBUS_METHOD_DESCRIBE(StartServer, NULL) | |||
| JACK_DBUS_METHOD_DESCRIBE(StopServer, NULL) | |||
| JACK_DBUS_METHOD_DESCRIBE(GetLoad, NULL) | |||
| JACK_DBUS_METHOD_DESCRIBE(GetXruns, NULL) | |||
| JACK_DBUS_METHOD_DESCRIBE(GetSampleRate, NULL) | |||
| JACK_DBUS_METHOD_DESCRIBE(GetLatency, NULL) | |||
| JACK_DBUS_METHOD_DESCRIBE(GetBufferSize, NULL) | |||
| JACK_DBUS_METHOD_DESCRIBE(SetBufferSize, NULL) | |||
| JACK_DBUS_METHOD_DESCRIBE(IsRealtime, NULL) | |||
| JACK_DBUS_METHOD_DESCRIBE(ResetXruns, NULL) | |||
| JACK_DBUS_METHODS_END | |||
| JACK_DBUS_IFACE_BEGIN(g_jack_controller_iface_control, "org.jackaudio.JackControl") | |||
| JACK_DBUS_IFACE_HANDLER(jack_control_run_method) | |||
| JACK_DBUS_IFACE_EXPOSE_METHODS | |||
| JACK_DBUS_IFACE_END | |||
| /* -*- Mode: C ; c-basic-offset: 4 -*- */ | |||
| /* | |||
| Copyright (C) 2007,2008 Nedko Arnaudov | |||
| Copyright (C) 2007-2008 Juuso Alasuutari | |||
| This program is free software; you can redistribute it and/or modify | |||
| it under the terms of the GNU General Public License as published by | |||
| the Free Software Foundation; either version 2 of the License. | |||
| 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 General Public License for more details. | |||
| You should have received a copy of the GNU General Public License | |||
| along with this program; if not, write to the Free Software | |||
| Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. | |||
| */ | |||
| #include <stdint.h> | |||
| #include <string.h> | |||
| #include <stdio.h> | |||
| #include <assert.h> | |||
| #include <dbus/dbus.h> | |||
| #include "jackdbus.h" | |||
| #include "controller_internal.h" | |||
| #define controller_ptr ((struct jack_controller *)call->context) | |||
| /* | |||
| * Check if the supplied method name exists in org.jackaudio.JackControl, | |||
| * if it does execute it and return true. Otherwise return false. | |||
| */ | |||
| static | |||
| bool | |||
| jack_control_run_method( | |||
| struct jack_dbus_method_call * call, | |||
| const struct jack_dbus_interface_method_descriptor * methods) | |||
| { | |||
| int ret; | |||
| int type; | |||
| message_arg_t arg; | |||
| /* use empty reply if not overriden in the code that follows */ | |||
| type = DBUS_TYPE_INVALID; | |||
| if (strcmp (call->method_name, "Exit") == 0) | |||
| { | |||
| g_exit_command = TRUE; | |||
| } | |||
| else if (strcmp (call->method_name, "IsStarted") == 0) | |||
| { | |||
| type = DBUS_TYPE_BOOLEAN; | |||
| arg.boolean = (dbus_bool_t) (controller_ptr->started ? TRUE : FALSE); | |||
| } | |||
| else if (strcmp (call->method_name, "StartServer") == 0) | |||
| { | |||
| if (!jack_controller_start_server(controller_ptr, call)) | |||
| { | |||
| jack_error ("Failed to start server"); | |||
| } | |||
| } | |||
| else if (strcmp (call->method_name, "StopServer") == 0) | |||
| { | |||
| if (!jack_controller_stop_server(controller_ptr, call)) | |||
| { | |||
| jack_error ("Failed to stop server"); | |||
| } | |||
| } | |||
| else if (strcmp (call->method_name, "GetLoad") == 0) | |||
| { | |||
| if (!controller_ptr->started) | |||
| { | |||
| goto not_started; | |||
| } | |||
| type = DBUS_TYPE_DOUBLE; | |||
| arg.doubl = jack_cpu_load(controller_ptr->client); | |||
| } | |||
| else if (strcmp (call->method_name, "GetXruns") == 0) | |||
| { | |||
| type = DBUS_TYPE_UINT32; | |||
| arg.uint32 = controller_ptr->xruns; | |||
| } | |||
| else if (strcmp (call->method_name, "GetSampleRate") == 0) | |||
| { | |||
| if (!controller_ptr->started) | |||
| { | |||
| goto not_started; | |||
| } | |||
| type = DBUS_TYPE_UINT32; | |||
| arg.uint32 = jack_get_sample_rate(controller_ptr->client); | |||
| } | |||
| else if (strcmp (call->method_name, "GetLatency") == 0) | |||
| { | |||
| if (!controller_ptr->started) | |||
| { | |||
| goto not_started; | |||
| } | |||
| type = DBUS_TYPE_DOUBLE; | |||
| arg.doubl = ((float)jack_get_buffer_size(controller_ptr->client) / (float)jack_get_sample_rate(controller_ptr->client)) * 1000.0f; | |||
| } | |||
| else if (strcmp (call->method_name, "GetBufferSize") == 0) | |||
| { | |||
| if (!controller_ptr->started) | |||
| { | |||
| goto not_started; | |||
| } | |||
| type = DBUS_TYPE_UINT32; | |||
| arg.uint32 = jack_get_buffer_size(controller_ptr->client); | |||
| } | |||
| else if (strcmp (call->method_name, "SetBufferSize") == 0) | |||
| { | |||
| dbus_uint32_t buffer_size; | |||
| if (!controller_ptr->started) | |||
| { | |||
| goto not_started; | |||
| } | |||
| if (!jack_dbus_get_method_args(call, DBUS_TYPE_UINT32, &buffer_size, DBUS_TYPE_INVALID)) | |||
| { | |||
| /* jack_dbus_get_method_args() has set reply for us */ | |||
| goto exit; | |||
| } | |||
| ret = jack_set_buffer_size(controller_ptr->client, buffer_size); | |||
| if (ret != 0) | |||
| { | |||
| jack_dbus_error( | |||
| call, | |||
| JACK_DBUS_ERROR_GENERIC, | |||
| "jack_set_buffer_size(%u) failed with error %d", (unsigned int)buffer_size, ret); | |||
| goto exit; | |||
| } | |||
| } | |||
| else if (strcmp (call->method_name, "IsRealtime") == 0) | |||
| { | |||
| type = DBUS_TYPE_BOOLEAN; | |||
| arg.boolean = jack_is_realtime(controller_ptr->client) ? TRUE : FALSE; | |||
| } | |||
| else if (strcmp (call->method_name, "ResetXruns") == 0) | |||
| { | |||
| controller_ptr->xruns = 0; | |||
| } | |||
| else | |||
| { | |||
| return false; | |||
| } | |||
| jack_dbus_construct_method_return_single(call, type, arg); | |||
| return true; | |||
| not_started: | |||
| jack_dbus_error (call, JACK_DBUS_ERROR_SERVER_NOT_RUNNING, | |||
| "Can't execute method '%s' with stopped JACK server", call->method_name); | |||
| exit: | |||
| return true; | |||
| } | |||
| #undef controller_ptr | |||
| JACK_DBUS_METHOD_ARGUMENTS_BEGIN(IsStarted) | |||
| JACK_DBUS_METHOD_ARGUMENT("started", "b", true) | |||
| JACK_DBUS_METHOD_ARGUMENTS_END | |||
| JACK_DBUS_METHOD_ARGUMENTS_BEGIN(StartServer) | |||
| JACK_DBUS_METHOD_ARGUMENTS_END | |||
| JACK_DBUS_METHOD_ARGUMENTS_BEGIN(StopServer) | |||
| JACK_DBUS_METHOD_ARGUMENTS_END | |||
| JACK_DBUS_METHOD_ARGUMENTS_BEGIN(GetLoad) | |||
| JACK_DBUS_METHOD_ARGUMENT("load", "d", true) | |||
| JACK_DBUS_METHOD_ARGUMENTS_END | |||
| JACK_DBUS_METHOD_ARGUMENTS_BEGIN(GetXruns) | |||
| JACK_DBUS_METHOD_ARGUMENT("xruns_count", "u", true) | |||
| JACK_DBUS_METHOD_ARGUMENTS_END | |||
| JACK_DBUS_METHOD_ARGUMENTS_BEGIN(GetSampleRate) | |||
| JACK_DBUS_METHOD_ARGUMENT("sample_rate", "u", true) | |||
| JACK_DBUS_METHOD_ARGUMENTS_END | |||
| JACK_DBUS_METHOD_ARGUMENTS_BEGIN(GetLatency) | |||
| JACK_DBUS_METHOD_ARGUMENT("latency_ms", "d", true) | |||
| JACK_DBUS_METHOD_ARGUMENTS_END | |||
| JACK_DBUS_METHOD_ARGUMENTS_BEGIN(GetBufferSize) | |||
| JACK_DBUS_METHOD_ARGUMENT("buffer_size_frames", "u", true) | |||
| JACK_DBUS_METHOD_ARGUMENTS_END | |||
| JACK_DBUS_METHOD_ARGUMENTS_BEGIN(SetBufferSize) | |||
| JACK_DBUS_METHOD_ARGUMENT("buffer_size_frames", "u", false) | |||
| JACK_DBUS_METHOD_ARGUMENTS_END | |||
| JACK_DBUS_METHOD_ARGUMENTS_BEGIN(IsRealtime) | |||
| JACK_DBUS_METHOD_ARGUMENT("realtime", "b", true) | |||
| JACK_DBUS_METHOD_ARGUMENTS_END | |||
| JACK_DBUS_METHOD_ARGUMENTS_BEGIN(ResetXruns) | |||
| JACK_DBUS_METHOD_ARGUMENTS_END | |||
| JACK_DBUS_METHODS_BEGIN | |||
| JACK_DBUS_METHOD_DESCRIBE(IsStarted, NULL) | |||
| JACK_DBUS_METHOD_DESCRIBE(StartServer, NULL) | |||
| JACK_DBUS_METHOD_DESCRIBE(StopServer, NULL) | |||
| JACK_DBUS_METHOD_DESCRIBE(GetLoad, NULL) | |||
| JACK_DBUS_METHOD_DESCRIBE(GetXruns, NULL) | |||
| JACK_DBUS_METHOD_DESCRIBE(GetSampleRate, NULL) | |||
| JACK_DBUS_METHOD_DESCRIBE(GetLatency, NULL) | |||
| JACK_DBUS_METHOD_DESCRIBE(GetBufferSize, NULL) | |||
| JACK_DBUS_METHOD_DESCRIBE(SetBufferSize, NULL) | |||
| JACK_DBUS_METHOD_DESCRIBE(IsRealtime, NULL) | |||
| JACK_DBUS_METHOD_DESCRIBE(ResetXruns, NULL) | |||
| JACK_DBUS_METHODS_END | |||
| JACK_DBUS_IFACE_BEGIN(g_jack_controller_iface_control, "org.jackaudio.JackControl") | |||
| JACK_DBUS_IFACE_HANDLER(jack_control_run_method) | |||
| JACK_DBUS_IFACE_EXPOSE_METHODS | |||
| JACK_DBUS_IFACE_END | |||
| @@ -0,0 +1,608 @@ | |||
| /* -*- Mode: C ; c-basic-offset: 4 -*- */ | |||
| /* | |||
| Copyright (C) 2007-2008 Nedko Arnaudov | |||
| Copyright (C) 2007-2008 Juuso Alasuutari | |||
| This program is free software; you can redistribute it and/or modify | |||
| it under the terms of the GNU General Public License as published by | |||
| the Free Software Foundation; either version 2 of the License. | |||
| 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 General Public License for more details. | |||
| You should have received a copy of the GNU General Public License | |||
| along with this program; if not, write to the Free Software | |||
| Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. | |||
| */ | |||
| #include <stdint.h> | |||
| #include <string.h> | |||
| #include <stdio.h> | |||
| #include <assert.h> | |||
| #include <dbus/dbus.h> | |||
| #include "jackdbus.h" | |||
| static char g_xml_data[102400]; | |||
| static | |||
| void | |||
| jack_controller_dbus_introspect( | |||
| struct jack_dbus_method_call * call) | |||
| { | |||
| jack_dbus_construct_method_return_single( | |||
| call, | |||
| DBUS_TYPE_STRING, | |||
| (message_arg_t)(const char *)g_xml_data); | |||
| } | |||
| JACK_DBUS_METHOD_ARGUMENTS_BEGIN(Introspect) | |||
| JACK_DBUS_METHOD_ARGUMENT("xml_data", "s", true) | |||
| JACK_DBUS_METHOD_ARGUMENTS_END | |||
| JACK_DBUS_METHODS_BEGIN | |||
| JACK_DBUS_METHOD_DESCRIBE(Introspect, jack_controller_dbus_introspect) | |||
| JACK_DBUS_METHODS_END | |||
| JACK_DBUS_IFACE_BEGIN(g_jack_controller_iface_introspectable, "org.freedesktop.DBus.Introspectable") | |||
| JACK_DBUS_IFACE_EXPOSE_METHODS | |||
| JACK_DBUS_IFACE_END | |||
| static char * g_buffer_ptr; | |||
| static | |||
| void | |||
| write_line_format(const char * format, ...) | |||
| { | |||
| va_list ap; | |||
| va_start(ap, format); | |||
| g_buffer_ptr += vsprintf(g_buffer_ptr, format, ap); | |||
| va_end(ap); | |||
| } | |||
| static | |||
| void | |||
| write_line(const char * line) | |||
| { | |||
| write_line_format("%s\n", line); | |||
| } | |||
| void jack_controller_introspect_init() __attribute__((constructor)); | |||
| void | |||
| jack_controller_introspect_init() | |||
| { | |||
| struct jack_dbus_interface_descriptor ** interface_ptr_ptr; | |||
| const struct jack_dbus_interface_method_descriptor * method_ptr; | |||
| const struct jack_dbus_interface_method_argument_descriptor * method_argument_ptr; | |||
| const struct jack_dbus_interface_signal_descriptor * signal_ptr; | |||
| const struct jack_dbus_interface_signal_argument_descriptor * signal_argument_ptr; | |||
| g_buffer_ptr = g_xml_data; | |||
| write_line("<!DOCTYPE node PUBLIC \"-//freedesktop//DTD D-BUS Object Introspection 1.0//EN\""); | |||
| write_line("\"http://www.freedesktop.org/standards/dbus/1.0/introspect.dtd\">"); | |||
| write_line("<node name=\"" JACK_CONTROLLER_OBJECT_PATH "\">"); | |||
| interface_ptr_ptr = g_jackcontroller_interfaces; | |||
| while (*interface_ptr_ptr != NULL) | |||
| { | |||
| write_line_format(" <interface name=\"%s\">\n", (*interface_ptr_ptr)->name); | |||
| if ((*interface_ptr_ptr)->methods != NULL) | |||
| { | |||
| method_ptr = (*interface_ptr_ptr)->methods; | |||
| while (method_ptr->name != NULL) | |||
| { | |||
| write_line_format(" <method name=\"%s\">\n", method_ptr->name); | |||
| method_argument_ptr = method_ptr->arguments; | |||
| while (method_argument_ptr->name != NULL) | |||
| { | |||
| write_line_format( | |||
| " <arg name=\"%s\" type=\"%s\" direction=\"%s\" />\n", | |||
| method_argument_ptr->name, | |||
| method_argument_ptr->type, | |||
| method_argument_ptr->direction_out ? "out" : "in"); | |||
| method_argument_ptr++; | |||
| } | |||
| write_line(" </method>"); | |||
| method_ptr++; | |||
| } | |||
| } | |||
| if ((*interface_ptr_ptr)->signals != NULL) | |||
| { | |||
| signal_ptr = (*interface_ptr_ptr)->signals; | |||
| while (signal_ptr->name != NULL) | |||
| { | |||
| write_line_format(" <signal name=\"%s\">\n", signal_ptr->name); | |||
| signal_argument_ptr = signal_ptr->arguments; | |||
| while (signal_argument_ptr->name != NULL) | |||
| { | |||
| write_line_format( | |||
| " <arg name=\"%s\" type=\"%s\" />\n", | |||
| signal_argument_ptr->name, | |||
| signal_argument_ptr->type); | |||
| signal_argument_ptr++; | |||
| } | |||
| write_line(" </signal>"); | |||
| signal_ptr++; | |||
| } | |||
| } | |||
| write_line(" </interface>"); | |||
| interface_ptr_ptr++; | |||
| } | |||
| write_line("</node>"); | |||
| *g_buffer_ptr = 0; | |||
| } | |||
| /* -*- Mode: C ; c-basic-offset: 4 -*- */ | |||
| /* | |||
| Copyright (C) 2007-2008 Nedko Arnaudov | |||
| Copyright (C) 2007-2008 Juuso Alasuutari | |||
| This program is free software; you can redistribute it and/or modify | |||
| it under the terms of the GNU General Public License as published by | |||
| the Free Software Foundation; either version 2 of the License. | |||
| 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 General Public License for more details. | |||
| You should have received a copy of the GNU General Public License | |||
| along with this program; if not, write to the Free Software | |||
| Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. | |||
| */ | |||
| #include <stdint.h> | |||
| #include <string.h> | |||
| #include <stdio.h> | |||
| #include <assert.h> | |||
| #include <dbus/dbus.h> | |||
| #include "jackdbus.h" | |||
| static char g_xml_data[102400]; | |||
| static | |||
| void | |||
| jack_controller_dbus_introspect( | |||
| struct jack_dbus_method_call * call) | |||
| { | |||
| jack_dbus_construct_method_return_single( | |||
| call, | |||
| DBUS_TYPE_STRING, | |||
| (message_arg_t)(const char *)g_xml_data); | |||
| } | |||
| JACK_DBUS_METHOD_ARGUMENTS_BEGIN(Introspect) | |||
| JACK_DBUS_METHOD_ARGUMENT("xml_data", "s", true) | |||
| JACK_DBUS_METHOD_ARGUMENTS_END | |||
| JACK_DBUS_METHODS_BEGIN | |||
| JACK_DBUS_METHOD_DESCRIBE(Introspect, jack_controller_dbus_introspect) | |||
| JACK_DBUS_METHODS_END | |||
| JACK_DBUS_IFACE_BEGIN(g_jack_controller_iface_introspectable, "org.freedesktop.DBus.Introspectable") | |||
| JACK_DBUS_IFACE_EXPOSE_METHODS | |||
| JACK_DBUS_IFACE_END | |||
| static char * g_buffer_ptr; | |||
| static | |||
| void | |||
| write_line_format(const char * format, ...) | |||
| { | |||
| va_list ap; | |||
| va_start(ap, format); | |||
| g_buffer_ptr += vsprintf(g_buffer_ptr, format, ap); | |||
| va_end(ap); | |||
| } | |||
| static | |||
| void | |||
| write_line(const char * line) | |||
| { | |||
| write_line_format("%s\n", line); | |||
| } | |||
| void jack_controller_introspect_init() __attribute__((constructor)); | |||
| void | |||
| jack_controller_introspect_init() | |||
| { | |||
| struct jack_dbus_interface_descriptor ** interface_ptr_ptr; | |||
| const struct jack_dbus_interface_method_descriptor * method_ptr; | |||
| const struct jack_dbus_interface_method_argument_descriptor * method_argument_ptr; | |||
| const struct jack_dbus_interface_signal_descriptor * signal_ptr; | |||
| const struct jack_dbus_interface_signal_argument_descriptor * signal_argument_ptr; | |||
| g_buffer_ptr = g_xml_data; | |||
| write_line("<!DOCTYPE node PUBLIC \"-//freedesktop//DTD D-BUS Object Introspection 1.0//EN\""); | |||
| write_line("\"http://www.freedesktop.org/standards/dbus/1.0/introspect.dtd\">"); | |||
| write_line("<node name=\"" JACK_CONTROLLER_OBJECT_PATH "\">"); | |||
| interface_ptr_ptr = g_jackcontroller_interfaces; | |||
| while (*interface_ptr_ptr != NULL) | |||
| { | |||
| write_line_format(" <interface name=\"%s\">\n", (*interface_ptr_ptr)->name); | |||
| if ((*interface_ptr_ptr)->methods != NULL) | |||
| { | |||
| method_ptr = (*interface_ptr_ptr)->methods; | |||
| while (method_ptr->name != NULL) | |||
| { | |||
| write_line_format(" <method name=\"%s\">\n", method_ptr->name); | |||
| method_argument_ptr = method_ptr->arguments; | |||
| while (method_argument_ptr->name != NULL) | |||
| { | |||
| write_line_format( | |||
| " <arg name=\"%s\" type=\"%s\" direction=\"%s\" />\n", | |||
| method_argument_ptr->name, | |||
| method_argument_ptr->type, | |||
| method_argument_ptr->direction_out ? "out" : "in"); | |||
| method_argument_ptr++; | |||
| } | |||
| write_line(" </method>"); | |||
| method_ptr++; | |||
| } | |||
| } | |||
| if ((*interface_ptr_ptr)->signals != NULL) | |||
| { | |||
| signal_ptr = (*interface_ptr_ptr)->signals; | |||
| while (signal_ptr->name != NULL) | |||
| { | |||
| write_line_format(" <signal name=\"%s\">\n", signal_ptr->name); | |||
| signal_argument_ptr = signal_ptr->arguments; | |||
| while (signal_argument_ptr->name != NULL) | |||
| { | |||
| write_line_format( | |||
| " <arg name=\"%s\" type=\"%s\" />\n", | |||
| signal_argument_ptr->name, | |||
| signal_argument_ptr->type); | |||
| signal_argument_ptr++; | |||
| } | |||
| write_line(" </signal>"); | |||
| signal_ptr++; | |||
| } | |||
| } | |||
| write_line(" </interface>"); | |||
| interface_ptr_ptr++; | |||
| } | |||
| write_line("</node>"); | |||
| *g_buffer_ptr = 0; | |||
| } | |||
| /* -*- Mode: C ; c-basic-offset: 4 -*- */ | |||
| /* | |||
| Copyright (C) 2007-2008 Nedko Arnaudov | |||
| Copyright (C) 2007-2008 Juuso Alasuutari | |||
| This program is free software; you can redistribute it and/or modify | |||
| it under the terms of the GNU General Public License as published by | |||
| the Free Software Foundation; either version 2 of the License. | |||
| 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 General Public License for more details. | |||
| You should have received a copy of the GNU General Public License | |||
| along with this program; if not, write to the Free Software | |||
| Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. | |||
| */ | |||
| #include <stdint.h> | |||
| #include <string.h> | |||
| #include <stdio.h> | |||
| #include <assert.h> | |||
| #include <dbus/dbus.h> | |||
| #include "jackdbus.h" | |||
| static char g_xml_data[102400]; | |||
| static | |||
| void | |||
| jack_controller_dbus_introspect( | |||
| struct jack_dbus_method_call * call) | |||
| { | |||
| jack_dbus_construct_method_return_single( | |||
| call, | |||
| DBUS_TYPE_STRING, | |||
| (message_arg_t)(const char *)g_xml_data); | |||
| } | |||
| JACK_DBUS_METHOD_ARGUMENTS_BEGIN(Introspect) | |||
| JACK_DBUS_METHOD_ARGUMENT("xml_data", "s", true) | |||
| JACK_DBUS_METHOD_ARGUMENTS_END | |||
| JACK_DBUS_METHODS_BEGIN | |||
| JACK_DBUS_METHOD_DESCRIBE(Introspect, jack_controller_dbus_introspect) | |||
| JACK_DBUS_METHODS_END | |||
| JACK_DBUS_IFACE_BEGIN(g_jack_controller_iface_introspectable, "org.freedesktop.DBus.Introspectable") | |||
| JACK_DBUS_IFACE_EXPOSE_METHODS | |||
| JACK_DBUS_IFACE_END | |||
| static char * g_buffer_ptr; | |||
| static | |||
| void | |||
| write_line_format(const char * format, ...) | |||
| { | |||
| va_list ap; | |||
| va_start(ap, format); | |||
| g_buffer_ptr += vsprintf(g_buffer_ptr, format, ap); | |||
| va_end(ap); | |||
| } | |||
| static | |||
| void | |||
| write_line(const char * line) | |||
| { | |||
| write_line_format("%s\n", line); | |||
| } | |||
| void jack_controller_introspect_init() __attribute__((constructor)); | |||
| void | |||
| jack_controller_introspect_init() | |||
| { | |||
| struct jack_dbus_interface_descriptor ** interface_ptr_ptr; | |||
| const struct jack_dbus_interface_method_descriptor * method_ptr; | |||
| const struct jack_dbus_interface_method_argument_descriptor * method_argument_ptr; | |||
| const struct jack_dbus_interface_signal_descriptor * signal_ptr; | |||
| const struct jack_dbus_interface_signal_argument_descriptor * signal_argument_ptr; | |||
| g_buffer_ptr = g_xml_data; | |||
| write_line("<!DOCTYPE node PUBLIC \"-//freedesktop//DTD D-BUS Object Introspection 1.0//EN\""); | |||
| write_line("\"http://www.freedesktop.org/standards/dbus/1.0/introspect.dtd\">"); | |||
| write_line("<node name=\"" JACK_CONTROLLER_OBJECT_PATH "\">"); | |||
| interface_ptr_ptr = g_jackcontroller_interfaces; | |||
| while (*interface_ptr_ptr != NULL) | |||
| { | |||
| write_line_format(" <interface name=\"%s\">\n", (*interface_ptr_ptr)->name); | |||
| if ((*interface_ptr_ptr)->methods != NULL) | |||
| { | |||
| method_ptr = (*interface_ptr_ptr)->methods; | |||
| while (method_ptr->name != NULL) | |||
| { | |||
| write_line_format(" <method name=\"%s\">\n", method_ptr->name); | |||
| method_argument_ptr = method_ptr->arguments; | |||
| while (method_argument_ptr->name != NULL) | |||
| { | |||
| write_line_format( | |||
| " <arg name=\"%s\" type=\"%s\" direction=\"%s\" />\n", | |||
| method_argument_ptr->name, | |||
| method_argument_ptr->type, | |||
| method_argument_ptr->direction_out ? "out" : "in"); | |||
| method_argument_ptr++; | |||
| } | |||
| write_line(" </method>"); | |||
| method_ptr++; | |||
| } | |||
| } | |||
| if ((*interface_ptr_ptr)->signals != NULL) | |||
| { | |||
| signal_ptr = (*interface_ptr_ptr)->signals; | |||
| while (signal_ptr->name != NULL) | |||
| { | |||
| write_line_format(" <signal name=\"%s\">\n", signal_ptr->name); | |||
| signal_argument_ptr = signal_ptr->arguments; | |||
| while (signal_argument_ptr->name != NULL) | |||
| { | |||
| write_line_format( | |||
| " <arg name=\"%s\" type=\"%s\" />\n", | |||
| signal_argument_ptr->name, | |||
| signal_argument_ptr->type); | |||
| signal_argument_ptr++; | |||
| } | |||
| write_line(" </signal>"); | |||
| signal_ptr++; | |||
| } | |||
| } | |||
| write_line(" </interface>"); | |||
| interface_ptr_ptr++; | |||
| } | |||
| write_line("</node>"); | |||
| *g_buffer_ptr = 0; | |||
| } | |||
| /* -*- Mode: C ; c-basic-offset: 4 -*- */ | |||
| /* | |||
| Copyright (C) 2007-2008 Nedko Arnaudov | |||
| Copyright (C) 2007-2008 Juuso Alasuutari | |||
| This program is free software; you can redistribute it and/or modify | |||
| it under the terms of the GNU General Public License as published by | |||
| the Free Software Foundation; either version 2 of the License. | |||
| 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 General Public License for more details. | |||
| You should have received a copy of the GNU General Public License | |||
| along with this program; if not, write to the Free Software | |||
| Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. | |||
| */ | |||
| #include <stdint.h> | |||
| #include <string.h> | |||
| #include <stdio.h> | |||
| #include <assert.h> | |||
| #include <dbus/dbus.h> | |||
| #include "jackdbus.h" | |||
| static char g_xml_data[102400]; | |||
| static | |||
| void | |||
| jack_controller_dbus_introspect( | |||
| struct jack_dbus_method_call * call) | |||
| { | |||
| jack_dbus_construct_method_return_single( | |||
| call, | |||
| DBUS_TYPE_STRING, | |||
| (message_arg_t)(const char *)g_xml_data); | |||
| } | |||
| JACK_DBUS_METHOD_ARGUMENTS_BEGIN(Introspect) | |||
| JACK_DBUS_METHOD_ARGUMENT("xml_data", "s", true) | |||
| JACK_DBUS_METHOD_ARGUMENTS_END | |||
| JACK_DBUS_METHODS_BEGIN | |||
| JACK_DBUS_METHOD_DESCRIBE(Introspect, jack_controller_dbus_introspect) | |||
| JACK_DBUS_METHODS_END | |||
| JACK_DBUS_IFACE_BEGIN(g_jack_controller_iface_introspectable, "org.freedesktop.DBus.Introspectable") | |||
| JACK_DBUS_IFACE_EXPOSE_METHODS | |||
| JACK_DBUS_IFACE_END | |||
| static char * g_buffer_ptr; | |||
| static | |||
| void | |||
| write_line_format(const char * format, ...) | |||
| { | |||
| va_list ap; | |||
| va_start(ap, format); | |||
| g_buffer_ptr += vsprintf(g_buffer_ptr, format, ap); | |||
| va_end(ap); | |||
| } | |||
| static | |||
| void | |||
| write_line(const char * line) | |||
| { | |||
| write_line_format("%s\n", line); | |||
| } | |||
| void jack_controller_introspect_init() __attribute__((constructor)); | |||
| void | |||
| jack_controller_introspect_init() | |||
| { | |||
| struct jack_dbus_interface_descriptor ** interface_ptr_ptr; | |||
| const struct jack_dbus_interface_method_descriptor * method_ptr; | |||
| const struct jack_dbus_interface_method_argument_descriptor * method_argument_ptr; | |||
| const struct jack_dbus_interface_signal_descriptor * signal_ptr; | |||
| const struct jack_dbus_interface_signal_argument_descriptor * signal_argument_ptr; | |||
| g_buffer_ptr = g_xml_data; | |||
| write_line("<!DOCTYPE node PUBLIC \"-//freedesktop//DTD D-BUS Object Introspection 1.0//EN\""); | |||
| write_line("\"http://www.freedesktop.org/standards/dbus/1.0/introspect.dtd\">"); | |||
| write_line("<node name=\"" JACK_CONTROLLER_OBJECT_PATH "\">"); | |||
| interface_ptr_ptr = g_jackcontroller_interfaces; | |||
| while (*interface_ptr_ptr != NULL) | |||
| { | |||
| write_line_format(" <interface name=\"%s\">\n", (*interface_ptr_ptr)->name); | |||
| if ((*interface_ptr_ptr)->methods != NULL) | |||
| { | |||
| method_ptr = (*interface_ptr_ptr)->methods; | |||
| while (method_ptr->name != NULL) | |||
| { | |||
| write_line_format(" <method name=\"%s\">\n", method_ptr->name); | |||
| method_argument_ptr = method_ptr->arguments; | |||
| while (method_argument_ptr->name != NULL) | |||
| { | |||
| write_line_format( | |||
| " <arg name=\"%s\" type=\"%s\" direction=\"%s\" />\n", | |||
| method_argument_ptr->name, | |||
| method_argument_ptr->type, | |||
| method_argument_ptr->direction_out ? "out" : "in"); | |||
| method_argument_ptr++; | |||
| } | |||
| write_line(" </method>"); | |||
| method_ptr++; | |||
| } | |||
| } | |||
| if ((*interface_ptr_ptr)->signals != NULL) | |||
| { | |||
| signal_ptr = (*interface_ptr_ptr)->signals; | |||
| while (signal_ptr->name != NULL) | |||
| { | |||
| write_line_format(" <signal name=\"%s\">\n", signal_ptr->name); | |||
| signal_argument_ptr = signal_ptr->arguments; | |||
| while (signal_argument_ptr->name != NULL) | |||
| { | |||
| write_line_format( | |||
| " <arg name=\"%s\" type=\"%s\" />\n", | |||
| signal_argument_ptr->name, | |||
| signal_argument_ptr->type); | |||
| signal_argument_ptr++; | |||
| } | |||
| write_line(" </signal>"); | |||
| signal_ptr++; | |||
| } | |||
| } | |||
| write_line(" </interface>"); | |||
| interface_ptr_ptr++; | |||
| } | |||
| write_line("</node>"); | |||
| *g_buffer_ptr = 0; | |||
| } | |||
| @@ -0,0 +1,136 @@ | |||
| /* -*- Mode: C ; c-basic-offset: 4 -*- */ | |||
| /* | |||
| Copyright (C) 2008 Nedko Arnaudov | |||
| Copyright (C) 2008 Juuso Alasuutari | |||
| This program is free software; you can redistribute it and/or modify | |||
| it under the terms of the GNU General Public License as published by | |||
| the Free Software Foundation; either version 2 of the License. | |||
| 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 General Public License for more details. | |||
| You should have received a copy of the GNU General Public License | |||
| along with this program; if not, write to the Free Software | |||
| Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. | |||
| */ | |||
| #include <stdint.h> | |||
| #include <string.h> | |||
| #include <stdio.h> | |||
| #include <assert.h> | |||
| #include <dbus/dbus.h> | |||
| #include "jackdbus.h" | |||
| JACK_DBUS_METHODS_BEGIN | |||
| JACK_DBUS_METHODS_END | |||
| JACK_DBUS_IFACE_BEGIN(g_jack_controller_iface_transport, "org.jackaudio.JackTransport") | |||
| JACK_DBUS_IFACE_EXPOSE_METHODS | |||
| JACK_DBUS_IFACE_END | |||
| /* -*- Mode: C ; c-basic-offset: 4 -*- */ | |||
| /* | |||
| Copyright (C) 2008 Nedko Arnaudov | |||
| Copyright (C) 2008 Juuso Alasuutari | |||
| This program is free software; you can redistribute it and/or modify | |||
| it under the terms of the GNU General Public License as published by | |||
| the Free Software Foundation; either version 2 of the License. | |||
| 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 General Public License for more details. | |||
| You should have received a copy of the GNU General Public License | |||
| along with this program; if not, write to the Free Software | |||
| Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. | |||
| */ | |||
| #include <stdint.h> | |||
| #include <string.h> | |||
| #include <stdio.h> | |||
| #include <assert.h> | |||
| #include <dbus/dbus.h> | |||
| #include "jackdbus.h" | |||
| JACK_DBUS_METHODS_BEGIN | |||
| JACK_DBUS_METHODS_END | |||
| JACK_DBUS_IFACE_BEGIN(g_jack_controller_iface_transport, "org.jackaudio.JackTransport") | |||
| JACK_DBUS_IFACE_EXPOSE_METHODS | |||
| JACK_DBUS_IFACE_END | |||
| /* -*- Mode: C ; c-basic-offset: 4 -*- */ | |||
| /* | |||
| Copyright (C) 2008 Nedko Arnaudov | |||
| Copyright (C) 2008 Juuso Alasuutari | |||
| This program is free software; you can redistribute it and/or modify | |||
| it under the terms of the GNU General Public License as published by | |||
| the Free Software Foundation; either version 2 of the License. | |||
| 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 General Public License for more details. | |||
| You should have received a copy of the GNU General Public License | |||
| along with this program; if not, write to the Free Software | |||
| Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. | |||
| */ | |||
| #include <stdint.h> | |||
| #include <string.h> | |||
| #include <stdio.h> | |||
| #include <assert.h> | |||
| #include <dbus/dbus.h> | |||
| #include "jackdbus.h" | |||
| JACK_DBUS_METHODS_BEGIN | |||
| JACK_DBUS_METHODS_END | |||
| JACK_DBUS_IFACE_BEGIN(g_jack_controller_iface_transport, "org.jackaudio.JackTransport") | |||
| JACK_DBUS_IFACE_EXPOSE_METHODS | |||
| JACK_DBUS_IFACE_END | |||
| /* -*- Mode: C ; c-basic-offset: 4 -*- */ | |||
| /* | |||
| Copyright (C) 2008 Nedko Arnaudov | |||
| Copyright (C) 2008 Juuso Alasuutari | |||
| This program is free software; you can redistribute it and/or modify | |||
| it under the terms of the GNU General Public License as published by | |||
| the Free Software Foundation; either version 2 of the License. | |||
| 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 General Public License for more details. | |||
| You should have received a copy of the GNU General Public License | |||
| along with this program; if not, write to the Free Software | |||
| Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. | |||
| */ | |||
| #include <stdint.h> | |||
| #include <string.h> | |||
| #include <stdio.h> | |||
| #include <assert.h> | |||
| #include <dbus/dbus.h> | |||
| #include "jackdbus.h" | |||
| JACK_DBUS_METHODS_BEGIN | |||
| JACK_DBUS_METHODS_END | |||
| JACK_DBUS_IFACE_BEGIN(g_jack_controller_iface_transport, "org.jackaudio.JackTransport") | |||
| JACK_DBUS_IFACE_EXPOSE_METHODS | |||
| JACK_DBUS_IFACE_END | |||
| @@ -0,0 +1,724 @@ | |||
| /* -*- Mode: C ; c-basic-offset: 4 -*- */ | |||
| /* | |||
| Copyright (C) 2007,2008 Nedko Arnaudov | |||
| Copyright (C) 2007-2008 Juuso Alasuutari | |||
| This program is free software; you can redistribute it and/or modify | |||
| it under the terms of the GNU General Public License as published by | |||
| the Free Software Foundation; either version 2 of the License. | |||
| 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 General Public License for more details. | |||
| You should have received a copy of the GNU General Public License | |||
| along with this program; if not, write to the Free Software | |||
| Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. | |||
| */ | |||
| #ifndef CONTROLLER_INTERNAL_H__04D54D51_3D79_49A2_A1DA_F8587E9E7F42__INCLUDED | |||
| #define CONTROLLER_INTERNAL_H__04D54D51_3D79_49A2_A1DA_F8587E9E7F42__INCLUDED | |||
| #include <stdbool.h> | |||
| #include "jslist.h" | |||
| #include "jack/control.h" | |||
| #include "jack/jack.h" | |||
| #include "jackdbus.h" | |||
| struct jack_controller | |||
| { | |||
| jackctl_server_t *server; | |||
| void *patchbay_context; | |||
| bool started; | |||
| jack_client_t *client; | |||
| unsigned int xruns; | |||
| const char **driver_names; | |||
| unsigned int drivers_count; | |||
| /* current driver, NULL if not driver is selected */ | |||
| jackctl_driver_t *driver; | |||
| struct jack_dbus_object_descriptor dbus_descriptor; | |||
| }; | |||
| #define JACK_CONF_HEADER_TEXT \ | |||
| "JACK settings, as persisted by D-Bus object.\n" \ | |||
| "You probably don't want to edit this because\n" \ | |||
| "it will be overwritten next time jackdbus saves.\n" | |||
| jackctl_driver_t * | |||
| jack_controller_find_driver( | |||
| jackctl_server_t *server, | |||
| const char *driver_name); | |||
| jackctl_parameter_t * | |||
| jack_controller_find_parameter( | |||
| const JSList *parameters_list, | |||
| const char *parameter_name); | |||
| bool | |||
| jack_controller_start_server( | |||
| struct jack_controller *controller_ptr, | |||
| void *dbus_call_context_ptr); | |||
| bool | |||
| jack_controller_stop_server( | |||
| struct jack_controller *controller_ptr, | |||
| void *dbus_call_context_ptr); | |||
| bool | |||
| jack_controller_select_driver( | |||
| struct jack_controller *controller_ptr, | |||
| const char * driver_name); | |||
| void | |||
| jack_controller_settings_set_driver_option( | |||
| jackctl_driver_t *driver, | |||
| const char *option_name, | |||
| const char *option_value); | |||
| void | |||
| jack_controller_settings_set_engine_option( | |||
| struct jack_controller *controller_ptr, | |||
| const char *option_name, | |||
| const char *option_value); | |||
| bool | |||
| jack_controller_settings_save_engine_options( | |||
| void *context, | |||
| struct jack_controller *controller_ptr, | |||
| void *dbus_call_context_ptr); | |||
| bool | |||
| jack_controller_settings_write_option( | |||
| void *context, | |||
| const char *name, | |||
| const char *content, | |||
| void *dbus_call_context_ptr); | |||
| bool | |||
| jack_controller_settings_save_driver_options( | |||
| void *context, | |||
| jackctl_driver_t *driver, | |||
| void *dbus_call_context_ptr); | |||
| bool | |||
| jack_controller_patchbay_init( | |||
| struct jack_controller *controller_ptr); | |||
| void | |||
| jack_controller_patchbay_uninit( | |||
| struct jack_controller *controller_ptr); | |||
| void * | |||
| jack_controller_patchbay_client_appeared_callback( | |||
| void * server_context, | |||
| uint64_t client_id, | |||
| const char *client_name); | |||
| void | |||
| jack_controller_patchbay_client_disappeared_callback( | |||
| void *server_context, | |||
| uint64_t client_id, | |||
| void *client_context); | |||
| void * | |||
| jack_controller_patchbay_port_appeared_callback( | |||
| void *server_context, | |||
| uint64_t client_id, | |||
| void *client_context, | |||
| uint64_t port_id, | |||
| const char *port_name, | |||
| uint32_t port_flags, | |||
| uint32_t port_type); | |||
| void | |||
| jack_controller_patchbay_port_disappeared_callback( | |||
| void *server_context, | |||
| uint64_t client_id, | |||
| void *client_context, | |||
| uint64_t port_id, | |||
| void *port_context); | |||
| void * | |||
| jack_controller_patchbay_ports_connected_callback( | |||
| void *server_context, | |||
| uint64_t client1_id, | |||
| void *client1_context, | |||
| uint64_t port1_id, | |||
| void *port1_context, | |||
| uint64_t client2_id, | |||
| void *client2_context, | |||
| uint64_t port2_id, | |||
| void *port2_context, | |||
| uint64_t connection_id); | |||
| void | |||
| jack_controller_patchbay_ports_disconnected_callback( | |||
| void *server_context, | |||
| uint64_t client1_id, | |||
| void *client1_context, | |||
| uint64_t port1_id, | |||
| void *port1_context, | |||
| uint64_t client2_id, | |||
| void *client2_context, | |||
| uint64_t port2_id, | |||
| void *port2_context, | |||
| uint64_t connection_id, | |||
| void *connection_context); | |||
| extern struct jack_dbus_interface_descriptor g_jack_controller_iface_introspectable; | |||
| extern struct jack_dbus_interface_descriptor g_jack_controller_iface_control; | |||
| extern struct jack_dbus_interface_descriptor g_jack_controller_iface_configure; | |||
| extern struct jack_dbus_interface_descriptor g_jack_controller_iface_patchbay; | |||
| extern struct jack_dbus_interface_descriptor g_jack_controller_iface_transport; | |||
| #endif /* #ifndef CONTROLLER_INTERNAL_H__04D54D51_3D79_49A2_A1DA_F8587E9E7F42__INCLUDED */ | |||
| /* -*- Mode: C ; c-basic-offset: 4 -*- */ | |||
| /* | |||
| Copyright (C) 2007,2008 Nedko Arnaudov | |||
| Copyright (C) 2007-2008 Juuso Alasuutari | |||
| This program is free software; you can redistribute it and/or modify | |||
| it under the terms of the GNU General Public License as published by | |||
| the Free Software Foundation; either version 2 of the License. | |||
| 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 General Public License for more details. | |||
| You should have received a copy of the GNU General Public License | |||
| along with this program; if not, write to the Free Software | |||
| Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. | |||
| */ | |||
| #ifndef CONTROLLER_INTERNAL_H__04D54D51_3D79_49A2_A1DA_F8587E9E7F42__INCLUDED | |||
| #define CONTROLLER_INTERNAL_H__04D54D51_3D79_49A2_A1DA_F8587E9E7F42__INCLUDED | |||
| #include <stdbool.h> | |||
| #include "jslist.h" | |||
| #include "jack/control.h" | |||
| #include "jack/jack.h" | |||
| #include "jackdbus.h" | |||
| struct jack_controller | |||
| { | |||
| jackctl_server_t *server; | |||
| void *patchbay_context; | |||
| bool started; | |||
| jack_client_t *client; | |||
| unsigned int xruns; | |||
| const char **driver_names; | |||
| unsigned int drivers_count; | |||
| /* current driver, NULL if not driver is selected */ | |||
| jackctl_driver_t *driver; | |||
| struct jack_dbus_object_descriptor dbus_descriptor; | |||
| }; | |||
| #define JACK_CONF_HEADER_TEXT \ | |||
| "JACK settings, as persisted by D-Bus object.\n" \ | |||
| "You probably don't want to edit this because\n" \ | |||
| "it will be overwritten next time jackdbus saves.\n" | |||
| jackctl_driver_t * | |||
| jack_controller_find_driver( | |||
| jackctl_server_t *server, | |||
| const char *driver_name); | |||
| jackctl_parameter_t * | |||
| jack_controller_find_parameter( | |||
| const JSList *parameters_list, | |||
| const char *parameter_name); | |||
| bool | |||
| jack_controller_start_server( | |||
| struct jack_controller *controller_ptr, | |||
| void *dbus_call_context_ptr); | |||
| bool | |||
| jack_controller_stop_server( | |||
| struct jack_controller *controller_ptr, | |||
| void *dbus_call_context_ptr); | |||
| bool | |||
| jack_controller_select_driver( | |||
| struct jack_controller *controller_ptr, | |||
| const char * driver_name); | |||
| void | |||
| jack_controller_settings_set_driver_option( | |||
| jackctl_driver_t *driver, | |||
| const char *option_name, | |||
| const char *option_value); | |||
| void | |||
| jack_controller_settings_set_engine_option( | |||
| struct jack_controller *controller_ptr, | |||
| const char *option_name, | |||
| const char *option_value); | |||
| bool | |||
| jack_controller_settings_save_engine_options( | |||
| void *context, | |||
| struct jack_controller *controller_ptr, | |||
| void *dbus_call_context_ptr); | |||
| bool | |||
| jack_controller_settings_write_option( | |||
| void *context, | |||
| const char *name, | |||
| const char *content, | |||
| void *dbus_call_context_ptr); | |||
| bool | |||
| jack_controller_settings_save_driver_options( | |||
| void *context, | |||
| jackctl_driver_t *driver, | |||
| void *dbus_call_context_ptr); | |||
| bool | |||
| jack_controller_patchbay_init( | |||
| struct jack_controller *controller_ptr); | |||
| void | |||
| jack_controller_patchbay_uninit( | |||
| struct jack_controller *controller_ptr); | |||
| void * | |||
| jack_controller_patchbay_client_appeared_callback( | |||
| void * server_context, | |||
| uint64_t client_id, | |||
| const char *client_name); | |||
| void | |||
| jack_controller_patchbay_client_disappeared_callback( | |||
| void *server_context, | |||
| uint64_t client_id, | |||
| void *client_context); | |||
| void * | |||
| jack_controller_patchbay_port_appeared_callback( | |||
| void *server_context, | |||
| uint64_t client_id, | |||
| void *client_context, | |||
| uint64_t port_id, | |||
| const char *port_name, | |||
| uint32_t port_flags, | |||
| uint32_t port_type); | |||
| void | |||
| jack_controller_patchbay_port_disappeared_callback( | |||
| void *server_context, | |||
| uint64_t client_id, | |||
| void *client_context, | |||
| uint64_t port_id, | |||
| void *port_context); | |||
| void * | |||
| jack_controller_patchbay_ports_connected_callback( | |||
| void *server_context, | |||
| uint64_t client1_id, | |||
| void *client1_context, | |||
| uint64_t port1_id, | |||
| void *port1_context, | |||
| uint64_t client2_id, | |||
| void *client2_context, | |||
| uint64_t port2_id, | |||
| void *port2_context, | |||
| uint64_t connection_id); | |||
| void | |||
| jack_controller_patchbay_ports_disconnected_callback( | |||
| void *server_context, | |||
| uint64_t client1_id, | |||
| void *client1_context, | |||
| uint64_t port1_id, | |||
| void *port1_context, | |||
| uint64_t client2_id, | |||
| void *client2_context, | |||
| uint64_t port2_id, | |||
| void *port2_context, | |||
| uint64_t connection_id, | |||
| void *connection_context); | |||
| extern struct jack_dbus_interface_descriptor g_jack_controller_iface_introspectable; | |||
| extern struct jack_dbus_interface_descriptor g_jack_controller_iface_control; | |||
| extern struct jack_dbus_interface_descriptor g_jack_controller_iface_configure; | |||
| extern struct jack_dbus_interface_descriptor g_jack_controller_iface_patchbay; | |||
| extern struct jack_dbus_interface_descriptor g_jack_controller_iface_transport; | |||
| #endif /* #ifndef CONTROLLER_INTERNAL_H__04D54D51_3D79_49A2_A1DA_F8587E9E7F42__INCLUDED */ | |||
| /* -*- Mode: C ; c-basic-offset: 4 -*- */ | |||
| /* | |||
| Copyright (C) 2007,2008 Nedko Arnaudov | |||
| Copyright (C) 2007-2008 Juuso Alasuutari | |||
| This program is free software; you can redistribute it and/or modify | |||
| it under the terms of the GNU General Public License as published by | |||
| the Free Software Foundation; either version 2 of the License. | |||
| 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 General Public License for more details. | |||
| You should have received a copy of the GNU General Public License | |||
| along with this program; if not, write to the Free Software | |||
| Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. | |||
| */ | |||
| #ifndef CONTROLLER_INTERNAL_H__04D54D51_3D79_49A2_A1DA_F8587E9E7F42__INCLUDED | |||
| #define CONTROLLER_INTERNAL_H__04D54D51_3D79_49A2_A1DA_F8587E9E7F42__INCLUDED | |||
| #include <stdbool.h> | |||
| #include "jslist.h" | |||
| #include "jack/control.h" | |||
| #include "jack/jack.h" | |||
| #include "jackdbus.h" | |||
| struct jack_controller | |||
| { | |||
| jackctl_server_t *server; | |||
| void *patchbay_context; | |||
| bool started; | |||
| jack_client_t *client; | |||
| unsigned int xruns; | |||
| const char **driver_names; | |||
| unsigned int drivers_count; | |||
| /* current driver, NULL if not driver is selected */ | |||
| jackctl_driver_t *driver; | |||
| struct jack_dbus_object_descriptor dbus_descriptor; | |||
| }; | |||
| #define JACK_CONF_HEADER_TEXT \ | |||
| "JACK settings, as persisted by D-Bus object.\n" \ | |||
| "You probably don't want to edit this because\n" \ | |||
| "it will be overwritten next time jackdbus saves.\n" | |||
| jackctl_driver_t * | |||
| jack_controller_find_driver( | |||
| jackctl_server_t *server, | |||
| const char *driver_name); | |||
| jackctl_parameter_t * | |||
| jack_controller_find_parameter( | |||
| const JSList *parameters_list, | |||
| const char *parameter_name); | |||
| bool | |||
| jack_controller_start_server( | |||
| struct jack_controller *controller_ptr, | |||
| void *dbus_call_context_ptr); | |||
| bool | |||
| jack_controller_stop_server( | |||
| struct jack_controller *controller_ptr, | |||
| void *dbus_call_context_ptr); | |||
| bool | |||
| jack_controller_select_driver( | |||
| struct jack_controller *controller_ptr, | |||
| const char * driver_name); | |||
| void | |||
| jack_controller_settings_set_driver_option( | |||
| jackctl_driver_t *driver, | |||
| const char *option_name, | |||
| const char *option_value); | |||
| void | |||
| jack_controller_settings_set_engine_option( | |||
| struct jack_controller *controller_ptr, | |||
| const char *option_name, | |||
| const char *option_value); | |||
| bool | |||
| jack_controller_settings_save_engine_options( | |||
| void *context, | |||
| struct jack_controller *controller_ptr, | |||
| void *dbus_call_context_ptr); | |||
| bool | |||
| jack_controller_settings_write_option( | |||
| void *context, | |||
| const char *name, | |||
| const char *content, | |||
| void *dbus_call_context_ptr); | |||
| bool | |||
| jack_controller_settings_save_driver_options( | |||
| void *context, | |||
| jackctl_driver_t *driver, | |||
| void *dbus_call_context_ptr); | |||
| bool | |||
| jack_controller_patchbay_init( | |||
| struct jack_controller *controller_ptr); | |||
| void | |||
| jack_controller_patchbay_uninit( | |||
| struct jack_controller *controller_ptr); | |||
| void * | |||
| jack_controller_patchbay_client_appeared_callback( | |||
| void * server_context, | |||
| uint64_t client_id, | |||
| const char *client_name); | |||
| void | |||
| jack_controller_patchbay_client_disappeared_callback( | |||
| void *server_context, | |||
| uint64_t client_id, | |||
| void *client_context); | |||
| void * | |||
| jack_controller_patchbay_port_appeared_callback( | |||
| void *server_context, | |||
| uint64_t client_id, | |||
| void *client_context, | |||
| uint64_t port_id, | |||
| const char *port_name, | |||
| uint32_t port_flags, | |||
| uint32_t port_type); | |||
| void | |||
| jack_controller_patchbay_port_disappeared_callback( | |||
| void *server_context, | |||
| uint64_t client_id, | |||
| void *client_context, | |||
| uint64_t port_id, | |||
| void *port_context); | |||
| void * | |||
| jack_controller_patchbay_ports_connected_callback( | |||
| void *server_context, | |||
| uint64_t client1_id, | |||
| void *client1_context, | |||
| uint64_t port1_id, | |||
| void *port1_context, | |||
| uint64_t client2_id, | |||
| void *client2_context, | |||
| uint64_t port2_id, | |||
| void *port2_context, | |||
| uint64_t connection_id); | |||
| void | |||
| jack_controller_patchbay_ports_disconnected_callback( | |||
| void *server_context, | |||
| uint64_t client1_id, | |||
| void *client1_context, | |||
| uint64_t port1_id, | |||
| void *port1_context, | |||
| uint64_t client2_id, | |||
| void *client2_context, | |||
| uint64_t port2_id, | |||
| void *port2_context, | |||
| uint64_t connection_id, | |||
| void *connection_context); | |||
| extern struct jack_dbus_interface_descriptor g_jack_controller_iface_introspectable; | |||
| extern struct jack_dbus_interface_descriptor g_jack_controller_iface_control; | |||
| extern struct jack_dbus_interface_descriptor g_jack_controller_iface_configure; | |||
| extern struct jack_dbus_interface_descriptor g_jack_controller_iface_patchbay; | |||
| extern struct jack_dbus_interface_descriptor g_jack_controller_iface_transport; | |||
| #endif /* #ifndef CONTROLLER_INTERNAL_H__04D54D51_3D79_49A2_A1DA_F8587E9E7F42__INCLUDED */ | |||
| /* -*- Mode: C ; c-basic-offset: 4 -*- */ | |||
| /* | |||
| Copyright (C) 2007,2008 Nedko Arnaudov | |||
| Copyright (C) 2007-2008 Juuso Alasuutari | |||
| This program is free software; you can redistribute it and/or modify | |||
| it under the terms of the GNU General Public License as published by | |||
| the Free Software Foundation; either version 2 of the License. | |||
| 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 General Public License for more details. | |||
| You should have received a copy of the GNU General Public License | |||
| along with this program; if not, write to the Free Software | |||
| Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. | |||
| */ | |||
| #ifndef CONTROLLER_INTERNAL_H__04D54D51_3D79_49A2_A1DA_F8587E9E7F42__INCLUDED | |||
| #define CONTROLLER_INTERNAL_H__04D54D51_3D79_49A2_A1DA_F8587E9E7F42__INCLUDED | |||
| #include <stdbool.h> | |||
| #include "jslist.h" | |||
| #include "jack/control.h" | |||
| #include "jack/jack.h" | |||
| #include "jackdbus.h" | |||
| struct jack_controller | |||
| { | |||
| jackctl_server_t *server; | |||
| void *patchbay_context; | |||
| bool started; | |||
| jack_client_t *client; | |||
| unsigned int xruns; | |||
| const char **driver_names; | |||
| unsigned int drivers_count; | |||
| /* current driver, NULL if not driver is selected */ | |||
| jackctl_driver_t *driver; | |||
| struct jack_dbus_object_descriptor dbus_descriptor; | |||
| }; | |||
| #define JACK_CONF_HEADER_TEXT \ | |||
| "JACK settings, as persisted by D-Bus object.\n" \ | |||
| "You probably don't want to edit this because\n" \ | |||
| "it will be overwritten next time jackdbus saves.\n" | |||
| jackctl_driver_t * | |||
| jack_controller_find_driver( | |||
| jackctl_server_t *server, | |||
| const char *driver_name); | |||
| jackctl_parameter_t * | |||
| jack_controller_find_parameter( | |||
| const JSList *parameters_list, | |||
| const char *parameter_name); | |||
| bool | |||
| jack_controller_start_server( | |||
| struct jack_controller *controller_ptr, | |||
| void *dbus_call_context_ptr); | |||
| bool | |||
| jack_controller_stop_server( | |||
| struct jack_controller *controller_ptr, | |||
| void *dbus_call_context_ptr); | |||
| bool | |||
| jack_controller_select_driver( | |||
| struct jack_controller *controller_ptr, | |||
| const char * driver_name); | |||
| void | |||
| jack_controller_settings_set_driver_option( | |||
| jackctl_driver_t *driver, | |||
| const char *option_name, | |||
| const char *option_value); | |||
| void | |||
| jack_controller_settings_set_engine_option( | |||
| struct jack_controller *controller_ptr, | |||
| const char *option_name, | |||
| const char *option_value); | |||
| bool | |||
| jack_controller_settings_save_engine_options( | |||
| void *context, | |||
| struct jack_controller *controller_ptr, | |||
| void *dbus_call_context_ptr); | |||
| bool | |||
| jack_controller_settings_write_option( | |||
| void *context, | |||
| const char *name, | |||
| const char *content, | |||
| void *dbus_call_context_ptr); | |||
| bool | |||
| jack_controller_settings_save_driver_options( | |||
| void *context, | |||
| jackctl_driver_t *driver, | |||
| void *dbus_call_context_ptr); | |||
| bool | |||
| jack_controller_patchbay_init( | |||
| struct jack_controller *controller_ptr); | |||
| void | |||
| jack_controller_patchbay_uninit( | |||
| struct jack_controller *controller_ptr); | |||
| void * | |||
| jack_controller_patchbay_client_appeared_callback( | |||
| void * server_context, | |||
| uint64_t client_id, | |||
| const char *client_name); | |||
| void | |||
| jack_controller_patchbay_client_disappeared_callback( | |||
| void *server_context, | |||
| uint64_t client_id, | |||
| void *client_context); | |||
| void * | |||
| jack_controller_patchbay_port_appeared_callback( | |||
| void *server_context, | |||
| uint64_t client_id, | |||
| void *client_context, | |||
| uint64_t port_id, | |||
| const char *port_name, | |||
| uint32_t port_flags, | |||
| uint32_t port_type); | |||
| void | |||
| jack_controller_patchbay_port_disappeared_callback( | |||
| void *server_context, | |||
| uint64_t client_id, | |||
| void *client_context, | |||
| uint64_t port_id, | |||
| void *port_context); | |||
| void * | |||
| jack_controller_patchbay_ports_connected_callback( | |||
| void *server_context, | |||
| uint64_t client1_id, | |||
| void *client1_context, | |||
| uint64_t port1_id, | |||
| void *port1_context, | |||
| uint64_t client2_id, | |||
| void *client2_context, | |||
| uint64_t port2_id, | |||
| void *port2_context, | |||
| uint64_t connection_id); | |||
| void | |||
| jack_controller_patchbay_ports_disconnected_callback( | |||
| void *server_context, | |||
| uint64_t client1_id, | |||
| void *client1_context, | |||
| uint64_t port1_id, | |||
| void *port1_context, | |||
| uint64_t client2_id, | |||
| void *client2_context, | |||
| uint64_t port2_id, | |||
| void *port2_context, | |||
| uint64_t connection_id, | |||
| void *connection_context); | |||
| extern struct jack_dbus_interface_descriptor g_jack_controller_iface_introspectable; | |||
| extern struct jack_dbus_interface_descriptor g_jack_controller_iface_control; | |||
| extern struct jack_dbus_interface_descriptor g_jack_controller_iface_configure; | |||
| extern struct jack_dbus_interface_descriptor g_jack_controller_iface_patchbay; | |||
| extern struct jack_dbus_interface_descriptor g_jack_controller_iface_transport; | |||
| #endif /* #ifndef CONTROLLER_INTERNAL_H__04D54D51_3D79_49A2_A1DA_F8587E9E7F42__INCLUDED */ | |||
| @@ -0,0 +1,12 @@ | |||
| [D-BUS Service] | |||
| Name=org.jackaudio.service | |||
| Exec=${BINDIR}/jackdbus auto | |||
| [D-BUS Service] | |||
| Name=org.jackaudio.service | |||
| Exec=${BINDIR}/jackdbus auto | |||
| [D-BUS Service] | |||
| Name=org.jackaudio.service | |||
| Exec=${BINDIR}/jackdbus auto | |||
| [D-BUS Service] | |||
| Name=org.jackaudio.service | |||
| Exec=${BINDIR}/jackdbus auto | |||
| @@ -0,0 +1,144 @@ | |||
| /* -*- Mode: C ; c-basic-offset: 4 -*- */ | |||
| /* | |||
| Copyright (C) 2007,2008 Nedko Arnaudov | |||
| This program is free software; you can redistribute it and/or modify | |||
| it under the terms of the GNU General Public License as published by | |||
| the Free Software Foundation; either version 2 of the License. | |||
| 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 General Public License for more details. | |||
| You should have received a copy of the GNU General Public License | |||
| along with this program; if not, write to the Free Software | |||
| Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. | |||
| */ | |||
| #ifndef XML_H__4F102BD2_3354_41C9_B842_DC00E1557A0F__INCLUDED | |||
| #define XML_H__4F102BD2_3354_41C9_B842_DC00E1557A0F__INCLUDED | |||
| bool | |||
| jack_controller_settings_save( | |||
| struct jack_controller * controller_ptr, | |||
| void *dbus_call_context_ptr); | |||
| void | |||
| jack_controller_settings_load( | |||
| struct jack_controller * controller_ptr); | |||
| void | |||
| jack_controller_settings_save_auto( | |||
| struct jack_controller * controller_ptr); | |||
| #endif /* #ifndef XML_H__4F102BD2_3354_41C9_B842_DC00E1557A0F__INCLUDED */ | |||
| /* -*- Mode: C ; c-basic-offset: 4 -*- */ | |||
| /* | |||
| Copyright (C) 2007,2008 Nedko Arnaudov | |||
| This program is free software; you can redistribute it and/or modify | |||
| it under the terms of the GNU General Public License as published by | |||
| the Free Software Foundation; either version 2 of the License. | |||
| 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 General Public License for more details. | |||
| You should have received a copy of the GNU General Public License | |||
| along with this program; if not, write to the Free Software | |||
| Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. | |||
| */ | |||
| #ifndef XML_H__4F102BD2_3354_41C9_B842_DC00E1557A0F__INCLUDED | |||
| #define XML_H__4F102BD2_3354_41C9_B842_DC00E1557A0F__INCLUDED | |||
| bool | |||
| jack_controller_settings_save( | |||
| struct jack_controller * controller_ptr, | |||
| void *dbus_call_context_ptr); | |||
| void | |||
| jack_controller_settings_load( | |||
| struct jack_controller * controller_ptr); | |||
| void | |||
| jack_controller_settings_save_auto( | |||
| struct jack_controller * controller_ptr); | |||
| #endif /* #ifndef XML_H__4F102BD2_3354_41C9_B842_DC00E1557A0F__INCLUDED */ | |||
| /* -*- Mode: C ; c-basic-offset: 4 -*- */ | |||
| /* | |||
| Copyright (C) 2007,2008 Nedko Arnaudov | |||
| This program is free software; you can redistribute it and/or modify | |||
| it under the terms of the GNU General Public License as published by | |||
| the Free Software Foundation; either version 2 of the License. | |||
| 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 General Public License for more details. | |||
| You should have received a copy of the GNU General Public License | |||
| along with this program; if not, write to the Free Software | |||
| Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. | |||
| */ | |||
| #ifndef XML_H__4F102BD2_3354_41C9_B842_DC00E1557A0F__INCLUDED | |||
| #define XML_H__4F102BD2_3354_41C9_B842_DC00E1557A0F__INCLUDED | |||
| bool | |||
| jack_controller_settings_save( | |||
| struct jack_controller * controller_ptr, | |||
| void *dbus_call_context_ptr); | |||
| void | |||
| jack_controller_settings_load( | |||
| struct jack_controller * controller_ptr); | |||
| void | |||
| jack_controller_settings_save_auto( | |||
| struct jack_controller * controller_ptr); | |||
| #endif /* #ifndef XML_H__4F102BD2_3354_41C9_B842_DC00E1557A0F__INCLUDED */ | |||
| /* -*- Mode: C ; c-basic-offset: 4 -*- */ | |||
| /* | |||
| Copyright (C) 2007,2008 Nedko Arnaudov | |||
| This program is free software; you can redistribute it and/or modify | |||
| it under the terms of the GNU General Public License as published by | |||
| the Free Software Foundation; either version 2 of the License. | |||
| 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 General Public License for more details. | |||
| You should have received a copy of the GNU General Public License | |||
| along with this program; if not, write to the Free Software | |||
| Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. | |||
| */ | |||
| #ifndef XML_H__4F102BD2_3354_41C9_B842_DC00E1557A0F__INCLUDED | |||
| #define XML_H__4F102BD2_3354_41C9_B842_DC00E1557A0F__INCLUDED | |||
| bool | |||
| jack_controller_settings_save( | |||
| struct jack_controller * controller_ptr, | |||
| void *dbus_call_context_ptr); | |||
| void | |||
| jack_controller_settings_load( | |||
| struct jack_controller * controller_ptr); | |||
| void | |||
| jack_controller_settings_save_auto( | |||
| struct jack_controller * controller_ptr); | |||
| #endif /* #ifndef XML_H__4F102BD2_3354_41C9_B842_DC00E1557A0F__INCLUDED */ | |||
| @@ -0,0 +1,232 @@ | |||
| /* -*- Mode: C ; c-basic-offset: 4 -*- */ | |||
| /* | |||
| Copyright (C) 2007,2008 Nedko Arnaudov | |||
| This program is free software; you can redistribute it and/or modify | |||
| it under the terms of the GNU General Public License as published by | |||
| the Free Software Foundation; either version 2 of the License. | |||
| 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 General Public License for more details. | |||
| You should have received a copy of the GNU General Public License | |||
| along with this program; if not, write to the Free Software | |||
| Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. | |||
| */ | |||
| #include <stdbool.h> | |||
| #include <dbus/dbus.h> | |||
| #include <jack/driver.h> | |||
| #include <jack/engine.h> | |||
| #include "dbus.h" | |||
| #include "controller_internal.h" | |||
| bool | |||
| jack_controller_settings_init() | |||
| { | |||
| return true; | |||
| } | |||
| void | |||
| jack_controller_settings_uninit() | |||
| { | |||
| } | |||
| bool | |||
| jack_controller_settings_save( | |||
| struct jack_controller * controller_ptr, | |||
| void *dbus_call_context_ptr) | |||
| { | |||
| jack_dbus_error(dbus_call_context_ptr, JACK_DBUS_ERROR_GENERIC, "jackdbus compiled without settings persistence"); | |||
| return true; | |||
| } | |||
| void | |||
| jack_controller_settings_load( | |||
| struct jack_controller * controller_ptr) | |||
| { | |||
| } | |||
| void | |||
| jack_controller_settings_save_auto( | |||
| struct jack_controller * controller_ptr) | |||
| { | |||
| } | |||
| /* -*- Mode: C ; c-basic-offset: 4 -*- */ | |||
| /* | |||
| Copyright (C) 2007,2008 Nedko Arnaudov | |||
| This program is free software; you can redistribute it and/or modify | |||
| it under the terms of the GNU General Public License as published by | |||
| the Free Software Foundation; either version 2 of the License. | |||
| 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 General Public License for more details. | |||
| You should have received a copy of the GNU General Public License | |||
| along with this program; if not, write to the Free Software | |||
| Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. | |||
| */ | |||
| #include <stdbool.h> | |||
| #include <dbus/dbus.h> | |||
| #include <jack/driver.h> | |||
| #include <jack/engine.h> | |||
| #include "dbus.h" | |||
| #include "controller_internal.h" | |||
| bool | |||
| jack_controller_settings_init() | |||
| { | |||
| return true; | |||
| } | |||
| void | |||
| jack_controller_settings_uninit() | |||
| { | |||
| } | |||
| bool | |||
| jack_controller_settings_save( | |||
| struct jack_controller * controller_ptr, | |||
| void *dbus_call_context_ptr) | |||
| { | |||
| jack_dbus_error(dbus_call_context_ptr, JACK_DBUS_ERROR_GENERIC, "jackdbus compiled without settings persistence"); | |||
| return true; | |||
| } | |||
| void | |||
| jack_controller_settings_load( | |||
| struct jack_controller * controller_ptr) | |||
| { | |||
| } | |||
| void | |||
| jack_controller_settings_save_auto( | |||
| struct jack_controller * controller_ptr) | |||
| { | |||
| } | |||
| /* -*- Mode: C ; c-basic-offset: 4 -*- */ | |||
| /* | |||
| Copyright (C) 2007,2008 Nedko Arnaudov | |||
| This program is free software; you can redistribute it and/or modify | |||
| it under the terms of the GNU General Public License as published by | |||
| the Free Software Foundation; either version 2 of the License. | |||
| 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 General Public License for more details. | |||
| You should have received a copy of the GNU General Public License | |||
| along with this program; if not, write to the Free Software | |||
| Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. | |||
| */ | |||
| #include <stdbool.h> | |||
| #include <dbus/dbus.h> | |||
| #include <jack/driver.h> | |||
| #include <jack/engine.h> | |||
| #include "dbus.h" | |||
| #include "controller_internal.h" | |||
| bool | |||
| jack_controller_settings_init() | |||
| { | |||
| return true; | |||
| } | |||
| void | |||
| jack_controller_settings_uninit() | |||
| { | |||
| } | |||
| bool | |||
| jack_controller_settings_save( | |||
| struct jack_controller * controller_ptr, | |||
| void *dbus_call_context_ptr) | |||
| { | |||
| jack_dbus_error(dbus_call_context_ptr, JACK_DBUS_ERROR_GENERIC, "jackdbus compiled without settings persistence"); | |||
| return true; | |||
| } | |||
| void | |||
| jack_controller_settings_load( | |||
| struct jack_controller * controller_ptr) | |||
| { | |||
| } | |||
| void | |||
| jack_controller_settings_save_auto( | |||
| struct jack_controller * controller_ptr) | |||
| { | |||
| } | |||
| /* -*- Mode: C ; c-basic-offset: 4 -*- */ | |||
| /* | |||
| Copyright (C) 2007,2008 Nedko Arnaudov | |||
| This program is free software; you can redistribute it and/or modify | |||
| it under the terms of the GNU General Public License as published by | |||
| the Free Software Foundation; either version 2 of the License. | |||
| 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 General Public License for more details. | |||
| You should have received a copy of the GNU General Public License | |||
| along with this program; if not, write to the Free Software | |||
| Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. | |||
| */ | |||
| #include <stdbool.h> | |||
| #include <dbus/dbus.h> | |||
| #include <jack/driver.h> | |||
| #include <jack/engine.h> | |||
| #include "dbus.h" | |||
| #include "controller_internal.h" | |||
| bool | |||
| jack_controller_settings_init() | |||
| { | |||
| return true; | |||
| } | |||
| void | |||
| jack_controller_settings_uninit() | |||
| { | |||
| } | |||
| bool | |||
| jack_controller_settings_save( | |||
| struct jack_controller * controller_ptr, | |||
| void *dbus_call_context_ptr) | |||
| { | |||
| jack_dbus_error(dbus_call_context_ptr, JACK_DBUS_ERROR_GENERIC, "jackdbus compiled without settings persistence"); | |||
| return true; | |||
| } | |||
| void | |||
| jack_controller_settings_load( | |||
| struct jack_controller * controller_ptr) | |||
| { | |||
| } | |||
| void | |||
| jack_controller_settings_save_auto( | |||
| struct jack_controller * controller_ptr) | |||
| { | |||
| } | |||
| @@ -0,0 +1,82 @@ | |||
| /* | |||
| Copyright (C) 2004-2006 Grame | |||
| This program is free software; you can redistribute it and/or modify | |||
| it under the terms of the GNU General Public License as published by | |||
| the Free Software Foundation; either version 2 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 General Public License for more details. | |||
| You should have received a copy of the GNU General Public License | |||
| along with this program; if not, write to the Free Software | |||
| Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. | |||
| */ | |||
| #include "JackWinProcessSync.h" | |||
| #include "JackError.h" | |||
| namespace Jack | |||
| { | |||
| bool JackWinProcessSync::TimedWait(long usec) | |||
| { | |||
| DWORD res = WaitForSingleObject(fEvent, usec / 1000); | |||
| return (res == WAIT_OBJECT_0); | |||
| } | |||
| void JackWinProcessSync::Wait() | |||
| { | |||
| WaitForSingleObject(fEvent, INFINITE); | |||
| } | |||
| } // end of namespace | |||
| /* | |||
| Copyright (C) 2004-2006 Grame | |||
| This program is free software; you can redistribute it and/or modify | |||
| it under the terms of the GNU General Public License as published by | |||
| the Free Software Foundation; either version 2 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 General Public License for more details. | |||
| You should have received a copy of the GNU General Public License | |||
| along with this program; if not, write to the Free Software | |||
| Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. | |||
| */ | |||
| #include "JackWinProcessSync.h" | |||
| #include "JackError.h" | |||
| namespace Jack | |||
| { | |||
| bool JackWinProcessSync::TimedWait(long usec) | |||
| { | |||
| DWORD res = WaitForSingleObject(fEvent, usec / 1000); | |||
| return (res == WAIT_OBJECT_0); | |||
| } | |||
| void JackWinProcessSync::Wait() | |||
| { | |||
| WaitForSingleObject(fEvent, INFINITE); | |||
| } | |||
| } // end of namespace | |||