Ticket #1584: alsa_cloexec.diff

File alsa_cloexec.diff, 900 bytes (added by reimar, 17 years ago)

Try to set CLOEXEC on ALSA fds

  • libao2/ao_alsa.c

     
    480480    }
    481481
    482482    if (!alsa_handler) {
     483      struct pollfd *pollfds;
     484      int fd_count;
    483485      //modes = 0, SND_PCM_NONBLOCK, SND_PCM_ASYNC
    484486      if ((err = try_open_device(alsa_device, open_mode, format == AF_FORMAT_AC3)) < 0)
    485487        {
     
    494496            return 0;
    495497          }
    496498        }
     499      fd_count = snd_pcm_poll_descriptors_count(alsa_handler);
     500      pollfds = calloc(fd_count, sizeof(*pollfds));
     501      snd_pcm_poll_descriptors(alsa_handler, pollfds, fd_count);
     502      while (fd_count-- >= 0) fcntl(pollfds[fd_count].fd, F_SETFD, FD_CLOEXEC);
     503      free(pollfds);
    497504
    498505      if ((err = snd_pcm_nonblock(alsa_handler, 0)) < 0) {
    499506         mp_msg(MSGT_AO,MSGL_ERR,MSGTR_AO_ALSA_ErrorSetBlockMode, snd_strerror(err));