~ubuntu-branches/ubuntu/lucid/alsa-lib/lucid

« back to all changes in this revision

Viewing changes to src/control/control.c

  • Committer: Bazaar Package Importer
  • Author(s): Luke Yelavich
  • Date: 2009-11-04 19:04:11 UTC
  • mfrom: (1.1.12 upstream) (2.2.4 squeeze)
  • Revision ID: james.westby@ubuntu.com-20091104190411-igse8f4bzca8dq5x
Tags: 1.0.21a-1ubuntu1
* Merge from debian unstable, remaining changes:
  - debian/rules:
    + Don't bail when removing include/alsa
  - debian/control: Add Vcs-Bzr URI
  - Add configuration files for bluetooth/bluez-alsa and pulseaudio
  - debian/libasound2.install: Ship smixer plugins for native and bi-arch
    packages
  - drop libcxxtools-dev build dependency, its in universe
  - debian/patches/Fix-fpe-snd_pcm_mmap_begin.patch: Handle attempts to
    divide by zero

Show diffs side-by-side

added added

removed removed

Lines of Context:
211
211
}
212
212
 
213
213
/**
214
 
 * \brief Ask to be informed about events (poll, #snd_ctl_async, #snd_ctl_read)
 
214
 * \brief Ask to be informed about events (poll, #snd_async_add_ctl_handler, #snd_ctl_read)
215
215
 * \param ctl CTL handle
216
216
 * \param subscribe 0 = unsubscribe, 1 = subscribe
217
217
 * \return 0 on success otherwise a negative error code
674
674
int snd_ctl_wait(snd_ctl_t *ctl, int timeout)
675
675
{
676
676
        struct pollfd *pfd;
677
 
        unsigned short *revents;
678
 
        int i, npfds, pollio, err, err_poll;
 
677
        unsigned short revents;
 
678
        int i, npfds, err, err_poll;
679
679
 
680
680
        npfds = snd_ctl_poll_descriptors_count(ctl);
681
681
        if (npfds <= 0 || npfds >= 16) {
683
683
                return -EIO;
684
684
        }
685
685
        pfd = alloca(sizeof(*pfd) * npfds);
686
 
        revents = alloca(sizeof(*revents) * npfds);
687
686
        err = snd_ctl_poll_descriptors(ctl, pfd, npfds);
688
687
        if (err < 0)
689
688
                return err;
691
690
                SNDMSG("invalid poll descriptors %d\n", err);
692
691
                return -EIO;
693
692
        }
694
 
        do {
 
693
        for (;;) {
695
694
                err_poll = poll(pfd, npfds, timeout);
696
695
                if (err_poll < 0)
697
696
                        return -errno;
698
697
                if (! err_poll)
699
 
                        break;
700
 
                err = snd_ctl_poll_descriptors_revents(ctl, pfd, npfds, revents);
 
698
                        return 0;
 
699
                err = snd_ctl_poll_descriptors_revents(ctl, pfd, npfds, &revents);
701
700
                if (err < 0)
702
701
                        return err;
703
 
                pollio = 0;
704
 
                for (i = 0; i < npfds; i++) {
705
 
                        if (revents[i] & (POLLERR | POLLNVAL))
706
 
                                return -EIO;
707
 
                        if ((revents[i] & (POLLIN | POLLOUT)) == 0)
708
 
                                continue;
709
 
                        pollio++;
710
 
                }
711
 
        } while (! pollio);
712
 
 
713
 
        return err_poll > 0 ? 1 : 0;
 
702
                if (revents & (POLLERR | POLLNVAL))
 
703
                        return -EIO;
 
704
                if (revents & (POLLIN | POLLOUT))
 
705
                        return 1;
 
706
        }
714
707
}
715
708
 
716
709
/**