On Tue, 14 Oct 2003 11:49:37 +0200 Takashi Iwai <[EMAIL PROTECTED]> wrote:
> At Mon, 13 Oct 2003 10:53:24 -0700, > Ryan Pavlik wrote: > > > > Hey, I'm currently pondering an ALSA interface for Ruby > > (http://ruby-lang.org). Unfortunately, to do what I want, I need to > > be able to have a file descriptor for select(). I've tried using the > > fds returned by snd_seq_poll_descriptors(), but (not suprisingly) they > > didn't work: select blocks indefinitely. > > if i understand correctly, it should work. fd field in the returned > pollfd struct is the file descriptor for select(). This is what I had hoped. However, it doesn't seem to work correctly, and I'm thinking it's because the file descriptor isn't actually for reading and writing, but some other form of communication I'm not familiar with. I'm using the "seqdemo.c" example from the HOWTO as a testbase. The main bit of code looks like this: while (1) { FD_ZERO(&rfds); FD_SET(pfd[0].fd, &rfds); if (select(npfd, &rfds, NULL, NULL, NULL)) { midi_action(seq_handle); } } Basically, a replacement of the old while() loop with a bridge from the poll() structs to select(). I've used select() before with no problems, but this simply hangs indefinitely, while the poll() version works as advertised. >From the select manpage: Three independent sets of descriptors are watched. Those listed in readfds will be watched to see if characters become available for read- ing (more precisely, to see if a read will not block - in particular, a file descriptor is also ready on end-of-file), [...] I'm thinking it may not be the case that /proc/snd/dev/seq may not be something that you read() from, but I'm not sure. I've attached my version of seqdemo, perhaps I'm doing something wrong. thanks, -- Ryan Pavlik <[EMAIL PROTECTED]> "I'll *prove* to you that sword-chucks are the single greatest advancement in all weaponology." - 8BT
seqdemo.c
Description: Binary data