Commit ec2e42c9 authored by sletz's avatar sletz
Browse files

rebase from trunk 3899:3916

git-svn-id: http://subversion.jackaudio.org/jack/jack2/branches/libjacknet@3917 0c269be4-1314-0410-8aa9-9f06e86f4224
parent 6ae91579
......@@ -29,6 +29,10 @@ Mario Lang
Jackdmp changes log
---------------------------
2010-02-15 Gabriel M. Beddingfield <gabriel@teuton.org>
* Version 1.9.6 started.
2010-01-29 Gabriel M. Beddingfield <gabriel@teuton.org>
* Change JackEngineProfiling and JackAudioAdapterInterface gnuplot scripts to output SVG instead of PDF.
......
......@@ -214,6 +214,7 @@ Note : To experiment with the -S option, jackdmp must be launched in a console.
1.9.2 : Solaris version. New "profiling" tools. Rework the mutex/signal classes. Support for BIG_ENDIAN machines in NetJack2. D-BUS based device reservation to better coexist with PulseAudio on Linux. Add auto_connect parameter in netmanager and netadapter. Use Torben Hohn PI controler code for adapters. Client incorrect re-naming fixed : now done at socket and fifo level. Virtualize and allow overriding of thread creation function, to allow Wine support (from JACK1).
1.9.3 : New JackBoomerDriver class for Boomer driver on Solaris. Add mixed 32/64 bits mode (off by default). Native MIDI backend (JackCoreMidiDriver, JackWinMMEDriver). In ALSA audio card reservation code, tries to open the card even if reservation fails. Clock source setting on Linux. Add jackctl_server_switch_master API. Fix transport callback (timebase master, sync) issue when used after jack_activate (RT thread was not running). D-Bus access for jackctl_server_add_slave/jackctl_server_remove_slave API. Cleanup "loopback" stuff in server. Torben Hohn fix for InitTime and GetMicroSeconds in JackWinTime.c. New jack_free function added in jack.h. Reworked Torben Hohn fix for server restart issue on Windows. Correct jack_set_error_function, jack_set_info_function and jack_set_thread_creator functions. Correct JackFifo::TimedWait for EINTR handling. Move DBus based audio device reservation code in ALSA backend compilation. Correct JackTransportEngine::MakeAllLocating, sync callback has to be called in this case also. NetJack2 code : better error checkout, method renaming. Tim Bechmann patch : hammerfall, only release monitor thread, if it has been created. Tim Bechmann memops.c optimization patches. In combined --dbus and --classic compilation code, use PulseAudio acquire/release code. Big rewrite of Solaris boomer driver, seems to work in duplex mode at least. Loopback backend reborn as a dynamically loadable separated backend.
1.9.4 : Solaris boomer backend now working in capture or playback only mode. Add a -G parameter in CoreAudio backend (the computation value in RT thread expressed as percent of period). Use SNDCTL_DSP_SYNCGROUP/SNDCTL_DSP_SYNCSTART API to synchronize input and output in Solaris boomer backend. Big endian bug fix in memops.c. Fix issues in JackNetDriver::DecodeTransportData and JackNetDriver::Initialize. Correct CPU timing in JackNetDriver, now take cycle begin time after Read. Simplify transport in NetJack2: master only can control transport. Change CoreAudio notification thread setup for OSX Snow Leopard. Correct server temporary mode : now set a global and quit after server/client message handling is finished. 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É). Correct jackdmp.cpp (failures case were not correct..). Improve JackCoreAudioDriver code. Raise default port number to 2048. Correct JackProcessSync::LockedTimedWait. Correct JACK_MESSAGE_SIZE value, particularly in OSX RPC code. Now start server channel thread only when backend has been started (so in JackServer::Start). Should solve race conditions at start time. jack_verbose moved to JackGlobals class. Improve aggregate device management in JackCoreAudioDriver : now a "private" device only and cleanup properly. Aggregate device code added to JackCoreAudioAdapter. Implement "hog mode" (exclusive access of the audio device) in JackCoreAudioDriver. Fix jack_set_sample_rate_callback to have he same behavior as in JACK1. Dynamic system version detection in JackCoreAudioDriver to either create public or private aggregate device. In JackCoreAudioDriver, force the SR value to the wanted one *before* creating aggregate device (otherwise creation will fail). In JackCoreAudioDriver, better cleanup of AD when intermediate open failure. In JackCoreAudioDriver::Start, wait for the audio driver to effectively start (use the MeasureCallback). In JackCoreAudioDriver, improve management of input/output channels: -1 is now used internally to indicate a wanted max value. In JackCoreAudioDriver::OpenAUHAL, correct stream format setup and cleanup. Correct crash bug in JackAudioAdapterInterface when not input is used in adapter (temporary fixÉ). Sync JackCoreAudioAdapter code on JackCoreAudioDriver one. JACK_SCHED_POLICY switched to SCHED_FIFO. Now can aggregate device that are themselves AD. No reason to make jack_on_shutdown deprecated, so revert the incorrect change. Thread AcquireRealTime and DropRealTime were (incorrectly) using fThread field. Use pthread_self()) (or GetCurrentThread() on Windows) to get the calling thread. Correctly save and restore RT mode state in freewheel mode. Correct freewheel code on client side. Fix AcquireRealTime and DropRealTime: now distinguish when called from another thread (AcquireRealTime/DropRealTime) and from the thread itself (AcquireSelfRealTime/DropSelfRealTime). Correct JackPosixThread::StartImp : thread priority setting now done in the RT case only. Correct JackGraphManager::GetBuffer for the "client loop with one connection" case : buffer must be copied. Correct JackInfoShutdownCallback prototype, two new JackClientProcessFailure and JackClientZombie JackStatus code. Correct JackCoreAudio driver when empty strings are given as -C, -P or -d parameter. Better memory allocation error checking on client (library) side. Better memory allocation error checking in ringbuffer.c, weak import improvements. Memory allocation error checking for jack_client_new and jack_client_open (server and client side). Memory allocation error checking in server for RPC. Simplify server temporary mode : now use a JackTemporaryException. Lock/Unlock shared memory segments (to test...). Sync with JACK1 : -r parameter now used for no-realtime, realtime (-R) is now default, usable backend given vie platform. In JackCoreAudio driver, (possibly) clock drift compensation when needed in aggregated devices. In JackCoreAudio driver, clock drift compensation in aggregated devices working. In JackCoreAudio driver, clock drift compensation semantic changed a bit : when on, does not activate if not needed (same clock domain). Sync JackCoreAudioAdapter code with JackCoreAudioDriver.
1.9.5 : Dynamic choice of maximum port number. More robust sample rate change handling code in JackCoreAudioDriver. Devin Anderson patch for Jack FFADO driver issues with lost MIDI bytes between periods (and more). Fix port_rename callback : now both old name and new name are given as parameters. Special code in JackCoreAudio driver to handle completely buggy Digidesign CoreAudio user-land driver. Ensure that client-side message buffer thread calls thread_init callback if/when it is set by the client (backport of JACK1 rev 3838). Check dynamic port-max value. Fix JackCoreMidiDriver::ReadProcAux when ring buffer is full (thanks Devin Anderson). Josh Green ALSA driver capture only patch. When threads are cancelled, the exception has to be rethrown. Use a QUIT notification to properly quit the server channel, the server channel thread can then be 'stopped' instead of 'canceled'. Mario Lang alsa_io time calculation overflow patch. Shared memory manager was calling abort in case of fatal error, now return an error in caller. Change JackEngineProfiling and JackAudioAdapterInterface gnuplot scripts to output SVG instead of PDF.
This is a work in progress but the implementation is now stable enough to be tested. jackdmp has been used successfully with the following applications : Ardour, Hydrogen, Jamin, Qjackctl, Jack-Rack, SooperLooper, AlsaPlayer...
......
......@@ -101,7 +101,6 @@ int JackAudioDriver::Attach()
jack_port_id_t port_index;
char name[JACK_CLIENT_NAME_SIZE + JACK_PORT_NAME_SIZE];
char alias[JACK_CLIENT_NAME_SIZE + JACK_PORT_NAME_SIZE];
unsigned long port_flags = JackPortIsOutput | JackPortIsPhysical | JackPortIsTerminal;
int i;
jack_log("JackAudioDriver::Attach fBufferSize = %ld fSampleRate = %ld", fEngineControl->fBufferSize, fEngineControl->fSampleRate);
......@@ -109,7 +108,7 @@ int JackAudioDriver::Attach()
for (i = 0; i < fCaptureChannels; i++) {
snprintf(alias, sizeof(alias) - 1, "%s:%s:out%d", fAliasName, fCaptureDriverName, i + 1);
snprintf(name, sizeof(name) - 1, "%s:capture_%d", fClientControl.fName, i + 1);
if ((port_index = fGraphManager->AllocatePort(fClientControl.fRefNum, name, JACK_DEFAULT_AUDIO_TYPE, (JackPortFlags)port_flags, fEngineControl->fBufferSize)) == NO_PORT) {
if ((port_index = fGraphManager->AllocatePort(fClientControl.fRefNum, name, JACK_DEFAULT_AUDIO_TYPE, CaptureDriverFlags, fEngineControl->fBufferSize)) == NO_PORT) {
jack_error("driver: cannot register port for %s", name);
return -1;
}
......@@ -120,12 +119,10 @@ int JackAudioDriver::Attach()
jack_log("JackAudioDriver::Attach fCapturePortList[i] port_index = %ld", port_index);
}
port_flags = JackPortIsInput | JackPortIsPhysical | JackPortIsTerminal;
for (i = 0; i < fPlaybackChannels; i++) {
snprintf(alias, sizeof(alias) - 1, "%s:%s:in%d", fAliasName, fPlaybackDriverName, i + 1);
snprintf(name, sizeof(name) - 1, "%s:playback_%d", fClientControl.fName, i + 1);
if ((port_index = fGraphManager->AllocatePort(fClientControl.fRefNum, name, JACK_DEFAULT_AUDIO_TYPE, (JackPortFlags)port_flags, fEngineControl->fBufferSize)) == NO_PORT) {
if ((port_index = fGraphManager->AllocatePort(fClientControl.fRefNum, name, JACK_DEFAULT_AUDIO_TYPE, PlaybackDriverFlags, fEngineControl->fBufferSize)) == NO_PORT) {
jack_error("driver: cannot register port for %s", name);
return -1;
}
......
......@@ -252,7 +252,7 @@ int JackClient::ClientNotify(int refnum, const char* name, int notify, int sync,
break;
case kPortRenameCallback:
jack_log("JackClient::kPortRenameCallback port = %ld");
jack_log("JackClient::kPortRenameCallback port = %ld", value1);
if (fPortRename) {
fPortRename(value1, message, GetGraphManager()->GetPort(value1)->GetName(), fPortRenameArg);
}
......
......@@ -24,7 +24,7 @@
#include "config.h"
#endif
#define VERSION "1.9.5"
#define VERSION "1.9.6"
#define BUFFER_SIZE_MAX 8192
......
......@@ -109,6 +109,10 @@ class SERVER_EXPORT JackDriverClientInterface : public JackDriverInterface, publ
/*!
\brief The base class for drivers.
*/
#define CaptureDriverFlags static_cast<JackPortFlags>(JackPortIsOutput | JackPortIsPhysical | JackPortIsTerminal | JackPortIsActive)
#define PlaybackDriverFlags static_cast<JackPortFlags>(JackPortIsInput | JackPortIsPhysical | JackPortIsTerminal | JackPortIsActive)
#define MonitorDriverFlags static_cast<JackPortFlags>(JackPortIsOutput | JackPortIsActive)
class SERVER_EXPORT JackDriver : public JackDriverClientInterface
{
......
......@@ -35,8 +35,6 @@ Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
namespace Jack
{
#define AssertRefnum(ref) assert(ref >= 0 && ref < CLIENT_NUM);
JackEngine::JackEngine(JackGraphManager* manager,
JackSynchro* table,
JackEngineControl* control)
......@@ -213,28 +211,28 @@ void JackEngine::NotifyClient(int refnum, int event, int sync, const char* messa
JackClientInterface* client = fClientTable[refnum];
// The client may be notified by the RT thread while closing
if (!client) {
jack_log("JackEngine::NotifyClient: client not available anymore");
} else if (client->GetClientControl()->fCallback[event]) {
if (client->ClientNotify(refnum, client->GetClientControl()->fName, event, sync, message, value1, value2) < 0)
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);
if (client) {
if (client && client->GetClientControl()->fCallback[event]) {
/*
Important for internal clients : unlock before calling the notification callbacks.
*/
bool res = fMutex.Unlock();
if (client->ClientNotify(refnum, client->GetClientControl()->fName, event, sync, message, value1, value2) < 0)
jack_error("NotifyClient fails name = %s event = %ld val1 = %ld val2 = %ld", client->GetClientControl()->fName, event, value1, value2);
if (res)
fMutex.Lock();
} else {
jack_log("JackEngine::NotifyClient: no callback for event = %ld", event);
}
}
}
void JackEngine::NotifyClients(int event, int sync, const char* message, int value1, int value2)
void JackEngine::NotifyClients(int event, int sync, const char* message, int value1, int value2)
{
for (int i = 0; i < CLIENT_NUM; i++) {
JackClientInterface* client = fClientTable[i];
if (client) {
if (client->GetClientControl()->fCallback[event]) {
if (client->ClientNotify(i, client->GetClientControl()->fName, event, sync, message, value1, value2) < 0)
jack_error("NotifyClient fails name = %s event = %ld val1 = %ld val2 = %ld", client->GetClientControl()->fName, event, value1, value2);
} else {
jack_log("JackEngine::NotifyClients: no callback for event = %ld", event);
}
}
NotifyClient(i, event, sync, message, value1, value2);
}
}
......@@ -274,8 +272,7 @@ void JackEngine::NotifyRemoveClient(const char* name, int refnum)
void JackEngine::NotifyXRun(jack_time_t callback_usecs, float delayed_usecs)
{
// Use the audio thread => request thread communication channel
fEngineControl->ResetFrameTime(callback_usecs);
fEngineControl->NotifyXRun(delayed_usecs);
fEngineControl->NotifyXRun(callback_usecs, delayed_usecs);
fChannel.Notify(ALL_CLIENTS, kXRunCallback, 0);
}
......@@ -348,14 +345,9 @@ void JackEngine::NotifyActivate(int refnum)
int JackEngine::GetInternalClientName(int refnum, char* name_res)
{
AssertRefnum(refnum);
JackClientInterface* client = fClientTable[refnum];
if (client) {
strncpy(name_res, client->GetClientControl()->fName, JACK_CLIENT_NAME_SIZE);
return 0;
} else {
return -1;
}
strncpy(name_res, client->GetClientControl()->fName, JACK_CLIENT_NAME_SIZE);
return 0;
}
int JackEngine::InternalClientHandle(const char* client_name, int* status, int* int_ref)
......@@ -378,7 +370,6 @@ int JackEngine::InternalClientHandle(const char* client_name, int* status, int*
int JackEngine::InternalClientUnload(int refnum, int* status)
{
AssertRefnum(refnum);
JackClientInterface* client = fClientTable[refnum];
if (client) {
int res = client->Close();
......@@ -592,26 +583,19 @@ error:
// Used for external clients
int JackEngine::ClientExternalClose(int refnum)
{
AssertRefnum(refnum);
JackClientInterface* client = fClientTable[refnum];
if (client) {
fEngineControl->fTransport.ResetTimebase(refnum);
int res = ClientCloseAux(refnum, client, true);
client->Close();
delete client;
return res;
} else {
return -1;
}
fEngineControl->fTransport.ResetTimebase(refnum);
int res = ClientCloseAux(refnum, client, true);
client->Close();
delete client;
return res;
}
// Used for server internal clients or drivers when the RT thread is stopped
int JackEngine::ClientInternalClose(int refnum, bool wait)
{
AssertRefnum(refnum);
JackClientInterface* client = fClientTable[refnum];
return (client) ? ClientCloseAux(refnum, client, wait) : -1;
return ClientCloseAux(refnum, client, wait);
}
int JackEngine::ClientCloseAux(int refnum, JackClientInterface* client, bool wait)
......@@ -656,11 +640,9 @@ int JackEngine::ClientCloseAux(int refnum, JackClientInterface* client, bool wai
int JackEngine::ClientActivate(int refnum, bool is_real_time)
{
AssertRefnum(refnum);
JackClientInterface* client = fClientTable[refnum];
assert(fClientTable[refnum]);
jack_log("JackEngine::ClientActivate ref = %ld name = %s", refnum, client->GetClientControl()->fName);
if (is_real_time)
fGraphManager->Activate(refnum);
......@@ -669,7 +651,30 @@ int JackEngine::ClientActivate(int refnum, bool is_real_time)
jack_error("JackEngine::ClientActivate wait error ref = %ld name = %s", refnum, client->GetClientControl()->fName);
return -1;
} else {
jack_int_t input_ports[PORT_NUM_FOR_CLIENT];
jack_int_t output_ports[PORT_NUM_FOR_CLIENT];
fGraphManager->GetInputPorts(refnum, input_ports);
fGraphManager->GetOutputPorts(refnum, output_ports);
// First add port state to JackPortIsActive
for (int i = 0; (i < PORT_NUM_FOR_CLIENT) && (input_ports[i] != EMPTY); i++) {
fGraphManager->ActivatePort(input_ports[i]);
}
for (int i = 0; (i < PORT_NUM_FOR_CLIENT) && (output_ports[i] != EMPTY); i++) {
fGraphManager->ActivatePort(output_ports[i]);
}
// Notify client
NotifyActivate(refnum);
// Then issue port registration notification
for (int i = 0; (i < PORT_NUM_FOR_CLIENT) && (input_ports[i] != EMPTY); i++) {
NotifyPortRegistation(input_ports[i], true);
}
for (int i = 0; (i < PORT_NUM_FOR_CLIENT) && (output_ports[i] != EMPTY); i++) {
NotifyPortRegistation(output_ports[i], true);
}
return 0;
}
}
......@@ -677,25 +682,30 @@ int JackEngine::ClientActivate(int refnum, bool is_real_time)
// May be called without client
int JackEngine::ClientDeactivate(int refnum)
{
AssertRefnum(refnum);
JackClientInterface* client = fClientTable[refnum];
if (client == NULL)
return -1;
jack_log("JackEngine::ClientDeactivate ref = %ld name = %s", refnum, client->GetClientControl()->fName);
// Disconnect all ports ==> notifications are sent
jack_int_t ports[PORT_NUM_FOR_CLIENT];
int i;
jack_int_t input_ports[PORT_NUM_FOR_CLIENT];
jack_int_t output_ports[PORT_NUM_FOR_CLIENT];
fGraphManager->GetInputPorts(refnum, input_ports);
fGraphManager->GetOutputPorts(refnum, output_ports);
fGraphManager->GetInputPorts(refnum, ports);
for (i = 0; (i < PORT_NUM_FOR_CLIENT) && (ports[i] != EMPTY) ; i++) {
PortDisconnect(refnum, ports[i], ALL_PORTS);
// First disconnect all ports and remove their JackPortIsActive state
for (int i = 0; (i < PORT_NUM_FOR_CLIENT) && (input_ports[i] != EMPTY); i++) {
PortDisconnect(refnum, input_ports[i], ALL_PORTS);
fGraphManager->DeactivatePort(input_ports[i]);
}
fGraphManager->GetOutputPorts(refnum, ports);
for (i = 0; (i < PORT_NUM_FOR_CLIENT) && (ports[i] != EMPTY) ; i++) {
PortDisconnect(refnum, ports[i], ALL_PORTS);
for (int i = 0; (i < PORT_NUM_FOR_CLIENT) && (output_ports[i] != EMPTY); i++) {
PortDisconnect(refnum, output_ports[i], ALL_PORTS);
fGraphManager->DeactivatePort(output_ports[i]);
}
// Then issue port registration notification
for (int i = 0; (i < PORT_NUM_FOR_CLIENT) && (input_ports[i] != EMPTY); i++) {
NotifyPortRegistation(input_ports[i], false);
}
for (int i = 0; (i < PORT_NUM_FOR_CLIENT) && (output_ports[i] != EMPTY); i++) {
NotifyPortRegistation(output_ports[i], false);
}
fGraphManager->Deactivate(refnum);
......@@ -717,8 +727,7 @@ int JackEngine::ClientDeactivate(int refnum)
int JackEngine::PortRegister(int refnum, const char* name, const char *type, unsigned int flags, unsigned int buffer_size, jack_port_id_t* port_index)
{
jack_log("JackEngine::PortRegister ref = %ld name = %s type = %s flags = %d buffer_size = %d", refnum, name, type, flags, buffer_size);
AssertRefnum(refnum);
assert(fClientTable[refnum]);
JackClientInterface* client = fClientTable[refnum];
// Check if port name already exists
if (fGraphManager->GetPort(name) != NO_PORT) {
......@@ -728,7 +737,8 @@ int JackEngine::PortRegister(int refnum, const char* name, const char *type, uns
*port_index = fGraphManager->AllocatePort(refnum, name, type, (JackPortFlags)flags, fEngineControl->fBufferSize);
if (*port_index != NO_PORT) {
NotifyPortRegistation(*port_index, true);
if (client->GetClientControl()->fActive)
NotifyPortRegistation(*port_index, true);
return 0;
} else {
return -1;
......@@ -738,14 +748,14 @@ int JackEngine::PortRegister(int refnum, const char* name, const char *type, uns
int JackEngine::PortUnRegister(int refnum, jack_port_id_t port_index)
{
jack_log("JackEngine::PortUnRegister ref = %ld port_index = %ld", refnum, port_index);
AssertRefnum(refnum);
assert(fClientTable[refnum]);
JackClientInterface* client = fClientTable[refnum];
// Disconnect port ==> notification is sent
PortDisconnect(refnum, port_index, ALL_PORTS);
if (fGraphManager->ReleasePort(refnum, port_index) == 0) {
NotifyPortRegistation(port_index, false);
if (client->GetClientControl()->fActive)
NotifyPortRegistation(port_index, false);
return 0;
} else {
return -1;
......@@ -755,7 +765,6 @@ int JackEngine::PortUnRegister(int refnum, jack_port_id_t port_index)
int JackEngine::PortConnect(int refnum, const char* src, const char* dst)
{
jack_log("JackEngine::PortConnect src = %s dst = %s", src, dst);
AssertRefnum(refnum);
jack_port_id_t port_src, port_dst;
return (fGraphManager->GetTwoPorts(src, dst, &port_src, &port_dst) < 0)
......@@ -766,7 +775,6 @@ int JackEngine::PortConnect(int refnum, const char* src, const char* dst)
int JackEngine::PortConnect(int refnum, jack_port_id_t src, jack_port_id_t dst)
{
jack_log("JackEngine::PortConnect src = %d dst = %d", src, dst);
AssertRefnum(refnum);
JackClientInterface* client;
int ref;
......@@ -802,7 +810,6 @@ int JackEngine::PortConnect(int refnum, jack_port_id_t src, jack_port_id_t dst)
int JackEngine::PortDisconnect(int refnum, const char* src, const char* dst)
{
jack_log("JackEngine::PortDisconnect src = %s dst = %s", src, dst);
AssertRefnum(refnum);
jack_port_id_t port_src, port_dst;
return (fGraphManager->GetTwoPorts(src, dst, &port_src, &port_dst) < 0)
......@@ -813,8 +820,7 @@ int JackEngine::PortDisconnect(int refnum, const char* src, const char* dst)
int JackEngine::PortDisconnect(int refnum, jack_port_id_t src, jack_port_id_t dst)
{
jack_log("JackEngine::PortDisconnect src = %d dst = %d", src, dst);
AssertRefnum(refnum);
if (dst == ALL_PORTS) {
jack_int_t connections[CONNECTION_NUM_FOR_PORT];
......@@ -850,7 +856,6 @@ int JackEngine::PortDisconnect(int refnum, jack_port_id_t src, jack_port_id_t ds
int JackEngine::PortRename(int refnum, jack_port_id_t port, const char* name)
{
AssertRefnum(refnum);
char old_name[JACK_CLIENT_NAME_SIZE + JACK_PORT_NAME_SIZE];
strcpy(old_name, fGraphManager->GetPort(port)->GetName());
fGraphManager->GetPort(port)->SetName(name);
......
......@@ -23,6 +23,7 @@ Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
#include "JackConstants.h"
#include "JackGraphManager.h"
#include "JackSynchro.h"
#include "JackMutex.h"
#include "JackTransportEngine.h"
#include "JackPlatformPlug.h"
......@@ -37,8 +38,10 @@ class JackExternalClient;
\brief Engine description.
*/
class SERVER_EXPORT JackEngine
class SERVER_EXPORT JackEngine : public JackLockAble
{
friend class JackLockedEngine;
private:
JackGraphManager* fGraphManager;
......@@ -71,6 +74,11 @@ class SERVER_EXPORT JackEngine
void NotifyPortConnect(jack_port_id_t src, jack_port_id_t dst, bool onoff);
void NotifyPortRename(jack_port_id_t src, const char* old_name);
void NotifyActivate(int refnum);
bool CheckClient(int refnum)
{
return (refnum >= 0 && refnum < CLIENT_NUM && fClientTable[refnum] != NULL);
}
public:
......
......@@ -81,8 +81,9 @@ void JackEngineControl::ResetRollingUsecs()
fRollingInterval = int(floor((JACK_ENGINE_ROLLING_INTERVAL * 1000.f) / fPeriodUsecs));
}
void JackEngineControl::NotifyXRun(float delayed_usecs)
void JackEngineControl::NotifyXRun(jack_time_t callback_usecs, float delayed_usecs)
{
ResetFrameTime(callback_usecs);
fXrunDelayedUsecs = delayed_usecs;
if (delayed_usecs > fMaxDelayedUsecs)
fMaxDelayedUsecs = delayed_usecs;
......
......@@ -162,7 +162,7 @@ struct SERVER_EXPORT JackEngineControl : public JackShmMem
}
// XRun
void NotifyXRun(float delayed_usecs);
void NotifyXRun(jack_time_t callback_usecs, float delayed_usecs);
void ResetXRun()
{
fMaxDelayedUsecs = 0.f;
......
......@@ -376,6 +376,18 @@ int JackGraphManager::ReleasePort(int refnum, jack_port_id_t port_index)
return res;
}
void JackGraphManager::ActivatePort(jack_port_id_t port_index)
{
JackPort* port = GetPort(port_index);
port->fFlags = (JackPortFlags)(port->fFlags | JackPortIsActive);
}
void JackGraphManager::DeactivatePort(jack_port_id_t port_index)
{
JackPort* port = GetPort(port_index);
port->fFlags = (JackPortFlags)(port->fFlags | ~JackPortIsActive);
}
void JackGraphManager::GetInputPorts(int refnum, jack_int_t* res)
{
JackConnectionManager* manager = WriteNextStateStart();
......
......@@ -65,6 +65,8 @@ class SERVER_EXPORT JackGraphManager : public JackShmMem, public JackAtomicState
// Ports management
jack_port_id_t AllocatePort(int refnum, const char* port_name, const char* port_type, JackPortFlags flags, jack_nframes_t buffer_size);
int ReleasePort(int refnum, jack_port_id_t port_index);
void ActivatePort(jack_port_id_t port_index);
void DeactivatePort(jack_port_id_t port_index);
void GetInputPorts(int refnum, jack_int_t* res);
void GetOutputPorts(int refnum, jack_int_t* res);
void RemoveAllPorts(int refnum);
......@@ -75,7 +77,7 @@ class SERVER_EXPORT JackGraphManager : public JackShmMem, public JackAtomicState
int ComputeTotalLatency(jack_port_id_t port_index);
int ComputeTotalLatencies();
int RequestMonitor(jack_port_id_t port_index, bool onoff);
// Connections management
int Connect(jack_port_id_t src_index, jack_port_id_t dst_index);
int Disconnect(jack_port_id_t src_index, jack_port_id_t dst_index);
......
......@@ -37,7 +37,6 @@ See : http://groups.google.com/group/comp.programming.threads/browse_thread/thre
catch (...) {
// Assuming thread cancellation, must rethrow
throw;
}
*/
......@@ -62,11 +61,12 @@ catch (...) {
throw; \
} \
/*!
\brief Locked Engine, access to methods is serialized using a mutex.
*/
class SERVER_EXPORT JackLockedEngine : public JackLockAble
class SERVER_EXPORT JackLockedEngine
{
private:
......@@ -99,21 +99,21 @@ class SERVER_EXPORT JackLockedEngine : public JackLockAble
int ClientCheck(const char* name, char* name_res, int protocol, int options, int* status)
{
TRY_CALL
JackLock lock(this);
JackLock lock(&fEngine);
return fEngine.ClientCheck(name, name_res, protocol, options, status);
CATCH_EXCEPTION_RETURN
}
int ClientExternalOpen(const char* name, int pid, int* ref, int* shared_engine, int* shared_client, int* shared_graph_manager)
{
TRY_CALL
JackLock lock(this);
JackLock lock(&fEngine);
return fEngine.ClientExternalOpen(name, pid, ref, shared_engine, shared_client, shared_graph_manager);
CATCH_EXCEPTION_RETURN
}
int ClientInternalOpen(const char* name, int* ref, JackEngineControl** shared_engine, JackGraphManager** shared_manager, JackClientInterface* client, bool wait)
{
TRY_CALL
JackLock lock(this);
JackLock lock(&fEngine);
return fEngine.ClientInternalOpen(name, ref, shared_engine, shared_manager, client, wait);
CATCH_EXCEPTION_RETURN
}
......@@ -121,30 +121,30 @@ class SERVER_EXPORT JackLockedEngine : public JackLockAble
int ClientExternalClose(int refnum)
{
TRY_CALL
JackLock lock(this);
return fEngine.ClientExternalClose(refnum);
JackLock lock(&fEngine);
return (fEngine.CheckClient(refnum)) ? fEngine.ClientExternalClose(refnum) : - 1;
CATCH_EXCEPTION_RETURN
}
int ClientInternalClose(int refnum, bool wait)
{
TRY_CALL
JackLock lock(this);
return fEngine.ClientInternalClose(refnum, wait);
JackLock lock(&fEngine);
return (fEngine.CheckClient(refnum)) ? fEngine.ClientInternalClose(refnum, wait) : -1;
CATCH_EXCEPTION_RETURN
}
int ClientActivate(int refnum, bool is_real_time)
{
TRY_CALL
JackLock lock(this);
return fEngine.ClientActivate(refnum, is_real_time);
JackLock lock(&fEngine);
return (fEngine.CheckClient(refnum)) ? fEngine.ClientActivate(refnum, is_real_time) : -1;
CATCH_EXCEPTION_RETURN
}
int ClientDeactivate(int refnum)
{
TRY_CALL
JackLock lock(this);
return fEngine.ClientDeactivate(refnum);
JackLock lock(&fEngine);
return (fEngine.CheckClient(refnum)) ? fEngine.ClientDeactivate(refnum) : -1;
CATCH_EXCEPTION_RETURN
}
......@@ -152,21 +152,22 @@ class SERVER_EXPORT JackLockedEngine : public JackLockAble
int GetInternalClientName(int int_ref, char* name_res)
{
TRY_CALL
JackLock lock(this);
JackLock lock(&fEngine);
return fEngine.GetInternalClientName(int_ref, name_res);
CATCH_EXCEPTION_RETURN
}
int InternalClientHandle(const char* client_name, int* status, int* int_ref)
{
TRY_CALL
JackLock lock(this);
JackLock lock(&fEngine);
return fEngine.InternalClientHandle(client_name, status, int_ref);
CATCH_EXCEPTION_RETURN
}
int InternalClientUnload(int refnum, int* status)
{
TRY_CALL
JackLock lock(this);
JackLock lock(&fEngine);
// Client is tested in fEngine.InternalClientUnload
return fEngine.InternalClientUnload(refnum, status);
CATCH_EXCEPTION_RETURN
}
......@@ -175,53 +176,53 @@ class SERVER_EXPORT JackLockedEngine : public JackLockAble
int PortRegister(int refnum, const char* name, const char *type, unsigned int flags, unsigned int buffer_size, jack_port_id_t* port)
{
TRY_CALL
JackLock lock(this);
return fEngine.PortRegister(refnum, name, type, flags, buffer_size, port);
JackLock lock(&fEngine);
return (fEngine.CheckClient(refnum)) ? fEngine.PortRegister(refnum, name, type, flags, buffer_size, port) : -1;
CATCH_EXCEPTION_RETURN
}
int PortUnRegister(int refnum, jack_port_id_t port)
{
TRY_CALL
JackLock lock(this);
return fEngine.PortUnRegister(refnum, port);
JackLock lock(&fEngine);
return (fEngine.CheckClient(refnum)) ? fEngine.PortUnRegister(refnum, port) : -1;
CATCH_EXCEPTION_RETURN
}
int PortConnect(int refnum, const char* src, const char* dst)
{
TRY_CALL
JackLock lock(this);
return fEngine.PortConnect(refnum, src, dst);
JackLock lock(&fEngine);
return (fEngine.CheckClient(refnum)) ? fEngine.PortConnect(refnum, src, dst) : -1;
CATCH_EXCEPTION_RETURN
}
int PortDisconnect(int refnum, const char* src, const char* dst)
{