Signed-off-by: falkTX <falktx@falktx.com>pull/854/merge
@@ -28,6 +28,7 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. | |||
#include "JackGlobals.h" | |||
#include "JackTime.h" | |||
#include "JackPortType.h" | |||
#include "JackMetadata.h" | |||
#include <math.h> | |||
using namespace Jack; | |||
@@ -277,6 +278,16 @@ extern "C" | |||
LIB_EXPORT void jack_uuid_unparse(jack_uuid_t, char buf[JACK_UUID_STRING_SIZE]); | |||
LIB_EXPORT int jack_uuid_empty(jack_uuid_t); | |||
LIB_EXPORT int jack_set_property(jack_client_t*, jack_uuid_t subject, const char* key, const char* value, const char* type); | |||
LIB_EXPORT int jack_get_property(jack_uuid_t subject, const char* key, char** value, char** type); | |||
LIB_EXPORT void jack_free_description(jack_description_t* desc, int free_description_itself); | |||
LIB_EXPORT int jack_get_properties(jack_uuid_t subject, jack_description_t* desc); | |||
LIB_EXPORT int jack_get_all_properties(jack_description_t** descs); | |||
LIB_EXPORT int jack_remove_property(jack_client_t* client, jack_uuid_t subject, const char* key); | |||
LIB_EXPORT int jack_remove_properties(jack_client_t* client, jack_uuid_t subject); | |||
LIB_EXPORT int jack_remove_all_properties(jack_client_t* client); | |||
LIB_EXPORT int jack_set_property_change_callback(jack_client_t* client, JackPropertyChangeCallback callback, void* arg); | |||
#ifdef __cplusplus | |||
} | |||
#endif | |||
@@ -2140,3 +2151,112 @@ LIB_EXPORT int jack_uuid_empty(jack_uuid_t u) | |||
{ | |||
return u == JACK_UUID_EMPTY_INITIALIZER; | |||
} | |||
// Metadata API | |||
LIB_EXPORT int jack_set_property(jack_client_t* ext_client, jack_uuid_t subject, const char* key, const char* value, const char* type) | |||
{ | |||
JackGlobals::CheckContext("jack_set_property"); | |||
JackClient* client = (JackClient*)ext_client; | |||
jack_log("jack_set_property ext_client %x client %x ", ext_client, client); | |||
if (client == NULL) { | |||
jack_error("jack_set_property called with a NULL client"); | |||
return -1; | |||
} else { | |||
JackMetadata* metadata = GetMetadata(); | |||
return (metadata ? metadata->SetProperty(client, subject, key, value, type) : -1); | |||
} | |||
} | |||
LIB_EXPORT int jack_get_property(jack_uuid_t subject, const char* key, char** value, char** type) | |||
{ | |||
JackGlobals::CheckContext("jack_get_property"); | |||
JackMetadata* metadata = GetMetadata(); | |||
return (metadata ? metadata->GetProperty(subject, key, value, type) : -1); | |||
} | |||
LIB_EXPORT void jack_free_description(jack_description_t* desc, int free_actual_description_too) | |||
{ | |||
JackGlobals::CheckContext("jack_free_description"); | |||
JackMetadata* metadata = GetMetadata(); | |||
if (metadata) | |||
metadata->FreeDescription(desc, free_actual_description_too); | |||
} | |||
LIB_EXPORT int jack_get_properties(jack_uuid_t subject, jack_description_t* desc) | |||
{ | |||
JackGlobals::CheckContext("jack_get_properties"); | |||
JackMetadata* metadata = GetMetadata(); | |||
return (metadata ? metadata->GetProperties(subject, desc) : -1); | |||
} | |||
LIB_EXPORT int jack_get_all_properties(jack_description_t** descriptions) | |||
{ | |||
JackGlobals::CheckContext("jack_get_all_properties"); | |||
JackMetadata* metadata = GetMetadata(); | |||
return (metadata ? metadata->GetAllProperties(descriptions) : -1); | |||
} | |||
LIB_EXPORT int jack_remove_property(jack_client_t* ext_client, jack_uuid_t subject, const char* key) | |||
{ | |||
JackGlobals::CheckContext("jack_remove_property"); | |||
JackClient* client = (JackClient*)ext_client; | |||
jack_log("jack_remove_property ext_client %x client %x ", ext_client, client); | |||
if (client == NULL) { | |||
jack_error("jack_remove_property called with a NULL client"); | |||
return -1; | |||
} else { | |||
JackMetadata* metadata = GetMetadata(); | |||
return (metadata ? metadata->RemoveProperty(client, subject, key) : -1); | |||
} | |||
} | |||
LIB_EXPORT int jack_remove_properties(jack_client_t* ext_client, jack_uuid_t subject) | |||
{ | |||
JackGlobals::CheckContext("jack_remove_properties"); | |||
JackClient* client = (JackClient*)ext_client; | |||
jack_log("jack_remove_properties ext_client %x client %x ", ext_client, client); | |||
if (client == NULL) { | |||
jack_error("jack_remove_properties called with a NULL client"); | |||
return -1; | |||
} else { | |||
JackMetadata* metadata = GetMetadata(); | |||
return (metadata ? metadata->RemoveProperties(client, subject) : -1); | |||
} | |||
} | |||
LIB_EXPORT int jack_remove_all_properties(jack_client_t* ext_client) | |||
{ | |||
JackGlobals::CheckContext("jack_remove_all_properties"); | |||
JackClient* client = (JackClient*)ext_client; | |||
jack_log("jack_remove_all_properties ext_client %x client %x ", ext_client, client); | |||
if (client == NULL) { | |||
jack_error("jack_remove_all_properties called with a NULL client"); | |||
return -1; | |||
} else { | |||
JackMetadata* metadata = GetMetadata(); | |||
return (metadata ? metadata->RemoveAllProperties(client) : -1); | |||
} | |||
} | |||
LIB_EXPORT int jack_set_property_change_callback(jack_client_t* ext_client, JackPropertyChangeCallback callback, void* arg) | |||
{ | |||
JackGlobals::CheckContext("jack_set_property_change_callback"); | |||
JackClient* client = (JackClient*)ext_client; | |||
jack_log("jack_set_property_change_callback ext_client %x client %x ", ext_client, client); | |||
if (client == NULL) { | |||
jack_error("jack_set_property_change_callback called with a NULL client"); | |||
return -1; | |||
} else { | |||
return client->SetPropertyChangeCallback(callback, arg); | |||
} | |||
} |
@@ -59,6 +59,7 @@ struct JackGlobals { | |||
extern SERVER_EXPORT JackGraphManager* GetGraphManager(); | |||
extern SERVER_EXPORT JackEngineControl* GetEngineControl(); | |||
extern SERVER_EXPORT JackSynchro* GetSynchroTable(); | |||
extern SERVER_EXPORT JackMetadata* GetMetadata(); | |||
} // end of namespace | |||
@@ -53,6 +53,11 @@ SERVER_EXPORT JackSynchro* GetSynchroTable() | |||
return JackServerGlobals::fInstance->GetSynchroTable(); | |||
} | |||
SERVER_EXPORT JackMetadata* GetMetadata() | |||
{ | |||
return JackServerGlobals::fInstance->GetMetadata(); | |||
} | |||
JackInternalClient::JackInternalClient(JackServer* server, JackSynchro* table): JackClient(table) | |||
{ | |||
fChannel = new JackInternalClientChannel(server); | |||
@@ -47,16 +47,6 @@ extern "C" | |||
LIB_EXPORT int jack_client_close (jack_client_t *client); | |||
LIB_EXPORT int jack_get_client_pid (const char *name); | |||
LIB_EXPORT int jack_set_property(jack_client_t*, jack_uuid_t subject, const char* key, const char* value, const char* type); | |||
LIB_EXPORT int jack_get_property(jack_uuid_t subject, const char* key, char** value, char** type); | |||
LIB_EXPORT void jack_free_description(jack_description_t* desc, int free_description_itself); | |||
LIB_EXPORT int jack_get_properties(jack_uuid_t subject, jack_description_t* desc); | |||
LIB_EXPORT int jack_get_all_properties(jack_description_t** descs); | |||
LIB_EXPORT int jack_remove_property(jack_client_t* client, jack_uuid_t subject, const char* key); | |||
LIB_EXPORT int jack_remove_properties(jack_client_t* client, jack_uuid_t subject); | |||
LIB_EXPORT int jack_remove_all_properties(jack_client_t* client); | |||
LIB_EXPORT int jack_set_property_change_callback(jack_client_t* client, JackPropertyChangeCallback callback, void* arg); | |||
#ifdef __cplusplus | |||
} | |||
#endif | |||
@@ -222,112 +212,3 @@ LIB_EXPORT int jack_get_client_pid(const char *name) | |||
jack_error("jack_get_client_pid : not implemented on library side"); | |||
return 0; | |||
} | |||
// Metadata API | |||
LIB_EXPORT int jack_set_property(jack_client_t* ext_client, jack_uuid_t subject, const char* key, const char* value, const char* type) | |||
{ | |||
JackGlobals::CheckContext("jack_set_property"); | |||
JackClient* client = (JackClient*)ext_client; | |||
jack_log("jack_set_property ext_client %x client %x ", ext_client, client); | |||
if (client == NULL) { | |||
jack_error("jack_set_property called with a NULL client"); | |||
return -1; | |||
} else { | |||
JackMetadata* metadata = GetMetadata(); | |||
return (metadata ? metadata->SetProperty(client, subject, key, value, type) : -1); | |||
} | |||
} | |||
LIB_EXPORT int jack_get_property(jack_uuid_t subject, const char* key, char** value, char** type) | |||
{ | |||
JackGlobals::CheckContext("jack_get_property"); | |||
JackMetadata* metadata = GetMetadata(); | |||
return (metadata ? metadata->GetProperty(subject, key, value, type) : -1); | |||
} | |||
LIB_EXPORT void jack_free_description(jack_description_t* desc, int free_actual_description_too) | |||
{ | |||
JackGlobals::CheckContext("jack_free_description"); | |||
JackMetadata* metadata = GetMetadata(); | |||
if (metadata) | |||
metadata->FreeDescription(desc, free_actual_description_too); | |||
} | |||
LIB_EXPORT int jack_get_properties(jack_uuid_t subject, jack_description_t* desc) | |||
{ | |||
JackGlobals::CheckContext("jack_get_properties"); | |||
JackMetadata* metadata = GetMetadata(); | |||
return (metadata ? metadata->GetProperties(subject, desc) : -1); | |||
} | |||
LIB_EXPORT int jack_get_all_properties(jack_description_t** descriptions) | |||
{ | |||
JackGlobals::CheckContext("jack_get_all_properties"); | |||
JackMetadata* metadata = GetMetadata(); | |||
return (metadata ? metadata->GetAllProperties(descriptions) : -1); | |||
} | |||
LIB_EXPORT int jack_remove_property(jack_client_t* ext_client, jack_uuid_t subject, const char* key) | |||
{ | |||
JackGlobals::CheckContext("jack_remove_property"); | |||
JackClient* client = (JackClient*)ext_client; | |||
jack_log("jack_remove_property ext_client %x client %x ", ext_client, client); | |||
if (client == NULL) { | |||
jack_error("jack_remove_property called with a NULL client"); | |||
return -1; | |||
} else { | |||
JackMetadata* metadata = GetMetadata(); | |||
return (metadata ? metadata->RemoveProperty(client, subject, key) : -1); | |||
} | |||
} | |||
LIB_EXPORT int jack_remove_properties(jack_client_t* ext_client, jack_uuid_t subject) | |||
{ | |||
JackGlobals::CheckContext("jack_remove_properties"); | |||
JackClient* client = (JackClient*)ext_client; | |||
jack_log("jack_remove_properties ext_client %x client %x ", ext_client, client); | |||
if (client == NULL) { | |||
jack_error("jack_remove_properties called with a NULL client"); | |||
return -1; | |||
} else { | |||
JackMetadata* metadata = GetMetadata(); | |||
return (metadata ? metadata->RemoveProperties(client, subject) : -1); | |||
} | |||
} | |||
LIB_EXPORT int jack_remove_all_properties(jack_client_t* ext_client) | |||
{ | |||
JackGlobals::CheckContext("jack_remove_all_properties"); | |||
JackClient* client = (JackClient*)ext_client; | |||
jack_log("jack_remove_all_properties ext_client %x client %x ", ext_client, client); | |||
if (client == NULL) { | |||
jack_error("jack_remove_all_properties called with a NULL client"); | |||
return -1; | |||
} else { | |||
JackMetadata* metadata = GetMetadata(); | |||
return (metadata ? metadata->RemoveAllProperties(client) : -1); | |||
} | |||
} | |||
LIB_EXPORT int jack_set_property_change_callback(jack_client_t* ext_client, JackPropertyChangeCallback callback, void* arg) | |||
{ | |||
JackGlobals::CheckContext("jack_set_property_change_callback"); | |||
JackClient* client = (JackClient*)ext_client; | |||
jack_log("jack_set_property_change_callback ext_client %x client %x ", ext_client, client); | |||
if (client == NULL) { | |||
jack_error("jack_set_property_change_callback called with a NULL client"); | |||
return -1; | |||
} else { | |||
return client->SetPropertyChangeCallback(callback, arg); | |||
} | |||
} |
@@ -51,7 +51,6 @@ JackSynchro* GetSynchroTable() | |||
return (JackLibGlobals::fGlobals ? JackLibGlobals::fGlobals->fSynchroTable : 0); | |||
} | |||
// Used for client-side Metadata API (JackLibAPI.cpp) | |||
JackMetadata* GetMetadata() | |||
{ | |||
if (JackLibGlobals::fGlobals) { | |||
@@ -52,11 +52,9 @@ class JackLibClient : public JackClient | |||
JackGraphManager* GetGraphManager() const; | |||
JackEngineControl* GetEngineControl() const; | |||
JackClientControl* GetClientControl() const; | |||
JackMetadata* GetMetadata() const; | |||
}; | |||
// Used for client-side Metadata API (JackLibAPI.cpp) | |||
JackMetadata* GetMetadata(); | |||
} // end of namespace | |||
#endif | |||
@@ -54,6 +54,7 @@ JackServer::JackServer(bool sync, bool temporary, int timeout, bool rt, int prio | |||
jack_info("self-connect-mode is \"%s\"", jack_get_self_connect_mode_description(self_connect_mode)); | |||
fGraphManager = JackGraphManager::Allocate(port_max); | |||
fMetadata = new JackMetadata(true); | |||
fEngineControl = new JackEngineControl(sync, temporary, timeout, rt, priority, verbose, clock, server_name); | |||
fEngine = new JackLockedEngine(fGraphManager, GetSynchroTable(), fEngineControl, self_connect_mode); | |||
@@ -76,6 +77,7 @@ JackServer::JackServer(bool sync, bool temporary, int timeout, bool rt, int prio | |||
JackServer::~JackServer() | |||
{ | |||
JackGraphManager::Destroy(fGraphManager); | |||
delete fMetadata; | |||
delete fDriverInfo; | |||
delete fThreadedFreewheelDriver; | |||
delete fEngine; | |||
@@ -464,5 +466,10 @@ JackGraphManager* JackServer::GetGraphManager() | |||
return fGraphManager; | |||
} | |||
JackMetadata* JackServer::GetMetadata() | |||
{ | |||
return fMetadata; | |||
} | |||
} // end of namespace | |||
@@ -38,6 +38,7 @@ class JackDriverClientInterface; | |||
struct JackEngineControl; | |||
class JackLockedEngine; | |||
class JackLoadableInternalClient; | |||
class JackMetadata; | |||
/*! | |||
\brief The Jack server. | |||
@@ -55,6 +56,7 @@ class SERVER_EXPORT JackServer | |||
JackLockedEngine* fEngine; | |||
JackEngineControl* fEngineControl; | |||
JackGraphManager* fGraphManager; | |||
JackMetadata* fMetadata; | |||
JackServerChannel fRequestChannel; | |||
JackConnectionManager fConnectionState; | |||
JackSynchro fSynchroTable[CLIENT_NUM]; | |||
@@ -104,6 +106,7 @@ class SERVER_EXPORT JackServer | |||
JackEngineControl* GetEngineControl(); | |||
JackSynchro* GetSynchroTable(); | |||
JackGraphManager* GetGraphManager(); | |||
JackMetadata* GetMetadata(); | |||
}; | |||