Commit 5f68a655 authored by sletz's avatar sletz
Browse files

rebase from trunk 3813:3899

git-svn-id: http://subversion.jackaudio.org/jack/jack2/branches/libjacknet@3900 0c269be4-1314-0410-8aa9-9f06e86f4224
parent 6b765f01
......@@ -3,10 +3,10 @@
---------------------------
Dmitry Baikov
Gabriel M. Beddingfield
Steven Chamberlain
Thom Johansen
Thibault LeMeur
Pieter Palmers
Tom Szilagyi
Andrzej Szombierski
Kjetil S.Matheussen
......@@ -19,12 +19,75 @@ Romain Moret
Florian Faber
Michael Voigt
Torben Hohn
Paul Davis
Paul Davis
Peter L Jones
Devin Anderson
Josh Green
Mario Lang
---------------------------
Jackdmp changes log
---------------------------
2010-01-29 Gabriel M. Beddingfield <gabriel@teuton.org>
* Change JackEngineProfiling and JackAudioAdapterInterface gnuplot scripts to output SVG instead of PDF.
2009-12-15 Stephane Letz <letz@grame.fr>
* Shared memory manager was calling abort in case of fatal error, now return an error in caller.
2009-12-13 Stephane Letz <letz@grame.fr>
* Mario Lang alsa_io time calculation overflow patch.
2009-12-10 Stephane Letz <letz@grame.fr>
* Use a QUIT notification to properly quit the server channel, the server channel thread can then be 'stopped' instead of 'canceled'.
2009-12-09 Stephane Letz <letz@grame.fr>
* When threads are cancelled, the exception has to be rethrown.
2009-12-08 Stephane Letz <letz@grame.fr>
* Josh Green ALSA driver capture only patch.
2009-12-03 Stephane Letz <letz@grame.fr>
* Fix JackCoreMidiDriver::ReadProcAux when ring buffer is full (thanks Devin Anderson).
2009-12-02 Stephane Letz <letz@grame.fr>
* 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.
2009-12-01 Stephane Letz <letz@grame.fr>
* Fix port_rename callback : now both old name and new name are given as parameters.
2009-11-30 Stephane Letz <letz@grame.fr>
* Devin Anderson patch for Jack FFADO driver issues with lost MIDI bytes between periods (and more).
2009-11-29 Stephane Letz <letz@grame.fr>
* More robust sample rate change handling code in JackCoreAudioDriver.
2009-11-24 Stephane Letz <letz@grame.fr>
* Dynamic choice of maximum port number.
2009-11-23 Stephane Letz <letz@grame.fr>
* Peter L Jones patch for NetJack1 compilation on Windows.
2009-11-20 Stephane Letz <letz@grame.fr>
* Version 1.9.5 started.
* Client debugging code improved.
2009-11-18 Stephane Letz <letz@grame.fr>
* Sync JackCoreAudioAdapter code with JackCoreAudioDriver.
......
This diff is collapsed.
......@@ -17,10 +17,11 @@ Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
*/
#include "JackAudioAdapter.h"
#ifdef __APPLE__
#include <TargetConditionals.h>
#endif
#include "JackAudioAdapter.h"
#ifndef TARGET_OS_IPHONE
#include "JackLibSampleRateResampler.h"
#endif
......@@ -73,8 +74,8 @@ namespace Jack
fprintf(file, buffer);
fprintf(file, "\n unset multiplot\n");
fprintf(file, "set output 'AdapterTiming1.pdf\n");
fprintf(file, "set terminal pdf\n");
fprintf(file, "set output 'AdapterTiming1.svg\n");
fprintf(file, "set terminal svg\n");
fprintf(file, "set multiplot\n");
fprintf(file, "set grid\n");
......@@ -85,8 +86,10 @@ namespace Jack
fprintf(file, "plot ");
sprintf(buffer, "\"JackAudioAdapter.log\" using 2 title \"Consumer interrupt period\" with lines,");
fprintf(file, buffer);
sprintf(buffer, "\"JackAudioAdapter.log\" using 3 title \"Producer interrupt period\" with lines");
sprintf(buffer, "\"JackAudioAdapter.log\" using 3 title \"Producer interrupt period\" with lines\n");
fprintf(file, buffer);
fprintf(file, "unset multiplot\n");
fprintf(file, "unset output\n");
fclose(file);
......@@ -105,8 +108,8 @@ namespace Jack
fprintf(file, buffer);
fprintf(file, "\n unset multiplot\n");
fprintf(file, "set output 'AdapterTiming2.pdf\n");
fprintf(file, "set terminal pdf\n");
fprintf(file, "set output 'AdapterTiming2.svg\n");
fprintf(file, "set terminal svg\n");
fprintf(file, "set multiplot\n");
fprintf(file, "set grid\n");
......@@ -117,8 +120,10 @@ namespace Jack
fprintf(file, "plot ");
sprintf(buffer, "\"JackAudioAdapter.log\" using 4 title \"Ratio 1\" with lines,");
fprintf(file, buffer);
sprintf(buffer, "\"JackAudioAdapter.log\" using 5 title \"Ratio 2\" with lines");
sprintf(buffer, "\"JackAudioAdapter.log\" using 5 title \"Ratio 2\" with lines\n");
fprintf(file, buffer);
fprintf(file, "unset multiplot\n");
fprintf(file, "unset output\n");
fclose(file);
......@@ -137,8 +142,8 @@ namespace Jack
fprintf(file, buffer);
fprintf(file, "\n unset multiplot\n");
fprintf(file, "set output 'AdapterTiming3.pdf\n");
fprintf(file, "set terminal pdf\n");
fprintf(file, "set output 'AdapterTiming3.svg\n");
fprintf(file, "set terminal svg\n");
fprintf(file, "set multiplot\n");
fprintf(file, "set grid\n");
......@@ -149,8 +154,10 @@ namespace Jack
fprintf(file, "plot ");
sprintf(buffer, "\"JackAudioAdapter.log\" using 6 title \"Frames position in consumer ringbuffer\" with lines,");
fprintf(file, buffer);
sprintf(buffer, "\"JackAudioAdapter.log\" using 7 title \"Frames position in producer ringbuffer\" with lines");
sprintf(buffer, "\"JackAudioAdapter.log\" using 7 title \"Frames position in producer ringbuffer\" with lines\n");
fprintf(file, buffer);
fprintf(file, "unset multiplot\n");
fprintf(file, "unset output\n");
fclose(file);
}
......
......@@ -254,7 +254,7 @@ int JackClient::ClientNotify(int refnum, const char* name, int notify, int sync,
case kPortRenameCallback:
jack_log("JackClient::kPortRenameCallback port = %ld");
if (fPortRename) {
fPortRename(value1, GetGraphManager()->GetPort(value1)->GetName(), fPortRenameArg);
fPortRename(value1, message, GetGraphManager()->GetPort(value1)->GetName(), fPortRenameArg);
}
break;
......@@ -848,6 +848,8 @@ int JackClient::SetInitCallback(JackThreadInitCallback callback, void *arg)
} else {
fInitArg = arg;
fInit = callback;
/* make sure that the message buffer thread is initialized too */
JackMessageBuffer::fInstance->SetInitCallback(callback, arg);
return 0;
}
}
......
......@@ -33,7 +33,7 @@ JackConnectionManager::JackConnectionManager()
int i;
jack_log("JackConnectionManager::InitConnections size = %ld ", sizeof(JackConnectionManager));
for (i = 0; i < PORT_NUM; i++) {
for (i = 0; i < PORT_NUM_MAX; i++) {
fConnection[i].Init();
}
......
......@@ -353,11 +353,21 @@ struct JackClientTiming
jack_time_t fFinishedAt;
jack_client_state_t fStatus;
JackClientTiming(): fSignaledAt(0), fAwakeAt(0), fFinishedAt(0), fStatus(NotTriggered)
{}
JackClientTiming()
{
Init();
}
~JackClientTiming()
{}
void Init()
{
fSignaledAt = 0;
fAwakeAt = 0;
fFinishedAt = 0;
fStatus = NotTriggered;
}
} POST_PACKED_STRUCTURE;
/*!
......@@ -379,7 +389,7 @@ class SERVER_EXPORT JackConnectionManager
private:
JackFixedArray<CONNECTION_NUM_FOR_PORT> fConnection[PORT_NUM]; /*! Connection matrix: list of connected ports for a given port: needed to compute Mix buffer */
JackFixedArray<CONNECTION_NUM_FOR_PORT> fConnection[PORT_NUM_MAX]; /*! Connection matrix: list of connected ports for a given port: needed to compute Mix buffer */
JackFixedArray1<PORT_NUM_FOR_CLIENT> fInputPort[CLIENT_NUM]; /*! Table of input port per refnum : to find a refnum for a given port */
JackFixedArray<PORT_NUM_FOR_CLIENT> fOutputPort[CLIENT_NUM]; /*! Table of output port per refnum : to find a refnum for a given port */
JackFixedMatrix<CLIENT_NUM> fConnectionRef; /*! Table of port connections by (refnum , refnum) */
......
......@@ -24,7 +24,7 @@
#include "config.h"
#endif
#define VERSION "1.9.4"
#define VERSION "1.9.5"
#define BUFFER_SIZE_MAX 8192
......@@ -38,6 +38,8 @@
#define PORT_NUM 2048
#endif
#define PORT_NUM_MAX 4096 // The "max" value for ports used in connection manager, although port number in graph manager is dynamic
#define DRIVER_PORT_NUM 256
#ifndef PORT_NUM_FOR_CLIENT
......
......@@ -82,7 +82,11 @@ struct jackctl_server
/* uint32_t, clock source type */
union jackctl_parameter_value clock_source;
union jackctl_parameter_value default_clock_source;
/* uint32_t, max port number */
union jackctl_parameter_value port_max;
union jackctl_parameter_value default_port_max;
/* bool */
union jackctl_parameter_value replace_registry;
union jackctl_parameter_value default_replace_registry;
......@@ -741,6 +745,20 @@ EXPORT jackctl_server_t * jackctl_server_create(
{
goto fail_free_parameters;
}
value.ui = PORT_NUM;
if (jackctl_add_parameter(
&server_ptr->parameters,
"port-max",
"Maximum number of ports.",
"",
JackParamUInt,
&server_ptr->port_max,
&server_ptr->default_port_max,
value) == NULL)
{
goto fail_free_parameters;
}
value.b = false;
if (jackctl_add_parameter(
......@@ -864,15 +882,21 @@ jackctl_server_start(
if (!server_ptr->realtime.b && server_ptr->client_timeout.i == 0)
server_ptr->client_timeout.i = 500; /* 0.5 sec; usable when non realtime. */
/* check port max value before allocating server */
if (server_ptr->port_max.ui > PORT_NUM_MAX) {
jack_error("JACK server started with too much ports %d (when port max can be %d)", server_ptr->port_max.ui, PORT_NUM_MAX);
goto fail;
}
/* 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->port_max.ui,
server_ptr->verbose.b,
(jack_timer_type_t)server_ptr->clock_source.ui,
server_ptr->name.str);
......
......@@ -19,6 +19,7 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
#include "JackDebugClient.h"
#include "JackEngineControl.h"
#include "JackException.h"
#include "JackError.h"
#include "JackTime.h"
#include <iostream>
......@@ -55,9 +56,9 @@ JackDebugClient::~JackDebugClient()
*fStream << setw(5) << "- Total number of instantiated port : " << fTotalPortNumber << endl;
*fStream << setw(5) << "- Number of port remaining open when exiting client : " << fOpenPortNumber << endl;
if (fOpenPortNumber != 0)
*fStream << "!!! WARNING !!! Some ports have not been unregistrated ! Incorrect exiting !" << endl;
*fStream << "!!! WARNING !!! Some ports have not been unregistered ! Incorrect exiting !" << endl;
if (fIsDeactivated != fIsActivated)
*fStream << "!!! ERROR !!! Client seem do not perform symetric activation-deactivation ! (not the same number of activate and deactivate)" << endl;
*fStream << "!!! ERROR !!! Client seem to not perform symetric activation-deactivation ! (not the same number of activate and deactivate)" << endl;
if (fIsClosed == 0)
*fStream << "!!! ERROR !!! Client have not been closed with jack_client_close() !" << endl;
......@@ -68,9 +69,9 @@ JackDebugClient::~JackDebugClient()
*fStream << setw(5) << "- Name : " << fPortList[i].name << endl;
*fStream << setw(5) << "- idport : " << fPortList[i].idport << endl;
*fStream << setw(5) << "- IsConnected : " << fPortList[i].IsConnected << endl;
*fStream << setw(5) << "- IsUnregistrated : " << fPortList[i].IsUnregistrated << endl;
if (fPortList[i].IsUnregistrated == 0)
*fStream << "!!! WARNING !!! Port have not been unregistrated ! Incorrect exiting !" << endl;
*fStream << setw(5) << "- IsUnregistered : " << fPortList[i].IsUnregistered << endl;
if (fPortList[i].IsUnregistered == 0)
*fStream << "!!! WARNING !!! Port have not been unregistered ! Incorrect exiting !" << endl;
}
*fStream << "delete object JackDebugClient : end of tracing" << endl;
delete fStream;
......@@ -106,33 +107,39 @@ int JackDebugClient::Open(const char* server_name, const char* name, jack_option
int JackDebugClient::Close()
{
fIsClosed++;
*fStream << "Client '" << fClientName << "' was closed" << endl;
return fClient->Close();
int res = fClient->Close();
fIsClosed++;
return res;
}
void JackDebugClient::CheckClient() const
void JackDebugClient::CheckClient(const char* function_name) const
{
*fStream << "CheckClient : " << function_name << ", calling thread : " << pthread_self() << endl;
if (fIsClosed > 0) {
*fStream << "!!! ERROR !!! : Accessing a client '" << fClientName << "' already closed !" << endl;
*fStream << "!!! ERROR !!! : Accessing a client '" << fClientName << "' already closed " << "from " << function_name << endl;
*fStream << "This is likely to cause crash !'" << endl;
#ifdef __APPLE__
// Debugger();
#endif
}
}
pthread_t JackDebugClient::GetThreadID()
{
CheckClient();
CheckClient("GetThreadID");
return fClient->GetThreadID();
}
JackGraphManager* JackDebugClient::GetGraphManager() const
{
CheckClient();
CheckClient("GetGraphManager");
return fClient->GetGraphManager();
}
JackEngineControl* JackDebugClient::GetEngineControl() const
{
CheckClient();
CheckClient("GetEngineControl");
return fClient->GetEngineControl();
}
/*!
......@@ -141,13 +148,13 @@ JackEngineControl* JackDebugClient::GetEngineControl() const
int JackDebugClient::ClientNotify(int refnum, const char* name, int notify, int sync, const char* message, int value1, int value2)
{
CheckClient();
CheckClient("ClientNotify");
return fClient->ClientNotify( refnum, name, notify, sync, message, value1, value2);
}
int JackDebugClient::Activate()
{
CheckClient();
CheckClient("Activate");
int res = fClient->Activate();
fIsActivated++;
if (fIsDeactivated)
......@@ -160,7 +167,7 @@ int JackDebugClient::Activate()
int JackDebugClient::Deactivate()
{
CheckClient();
CheckClient("Deactivate");
int res = fClient->Deactivate();
fIsDeactivated++;
if (fIsActivated == 0)
......@@ -177,7 +184,7 @@ int JackDebugClient::Deactivate()
int JackDebugClient::PortRegister(const char* port_name, const char* port_type, unsigned long flags, unsigned long buffer_size)
{
CheckClient();
CheckClient("PortRegister");
int res = fClient->PortRegister(port_name, port_type, flags, buffer_size);
if (res <= 0) {
*fStream << "Client '" << fClientName << "' try port register ('" << port_name << "') and server return error " << res << " ." << endl;
......@@ -186,7 +193,7 @@ int JackDebugClient::PortRegister(const char* port_name, const char* port_type,
fPortList[fTotalPortNumber].idport = res;
strcpy(fPortList[fTotalPortNumber].name, port_name);
fPortList[fTotalPortNumber].IsConnected = 0;
fPortList[fTotalPortNumber].IsUnregistrated = 0;
fPortList[fTotalPortNumber].IsUnregistered = 0;
} else {
*fStream << "!!! WARNING !!! History is full : no more port history will be recorded." << endl;
}
......@@ -199,42 +206,42 @@ int JackDebugClient::PortRegister(const char* port_name, const char* port_type,
int JackDebugClient::PortUnRegister(jack_port_id_t port_index)
{
CheckClient();
CheckClient("PortUnRegister");
int res = fClient->PortUnRegister(port_index);
fOpenPortNumber--;
int i;
for (i = (fTotalPortNumber - 1); i >= 0; i--) { // We search the record into the history
if (fPortList[i].idport == port_index) { // We found the last record
if (fPortList[i].IsUnregistrated != 0)
if (fPortList[i].IsUnregistered != 0)
*fStream << "!!! ERROR !!! : '" << fClientName << "' id deregistering port '" << fPortList[i].name << "' that have already been unregistered !" << endl;
fPortList[i].IsUnregistrated++;
fPortList[i].IsUnregistered++;
break;
}
}
if (i == 0) // Port is not found
*fStream << "JackClientDebug : PortUnregister : port " << port_index << " was not previously registered !" << endl;
if (res != 0)
*fStream << "Client '" << fClientName << "' try to do PortUnregister and server return " << res << " )." << endl;
*fStream << "Client '" << fClientName << "' try to do PortUnregister and server return " << res << endl;
*fStream << "Client '" << fClientName << "' unregister port '" << port_index << "'." << endl;
return res;
}
int JackDebugClient::PortConnect(const char* src, const char* dst)
{
CheckClient();
CheckClient("PortConnect");
if (!fIsActivated)
*fStream << "!!! ERROR !!! Trying to connect a port ( " << src << " to " << dst << ") while the client has not been activated !" << endl;
int i;
int res = fClient->PortConnect( src, dst);
for (i = (fTotalPortNumber - 1); i >= 0; i--) { // We search the record into the history
if (strcmp(fPortList[i].name, src) == 0) { // We found the last record in sources
if (fPortList[i].IsUnregistrated != 0)
if (fPortList[i].IsUnregistered != 0)
*fStream << "!!! ERROR !!! Connecting port " << src << " previoulsy unregistered !" << endl;
fPortList[i].IsConnected++;
*fStream << "Connecting port " << src << " to " << dst << ". ";
break;
} else if (strcmp(fPortList[i].name, dst) == 0 ) { // We found the record in dest
if (fPortList[i].IsUnregistrated != 0)
if (fPortList[i].IsUnregistered != 0)
*fStream << "!!! ERROR !!! Connecting port " << dst << " previoulsy unregistered !" << endl;
fPortList[i].IsConnected++;
*fStream << "Connecting port " << src << " to " << dst << ". ";
......@@ -251,20 +258,20 @@ int JackDebugClient::PortConnect(const char* src, const char* dst)
int JackDebugClient::PortDisconnect(const char* src, const char* dst)
{
CheckClient();
CheckClient("PortDisconnect");
if (!fIsActivated)
*fStream << "!!! ERROR !!! Trying to disconnect a port ( " << src << " to " << dst << ") while the client has not been activated !" << endl;
int res = fClient->PortDisconnect( src, dst);
int i;
for (i = (fTotalPortNumber - 1); i >= 0; i--) { // We search the record into the history
if (strcmp(fPortList[i].name, src) == 0) { // We found the record in sources
if (fPortList[i].IsUnregistrated != 0)
if (fPortList[i].IsUnregistered != 0)
*fStream << "!!! ERROR !!! : Disconnecting port " << src << " previoulsy unregistered !" << endl;
fPortList[i].IsConnected--;
*fStream << "disconnecting port " << src << ". ";
break;
} else if (strcmp(fPortList[i].name, dst) == 0 ) { // We found the record in dest
if (fPortList[i].IsUnregistrated != 0)
if (fPortList[i].IsUnregistered != 0)
*fStream << "!!! ERROR !!! : Disonnecting port " << dst << " previoulsy unregistered !" << endl;
fPortList[i].IsConnected--;
*fStream << "disconnecting port " << dst << ". ";
......@@ -281,14 +288,14 @@ int JackDebugClient::PortDisconnect(const char* src, const char* dst)
int JackDebugClient::PortDisconnect(jack_port_id_t src)
{
CheckClient();
CheckClient("PortDisconnect");
if (!fIsActivated)
*fStream << "!!! ERROR !!! : Trying to disconnect port " << src << " while that client has not been activated !" << endl;
int res = fClient->PortDisconnect(src);
int i;
for (i = (fTotalPortNumber - 1); i >= 0; i--) { // We search the record into the history
if (fPortList[i].idport == src) { // We found the record in sources
if (fPortList[i].IsUnregistrated != 0)
if (fPortList[i].IsUnregistered != 0)
*fStream << "!!! ERROR !!! : Disconnecting port " << src << " previoulsy unregistered !" << endl;
fPortList[i].IsConnected--;
*fStream << "Disconnecting port " << src << ". " << endl;
......@@ -305,7 +312,7 @@ int JackDebugClient::PortDisconnect(jack_port_id_t src)
int JackDebugClient::PortIsMine(jack_port_id_t port_index)
{
CheckClient();
CheckClient("PortIsMine");
return fClient->PortIsMine(port_index);
}
......@@ -315,13 +322,13 @@ int JackDebugClient::PortIsMine(jack_port_id_t port_index)
int JackDebugClient::SetBufferSize(jack_nframes_t buffer_size)
{
CheckClient();
CheckClient("SetBufferSize");
return fClient->SetBufferSize(buffer_size);
}
int JackDebugClient::SetFreeWheel(int onoff)
{
CheckClient();
CheckClient("SetFreeWheel");
if (onoff && fFreewheel)
*fStream << "!!! ERROR !!! : Freewheel setup seems incorrect : set = ON while FW is already ON " << endl;
if (!onoff && !fFreewheel)
......@@ -348,61 +355,61 @@ void JackDebugClient::ShutDown()
int JackDebugClient::ReleaseTimebase()
{
CheckClient();
CheckClient("ReleaseTimebase");
return fClient->ReleaseTimebase();
}
int JackDebugClient::SetSyncCallback(JackSyncCallback sync_callback, void* arg)
{
CheckClient();
CheckClient("SetSyncCallback");
return fClient->SetSyncCallback(sync_callback, arg);
}
int JackDebugClient::SetSyncTimeout(jack_time_t timeout)
{
CheckClient();
CheckClient("SetSyncTimeout");
return fClient->SetSyncTimeout(timeout);
}
int JackDebugClient::SetTimebaseCallback(int conditional, JackTimebaseCallback timebase_callback, void* arg)
{
CheckClient();
CheckClient("SetTimebaseCallback");
return fClient->SetTimebaseCallback( conditional, timebase_callback, arg);
}
void JackDebugClient::TransportLocate(jack_nframes_t frame)
{
CheckClient();
CheckClient("TransportLocate");
fClient->TransportLocate(frame);
}
jack_transport_state_t JackDebugClient::TransportQuery(jack_position_t* pos)
{
CheckClient();
CheckClient("TransportQuery");
return fClient->TransportQuery(pos);
}
jack_nframes_t JackDebugClient::GetCurrentTransportFrame()
{
CheckClient();
CheckClient("GetCurrentTransportFrame");
return fClient->GetCurrentTransportFrame();
}
int JackDebugClient::TransportReposition(jack_position_t* pos)
{
CheckClient();
CheckClient("TransportReposition");
return fClient->TransportReposition(pos);
}
void JackDebugClient::TransportStart()
{
CheckClient();
CheckClient("TransportStart");
fClient->TransportStart();
}
void JackDebugClient::TransportStop()
{
CheckClient();
CheckClient("TransportStop");
fClient->TransportStop();
}
......@@ -412,13 +419,13 @@ void JackDebugClient::TransportStop()
void JackDebugClient::OnShutdown(JackShutdownCallback callback, void *arg)
{
CheckClient();
CheckClient("OnShutdown");
fClient->OnShutdown(callback, arg);