Skip to content
Snippets Groups Projects
Commit d8bf6286 authored by deuce's avatar deuce
Browse files

Watch for short ALSA writes (even though we're in blocking mode)

parent c38bb86c
No related branches found
No related tags found
No related merge requests found
......@@ -630,15 +630,28 @@ void xp_play_sample_thread(void *data)
#ifdef USE_ALSA_SOUND
if(handle_type==SOUND_DEVICE_ALSA) {
if(alsa_api->snd_pcm_writei(playback_handle, sample_buffer, sample_size)!=sample_size) {
/* Go back and try OSS */
alsa_device_open_failed=TRUE;
xptone_close();
xptone_open();
int ret;
int written=0;
while(written < sample_size) {
ret=alsa_api->snd_pcm_writei(playback_handle, sample, sample_size);
if(ret < 0) {
if(written==0) {
/* Go back and try OSS */
xptone_close();
alsa_device_open_failed=TRUE;
xptone_open();
}
break;
}
written += ret;
}
else {
if(!alsa_device_open_failed) {
while(alsa_api->snd_pcm_drain(playback_handle))
SLEEP(1);
if(must_close)
xptone_close();
return(TRUE);
}
}
#endif
......@@ -768,13 +781,23 @@ BOOL DLLCALL xp_play_sample(const unsigned char *sample, size_t sample_size, BOO
#ifdef USE_ALSA_SOUND
if(handle_type==SOUND_DEVICE_ALSA) {
if(alsa_api->snd_pcm_writei(playback_handle, sample, sample_size)!=sample_size) {
/* Go back and try OSS */
alsa_device_open_failed=TRUE;
xptone_close();
xptone_open();
int ret;
int written=0;
while(written < sample_size) {
ret=alsa_api->snd_pcm_writei(playback_handle, sample, sample_size);
if(ret < 0) {
if(written==0) {
/* Go back and try OSS */
xptone_close();
alsa_device_open_failed=TRUE;
xptone_open();
}
break;
}
written += ret;
}
else {
if(!alsa_device_open_failed) {
while(alsa_api->snd_pcm_drain(playback_handle))
SLEEP(1);
if(must_close)
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment