summaryrefslogtreecommitdiff
path: root/test
diff options
context:
space:
mode:
authorJaroslav Kysela <perex@perex.cz>1999-09-01 22:19:11 +0000
committerJaroslav Kysela <perex@perex.cz>1999-09-01 22:19:11 +0000
commit11ce43d87cda6d69519c843a9b906b038a15c94a (patch)
tree78873e3ff9dcbca04f58c47efc8982916ec71468 /test
parentf247f920e1e46009da7a94ed5f7a35c3b36f0713 (diff)
Takashi Iwai <iwai@ww.uni-erlangen.de> Mon, 30 Aug 1999 14:56:38 +0200
Diffstat (limited to 'test')
-rw-r--r--test/README.aconnect5
-rw-r--r--test/aconnect.c11
-rw-r--r--test/playmidi1.c148
3 files changed, 75 insertions, 89 deletions
diff --git a/test/README.aconnect b/test/README.aconnect
index ecc4f842..7d3d071f 100644
--- a/test/README.aconnect
+++ b/test/README.aconnect
@@ -1,6 +1,6 @@
================================================================
aconnect - control subscriptions
- ver.0.1.1
+ ver.0.1.2
Copyright (C) 1999 Takashi Iwai
================================================================
@@ -40,8 +40,7 @@ Some ports may have permission for its own group.
In such a case, change the group of aconnect to the appropriate one by
using -g option.
-The option -l together with -i or -o shows subscribers and tracking
-for each port.
+The option -l together with -i or -o shows subscribers for each port.
The option -D specifies the sequencer device file (as default,
/dev/snd/seq). Usually, you don't have to change it.
diff --git a/test/aconnect.c b/test/aconnect.c
index cd81ab7d..888f2301 100644
--- a/test/aconnect.c
+++ b/test/aconnect.c
@@ -1,6 +1,6 @@
/*
* connect / disconnect two subscriber ports
- * ver.0.1.1
+ * ver.0.1.2
*
* Copyright (C) 1999 Takashi Iwai
*
@@ -96,10 +96,8 @@ static void list_subscribers(snd_seq_t *seq, int client, int port)
memset(&subs, 0, sizeof(subs));
subs.client = client;
subs.port = port;
- list_each_subs(seq, &subs, SND_SEQ_QUERY_SUBS_READ, "Read Subscribers");
- list_each_subs(seq, &subs, SND_SEQ_QUERY_SUBS_WRITE, "Write Subscribers");
- list_each_subs(seq, &subs, SND_SEQ_QUERY_SUBS_READ_TRACK, "Read Tracking");
- list_each_subs(seq, &subs, SND_SEQ_QUERY_SUBS_WRITE_TRACK, "Write Tracking");
+ list_each_subs(seq, &subs, SND_SEQ_QUERY_SUBS_READ, "Connecting To");
+ list_each_subs(seq, &subs, SND_SEQ_QUERY_SUBS_WRITE, "Connected From");
}
/*
@@ -231,6 +229,7 @@ int main(int argc, char **argv)
parse_address(&subs.dest, argv[optind + 1]);
subs.sender.queue = subs.dest.queue = queue;
subs.exclusive = 0;
+ subs.convert_time = 0;
subs.realtime = 0;
if (command == UNSUBSCRIBE) {
@@ -245,7 +244,7 @@ int main(int argc, char **argv)
return 1;
}
} else {
- if (snd_seq_get_port_subscription(seq, &subs) < 0) {
+ if (snd_seq_get_port_subscription(seq, &subs) == 0) {
snd_seq_close(seq);
fprintf(stderr, "Connection is already subscribed\n");
return 1;
diff --git a/test/playmidi1.c b/test/playmidi1.c
index b42b522e..d8d4017a 100644
--- a/test/playmidi1.c
+++ b/test/playmidi1.c
@@ -12,6 +12,9 @@
* - fix tempo event bug
* - add command line options
*
+ * 19990827 Takashi Iwai <iwai@ww.uni-erlangen.de>
+ * - use snd_seq_alloc_queue()
+ *
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
@@ -49,7 +52,6 @@
#define USE_BLOCKING_MODE
/* default destination queue, client and port numbers */
-#define DEST_QUEUE_NUMBER 7
#define DEST_CLIENT_NUMBER 65
#define DEST_PORT_NUMBER 0
@@ -66,7 +68,7 @@ static double local_secs = 0;
static int local_ticks = 0;
static int local_tempo = 500000;
-static int dest_queue = DEST_QUEUE_NUMBER;
+static int dest_queue = 0;
static int dest_client = DEST_CLIENT_NUMBER;
static int dest_port = DEST_PORT_NUMBER;
static int source_channel = 0;
@@ -413,11 +415,42 @@ static void do_sysex(int len, char *msg)
write_ev_var(&ev, len, msg);
}
+static snd_seq_event_t *wait_for_event(void)
+{
+ int left;
+ snd_seq_event_t *input_event;
+
+#ifdef USE_BLOCKING_MODE
+ /* read event - blocked until any event is read */
+ left = snd_seq_event_input(seq_handle, &input_event);
+#else
+ /* read event - using select syscall */
+ while ((left = snd_seq_event_input(seq_handle, &input_event)) >= 0 &&
+ input_event == NULL) {
+ int seqfd;
+ fd_set fds;
+ seqfd = snd_seq_file_descriptor(seq_handle);
+ FD_ZERO(&fds);
+ FD_SET(seqfd, &fds);
+ if ((left = select(seqfd + 1, &fds, NULL, NULL, NULL)) < 0) {
+ printf("select error = %i (%s)\n", left, snd_strerror(left));
+ exit(1);
+ }
+ }
+#endif
+ if (left < 0) {
+ printf("alsa_sync error!:%s\n", snd_strerror(left));
+ return NULL;
+ }
+
+ return input_event;
+}
+
/* synchronize to the end of event */
static void alsa_sync(void)
{
int left;
- snd_seq_event_t* input_event;
+ snd_seq_event_t *input_event;
snd_seq_event_t ev;
/* send echo event to self client. */
@@ -425,7 +458,6 @@ static void alsa_sync(void)
printf("alsa_sync syncing... send ECHO(%d) event to myself. time=%f\n",
SND_SEQ_EVENT_ECHO, (double) Mf_currtime+1);
ev.source.port = source_port;
- ev.source.channel = source_channel;
ev.dest.queue = dest_queue;
ev.dest.client = snd_seq_client_id(seq_handle);
ev.dest.port = source_port;
@@ -445,34 +477,17 @@ static void alsa_sync(void)
left = snd_seq_flush_output(seq_handle);
/* wait for the timer start event */
-#ifdef USE_BLOCKING_MODE
- /* read event - blocked until any event is read */
- left = snd_seq_event_input(seq_handle, &input_event);
-#else
- /* read event - using select syscall */
- while ((left = snd_seq_event_input(seq_handle, &input_event)) >= 0 &&
- input_event == NULL) {
- int seqfd;
- fd_set fds;
- seqfd = snd_seq_file_descriptor(seq_handle);
- FD_ZERO(&fds);
- FD_SET(seqfd, &fds);
- if ((left = select(seqfd + 1, &fds, NULL, NULL, NULL)) < 0) {
- printf("select error = %i (%s)\n", left, snd_strerror(left));
- exit(1);
+ for (;;) {
+ input_event = wait_for_event();
+ if (input_event) {
+ if (verbose >= VERB_MUCH)
+ printf("alsa_sync got event. type=%d, flags=%d\n",
+ input_event->type, input_event->flags);
+ if (input_event->type == SND_SEQ_EVENT_ECHO)
+ break;
+ snd_seq_free_event(input_event);
}
}
-#endif
- if (left < 0) {
- printf("alsa_sync error!:%s\n", snd_strerror(left));
- return;
- }
-
- if (verbose >= VERB_MUCH)
- printf("alsa_sync got event. type=%d, flags=%d\n",
- input_event->type, input_event->flags);
- snd_seq_free_event(input_event);
-
if (verbose >= VERB_MUCH)
printf("alsa_sync synced\n");
}
@@ -481,41 +496,21 @@ static void alsa_sync(void)
/* wait for start of the queue */
static void wait_start(void)
{
- int left;
- snd_seq_event_t* input_event;
-
+ snd_seq_event_t *input_event;
+
/* wait the start event from the system timer */
- do {
-#ifdef USE_BLOCKING_MODE
- /* read event - blocked until any event is read */
- left = snd_seq_event_input(seq_handle, &input_event);
-#else
- /* read event - using select syscall */
- while ((left = snd_seq_event_input(seq_handle, &input_event)) >= 0 &&
- input_event == NULL) {
- int seqfd;
- fd_set fds;
- seqfd = snd_seq_file_descriptor(seq_handle);
- FD_ZERO(&fds);
- FD_SET(seqfd, &fds);
- if ((left = select(seqfd + 1, &fds, NULL, NULL, NULL)) < 0) {
- printf("select error = %i (%s)\n", left, snd_strerror(left));
- exit(1);
- }
+ for (;;) {
+ input_event = wait_for_event();
+ if (input_event) {
+ if (verbose >= VERB_MUCH)
+ printf("wait_start got event. type=%d, flags=%d\n",
+ input_event->type, input_event->flags);
+ if (input_event->type == SND_SEQ_EVENT_START &&
+ input_event->data.addr.queue == dest_queue)
+ break;
+ snd_seq_free_event(input_event);
}
-#endif
- if (left < 0) {
- printf("alsa_sync error!:%s\n", snd_strerror(left));
- return;
- }
-
- if (verbose >= VERB_MUCH)
- printf("wait_start got event. type=%d, flags=%d\n",
- input_event->type, input_event->flags);
- snd_seq_free_event(input_event);
-
- } while (input_event->type != SND_SEQ_EVENT_START);
-
+ }
if (verbose >= VERB_MUCH)
printf("start received\n");
}
@@ -527,30 +522,25 @@ static void usage(void)
fprintf(stderr, "usage: playmidi1 [options] [file]\n");
fprintf(stderr, " options:\n");
fprintf(stderr, " -v: verbose mode\n");
- fprintf(stderr, " -a queue:client:port : set destination address (default=%d:%d:%d)\n",
- DEST_QUEUE_NUMBER, DEST_CLIENT_NUMBER, DEST_PORT_NUMBER);
+ fprintf(stderr, " -a client:port : set destination address (default=%d:%d)\n",
+ DEST_CLIENT_NUMBER, DEST_PORT_NUMBER);
fprintf(stderr, " -s: slave mode (allow external clock synchronisation)\n");
-
}
/* parse destination address (-a option) */
-void parse_address(char *arg, int *queuep, int *clientp, int *portp)
+void parse_address(char *arg, int *clientp, int *portp)
{
char *next;
- *queuep = atoi(arg);
- if ((next = strchr(arg, ':')) != NULL) {
- *clientp = atoi(next + 1);
- if ((next = strchr(next + 1, ':')) != NULL)
- *portp = atoi(next + 1);
- }
+ *clientp = atoi(arg);
+ if ((next = strchr(arg, ':')) != NULL)
+ *portp = atoi(next + 1);
}
int main(int argc, char *argv[])
{
snd_seq_client_info_t inf;
snd_seq_port_info_t src_port_info;
- snd_seq_queue_client_t queue_info;
snd_seq_port_subscribe_t subscribe;
snd_seq_client_pool_t pool;
int tmp;
@@ -562,7 +552,7 @@ int main(int argc, char *argv[])
verbose++;
break;
case 'a':
- parse_address(optarg, &dest_queue, &dest_client, &dest_port);
+ parse_address(optarg, &dest_client, &dest_port);
break;
case 's':
slave = 1;
@@ -630,11 +620,9 @@ int main(int argc, char *argv[])
source_port = src_port_info.port;
/* setup queue */
- bzero(&queue_info,sizeof(queue_info));
- queue_info.used = 1;
- tmp = snd_seq_set_queue_client(seq_handle, dest_queue, &queue_info);
- if (tmp < 0) {
- perror("queue_client");
+ dest_queue = snd_seq_alloc_queue(seq_handle);
+ if (dest_queue < 0) {
+ perrror("alloc queue");
exit(1);
}