snd_pcm_recover should automatically re-prepare the stream as needed

This commit is contained in:
Chris Robinson 2010-06-16 02:17:41 -07:00
parent 17e6840f92
commit 6b23f2dfa3

View File

@ -302,14 +302,9 @@ static DevMap *probe_devices(snd_pcm_stream_t stream, ALuint *count)
static int xrun_recovery(snd_pcm_t *handle, int err) static int xrun_recovery(snd_pcm_t *handle, int err)
{ {
if(err == -EINTR || err == -EPIPE || err == -ESTRPIPE) err = psnd_pcm_recover(handle, err, 1);
{ if(err < 0)
err = psnd_pcm_recover(handle, err, 1); AL_PRINT("recover failed: %s\n", psnd_strerror(err));
if(err >= 0)
err = psnd_pcm_prepare(handle);
if(err < 0)
AL_PRINT("recover failed: %s\n", psnd_strerror(err));
}
return err; return err;
} }
@ -444,8 +439,8 @@ static ALuint ALSANoMMapProc(ALvoid *ptr)
case -EPIPE: case -EPIPE:
case -EINTR: case -EINTR:
ret = psnd_pcm_recover(data->pcmHandle, ret, 1); ret = psnd_pcm_recover(data->pcmHandle, ret, 1);
if(ret >= 0) if(ret < 0)
psnd_pcm_prepare(data->pcmHandle); avail = 0;
break; break;
default: default:
if (ret >= 0) if (ret >= 0)
@ -943,8 +938,7 @@ static ALCuint alsa_available_samples(ALCdevice *Device)
{ {
AL_PRINT("avail update failed: %s\n", psnd_strerror(avail)); AL_PRINT("avail update failed: %s\n", psnd_strerror(avail));
if((avail=psnd_pcm_recover(data->pcmHandle, avail, 1)) >= 0 && if((avail=psnd_pcm_recover(data->pcmHandle, avail, 1)) >= 0)
(avail=psnd_pcm_prepare(data->pcmHandle)) >= 0)
{ {
if(data->doCapture) if(data->doCapture)
avail = psnd_pcm_start(data->pcmHandle); avail = psnd_pcm_start(data->pcmHandle);
@ -971,8 +965,7 @@ static ALCuint alsa_available_samples(ALCdevice *Device)
if(amt == -EAGAIN) if(amt == -EAGAIN)
continue; continue;
if((amt=psnd_pcm_recover(data->pcmHandle, amt, 1)) >= 0 && if((amt=psnd_pcm_recover(data->pcmHandle, amt, 1)) >= 0)
(amt=psnd_pcm_prepare(data->pcmHandle)) >= 0)
{ {
if(data->doCapture) if(data->doCapture)
amt = psnd_pcm_start(data->pcmHandle); amt = psnd_pcm_start(data->pcmHandle);