Commit 1a44ede4 authored by Torben Hohn's avatar Torben Hohn
Browse files

fix tabs and convert em to spaces.

parent b623e040
......@@ -108,8 +108,8 @@ extern "C"
JackPortConnectCallback
connect_callback, void *arg);
EXPORT int jack_set_port_rename_callback (jack_client_t *,
JackPortRenameCallback
rename_callback, void *arg);
JackPortRenameCallback
rename_callback, void *arg);
EXPORT int jack_set_graph_order_callback (jack_client_t *,
JackGraphOrderCallback graph_callback,
void *);
......@@ -217,7 +217,7 @@ extern "C"
EXPORT int jack_client_create_thread (jack_client_t* client,
pthread_t *thread,
int priority,
int realtime, // boolean
int realtime, // boolean
thread_routine routine,
void *arg);
EXPORT int jack_drop_real_time_scheduling (pthread_t thread);
......@@ -1686,7 +1686,7 @@ EXPORT int jack_acquire_real_time_scheduling(pthread_t thread, int priority)
EXPORT int jack_client_create_thread(jack_client_t* client,
pthread_t *thread,
int priority,
int realtime, /* boolean */
int realtime, /* boolean */
thread_routine routine,
void *arg)
{
......@@ -1766,8 +1766,8 @@ EXPORT jack_intclient_t jack_internal_client_handle(jack_client_t* ext_client, c
return 0;
} else {
jack_status_t my_status;
if (status == NULL) /* no status from caller? */
status = &my_status; /* use local status word */
if (status == NULL) /* no status from caller? */
status = &my_status; /* use local status word */
*status = (jack_status_t)0;
return client->InternalClientHandle(client_name, status);
}
......@@ -1786,8 +1786,8 @@ EXPORT jack_intclient_t jack_internal_client_load_aux(jack_client_t* ext_client,
jack_varargs_t va;
jack_status_t my_status;
if (status == NULL) /* no status from caller? */
status = &my_status; /* use local status word */
if (status == NULL) /* no status from caller? */
status = &my_status; /* use local status word */
*status = (jack_status_t)0;
/* validate parameters */
......@@ -1911,7 +1911,7 @@ EXPORT void jack_session_event_free(jack_session_event_t* ev)
free((void *)ev->session_dir);
free((void *)ev->client_uuid);
if (ev->command_line)
free(ev->command_line);
free(ev->command_line);
free(ev);
}
......@@ -1964,16 +1964,16 @@ EXPORT void jack_session_commands_free( jack_session_command_t *cmds )
{
int i=0;
while(1) {
if (cmds[i].client_name)
free ((char *)cmds[i].client_name);
if (cmds[i].command)
free ((char *)cmds[i].command);
if (cmds[i].uuid)
free ((char *)cmds[i].uuid);
else
break;
i += 1;
if (cmds[i].client_name)
free ((char *)cmds[i].client_name);
if (cmds[i].command)
free ((char *)cmds[i].command);
if (cmds[i].uuid)
free ((char *)cmds[i].uuid);
else
break;
i += 1;
}
free(cmds);
......
......@@ -127,23 +127,23 @@ class JackClientChannelInterface
virtual void InternalClientUnload(int refnum, int int_ref, int* status, int* result)
{}
virtual void SessionNotify(int refnum, const char* target, jack_session_event_type_t type, const char *path, jack_session_command_t **result)
{}
virtual void SessionNotify(int refnum, const char* target, jack_session_event_type_t type, const char *path, jack_session_command_t **result)
{}
virtual void SessionReply(int refnum, int *result)
{}
virtual void SessionReply(int refnum, int *result)
{}
virtual void GetUUIDForClientName( int refnum, const char *client_name, char *uuid_res, int *result )
{}
virtual void GetUUIDForClientName( int refnum, const char *client_name, char *uuid_res, int *result )
{}
virtual void GetClientNameForUUID( int refnum, const char *uuid, char *name_res, int *result )
{}
virtual void GetClientNameForUUID( int refnum, const char *uuid, char *name_res, int *result )
{}
virtual void ReserveClientName( int refnum, const char *client_name, const char *uuid, int *result )
{}
virtual void ReserveClientName( int refnum, const char *client_name, const char *uuid, int *result )
{}
virtual bool IsChannelThread()
{ return false; }
virtual bool IsChannelThread()
{ return false; }
};
}
......
......@@ -112,9 +112,9 @@ pthread_t JackClient::GetThreadID()
}
/*!
In "async" mode, the server does not synchronize itself on the output drivers, thus it would never "consume" the activations.
The synchronization primitives for drivers are setup in "flush" mode that to not keep unneeded activations.
Drivers synchro are setup in "flush" mode if server is "async" and NOT freewheel.
In "async" mode, the server does not synchronize itself on the output drivers, thus it would never "consume" the activations.
The synchronization primitives for drivers are setup in "flush" mode that to not keep unneeded activations.
Drivers synchro are setup in "flush" mode if server is "async" and NOT freewheel.
*/
void JackClient::SetupDriverSync(bool freewheel)
{
......@@ -170,7 +170,7 @@ int JackClient::ClientNotify(int refnum, const char* name, int notify, int sync,
case kAddClient:
jack_log("JackClient::kAddClient fName = %s name = %s", GetClientControl()->fName, name);
if (fClientRegistration && strcmp(GetClientControl()->fName, name) != 0) { // Don't call the callback for the registering client itself
if (fClientRegistration && strcmp(GetClientControl()->fName, name) != 0) { // Don't call the callback for the registering client itself
fClientRegistration(name, 1, fClientRegistrationArg);
}
break;
......@@ -276,23 +276,23 @@ int JackClient::ClientNotify(int refnum, const char* name, int notify, int sync,
case kSessionCallback:
jack_log("JackClient::kSessionCallback");
if (fSession) {
jack_session_event_t *event = (jack_session_event_t *) malloc( sizeof(jack_session_event_t) );
char uuid_buf[32];
event->type = (jack_session_event_type_t) value1;
event->session_dir = strdup( message );
event->command_line = NULL;
event->flags = (jack_session_flags_t) 0;
snprintf( uuid_buf, sizeof(uuid_buf), "%d", GetClientControl()->fSessionID );
event->client_uuid = strdup( uuid_buf );
jack_session_event_t *event = (jack_session_event_t *) malloc( sizeof(jack_session_event_t) );
char uuid_buf[32];
event->type = (jack_session_event_type_t) value1;
event->session_dir = strdup( message );
event->command_line = NULL;
event->flags = (jack_session_flags_t) 0;
snprintf( uuid_buf, sizeof(uuid_buf), "%d", GetClientControl()->fSessionID );
event->client_uuid = strdup( uuid_buf );
fImmediateSessionReply = false;
fImmediateSessionReply = false;
fSession(event, fSessionArg);
if (fImmediateSessionReply)
res = 1;
else
res = 2;
if (fImmediateSessionReply)
res = 1;
else
res = 2;
}
break;
}
......@@ -303,7 +303,7 @@ int JackClient::ClientNotify(int refnum, const char* name, int notify, int sync,
/*!
\brief We need to start thread before activating in the server, otherwise the FW driver
connected to the client may not be activated.
connected to the client may not be activated.
*/
int JackClient::Activate()
{
......@@ -433,7 +433,7 @@ inline void JackClient::ExecuteThread()
while (true) {
CycleWaitAux();
CycleSignalAux(CallProcessCallback());
}
}
}
inline jack_nframes_t JackClient::CycleWaitAux()
......@@ -1010,7 +1010,7 @@ int JackClient::SetSessionCallback(JackSessionCallback callback, void *arg)
jack_error("You cannot set callbacks on an active client");
return -1;
} else {
GetClientControl()->fCallback[kSessionCallback] = (callback != NULL);
GetClientControl()->fCallback[kSessionCallback] = (callback != NULL);
fSessionArg = arg;
fSession = callback;
return 0;
......@@ -1088,18 +1088,18 @@ jack_session_command_t *JackClient::SessionNotify( const char* target, jack_sess
int JackClient::SessionReply( jack_session_event_t *ev )
{
if (ev->command_line) {
strncpy( GetClientControl()->fSessionCommand, ev->command_line, sizeof(GetClientControl()->fSessionCommand) );
strncpy( GetClientControl()->fSessionCommand, ev->command_line, sizeof(GetClientControl()->fSessionCommand) );
} else {
GetClientControl()->fSessionCommand[0] = '\0';
GetClientControl()->fSessionCommand[0] = '\0';
}
GetClientControl()->fSessionFlags = ev->flags;
jack_log( "JackClient::SessionReply... we are here" );
if (fChannel->IsChannelThread()) {
jack_log( "JackClient::SessionReply... in callback reply" );
fImmediateSessionReply = true;
return 0;
jack_log( "JackClient::SessionReply... in callback reply" );
fImmediateSessionReply = true;
return 0;
}
jack_log( "JackClient::SessionReply... out of cb" );
......@@ -1116,7 +1116,7 @@ char* JackClient::GetUUIDForClientName(const char* client_name)
fChannel->GetUUIDForClientName( GetClientControl()->fRefNum, client_name, uuid_res, &result);
if(result)
return NULL;
return NULL;
return strdup(uuid_res);
}
......@@ -1128,7 +1128,7 @@ char* JackClient::GetClientNameForUUID(const char* uuid)
fChannel->GetClientNameForUUID(GetClientControl()->fRefNum, uuid, name_res, &result);
if(result)
return NULL;
return NULL;
return strdup(name_res);
}
......
......@@ -93,7 +93,7 @@ class JackClient : public JackClientInterface, public JackRunnableInterface
JackSynchro* fSynchroTable;
std::list<jack_port_id_t> fPortList;
bool fImmediateSessionReply;
bool fImmediateSessionReply;
int StartThread();
void SetupDriverSync(bool freewheel);
......@@ -190,9 +190,9 @@ class JackClient : public JackClientInterface, public JackRunnableInterface
void CycleSignal(int status);
int SetProcessThread(JackThreadCallback fun, void *arg);
// Session api
virtual jack_session_command_t *SessionNotify(const char *target, jack_session_event_type_t type, const char *path);
virtual int SessionReply(jack_session_event_t *ev);
// Session api
virtual jack_session_command_t *SessionNotify(const char *target, jack_session_event_type_t type, const char *path);
virtual int SessionReply(jack_session_event_t *ev);
char* GetUUIDForClientName(const char* client_name);
char* GetClientNameForUUID(const char* uuid);
int ReserveClientName(const char *name, const char* uuid);
......
......@@ -84,7 +84,7 @@ struct JackClientControl : public JackShmMemAble
fTransportTimebase = false;
fActive = false;
fSessionID = uuid;
fSessionID = uuid;
}
} POST_PACKED_STRUCTURE;
......
......@@ -450,21 +450,21 @@ sigset_t
jackctl_setup_signals(
unsigned int flags)
{
if ((waitEvent = CreateEvent(NULL, FALSE, FALSE, NULL)) == NULL) {
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(SIGINT, do_nothing_handler);
(void) signal(SIGABRT, do_nothing_handler);
(void) signal(SIGTERM, do_nothing_handler);
return (sigset_t)waitEvent;
return (sigset_t)waitEvent;
}
void jackctl_wait_signals(sigset_t signals)
{
if (WaitForSingleObject(waitEvent, INFINITE) != WAIT_OBJECT_0) {
if (WaitForSingleObject(waitEvent, INFINITE) != WAIT_OBJECT_0) {
jack_error("WaitForSingleObject fails err = %ld", GetLastError());
}
}
......
......@@ -36,8 +36,8 @@ namespace Jack
JackDebugClient::JackDebugClient(JackClient * client)
{
fTotalPortNumber = 1; // The total number of port opened and maybe closed. Historical view.
fOpenPortNumber = 0; // The current number of opened port.
fTotalPortNumber = 1; // The total number of port opened and maybe closed. Historical view.
fOpenPortNumber = 0; // The current number of opened port.
fIsActivated = 0;
fIsDeactivated = 0;
fIsClosed = 0;
......@@ -210,8 +210,8 @@ int JackDebugClient::PortUnRegister(jack_port_id_t port_index)
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
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].IsUnregistered != 0)
*fStream << "!!! ERROR !!! : '" << fClientName << "' id deregistering port '" << fPortList[i].name << "' that have already been unregistered !" << endl;
fPortList[i].IsUnregistered++;
......@@ -233,8 +233,8 @@ int JackDebugClient::PortConnect(const char* src, const char* dst)
*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
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].IsUnregistered != 0)
*fStream << "!!! ERROR !!! Connecting port " << src << " previoulsy unregistered !" << endl;
fPortList[i].IsConnected++;
......@@ -293,8 +293,8 @@ int JackDebugClient::PortDisconnect(jack_port_id_t src)
*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
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].IsUnregistered != 0)
*fStream << "!!! ERROR !!! : Disconnecting port " << src << " previoulsy unregistered !" << endl;
fPortList[i].IsConnected--;
......
......@@ -53,8 +53,8 @@ class JackDebugClient : public JackClient
JackClient* fClient;
std::ofstream* fStream;
PortFollower fPortList[MAX_PORT_HISTORY]; // Arbitrary value... To be tuned...
int fTotalPortNumber; // The total number of port opened and maybe closed. Historical view.
int fOpenPortNumber; // The current number of opened port.
int fTotalPortNumber; // The total number of port opened and maybe closed. Historical view.
int fOpenPortNumber; // The current number of opened port.
int fIsActivated;
int fIsDeactivated;
int fIsClosed;
......
......@@ -139,7 +139,7 @@ void JackEngine::ReleaseRefnum(int ref)
void JackEngine::ProcessNext(jack_time_t cur_cycle_begin)
{
fLastSwitchUsecs = cur_cycle_begin;
if (fGraphManager->RunNextGraph()) // True if the graph actually switched to a new state
if (fGraphManager->RunNextGraph()) // True if the graph actually switched to a new state
fChannel.Notify(ALL_CLIENTS, kGraphOrderCallback, 0);
fSignal.Signal(); // Signal for threads waiting for next cycle
}
......@@ -431,7 +431,7 @@ bool JackEngine::GenerateUniqueName(char* name)
if (length > JACK_CLIENT_NAME_SIZE - 4) {
jack_error("%s exists and is too long to make unique", name);
return true; /* failure */
return true; /* failure */
}
/* generate a unique name by appending "-01".."-99" */
......@@ -466,8 +466,8 @@ bool JackEngine::ClientCheckName(const char* name)
}
for (std::map<int,std::string>::iterator i=fReservationMap.begin(); i!=fReservationMap.end(); i++) {
if (i->second == name)
return true;
if (i->second == name)
return true;
}
return false;
......@@ -481,13 +481,13 @@ int JackEngine::GetNewUUID()
void JackEngine::EnsureUUID(int uuid)
{
if (uuid > fMaxUUID)
fMaxUUID = uuid+1;
fMaxUUID = uuid+1;
for (int i = 0; i < CLIENT_NUM; i++) {
JackClientInterface* client = fClientTable[i];
if (client && (client->GetClientControl()->fSessionID==uuid)) {
client->GetClientControl()->fSessionID = GetNewUUID();
}
client->GetClientControl()->fSessionID = GetNewUUID();
}
}
}
......@@ -519,18 +519,18 @@ int JackEngine::ClientExternalOpen(const char* name, int pid, int uuid, int* ref
char real_name[JACK_CLIENT_NAME_SIZE+1];
if (uuid < 0) {
uuid = GetNewUUID();
strncpy( real_name, name, JACK_CLIENT_NAME_SIZE );
uuid = GetNewUUID();
strncpy( real_name, name, JACK_CLIENT_NAME_SIZE );
} else {
std::map<int,std::string>::iterator res = fReservationMap.find(uuid);
if (res != fReservationMap.end()) {
strncpy( real_name, res->second.c_str(), JACK_CLIENT_NAME_SIZE );
fReservationMap.erase(uuid);
} else {
strncpy( real_name, name, JACK_CLIENT_NAME_SIZE );
}
EnsureUUID(uuid);
std::map<int,std::string>::iterator res = fReservationMap.find(uuid);
if (res != fReservationMap.end()) {
strncpy( real_name, res->second.c_str(), JACK_CLIENT_NAME_SIZE );
fReservationMap.erase(uuid);
} else {
strncpy( real_name, name, JACK_CLIENT_NAME_SIZE );
}
EnsureUUID(uuid);
}
jack_log("JackEngine::ClientExternalOpen: name = %s ", real_name);
......@@ -549,9 +549,9 @@ int JackEngine::ClientExternalOpen(const char* name, int pid, int uuid, int* ref
}
if (uuid < 0)
uuid = GetNewUUID();
uuid = GetNewUUID();
else
EnsureUUID(uuid);
EnsureUUID(uuid);
if (client->Open(real_name, pid, refnum, uuid, shared_client) < 0) {
jack_error("Cannot open client");
......@@ -916,17 +916,17 @@ int JackEngine::PortRename(int refnum, jack_port_id_t port, const char* name)
void JackEngine::SessionNotify(int refnum, const char *target, jack_session_event_type_t type, const char *path, JackChannelTransaction *socket )
{
if (fSessionPendingReplies != 0) {
JackSessionNotifyResult res(-1);
res.Write(socket);
jack_log("JackEngine::SessionNotify ... busy");
return;
JackSessionNotifyResult res(-1);
res.Write(socket);
jack_log("JackEngine::SessionNotify ... busy");
return;
}
for (int i = 0; i < CLIENT_NUM; i++) {
JackClientInterface* client = fClientTable[i];
if (client && (client->GetClientControl()->fSessionID < 0)) {
client->GetClientControl()->fSessionID = GetNewUUID();
}
client->GetClientControl()->fSessionID = GetNewUUID();
}
}
fSessionResult = new JackSessionNotifyResult();
......@@ -934,48 +934,48 @@ void JackEngine::SessionNotify(int refnum, const char *target, jack_session_even
JackClientInterface* client = fClientTable[i];
if (client && client->GetClientControl()->fCallback[kSessionCallback]) {
// check if this is a notification to a specific client.
if (target!=NULL && strlen(target)!=0) {
if (strcmp(target, client->GetClientControl()->fName)) {
continue;
}
}
// check if this is a notification to a specific client.
if (target!=NULL && strlen(target)!=0) {
if (strcmp(target, client->GetClientControl()->fName)) {
continue;
}
}
// TODO: this is linux specific right now. need proper platform abstract way.
// TODO: this is linux specific right now. need proper platform abstract way.
#define DIR_SEPARATOR '/'
char path_buf[JACK_PORT_NAME_SIZE];
snprintf( path_buf, sizeof(path_buf), "%s%s%c", path, client->GetClientControl()->fName, DIR_SEPARATOR );
int mkdir_res = mkdir( path_buf, 0777 );
if (mkdir_res != 0 && mkdir_res != EEXIST)
{
jack_error( "JackEngine::SessionNotify: can not create session directory '%s'", path_buf );
}
// end of platform specific code.
int result = client->ClientNotify(i, client->GetClientControl()->fName, kSessionCallback, true, path_buf, (int) type, 0);
if (result == 2) {
fSessionPendingReplies += 1;
} else if (result == 1) {
char uuid_buf[32];
snprintf( uuid_buf, sizeof(uuid_buf), "%d", client->GetClientControl()->fSessionID );
fSessionResult->fCommandList.push_back( JackSessionCommand( uuid_buf,
client->GetClientControl()->fName,
client->GetClientControl()->fSessionCommand,
client->GetClientControl()->fSessionFlags ));
}
}
char path_buf[JACK_PORT_NAME_SIZE];
snprintf( path_buf, sizeof(path_buf), "%s%s%c", path, client->GetClientControl()->fName, DIR_SEPARATOR );
int mkdir_res = mkdir( path_buf, 0777 );
if (mkdir_res != 0 && mkdir_res != EEXIST)
{
jack_error( "JackEngine::SessionNotify: can not create session directory '%s'", path_buf );
}
// end of platform specific code.
int result = client->ClientNotify(i, client->GetClientControl()->fName, kSessionCallback, true, path_buf, (int) type, 0);
if (result == 2) {
fSessionPendingReplies += 1;
} else if (result == 1) {
char uuid_buf[32];
snprintf( uuid_buf, sizeof(uuid_buf), "%d", client->GetClientControl()->fSessionID );
fSessionResult->fCommandList.push_back( JackSessionCommand( uuid_buf,
client->GetClientControl()->fName,
client->GetClientControl()->fSessionCommand,
client->GetClientControl()->fSessionFlags ));
}
}
}
if (fSessionPendingReplies == 0) {
fSessionResult->Write(socket);
delete fSessionResult;
fSessionResult = NULL;
fSessionResult->Write(socket);
delete fSessionResult;
fSessionResult = NULL;
} else {
fSessionTransaction = socket;
fSessionTransaction = socket;
}
}
......@@ -986,14 +986,14 @@ void JackEngine::SessionReply(int refnum)
snprintf( uuid_buf, sizeof(uuid_buf), "%d", client->GetClientControl()->fSessionID );
fSessionResult->fCommandList.push_back( JackSessionCommand( uuid_buf,
client->GetClientControl()->fName,
client->GetClientControl()->fSessionCommand,
client->GetClientControl()->fSessionFlags ));
client->GetClientControl()->fSessionCommand,
client->GetClientControl()->fSessionFlags ));
fSessionPendingReplies -= 1;
if (fSessionPendingReplies == 0) {
fSessionResult->Write(fSessionTransaction);
delete fSessionResult;
fSessionResult = NULL;
fSessionResult->Write(fSessionTransaction);
delete fSessionResult;
fSessionResult = NULL;
}
}
......@@ -1002,11 +1002,11 @@ void JackEngine::GetUUIDForClientName(const char *client_name, char *uuid_res, i
for (int i = 0; i < CLIENT_NUM; i++) {
JackClientInterface* client = fClientTable[i];
if (client && (strcmp(client_name, client->GetClientControl()->fName)==0)) {
snprintf(uuid_res, 32, "%d", client->GetClientControl()->fSessionID);
*result = 0;
return;
}
if (client && (strcmp(client_name, client->GetClientControl()->fName)==0)) {
snprintf(uuid_res, 32, "%d", client->GetClientControl()->fSessionID);
*result = 0;
return;
}
}
// did not find name.
*result = -1;
......@@ -1018,17 +1018,17 @@ void JackEngine::GetClientNameForUUID(const char *uuid, char *name_res, int *res
for (int i = 0; i < CLIENT_NUM; i++) {
JackClientInterface* client = fClientTable[i];
if (!client)
continue;
if (!client)
continue;
char uuid_buf[33];
snprintf(uuid_buf, 32, "%d", client->GetClientControl()->fSessionID);
char uuid_buf