From e288aa689738f2d8e7fddf5d2ddb4c87b82fa147 Mon Sep 17 00:00:00 2001 From: Rodrigo Braz Monteiro Date: Fri, 16 Nov 2007 13:15:26 +0000 Subject: [PATCH] Applied p-static's patch for ALSA Originally committed to SVN as r1654. --- aegisub/audio_player_alsa.cpp | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/aegisub/audio_player_alsa.cpp b/aegisub/audio_player_alsa.cpp index 191e86d24..e3ae15768 100644 --- a/aegisub/audio_player_alsa.cpp +++ b/aegisub/audio_player_alsa.cpp @@ -418,6 +418,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 @@ -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) +