info.play.sample_rate = rate;
FILE *out_file_open(char *outFile, int rate, int *channels){   FILE *fout=NULL;   /*Open output file*/   if (strlen(outFile)==0)   {#if defined HAVE_SYS_SOUNDCARD_H      int audio_fd, format, stereo;      audio_fd=open("/dev/dsp", O_WRONLY);      if (audio_fd<0)      {         perror("Cannot open /dev/dsp");         exit(1);               }      format=AFMT_S16_NE;      if (ioctl(audio_fd, SNDCTL_DSP_SETFMT, &format)==-1)      {         perror("SNDCTL_DSP_SETFMT");         close(audio_fd);         exit(1);      }      stereo=0;      if (*channels==2)         stereo=1;      if (ioctl(audio_fd, SNDCTL_DSP_STEREO, &stereo)==-1)      {         perror("SNDCTL_DSP_STEREO");         close(audio_fd);         exit(1);      }      if (stereo!=0)      {         if (*channels==1)            fprintf (stderr, "Cannot set mono mode, will decode in stereo\n");         *channels=2;      }      if (ioctl(audio_fd, SNDCTL_DSP_SPEED, &rate)==-1)      {         perror("SNDCTL_DSP_SPEED");         close(audio_fd);         exit(1);      }      fout = fdopen(audio_fd, "w");#elif defined HAVE_SYS_AUDIOIO_H      audio_info_t info;      int audio_fd;            audio_fd = open("/dev/audio", O_WRONLY);      if (audio_fd<0)      {         perror("Cannot open /dev/audio");         exit(1);      }      AUDIO_INITINFO(&info);#ifdef AUMODE_PLAY    /* NetBSD/OpenBSD */      info.mode = AUMODE_PLAY;#endif      info.play.encoding = AUDIO_ENCODING_SLINEAR;      info.play.precision = 16;      info.play.channels = *channels;            if (ioctl(audio_fd, AUDIO_SETINFO, &info) < 0)      {         perror ("AUDIO_SETINFO");         exit(1);      }      fout = fdopen(audio_fd, "w");#elif defined WIN32 || defined _WIN32      {         unsigned int speex_channels = *channels;         if (Set_WIN_Params (INVALID_FILEDESC, rate, SAMPLE_SIZE, speex_channels))         {            fprintf (stderr, "Can't access %s\n", "WAVE OUT");            exit(1);         }      }#else      fprintf (stderr, "No soundcard support\n");      exit(1);#endif   } else {      if (strcmp(outFile,"-")==0)      {#if defined WIN32 || defined _WIN32         _setmode(_fileno(stdout), _O_BINARY);#endif         fout=stdout;      }      else       {#if defined WIN32 || defined _WIN32         fout = fopen(outFile, "wb");#else         fout = fopen(outFile, "w");#endif         if (!fout)         {            perror(outFile);            exit(1);         }         if (strcmp(outFile+strlen(outFile)-4,".wav")==0 || strcmp(outFile+strlen(outFile)-4,".WAV")==0)            write_wav_header(fout, rate, *channels, 0, 0);      }   }   return fout;}