| @@ -108,8 +108,8 @@ extern "C" | |||||
| JackPortConnectCallback | JackPortConnectCallback | ||||
| connect_callback, void *arg); | connect_callback, void *arg); | ||||
| EXPORT int jack_set_port_rename_callback (jack_client_t *, | 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 *, | EXPORT int jack_set_graph_order_callback (jack_client_t *, | ||||
| JackGraphOrderCallback graph_callback, | JackGraphOrderCallback graph_callback, | ||||
| void *); | void *); | ||||
| @@ -217,7 +217,7 @@ extern "C" | |||||
| EXPORT int jack_client_create_thread (jack_client_t* client, | EXPORT int jack_client_create_thread (jack_client_t* client, | ||||
| pthread_t *thread, | pthread_t *thread, | ||||
| int priority, | int priority, | ||||
| int realtime, // boolean | |||||
| int realtime, // boolean | |||||
| thread_routine routine, | thread_routine routine, | ||||
| void *arg); | void *arg); | ||||
| EXPORT int jack_drop_real_time_scheduling (pthread_t thread); | 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, | EXPORT int jack_client_create_thread(jack_client_t* client, | ||||
| pthread_t *thread, | pthread_t *thread, | ||||
| int priority, | int priority, | ||||
| int realtime, /* boolean */ | |||||
| int realtime, /* boolean */ | |||||
| thread_routine routine, | thread_routine routine, | ||||
| void *arg) | void *arg) | ||||
| { | { | ||||
| @@ -1766,8 +1766,8 @@ EXPORT jack_intclient_t jack_internal_client_handle(jack_client_t* ext_client, c | |||||
| return 0; | return 0; | ||||
| } else { | } else { | ||||
| jack_status_t my_status; | 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; | *status = (jack_status_t)0; | ||||
| return client->InternalClientHandle(client_name, status); | 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_varargs_t va; | ||||
| jack_status_t my_status; | 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; | *status = (jack_status_t)0; | ||||
| /* validate parameters */ | /* 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->session_dir); | ||||
| free((void *)ev->client_uuid); | free((void *)ev->client_uuid); | ||||
| if (ev->command_line) | if (ev->command_line) | ||||
| free(ev->command_line); | |||||
| free(ev->command_line); | |||||
| free(ev); | free(ev); | ||||
| } | } | ||||
| @@ -1964,16 +1964,16 @@ EXPORT void jack_session_commands_free( jack_session_command_t *cmds ) | |||||
| { | { | ||||
| int i=0; | int i=0; | ||||
| while(1) { | 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); | free(cmds); | ||||
| @@ -127,23 +127,23 @@ class JackClientChannelInterface | |||||
| virtual void InternalClientUnload(int refnum, int int_ref, int* status, int* result) | 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) | void JackClient::SetupDriverSync(bool freewheel) | ||||
| { | { | ||||
| @@ -170,7 +170,7 @@ int JackClient::ClientNotify(int refnum, const char* name, int notify, int sync, | |||||
| case kAddClient: | case kAddClient: | ||||
| jack_log("JackClient::kAddClient fName = %s name = %s", GetClientControl()->fName, name); | 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); | fClientRegistration(name, 1, fClientRegistrationArg); | ||||
| } | } | ||||
| break; | break; | ||||
| @@ -276,23 +276,23 @@ int JackClient::ClientNotify(int refnum, const char* name, int notify, int sync, | |||||
| case kSessionCallback: | case kSessionCallback: | ||||
| jack_log("JackClient::kSessionCallback"); | jack_log("JackClient::kSessionCallback"); | ||||
| if (fSession) { | 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); | fSession(event, fSessionArg); | ||||
| if (fImmediateSessionReply) | |||||
| res = 1; | |||||
| else | |||||
| res = 2; | |||||
| if (fImmediateSessionReply) | |||||
| res = 1; | |||||
| else | |||||
| res = 2; | |||||
| } | } | ||||
| break; | 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 | \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() | int JackClient::Activate() | ||||
| { | { | ||||
| @@ -433,7 +433,7 @@ inline void JackClient::ExecuteThread() | |||||
| while (true) { | while (true) { | ||||
| CycleWaitAux(); | CycleWaitAux(); | ||||
| CycleSignalAux(CallProcessCallback()); | CycleSignalAux(CallProcessCallback()); | ||||
| } | |||||
| } | |||||
| } | } | ||||
| inline jack_nframes_t JackClient::CycleWaitAux() | 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"); | jack_error("You cannot set callbacks on an active client"); | ||||
| return -1; | return -1; | ||||
| } else { | } else { | ||||
| GetClientControl()->fCallback[kSessionCallback] = (callback != NULL); | |||||
| GetClientControl()->fCallback[kSessionCallback] = (callback != NULL); | |||||
| fSessionArg = arg; | fSessionArg = arg; | ||||
| fSession = callback; | fSession = callback; | ||||
| return 0; | 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 ) | int JackClient::SessionReply( jack_session_event_t *ev ) | ||||
| { | { | ||||
| if (ev->command_line) { | if (ev->command_line) { | ||||
| strncpy( GetClientControl()->fSessionCommand, ev->command_line, sizeof(GetClientControl()->fSessionCommand) ); | |||||
| strncpy( GetClientControl()->fSessionCommand, ev->command_line, sizeof(GetClientControl()->fSessionCommand) ); | |||||
| } else { | } else { | ||||
| GetClientControl()->fSessionCommand[0] = '\0'; | |||||
| GetClientControl()->fSessionCommand[0] = '\0'; | |||||
| } | } | ||||
| GetClientControl()->fSessionFlags = ev->flags; | GetClientControl()->fSessionFlags = ev->flags; | ||||
| jack_log( "JackClient::SessionReply... we are here" ); | jack_log( "JackClient::SessionReply... we are here" ); | ||||
| if (fChannel->IsChannelThread()) { | 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" ); | 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); | fChannel->GetUUIDForClientName( GetClientControl()->fRefNum, client_name, uuid_res, &result); | ||||
| if(result) | if(result) | ||||
| return NULL; | |||||
| return NULL; | |||||
| return strdup(uuid_res); | return strdup(uuid_res); | ||||
| } | } | ||||
| @@ -1128,7 +1128,7 @@ char* JackClient::GetClientNameForUUID(const char* uuid) | |||||
| fChannel->GetClientNameForUUID(GetClientControl()->fRefNum, uuid, name_res, &result); | fChannel->GetClientNameForUUID(GetClientControl()->fRefNum, uuid, name_res, &result); | ||||
| if(result) | if(result) | ||||
| return NULL; | |||||
| return NULL; | |||||
| return strdup(name_res); | return strdup(name_res); | ||||
| } | } | ||||
| @@ -93,7 +93,7 @@ class JackClient : public JackClientInterface, public JackRunnableInterface | |||||
| JackSynchro* fSynchroTable; | JackSynchro* fSynchroTable; | ||||
| std::list<jack_port_id_t> fPortList; | std::list<jack_port_id_t> fPortList; | ||||
| bool fImmediateSessionReply; | |||||
| bool fImmediateSessionReply; | |||||
| int StartThread(); | int StartThread(); | ||||
| void SetupDriverSync(bool freewheel); | void SetupDriverSync(bool freewheel); | ||||
| @@ -190,9 +190,9 @@ class JackClient : public JackClientInterface, public JackRunnableInterface | |||||
| void CycleSignal(int status); | void CycleSignal(int status); | ||||
| int SetProcessThread(JackThreadCallback fun, void *arg); | 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* GetUUIDForClientName(const char* client_name); | ||||
| char* GetClientNameForUUID(const char* uuid); | char* GetClientNameForUUID(const char* uuid); | ||||
| int ReserveClientName(const char *name, const char* uuid); | int ReserveClientName(const char *name, const char* uuid); | ||||
| @@ -84,7 +84,7 @@ struct JackClientControl : public JackShmMemAble | |||||
| fTransportTimebase = false; | fTransportTimebase = false; | ||||
| fActive = false; | fActive = false; | ||||
| fSessionID = uuid; | |||||
| fSessionID = uuid; | |||||
| } | } | ||||
| } POST_PACKED_STRUCTURE; | } POST_PACKED_STRUCTURE; | ||||
| @@ -450,21 +450,21 @@ sigset_t | |||||
| jackctl_setup_signals( | jackctl_setup_signals( | ||||
| unsigned int flags) | 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()); | jack_error("CreateEvent fails err = %ld", GetLastError()); | ||||
| return 0; | return 0; | ||||
| } | } | ||||
| (void) signal(SIGINT, do_nothing_handler); | |||||
| (void) signal(SIGINT, do_nothing_handler); | |||||
| (void) signal(SIGABRT, do_nothing_handler); | (void) signal(SIGABRT, do_nothing_handler); | ||||
| (void) signal(SIGTERM, do_nothing_handler); | (void) signal(SIGTERM, do_nothing_handler); | ||||
| return (sigset_t)waitEvent; | |||||
| return (sigset_t)waitEvent; | |||||
| } | } | ||||
| void jackctl_wait_signals(sigset_t signals) | 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()); | jack_error("WaitForSingleObject fails err = %ld", GetLastError()); | ||||
| } | } | ||||
| } | } | ||||
| @@ -36,8 +36,8 @@ namespace Jack | |||||
| JackDebugClient::JackDebugClient(JackClient * client) | 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; | fIsActivated = 0; | ||||
| fIsDeactivated = 0; | fIsDeactivated = 0; | ||||
| fIsClosed = 0; | fIsClosed = 0; | ||||
| @@ -210,8 +210,8 @@ int JackDebugClient::PortUnRegister(jack_port_id_t port_index) | |||||
| int res = fClient->PortUnRegister(port_index); | int res = fClient->PortUnRegister(port_index); | ||||
| fOpenPortNumber--; | fOpenPortNumber--; | ||||
| int i; | 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) | if (fPortList[i].IsUnregistered != 0) | ||||
| *fStream << "!!! ERROR !!! : '" << fClientName << "' id deregistering port '" << fPortList[i].name << "' that have already been unregistered !" << endl; | *fStream << "!!! ERROR !!! : '" << fClientName << "' id deregistering port '" << fPortList[i].name << "' that have already been unregistered !" << endl; | ||||
| fPortList[i].IsUnregistered++; | 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; | *fStream << "!!! ERROR !!! Trying to connect a port ( " << src << " to " << dst << ") while the client has not been activated !" << endl; | ||||
| int i; | int i; | ||||
| int res = fClient->PortConnect( src, dst); | 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) | if (fPortList[i].IsUnregistered != 0) | ||||
| *fStream << "!!! ERROR !!! Connecting port " << src << " previoulsy unregistered !" << endl; | *fStream << "!!! ERROR !!! Connecting port " << src << " previoulsy unregistered !" << endl; | ||||
| fPortList[i].IsConnected++; | 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; | *fStream << "!!! ERROR !!! : Trying to disconnect port " << src << " while that client has not been activated !" << endl; | ||||
| int res = fClient->PortDisconnect(src); | int res = fClient->PortDisconnect(src); | ||||
| int i; | 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) | if (fPortList[i].IsUnregistered != 0) | ||||
| *fStream << "!!! ERROR !!! : Disconnecting port " << src << " previoulsy unregistered !" << endl; | *fStream << "!!! ERROR !!! : Disconnecting port " << src << " previoulsy unregistered !" << endl; | ||||
| fPortList[i].IsConnected--; | fPortList[i].IsConnected--; | ||||
| @@ -53,8 +53,8 @@ class JackDebugClient : public JackClient | |||||
| JackClient* fClient; | JackClient* fClient; | ||||
| std::ofstream* fStream; | std::ofstream* fStream; | ||||
| PortFollower fPortList[MAX_PORT_HISTORY]; // Arbitrary value... To be tuned... | 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 fIsActivated; | ||||
| int fIsDeactivated; | int fIsDeactivated; | ||||
| int fIsClosed; | int fIsClosed; | ||||
| @@ -139,7 +139,7 @@ void JackEngine::ReleaseRefnum(int ref) | |||||
| void JackEngine::ProcessNext(jack_time_t cur_cycle_begin) | void JackEngine::ProcessNext(jack_time_t cur_cycle_begin) | ||||
| { | { | ||||
| fLastSwitchUsecs = 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); | fChannel.Notify(ALL_CLIENTS, kGraphOrderCallback, 0); | ||||
| fSignal.Signal(); // Signal for threads waiting for next cycle | 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) { | if (length > JACK_CLIENT_NAME_SIZE - 4) { | ||||
| jack_error("%s exists and is too long to make unique", name); | 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" */ | /* 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++) { | 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; | return false; | ||||
| @@ -481,13 +481,13 @@ int JackEngine::GetNewUUID() | |||||
| void JackEngine::EnsureUUID(int uuid) | void JackEngine::EnsureUUID(int uuid) | ||||
| { | { | ||||
| if (uuid > fMaxUUID) | if (uuid > fMaxUUID) | ||||
| fMaxUUID = uuid+1; | |||||
| fMaxUUID = uuid+1; | |||||
| for (int i = 0; i < CLIENT_NUM; i++) { | for (int i = 0; i < CLIENT_NUM; i++) { | ||||
| JackClientInterface* client = fClientTable[i]; | JackClientInterface* client = fClientTable[i]; | ||||
| if (client && (client->GetClientControl()->fSessionID==uuid)) { | 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]; | char real_name[JACK_CLIENT_NAME_SIZE+1]; | ||||
| if (uuid < 0) { | if (uuid < 0) { | ||||
| uuid = GetNewUUID(); | |||||
| strncpy( real_name, name, JACK_CLIENT_NAME_SIZE ); | |||||
| uuid = GetNewUUID(); | |||||
| strncpy( real_name, name, JACK_CLIENT_NAME_SIZE ); | |||||
| } else { | } 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); | 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) | if (uuid < 0) | ||||
| uuid = GetNewUUID(); | |||||
| uuid = GetNewUUID(); | |||||
| else | else | ||||
| EnsureUUID(uuid); | |||||
| EnsureUUID(uuid); | |||||
| if (client->Open(real_name, pid, refnum, uuid, shared_client) < 0) { | if (client->Open(real_name, pid, refnum, uuid, shared_client) < 0) { | ||||
| jack_error("Cannot open client"); | 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 ) | void JackEngine::SessionNotify(int refnum, const char *target, jack_session_event_type_t type, const char *path, JackChannelTransaction *socket ) | ||||
| { | { | ||||
| if (fSessionPendingReplies != 0) { | 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++) { | for (int i = 0; i < CLIENT_NUM; i++) { | ||||
| JackClientInterface* client = fClientTable[i]; | JackClientInterface* client = fClientTable[i]; | ||||
| if (client && (client->GetClientControl()->fSessionID < 0)) { | if (client && (client->GetClientControl()->fSessionID < 0)) { | ||||
| client->GetClientControl()->fSessionID = GetNewUUID(); | |||||
| } | |||||
| client->GetClientControl()->fSessionID = GetNewUUID(); | |||||
| } | |||||
| } | } | ||||
| fSessionResult = new JackSessionNotifyResult(); | fSessionResult = new JackSessionNotifyResult(); | ||||
| @@ -934,48 +934,48 @@ void JackEngine::SessionNotify(int refnum, const char *target, jack_session_even | |||||
| JackClientInterface* client = fClientTable[i]; | JackClientInterface* client = fClientTable[i]; | ||||
| if (client && client->GetClientControl()->fCallback[kSessionCallback]) { | 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 '/' | #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) { | if (fSessionPendingReplies == 0) { | ||||
| fSessionResult->Write(socket); | |||||
| delete fSessionResult; | |||||
| fSessionResult = NULL; | |||||
| fSessionResult->Write(socket); | |||||
| delete fSessionResult; | |||||
| fSessionResult = NULL; | |||||
| } else { | } else { | ||||
| fSessionTransaction = socket; | |||||
| fSessionTransaction = socket; | |||||
| } | } | ||||
| } | } | ||||
| @@ -986,14 +986,14 @@ void JackEngine::SessionReply(int refnum) | |||||
| snprintf( uuid_buf, sizeof(uuid_buf), "%d", client->GetClientControl()->fSessionID ); | snprintf( uuid_buf, sizeof(uuid_buf), "%d", client->GetClientControl()->fSessionID ); | ||||
| fSessionResult->fCommandList.push_back( JackSessionCommand( uuid_buf, | fSessionResult->fCommandList.push_back( JackSessionCommand( uuid_buf, | ||||
| client->GetClientControl()->fName, | client->GetClientControl()->fName, | ||||
| client->GetClientControl()->fSessionCommand, | |||||
| client->GetClientControl()->fSessionFlags )); | |||||
| client->GetClientControl()->fSessionCommand, | |||||
| client->GetClientControl()->fSessionFlags )); | |||||
| fSessionPendingReplies -= 1; | fSessionPendingReplies -= 1; | ||||
| if (fSessionPendingReplies == 0) { | 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++) { | for (int i = 0; i < CLIENT_NUM; i++) { | ||||
| JackClientInterface* client = fClientTable[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. | // did not find name. | ||||
| *result = -1; | *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++) { | for (int i = 0; i < CLIENT_NUM; i++) { | ||||
| JackClientInterface* client = fClientTable[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[33]; | |||||
| snprintf(uuid_buf, 32, "%d", client->GetClientControl()->fSessionID); | |||||
| if (strcmp(uuid,uuid_buf) == 0) { | |||||
| strncpy(name_res, client->GetClientControl()->fName, JACK_CLIENT_NAME_SIZE); | |||||
| *result = 0; | |||||
| return; | |||||
| } | |||||
| if (strcmp(uuid,uuid_buf) == 0) { | |||||
| strncpy(name_res, client->GetClientControl()->fName, JACK_CLIENT_NAME_SIZE); | |||||
| *result = 0; | |||||
| return; | |||||
| } | |||||
| } | } | ||||
| // did not find uuid. | // did not find uuid. | ||||
| *result = -1; | *result = -1; | ||||
| @@ -1040,8 +1040,8 @@ void JackEngine::ReserveClientName(const char *name, const char *uuid, int *resu | |||||
| if (ClientCheckName(name)) | if (ClientCheckName(name)) | ||||
| { | { | ||||
| *result = -1; | |||||
| return; | |||||
| *result = -1; | |||||
| return; | |||||
| } | } | ||||
| EnsureUUID(atoi(uuid)); | EnsureUUID(atoi(uuid)); | ||||
| @@ -52,11 +52,11 @@ class SERVER_EXPORT JackEngine : public JackLockAble | |||||
| JackProcessSync fSignal; | JackProcessSync fSignal; | ||||
| jack_time_t fLastSwitchUsecs; | jack_time_t fLastSwitchUsecs; | ||||
| int fSessionPendingReplies; | |||||
| JackChannelTransaction *fSessionTransaction; | |||||
| JackSessionNotifyResult *fSessionResult; | |||||
| std::map<int,std::string> fReservationMap; | |||||
| int fMaxUUID; | |||||
| int fSessionPendingReplies; | |||||
| JackChannelTransaction *fSessionTransaction; | |||||
| JackSessionNotifyResult *fSessionResult; | |||||
| std::map<int,std::string> fReservationMap; | |||||
| int fMaxUUID; | |||||
| int ClientCloseAux(int refnum, JackClientInterface* client, bool wait); | int ClientCloseAux(int refnum, JackClientInterface* client, bool wait); | ||||
| @@ -139,13 +139,13 @@ class SERVER_EXPORT JackEngine : public JackLockAble | |||||
| void NotifyFreewheel(bool onoff); | void NotifyFreewheel(bool onoff); | ||||
| void NotifyQuit(); | void NotifyQuit(); | ||||
| void SessionNotify( int refnum, const char *target, jack_session_event_type_t type, const char *path, JackChannelTransaction *socket ); | |||||
| void SessionReply( int refnum ); | |||||
| int GetNewUUID(); | |||||
| void EnsureUUID(int uuid); | |||||
| void GetUUIDForClientName(const char *client_name, char *uuid_res, int *result); | |||||
| void GetClientNameForUUID(const char *uuid, char *name_res, int *result); | |||||
| void ReserveClientName(const char *name, const char *uuid, int *result); | |||||
| void SessionNotify( int refnum, const char *target, jack_session_event_type_t type, const char *path, JackChannelTransaction *socket ); | |||||
| void SessionReply( int refnum ); | |||||
| int GetNewUUID(); | |||||
| void EnsureUUID(int uuid); | |||||
| void GetUUIDForClientName(const char *client_name, char *uuid_res, int *result); | |||||
| void GetClientNameForUUID(const char *uuid, char *name_res, int *result); | |||||
| void ReserveClientName(const char *name, const char *uuid, int *result); | |||||
| }; | }; | ||||
| @@ -39,7 +39,7 @@ class JackExternalClient : public JackClientInterface | |||||
| private: | private: | ||||
| JackNotifyChannel fChannel; /*! Server/client communication channel */ | JackNotifyChannel fChannel; /*! Server/client communication channel */ | ||||
| JackClientControl* fClientControl; /*! Client control in shared memory */ | |||||
| JackClientControl* fClientControl; /*! Client control in shared memory */ | |||||
| public: | public: | ||||
| @@ -52,8 +52,8 @@ class JackInternalClient : public JackClient | |||||
| JackEngineControl* GetEngineControl() const; | JackEngineControl* GetEngineControl() const; | ||||
| JackClientControl* GetClientControl() const; | JackClientControl* GetClientControl() const; | ||||
| static JackGraphManager* fGraphManager; /*! Shared memory Port manager */ | |||||
| static JackEngineControl* fEngineControl; /*! Shared engine cotrol */ | |||||
| static JackGraphManager* fGraphManager; /*! Shared memory Port manager */ | |||||
| static JackEngineControl* fEngineControl; /*! Shared engine cotrol */ | |||||
| }; | }; | ||||
| /*! | /*! | ||||
| @@ -112,10 +112,10 @@ class JackInternalClientChannel : public detail::JackClientChannelInterface | |||||
| *result = fServer->SetFreewheel(onoff); | *result = fServer->SetFreewheel(onoff); | ||||
| } | } | ||||
| void SessionNotify( int refnum, const char *target, jack_session_event_type_t type, const char *path, jack_session_command_t **result ) | |||||
| { | |||||
| *result = NULL; | |||||
| } | |||||
| void SessionNotify( int refnum, const char *target, jack_session_event_type_t type, const char *path, jack_session_command_t **result ) | |||||
| { | |||||
| *result = NULL; | |||||
| } | |||||
| void ReleaseTimebase(int refnum, int* result) | void ReleaseTimebase(int refnum, int* result) | ||||
| { | { | ||||
| @@ -139,7 +139,7 @@ class JackInternalClientChannel : public detail::JackClientChannelInterface | |||||
| void InternalClientLoad(int refnum, const char* client_name, const char* so_name, const char* objet_data, int options, int* status, int* int_ref, int* result, int uuid) | void InternalClientLoad(int refnum, const char* client_name, const char* so_name, const char* objet_data, int options, int* status, int* int_ref, int* result, int uuid) | ||||
| { | { | ||||
| *result = fServer->InternalClientLoad(client_name, so_name, objet_data, options, int_ref, status, uuid); | |||||
| *result = fServer->InternalClientLoad(client_name, so_name, objet_data, options, int_ref, status, uuid); | |||||
| } | } | ||||
| void InternalClientUnload(int refnum, int int_ref, int* status, int* result) | void InternalClientUnload(int refnum, int int_ref, int* status, int* result) | ||||
| @@ -57,7 +57,7 @@ int JackLibGlobals::fClientCount = 0; | |||||
| jack_client_t* jack_client_new_aux(const char* client_name, jack_options_t options, jack_status_t* status) | jack_client_t* jack_client_new_aux(const char* client_name, jack_options_t options, jack_status_t* status) | ||||
| { | { | ||||
| jack_varargs_t va; /* variable arguments */ | |||||
| jack_varargs_t va; /* variable arguments */ | |||||
| jack_status_t my_status; | jack_status_t my_status; | ||||
| JackClient* client; | JackClient* client; | ||||
| @@ -68,8 +68,8 @@ jack_client_t* jack_client_new_aux(const char* client_name, jack_options_t optio | |||||
| jack_log("jack_client_new %s", client_name); | jack_log("jack_client_new %s", client_name); | ||||
| 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; | *status = (jack_status_t)0; | ||||
| /* validate parameters */ | /* validate parameters */ | ||||
| @@ -37,7 +37,7 @@ class JackLibClient : public JackClient | |||||
| private: | private: | ||||
| JackShmReadWritePtr1<JackClientControl> fClientControl; /*! Shared client control */ | |||||
| JackShmReadWritePtr1<JackClientControl> fClientControl; /*! Shared client control */ | |||||
| public: | public: | ||||
| @@ -307,43 +307,43 @@ class SERVER_EXPORT JackLockedEngine | |||||
| CATCH_EXCEPTION | CATCH_EXCEPTION | ||||
| } | } | ||||
| void SessionNotify(int refnum, const char* target, jack_session_event_type_t type, const char *path, JackChannelTransaction *socket) | |||||
| { | |||||
| void SessionNotify(int refnum, const char* target, jack_session_event_type_t type, const char *path, JackChannelTransaction *socket) | |||||
| { | |||||
| TRY_CALL | TRY_CALL | ||||
| JackLock lock(&fEngine); | JackLock lock(&fEngine); | ||||
| fEngine.SessionNotify(refnum, target, type, path, socket); | fEngine.SessionNotify(refnum, target, type, path, socket); | ||||
| CATCH_EXCEPTION | CATCH_EXCEPTION | ||||
| } | |||||
| } | |||||
| void SessionReply(int refnum) | |||||
| { | |||||
| void SessionReply(int refnum) | |||||
| { | |||||
| TRY_CALL | TRY_CALL | ||||
| JackLock lock(&fEngine); | JackLock lock(&fEngine); | ||||
| fEngine.SessionReply(refnum); | fEngine.SessionReply(refnum); | ||||
| CATCH_EXCEPTION | CATCH_EXCEPTION | ||||
| } | |||||
| } | |||||
| void GetUUIDForClientName(const char *client_name, char *uuid_res, int *result) | |||||
| { | |||||
| void GetUUIDForClientName(const char *client_name, char *uuid_res, int *result) | |||||
| { | |||||
| TRY_CALL | TRY_CALL | ||||
| JackLock lock(&fEngine); | JackLock lock(&fEngine); | ||||
| fEngine.GetUUIDForClientName(client_name, uuid_res, result); | |||||
| fEngine.GetUUIDForClientName(client_name, uuid_res, result); | |||||
| CATCH_EXCEPTION | CATCH_EXCEPTION | ||||
| } | |||||
| void GetClientNameForUUID(const char *uuid, char *name_res, int *result) | |||||
| { | |||||
| } | |||||
| void GetClientNameForUUID(const char *uuid, char *name_res, int *result) | |||||
| { | |||||
| TRY_CALL | TRY_CALL | ||||
| JackLock lock(&fEngine); | JackLock lock(&fEngine); | ||||
| fEngine.GetClientNameForUUID(uuid, name_res, result); | |||||
| fEngine.GetClientNameForUUID(uuid, name_res, result); | |||||
| CATCH_EXCEPTION | CATCH_EXCEPTION | ||||
| } | |||||
| void ReserveClientName(const char *name, const char *uuid, int *result) | |||||
| { | |||||
| } | |||||
| void ReserveClientName(const char *name, const char *uuid, int *result) | |||||
| { | |||||
| TRY_CALL | TRY_CALL | ||||
| JackLock lock(&fEngine); | JackLock lock(&fEngine); | ||||
| fEngine.ReserveClientName(name, uuid, result); | |||||
| fEngine.ReserveClientName(name, uuid, result); | |||||
| CATCH_EXCEPTION | CATCH_EXCEPTION | ||||
| } | |||||
| } | |||||
| }; | }; | ||||
| } // end of namespace | } // end of namespace | ||||
| @@ -67,11 +67,11 @@ struct JackRequest | |||||
| kInternalClientUnload = 30, | kInternalClientUnload = 30, | ||||
| kPortRename = 31, | kPortRename = 31, | ||||
| kNotification = 32, | kNotification = 32, | ||||
| kSessionNotify = 33, | |||||
| kSessionReply = 34, | |||||
| kGetClientByUUID = 35, | |||||
| kReserveClientName = 36, | |||||
| kGetUUIDByClient = 37 | |||||
| kSessionNotify = 33, | |||||
| kSessionReply = 34, | |||||
| kGetClientByUUID = 35, | |||||
| kReserveClientName = 36, | |||||
| kGetUUIDByClient = 37 | |||||
| }; | }; | ||||
| RequestType fType; | RequestType fType; | ||||
| @@ -104,7 +104,7 @@ struct JackRequest | |||||
| struct JackResult | struct JackResult | ||||
| { | { | ||||
| int fResult; | |||||
| int fResult; | |||||
| JackResult(): fResult( -1) | JackResult(): fResult( -1) | ||||
| {} | {} | ||||
| @@ -215,7 +215,7 @@ struct JackClientOpenRequest : public JackRequest | |||||
| { | { | ||||
| snprintf(fName, sizeof(fName), "%s", name); | snprintf(fName, sizeof(fName), "%s", name); | ||||
| fPID = pid; | fPID = pid; | ||||
| fUUID = uuid; | |||||
| fUUID = uuid; | |||||
| } | } | ||||
| int Read(JackChannelTransaction* trans) | int Read(JackChannelTransaction* trans) | ||||
| @@ -1094,10 +1094,10 @@ struct JackSessionCommand | |||||
| JackSessionCommand( const char *uuid, const char *clientname, const char *command, jack_session_flags_t flags ) | JackSessionCommand( const char *uuid, const char *clientname, const char *command, jack_session_flags_t flags ) | ||||
| { | { | ||||
| strncpy( fUUID, uuid, sizeof(fUUID)); | |||||
| strncpy( fClientName, clientname, sizeof(fClientName)); | |||||
| strncpy( fCommand, command, sizeof(fCommand)); | |||||
| fFlags = flags; | |||||
| strncpy( fUUID, uuid, sizeof(fUUID)); | |||||
| strncpy( fClientName, clientname, sizeof(fClientName)); | |||||
| strncpy( fCommand, command, sizeof(fCommand)); | |||||
| fFlags = flags; | |||||
| } | } | ||||
| }; | }; | ||||
| @@ -1116,34 +1116,34 @@ struct JackSessionNotifyResult : public JackResult | |||||
| int Read(JackChannelTransaction* trans) | int Read(JackChannelTransaction* trans) | ||||
| { | { | ||||
| CheckRes(JackResult::Read(trans)); | CheckRes(JackResult::Read(trans)); | ||||
| while(1) { | |||||
| JackSessionCommand buffer; | |||||
| while(1) { | |||||
| JackSessionCommand buffer; | |||||
| CheckRes(trans->Read(buffer.fUUID, sizeof(buffer.fUUID))); | |||||
| if (buffer.fUUID[0] == '\0') | |||||
| break; | |||||
| CheckRes(trans->Read(buffer.fUUID, sizeof(buffer.fUUID))); | |||||
| if (buffer.fUUID[0] == '\0') | |||||
| break; | |||||
| CheckRes(trans->Read(buffer.fClientName, sizeof(buffer.fClientName))); | |||||
| CheckRes(trans->Read(buffer.fCommand, sizeof(buffer.fCommand))); | |||||
| CheckRes(trans->Read(&(buffer.fFlags), sizeof(buffer.fFlags))); | |||||
| CheckRes(trans->Read(buffer.fClientName, sizeof(buffer.fClientName))); | |||||
| CheckRes(trans->Read(buffer.fCommand, sizeof(buffer.fCommand))); | |||||
| CheckRes(trans->Read(&(buffer.fFlags), sizeof(buffer.fFlags))); | |||||
| fCommandList.push_back(buffer); | |||||
| } | |||||
| fCommandList.push_back(buffer); | |||||
| } | |||||
| return 0; | return 0; | ||||
| } | } | ||||
| int Write(JackChannelTransaction* trans) | int Write(JackChannelTransaction* trans) | ||||
| { | { | ||||
| char terminator[32]; | |||||
| terminator[0] = '\0'; | |||||
| char terminator[32]; | |||||
| terminator[0] = '\0'; | |||||
| CheckRes(JackResult::Write(trans)); | CheckRes(JackResult::Write(trans)); | ||||
| for (std::list<JackSessionCommand>::iterator i=fCommandList.begin(); i!=fCommandList.end(); i++) { | |||||
| CheckRes(trans->Write(i->fUUID, sizeof(i->fUUID))); | |||||
| CheckRes(trans->Write(i->fClientName, sizeof(i->fClientName))); | |||||
| CheckRes(trans->Write(i->fCommand, sizeof(i->fCommand))); | |||||
| CheckRes(trans->Write(&(i->fFlags), sizeof(i->fFlags))); | |||||
| } | |||||
| for (std::list<JackSessionCommand>::iterator i=fCommandList.begin(); i!=fCommandList.end(); i++) { | |||||
| CheckRes(trans->Write(i->fUUID, sizeof(i->fUUID))); | |||||
| CheckRes(trans->Write(i->fClientName, sizeof(i->fClientName))); | |||||
| CheckRes(trans->Write(i->fCommand, sizeof(i->fCommand))); | |||||
| CheckRes(trans->Write(&(i->fFlags), sizeof(i->fFlags))); | |||||
| } | |||||
| CheckRes(trans->Write(terminator, sizeof(terminator))); | CheckRes(trans->Write(terminator, sizeof(terminator))); | ||||
| return 0; | return 0; | ||||
| } | } | ||||
| @@ -1167,10 +1167,10 @@ struct JackSessionNotifyRequest : public JackRequest | |||||
| : JackRequest(JackRequest::kSessionNotify), fEventType(type), fRefNum(refnum) | : JackRequest(JackRequest::kSessionNotify), fEventType(type), fRefNum(refnum) | ||||
| { | { | ||||
| snprintf(fPath, sizeof(fPath), "%s", path); | snprintf(fPath, sizeof(fPath), "%s", path); | ||||
| if (dst) | |||||
| snprintf(fDst, sizeof(fDst), "%s", dst); | |||||
| else | |||||
| fDst[0] = '\0'; | |||||
| if (dst) | |||||
| snprintf(fDst, sizeof(fDst), "%s", dst); | |||||
| else | |||||
| fDst[0] = '\0'; | |||||
| } | } | ||||
| int Read(JackChannelTransaction* trans) | int Read(JackChannelTransaction* trans) | ||||
| @@ -1289,7 +1289,7 @@ struct JackGetUUIDRequest : public JackRequest | |||||
| JackGetUUIDRequest(const char* client_name) | JackGetUUIDRequest(const char* client_name) | ||||
| : JackRequest(JackRequest::kGetUUIDByClient) | : JackRequest(JackRequest::kGetUUIDByClient) | ||||
| { | { | ||||
| strncpy(fName, client_name, sizeof(fName)); | |||||
| strncpy(fName, client_name, sizeof(fName)); | |||||
| } | } | ||||
| int Read(JackChannelTransaction* trans) | int Read(JackChannelTransaction* trans) | ||||
| @@ -1318,7 +1318,7 @@ struct JackGetClientNameRequest : public JackRequest | |||||
| JackGetClientNameRequest(const char* uuid) | JackGetClientNameRequest(const char* uuid) | ||||
| : JackRequest(JackRequest::kGetClientByUUID) | : JackRequest(JackRequest::kGetClientByUUID) | ||||
| { | { | ||||
| strncpy(fUUID, uuid, sizeof(fUUID)); | |||||
| strncpy(fUUID, uuid, sizeof(fUUID)); | |||||
| } | } | ||||
| int Read(JackChannelTransaction* trans) | int Read(JackChannelTransaction* trans) | ||||
| @@ -1349,8 +1349,8 @@ struct JackReserveNameRequest : public JackRequest | |||||
| JackReserveNameRequest(int refnum, const char *name, const char* uuid) | JackReserveNameRequest(int refnum, const char *name, const char* uuid) | ||||
| : JackRequest(JackRequest::kReserveClientName), fRefNum(refnum) | : JackRequest(JackRequest::kReserveClientName), fRefNum(refnum) | ||||
| { | { | ||||
| strncpy(fName, name, sizeof(fName)); | |||||
| strncpy(fUUID, uuid, sizeof(fUUID)); | |||||
| strncpy(fName, name, sizeof(fName)); | |||||
| strncpy(fUUID, uuid, sizeof(fUUID)); | |||||
| } | } | ||||
| int Read(JackChannelTransaction* trans) | int Read(JackChannelTransaction* trans) | ||||
| @@ -53,7 +53,7 @@ using namespace Jack; | |||||
| jack_client_t* jack_client_new_aux(const char* client_name, jack_options_t options, jack_status_t* status) | jack_client_t* jack_client_new_aux(const char* client_name, jack_options_t options, jack_status_t* status) | ||||
| { | { | ||||
| jack_varargs_t va; /* variable arguments */ | |||||
| jack_varargs_t va; /* variable arguments */ | |||||
| jack_status_t my_status; | jack_status_t my_status; | ||||
| JackClient* client; | JackClient* client; | ||||
| @@ -64,8 +64,8 @@ jack_client_t* jack_client_new_aux(const char* client_name, jack_options_t optio | |||||
| jack_log("jack_client_new %s", client_name); | jack_log("jack_client_new %s", client_name); | ||||
| 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; | *status = (jack_status_t)0; | ||||
| /* validate parameters */ | /* validate parameters */ | ||||
| @@ -191,7 +191,7 @@ EXPORT int jack_client_close(jack_client_t* ext_client) | |||||
| } else { | } else { | ||||
| res = client->Close(); | res = client->Close(); | ||||
| delete client; | delete client; | ||||
| JackServerGlobals::Destroy(); // jack server destruction | |||||
| JackServerGlobals::Destroy(); // jack server destruction | |||||
| jack_log("jack_client_close res = %d", res); | jack_log("jack_client_close res = %d", res); | ||||
| } | } | ||||
| JackGlobals::fOpenMutex->Unlock(); | JackGlobals::fOpenMutex->Unlock(); | ||||
| @@ -106,7 +106,7 @@ class SERVER_EXPORT JackThreadInterface | |||||
| int DropSelfRealTime(); // Used when called from thread itself | int DropSelfRealTime(); // Used when called from thread itself | ||||
| pthread_t GetThreadID(); | pthread_t GetThreadID(); | ||||
| bool IsThread(); | |||||
| bool IsThread(); | |||||
| static int AcquireRealTimeImp(pthread_t thread, int priority); | static int AcquireRealTimeImp(pthread_t thread, int priority); | ||||
| static int AcquireRealTimeImp(pthread_t thread, int priority, UInt64 period, UInt64 computation, UInt64 constraint); | static int AcquireRealTimeImp(pthread_t thread, int priority, UInt64 period, UInt64 computation, UInt64 constraint); | ||||
| @@ -133,8 +133,8 @@ typedef void (*JackSessionCallback)(jack_session_event_t *event, void *arg); | |||||
| * @return 0 on success, otherwise a non-zero error code | * @return 0 on success, otherwise a non-zero error code | ||||
| */ | */ | ||||
| int jack_set_session_callback(jack_client_t *client, | int jack_set_session_callback(jack_client_t *client, | ||||
| JackSessionCallback session_callback, | |||||
| void *arg) JACK_WEAK_EXPORT; | |||||
| JackSessionCallback session_callback, | |||||
| void *arg) JACK_WEAK_EXPORT; | |||||
| /** | /** | ||||
| * reply to a session_event | * reply to a session_event | ||||
| @@ -162,18 +162,18 @@ void jack_session_event_free (jack_session_event_t *event); | |||||
| /** | /** | ||||
| * @defgroup JackSessionManagerAPI this API is intended for a sessionmanager. | * @defgroup JackSessionManagerAPI this API is intended for a sessionmanager. | ||||
| * this API could be server specific. if we dont reach consensus here, | |||||
| * we can just drop it. | |||||
| * i know its a bit clumsy. | |||||
| * but this api isnt required to be as stable as the client api. | |||||
| * this API could be server specific. if we dont reach consensus here, | |||||
| * we can just drop it. | |||||
| * i know its a bit clumsy. | |||||
| * but this api isnt required to be as stable as the client api. | |||||
| * @{ | * @{ | ||||
| */ | */ | ||||
| typedef struct { | typedef struct { | ||||
| const char *uuid; | |||||
| const char *client_name; | |||||
| const char *command; | |||||
| jack_session_flags_t flags; | |||||
| const char *uuid; | |||||
| const char *client_name; | |||||
| const char *command; | |||||
| jack_session_flags_t flags; | |||||
| } jack_session_command_t; | } jack_session_command_t; | ||||
| /** | /** | ||||
| @@ -185,9 +185,9 @@ typedef struct { | |||||
| */ | */ | ||||
| jack_session_command_t *jack_session_notify (jack_client_t* client, | jack_session_command_t *jack_session_notify (jack_client_t* client, | ||||
| const char *target, | |||||
| jack_session_event_type_t type, | |||||
| const char *path ) JACK_WEAK_EXPORT; | |||||
| const char *target, | |||||
| jack_session_event_type_t type, | |||||
| const char *path ) JACK_WEAK_EXPORT; | |||||
| /** | /** | ||||
| * free the memory allocated by a session command. | * free the memory allocated by a session command. | ||||
| @@ -29,12 +29,12 @@ typedef int32_t jack_shmsize_t; | |||||
| /** | /** | ||||
| * Type used to represent sample frame counts. | * Type used to represent sample frame counts. | ||||
| */ | */ | ||||
| typedef uint32_t jack_nframes_t; | |||||
| typedef uint32_t jack_nframes_t; | |||||
| /** | /** | ||||
| * Maximum value that can be stored in jack_nframes_t | * Maximum value that can be stored in jack_nframes_t | ||||
| */ | */ | ||||
| #define JACK_MAX_FRAMES (4294967295U) /* This should be UINT32_MAX, but C++ has a problem with that. */ | |||||
| #define JACK_MAX_FRAMES (4294967295U) /* This should be UINT32_MAX, but C++ has a problem with that. */ | |||||
| /** | /** | ||||
| * Type used to represent the value of free running | * Type used to represent the value of free running | ||||
| @@ -284,9 +284,9 @@ enum JackPortFlags { | |||||
| /** | /** | ||||
| * JackPortIsTerminal means: | * JackPortIsTerminal means: | ||||
| * | * | ||||
| * for an input port: the data received by the port | |||||
| * for an input port: the data received by the port | |||||
| * will not be passed on or made | * will not be passed on or made | ||||
| * available at any other port | |||||
| * available at any other port | |||||
| * | * | ||||
| * for an output port: the data available at the port | * for an output port: the data available at the port | ||||
| * does not originate from any other port | * does not originate from any other port | ||||
| @@ -461,20 +461,20 @@ typedef enum { | |||||
| JackTransportRolling = 1, /**< Transport playing */ | JackTransportRolling = 1, /**< Transport playing */ | ||||
| JackTransportLooping = 2, /**< For OLD_TRANSPORT, now ignored */ | JackTransportLooping = 2, /**< For OLD_TRANSPORT, now ignored */ | ||||
| JackTransportStarting = 3, /**< Waiting for sync ready */ | JackTransportStarting = 3, /**< Waiting for sync ready */ | ||||
| JackTransportNetStarting = 4, /**< Waiting for sync ready on the network*/ | |||||
| JackTransportNetStarting = 4, /**< Waiting for sync ready on the network*/ | |||||
| } jack_transport_state_t; | } jack_transport_state_t; | ||||
| typedef uint64_t jack_unique_t; /**< Unique ID (opaque) */ | |||||
| typedef uint64_t jack_unique_t; /**< Unique ID (opaque) */ | |||||
| /** | /** | ||||
| * Optional struct jack_position_t fields. | * Optional struct jack_position_t fields. | ||||
| */ | */ | ||||
| typedef enum { | typedef enum { | ||||
| JackPositionBBT = 0x10, /**< Bar, Beat, Tick */ | |||||
| JackPositionTimecode = 0x20, /**< External timecode */ | |||||
| JackBBTFrameOffset = 0x40, /**< Frame offset of BBT information */ | |||||
| JackPositionBBT = 0x10, /**< Bar, Beat, Tick */ | |||||
| JackPositionTimecode = 0x20, /**< External timecode */ | |||||
| JackBBTFrameOffset = 0x40, /**< Frame offset of BBT information */ | |||||
| JackAudioVideoRatio = 0x80, /**< audio frames per video frame */ | JackAudioVideoRatio = 0x80, /**< audio frames per video frame */ | ||||
| JackVideoFrameOffset = 0x100 /**< frame offset of first video frame */ | JackVideoFrameOffset = 0x100 /**< frame offset of first video frame */ | ||||
| @@ -487,31 +487,31 @@ typedef enum { | |||||
| typedef struct { | typedef struct { | ||||
| /* these four cannot be set from clients: the server sets them */ | /* these four cannot be set from clients: the server sets them */ | ||||
| jack_unique_t unique_1; /**< unique ID */ | |||||
| jack_time_t usecs; /**< monotonic, free-rolling */ | |||||
| jack_nframes_t frame_rate; /**< current frame rate (per second) */ | |||||
| jack_nframes_t frame; /**< frame number, always present */ | |||||
| jack_unique_t unique_1; /**< unique ID */ | |||||
| jack_time_t usecs; /**< monotonic, free-rolling */ | |||||
| jack_nframes_t frame_rate; /**< current frame rate (per second) */ | |||||
| jack_nframes_t frame; /**< frame number, always present */ | |||||
| jack_position_bits_t valid; /**< which other fields are valid */ | |||||
| jack_position_bits_t valid; /**< which other fields are valid */ | |||||
| /* JackPositionBBT fields: */ | /* JackPositionBBT fields: */ | ||||
| int32_t bar; /**< current bar */ | |||||
| int32_t beat; /**< current beat-within-bar */ | |||||
| int32_t tick; /**< current tick-within-beat */ | |||||
| double bar_start_tick; | |||||
| float beats_per_bar; /**< time signature "numerator" */ | |||||
| float beat_type; /**< time signature "denominator" */ | |||||
| double ticks_per_beat; | |||||
| double beats_per_minute; | |||||
| /* JackPositionTimecode fields: (EXPERIMENTAL: could change) */ | |||||
| double frame_time; /**< current time in seconds */ | |||||
| double next_time; /**< next sequential frame_time | |||||
| int32_t bar; /**< current bar */ | |||||
| int32_t beat; /**< current beat-within-bar */ | |||||
| int32_t tick; /**< current tick-within-beat */ | |||||
| double bar_start_tick; | |||||
| float beats_per_bar; /**< time signature "numerator" */ | |||||
| float beat_type; /**< time signature "denominator" */ | |||||
| double ticks_per_beat; | |||||
| double beats_per_minute; | |||||
| /* JackPositionTimecode fields: (EXPERIMENTAL: could change) */ | |||||
| double frame_time; /**< current time in seconds */ | |||||
| double next_time; /**< next sequential frame_time | |||||
| (unless repositioned) */ | (unless repositioned) */ | ||||
| /* JackBBTFrameOffset fields: */ | /* JackBBTFrameOffset fields: */ | ||||
| jack_nframes_t bbt_offset; /**< frame offset for the BBT fields | |||||
| jack_nframes_t bbt_offset; /**< frame offset for the BBT fields | |||||
| (the given bar, beat, and tick | (the given bar, beat, and tick | ||||
| values actually refer to a time | values actually refer to a time | ||||
| frame_offset frames before the | frame_offset frames before the | ||||
| @@ -545,10 +545,10 @@ typedef struct { | |||||
| /* For binary compatibility, new fields should be allocated from | /* For binary compatibility, new fields should be allocated from | ||||
| * this padding area with new valid bits controlling access, so | * this padding area with new valid bits controlling access, so | ||||
| * the existing structure size and offsets are preserved. */ | * the existing structure size and offsets are preserved. */ | ||||
| int32_t padding[7]; | |||||
| int32_t padding[7]; | |||||
| /* When (unique_1 == unique_2) the contents are consistent. */ | /* When (unique_1 == unique_2) the contents are consistent. */ | ||||
| jack_unique_t unique_2; /**< unique ID */ | |||||
| jack_unique_t unique_2; /**< unique ID */ | |||||
| } jack_position_t; | } jack_position_t; | ||||
| @@ -625,11 +625,11 @@ typedef void (*JackTimebaseCallback)(jack_transport_state_t state, | |||||
| */ | */ | ||||
| typedef enum { | typedef enum { | ||||
| JackTransportState = 0x1, /**< Transport state */ | |||||
| JackTransportPosition = 0x2, /**< Frame number */ | |||||
| JackTransportLoop = 0x4, /**< Loop boundaries (ignored) */ | |||||
| JackTransportSMPTE = 0x8, /**< SMPTE (ignored) */ | |||||
| JackTransportBBT = 0x10 /**< Bar, Beat, Tick */ | |||||
| JackTransportState = 0x1, /**< Transport state */ | |||||
| JackTransportPosition = 0x2, /**< Frame number */ | |||||
| JackTransportLoop = 0x4, /**< Loop boundaries (ignored) */ | |||||
| JackTransportSMPTE = 0x8, /**< SMPTE (ignored) */ | |||||
| JackTransportBBT = 0x10 /**< Bar, Beat, Tick */ | |||||
| } jack_transport_bits_t; | } jack_transport_bits_t; | ||||
| @@ -643,17 +643,17 @@ typedef struct { | |||||
| /* these two cannot be set from clients: the server sets them */ | /* these two cannot be set from clients: the server sets them */ | ||||
| jack_nframes_t frame_rate; /**< current frame rate (per second) */ | |||||
| jack_time_t usecs; /**< monotonic, free-rolling */ | |||||
| jack_nframes_t frame_rate; /**< current frame rate (per second) */ | |||||
| jack_time_t usecs; /**< monotonic, free-rolling */ | |||||
| jack_transport_bits_t valid; /**< which fields are legal to read */ | |||||
| jack_transport_bits_t valid; /**< which fields are legal to read */ | |||||
| jack_transport_state_t transport_state; | jack_transport_state_t transport_state; | ||||
| jack_nframes_t frame; | jack_nframes_t frame; | ||||
| jack_nframes_t loop_start; | jack_nframes_t loop_start; | ||||
| jack_nframes_t loop_end; | jack_nframes_t loop_end; | ||||
| long smpte_offset; /**< SMPTE offset (from frame 0) */ | |||||
| float smpte_frame_rate; /**< 29.97, 30, 24 etc. */ | |||||
| long smpte_offset; /**< SMPTE offset (from frame 0) */ | |||||
| float smpte_frame_rate; /**< 29.97, 30, 24 etc. */ | |||||
| int bar; | int bar; | ||||
| int beat; | int beat; | ||||
| @@ -32,15 +32,15 @@ extern "C" | |||||
| /* variable argument structure */ | /* variable argument structure */ | ||||
| typedef struct { | typedef struct { | ||||
| char *server_name; /* server name */ | |||||
| char *load_name; /* load module name */ | |||||
| char *load_init; /* initialization string */ | |||||
| int session_id; /* requested session_id */ | |||||
| char *server_name; /* server name */ | |||||
| char *load_name; /* load module name */ | |||||
| char *load_init; /* initialization string */ | |||||
| int session_id; /* requested session_id */ | |||||
| } | } | ||||
| jack_varargs_t; | jack_varargs_t; | ||||
| static const char* jack_default_server_name (void) | static const char* jack_default_server_name (void) | ||||
| { | |||||
| { | |||||
| const char *server_name; | const char *server_name; | ||||
| if ((server_name = getenv("JACK_DEFAULT_SERVER")) == NULL) | if ((server_name = getenv("JACK_DEFAULT_SERVER")) == NULL) | ||||
| server_name = "default"; | server_name = "default"; | ||||
| @@ -48,14 +48,14 @@ extern "C" | |||||
| } | } | ||||
| static inline void jack_varargs_init (jack_varargs_t *va) | static inline void jack_varargs_init (jack_varargs_t *va) | ||||
| { | |||||
| { | |||||
| memset (va, 0, sizeof(jack_varargs_t)); | memset (va, 0, sizeof(jack_varargs_t)); | ||||
| va->server_name = (char*)jack_default_server_name(); | va->server_name = (char*)jack_default_server_name(); | ||||
| va->session_id = -1; | |||||
| va->session_id = -1; | |||||
| } | } | ||||
| static inline void jack_varargs_parse (jack_options_t options, va_list ap, jack_varargs_t *va) | static inline void jack_varargs_parse (jack_options_t options, va_list ap, jack_varargs_t *va) | ||||
| { | |||||
| { | |||||
| // initialize default settings | // initialize default settings | ||||
| jack_varargs_init (va); | jack_varargs_init (va); | ||||
| @@ -30,7 +30,7 @@ | |||||
| #include <jack/transport.h> | #include <jack/transport.h> | ||||
| #include <jack/session.h> | #include <jack/session.h> | ||||
| char *package; /* program name */ | |||||
| char *package; /* program name */ | |||||
| jack_client_t *client; | jack_client_t *client; | ||||
| jack_session_event_type_t notify_type; | jack_session_event_type_t notify_type; | ||||
| @@ -38,147 +38,147 @@ char *save_path = NULL; | |||||
| void jack_shutdown(void *arg) | void jack_shutdown(void *arg) | ||||
| { | { | ||||
| fprintf(stderr, "JACK shut down, exiting ...\n"); | |||||
| exit(1); | |||||
| fprintf(stderr, "JACK shut down, exiting ...\n"); | |||||
| exit(1); | |||||
| } | } | ||||
| void signal_handler(int sig) | void signal_handler(int sig) | ||||
| { | { | ||||
| jack_client_close(client); | |||||
| fprintf(stderr, "signal received, exiting ...\n"); | |||||
| exit(0); | |||||
| jack_client_close(client); | |||||
| fprintf(stderr, "signal received, exiting ...\n"); | |||||
| exit(0); | |||||
| } | } | ||||
| void parse_arguments(int argc, char *argv[]) | void parse_arguments(int argc, char *argv[]) | ||||
| { | { | ||||
| /* basename $0 */ | |||||
| package = strrchr(argv[0], '/'); | |||||
| if (package == 0) | |||||
| package = argv[0]; | |||||
| else | |||||
| package++; | |||||
| if (argc==2) { | |||||
| if( !strcmp( argv[1], "quit" ) ) { | |||||
| notify_type = JackSessionSaveAndQuit; | |||||
| return; | |||||
| } | |||||
| } | |||||
| if (argc==3) { | |||||
| if( !strcmp( argv[1], "save" ) ) { | |||||
| notify_type = JackSessionSave; | |||||
| save_path = argv[2]; | |||||
| return; | |||||
| } | |||||
| } | |||||
| fprintf(stderr, "usage: %s quit|save [path]\n", package); | |||||
| exit(9); | |||||
| /* basename $0 */ | |||||
| package = strrchr(argv[0], '/'); | |||||
| if (package == 0) | |||||
| package = argv[0]; | |||||
| else | |||||
| package++; | |||||
| if (argc==2) { | |||||
| if( !strcmp( argv[1], "quit" ) ) { | |||||
| notify_type = JackSessionSaveAndQuit; | |||||
| return; | |||||
| } | |||||
| } | |||||
| if (argc==3) { | |||||
| if( !strcmp( argv[1], "save" ) ) { | |||||
| notify_type = JackSessionSave; | |||||
| save_path = argv[2]; | |||||
| return; | |||||
| } | |||||
| } | |||||
| fprintf(stderr, "usage: %s quit|save [path]\n", package); | |||||
| exit(9); | |||||
| } | } | ||||
| typedef struct { | typedef struct { | ||||
| char name[32]; | |||||
| char uuid[16]; | |||||
| char name[32]; | |||||
| char uuid[16]; | |||||
| } uuid_map_t; | } uuid_map_t; | ||||
| JSList *uuid_map = NULL; | JSList *uuid_map = NULL; | ||||
| void add_uuid_mapping( const char *uuid ) { | void add_uuid_mapping( const char *uuid ) { | ||||
| char *clientname = jack_get_client_name_by_uuid( client, uuid ); | |||||
| if( !clientname ) { | |||||
| printf( "error... cant find client for uuid %s", uuid ); | |||||
| char *clientname = jack_get_client_name_by_uuid( client, uuid ); | |||||
| if( !clientname ) { | |||||
| printf( "error... cant find client for uuid %s", uuid ); | |||||
| return; | |||||
| } | |||||
| return; | |||||
| } | |||||
| uuid_map_t *mapping = malloc( sizeof(uuid_map_t) ); | |||||
| snprintf( mapping->uuid, sizeof(mapping->uuid), "%s", uuid ); | |||||
| snprintf( mapping->name, sizeof(mapping->name), "%s", clientname ); | |||||
| uuid_map = jack_slist_append( uuid_map, mapping ); | |||||
| uuid_map_t *mapping = malloc( sizeof(uuid_map_t) ); | |||||
| snprintf( mapping->uuid, sizeof(mapping->uuid), "%s", uuid ); | |||||
| snprintf( mapping->name, sizeof(mapping->name), "%s", clientname ); | |||||
| uuid_map = jack_slist_append( uuid_map, mapping ); | |||||
| } | } | ||||
| char *map_port_name_to_uuid_port( const char *port_name ) | char *map_port_name_to_uuid_port( const char *port_name ) | ||||
| { | { | ||||
| JSList *node; | |||||
| char retval[300]; | |||||
| char *port_component = strchr( port_name,':' ); | |||||
| char *client_component = strdup( port_name ); | |||||
| strchr( client_component, ':' )[0] = '\0'; | |||||
| sprintf( retval, "%s", port_name ); | |||||
| for( node=uuid_map; node; node=jack_slist_next(node) ) { | |||||
| uuid_map_t *mapping = node->data; | |||||
| if( !strcmp( mapping->name, client_component ) ) { | |||||
| sprintf( retval, "%s%s", mapping->uuid, port_component ); | |||||
| break; | |||||
| } | |||||
| } | |||||
| return strdup(retval); | |||||
| JSList *node; | |||||
| char retval[300]; | |||||
| char *port_component = strchr( port_name,':' ); | |||||
| char *client_component = strdup( port_name ); | |||||
| strchr( client_component, ':' )[0] = '\0'; | |||||
| sprintf( retval, "%s", port_name ); | |||||
| for( node=uuid_map; node; node=jack_slist_next(node) ) { | |||||
| uuid_map_t *mapping = node->data; | |||||
| if( !strcmp( mapping->name, client_component ) ) { | |||||
| sprintf( retval, "%s%s", mapping->uuid, port_component ); | |||||
| break; | |||||
| } | |||||
| } | |||||
| return strdup(retval); | |||||
| } | } | ||||
| int main(int argc, char *argv[]) | int main(int argc, char *argv[]) | ||||
| { | { | ||||
| parse_arguments(argc, argv); | |||||
| jack_session_command_t *retval; | |||||
| int k,i,j; | |||||
| /* become a JACK client */ | |||||
| if ((client = jack_client_open(package, JackNullOption, NULL)) == 0) { | |||||
| fprintf(stderr, "JACK server not running?\n"); | |||||
| exit(1); | |||||
| } | |||||
| signal(SIGQUIT, signal_handler); | |||||
| signal(SIGTERM, signal_handler); | |||||
| signal(SIGHUP, signal_handler); | |||||
| signal(SIGINT, signal_handler); | |||||
| jack_on_shutdown(client, jack_shutdown, 0); | |||||
| jack_activate(client); | |||||
| retval = jack_session_notify( client, NULL, notify_type, save_path ); | |||||
| printf( "retval = %p\n", retval ); | |||||
| for(i=0; retval[i].uuid; i++ ) { | |||||
| printf( "export SESSION_DIR=\"%s%s/\"\n", save_path, retval[i].client_name ); | |||||
| printf( "%s &\n", retval[i].command ); | |||||
| add_uuid_mapping(retval[i].uuid); | |||||
| } | |||||
| printf( "sleep 10\n" ); | |||||
| for(k=0; retval[k].uuid; k++ ) { | |||||
| char* port_regexp = alloca( jack_client_name_size()+3 ); | |||||
| char* client_name = jack_get_client_name_by_uuid( client, retval[k].uuid ); | |||||
| snprintf( port_regexp, jack_client_name_size()+3, "%s:.*", client_name ); | |||||
| jack_free(client_name); | |||||
| const char **ports = jack_get_ports( client, port_regexp, NULL, 0 ); | |||||
| if( !ports ) { | |||||
| continue; | |||||
| } | |||||
| for (i = 0; ports[i]; ++i) { | |||||
| const char **connections; | |||||
| if ((connections = jack_port_get_all_connections (client, jack_port_by_name(client, ports[i]))) != 0) { | |||||
| for (j = 0; connections[j]; j++) { | |||||
| char *src = map_port_name_to_uuid_port( ports[i] ); | |||||
| char *dst = map_port_name_to_uuid_port( connections[j] ); | |||||
| printf( "jack_connect -u \"%s\" \"%s\"\n", src, dst ); | |||||
| } | |||||
| jack_free (connections); | |||||
| } | |||||
| } | |||||
| jack_free(ports); | |||||
| } | |||||
| jack_session_commands_free(retval); | |||||
| jack_client_close(client); | |||||
| return 0; | |||||
| parse_arguments(argc, argv); | |||||
| jack_session_command_t *retval; | |||||
| int k,i,j; | |||||
| /* become a JACK client */ | |||||
| if ((client = jack_client_open(package, JackNullOption, NULL)) == 0) { | |||||
| fprintf(stderr, "JACK server not running?\n"); | |||||
| exit(1); | |||||
| } | |||||
| signal(SIGQUIT, signal_handler); | |||||
| signal(SIGTERM, signal_handler); | |||||
| signal(SIGHUP, signal_handler); | |||||
| signal(SIGINT, signal_handler); | |||||
| jack_on_shutdown(client, jack_shutdown, 0); | |||||
| jack_activate(client); | |||||
| retval = jack_session_notify( client, NULL, notify_type, save_path ); | |||||
| printf( "retval = %p\n", retval ); | |||||
| for(i=0; retval[i].uuid; i++ ) { | |||||
| printf( "export SESSION_DIR=\"%s%s/\"\n", save_path, retval[i].client_name ); | |||||
| printf( "%s &\n", retval[i].command ); | |||||
| add_uuid_mapping(retval[i].uuid); | |||||
| } | |||||
| printf( "sleep 10\n" ); | |||||
| for(k=0; retval[k].uuid; k++ ) { | |||||
| char* port_regexp = alloca( jack_client_name_size()+3 ); | |||||
| char* client_name = jack_get_client_name_by_uuid( client, retval[k].uuid ); | |||||
| snprintf( port_regexp, jack_client_name_size()+3, "%s:.*", client_name ); | |||||
| jack_free(client_name); | |||||
| const char **ports = jack_get_ports( client, port_regexp, NULL, 0 ); | |||||
| if( !ports ) { | |||||
| continue; | |||||
| } | |||||
| for (i = 0; ports[i]; ++i) { | |||||
| const char **connections; | |||||
| if ((connections = jack_port_get_all_connections (client, jack_port_by_name(client, ports[i]))) != 0) { | |||||
| for (j = 0; connections[j]; j++) { | |||||
| char *src = map_port_name_to_uuid_port( ports[i] ); | |||||
| char *dst = map_port_name_to_uuid_port( connections[j] ); | |||||
| printf( "jack_connect -u \"%s\" \"%s\"\n", src, dst ); | |||||
| } | |||||
| jack_free (connections); | |||||
| } | |||||
| } | |||||
| jack_free(ports); | |||||
| } | |||||
| jack_session_commands_free(retval); | |||||
| jack_client_close(client); | |||||
| return 0; | |||||
| } | } | ||||
| @@ -32,34 +32,34 @@ int simple_quit = 0; | |||||
| int | int | ||||
| process (jack_nframes_t nframes, void *arg) | process (jack_nframes_t nframes, void *arg) | ||||
| { | { | ||||
| jack_default_audio_sample_t *in, *out; | |||||
| jack_default_audio_sample_t *in, *out; | |||||
| in = jack_port_get_buffer (input_port, nframes); | |||||
| out = jack_port_get_buffer (output_port, nframes); | |||||
| memcpy (out, in, | |||||
| sizeof (jack_default_audio_sample_t) * nframes); | |||||
| in = jack_port_get_buffer (input_port, nframes); | |||||
| out = jack_port_get_buffer (output_port, nframes); | |||||
| memcpy (out, in, | |||||
| sizeof (jack_default_audio_sample_t) * nframes); | |||||
| return 0; | |||||
| return 0; | |||||
| } | } | ||||
| void | void | ||||
| session_callback (jack_session_event_t *event, void *arg) | session_callback (jack_session_event_t *event, void *arg) | ||||
| { | { | ||||
| char retval[100]; | |||||
| printf ("session notification\n"); | |||||
| printf ("path %s, uuid %s, type: %s\n", event->session_dir, event->client_uuid, event->type == JackSessionSave ? "save" : "quit"); | |||||
| char retval[100]; | |||||
| printf ("session notification\n"); | |||||
| printf ("path %s, uuid %s, type: %s\n", event->session_dir, event->client_uuid, event->type == JackSessionSave ? "save" : "quit"); | |||||
| snprintf (retval, 100, "jack_simple_session_client %s", event->client_uuid); | |||||
| event->command_line = strdup (retval); | |||||
| snprintf (retval, 100, "jack_simple_session_client %s", event->client_uuid); | |||||
| event->command_line = strdup (retval); | |||||
| jack_session_reply( client, event ); | |||||
| jack_session_reply( client, event ); | |||||
| if (event->type == JackSessionSaveAndQuit) { | |||||
| simple_quit = 1; | |||||
| } | |||||
| if (event->type == JackSessionSaveAndQuit) { | |||||
| simple_quit = 1; | |||||
| } | |||||
| jack_session_event_free (event); | |||||
| jack_session_event_free (event); | |||||
| } | } | ||||
| /** | /** | ||||
| @@ -69,134 +69,134 @@ session_callback (jack_session_event_t *event, void *arg) | |||||
| void | void | ||||
| jack_shutdown (void *arg) | jack_shutdown (void *arg) | ||||
| { | { | ||||
| exit (1); | |||||
| exit (1); | |||||
| } | } | ||||
| int | int | ||||
| main (int argc, char *argv[]) | main (int argc, char *argv[]) | ||||
| { | { | ||||
| const char **ports; | |||||
| const char *client_name = "simple"; | |||||
| jack_status_t status; | |||||
| /* open a client connection to the JACK server */ | |||||
| if( argc == 1 ) | |||||
| client = jack_client_open (client_name, JackNullOption, &status ); | |||||
| else if( argc == 2 ) | |||||
| client = jack_client_open (client_name, JackSessionID, &status, argv[1] ); | |||||
| if (client == NULL) { | |||||
| fprintf (stderr, "jack_client_open() failed, " | |||||
| "status = 0x%2.0x\n", status); | |||||
| if (status & JackServerFailed) { | |||||
| fprintf (stderr, "Unable to connect to JACK server\n"); | |||||
| } | |||||
| exit (1); | |||||
| } | |||||
| if (status & JackServerStarted) { | |||||
| fprintf (stderr, "JACK server started\n"); | |||||
| } | |||||
| if (status & JackNameNotUnique) { | |||||
| client_name = jack_get_client_name(client); | |||||
| fprintf (stderr, "unique name `%s' assigned\n", client_name); | |||||
| } | |||||
| /* tell the JACK server to call `process()' whenever | |||||
| there is work to be done. | |||||
| */ | |||||
| jack_set_process_callback (client, process, 0); | |||||
| /* tell the JACK server to call `jack_shutdown()' if | |||||
| it ever shuts down, either entirely, or if it | |||||
| just decides to stop calling us. | |||||
| */ | |||||
| jack_on_shutdown (client, jack_shutdown, 0); | |||||
| /* tell the JACK server to call `session_callback()' if | |||||
| the session is saved. | |||||
| */ | |||||
| jack_set_session_callback (client, session_callback, NULL); | |||||
| /* display the current sample rate. | |||||
| */ | |||||
| printf ("engine sample rate: %" PRIu32 "\n", | |||||
| jack_get_sample_rate (client)); | |||||
| /* create two ports */ | |||||
| input_port = jack_port_register (client, "input", | |||||
| JACK_DEFAULT_AUDIO_TYPE, | |||||
| JackPortIsInput, 0); | |||||
| output_port = jack_port_register (client, "output", | |||||
| JACK_DEFAULT_AUDIO_TYPE, | |||||
| JackPortIsOutput, 0); | |||||
| if ((input_port == NULL) || (output_port == NULL)) { | |||||
| fprintf(stderr, "no more JACK ports available\n"); | |||||
| exit (1); | |||||
| } | |||||
| /* Tell the JACK server that we are ready to roll. Our | |||||
| * process() callback will start running now. */ | |||||
| if (jack_activate (client)) { | |||||
| fprintf (stderr, "cannot activate client"); | |||||
| exit (1); | |||||
| } | |||||
| /* Connect the ports. You can't do this before the client is | |||||
| * activated, because we can't make connections to clients | |||||
| * that aren't running. Note the confusing (but necessary) | |||||
| * orientation of the driver backend ports: playback ports are | |||||
| * "input" to the backend, and capture ports are "output" from | |||||
| * it. | |||||
| */ | |||||
| /* only do the autoconnect when not reloading from a session. | |||||
| * in case of a session reload, the SM will restore our connections | |||||
| */ | |||||
| if (argc==1) { | |||||
| ports = jack_get_ports (client, NULL, NULL, | |||||
| JackPortIsPhysical|JackPortIsOutput); | |||||
| if (ports == NULL) { | |||||
| fprintf(stderr, "no physical capture ports\n"); | |||||
| exit (1); | |||||
| } | |||||
| if (jack_connect (client, ports[0], jack_port_name (input_port))) { | |||||
| fprintf (stderr, "cannot connect input ports\n"); | |||||
| } | |||||
| free (ports); | |||||
| ports = jack_get_ports (client, NULL, NULL, | |||||
| JackPortIsPhysical|JackPortIsInput); | |||||
| if (ports == NULL) { | |||||
| fprintf(stderr, "no physical playback ports\n"); | |||||
| exit (1); | |||||
| } | |||||
| if (jack_connect (client, jack_port_name (output_port), ports[0])) { | |||||
| fprintf (stderr, "cannot connect output ports\n"); | |||||
| } | |||||
| free (ports); | |||||
| } | |||||
| /* keep running until until we get a quit event */ | |||||
| const char **ports; | |||||
| const char *client_name = "simple"; | |||||
| jack_status_t status; | |||||
| /* open a client connection to the JACK server */ | |||||
| if( argc == 1 ) | |||||
| client = jack_client_open (client_name, JackNullOption, &status ); | |||||
| else if( argc == 2 ) | |||||
| client = jack_client_open (client_name, JackSessionID, &status, argv[1] ); | |||||
| if (client == NULL) { | |||||
| fprintf (stderr, "jack_client_open() failed, " | |||||
| "status = 0x%2.0x\n", status); | |||||
| if (status & JackServerFailed) { | |||||
| fprintf (stderr, "Unable to connect to JACK server\n"); | |||||
| } | |||||
| exit (1); | |||||
| } | |||||
| if (status & JackServerStarted) { | |||||
| fprintf (stderr, "JACK server started\n"); | |||||
| } | |||||
| if (status & JackNameNotUnique) { | |||||
| client_name = jack_get_client_name(client); | |||||
| fprintf (stderr, "unique name `%s' assigned\n", client_name); | |||||
| } | |||||
| /* tell the JACK server to call `process()' whenever | |||||
| there is work to be done. | |||||
| */ | |||||
| jack_set_process_callback (client, process, 0); | |||||
| /* tell the JACK server to call `jack_shutdown()' if | |||||
| it ever shuts down, either entirely, or if it | |||||
| just decides to stop calling us. | |||||
| */ | |||||
| jack_on_shutdown (client, jack_shutdown, 0); | |||||
| /* tell the JACK server to call `session_callback()' if | |||||
| the session is saved. | |||||
| */ | |||||
| jack_set_session_callback (client, session_callback, NULL); | |||||
| /* display the current sample rate. | |||||
| */ | |||||
| printf ("engine sample rate: %" PRIu32 "\n", | |||||
| jack_get_sample_rate (client)); | |||||
| /* create two ports */ | |||||
| input_port = jack_port_register (client, "input", | |||||
| JACK_DEFAULT_AUDIO_TYPE, | |||||
| JackPortIsInput, 0); | |||||
| output_port = jack_port_register (client, "output", | |||||
| JACK_DEFAULT_AUDIO_TYPE, | |||||
| JackPortIsOutput, 0); | |||||
| if ((input_port == NULL) || (output_port == NULL)) { | |||||
| fprintf(stderr, "no more JACK ports available\n"); | |||||
| exit (1); | |||||
| } | |||||
| /* Tell the JACK server that we are ready to roll. Our | |||||
| * process() callback will start running now. */ | |||||
| if (jack_activate (client)) { | |||||
| fprintf (stderr, "cannot activate client"); | |||||
| exit (1); | |||||
| } | |||||
| /* Connect the ports. You can't do this before the client is | |||||
| * activated, because we can't make connections to clients | |||||
| * that aren't running. Note the confusing (but necessary) | |||||
| * orientation of the driver backend ports: playback ports are | |||||
| * "input" to the backend, and capture ports are "output" from | |||||
| * it. | |||||
| */ | |||||
| /* only do the autoconnect when not reloading from a session. | |||||
| * in case of a session reload, the SM will restore our connections | |||||
| */ | |||||
| if (argc==1) { | |||||
| ports = jack_get_ports (client, NULL, NULL, | |||||
| JackPortIsPhysical|JackPortIsOutput); | |||||
| if (ports == NULL) { | |||||
| fprintf(stderr, "no physical capture ports\n"); | |||||
| exit (1); | |||||
| } | |||||
| if (jack_connect (client, ports[0], jack_port_name (input_port))) { | |||||
| fprintf (stderr, "cannot connect input ports\n"); | |||||
| } | |||||
| free (ports); | |||||
| ports = jack_get_ports (client, NULL, NULL, | |||||
| JackPortIsPhysical|JackPortIsInput); | |||||
| if (ports == NULL) { | |||||
| fprintf(stderr, "no physical playback ports\n"); | |||||
| exit (1); | |||||
| } | |||||
| if (jack_connect (client, jack_port_name (output_port), ports[0])) { | |||||
| fprintf (stderr, "cannot connect output ports\n"); | |||||
| } | |||||
| free (ports); | |||||
| } | |||||
| /* keep running until until we get a quit event */ | |||||
| while (!simple_quit) | |||||
| sleep(1); | |||||
| while (!simple_quit) | |||||
| sleep(1); | |||||
| jack_client_close (client); | |||||
| exit (0); | |||||
| jack_client_close (client); | |||||
| exit (0); | |||||
| } | } | ||||
| @@ -117,7 +117,7 @@ int JackPosixThread::StartImp(pthread_t* thread, int priority, int realtime, voi | |||||
| if ((res = pthread_attr_setinheritsched(&attributes, PTHREAD_EXPLICIT_SCHED))) { | if ((res = pthread_attr_setinheritsched(&attributes, PTHREAD_EXPLICIT_SCHED))) { | ||||
| jack_error("Cannot request explicit scheduling for RT thread res = %d", res); | jack_error("Cannot request explicit scheduling for RT thread res = %d", res); | ||||
| return -1; | return -1; | ||||
| } | |||||
| } | |||||
| if ((res = pthread_attr_setschedpolicy(&attributes, JACK_SCHED_POLICY))) { | if ((res = pthread_attr_setschedpolicy(&attributes, JACK_SCHED_POLICY))) { | ||||
| jack_error("Cannot set RR scheduling class for RT thread res = %d", res); | jack_error("Cannot set RR scheduling class for RT thread res = %d", res); | ||||
| @@ -68,11 +68,11 @@ class SERVER_EXPORT JackPosixThread : public detail::JackThreadInterface | |||||
| int DropSelfRealTime(); // Used when called from thread itself | int DropSelfRealTime(); // Used when called from thread itself | ||||
| pthread_t GetThreadID(); | pthread_t GetThreadID(); | ||||
| bool IsThread(); | |||||
| bool IsThread(); | |||||
| static int AcquireRealTimeImp(pthread_t thread, int priority); | static int AcquireRealTimeImp(pthread_t thread, int priority); | ||||
| static int AcquireRealTimeImp(pthread_t thread, int priority, UInt64 period, UInt64 computation, UInt64 constraint) | static int AcquireRealTimeImp(pthread_t thread, int priority, UInt64 period, UInt64 computation, UInt64 constraint) | ||||
| { return JackPosixThread::AcquireRealTimeImp(thread, priority); } | |||||
| { return JackPosixThread::AcquireRealTimeImp(thread, priority); } | |||||
| static int DropRealTimeImp(pthread_t thread); | static int DropRealTimeImp(pthread_t thread); | ||||
| static int StartImp(pthread_t* thread, int priority, int realtime, void*(*start_routine)(void*), void* arg); | static int StartImp(pthread_t* thread, int priority, int realtime, void*(*start_routine)(void*), void* arg); | ||||
| static int StopImp(pthread_t thread); | static int StopImp(pthread_t thread); | ||||
| @@ -38,11 +38,11 @@ class JackSocketClientChannel : public detail::JackClientChannelInterface, publi | |||||
| private: | private: | ||||
| JackClientSocket fRequestSocket; // Socket to communicate with the server | |||||
| JackServerSocket fNotificationListenSocket; // Socket listener for server notification | |||||
| JackClientSocket* fNotificationSocket; // Socket for server notification | |||||
| JackClientSocket fRequestSocket; // Socket to communicate with the server | |||||
| JackServerSocket fNotificationListenSocket; // Socket listener for server notification | |||||
| JackClientSocket* fNotificationSocket; // Socket for server notification | |||||
| JackThread fThread; // Thread to execute the event loop | JackThread fThread; // Thread to execute the event loop | ||||
| JackClient* fClient; | |||||
| JackClient* fClient; | |||||
| void ServerSyncCall(JackRequest* req, JackResult* res, int* result); | void ServerSyncCall(JackRequest* req, JackResult* res, int* result); | ||||
| void ServerAsyncCall(JackRequest* req, JackResult* res, int* result); | void ServerAsyncCall(JackRequest* req, JackResult* res, int* result); | ||||
| @@ -91,19 +91,19 @@ class JackSocketClientChannel : public detail::JackClientChannelInterface, publi | |||||
| void InternalClientLoad(int refnum, const char* client_name, const char* so_name, const char* objet_data, int options, int* status, int* int_ref, int* result, int uuid); | void InternalClientLoad(int refnum, const char* client_name, const char* so_name, const char* objet_data, int options, int* status, int* int_ref, int* result, int uuid); | ||||
| void InternalClientUnload(int refnum, int int_ref, int* status, int* result); | void InternalClientUnload(int refnum, int int_ref, int* status, int* result); | ||||
| // Session Stuff | |||||
| void SessionNotify(int refnum, const char* target, jack_session_event_type_t type, const char* path, jack_session_command_t** result); | |||||
| void SessionReply(int refnum, int* result); | |||||
| void GetUUIDForClientName( int refnum, const char *client_name, char *uuid_res, int *result ); | |||||
| void GetClientNameForUUID( int refnum, const char *uuid, char *name_res, int *result ); | |||||
| void ReserveClientName( int refnum, const char *client_name, const char *uuid, int *result ); | |||||
| // Session Stuff | |||||
| void SessionNotify(int refnum, const char* target, jack_session_event_type_t type, const char* path, jack_session_command_t** result); | |||||
| void SessionReply(int refnum, int* result); | |||||
| void GetUUIDForClientName( int refnum, const char *client_name, char *uuid_res, int *result ); | |||||
| void GetClientNameForUUID( int refnum, const char *uuid, char *name_res, int *result ); | |||||
| void ReserveClientName( int refnum, const char *client_name, const char *uuid, int *result ); | |||||
| // JackRunnableInterface interface | // JackRunnableInterface interface | ||||
| bool Init(); | bool Init(); | ||||
| bool Execute(); | bool Execute(); | ||||
| bool IsChannelThread() { return fThread.IsThread(); } | |||||
| bool IsChannelThread() { return fThread.IsThread(); } | |||||
| }; | }; | ||||
| } // end of namespace | } // end of namespace | ||||
| @@ -405,7 +405,7 @@ bool JackSocketServerChannel::HandleRequest(int fd) | |||||
| JackSessionNotifyRequest req; | JackSessionNotifyRequest req; | ||||
| JackSessionNotifyResult res; | JackSessionNotifyResult res; | ||||
| if (req.Read(socket) == 0) { | if (req.Read(socket) == 0) { | ||||
| fServer->GetEngine()->SessionNotify(req.fRefNum, req.fDst, req.fEventType, req.fPath, socket); | |||||
| fServer->GetEngine()->SessionNotify(req.fRefNum, req.fDst, req.fEventType, req.fPath, socket); | |||||
| } | } | ||||
| break; | break; | ||||
| } | } | ||||
| @@ -415,8 +415,8 @@ bool JackSocketServerChannel::HandleRequest(int fd) | |||||
| JackSessionReplyRequest req; | JackSessionReplyRequest req; | ||||
| JackResult res; | JackResult res; | ||||
| if (req.Read(socket) == 0) { | if (req.Read(socket) == 0) { | ||||
| fServer->GetEngine()->SessionReply(req.fRefNum); | |||||
| res.fResult = 0; | |||||
| fServer->GetEngine()->SessionReply(req.fRefNum); | |||||
| res.fResult = 0; | |||||
| } | } | ||||
| break; | break; | ||||
| } | } | ||||
| @@ -426,7 +426,7 @@ bool JackSocketServerChannel::HandleRequest(int fd) | |||||
| JackGetClientNameRequest req; | JackGetClientNameRequest req; | ||||
| JackClientNameResult res; | JackClientNameResult res; | ||||
| if (req.Read(socket) == 0) { | if (req.Read(socket) == 0) { | ||||
| fServer->GetEngine()->GetClientNameForUUID(req.fUUID, res.fName, &res.fResult); | |||||
| fServer->GetEngine()->GetClientNameForUUID(req.fUUID, res.fName, &res.fResult); | |||||
| } | } | ||||
| if (res.Write(socket) < 0) | if (res.Write(socket) < 0) | ||||
| jack_error("JackRequest::GetClientNameForUUID write error"); | jack_error("JackRequest::GetClientNameForUUID write error"); | ||||
| @@ -438,8 +438,8 @@ bool JackSocketServerChannel::HandleRequest(int fd) | |||||
| JackGetUUIDRequest req; | JackGetUUIDRequest req; | ||||
| JackUUIDResult res; | JackUUIDResult res; | ||||
| if (req.Read(socket) == 0) { | if (req.Read(socket) == 0) { | ||||
| fServer->GetEngine()->GetUUIDForClientName(req.fName, res.fUUID, &res.fResult); | |||||
| res.fResult = 0; | |||||
| fServer->GetEngine()->GetUUIDForClientName(req.fName, res.fUUID, &res.fResult); | |||||
| res.fResult = 0; | |||||
| } | } | ||||
| if (res.Write(socket) < 0) | if (res.Write(socket) < 0) | ||||
| jack_error("JackRequest::GetUUIDForClientName write error"); | jack_error("JackRequest::GetUUIDForClientName write error"); | ||||
| @@ -451,8 +451,8 @@ bool JackSocketServerChannel::HandleRequest(int fd) | |||||
| JackReserveNameRequest req; | JackReserveNameRequest req; | ||||
| JackResult res; | JackResult res; | ||||
| if (req.Read(socket) == 0) { | if (req.Read(socket) == 0) { | ||||
| fServer->GetEngine()->ReserveClientName(req.fName, req.fUUID, &res.fResult); | |||||
| res.fResult = 0; | |||||
| fServer->GetEngine()->ReserveClientName(req.fName, req.fUUID, &res.fResult); | |||||
| res.fResult = 0; | |||||
| } | } | ||||
| if (res.Write(socket) < 0) | if (res.Write(socket) < 0) | ||||
| jack_error("JackRequest::ReserveClientName write error"); | jack_error("JackRequest::ReserveClientName write error"); | ||||
| @@ -39,10 +39,10 @@ class JackSocketServerChannel : public JackRunnableInterface | |||||
| private: | private: | ||||
| JackServerSocket fRequestListenSocket; // Socket to create request socket for the client | |||||
| JackServerSocket fRequestListenSocket; // Socket to create request socket for the client | |||||
| JackThread fThread; // Thread to execute the event loop | JackThread fThread; // Thread to execute the event loop | ||||
| JackServer* fServer; | |||||
| pollfd* fPollTable; | |||||
| JackServer* fServer; | |||||
| pollfd* fPollTable; | |||||
| bool fRebuild; | bool fRebuild; | ||||
| std::map<int, std::pair<int, JackClientSocket*> > fSocketTable; | std::map<int, std::pair<int, JackClientSocket*> > fSocketTable; | ||||
| @@ -53,7 +53,7 @@ JackClientPipeThread::~JackClientPipeThread() | |||||
| delete fPipe; | delete fPipe; | ||||
| } | } | ||||
| int JackClientPipeThread::Open(JackServer* server) // Open the Server/Client connection | |||||
| int JackClientPipeThread::Open(JackServer* server) // Open the Server/Client connection | |||||
| { | { | ||||
| // Start listening | // Start listening | ||||
| if (fThread.Start() != 0) { | if (fThread.Start() != 0) { | ||||
| @@ -65,13 +65,13 @@ int JackClientPipeThread::Open(JackServer* server) // Open the Server/Client con | |||||
| return 0; | return 0; | ||||
| } | } | ||||
| void JackClientPipeThread::Close() // Close the Server/Client connection | |||||
| void JackClientPipeThread::Close() // Close the Server/Client connection | |||||
| { | { | ||||
| jack_log("JackClientPipeThread::Close %x %ld", this, fRefNum); | jack_log("JackClientPipeThread::Close %x %ld", this, fRefNum); | ||||
| /* | /* | ||||
| TODO : solve WIN32 thread Kill issue | |||||
| This would hang.. since Close will be followed by a delete, | |||||
| all ressources will be desallocated at the end. | |||||
| TODO : solve WIN32 thread Kill issue | |||||
| This would hang.. since Close will be followed by a delete, | |||||
| all ressources will be desallocated at the end. | |||||
| */ | */ | ||||
| fThread.Kill(); | fThread.Kill(); | ||||
| @@ -326,16 +326,16 @@ bool JackClientPipeThread::HandleRequest() | |||||
| break; | break; | ||||
| } | } | ||||
| case JackRequest::kSessionNotify: { | |||||
| jack_log("JackRequest::SessionNotify"); | |||||
| JackSessionNotifyRequest req; | |||||
| JackSessionNotifyResult res; | |||||
| if (req.Read(fPipe) == 0) { | |||||
| fServer->GetEngine()->SessionNotify(req.fRefNum, req.fDst, req.fEventType, req.fPath); | |||||
| } | |||||
| res.Write(fPipe); | |||||
| break; | |||||
| } | |||||
| case JackRequest::kSessionNotify: { | |||||
| jack_log("JackRequest::SessionNotify"); | |||||
| JackSessionNotifyRequest req; | |||||
| JackSessionNotifyResult res; | |||||
| if (req.Read(fPipe) == 0) { | |||||
| fServer->GetEngine()->SessionNotify(req.fRefNum, req.fDst, req.fEventType, req.fPath); | |||||
| } | |||||
| res.Write(fPipe); | |||||
| break; | |||||
| } | |||||
| default: | default: | ||||
| jack_log("Unknown request %ld", header.fType); | jack_log("Unknown request %ld", header.fType); | ||||
| @@ -369,7 +369,7 @@ void JackClientPipeThread::ClientKill() | |||||
| { | { | ||||
| jack_log("JackClientPipeThread::ClientKill ref = %d", fRefNum); | jack_log("JackClientPipeThread::ClientKill ref = %d", fRefNum); | ||||
| if (fRefNum == -1) { // Correspond to an already removed client. | |||||
| if (fRefNum == -1) { // Correspond to an already removed client. | |||||
| jack_log("Kill a closed client"); | jack_log("Kill a closed client"); | ||||
| } else if (fRefNum == 0) { // Correspond to a still not opened client. | } else if (fRefNum == 0) { // Correspond to a still not opened client. | ||||
| jack_log("Kill a not opened client"); | jack_log("Kill a not opened client"); | ||||
| @@ -412,10 +412,10 @@ int JackWinNamedPipeServerChannel::Open(const char* server_name, JackServer* ser | |||||
| void JackWinNamedPipeServerChannel::Close() | void JackWinNamedPipeServerChannel::Close() | ||||
| { | { | ||||
| /* TODO : solve WIN32 thread Kill issue | /* TODO : solve WIN32 thread Kill issue | ||||
| This would hang the server... since we are quitting it, its not really problematic, | |||||
| all ressources will be desallocated at the end. | |||||
| This would hang the server... since we are quitting it, its not really problematic, | |||||
| all ressources will be desallocated at the end. | |||||
| fRequestListenPipe.Close(); | |||||
| fRequestListenPipe.Close(); | |||||
| fThread.Stop(); | fThread.Stop(); | ||||
| */ | */ | ||||