Browse Source

libjack: Implement client name uuid stuff

Signed-off-by: falkTX <falktx@falktx.com>
tags/v2.2.0-RC1
falkTX 4 years ago
parent
commit
ae6e10fa9c
Signed by: falkTX <falktx@falktx.com> GPG Key ID: CDBAA37ABC74FBA0
3 changed files with 58 additions and 8 deletions
  1. +46
    -0
      source/libjack/libjack.cpp
  2. +2
    -0
      source/libjack/libjack.hpp
  3. +10
    -8
      source/libjack/libjack_client.cpp

+ 46
- 0
source/libjack/libjack.cpp View File

@@ -270,6 +270,20 @@ public:
return true; return true;
} }


const char* getClientNameFromUUID(jack_uuid_t uuid) const
{
for (LinkedList<JackClientState*>::Itenerator it = fClients.begin2(); it.valid(); it.next())
{
JackClientState* const jclient(it.getValue(nullptr));
CARLA_SAFE_ASSERT_CONTINUE(jclient != nullptr);

if (jclient->uuid == uuid)
return jclient->name;
}

return nullptr;
}

pthread_t getRealtimeThreadId() const noexcept pthread_t getRealtimeThreadId() const noexcept
{ {
return (pthread_t)fRealtimeThread.getThreadId(); return (pthread_t)fRealtimeThread.getThreadId();
@@ -1377,6 +1391,38 @@ int jack_deactivate(jack_client_t* client)


// --------------------------------------------------------------------------------------------------------------------- // ---------------------------------------------------------------------------------------------------------------------


CARLA_EXPORT
char* jack_get_client_name_by_uuid(jack_client_t* const client, const char* const uuidstr)
{
carla_debug("%s(%p, %s)", __FUNCTION__, client, uuidstr);

jack_uuid_t uuid = JACK_UUID_EMPTY_INITIALIZER;
CARLA_SAFE_ASSERT_RETURN(jack_uuid_parse(uuidstr, &uuid) == 0, nullptr);

JackClientState* const jclient = (JackClientState*)client;
CARLA_SAFE_ASSERT_RETURN(jclient != nullptr, nullptr);

const char* clientName;

if (jclient->uuid == uuid)
{
clientName = jclient->name;
CARLA_SAFE_ASSERT_RETURN(clientName != nullptr, nullptr);
}
else
{
CarlaJackAppClient* const jackAppPtr = jclient->server.jackAppPtr;
CARLA_SAFE_ASSERT_RETURN(jackAppPtr != nullptr && jackAppPtr == &gClient, nullptr);

clientName = jackAppPtr->getClientNameFromUUID(uuid);
CARLA_SAFE_ASSERT_RETURN(clientName != nullptr, nullptr);
}

return strdup(clientName);
}

// ---------------------------------------------------------------------------------------------------------------------

CARLA_EXPORT CARLA_EXPORT
pthread_t jack_client_thread_id(jack_client_t* client) pthread_t jack_client_thread_id(jack_client_t* client)
{ {


+ 2
- 0
source/libjack/libjack.hpp View File

@@ -164,6 +164,7 @@ struct JackClientState {
bool deactivated; // activated once, then deactivated bool deactivated; // activated once, then deactivated


char* name; char* name;
jack_uuid_t uuid;


LinkedList<JackPortState*> audioIns; LinkedList<JackPortState*> audioIns;
LinkedList<JackPortState*> audioOuts; LinkedList<JackPortState*> audioOuts;
@@ -202,6 +203,7 @@ struct JackClientState {
activated(false), activated(false),
deactivated(false), deactivated(false),
name(strdup(n)), name(strdup(n)),
uuid(jack_client_uuid_generate()),
audioIns(), audioIns(),
audioOuts(), audioOuts(),
midiIns(), midiIns(),


+ 10
- 8
source/libjack/libjack_client.cpp View File

@@ -43,15 +43,17 @@ char* jack_get_client_name(jack_client_t* client)
CARLA_EXPORT CARLA_EXPORT
char* jack_get_uuid_for_client_name(jack_client_t* client, const char* name) char* jack_get_uuid_for_client_name(jack_client_t* client, const char* name)
{ {
carla_stderr2("%s(%p, %s)", __FUNCTION__, client, name);
return nullptr;
}
carla_debug("%s(%p, %s)", __FUNCTION__, client, name);


CARLA_EXPORT
char* jack_get_client_name_by_uuid(jack_client_t* client, const char* uuid)
{
carla_stderr2("%s(%p, %s)", __FUNCTION__, client, uuid);
return nullptr;
JackClientState* const jclient = (JackClientState*)client;
CARLA_SAFE_ASSERT_RETURN(jclient != nullptr, nullptr);

char* const uuidstr = static_cast<char*>(std::malloc(JACK_UUID_STRING_SIZE));
CARLA_SAFE_ASSERT_RETURN(uuidstr != nullptr, nullptr);

jack_uuid_unparse(jclient->uuid, uuidstr);

return uuidstr;
} }


// -------------------------------------------------------------------------------------------------------------------- // --------------------------------------------------------------------------------------------------------------------


Loading…
Cancel
Save