int snd_seq_open(snd_seq_t **handle, const char *name, int streams, int mode);
int snd_seq_close(snd_seq_t *handle);
-int snd_seq_poll_descriptors_count(snd_seq_t *handle);
-int snd_seq_poll_descriptors(snd_seq_t *handle, struct pollfd *pfds, unsigned int space);
+int snd_seq_poll_descriptors_count(snd_seq_t *handle, short events);
+int snd_seq_poll_descriptors(snd_seq_t *handle, struct pollfd *pfds, unsigned int space, short events);
int snd_seq_nonblock(snd_seq_t *handle, int nonblock);
int snd_seq_client_id(snd_seq_t *handle);
int snd_seq_output_buffer_size(snd_seq_t *handle);
return seq->poll_fd;
}
-int snd_seq_poll_descriptors_count(snd_seq_t *seq)
+int snd_seq_poll_descriptors_count(snd_seq_t *seq, short events)
{
+ int result = 0;
assert(seq);
- return 1;
+ if (events & POLLIN) {
+ assert(seq->streams & SND_SEQ_OPEN_INPUT);
+ result++;
+ }
+ if (events & POLLOUT) {
+ assert(seq->streams & SND_SEQ_OPEN_OUTPUT);
+ result++;
+ }
+ return result ? 1 : 0;
}
-int snd_seq_poll_descriptors(snd_seq_t *seq, struct pollfd *pfds, unsigned int space)
+int snd_seq_poll_descriptors(snd_seq_t *seq, struct pollfd *pfds, unsigned int space, short events)
{
+ short revents = 0;
+
assert(seq);
- if (space >= 1) {
- pfds->fd = seq->poll_fd;
- pfds->events = 0;
- if (seq->streams & SND_SEQ_OPEN_INPUT)
- pfds->events |= POLLIN;
- if (seq->streams & SND_SEQ_OPEN_OUTPUT)
- pfds->events |= POLLOUT;
- return 1;
+ if ((events & POLLIN) && space >= 1) {
+ assert(seq->streams & SND_SEQ_OPEN_INPUT);
+ revents |= POLLIN;
}
- return 0;
+ if ((events & POLLOUT) && space >= 1) {
+ assert(seq->streams & SND_SEQ_OPEN_INPUT);
+ revents |= POLLOUT;
+ }
+ if (!revents)
+ return 0;
+ pfds->fd = seq->poll_fd;
+ pfds->events = revents;
+ return 1;
}
/*