Commit 7a2863cf authored by sletz's avatar sletz
Browse files

rebase from trunk 4004:4041

git-svn-id: http://subversion.jackaudio.org/jack/jack2/branches/libjacknet@4042 0c269be4-1314-0410-8aa9-9f06e86f4224
parent 7e4abd92
......@@ -24,20 +24,60 @@ Peter L Jones
Devin Anderson
Josh Green
Mario Lang
Arnold Krille
Arnold Krille
Jan Engelhardt
Adrian Knoth
---------------------------
Jackdmp changes log
---------------------------
2010-04-016 Stephane Letz <letz@grame.fr>
2010-08-23 Stephane Letz <letz@grame.fr>
* Make jack_connect/jack_disconnect wait for effective port connection/disconnection.
* Adrian Knoth fix for linux cycle.h (ticket 188).
2010-07-07 Stephane Letz <letz@grame.fr>
* Jan Engelhardt patch for get_cycles on SPARC.
* Adrian Knoth hurd.patch, kfreebsd-fix.patch and alpha_ia64-sigsegv.patch from ticket 177.
2010-06-29 Stephane Letz <letz@grame.fr>
* Arnold Krille firewire snooping patch.
2010-06-16 Stephane Letz <letz@grame.fr>
* David Garcia Garzon unused_pkt_buf_field_jack2 netone patch.
2010-06-13 Stephane Letz <letz@grame.fr>
* Fix JackPosixSemaphore::TimedWait : same behavior as JackPosixSemaphore::Wait regarding EINTR.
2010-05-31 Stephane Letz <letz@grame.fr>
* Fix from Fernando Lopez-Lezcano for compilation on fc13.
2010-05-30 Stephane Letz <letz@grame.fr>
* David Garcia Garzon netone patch.
2010-05-27 Stephane Letz <letz@grame.fr>
* In JackCoreAudioDriver, move code called in MeasureCallback to be called once in IO thread.
2010-05-07 Stephane Letz <letz@grame.fr>
* Add tests to validate intclient.h API.
* On Linux, inter-process synchronization primitive switched to POSIX semaphore.
2010-04-16 Stephane Letz <letz@grame.fr>
* Make jack_connect/jack_disconnect wait for effective port connection/disconnection.
2010-04-07 Stephane Letz <letz@grame.fr>
* Remove call to exit in library code.
2010-03-26 Stephane Letz <letz@grame.fr>
* ffado-portname-sync.patch from ticket #163 applied.
......@@ -45,7 +85,7 @@ Arnold Krille
2010-03-24 Stephane Letz <letz@grame.fr>
* On Windows, now use TRE library for regexp (BSD license instead of GPL license).
2010-03-19 Stephane Letz <letz@grame.fr>
* Fix some file header to have library side code use LGPL.
......@@ -234,7 +274,7 @@ Arnold Krille
2009-10-20 Stephane Letz <letz@grame.fr>
* Add a string parameter to server ==> client notification, add a new JackInfoShutdownCallback type.
* CoreAudio backend now issue a JackInfoShutdownCallback when an unrecoverable error is detected (sampling rate change, stream configuration change)
* CoreAudio backend now issue a JackInfoShutdownCallback when an unrecoverable error is detected (sampling rate change, stream configuration changed)
2009-10-17 Stephane Letz <letz@grame.fr>
......
......@@ -1012,7 +1012,7 @@ int JackClient::InternalClientLoad(const char* client_name, jack_options_t optio
if (va->load_name && (strlen(va->load_name) >= JACK_PATH_MAX)) {
jack_error("\"%s\" is too long for a shared object name.\n"
"Please use %lu characters or less.",
va->load_name, PATH_MAX);
va->load_name, JACK_PATH_MAX);
int my_status1 = *status | (JackFailure | JackInvalidOption);
*status = (jack_status_t)my_status1;
return 0;
......@@ -1027,7 +1027,8 @@ int JackClient::InternalClientLoad(const char* client_name, jack_options_t optio
return 0;
}
int int_ref, result = -1;
int int_ref = 0;
int result = -1;
fChannel->InternalClientLoad(GetClientControl()->fRefNum, client_name, va->load_name, va->load_init, options, (int*)status, &int_ref, &result);
return int_ref;
}
......
......@@ -27,17 +27,15 @@
using namespace Jack;
void change_thread_log_function(jack_log_function_t log_function)
static bool change_thread_log_function(jack_log_function_t log_function)
{
if (!jack_tls_set(JackGlobals::fKeyLogFunction, (void*)log_function))
{
jack_error("failed to set thread log function");
}
return (jack_tls_get(JackGlobals::fKeyLogFunction) == NULL
&& jack_tls_set(JackGlobals::fKeyLogFunction, (void*)log_function));
}
SERVER_EXPORT void set_threaded_log_function()
SERVER_EXPORT int set_threaded_log_function()
{
change_thread_log_function(JackMessageBufferAdd);
return change_thread_log_function(JackMessageBufferAdd);
}
void jack_log_function(int level, const char *message)
......
......@@ -53,10 +53,9 @@ extern "C"
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);
SERVER_EXPORT void set_threaded_log_function();
SERVER_EXPORT int set_threaded_log_function();
#ifdef __cplusplus
}
......
......@@ -120,7 +120,7 @@ namespace Jack {
public:
JackPhysicalMidiInput(size_t buffer_size=1024);
~JackPhysicalMidiInput();
virtual ~JackPhysicalMidiInput();
/**
* Called to process MIDI data during a period.
......
......@@ -92,7 +92,7 @@ namespace Jack {
JackPhysicalMidiOutput(size_t non_rt_buffer_size=1024,
size_t rt_buffer_size=64);
~JackPhysicalMidiOutput();
virtual ~JackPhysicalMidiOutput();
/**
* Called to process MIDI data during a period.
......
......@@ -85,7 +85,7 @@ static void copyright(FILE* file)
{
fprintf(file, "jackdmp " VERSION "\n"
"Copyright 2001-2005 Paul Davis and others.\n"
"Copyright 2004-2009 Grame.\n"
"Copyright 2004-2010 Grame.\n"
"jackdmp comes with ABSOLUTELY NO WARRANTY\n"
"This is free software, and you are welcome to redistribute it\n"
"under certain conditions; see the file COPYING for details\n");
......
......@@ -53,7 +53,7 @@ Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
#endif /* WIN32 */
#if defined(__APPLE__) || defined(__linux__) || defined(__sun__) || defined(sun)
#if defined(__APPLE__) || defined(__linux__) || defined(__sun__) || defined(sun) || defined(__unix__)
#include <inttypes.h>
#include <pthread.h>
#include <sys/types.h>
......
......@@ -564,6 +564,7 @@ netjack_driver_state_t *netjack_init (netjack_driver_state_t *netj,
netj->resample_factor = resample_factor;
netj->resample_factor_up = resample_factor_up;
netj->jitter_val = jitter_val;
return netj;
}
......@@ -734,7 +735,6 @@ netjack_startup( netjack_driver_state_t *netj )
}
netj->rx_bufsize = sizeof (jacknet_packet_header) + netj->net_period_down * netj->capture_channels * get_sample_size (netj->bitdepth);
netj->pkt_buf = malloc (netj->rx_bufsize);
global_packcache = packet_cache_new (netj->latency + 50, netj->rx_bufsize, netj->mtu);
netj->expected_framecnt_valid = 0;
......
......@@ -85,7 +85,6 @@ struct _netjack_driver_state {
unsigned int handle_transport_sync;
unsigned int *rx_buf;
unsigned int *pkt_buf;
unsigned int rx_bufsize;
//unsigned int tx_bufsize;
unsigned int mtu;
......
......@@ -512,7 +512,7 @@ jack_register_server (const char *server_name, int new_registry)
unlock:
jack_shm_unlock_registry ();
return 0;
return res;
}
/* release server_name registration */
......
......@@ -60,7 +60,7 @@ SERVER_EXPORT int audio_reservation_finish()
if (gConnection) {
dbus_connection_unref(gConnection);
gConnection = NULL;
jack_info("audio_reservation_finish");
jack_info("audio_reservation_finish");
}
return 0;
}
......
/* -*- Mode: C ; c-basic-offset: 4 -*- */
/*
Copyright (C) 2007,2008 Nedko Arnaudov
Copyright (C) 2007,2008,2010 Nedko Arnaudov
Copyright (C) 2007-2008 Juuso Alasuutari
This program is free software; you can redistribute it and/or modify
......@@ -25,6 +25,7 @@
#include <stdint.h>
#include <string.h>
#include <dbus/dbus.h>
#include <assert.h>
#include "controller.h"
#include "controller_internal.h"
......@@ -142,11 +143,7 @@ jack_controller_start_server(
jack_info("Starting jack server...");
if (controller_ptr->started)
{
jack_info("Already started.");
return TRUE;
}
assert(!controller_ptr->started); /* should be ensured by caller */
if (controller_ptr->driver == NULL)
{
......@@ -171,7 +168,6 @@ jack_controller_start_server(
if (controller_ptr->client == NULL)
{
jack_dbus_error(dbus_call_context_ptr, JACK_DBUS_ERROR_GENERIC, "failed to create dbusapi jack client");
goto fail_stop_server;
}
......@@ -179,13 +175,12 @@ jack_controller_start_server(
if (ret != 0)
{
jack_dbus_error(dbus_call_context_ptr, JACK_DBUS_ERROR_GENERIC, "failed to set xrun callback. error is %d", ret);
goto fail_close_client;
}
if (!jack_controller_patchbay_init(controller_ptr))
{
jack_error("Failed to initialize patchbay district");
jack_dbus_error(dbus_call_context_ptr, JACK_DBUS_ERROR_GENERIC, "Failed to initialize patchbay district");
goto fail_close_client;
}
......@@ -193,7 +188,6 @@ jack_controller_start_server(
if (ret != 0)
{
jack_dbus_error(dbus_call_context_ptr, JACK_DBUS_ERROR_GENERIC, "failed to activate dbusapi jack client. error is %d", ret);
goto fail_patchbay_uninit;
}
......@@ -232,16 +226,12 @@ jack_controller_stop_server(
jack_info("Stopping jack server...");
if (!controller_ptr->started)
{
jack_info("Already stopped.");
return TRUE;
}
assert(controller_ptr->started); /* should be ensured by caller */
ret = jack_deactivate(controller_ptr->client);
if (ret != 0)
{
jack_dbus_error(dbus_call_context_ptr, JACK_DBUS_ERROR_GENERIC, "failed to deactivate dbusapi jack client. error is %d", ret);
jack_error("failed to deactivate dbusapi jack client. error is %d", ret);
}
jack_controller_patchbay_uninit(controller_ptr);
......@@ -256,6 +246,7 @@ jack_controller_stop_server(
if (!jackctl_server_stop(controller_ptr->server))
{
jack_dbus_error(dbus_call_context_ptr, JACK_DBUS_ERROR_GENERIC, "Failed to stop server");
return FALSE;
}
......
/* -*- Mode: C ; c-basic-offset: 4 -*- */
/*
Copyright (C) 2007,2008 Nedko Arnaudov
Copyright (C) 2007,2008,2010 Nedko Arnaudov
Copyright (C) 2007-2008 Juuso Alasuutari
This program is free software; you can redistribute it and/or modify
......@@ -85,29 +85,46 @@ jack_control_run_method(
}
else if (strcmp (call->method_name, "StartServer") == 0)
{
if (!jack_controller_start_server(controller_ptr, call))
if (controller_ptr->started)
{
jack_dbus_error(call, JACK_DBUS_ERROR_GENERIC, "Failed to start server");
return true;
jack_info("Ignoring JACK server start request because server is already started.");
}
else
{
if (!jack_controller_start_server(controller_ptr, call))
{
/* the reply is set by the failed function */
assert(call->reply != NULL);
return true;
}
jack_controller_control_send_signal_server_started();
}
jack_controller_control_send_signal_server_started();
}
else if (strcmp (call->method_name, "StopServer") == 0)
{
if (!jack_controller_stop_server(controller_ptr, call))
if (!controller_ptr->started)
{
jack_dbus_error(call, JACK_DBUS_ERROR_GENERIC, "Failed to stop server");
return true;
jack_info("Ignoring JACK server stop request because server is already stopped.");
}
else
{
if (!jack_controller_stop_server(controller_ptr, call))
{
/* the reply is set by the failed function */
assert(call->reply != NULL);
return true;
}
jack_controller_control_send_signal_server_stopped();
}
jack_controller_control_send_signal_server_stopped();
}
else if (strcmp (call->method_name, "SwitchMaster") == 0)
{
if (!jack_controller_switch_master(controller_ptr, call))
{
jack_dbus_error(call, JACK_DBUS_ERROR_GENERIC, "Failed to switch master");
/* the reply is set by the failed function */
assert(call->reply != NULL);
return true;
}
......
......@@ -98,14 +98,18 @@ static void signal_segv(int signum, siginfo_t* info, void*ptr) {
jack_error("info.si_errno = %d", info->si_errno);
jack_error("info.si_code = %d (%s)", info->si_code, si_codes[info->si_code]);
jack_error("info.si_addr = %p", info->si_addr);
#if !defined(__alpha__) && !defined(__ia64__) && !defined(__FreeBSD_kernel__) && !defined(__arm__) && !defined(__hppa__) && !defined(__sh__)
for(i = 0; i < NGREG; i++)
jack_error("reg[%02d] = 0x" REGFORMAT, i,
#if defined(__powerpc__)
ucontext->uc_mcontext.uc_regs[i]
#elif defined(__sparc__) && defined(__arch64__)
ucontext->uc_mcontext.mc_gregs[i]
#else
ucontext->uc_mcontext.gregs[i]
#endif
);
#endif /* alpha, ia64, kFreeBSD, arm, hppa */
#if defined(SIGSEGV_STACK_X86) || defined(SIGSEGV_STACK_IA64)
# if defined(SIGSEGV_STACK_IA64)
......
......@@ -17,9 +17,9 @@
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <signal.h>
#include <signal.h>
#ifndef WIN32
#include <unistd.h>
#include <unistd.h>
#endif
#include <getopt.h>
#include <jack/jack.h>
......@@ -126,7 +126,7 @@ parse_args (int argc, char *argv[])
int
main (int argc, char *argv[])
{
jack_status_t status;
jack_status_t status;
char* name;
/* parse and validate command arguments */
......@@ -157,8 +157,8 @@ main (int argc, char *argv[])
(JackLoadName|JackLoadInit),
&status, load_name, load_init);
if (status & JackFailure) {
fprintf (stderr, "could not load %s, status = 0x%2.0x\n",
load_name, status);
fprintf (stderr, "could not load %s, intclient = %d status = 0x%2.0x\n",
load_name, (int)intclient, status);
return 2;
}
if (status & JackNameNotUnique) {
......@@ -178,23 +178,23 @@ main (int argc, char *argv[])
if (wait_opt) {
/* define a signal handler to unload the client, then
* wait for it to exit */
#ifdef WIN32
signal(SIGINT, signal_handler);
signal(SIGABRT, signal_handler);
signal(SIGTERM, signal_handler);
#else
signal(SIGQUIT, signal_handler);
signal(SIGTERM, signal_handler);
signal(SIGHUP, signal_handler);
signal(SIGINT, signal_handler);
#endif
while (1) {
#ifdef WIN32
Sleep(1000);
* wait for it to exit */
#ifdef WIN32
signal(SIGINT, signal_handler);
signal(SIGABRT, signal_handler);
signal(SIGTERM, signal_handler);
#else
signal(SIGQUIT, signal_handler);
signal(SIGTERM, signal_handler);
signal(SIGHUP, signal_handler);
signal(SIGINT, signal_handler);
#endif
while (1) {
#ifdef WIN32
Sleep(1000);
#else
sleep (1);
sleep (1);
#endif
}
}
......
......@@ -49,8 +49,13 @@ namespace Jack {typedef JackPosixMutex JackMutex; }
namespace Jack { typedef JackPosixThread JackThread; }
/* __JackPlatformSynchro__ client activation */
/*
#include "JackFifo.h"
namespace Jack { typedef JackFifo JackSynchro; }
*/
#include "JackPosixSemaphore.h"
namespace Jack { typedef JackPosixSemaphore JackSynchro; }
/* __JackPlatformChannelTransaction__ */
#include "JackSocket.h"
......
......@@ -51,7 +51,17 @@ static inline unsigned long get_cycles(void)
return (((unsigned long)hi)<<32) | ((unsigned long)lo);
}
#endif
#endif /* __x86_64__ */
#ifdef __sparc_v9__
/* rd is V9 only */
static inline unsigned long long get_cycles(void)
{
unsigned long long res;
__asm__ __volatile__("rd %%tick, %0" : "=r"(res));
return res;
}
#endif /* __sparc_v9__ */
#ifdef __PPC__
......@@ -82,7 +92,7 @@ static inline cycles_t get_cycles(void)
return ret;
}
#endif
#endif /* __PPC__ */
#ifdef __i386__
......@@ -101,10 +111,26 @@ static inline cycles_t get_cycles (void)
return ret;
}
#endif
#endif /* __i386__ */
/* everything else but x86, amd64, sparcv9 or ppc */
#if !defined (__PPC__) && !defined (__x86_64__) && !defined (__i386__) && !defined (__sparc_v9__)
#warning No suitable get_cycles() implementation. Returning 0 instead
typedef unsigned long long cycles_t;
static inline cycles_t get_cycles(void)
{
return 0;
}
#endif /* everything else but x86, amd64, sparcv9 or ppc */
#endif /* __linux__ */
/* everything else but x86, amd64 or ppc */
#if !defined (__PPC__) && !defined (__x86_64__) && !defined (__i386__)
#if defined(__FreeBSD_kernel__)
#warning No suitable get_cycles() implementation. Returning 0 instead
......@@ -115,8 +141,7 @@ static inline cycles_t get_cycles(void)
return 0;
}
#endif
#endif /* __FreeBSD_kernel__ */
#endif
#endif /* __jack_cycles_h__ */
......@@ -338,6 +338,7 @@ JackFFADODriver::ffado_driver_new (const char *name,
driver->device_options.verbose = params->verbose_level;
driver->capture_frame_latency = params->capture_frame_latency;
driver->playback_frame_latency = params->playback_frame_latency;
driver->device_options.snoop_mode = params->snoop_mode;
debugPrint(DEBUG_LEVEL_STARTUP, " Driver compiled on %s %s", __DATE__, __TIME__);
debugPrint(DEBUG_LEVEL_STARTUP, " Created driver %s", name);
......@@ -753,7 +754,7 @@ extern "C"
strcpy (desc->name, "firewire"); // size MUST be less then JACK_DRIVER_NAME_MAX + 1
strcpy(desc->desc, "Linux FFADO API based audio backend"); // size MUST be less then JACK_DRIVER_PARAM_DESC + 1
desc->nparams = 12;
desc->nparams = 13;
params = (jack_driver_param_desc_t *)calloc (desc->nparams, sizeof (jack_driver_param_desc_t));
desc->params = params;
......@@ -854,6 +855,14 @@ extern "C"
strcpy (params[i].short_desc, "libffado verbose level");
strcpy (params[i].long_desc, params[i].short_desc);
i++;
strcpy (params[i].name, "snoop");
params[i].character = 'X';
params[i].type = JackDriverParamBool;
params[i].value.i = 0;
strcpy (params[i].short_desc, "Snoop firewire traffic");
strcpy (params[i].long_desc, params[i].short_desc);
return desc;
}
......@@ -863,7 +872,7 @@ extern "C"
ffado_jack_settings_t cmlparams;
char *device_name="hw:0";
char *device_name=(char*)"hw:0";
cmlparams.period_size_set = 0;
cmlparams.sample_rate_set = 0;
......@@ -919,7 +928,7 @@ extern "C"
cmlparams.slave_mode = param->value.ui;
break;
case 'X':
cmlparams.snoop_mode = param->value.ui;
cmlparams.snoop_mode = param->value.i;
break;
case 'v':
cmlparams.verbose_level = param->value.ui;
......
......@@ -194,6 +194,22 @@ OSStatus JackCoreAudioDriver::Render(void *inRefCon,
driver->fActionFags = ioActionFlags;
driver->fCurrentTime = (AudioTimeStamp *)inTimeStamp;
driver->fDriverOutputData = ioData;
// Setup threadded based log function once...
if (set_threaded_log_function()) {
jack_log("set_threaded_log_function");
JackMachThread::GetParams(pthread_self(), &driver->fEngineControl->fPeriod, &driver->fEngineControl->fComputation, &driver->fEngineControl->fConstraint);
if (driver->fComputationGrain > 0) {
jack_log("JackCoreAudioDriver::Render : RT thread computation setup to %d percent of period", int(driver->fComputationGrain * 100));
driver->fEngineControl->fComputation = driver->fEngineControl->fPeriod * driver->fComputationGrain;
}
// Signal waiting start function...
driver->fState = true;
}
driver->CycleTakeBeginTime();
return driver->Process();
}
......@@ -221,33 +237,6 @@ int JackCoreAudioDriver::Write()
return 0;
}
// Will run only once
OSStatus JackCoreAudioDriver::MeasureCallback(AudioDeviceID inDevice,
const AudioTimeStamp* inNow,
const AudioBufferList* inInputData,
const AudioTimeStamp* inInputTime,
AudioBufferList* outOutputData,
const AudioTimeStamp* inOutputTime,
void* inClientData)
{