git-svn-id: http://subversion.jackaudio.org/jack/jack2/trunk/jackmp@1777 0c269be4-1314-0410-8aa9-9f06e86f4224tags/0.70
| @@ -17,6 +17,10 @@ Tim Blechmann | |||||
| Jackdmp changes log | Jackdmp changes log | ||||
| --------------------------- | --------------------------- | ||||
| 2008-01-28 Stephane Letz <letz@grame.fr> | |||||
| * Updated API to match jack 0.109.0 version (in progress). Correct issue in CoreAudio driver. | |||||
| 2008-01-25 Stephane Letz <letz@grame.fr> | 2008-01-25 Stephane Letz <letz@grame.fr> | ||||
| * OSX 32/64 bits version. | * OSX 32/64 bits version. | ||||
| @@ -111,8 +111,6 @@ extern "C" | |||||
| const jack_port_t *port); | const jack_port_t *port); | ||||
| EXPORT int jack_port_tie (jack_port_t *src, jack_port_t *dst); | EXPORT int jack_port_tie (jack_port_t *src, jack_port_t *dst); | ||||
| EXPORT int jack_port_untie (jack_port_t *port); | EXPORT int jack_port_untie (jack_port_t *port); | ||||
| EXPORT int jack_port_lock (jack_client_t *, jack_port_t *); | |||||
| EXPORT int jack_port_unlock (jack_client_t *, jack_port_t *); | |||||
| EXPORT jack_nframes_t jack_port_get_latency (jack_port_t *port); | EXPORT jack_nframes_t jack_port_get_latency (jack_port_t *port); | ||||
| EXPORT jack_nframes_t jack_port_get_total_latency (jack_client_t *, | EXPORT jack_nframes_t jack_port_get_total_latency (jack_client_t *, | ||||
| jack_port_t *port); | jack_port_t *port); | ||||
| @@ -855,48 +853,6 @@ EXPORT const char** jack_port_get_all_connections(const jack_client_t* ext_clien | |||||
| } | } | ||||
| } | } | ||||
| // Does not use the client parameter | |||||
| EXPORT int jack_port_lock(jack_client_t* ext_client, jack_port_t* port) | |||||
| { | |||||
| #ifdef __CLIENTDEBUG__ | |||||
| JackLibGlobals::CheckContext(); | |||||
| #endif | |||||
| JackClient* client = (JackClient*)ext_client; | |||||
| if (client == NULL) { | |||||
| jack_error("jack_port_lock called with a NULL client"); | |||||
| return -1; | |||||
| } | |||||
| jack_port_id_t myport = (jack_port_id_t)port; | |||||
| if (!CheckPort(myport)) { | |||||
| jack_error("jack_port_lock called with an incorrect port %ld", myport); | |||||
| return -1; | |||||
| } else { | |||||
| return (myport && client->PortIsMine(myport)) ? GetGraphManager()->GetPort(myport)->Lock() : -1; | |||||
| } | |||||
| } | |||||
| // Does not use the client parameter | |||||
| EXPORT int jack_port_unlock(jack_client_t* ext_client, jack_port_t* port) | |||||
| { | |||||
| #ifdef __CLIENTDEBUG__ | |||||
| JackLibGlobals::CheckContext(); | |||||
| #endif | |||||
| JackClient* client = (JackClient*)ext_client; | |||||
| if (client == NULL) { | |||||
| jack_error("jack_port_unlock called with a NULL client"); | |||||
| return -1; | |||||
| } | |||||
| jack_port_id_t myport = (jack_port_id_t)port; | |||||
| if (!CheckPort(myport)) { | |||||
| jack_error("jack_port_unlock called with an incorrect port %ld", myport); | |||||
| return -1; | |||||
| } else { | |||||
| return (myport && client->PortIsMine(myport)) ? GetGraphManager()->GetPort(myport)->Unlock() : -1; | |||||
| } | |||||
| } | |||||
| EXPORT jack_nframes_t jack_port_get_total_latency(jack_client_t* ext_client, jack_port_t* port) | EXPORT jack_nframes_t jack_port_get_total_latency(jack_client_t* ext_client, jack_port_t* port) | ||||
| { | { | ||||
| #ifdef __CLIENTDEBUG__ | #ifdef __CLIENTDEBUG__ | ||||
| @@ -87,8 +87,6 @@ extern "C" | |||||
| const jack_port_t *port); | const jack_port_t *port); | ||||
| EXPORT int jack_port_tie (jack_port_t *src, jack_port_t *dst); | EXPORT int jack_port_tie (jack_port_t *src, jack_port_t *dst); | ||||
| EXPORT int jack_port_untie (jack_port_t *port); | EXPORT int jack_port_untie (jack_port_t *port); | ||||
| EXPORT int jack_port_lock (jack_client_t *, jack_port_t *); | |||||
| EXPORT int jack_port_unlock (jack_client_t *, jack_port_t *); | |||||
| EXPORT jack_nframes_t jack_port_get_latency (jack_port_t *port); | EXPORT jack_nframes_t jack_port_get_latency (jack_port_t *port); | ||||
| EXPORT jack_nframes_t jack_port_get_total_latency (jack_client_t *, | EXPORT jack_nframes_t jack_port_get_total_latency (jack_client_t *, | ||||
| jack_port_t *port); | jack_port_t *port); | ||||
| @@ -441,22 +439,6 @@ EXPORT const char** jack_port_get_all_connections(const jack_client_t* ext_clien | |||||
| return (*jack_port_get_all_connections_fun)(ext_client, port); | return (*jack_port_get_all_connections_fun)(ext_client, port); | ||||
| } | } | ||||
| // Does not use the client parameter | |||||
| typedef int (*jack_port_lock_fun_def)(jack_client_t* ext_client, jack_port_t* port); | |||||
| static jack_port_lock_fun_def jack_port_lock_fun = 0; | |||||
| EXPORT int jack_port_lock(jack_client_t* ext_client, jack_port_t* port) | |||||
| { | |||||
| return (*jack_port_lock_fun)(ext_client, port); | |||||
| } | |||||
| // Does not use the client parameter | |||||
| typedef int (*jack_port_unlock_fun_def)(jack_client_t* ext_client, jack_port_t* port); | |||||
| static jack_port_unlock_fun_def jack_port_unlock_fun = 0; | |||||
| EXPORT int jack_port_ununlock(jack_client_t* ext_client, jack_port_t* port) | |||||
| { | |||||
| return (*jack_port_unlock_fun)(ext_client, port); | |||||
| } | |||||
| typedef jack_nframes_t (*jack_port_get_total_latency_fun_def)(jack_client_t* ext_client, jack_port_t* port); | typedef jack_nframes_t (*jack_port_get_total_latency_fun_def)(jack_client_t* ext_client, jack_port_t* port); | ||||
| static jack_port_get_total_latency_fun_def jack_port_get_total_latency_fun = 0; | static jack_port_get_total_latency_fun_def jack_port_get_total_latency_fun = 0; | ||||
| EXPORT jack_nframes_t jack_port_get_total_latency(jack_client_t* ext_client, jack_port_t* port) | EXPORT jack_nframes_t jack_port_get_total_latency(jack_client_t* ext_client, jack_port_t* port) | ||||
| @@ -941,8 +923,6 @@ static bool init_library() | |||||
| jack_port_is_mine_fun = (jack_port_is_mine_fun_def)dlsym(gLibrary, "jack_port_is_mine"); | jack_port_is_mine_fun = (jack_port_is_mine_fun_def)dlsym(gLibrary, "jack_port_is_mine"); | ||||
| jack_port_get_connections_fun = (jack_port_get_connections_fun_def)dlsym(gLibrary, "jack_port_get_connections"); | jack_port_get_connections_fun = (jack_port_get_connections_fun_def)dlsym(gLibrary, "jack_port_get_connections"); | ||||
| jack_port_get_all_connections_fun = (jack_port_get_all_connections_fun_def)dlsym(gLibrary, "jack_port_get_all_connections_fun"); | jack_port_get_all_connections_fun = (jack_port_get_all_connections_fun_def)dlsym(gLibrary, "jack_port_get_all_connections_fun"); | ||||
| jack_port_lock_fun = (jack_port_lock_fun_def)dlsym(gLibrary, "jack_port_lock"); | |||||
| jack_port_unlock_fun = (jack_port_unlock_fun_def)dlsym(gLibrary, "jack_port_unlock"); | |||||
| jack_port_get_total_latency_fun = (jack_port_get_total_latency_fun_def)dlsym(gLibrary, "jack_port_get_total_latency"); | jack_port_get_total_latency_fun = (jack_port_get_total_latency_fun_def)dlsym(gLibrary, "jack_port_get_total_latency"); | ||||
| jack_connect_fun = (jack_connect_fun_def)dlsym(gLibrary, "jack_connect"); | jack_connect_fun = (jack_connect_fun_def)dlsym(gLibrary, "jack_connect"); | ||||
| jack_disconnect_fun = (jack_disconnect_fun_def)dlsym(gLibrary, "jack_disconnect"); | jack_disconnect_fun = (jack_disconnect_fun_def)dlsym(gLibrary, "jack_disconnect"); | ||||
| @@ -71,9 +71,9 @@ namespace Jack | |||||
| #define ALL_CLIENTS -1 // for notification | #define ALL_CLIENTS -1 // for notification | ||||
| #if defined(__ppc64__) || defined(__x86_64__) | #if defined(__ppc64__) || defined(__x86_64__) | ||||
| #define JACK_PROTOCOL_VERSION 3 | |||||
| #define JACK_PROTOCOL_VERSION 4 | |||||
| #else | #else | ||||
| #define JACK_PROTOCOL_VERSION 2 | |||||
| #define JACK_PROTOCOL_VERSION 3 | |||||
| #endif | #endif | ||||
| #define DRIVER_OPEN_TIMEOUT 5 // in sec | #define DRIVER_OPEN_TIMEOUT 5 // in sec | ||||
| @@ -702,9 +702,7 @@ int JackEngine::PortDisconnect(int refnum, jack_port_id_t src, jack_port_id_t ds | |||||
| JackLog("JackEngine::PortDisconnect src = %d dst = %d\n", src, dst); | JackLog("JackEngine::PortDisconnect src = %d dst = %d\n", src, dst); | ||||
| if (dst == ALL_PORTS) { | if (dst == ALL_PORTS) { | ||||
| return (fGraphManager->CheckPort(src) < 0) | |||||
| ? -1 | |||||
| : fGraphManager->DisconnectAll(src); | |||||
| return fGraphManager->DisconnectAll(src); | |||||
| } else { | } else { | ||||
| return (fGraphManager->CheckPorts(src, dst) < 0) | return (fGraphManager->CheckPorts(src, dst) < 0) | ||||
| ? -1 | ? -1 | ||||
| @@ -595,18 +595,6 @@ int JackGraphManager::ConnectedTo(jack_port_id_t port_src, const char* port_name | |||||
| } | } | ||||
| // Server | // Server | ||||
| int JackGraphManager::CheckPort(jack_port_id_t port_index) | |||||
| { | |||||
| JackPort* port = GetPort(port_index); | |||||
| if (port->fLocked) { | |||||
| jack_error("Port %s is locked against connection changes", port->fName); | |||||
| return -1; | |||||
| } else { | |||||
| return 0; | |||||
| } | |||||
| } | |||||
| int JackGraphManager::CheckPorts(jack_port_id_t port_src, jack_port_id_t port_dst) | int JackGraphManager::CheckPorts(jack_port_id_t port_src, jack_port_id_t port_dst) | ||||
| { | { | ||||
| JackPort* src = GetPort(port_src); | JackPort* src = GetPort(port_src); | ||||
| @@ -622,16 +610,6 @@ int JackGraphManager::CheckPorts(jack_port_id_t port_src, jack_port_id_t port_ds | |||||
| return -1; | return -1; | ||||
| } | } | ||||
| if (src->fLocked) { | |||||
| jack_error("Source port %s is locked against connection changes", src->fName); | |||||
| return -1; | |||||
| } | |||||
| if (dst->fLocked) { | |||||
| jack_error("Destination port %s is locked against connection changes", dst->fName); | |||||
| return -1; | |||||
| } | |||||
| return 0; | return 0; | ||||
| } | } | ||||
| @@ -82,8 +82,7 @@ class JackGraphManager : public JackShmMem, public JackAtomicState<JackConnectio | |||||
| int CheckPorts(const char* src, const char* dst, jack_port_id_t* src_index, jack_port_id_t* dst_index); | int CheckPorts(const char* src, const char* dst, jack_port_id_t* src_index, jack_port_id_t* dst_index); | ||||
| int CheckPorts(jack_port_id_t port_src, jack_port_id_t port_dst); | int CheckPorts(jack_port_id_t port_src, jack_port_id_t port_dst); | ||||
| int CheckPort(jack_port_id_t port_index); | |||||
| void DisconnectAllInput(jack_port_id_t port_index); | void DisconnectAllInput(jack_port_id_t port_index); | ||||
| void DisconnectAllOutput(jack_port_id_t port_index); | void DisconnectAllOutput(jack_port_id_t port_index); | ||||
| int DisconnectAll(jack_port_id_t port_index); | int DisconnectAll(jack_port_id_t port_index); | ||||
| @@ -23,14 +23,10 @@ This program is free software; you can redistribute it and/or modify | |||||
| #include <errno.h> | #include <errno.h> | ||||
| #include <string.h> | #include <string.h> | ||||
| #ifdef WIN32 | #ifdef WIN32 | ||||
| #define ENOBUFS 55 | #define ENOBUFS 55 | ||||
| #endif | #endif | ||||
| /* | |||||
| Post jack 0.103.0 version | |||||
| #ifdef __cplusplus | #ifdef __cplusplus | ||||
| extern "C" { | extern "C" { | ||||
| #endif | #endif | ||||
| @@ -134,108 +130,3 @@ jack_nframes_t jack_midi_get_lost_event_count(void* port_buffer) | |||||
| return buf->lost_events; | return buf->lost_events; | ||||
| return 0; | return 0; | ||||
| } | } | ||||
| */ | |||||
| #ifdef __cplusplus | |||||
| extern "C" { | |||||
| #endif | |||||
| EXPORT jack_nframes_t jack_midi_get_event_count(void* port_buffer, jack_nframes_t nframes); | |||||
| EXPORT int jack_midi_event_get(jack_midi_event_t* event, | |||||
| void* port_buffer, jack_nframes_t event_index, jack_nframes_t nframes); | |||||
| EXPORT void jack_midi_clear_buffer(void* port_buffer, jack_nframes_t nframes); | |||||
| EXPORT size_t jack_midi_max_event_size(void* port_buffer, jack_nframes_t nframes); | |||||
| EXPORT jack_midi_data_t* jack_midi_event_reserve(void* port_buffer, | |||||
| jack_nframes_t time, size_t data_size, jack_nframes_t nframes); | |||||
| EXPORT int jack_midi_event_write(void* port_buffer, | |||||
| jack_nframes_t time, const jack_midi_data_t* data, size_t data_size, jack_nframes_t nframes); | |||||
| EXPORT jack_nframes_t jack_midi_get_lost_event_count(void* port_buffer, jack_nframes_t nframes); | |||||
| #ifdef __cplusplus | |||||
| } | |||||
| #endif | |||||
| using namespace Jack; | |||||
| EXPORT | |||||
| jack_nframes_t jack_midi_get_event_count(void* port_buffer, jack_nframes_t) | |||||
| { | |||||
| JackMidiBuffer *buf = (JackMidiBuffer*)port_buffer; | |||||
| if (!buf || !buf->IsValid()) | |||||
| return 0; | |||||
| return buf->event_count; | |||||
| } | |||||
| EXPORT | |||||
| int jack_midi_event_get(jack_midi_event_t *event, void* port_buffer, jack_nframes_t event_index, jack_nframes_t) | |||||
| { | |||||
| JackMidiBuffer *buf = (JackMidiBuffer*)port_buffer; | |||||
| if (!buf || !buf->IsValid()) | |||||
| return -EINVAL; | |||||
| if (event_index < 0 || event_index >= buf->event_count) | |||||
| return -ENOBUFS; | |||||
| JackMidiEvent* ev = &buf->events[event_index]; | |||||
| event->time = ev->time; | |||||
| event->size = ev->size; | |||||
| event->buffer = ev->GetData(buf); | |||||
| return 0; | |||||
| } | |||||
| EXPORT | |||||
| void jack_midi_clear_buffer(void* port_buffer, jack_nframes_t) | |||||
| { | |||||
| JackMidiBuffer *buf = (JackMidiBuffer*)port_buffer; | |||||
| if (buf && buf->IsValid()) | |||||
| buf->Reset(buf->nframes); | |||||
| } | |||||
| EXPORT | |||||
| size_t jack_midi_max_event_size(void* port_buffer, jack_nframes_t) | |||||
| { | |||||
| JackMidiBuffer *buf = (JackMidiBuffer*)port_buffer; | |||||
| if (buf && buf->IsValid()) | |||||
| return buf->MaxEventSize(); | |||||
| return 0; | |||||
| } | |||||
| EXPORT | |||||
| jack_midi_data_t* jack_midi_event_reserve(void* port_buffer, jack_nframes_t time, size_t data_size, jack_nframes_t) | |||||
| { | |||||
| JackMidiBuffer *buf = (JackMidiBuffer*)port_buffer; | |||||
| if (!buf && !buf->IsValid()) | |||||
| return 0; | |||||
| if (time < 0 || time >= buf->nframes || (buf->event_count && buf->events[buf->event_count - 1].time > time)) | |||||
| return 0; | |||||
| return buf->ReserveEvent(time, data_size); | |||||
| } | |||||
| EXPORT | |||||
| int jack_midi_event_write(void* port_buffer, | |||||
| jack_nframes_t time, const jack_midi_data_t* data, size_t data_size, jack_nframes_t) | |||||
| { | |||||
| JackMidiBuffer *buf = (JackMidiBuffer*)port_buffer; | |||||
| if (!buf && !buf->IsValid()) | |||||
| return -EINVAL; | |||||
| if (time < 0 || time >= buf->nframes || (buf->event_count && buf->events[buf->event_count - 1].time > time)) | |||||
| return -EINVAL; | |||||
| jack_midi_data_t* dest = buf->ReserveEvent(time, data_size); | |||||
| if (!dest) | |||||
| return -ENOBUFS; | |||||
| memcpy(dest, data, data_size); | |||||
| return 0; | |||||
| } | |||||
| EXPORT | |||||
| jack_nframes_t jack_midi_get_lost_event_count(void* port_buffer, jack_nframes_t) | |||||
| { | |||||
| JackMidiBuffer *buf = (JackMidiBuffer*)port_buffer; | |||||
| if (buf && buf->IsValid()) | |||||
| return buf->lost_events; | |||||
| return 0; | |||||
| } | |||||
| @@ -29,7 +29,7 @@ namespace Jack | |||||
| { | { | ||||
| JackPort::JackPort() | JackPort::JackPort() | ||||
| : fFlags(JackPortIsInput), fRefNum( -1), fLatency(0), fMonitorRequests(0), fInUse(false), fLocked(false), fTied(NO_PORT) | |||||
| : fFlags(JackPortIsInput), fRefNum( -1), fLatency(0), fMonitorRequests(0), fInUse(false), fTied(NO_PORT) | |||||
| {} | {} | ||||
| JackPort::~JackPort() | JackPort::~JackPort() | ||||
| @@ -45,7 +45,6 @@ bool JackPort::Allocate(int refnum, const char* port_name, const char* port_type | |||||
| fRefNum = refnum; | fRefNum = refnum; | ||||
| strcpy(fName, port_name); | strcpy(fName, port_name); | ||||
| fInUse = true; | fInUse = true; | ||||
| fLocked = false; | |||||
| fLatency = 0; | fLatency = 0; | ||||
| fTied = NO_PORT; | fTied = NO_PORT; | ||||
| // DB: At this point we do not know current buffer size in frames, | // DB: At this point we do not know current buffer size in frames, | ||||
| @@ -63,7 +62,6 @@ void JackPort::Release() | |||||
| fFlags = JackPortIsInput; | fFlags = JackPortIsInput; | ||||
| fRefNum = -1; | fRefNum = -1; | ||||
| fInUse = false; | fInUse = false; | ||||
| fLocked = false; | |||||
| fLatency = 0; | fLatency = 0; | ||||
| fTied = NO_PORT; | fTied = NO_PORT; | ||||
| fAlias1[0] = '\0'; | fAlias1[0] = '\0'; | ||||
| @@ -85,18 +83,6 @@ int JackPort::GetRefNum() const | |||||
| return fRefNum; | return fRefNum; | ||||
| } | } | ||||
| int JackPort::Lock() | |||||
| { | |||||
| fLocked = true; | |||||
| return 0; | |||||
| } | |||||
| int JackPort::Unlock() | |||||
| { | |||||
| fLocked = false; | |||||
| return 0; | |||||
| } | |||||
| jack_nframes_t JackPort::GetLatency() const | jack_nframes_t JackPort::GetLatency() const | ||||
| { | { | ||||
| return fLatency; | return fLatency; | ||||
| @@ -52,7 +52,6 @@ class JackPort | |||||
| uint8_t fMonitorRequests; | uint8_t fMonitorRequests; | ||||
| bool fInUse; | bool fInUse; | ||||
| bool fLocked; | |||||
| jack_port_id_t fTied; // Locally tied source port | jack_port_id_t fTied; // Locally tied source port | ||||
| #ifdef WIN32 | #ifdef WIN32 | ||||
| @@ -91,10 +90,7 @@ class JackPort | |||||
| int GetFlags() const; | int GetFlags() const; | ||||
| const char* GetType() const; | const char* GetType() const; | ||||
| int Lock(); | |||||
| int Unlock(); | |||||
| int Tie(jack_port_id_t port_index); | |||||
| int Tie(jack_port_id_t port_index); | |||||
| int UnTie(); | int UnTie(); | ||||
| jack_nframes_t GetLatency() const; | jack_nframes_t GetLatency() const; | ||||
| @@ -78,26 +78,10 @@ extern "C" | |||||
| jack_status_t *status, ...); | jack_status_t *status, ...); | ||||
| /** | /** | ||||
| * Attempt to become an external client of the Jack server. | |||||
| * | |||||
| * JACK is evolving a mechanism for automatically starting the server | |||||
| * when needed. As a transition, jack_client_new() only does this | |||||
| * when \$JACK_START_SERVER is defined in the environment of the | |||||
| * calling process. In the future this will become normal behavior. | |||||
| * For full control of this feature, use jack_client_open(), instead. | |||||
| * In either case, defining \$JACK_NO_START_SERVER disables this | |||||
| * feature. | |||||
| * | |||||
| * @param client_name of at most jack_client_name_size() characters. | |||||
| * If this name is already in use, the request fails. | |||||
| * | |||||
| * @return Opaque client handle if successful, otherwise NULL. | |||||
| * | |||||
| * @note Failure generally means that the JACK server is not running. | |||||
| * If there was some other problem, it will be reported via the @ref | |||||
| * jack_error_callback mechanism. Use jack_client_open() and check | |||||
| * the @a status parameter for more detailed information. | |||||
| */ | |||||
| * \bold THIS FUNCTION IS DEPRECATED AND SHOULD NOT BE USED IN | |||||
| * NEW JACK CLIENTS | |||||
| * | |||||
| */ | |||||
| jack_client_t * jack_client_new (const char *client_name); | jack_client_t * jack_client_new (const char *client_name); | ||||
| /** | /** | ||||
| @@ -201,7 +185,19 @@ extern "C" | |||||
| int jack_set_process_callback (jack_client_t *client, | int jack_set_process_callback (jack_client_t *client, | ||||
| JackProcessCallback process_callback, | JackProcessCallback process_callback, | ||||
| void *arg); | void *arg); | ||||
| /** | |||||
| * Block until this JACK client should process data. | |||||
| * | |||||
| * The @a status argument typically indicates the result | |||||
| * of some recent data processing. | |||||
| * | |||||
| * @param client - pointer to a JACK client structure | |||||
| * @param status - if non-zero, calling thread should exit | |||||
| * | |||||
| * @return the number of frames of data to process | |||||
| */ | |||||
| jack_nframes_t jack_thread_wait (jack_client_t*, int status); | |||||
| /** | /** | ||||
| * Tell JACK to call @a thread_init_callback once just after | * Tell JACK to call @a thread_init_callback once just after | ||||
| * the creation of the thread in which all other callbacks | * the creation of the thread in which all other callbacks | ||||
| @@ -318,6 +314,16 @@ extern "C" | |||||
| int jack_set_port_registration_callback (jack_client_t *, | int jack_set_port_registration_callback (jack_client_t *, | ||||
| JackPortRegistrationCallback | JackPortRegistrationCallback | ||||
| registration_callback, void *arg); | registration_callback, void *arg); | ||||
| /** | |||||
| * Tell the JACK server to call @a connect_callback whenever a | |||||
| * port is connected or disconnected, passing @a arg as a parameter. | |||||
| * | |||||
| * @return 0 on success, otherwise a non-zero error code | |||||
| */ | |||||
| int jack_set_port_connect_callback (jack_client_t *, | |||||
| JackPortConnectCallback | |||||
| connect_callback, void *arg); | |||||
| /** | /** | ||||
| * Tell the JACK server to call @a graph_callback whenever the | * Tell the JACK server to call @a graph_callback whenever the | ||||
| @@ -523,23 +529,7 @@ extern "C" | |||||
| */ | */ | ||||
| int jack_port_untie (jack_port_t *port); | int jack_port_untie (jack_port_t *port); | ||||
| /** | |||||
| * A client may call this function to prevent other objects | |||||
| * from changing the connection status of a port. The port | |||||
| * must be owned by the calling client. | |||||
| * | |||||
| * @return 0 on success, otherwise a non-zero error code | |||||
| */ | |||||
| int jack_port_lock (jack_client_t *, jack_port_t *); | |||||
| /** | |||||
| * This allows other objects to change the connection status of a port. | |||||
| * | |||||
| * @return 0 on success, otherwise a non-zero error code | |||||
| */ | |||||
| int jack_port_unlock (jack_client_t *, jack_port_t *); | |||||
| /** | |||||
| /** | |||||
| * @return the time (in frames) between data being available or | * @return the time (in frames) between data being available or | ||||
| * delivered at/to a port, and the time at which it arrived at or is | * delivered at/to a port, and the time at which it arrived at or is | ||||
| * delivered to the "other side" of the port. E.g. for a physical | * delivered to the "other side" of the port. E.g. for a physical | ||||
| @@ -571,9 +561,32 @@ extern "C" | |||||
| */ | */ | ||||
| void jack_port_set_latency (jack_port_t *, jack_nframes_t); | void jack_port_set_latency (jack_port_t *, jack_nframes_t); | ||||
| /** | |||||
| * | |||||
| */ | |||||
| /** | |||||
| * Request a complete recomputation of a port's total latency. This | |||||
| * can be called by a client that has just changed the internal | |||||
| * latency of its port using @function jack_port_set_latency | |||||
| * and wants to ensure that all signal pathways in the graph | |||||
| * are updated with respect to the values that will be returned | |||||
| * by @function jack_port_get_total_latency. | |||||
| * | |||||
| * @return zero for successful execution of the request. non-zero | |||||
| * otherwise. | |||||
| */ | |||||
| int jack_recompute_total_latency (jack_client_t*, jack_port_t* port); | |||||
| /** | |||||
| * Request a complete recomputation of all port latencies. This | |||||
| * can be called by a client that has just changed the internal | |||||
| * latency of its port using @function jack_port_set_latency | |||||
| * and wants to ensure that all signal pathways in the graph | |||||
| * are updated with respect to the values that will be returned | |||||
| * by @function jack_port_get_total_latency. It allows a client | |||||
| * to change multiple port latencies without triggering a | |||||
| * recompute for each change. | |||||
| * | |||||
| * @return zero for successful execution of the request. non-zero | |||||
| * otherwise. | |||||
| */ | |||||
| int jack_recompute_total_latencies (jack_client_t*); | int jack_recompute_total_latencies (jack_client_t*); | ||||
| /** | /** | ||||
| @@ -45,12 +45,10 @@ typedef struct _jack_midi_event | |||||
| /* Get number of events in a port buffer. | /* Get number of events in a port buffer. | ||||
| * | * | ||||
| * @param port_buffer Port buffer from which to retrieve event. | * @param port_buffer Port buffer from which to retrieve event. | ||||
| * @param nframes Number of valid frames this cycle. | |||||
| * @return number of events inside @a port_buffer | * @return number of events inside @a port_buffer | ||||
| */ | */ | ||||
| jack_nframes_t | jack_nframes_t | ||||
| jack_midi_get_event_count(void* port_buffer, | |||||
| jack_nframes_t nframes); | |||||
| jack_midi_get_event_count(void* port_buffer); | |||||
| /** Get a MIDI event from an event port buffer. | /** Get a MIDI event from an event port buffer. | ||||
| @@ -62,14 +60,12 @@ jack_midi_get_event_count(void* port_buffer, | |||||
| * @param event Event structure to store retrieved event in. | * @param event Event structure to store retrieved event in. | ||||
| * @param port_buffer Port buffer from which to retrieve event. | * @param port_buffer Port buffer from which to retrieve event. | ||||
| * @param event_index Index of event to retrieve. | * @param event_index Index of event to retrieve. | ||||
| * @param nframes Number of valid frames this cycle. | |||||
| * @return 0 on success, ENODATA if buffer is empty. | * @return 0 on success, ENODATA if buffer is empty. | ||||
| */ | */ | ||||
| int | int | ||||
| jack_midi_event_get(jack_midi_event_t *event, | jack_midi_event_get(jack_midi_event_t *event, | ||||
| void *port_buffer, | void *port_buffer, | ||||
| jack_nframes_t event_index, | |||||
| jack_nframes_t nframes); | |||||
| jack_nframes_t event_index); | |||||
| /** Clear an event buffer. | /** Clear an event buffer. | ||||
| @@ -79,11 +75,9 @@ jack_midi_event_get(jack_midi_event_t *event, | |||||
| * function may not be called on an input port's buffer. | * function may not be called on an input port's buffer. | ||||
| * | * | ||||
| * @param port_buffer Port buffer to clear (must be an output port buffer). | * @param port_buffer Port buffer to clear (must be an output port buffer). | ||||
| * @param nframes Number of valid frames this cycle. | |||||
| */ | */ | ||||
| void | void | ||||
| jack_midi_clear_buffer(void *port_buffer, | |||||
| jack_nframes_t nframes); | |||||
| jack_midi_clear_buffer(void *port_buffer); | |||||
| /** Get the size of the largest event that can be stored by the port. | /** Get the size of the largest event that can be stored by the port. | ||||
| @@ -92,10 +86,9 @@ jack_midi_clear_buffer(void *port_buffer, | |||||
| * events already stored in the port. | * events already stored in the port. | ||||
| * | * | ||||
| * @param port_buffer Port buffer to check size of. | * @param port_buffer Port buffer to check size of. | ||||
| * @param nframes Number of valid frames this cycle. | |||||
| */ | */ | ||||
| size_t | size_t | ||||
| jack_midi_max_event_size(void* port_buffer, jack_nframes_t nframes); | |||||
| jack_midi_max_event_size(void* port_buffer); | |||||
| /** Allocate space for an event to be written to an event port buffer. | /** Allocate space for an event to be written to an event port buffer. | ||||
| @@ -110,15 +103,13 @@ jack_midi_max_event_size(void* port_buffer, jack_nframes_t nframes); | |||||
| * @param port_buffer Buffer to write event to. | * @param port_buffer Buffer to write event to. | ||||
| * @param time Sample offset of event. | * @param time Sample offset of event. | ||||
| * @param data_size Length of event's raw data in bytes. | * @param data_size Length of event's raw data in bytes. | ||||
| * @param nframes Number of valid frames this event. | |||||
| * @return Pointer to the beginning of the reserved event's data buffer, or | * @return Pointer to the beginning of the reserved event's data buffer, or | ||||
| * NULL on error (ie not enough space). | * NULL on error (ie not enough space). | ||||
| */ | */ | ||||
| jack_midi_data_t* | jack_midi_data_t* | ||||
| jack_midi_event_reserve(void *port_buffer, | jack_midi_event_reserve(void *port_buffer, | ||||
| jack_nframes_t time, | jack_nframes_t time, | ||||
| size_t data_size, | |||||
| jack_nframes_t nframes); | |||||
| size_t data_size); | |||||
| /** Write an event into an event port buffer. | /** Write an event into an event port buffer. | ||||
| @@ -131,15 +122,13 @@ jack_midi_event_reserve(void *port_buffer, | |||||
| * @param time Sample offset of event. | * @param time Sample offset of event. | ||||
| * @param data Message data to be written. | * @param data Message data to be written. | ||||
| * @param data_size Length of @a data in bytes. | * @param data_size Length of @a data in bytes. | ||||
| * @param nframes Number of valid frames this event. | |||||
| * @return 0 on success, ENOBUFS if there's not enough space in buffer for event. | * @return 0 on success, ENOBUFS if there's not enough space in buffer for event. | ||||
| */ | */ | ||||
| int | int | ||||
| jack_midi_event_write(void *port_buffer, | jack_midi_event_write(void *port_buffer, | ||||
| jack_nframes_t time, | jack_nframes_t time, | ||||
| const jack_midi_data_t *data, | const jack_midi_data_t *data, | ||||
| size_t data_size, | |||||
| jack_nframes_t nframes); | |||||
| size_t data_size); | |||||
| /** Get the number of events that could not be written to @a port_buffer. | /** Get the number of events that could not be written to @a port_buffer. | ||||
| @@ -148,12 +137,10 @@ jack_midi_event_write(void *port_buffer, | |||||
| * Currently the only way this can happen is if events are lost on port mixdown. | * Currently the only way this can happen is if events are lost on port mixdown. | ||||
| * | * | ||||
| * @param port_buffer Port to receive count for. | * @param port_buffer Port to receive count for. | ||||
| * @param nframes Number of valid frames this cycle. | |||||
| * @returns Number of events that could not be written to @a port_buffer. | * @returns Number of events that could not be written to @a port_buffer. | ||||
| */ | */ | ||||
| jack_nframes_t | jack_nframes_t | ||||
| jack_midi_get_lost_event_count(void *port_buffer, | |||||
| jack_nframes_t nframes); | |||||
| jack_midi_get_lost_event_count(void *port_buffer); | |||||
| #ifdef __cplusplus | #ifdef __cplusplus | ||||
| @@ -193,6 +193,18 @@ typedef void (*JackPortRegistrationCallback)(jack_port_id_t port, int, void *arg | |||||
| */ | */ | ||||
| typedef void (*JackClientRegistrationCallback)(const char* name, int val, void *arg); | typedef void (*JackClientRegistrationCallback)(const char* name, int val, void *arg); | ||||
| /** | |||||
| * Prototype for the client supplied function that is called | |||||
| * whenever a client is registered or unregistered. | |||||
| * | |||||
| * @param a one of two ports connected or disconnected | |||||
| * @param b one of two ports connected or disconnected | |||||
| * @param connect non-zero if ports were connected | |||||
| * zero if ports were disconnected | |||||
| * @param arg pointer to a client supplied data | |||||
| */ | |||||
| typedef void (*JackPortConnectCallback)(jack_port_id_t a, jack_port_id_t b, int connect, void* arg); | |||||
| /** | /** | ||||
| * Prototype for the client supplied function that is called | * Prototype for the client supplied function that is called | ||||
| * whenever jackd starts or stops freewheeling. | * whenever jackd starts or stops freewheeling. | ||||
| @@ -45,7 +45,7 @@ int process(jack_nframes_t nframes, void *arg) | |||||
| int i,j; | int i,j; | ||||
| void* port_buf = jack_port_get_buffer(output_port, nframes); | void* port_buf = jack_port_get_buffer(output_port, nframes); | ||||
| unsigned char* buffer; | unsigned char* buffer; | ||||
| jack_midi_clear_buffer(port_buf, nframes); | |||||
| jack_midi_clear_buffer(port_buf); | |||||
| /*memset(buffer, 0, nframes*sizeof(jack_default_audio_sample_t));*/ | /*memset(buffer, 0, nframes*sizeof(jack_default_audio_sample_t));*/ | ||||
| for(i=0; i<nframes; i++) | for(i=0; i<nframes; i++) | ||||
| @@ -54,7 +54,7 @@ int process(jack_nframes_t nframes, void *arg) | |||||
| { | { | ||||
| if(note_starts[j] == loop_index) | if(note_starts[j] == loop_index) | ||||
| { | { | ||||
| buffer = jack_midi_event_reserve(port_buf, i, 3, nframes); | |||||
| buffer = jack_midi_event_reserve(port_buf, i, 3); | |||||
| /* printf("wrote a note on, port buffer = 0x%x, event buffer = 0x%x\n", port_buf, buffer);*/ | /* printf("wrote a note on, port buffer = 0x%x, event buffer = 0x%x\n", port_buf, buffer);*/ | ||||
| buffer[2] = 64; /* velocity */ | buffer[2] = 64; /* velocity */ | ||||
| buffer[1] = note_frqs[j]; | buffer[1] = note_frqs[j]; | ||||
| @@ -62,7 +62,7 @@ int process(jack_nframes_t nframes, void *arg) | |||||
| } | } | ||||
| else if(note_starts[j] + note_lengths[j] == loop_index) | else if(note_starts[j] + note_lengths[j] == loop_index) | ||||
| { | { | ||||
| buffer = jack_midi_event_reserve(port_buf, i, 3, nframes); | |||||
| buffer = jack_midi_event_reserve(port_buf, i, 3); | |||||
| /* printf("wrote a note off, port buffer = 0x%x, event buffer = 0x%x\n", port_buf, buffer);*/ | /* printf("wrote a note off, port buffer = 0x%x, event buffer = 0x%x\n", port_buf, buffer);*/ | ||||
| buffer[2] = 64; /* velocity */ | buffer[2] = 64; /* velocity */ | ||||
| buffer[1] = note_frqs[j]; | buffer[1] = note_frqs[j]; | ||||
| @@ -49,18 +49,18 @@ int process(jack_nframes_t nframes, void *arg) | |||||
| jack_default_audio_sample_t *out = (jack_default_audio_sample_t *) jack_port_get_buffer (output_port, nframes); | jack_default_audio_sample_t *out = (jack_default_audio_sample_t *) jack_port_get_buffer (output_port, nframes); | ||||
| jack_midi_event_t in_event; | jack_midi_event_t in_event; | ||||
| jack_nframes_t event_index = 0; | jack_nframes_t event_index = 0; | ||||
| jack_nframes_t event_count = jack_midi_get_event_count(port_buf, nframes); | |||||
| jack_nframes_t event_count = jack_midi_get_event_count(port_buf); | |||||
| if(event_count > 1) | if(event_count > 1) | ||||
| { | { | ||||
| printf(" midisine: have %d events\n", event_count); | printf(" midisine: have %d events\n", event_count); | ||||
| for(i=0; i<event_count; i++) | for(i=0; i<event_count; i++) | ||||
| { | { | ||||
| jack_midi_event_get(&in_event, port_buf, i, nframes); | |||||
| jack_midi_event_get(&in_event, port_buf, i); | |||||
| printf(" event %d time is %d. 1st byte is 0x%x\n", i, in_event.time, *(in_event.buffer)); | printf(" event %d time is %d. 1st byte is 0x%x\n", i, in_event.time, *(in_event.buffer)); | ||||
| } | } | ||||
| /* printf("1st byte of 1st event addr is %p\n", in_events[0].buffer);*/ | /* printf("1st byte of 1st event addr is %p\n", in_events[0].buffer);*/ | ||||
| } | } | ||||
| jack_midi_event_get(&in_event, port_buf, 0, nframes); | |||||
| jack_midi_event_get(&in_event, port_buf, 0); | |||||
| for(i=0; i<nframes; i++) | for(i=0; i<nframes; i++) | ||||
| { | { | ||||
| if((in_event.time == i) && (event_index < event_count)) | if((in_event.time == i) && (event_index < event_count)) | ||||
| @@ -79,7 +79,7 @@ int process(jack_nframes_t nframes, void *arg) | |||||
| } | } | ||||
| event_index++; | event_index++; | ||||
| if(event_index < event_count) | if(event_index < event_count) | ||||
| jack_midi_event_get(&in_event, port_buf, event_index, nframes); | |||||
| jack_midi_event_get(&in_event, port_buf, event_index); | |||||
| } | } | ||||
| ramp += note_frqs[note]; | ramp += note_frqs[note]; | ||||
| ramp = (ramp > 1.0) ? ramp - 2.0 : ramp; | ramp = (ramp > 1.0) ? ramp - 2.0 : ramp; | ||||
| @@ -901,8 +901,6 @@ int JackCoreAudioDriver::Open(jack_nframes_t nframes, | |||||
| } | } | ||||
| fDriverOutputData = 0; | fDriverOutputData = 0; | ||||
| // Start checking thread... | |||||
| fThread->Start(); | |||||
| // Core driver may have changed the in/out values | // Core driver may have changed the in/out values | ||||
| fCaptureChannels = inchannels; | fCaptureChannels = inchannels; | ||||
| @@ -932,9 +930,7 @@ int JackCoreAudioDriver::Close() | |||||
| free(fJackInputData); | free(fJackInputData); | ||||
| AudioUnitUninitialize(fAUHAL); | AudioUnitUninitialize(fAUHAL); | ||||
| CloseComponent(fAUHAL); | CloseComponent(fAUHAL); | ||||
| // Kill checking thread... | |||||
| fThread->Kill(); | |||||
| return 0; | |||||
| return 0; | |||||
| } | } | ||||
| int JackCoreAudioDriver::Attach() | int JackCoreAudioDriver::Attach() | ||||
| @@ -1062,8 +1058,11 @@ int JackCoreAudioDriver::Start() | |||||
| printError(err); | printError(err); | ||||
| return -1; | return -1; | ||||
| } | } | ||||
| return 0; | |||||
| // Start checking thread... | |||||
| fRunning = true; | |||||
| fThread->Start(); | |||||
| return 0; | |||||
| } | } | ||||
| int JackCoreAudioDriver::Stop() | int JackCoreAudioDriver::Stop() | ||||
| @@ -1071,6 +1070,9 @@ int JackCoreAudioDriver::Stop() | |||||
| AudioDeviceStop(fDeviceID, MeasureCallback); | AudioDeviceStop(fDeviceID, MeasureCallback); | ||||
| AudioDeviceRemoveIOProc(fDeviceID, MeasureCallback); | AudioDeviceRemoveIOProc(fDeviceID, MeasureCallback); | ||||
| JackLog("JackCoreAudioDriver::Stop\n"); | JackLog("JackCoreAudioDriver::Stop\n"); | ||||
| // Kill checking thread... | |||||
| fThread->Kill(); | |||||
| fRunning = false; | |||||
| return (AudioOutputUnitStop(fAUHAL) == noErr) ? 0 : -1; | return (AudioOutputUnitStop(fAUHAL) == noErr) ? 0 : -1; | ||||
| } | } | ||||
| @@ -1256,54 +1256,12 @@ int main (int argc, char *argv[]) | |||||
| printf("!!! ERROR !!! while checking jack_port_get_connections() Vs jack_port_get_all_connections() on PHY port...\n"); | printf("!!! ERROR !!! while checking jack_port_get_connections() Vs jack_port_get_all_connections() on PHY port...\n"); | ||||
| } | } | ||||
| /** | |||||
| * Test port locking function | |||||
| * Check the validity of the lock... | |||||
| * | |||||
| */ | |||||
| Log("Testing connections locks between clients...\n"); | |||||
| if (jack_disconnect(client1, jack_port_name(output_port1), jack_port_name(input_port1)) != 0) { | |||||
| if (jack_disconnect(client1, jack_port_name(output_port1), jack_port_name(input_port1)) != 0) { | |||||
| printf("!!! ERROR !!! while client1 intenting to disconnect ports...\n"); | printf("!!! ERROR !!! while client1 intenting to disconnect ports...\n"); | ||||
| } | } | ||||
| if (jack_port_lock(client2, output_port2) != 0) { | |||||
| printf("Error while calling port_lock... jack_lock will not be checked !\n"); | |||||
| } else { | |||||
| Log("Locking port 'out2'...ok\n"); | |||||
| if (jack_disconnect(client2, jack_port_name(output_port2), jack_port_name(input_port1)) != 0) { | |||||
| Log("Checking lock status with disconnect... ok\n"); | |||||
| } else { | |||||
| printf("!!! ERRROR !!! Jack_lock didn't lock port_connections with disconnect!\n"); | |||||
| } | |||||
| if (jack_port_disconnect(client1, output_port2) != 0) { | |||||
| Log("Checking lock status with port_disconnect... ok\n"); | |||||
| } else { | |||||
| printf("!!! ERRROR !!! Jack_lock didn't lock port_connections with port_disconnect!\n"); | |||||
| } | |||||
| if (jack_connect(client2, jack_port_name(output_port2), jack_port_name(input_port2)) != 0) { | |||||
| Log("Checking lock status with connect... ok\n"); | |||||
| } else { | |||||
| printf("!!! ERRROR !!! Jack_lock didn't lock port_connections with connect!\n"); | |||||
| jack_disconnect(client2, jack_port_name(output_port2), jack_port_name(input_port2)); | |||||
| } | |||||
| if (jack_port_unlock(client1, output_port2) != 0) { | |||||
| Log("Checking unlock by another client... ok\n"); | |||||
| } else { | |||||
| printf("!!! ERROR !!! a client can unlock a port locked previously by another client... \n"); | |||||
| } | |||||
| if (jack_port_unlock(client2, output_port2) != 0) { | |||||
| printf("Error while calling port_unlock... \n"); | |||||
| } | |||||
| if (jack_port_lock(client2, output_port1) != 0) { | |||||
| Log("Checking lock of port of an other client... ok\n"); | |||||
| } else { | |||||
| printf("!!! ERROR !!! a port can be locked by a non-owner client !\n"); | |||||
| jack_port_unlock(client2, output_port1); | |||||
| } | |||||
| if (jack_disconnect(client1, jack_port_name(output_port2), jack_port_name(input_port1)) != 0) { | |||||
| printf("!!! ERROR !!! while client1 intenting to disconnect ports...\n"); | |||||
| } | } | ||||
| jack_disconnect(client1, jack_port_name(output_port2), jack_port_name(input_port1)); | |||||
| // No links should subsist now... | // No links should subsist now... | ||||
| /** | /** | ||||