dvbaudio.c 1.5 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950
  1. /*
  2. * libdvbnet - a DVB network support library
  3. *
  4. * Copyright (C) 2005 Andrew de Quincey (adq_dvb@lidskialf.net)
  5. *
  6. * This library is free software; you can redistribute it and/or
  7. * modify it under the terms of the GNU Lesser General Public
  8. * License as published by the Free Software Foundation; either
  9. * version 2.1 of the License, or (at your option) any later version.
  10. *
  11. * This library is distributed in the hope that it will be useful,
  12. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  13. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
  14. * Lesser General Public License for more details.
  15. *
  16. * You should have received a copy of the GNU Lesser General Public
  17. * License along with this library; if not, write to the Free Software
  18. * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
  19. */
  20. #include <stdlib.h>
  21. #include <string.h>
  22. #include <stdio.h>
  23. #include <sys/param.h>
  24. #include <fcntl.h>
  25. #include <unistd.h>
  26. #include <sys/ioctl.h>
  27. #include <linux/dvb/audio.h>
  28. #include <errno.h>
  29. #include "dvbaudio.h"
  30. int dvbaudio_open(int adapter, int audiodeviceid)
  31. {
  32. char filename[PATH_MAX+1];
  33. int fd;
  34. sprintf(filename, "/dev/dvb/adapter%i/audio%i", adapter, audiodeviceid);
  35. if ((fd = open(filename, O_RDWR)) < 0) {
  36. // if that failed, try a flat /dev structure
  37. sprintf(filename, "/dev/dvb%i.audio%i", adapter, audiodeviceid);
  38. fd = open(filename, O_RDWR);
  39. }
  40. return fd;
  41. }
  42. int dvbaudio_set_bypass(int fd, int bypass)
  43. {
  44. return ioctl(fd, AUDIO_SET_BYPASS_MODE, bypass);
  45. }