Browse Source

Merge branch 'newer-midi'

git-svn-id: http://subversion.jackaudio.org/jack/jack2/trunk/jackmp@4371 0c269be4-1314-0410-8aa9-9f06e86f4224
tags/1.9.8
sletz 14 years ago
parent
commit
61c4e13d66
4 changed files with 65 additions and 6 deletions
  1. +2
    -1
      common/JackEngine.cpp
  2. +16
    -2
      common/JackMidiAPI.cpp
  3. +2
    -0
      common/JackMidiPort.cpp
  4. +45
    -3
      example-clients/midi_latency_test.c

+ 2
- 1
common/JackEngine.cpp View File

@@ -804,7 +804,8 @@ int JackEngine::PortRegister(int refnum, const char* name, const char *type, uns
return -1;
}

*port_index = fGraphManager->AllocatePort(refnum, name, type, (JackPortFlags)flags, buffer_size);
// buffer_size is actually ignored...
*port_index = fGraphManager->AllocatePort(refnum, name, type, (JackPortFlags)flags, fEngineControl->fBufferSize);
if (*port_index != NO_PORT) {
if (client->GetClientControl()->fActive)
NotifyPortRegistation(*port_index, true);


+ 16
- 2
common/JackMidiAPI.cpp View File

@@ -98,10 +98,24 @@ EXPORT
jack_midi_data_t* jack_midi_event_reserve(void* port_buffer, jack_nframes_t time, size_t data_size)
{
JackMidiBuffer *buf = (JackMidiBuffer*)port_buffer;
if (!buf && !buf->IsValid())
if (! buf) {
jack_error("jack_midi_event_reserve: port buffer is set to NULL");
return 0;
if (time >= buf->nframes || (buf->event_count && buf->events[buf->event_count - 1].time > time))
}
if (! buf->IsValid()) {
jack_error("jack_midi_event_reserve: port buffer is invalid");
return 0;
}
if (time >= buf->nframes) {
jack_error("jack_midi_event_reserve: time parameter is out of range "
"(%lu >= %lu)", time, buf->nframes);
return 0;
}
if (buf->event_count && (buf->events[buf->event_count - 1].time > time)) {
jack_error("jack_midi_event_reserve: time parameter is earlier than "
"last reserved event");
return 0;
}
return buf->ReserveEvent(time, data_size);
}



+ 2
- 0
common/JackMidiPort.cpp View File

@@ -52,6 +52,8 @@ SERVER_EXPORT jack_midi_data_t* JackMidiBuffer::ReserveEvent(jack_nframes_t time
{
jack_shmsize_t space = MaxEventSize();
if (space == 0 || size > space) {
jack_error("JackMidiBuffer::ReserveEvent - the buffer does not have "
"enough room to enqueue a %lu byte event", size);
lost_events++;
return 0;
}


+ 45
- 3
example-clients/midi_latency_test.c View File

@@ -47,6 +47,7 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
* implementations for semaphores and command-line argument handling.
*/

#include <assert.h>
#include <errno.h>
#include <math.h>
#include <signal.h>
@@ -84,6 +85,8 @@ const char *SOURCE_SHUTDOWN = "handle_shutdown";
const char *SOURCE_SIGNAL_SEMAPHORE = "signal_semaphore";
const char *SOURCE_WAIT_SEMAPHORE = "wait_semaphore";

char *alias1;
char *alias2;
jack_client_t *client;
semaphore_t connect_semaphore;
volatile int connections_established;
@@ -517,9 +520,31 @@ update_connection(jack_port_t *remote_port, int connected,
return current_port;
}
if (target_name) {
if (strcmp(target_name, jack_port_name(remote_port))) {
char *aliases[2];
if (! strcmp(target_name, jack_port_name(remote_port))) {
return remote_port;
}
aliases[0] = alias1;
aliases[1] = alias2;
switch (jack_port_get_aliases(remote_port, aliases)) {
case -1:
/* Sigh ... */
die("jack_port_get_aliases", "Failed to get port aliases");
case 2:
if (! strcmp(target_name, alias2)) {
return remote_port;
}
/* Fallthrough on purpose */
case 1:
if (! strcmp(target_name, alias1)) {
return remote_port;
}
/* Fallthrough on purpose */
case 0:
return NULL;
}
/* This shouldn't happen. */
assert(0);
}
return remote_port;
}
@@ -537,7 +562,6 @@ update_connection(jack_port_t *remote_port, int connected,
connected, then we take the first port name in the array and use it
as our remote port. It's a dumb implementation. */
current_port = jack_port_by_name(client, port_names[0]);

jack_free(port_names);
if (current_port == NULL) {
/* Sigh */
@@ -597,6 +621,7 @@ main(int argc, char **argv)
{"timeout", 1, NULL, 't'}
};
size_t name_arg_count;
size_t name_size;
char *option_string = "hm:s:t:";
int show_usage = 0;
connections_established = 0;
@@ -656,11 +681,24 @@ main(int argc, char **argv)
output_usage();
return EXIT_FAILURE;
}
name_size = jack_port_name_size();
alias1 = malloc(name_size * sizeof(char));
if (alias1 == NULL) {
error_message = strerror(errno);
error_source = "malloc";
goto show_error;
}
alias2 = malloc(name_size * sizeof(char));
if (alias2 == NULL) {
error_message = strerror(errno);
error_source = "malloc";
goto free_alias1;
}
latency_values = malloc(sizeof(jack_nframes_t) * samples);
if (latency_values == NULL) {
error_message = strerror(errno);
error_source = "malloc";
goto show_error;
goto free_alias2;
}
latency_time_values = malloc(sizeof(jack_time_t) * samples);
if (latency_time_values == NULL) {
@@ -917,6 +955,10 @@ main(int argc, char **argv)
free(latency_time_values);
free_latency_values:
free(latency_values);
free_alias2:
free(alias2);
free_alias1:
free(alias1);
if (error_message != NULL) {
show_error:
output_error(error_source, error_message);


Loading…
Cancel
Save