patch-src_speexdec_c 2.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869
  1. $OpenBSD: patch-src_speexdec_c,v 1.4 2010/01/02 20:44:19 jakemsr Exp $
  2. --- src/speexdec.c.orig Fri May 30 00:34:16 2008
  3. +++ src/speexdec.c Sat Jan 2 12:40:42 2010
  4. @@ -68,6 +68,9 @@
  5. #include <fcntl.h>
  6. #include <sys/ioctl.h>
  7. +#elif defined USE_SNDIO
  8. +#include <sndio.h>
  9. +
  10. #elif defined HAVE_SYS_AUDIOIO_H
  11. #include <sys/types.h>
  12. #include <fcntl.h>
  13. @@ -92,6 +95,10 @@
  14. ((buf[base+1]<<8)&0xff00)| \
  15. (buf[base]&0xff))
  16. +#ifdef USE_SNDIO
  17. +struct sio_hdl *hdl;
  18. +#endif
  19. +
  20. static void print_comments(char *comments, int length)
  21. {
  22. char *c=comments;
  23. @@ -187,6 +194,32 @@ FILE *out_file_open(char *outFile, int rate, int *chan
  24. exit(1);
  25. }
  26. fout = fdopen(audio_fd, "w");
  27. +#elif defined USE_SNDIO
  28. + struct sio_par par;
  29. +
  30. + hdl = sio_open(NULL, SIO_PLAY, 0);
  31. + if (!hdl)
  32. + {
  33. + fprintf(stderr, "Cannot open sndio device\n");
  34. + exit(1);
  35. + }
  36. +
  37. + sio_initpar(&par);
  38. + par.sig = 1;
  39. + par.bits = 16;
  40. + par.rate = rate;
  41. + par.pchan = *channels;
  42. +
  43. + if (!sio_setpar(hdl, &par) || !sio_getpar(hdl, &par) ||
  44. + par.sig != 1 || par.bits != 16 || par.rate != rate) {
  45. + fprintf(stderr, "could not set sndio parameters\n");
  46. + exit(1);
  47. + }
  48. + *channels = par.pchan;
  49. + if (!sio_start(hdl)) {
  50. + fprintf(stderr, "could not start sndio\n");
  51. + exit(1);
  52. + }
  53. #elif defined HAVE_SYS_AUDIOIO_H
  54. audio_info_t info;
  55. int audio_fd;
  56. @@ -746,6 +779,10 @@ int main(int argc, char **argv)
  57. #if defined WIN32 || defined _WIN32
  58. if (strlen(outFile)==0)
  59. WIN_Play_Samples (out+frame_offset*channels, sizeof(short) * new_frame_size*channels);
  60. + else
  61. +#elif defined USE_SNDIO
  62. + if (strlen(outFile)==0)
  63. + sio_write (hdl, out+frame_offset*channels, sizeof(short) * new_frame_size*channels);
  64. else
  65. #endif
  66. fwrite(out+frame_offset*channels, sizeof(short), new_frame_size*channels, fout);