Commit 3a7b1ce6 authored by sletz's avatar sletz
Browse files

Add jack_set_client_registration_callback API

git-svn-id: http://subversion.jackaudio.org/jack/jack2/trunk/jackmp@1472 0c269be4-1314-0410-8aa9-9f06e86f4224
parent 940d44b6
......@@ -2,6 +2,10 @@
Jackdmp changes log
---------------------------
2007-05-05 Stephane Letz <letz@grame.fr>
* Add jack_set_client_registration_callback API.
2007-05-04 Stephane Letz <letz@grame.fr>
* Steven Chamberlain patch to fix jack_port_type. Test for jack_port_type behaviour in jack_test.cpp tool.
......
......@@ -76,6 +76,9 @@ extern "C"
EXPORT int jack_set_sample_rate_callback (jack_client_t *client,
JackSampleRateCallback srate_callback,
void *arg);
EXPORT int jack_set_client_registration_callback (jack_client_t *,
JackClientRegistrationCallback
registration_callback, void *arg);
EXPORT int jack_set_port_registration_callback (jack_client_t *,
JackPortRegistrationCallback
registration_callback, void *arg);
......@@ -649,7 +652,6 @@ EXPORT int jack_set_sample_rate_callback(jack_client_t* ext_client, JackSampleRa
JackLibGlobals::CheckContext();
#endif
JackClient* client = (JackClient*)ext_client;
JackLog("jack_set_sample_rate_callback ext_client %x client %x \n", ext_client, client);
if (client == NULL) {
jack_error("jack_set_sample_rate_callback called with a NULL client");
return -1;
......@@ -659,6 +661,20 @@ EXPORT int jack_set_sample_rate_callback(jack_client_t* ext_client, JackSampleRa
}
}
EXPORT int jack_set_client_registration_callback(jack_client_t* ext_client, JackClientRegistrationCallback registration_callback, void* arg)
{
#ifdef __CLIENTDEBUG__
JackLibGlobals::CheckContext();
#endif
JackClient* client = (JackClient*)ext_client;
if (client == NULL) {
jack_error("jack_set_client_registration_callback called with a NULL client");
return -1;
} else {
return client->SetClientRegistrationCallback(registration_callback, arg);
}
}
EXPORT int jack_set_port_registration_callback(jack_client_t* ext_client, JackPortRegistrationCallback registration_callback, void* arg)
{
#ifdef __CLIENTDEBUG__
......
......@@ -128,9 +128,12 @@ int JackClient::ClientNotify(int refnum, const char* name, int notify, int sync,
switch (notify) {
case JackNotifyChannelInterface::kAddClient:
case JackNotifyChannelInterface::kRemoveClient:
res = ClientNotifyImp(refnum, name, notify, sync, value);
break;
break;
case JackNotifyChannelInterface::kRemoveClient:
res = ClientNotifyImp(refnum, name, notify, sync, value);
break;
case JackNotifyChannelInterface::kActivateClient:
JackLog("JackClient::kActivateClient name = %s ref = %ld \n", name, refnum);
......@@ -145,6 +148,18 @@ int JackClient::ClientNotify(int refnum, const char* name, int notify, int sync,
if (IsActive()) {
switch (notify) {
case JackNotifyChannelInterface::kAddClient:
printf("ClientNotify fName = %s name = %s\n", GetClientControl()->fName, name);
if (fClientRegistration && strcmp(GetClientControl()->fName, name) != 0) // Don't call the callback for the registering client itself
fClientRegistration(name, 1, fClientRegistrationArg);
break;
case JackNotifyChannelInterface::kRemoveClient:
printf("ClientNotify fName = %s name = %s\n", GetClientControl()->fName, name);
if (fClientRegistration && strcmp(GetClientControl()->fName, name) != 0) // Don't call the callback for the registering client itself
fClientRegistration(name, 0, fClientRegistrationArg);
break;
case JackNotifyChannelInterface::kBufferSizeCallback:
JackLog("JackClient::kBufferSizeCallback buffer_size = %ld\n", value);
......@@ -759,6 +774,18 @@ int JackClient::SetBufferSizeCallback(JackBufferSizeCallback callback, void *arg
}
}
int JackClient::SetClientRegistrationCallback(JackClientRegistrationCallback callback, void* arg)
{
if (IsActive()) {
jack_error("You cannot set callbacks on an active client");
return -1;
} else {
fPortRegistrationArg = arg;
fClientRegistration = callback;
return 0;
}
}
int JackClient::SetFreewheelCallback(JackFreewheelCallback callback, void *arg)
{
if (IsActive()) {
......
......@@ -58,6 +58,7 @@ class JackClient : public JackClientInterface, public JackRunnableInterface
JackShutdownCallback fShutdown;
JackThreadInitCallback fInit;
JackBufferSizeCallback fBufferSize;
JackClientRegistrationCallback fClientRegistration;
JackFreewheelCallback fFreewheel;
JackPortRegistrationCallback fPortRegistration;
JackTimebaseCallback fTimebase;
......@@ -68,6 +69,7 @@ class JackClient : public JackClientInterface, public JackRunnableInterface
void* fShutdownArg;
void* fInitArg;
void* fBufferSizeArg;
void* fClientRegistrationArg;
void* fFreewheelArg;
void* fPortRegistrationArg;
void* fTimebaseArg;
......@@ -144,6 +146,7 @@ class JackClient : public JackClientInterface, public JackRunnableInterface
virtual int SetInitCallback(JackThreadInitCallback callback, void* arg);
virtual int SetGraphOrderCallback(JackGraphOrderCallback callback, void* arg);
virtual int SetBufferSizeCallback(JackBufferSizeCallback callback, void* arg);
virtual int SetClientRegistrationCallback(JackClientRegistrationCallback callback, void* arg);
virtual int SetFreewheelCallback(JackFreewheelCallback callback, void* arg);
virtual int SetPortRegistrationCallback(JackPortRegistrationCallback callback, void* arg);
......
......@@ -309,6 +309,16 @@ extern "C"
JackSampleRateCallback srate_callback,
void *arg);
/**
* Tell the JACK server to call @a registration_callback whenever a
* port is registered or unregistered, passing @a arg as a parameter.
*
* @return 0 on success, otherwise a non-zero error code
*/
int jack_set_client_registration_callback (jack_client_t *,
JackClientRegistrationCallback
registration_callback, void *arg);
/**
* Tell the JACK server to call @a registration_callback whenever a
* port is registered or unregistered, passing @a arg as a parameter.
......
......@@ -179,6 +179,17 @@ typedef int (*JackSampleRateCallback)(jack_nframes_t nframes, void *arg);
*/
typedef void (*JackPortRegistrationCallback)(jack_port_id_t port, int, void *arg);
/**
* Prototype for the client supplied function that is called
* whenever a client is registered or unregistered.
*
* @param name a null-terminated string containing the client name
* @param register non-zero if the client is being registered,
* zero if the client is being unregistered
* @param arg pointer to a client supplied structure
*/
typedef void (*JackClientRegistrationCallback)(const char* name, int register, void *arg);
/**
* Prototype for the client supplied function that is called
* whenever jackd starts or stops freewheeling.
......
......@@ -169,6 +169,11 @@ void Jack_Freewheel_Callback(int starting, void *arg)
FW = starting;
}
void Jack_Client_Registration_Callback(const char* name, int val, void *arg)
{
Log("Client registration callback name = %s has been successfully called with value %i.(msg from callback)\n", name, val);
}
int Jack_Update_Buffer_Size(jack_nframes_t nframes, void *arg)
{
cur_buffer_size = jack_get_buffer_size(client1);
......@@ -203,7 +208,7 @@ void Jack_Error_Callback(const char *msg)
}
}
void jack_shutdown (void *arg)
void jack_shutdown(void *arg)
{
printf("Jack_test has been kicked out by jackd !\n");
exit (1);
......@@ -600,6 +605,9 @@ int main (int argc, char *argv[])
if (jack_set_port_registration_callback(client1, Jack_Port_Register, 0) != 0) {
printf("Error when calling jack_set_port_registration_callback() !\n");
}
if (jack_set_client_registration_callback(client1, Jack_Client_Registration_Callback, 0) != 0) {
printf("Error when calling jack_set_client_registration_callback() !\n");
}
jack_set_error_function (Jack_Error_Callback);
/**
......@@ -1025,7 +1033,8 @@ int main (int argc, char *argv[])
}
free(inports); // free array of ports (as mentionned in the doc of jack_get_ports)
/**
*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*
*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment