mirror of
https://github.com/alsa-project/alsa-utils
synced 2024-12-22 19:56:31 +01:00
More generic support for poll descriptors
This commit is contained in:
parent
abd8b9f9e8
commit
0b01722266
2 changed files with 10 additions and 13 deletions
|
@ -1041,12 +1041,8 @@ static int events(int argc ATTRIBUTE_UNUSED, char *argv[] ATTRIBUTE_UNUSED)
|
||||||
}
|
}
|
||||||
printf("Ready to listen...\n");
|
printf("Ready to listen...\n");
|
||||||
while (1) {
|
while (1) {
|
||||||
struct pollfd ctl_poll;
|
int res = snd_hctl_wait(handle, -1);
|
||||||
int res;
|
if (res >= 0) {
|
||||||
ctl_poll.fd = snd_hctl_poll_descriptor(handle);
|
|
||||||
ctl_poll.events = POLLIN;
|
|
||||||
ctl_poll.revents = 0;
|
|
||||||
if ((res = poll(&ctl_poll, 1, -1)) > 0) {
|
|
||||||
printf("Poll ok: %i\n", res);
|
printf("Poll ok: %i\n", res);
|
||||||
res = snd_hctl_handle_events(handle);
|
res = snd_hctl_handle_events(handle);
|
||||||
assert(res > 0);
|
assert(res > 0);
|
||||||
|
@ -1152,13 +1148,9 @@ static int sevents(int argc ATTRIBUTE_UNUSED, char *argv[] ATTRIBUTE_UNUSED)
|
||||||
|
|
||||||
printf("Ready to listen...\n");
|
printf("Ready to listen...\n");
|
||||||
while (1) {
|
while (1) {
|
||||||
struct pollfd mixer_poll;
|
|
||||||
int res;
|
int res;
|
||||||
mixer_poll.fd = snd_mixer_poll_descriptor(handle, card);
|
res = snd_mixer_wait(handle, -1);
|
||||||
assert(mixer_poll.fd >= 0);
|
if (res >= 0) {
|
||||||
mixer_poll.events = POLLIN;
|
|
||||||
mixer_poll.revents = 0;
|
|
||||||
if ((res = poll(&mixer_poll, 1, -1)) > 0) {
|
|
||||||
printf("Poll ok: %i\n", res);
|
printf("Poll ok: %i\n", res);
|
||||||
res = snd_mixer_handle_events(handle);
|
res = snd_mixer_handle_events(handle);
|
||||||
assert(res >= 0);
|
assert(res >= 0);
|
||||||
|
|
|
@ -232,12 +232,17 @@ static void close_files(void)
|
||||||
static void init_seq(char *source, char *dest)
|
static void init_seq(char *source, char *dest)
|
||||||
{
|
{
|
||||||
snd_seq_addr_t addr;
|
snd_seq_addr_t addr;
|
||||||
|
int err;
|
||||||
|
struct pollfd pfd;
|
||||||
|
|
||||||
if (snd_seq_open(&handle, "hw", SND_SEQ_OPEN_DUPLEX, 0) < 0) {
|
if (snd_seq_open(&handle, "hw", SND_SEQ_OPEN_DUPLEX, 0) < 0) {
|
||||||
perror("snd_seq_open");
|
perror("snd_seq_open");
|
||||||
exit(1);
|
exit(1);
|
||||||
}
|
}
|
||||||
seqfd = snd_seq_poll_descriptor(handle);
|
err = snd_seq_poll_descriptors(handle, &pfd, 1);
|
||||||
|
assert(err == 1);
|
||||||
|
seqfd = pfd.fd;
|
||||||
|
|
||||||
snd_seq_nonblock(handle, 0);
|
snd_seq_nonblock(handle, 0);
|
||||||
|
|
||||||
/* set client info */
|
/* set client info */
|
||||||
|
|
Loading…
Reference in a new issue