diff options
author | Jaroslav Kysela <perex@perex.cz> | 2001-07-04 13:54:13 +0000 |
---|---|---|
committer | Jaroslav Kysela <perex@perex.cz> | 2001-07-04 13:54:13 +0000 |
commit | 88e5e451516e7496a86a96ea8a38e63e522b6b22 (patch) | |
tree | 1706ce3e52c92ed1a45d3ea95eeb9c5f432bc7ed /test/playmidi1.c | |
parent | d23ff765adde011a08638093698f00600a83fc9e (diff) | |
download | alsa-lib-88e5e451516e7496a86a96ea8a38e63e522b6b22.tar.gz |
Major change to sequencer API.
The sequencer API is totally recoded with the style of "encapsulation"
in other api.
The structure becomes opaque and accessed only via functions.
Other changes:
- There is no longer group in client and port info.
- snd_seq_query_subs_t is renamed to snd_seq_query_subscribe_t.
- snd_seq_delete_port takes only the port id argument instead of
port_info structure.
- snd_seq_input/output_buffer_size are renamed
as snd_seq_get_input/output_buffer_size.
Similarly snd_seq_resize_input/output_buffer are renamed as
snd_seq_set_input/output_buffer_size.
- snd_seq_get_named_queue is renamed to snd_seq_query_named_queue.
- Sync codes are removed temporarily from API.
- Subscription conditions are accessed via the corresponding functions.
convert_time is named now as time_update.
- snd_seq_get/set_queue_owner are removed.
Use snd_seq_get/set_queue_info instead.
- Instrument put/get/remove structure is unified as snd_instr_header_t.
Diffstat (limited to 'test/playmidi1.c')
-rw-r--r-- | test/playmidi1.c | 47 |
1 files changed, 22 insertions, 25 deletions
diff --git a/test/playmidi1.c b/test/playmidi1.c index a7b20467..7fc7baa7 100644 --- a/test/playmidi1.c +++ b/test/playmidi1.c @@ -114,13 +114,11 @@ static void write_ev(snd_seq_event_t *ev) return; } while ((rc = snd_seq_event_output(seq_handle, ev)) < 0) { - int seqfd; - fd_set fds; - seqfd = snd_seq_poll_descriptor(seq_handle); - FD_ZERO(&fds); - FD_SET(seqfd, &fds); - if ((rc = select(seqfd + 1, NULL, &fds, NULL, NULL)) < 0) { - printf("select error = %i (%s)\n", rc, snd_strerror(rc)); + int npfds = snd_seq_poll_descriptors_count(seq_handle, POLLOUT); + struct pollfd *pfds = alloca(sizeof(*pfds) * npfds); + snd_seq_poll_descriptors(seq_handle, pfds, npfds, POLLOUT); + if ((rc = poll(pfds, npfds, -1)) < 0) { + printf("poll error = %i (%s)\n", rc, snd_strerror(errno)); exit(1); } } @@ -147,7 +145,7 @@ static void mytext(int type, int leng, char *msg) static void do_header(int format, int ntracks, int division) { - snd_seq_queue_tempo_t tempo; + snd_seq_queue_tempo_t *tempo; if (verbose >= VERB_INFO) printf("smf format %d, %d tracks, %d ppq\n", format, ntracks, division); @@ -159,15 +157,16 @@ static void do_header(int format, int ntracks, int division) exit(1); } /* set ppq */ + snd_seq_queue_tempo_alloca(&tempo); /* ppq must be set before starting timer */ - if (snd_seq_get_queue_tempo(seq_handle, dest_queue, &tempo) < 0) { + if (snd_seq_get_queue_tempo(seq_handle, dest_queue, tempo) < 0) { perror("get_queue_tempo"); exit(1); } - if (tempo.ppq != ppq) { - slave_ppq = tempo.ppq; - tempo.ppq = ppq; - if (snd_seq_set_queue_tempo(seq_handle, dest_queue, &tempo) < 0) { + if (snd_seq_queue_tempo_get_ppq(tempo) != ppq) { + slave_ppq = snd_seq_queue_tempo_get_ppq(tempo); + snd_seq_queue_tempo_set_ppq(tempo, ppq); + if (snd_seq_set_queue_tempo(seq_handle, dest_queue, tempo) < 0) { perror("set_queue_tempo"); if (!slave) exit(1); @@ -176,7 +175,7 @@ static void do_header(int format, int ntracks, int division) } else slave_ppq = ppq; if (verbose >= VERB_INFO) - printf("ALSA Timer updated, PPQ = %d\n", tempo.ppq); + printf("ALSA Timer updated, PPQ = %d\n", snd_seq_queue_tempo_get_ppq(tempo)); } /* start playing... */ @@ -364,13 +363,11 @@ static snd_seq_event_t *wait_for_event(void) /* 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_poll_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)); + int npfds = snd_seq_poll_descriptors_count(seq_handle, POLLIN); + struct pollfd *pfds = alloca(sizeof(*pfds) * npfds); + snd_seq_poll_descriptors(seq_handle, pfds, npfds, POLLIN); + if ((left = poll(pfds, npfds, -1)) < 0) { + printf("poll error = %i (%s)\n", errno, snd_strerror(errno)); exit(1); } } @@ -525,13 +522,13 @@ int main(int argc, char *argv[]) /* open sequencer device */ /* Here we open the device read/write mode. */ /* Because we write SND_SEQ_EVENT_ECHO to myself to sync. */ - tmp = snd_seq_open(&seq_handle, SND_SEQ_OPEN); + tmp = snd_seq_open(&seq_handle, "hw", SND_SEQ_OPEN_DUPLEX, 0); if (tmp < 0) { perror("open /dev/snd/seq"); exit(1); } - tmp = snd_seq_block_mode(seq_handle, use_blocking_mode); + tmp = snd_seq_nonblock(seq_handle, !use_blocking_mode); if (tmp < 0) { perror("block_mode"); exit(1); @@ -557,7 +554,7 @@ int main(int argc, char *argv[]) /* setup queue */ if (dest_queue >= 0) { - if (snd_seq_use_queue(seq_handle, dest_queue, 1) < 0) { + if (snd_seq_set_queue_usage(seq_handle, dest_queue, 1) < 0) { perror("use queue"); exit(1); } @@ -580,7 +577,7 @@ int main(int argc, char *argv[]) if (slave) { tmp = snd_seq_connect_from(seq_handle, my_port, SND_SEQ_CLIENT_SYSTEM, - snd_seq_queue_sync_port(dest_queue)); + dest_queue + 16 /*snd_seq_queue_sync_port(dest_queue)*/); if (tmp < 0) { perror("subscribe"); exit(1); |