Write data to the sound device. Definition at line 156 of file audio_output_alsa.c. 00157 { 00158 int16_t buf[8192]; 00159 snd_pcm_sframes_t ret, len, done = 0; 00160 00161 if ((len = audio_file_read(fd, buf, sizeof buf / sizeof(int16_t))) == 0) 00162 return (-1); 00163 00164 if (fd->channels != channels || fd->srate != srate) { 00165 /* Apply the new values */ 00166 channels = fd->channels; 00167 srate = fd->srate; 00168 if (audio_output_apply_hwparams() != 0) { 00169 gui_msgbar_warn(_("Sample rate or amount of channels not supported.")); 00170 /* Invalidate the old settings */ 00171 srate = 0; 00172 return (-1); 00173 } 00174 } 00175 00176 /* ALSA measures in sample lengths */ 00177 len /= fd->channels; 00178 00179 /* Our complex error handling for snd_pcm_writei() */ 00180 while (done < len) { 00181 ret = snd_pcm_writei(devhnd, buf + (done * fd->channels), len - done); 00182 if (ret == -EPIPE) { 00183 /* Buffer underrun. Try again. */ 00184 if (snd_pcm_prepare(devhnd) != 0) 00185 return (-1); 00186 continue; 00187 } else if (ret <= 0) { 00188 /* Some other strange error. */ 00189 return (-1); 00190 } 00191 00192 done += ret; 00193 } 00194 00195 return (0); 00196 }
Here is the call graph for this function:
![]() |
1.6.3