Applied p-static's patch for ALSA

Originally committed to SVN as r1654.
This commit is contained in:
Rodrigo Braz Monteiro 2007-11-16 13:15:26 +00:00
parent 1cf34a15e7
commit e288aa6897
1 changed files with 10 additions and 1 deletions

View File

@ -419,6 +419,11 @@ void AlsaPlayer::async_write_handler(snd_async_handler_t *pcm_callback)
snd_pcm_sframes_t frames = snd_pcm_avail_update(player->pcm_handle);
if (frames == -EPIPE) {
snd_pcm_prepare(player->pcm_handle);
frames = snd_pcm_avail_update(player->pcm_handle);
}
// TODO: handle underrun
if (player->cur_frame >= player->end_frame) {
@ -434,7 +439,10 @@ void AlsaPlayer::async_write_handler(snd_async_handler_t *pcm_callback)
while (frames >= player->period) {
unsigned long start = player->cur_frame;
player->provider->GetAudioWithVolume(buf, player->cur_frame, player->period, player->volume);
snd_pcm_writei(player->pcm_handle, buf, player->period);
int err = snd_pcm_writei(player->pcm_handle, buf, player->period);
if(err == -EPIPE) {
snd_pcm_prepare(player->pcm_handle);
}
player->cur_frame += player->period;
frames = snd_pcm_avail_update(player->pcm_handle);
}
@ -443,3 +451,4 @@ void AlsaPlayer::async_write_handler(snd_async_handler_t *pcm_callback)