diff options
author | sletz <sletz@0c269be4-1314-0410-8aa9-9f06e86f4224> | 2008-01-28 12:52:04 +0000 |
---|---|---|
committer | sletz <sletz@0c269be4-1314-0410-8aa9-9f06e86f4224> | 2008-01-28 12:52:04 +0000 |
commit | 5f4030a7002271393fd6190ee982f90bb6a374f7 (patch) | |
tree | dfd44e591670115daeeaf34c0148b3ceb8272ece | |
parent | 4d17ae65e87d7fee955b1a3d5323e745c7408476 (diff) | |
download | jack2-5f4030a7002271393fd6190ee982f90bb6a374f7.tar.gz |
Updated API to match jack 0.109.0 version (in progress). Correct issue in CoreAudio driver.
git-svn-id: http://subversion.jackaudio.org/jack/jack2/trunk/jackmp@1777 0c269be4-1314-0410-8aa9-9f06e86f4224
-rw-r--r-- | ChangeLog | 4 | ||||
-rw-r--r-- | common/JackAPI.cpp | 44 | ||||
-rw-r--r-- | common/JackAPIWrapper.cpp | 20 | ||||
-rw-r--r-- | common/JackConstants.h | 4 | ||||
-rw-r--r-- | common/JackEngine.cpp | 4 | ||||
-rw-r--r-- | common/JackGraphManager.cpp | 22 | ||||
-rw-r--r-- | common/JackGraphManager.h | 3 | ||||
-rw-r--r-- | common/JackMidiAPI.cpp | 109 | ||||
-rw-r--r-- | common/JackPort.cpp | 16 | ||||
-rw-r--r-- | common/JackPort.h | 6 | ||||
-rw-r--r-- | common/jack/jack.h | 95 | ||||
-rw-r--r-- | common/jack/midiport.h | 27 | ||||
-rw-r--r-- | common/jack/types.h | 12 | ||||
-rw-r--r-- | example-clients/midiseq.c | 6 | ||||
-rw-r--r-- | example-clients/midisine.c | 8 | ||||
-rw-r--r-- | macosx/JackCoreAudioDriver.cpp | 16 | ||||
-rw-r--r-- | tests/jack_test.cpp | 48 |
17 files changed, 102 insertions, 342 deletions
@@ -17,6 +17,10 @@ Tim Blechmann 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> * OSX 32/64 bits version.
diff --git a/common/JackAPI.cpp b/common/JackAPI.cpp index 02de2530..8d16485c 100644 --- a/common/JackAPI.cpp +++ b/common/JackAPI.cpp @@ -111,8 +111,6 @@ extern "C" const jack_port_t *port); 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_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_total_latency (jack_client_t *, 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) { #ifdef __CLIENTDEBUG__ diff --git a/common/JackAPIWrapper.cpp b/common/JackAPIWrapper.cpp index 7b0bb153..5f1e8269 100644 --- a/common/JackAPIWrapper.cpp +++ b/common/JackAPIWrapper.cpp @@ -87,8 +87,6 @@ extern "C" const jack_port_t *port); 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_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_total_latency (jack_client_t *, 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); } -// 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); 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) @@ -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_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_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_connect_fun = (jack_connect_fun_def)dlsym(gLibrary, "jack_connect"); jack_disconnect_fun = (jack_disconnect_fun_def)dlsym(gLibrary, "jack_disconnect"); diff --git a/common/JackConstants.h b/common/JackConstants.h index 562830f3..de1faa8c 100644 --- a/common/JackConstants.h +++ b/common/JackConstants.h @@ -71,9 +71,9 @@ namespace Jack #define ALL_CLIENTS -1 // for notification #if defined(__ppc64__) || defined(__x86_64__) - #define JACK_PROTOCOL_VERSION 3 + #define JACK_PROTOCOL_VERSION 4 #else - #define JACK_PROTOCOL_VERSION 2 + #define JACK_PROTOCOL_VERSION 3 #endif #define DRIVER_OPEN_TIMEOUT 5 // in sec diff --git a/common/JackEngine.cpp b/common/JackEngine.cpp index d20871cd..8f7a8674 100644 --- a/common/JackEngine.cpp +++ b/common/JackEngine.cpp @@ -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); if (dst == ALL_PORTS) { - return (fGraphManager->CheckPort(src) < 0) - ? -1 - : fGraphManager->DisconnectAll(src); + return fGraphManager->DisconnectAll(src); } else { return (fGraphManager->CheckPorts(src, dst) < 0) ? -1 diff --git a/common/JackGraphManager.cpp b/common/JackGraphManager.cpp index 80f24798..8a0d508b 100644 --- a/common/JackGraphManager.cpp +++ b/common/JackGraphManager.cpp @@ -595,18 +595,6 @@ int JackGraphManager::ConnectedTo(jack_port_id_t port_src, const char* port_name } // 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) { 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; } - 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; } diff --git a/common/JackGraphManager.h b/common/JackGraphManager.h index 21d3af5d..52d3beb7 100644 --- a/common/JackGraphManager.h +++ b/common/JackGraphManager.h @@ -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(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 DisconnectAllOutput(jack_port_id_t port_index); int DisconnectAll(jack_port_id_t port_index); diff --git a/common/JackMidiAPI.cpp b/common/JackMidiAPI.cpp index a276c475..27b04baa 100644 --- a/common/JackMidiAPI.cpp +++ b/common/JackMidiAPI.cpp @@ -23,14 +23,10 @@ This program is free software; you can redistribute it and/or modify #include <errno.h> #include <string.h> - #ifdef WIN32 #define ENOBUFS 55 #endif -/* -Post jack 0.103.0 version - #ifdef __cplusplus extern "C" { #endif @@ -134,108 +130,3 @@ jack_nframes_t jack_midi_get_lost_event_count(void* port_buffer) return buf->lost_events; 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; -} diff --git a/common/JackPort.cpp b/common/JackPort.cpp index 4da8668f..5b8e083d 100644 --- a/common/JackPort.cpp +++ b/common/JackPort.cpp @@ -29,7 +29,7 @@ namespace Jack { 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() @@ -45,7 +45,6 @@ bool JackPort::Allocate(int refnum, const char* port_name, const char* port_type fRefNum = refnum; strcpy(fName, port_name); fInUse = true; - fLocked = false; fLatency = 0; fTied = NO_PORT; // DB: At this point we do not know current buffer size in frames, @@ -63,7 +62,6 @@ void JackPort::Release() fFlags = JackPortIsInput; fRefNum = -1; fInUse = false; - fLocked = false; fLatency = 0; fTied = NO_PORT; fAlias1[0] = '\0'; @@ -85,18 +83,6 @@ int JackPort::GetRefNum() const return fRefNum; } -int JackPort::Lock() -{ - fLocked = true; - return 0; -} - -int JackPort::Unlock() -{ - fLocked = false; - return 0; -} - jack_nframes_t JackPort::GetLatency() const { return fLatency; diff --git a/common/JackPort.h b/common/JackPort.h index ea8761c7..b0083994 100644 --- a/common/JackPort.h +++ b/common/JackPort.h @@ -52,7 +52,6 @@ class JackPort uint8_t fMonitorRequests; bool fInUse; - bool fLocked; jack_port_id_t fTied; // Locally tied source port #ifdef WIN32 @@ -91,10 +90,7 @@ class JackPort int GetFlags() 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(); jack_nframes_t GetLatency() const; diff --git a/common/jack/jack.h b/common/jack/jack.h index ae42ee9c..29bd7955 100644 --- a/common/jack/jack.h +++ b/common/jack/jack.h @@ -78,26 +78,10 @@ extern "C" 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); /** @@ -201,7 +185,19 @@ extern "C" int jack_set_process_callback (jack_client_t *client, JackProcessCallback process_callback, 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 * 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 *, JackPortRegistrationCallback 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 @@ -523,23 +529,7 @@ extern "C" */ 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 * 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 @@ -571,9 +561,32 @@ extern "C" */ 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*); /** diff --git a/common/jack/midiport.h b/common/jack/midiport.h index 3ff415ee..da574f8d 100644 --- a/common/jack/midiport.h +++ b/common/jack/midiport.h @@ -45,12 +45,10 @@ typedef struct _jack_midi_event /* Get number of events in a port buffer. * * @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 */ 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. @@ -62,14 +60,12 @@ jack_midi_get_event_count(void* port_buffer, * @param event Event structure to store retrieved event in. * @param port_buffer Port buffer from which to retrieve event. * @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. */ int jack_midi_event_get(jack_midi_event_t *event, void *port_buffer, - jack_nframes_t event_index, - jack_nframes_t nframes); + jack_nframes_t event_index); /** 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. * * @param port_buffer Port buffer to clear (must be an output port buffer). - * @param nframes Number of valid frames this cycle. */ 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. @@ -92,10 +86,9 @@ jack_midi_clear_buffer(void *port_buffer, * events already stored in the port. * * @param port_buffer Port buffer to check size of. - * @param nframes Number of valid frames this cycle. */ 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. @@ -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 time Sample offset of event. * @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 * NULL on error (ie not enough space). */ jack_midi_data_t* jack_midi_event_reserve(void *port_buffer, jack_nframes_t time, - size_t data_size, - jack_nframes_t nframes); + size_t data_size); /** 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 data Message data to be written. * @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. */ 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); + size_t data_size); /** 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. * * @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. */ 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 diff --git a/common/jack/types.h b/common/jack/types.h index 1b05618e..18792279 100644 --- a/common/jack/types.h +++ b/common/jack/types.h @@ -195,6 +195,18 @@ typedef void (*JackClientRegistrationCallback)(const char* name, int val, void * /** * 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 * whenever jackd starts or stops freewheeling. * * @param starting non-zero if we start starting to freewheel, zero otherwise diff --git a/example-clients/midiseq.c b/example-clients/midiseq.c index 44f2e9af..97459aec 100644 --- a/example-clients/midiseq.c +++ b/example-clients/midiseq.c @@ -45,7 +45,7 @@ int process(jack_nframes_t nframes, void *arg) int i,j; void* port_buf = jack_port_get_buffer(output_port, nframes); 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));*/ for(i=0; i<nframes; i++) @@ -54,7 +54,7 @@ int process(jack_nframes_t nframes, void *arg) { 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);*/ buffer[2] = 64; /* velocity */ 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) { - 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);*/ buffer[2] = 64; /* velocity */ buffer[1] = note_frqs[j]; diff --git a/example-clients/midisine.c b/example-clients/midisine.c index 7d05764a..871d4e8b 100644 --- a/example-clients/midisine.c +++ b/example-clients/midisine.c @@ -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_midi_event_t in_event; 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) { printf(" midisine: have %d events\n", event_count); 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("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++) { if((in_event.time == i) && (event_index < event_count)) @@ -79,7 +79,7 @@ int process(jack_nframes_t nframes, void *arg) } event_index++; 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 = (ramp > 1.0) ? ramp - 2.0 : ramp; diff --git a/macosx/JackCoreAudioDriver.cpp b/macosx/JackCoreAudioDriver.cpp index 36aa7d83..930e2a97 100644 --- a/macosx/JackCoreAudioDriver.cpp +++ b/macosx/JackCoreAudioDriver.cpp @@ -901,8 +901,6 @@ int JackCoreAudioDriver::Open(jack_nframes_t nframes, } fDriverOutputData = 0; - // Start checking thread... - fThread->Start(); // Core driver may have changed the in/out values fCaptureChannels = inchannels; @@ -932,9 +930,7 @@ int JackCoreAudioDriver::Close() free(fJackInputData); AudioUnitUninitialize(fAUHAL); CloseComponent(fAUHAL); - // Kill checking thread... - fThread->Kill(); - return 0; + return 0; } int JackCoreAudioDriver::Attach() @@ -1062,8 +1058,11 @@ int JackCoreAudioDriver::Start() printError(err); return -1; } - - return 0; + + // Start checking thread... + fRunning = true; + fThread->Start(); + return 0; } int JackCoreAudioDriver::Stop() @@ -1071,6 +1070,9 @@ int JackCoreAudioDriver::Stop() AudioDeviceStop(fDeviceID, MeasureCallback); AudioDeviceRemoveIOProc(fDeviceID, MeasureCallback); JackLog("JackCoreAudioDriver::Stop\n"); + // Kill checking thread... + fThread->Kill(); + fRunning = false; return (AudioOutputUnitStop(fAUHAL) == noErr) ? 0 : -1; } diff --git a/tests/jack_test.cpp b/tests/jack_test.cpp index d65c4ac0..c169f31a 100644 --- a/tests/jack_test.cpp +++ b/tests/jack_test.cpp @@ -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"); } - /** - * 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"); } - - 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... /** |