int audio_output_play ( struct audio_file fd  ) 

Write data to the sound device.

Definition at line 86 of file audio_output_ao.c.

00087 {
00088         const char *drvname;
00089         int16_t buf[2048];
00090         int len, drvnum;
00091 
00092         if ((len = audio_file_read(fd, buf, sizeof buf / sizeof(int16_t))) == 0)
00093                 return (-1);
00094 
00095         if ((unsigned int)devfmt.rate != fd->srate ||
00096             (unsigned int)devfmt.channels != fd->channels) {
00097                 /* Sample rate or amount of channels has changed */
00098                 audio_output_close();
00099 
00100                 devfmt.rate = fd->srate;
00101                 devfmt.channels = fd->channels;
00102         }
00103 
00104         if (devptr == NULL) {
00105                 drvname = config_getopt("audio.output.ao.driver");
00106                 if (drvname[0] != '\0') {
00107                         /* User specified driver */
00108                         drvnum = ao_driver_id(drvname);
00109                 } else {
00110                         /* Default driver */
00111                         drvnum = ao_default_driver_id();
00112                 }
00113 
00114                 devptr = ao_open_live(drvnum, &devfmt, devopt);
00115                 if (devptr == NULL) {
00116                         gui_msgbar_warn(_("Cannot open the audio device."));
00117                         return (-1);
00118                 }
00119         }
00120 
00121         if (ao_play(devptr, (char *)buf, len * sizeof(int16_t)) == 0) {
00122                 /* No success - device must be closed */
00123                 audio_output_close();
00124                 return (-1);
00125         }
00126 
00127         return (0);
00128 }

Here is the call graph for this function:

 All Data Structures Files Functions Variables Defines
Generated on Mon Mar 15 04:45:05 2010 for herrie by  doxygen 1.6.3