Commit c0f0fd7c authored by sletz's avatar sletz
Browse files

Merge control branch.

git-svn-id: http://subversion.jackaudio.org/jack/jack2/trunk/jackmp@2339 0c269be4-1314-0410-8aa9-9f06e86f4224
parent 408f1b18
......@@ -20,6 +20,10 @@ Fernando Lopez-Lezcano
Jackdmp changes log
---------------------------
2008-05-26 Stephane Letz <letz@grame.fr>
* Merge control branch.
2008-05-24 Stephane Letz <letz@grame.fr>
* Tim Blechmann RAII idiom patch for JackServer ressource initialization.
......@@ -143,6 +147,10 @@ Fernando Lopez-Lezcano
* Synchronise transport.h with latest jackd version (Video handling).
2008-03-19 Stephane Letz <letz@grame.fr>
* Add jack_port_type_id in jack API.
2008-03-17 Stephane Letz <letz@grame.fr>
* New jack_server_control client to test notifications when linked to the server library.
......
......@@ -81,6 +81,7 @@ opts.AddOptions(
BoolOption('BUILD_EXAMPLES', 'Build the example clients in their directory', True),
BoolOption('INSTALL_EXAMPLES', 'Install the example clients in the BINDIR directory', True),
BoolOption('BUILD_DOXYGEN_DOCS', 'Build doxygen documentation', False),
BoolOption('ENABLE_DBUS', 'Whether to use D-Bus API', False),
('cc', 'cc', False),
('cxx', 'cxx', False),
('ccflags', 'ccflags', False),
......@@ -195,6 +196,7 @@ if env['DEBUG']:
print '--> Doing a DEBUG build'
# TODO: -Werror could be added to, which would force the devs to really remove all the warnings :-)
env.AppendUnique(CCFLAGS = ['-DDEBUG', '-Wall', '-g'])
env.AppendUnique(LINKFLAGS = ['-g'])
else:
env.AppendUnique(CCFLAGS = ['-O3','-DNDEBUG'])
......@@ -234,6 +236,8 @@ pkg_config_dir = env['INSTALL_LIBDIR']+"/pkgconfig/"
env.Install(pkg_config_dir, 'jack.pc')
env.Alias('install', pkg_config_dir)
env['BINDIR']=env.subst(env['BINDIR'])
# To have the top_srcdir as the doxygen-script is used from auto*
env['top_srcdir'] = env.Dir('.').abspath
......@@ -259,6 +263,10 @@ subdirs=['common']
if env['PLATFORM'] == 'posix':
subdirs.append('linux')
if env['ENABLE_DBUS']:
subdirs.append('linux/dbus')
env.AppendUnique(CCFLAGS = ['-DJACK_DBUS'])
# TODO FOR Marc: make macosx/SConscript work right
if env['PLATFORM'] == 'macosx':
subdirs.append('macosx')
......
......@@ -26,6 +26,7 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
#include "JackGlobals.h"
#include "JackTime.h"
#include "JackExports.h"
#include "JackPortType.h"
#ifdef __APPLE__
#include "JackMachThread.h"
......@@ -47,6 +48,18 @@ extern "C"
{
#endif
EXPORT
void
jack_get_version(
int *major_ptr,
int *minor_ptr,
int *micro_ptr,
int *proto_ptr);
EXPORT
const char *
jack_get_version_string();
EXPORT jack_client_t * jack_client_open_aux (const char *client_name,
jack_options_t options,
jack_status_t *status, va_list ap);
......@@ -114,6 +127,7 @@ extern "C"
EXPORT const char * jack_port_short_name (const jack_port_t *port);
EXPORT int jack_port_flags (const jack_port_t *port);
EXPORT const char * jack_port_type (const jack_port_t *port);
EXPORT jack_port_type_id_t jack_port_type_id (const jack_port_t *port);
EXPORT int jack_port_is_mine (const jack_client_t *, const jack_port_t *port);
EXPORT int jack_port_connected (const jack_port_t *port);
EXPORT int jack_port_connected_to (const jack_port_t *port,
......@@ -359,6 +373,21 @@ EXPORT const char* jack_port_type(const jack_port_t* port)
}
}
EXPORT jack_port_type_id_t jack_port_type_id (const jack_port_t *port)
{
#ifdef __CLIENTDEBUG__
JackLibGlobals::CheckContext();
#endif
jack_port_id_t myport = (jack_port_id_t)port;
if (!CheckPort(myport)) {
jack_error("jack_port_type_id called an incorrect port %ld", myport);
return 0;
} else {
JackGraphManager* manager = GetGraphManager();
return (manager ? GetPortTypeId(manager->GetPort(myport)->GetType()) : 0);
}
}
EXPORT int jack_port_connected(const jack_port_t* port)
{
#ifdef __CLIENTDEBUG__
......@@ -1686,3 +1715,25 @@ EXPORT jack_status_t jack_internal_client_unload(jack_client_t* ext_client, jack
return my_status;
}
}
EXPORT
void
jack_get_version(
int *major_ptr,
int *minor_ptr,
int *micro_ptr,
int *proto_ptr)
{
// FIXME: We need these comming from build system
*major_ptr = 0;
*minor_ptr = 0;
*micro_ptr = 0;
*proto_ptr = 0;
}
EXPORT
const char *
jack_get_version_string()
{
return VERSION;
}
......@@ -21,7 +21,6 @@ Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
#define __JackAtomicArrayState__
#include "JackAtomic.h"
#include "JackError.h"
#include <string.h> // for memcpy
namespace Jack
......@@ -136,7 +135,6 @@ class JackAtomicArrayState
JackAtomicArrayState()
{
jack_log("JackAtomicArrayState constructor");
Counter1(fCounter) = 0;
}
......
......@@ -21,7 +21,6 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
#define __JackChannel__
#include "types.h"
#include "JackError.h"
namespace Jack
{
......
......@@ -354,7 +354,7 @@ void JackConnectionManager::DirectDisconnect(int ref1, int ref2)
bool JackConnectionManager::IsDirectConnection(int ref1, int ref2) const
{
assert(ref1 >= 0 && ref2 >= 0);
return fConnectionRef.GetItemCount(ref1, ref2);
return (fConnectionRef.GetItemCount(ref1, ref2) > 0);
}
/*!
......
......@@ -22,6 +22,8 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
#include "JackConstants.h"
#include "JackActivationCount.h"
#include "JackError.h"
#include <assert.h>
namespace Jack
......
......@@ -48,6 +48,8 @@ namespace Jack
#define LOOPBACK_DRIVER_REFNUM 2 // Loopback driver is initialized third, it will get the refnum 2
#define REAL_REFNUM LOOPBACK_DRIVER_REFNUM + 1 // Real clients start at LOOPBACK_DRIVER_REFNUM + 1
#define JACK_DEFAULT_SERVER_NAME "default"
#ifdef WIN32
#define jack_server_dir "server"
#define jack_client_dir "client"
......
......@@ -36,6 +36,10 @@ Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
#include <dirent.h>
#endif
#include <errno.h>
jack_driver_desc_t * jackctl_driver_get_desc(jackctl_driver_t * driver);
static void
jack_print_driver_options (jack_driver_desc_t * desc, FILE *file)
{
......@@ -222,6 +226,147 @@ jack_parse_driver_params (jack_driver_desc_t * desc, int argc, char* argv[], JSL
return 0;
}
EXPORT int
jackctl_parse_driver_params (jackctl_driver *driver_ptr, int argc, char* argv[])
{
struct option * long_options;
char * options, * options_ptr;
unsigned long i;
int opt;
JSList * node_ptr;
jackctl_parameter_t * param;
union jackctl_parameter_value value;
if (argc <= 1)
return 0;
const JSList * driver_params = jackctl_driver_get_parameters(driver_ptr);
if (driver_params == NULL)
return 1;
jack_driver_desc_t * desc = jackctl_driver_get_desc(driver_ptr);
/* check for help */
if (strcmp (argv[1], "-h") == 0 || strcmp (argv[1], "--help") == 0) {
if (argc > 2) {
for (i = 0; i < desc->nparams; i++) {
if (strcmp (desc->params[i].name, argv[2]) == 0) {
jack_print_driver_param_usage (desc, i, stdout);
return 1;
}
}
fprintf (stderr, "jackd: unknown option '%s' "
"for driver '%s'\n", argv[2],
desc->name);
}
printf ("Parameters for driver '%s' (all parameters are optional):\n", desc->name);
jack_print_driver_options (desc, stdout);
return 1;
}
/* set up the stuff for getopt */
options = (char*)calloc (desc->nparams * 3 + 1, sizeof (char));
long_options = (option*)calloc (desc->nparams + 1, sizeof (struct option));
options_ptr = options;
for (i = 0; i < desc->nparams; i++) {
sprintf (options_ptr, "%c::", desc->params[i].character);
options_ptr += 3;
long_options[i].name = desc->params[i].name;
long_options[i].flag = NULL;
long_options[i].val = desc->params[i].character;
long_options[i].has_arg = optional_argument;
}
/* create the params */
optind = 0;
opterr = 0;
while ((opt = getopt_long(argc, argv, options, long_options, NULL)) != -1) {
if (opt == ':' || opt == '?') {
if (opt == ':') {
fprintf (stderr, "Missing option to argument '%c'\n", optopt);
} else {
fprintf (stderr, "Unknownage with option '%c'\n", optopt);
}
fprintf (stderr, "Options for driver '%s':\n", desc->name);
jack_print_driver_options (desc, stderr);
exit (1);
}
node_ptr = (JSList *)driver_params;
while (node_ptr) {
param = (jackctl_parameter_t*)node_ptr->data;
if (opt == jackctl_parameter_get_id(param)) {
break;
}
node_ptr = node_ptr->next;
}
if (!optarg && optind < argc &&
strlen(argv[optind]) &&
argv[optind][0] != '-') {
optarg = argv[optind];
}
if (optarg) {
switch (jackctl_parameter_get_type(param)) {
case JackDriverParamInt:
value.i = atoi (optarg);
jackctl_parameter_set_value(param, &value);
break;
case JackDriverParamUInt:
value.ui = strtoul (optarg, NULL, 10);
jackctl_parameter_set_value(param, &value);
break;
case JackDriverParamChar:
value.c = optarg[0];
jackctl_parameter_set_value(param, &value);
break;
case JackDriverParamString:
strncpy (value.str, optarg, JACK_DRIVER_PARAM_STRING_MAX);
jackctl_parameter_set_value(param, &value);
break;
case JackDriverParamBool:
/*
if (strcasecmp ("false", optarg) == 0 ||
strcasecmp ("off", optarg) == 0 ||
strcasecmp ("no", optarg) == 0 ||
strcasecmp ("0", optarg) == 0 ||
strcasecmp ("(null)", optarg) == 0 ) {
*/
// steph
if (strcmp ("false", optarg) == 0 ||
strcmp ("off", optarg) == 0 ||
strcmp ("no", optarg) == 0 ||
strcmp ("0", optarg) == 0 ||
strcmp ("(null)", optarg) == 0 ) {
value.i = false;
} else {
value.i = true;
}
jackctl_parameter_set_value(param, &value);
break;
}
} else {
if (jackctl_parameter_get_type(param) == JackParamBool) {
value.i = true;
} else {
value = jackctl_parameter_get_default_value(param);
jackctl_parameter_set_value(param, &value);
}
}
}
free (options);
free (long_options);
return 0;
}
EXPORT jack_driver_desc_t *
jack_find_driver_descriptor (JSList * drivers, const char * name)
{
......
......@@ -21,9 +21,10 @@ Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
#ifndef __JackDriverLoader__
#define __JackDriverLoader__
#include "jslist.h"
#include "driver_interface.h"
#include "JackDriver.h"
#include "control_types.h"
#include "jslist.h"
#ifdef WIN32
......@@ -54,14 +55,13 @@ typedef struct _jack_driver_info
jack_driver_info_t;
EXPORT jack_driver_desc_t * jack_find_driver_descriptor (JSList * drivers, const char * name);
jack_driver_desc_t * jack_drivers_get_descriptor (JSList * drivers, const char * sofile);
EXPORT JSList * jack_drivers_load (JSList * drivers);
jack_driver_info_t * jack_load_driver (jack_driver_desc_t * driver_desc);
EXPORT int jack_parse_driver_params (jack_driver_desc_t * desc, int argc, char* argv[], JSList ** param_ptr);
EXPORT int jackctl_parse_driver_params (jackctl_driver *driver_ptr, int argc, char* argv[]);
#endif
......@@ -34,6 +34,7 @@ Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
#include "JackGlobals.h"
#include "JackChannel.h"
#include "JackSyncInterface.h"
#include "JackError.h"
namespace Jack
{
......@@ -76,6 +77,7 @@ int JackEngine::Close()
jack_log("JackEngine::Close");
fChannel->Close();
// Close (possibly) remaining clients (RT is stopped)
for (int i = 0; i < CLIENT_NUM; i++) {
/*
Can only delete clients that where loaded using "jack_internal_client_load" (and not properly unloaded using "jack_internal_client_unload"...)
......@@ -112,6 +114,7 @@ void JackEngine::ReleaseRefnum(int ref)
fClientTable[ref] = NULL;
if (fEngineControl->fTemporary) {
jack_log("JackEngine::ReleaseRefnum fTemporary");
int i;
for (i = REAL_REFNUM; i < CLIENT_NUM; i++) {
if (fClientTable[i])
......@@ -217,7 +220,7 @@ void JackEngine::NotifyClient(int refnum, int event, int sync, int value1, int v
jack_log("JackEngine::NotifyClient: client not available anymore");
} else if (client->GetClientControl()->fCallback[event]) {
if (client->ClientNotify(refnum, client->GetClientControl()->fName, event, sync, value1, value2) < 0)
jack_error("NotifyClient fails name = %s event = %ld val1 = %ld val2 = %ld", client->GetClientControl()->fName, event, value1, value2);
jack_error("NotifyClient fails name = %s event = %ld = val1 = %ld val2 = %ld", client->GetClientControl()->fName, event, value1, value2);
} else {
jack_log("JackEngine::NotifyClient: no callback for event = %ld", event);
}
......@@ -680,7 +683,7 @@ int JackEngine::PortRegister(int refnum, const char* name, const char *type, uns
assert(fClientTable[refnum]);
// Check if port name already exists
if (fGraphManager->GetPort(name) != NO_PORT) {
if (GetGraphManager()->GetPort(name) != NO_PORT) {
jack_error("port_name \"%s\" already exists", name);
return -1;
}
......
......@@ -25,6 +25,7 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
#include "JackFrameTimer.h"
#include "JackTransportEngine.h"
#include "types.h"
#include <stdio.h>
namespace Jack
{
......
/*
Copyright (C) 2001 Paul Davis
Copyright (C) 2004-2008 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 <stdarg.h>
#include <stdio.h>
#include "JackError.h"
int jack_verbose = 0;
static
void
jack_format_and_log(const char *prefix, const char *fmt, va_list ap, void (* log_callback)(const char *))
{
char buffer[300];
size_t len;
if (prefix != NULL) {
len = strlen(prefix);
memcpy(buffer, prefix, len);
} else {
len = 0;
}
vsnprintf(buffer + len, sizeof(buffer) - len, fmt, ap);
log_callback(buffer);
}
EXPORT void jack_error(const char *fmt, ...)
{
va_list ap;
va_start(ap, fmt);
jack_format_and_log(NULL, fmt, ap, jack_error_callback);
va_end(ap);
}
EXPORT void jack_info(const char *fmt, ...)
{
va_list ap;
va_start(ap, fmt);
jack_format_and_log(NULL, fmt, ap, jack_info_callback);
va_end(ap);
}
EXPORT void jack_info_multiline(const char *fmt, ...)
{
va_list ap;
va_start(ap, fmt);
jack_format_and_log(NULL, fmt, ap, jack_info_callback);
va_end(ap);
}
EXPORT void jack_log(const char *fmt,...)
{
if (jack_verbose) {
va_list ap;
va_start(ap, fmt);
jack_format_and_log("Jack: ", fmt, ap, jack_info_callback);
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;
/*
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
......@@ -19,20 +20,22 @@ Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
*/
#ifndef __JackError__
#define __JackError__
#include <string.h>
#include <errno.h>
#include <stdio.h>
#include "JackExports.h"
#include "types.h"
#ifdef __cplusplus
extern "C"
{
#endif
#ifdef WIN32
#define vsnprintf _vsnprintf
#define snprintf _snprintf
#endif
#define LOG_LEVEL_INFO 1
#define LOG_LEVEL_ERROR 2
EXPORT void jack_error(const char *fmt, ...);
......@@ -41,11 +44,20 @@ extern "C"
// like jack_info() but only if verbose mode is enabled
EXPORT void jack_log(const char *fmt, ...);
extern int jack_verbose;
extern void (*jack_error_callback)(const char *desc);
extern void (*jack_info_callback)(const char *desc);
typedef void (* jack_log_function_t)(int level, const char *message);
void change_thread_log_function(jack_log_function_t log_function);
void jack_log_function(int level, const char *message);
EXPORT void set_threaded_log_function();
extern int jack_verbose;
#ifdef __cplusplus
}
#endif
#endif
......@@ -58,6 +58,71 @@ namespace Jack
JackDriverException(const char* msg) : JackException(msg)
{}
};
}
#endif
/*
Copyright (C) 2008 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.
*/
#ifndef __JackException__
#define __JackException__
#include <stdexcept>
#include <iostream>
#include <string>
#include "JackError.h"
namespace Jack
{
class JackException : public std::runtime_error {
public:
JackException(const std::string& msg) : runtime_error(msg)
{}
JackException(const char* msg) : runtime_error(msg)