File tree Expand file tree Collapse file tree 1 file changed +8
-11
lines changed Expand file tree Collapse file tree 1 file changed +8
-11
lines changed Original file line number Diff line number Diff line change @@ -351,21 +351,18 @@ static bool ALSA_WaitDevice(SDL_AudioDevice *device)
351
351
const int sample_frames = device -> sample_frames ;
352
352
const int fulldelay = (int ) ((((Uint64 ) sample_frames ) * 1000 ) / device -> spec .freq );
353
353
const int delay = SDL_clamp (fulldelay , 1 , 5 );
354
- int total_delays = 0 ;
355
354
356
- SDL_assert (fulldelay > 0 ); // so the `fulldelay * 5` below produces a reasonable result.
357
-
358
- while (!SDL_GetAtomicInt (& device -> shutdown ) && (ALSA_snd_pcm_avail (device -> hidden -> pcm ) < sample_frames )) {
359
- if (total_delays >= (fulldelay * 5 )) {
360
- // Hmm, not much we can do - probably disconnected, abort
361
- //SDL_LogError(SDL_LOG_CATEGORY_AUDIO, "ALSA: hardware seems to have frozen, giving up on it.");
355
+ while (!SDL_GetAtomicInt (& device -> shutdown )) {
356
+ const int rc = ALSA_snd_pcm_avail (device -> hidden -> pcm );
357
+ if (rc < 0 ) {
358
+ SDL_LogError (SDL_LOG_CATEGORY_AUDIO , "ALSA wait failed (unrecoverable): %s" , ALSA_snd_strerror (rc ));
362
359
return false;
363
- } else {
364
- SDL_Delay (delay );
365
- total_delays += delay ; // THIS IS NOT EXACT, but just so we don't wait forever on problems...
366
360
}
361
+ if (rc >= sample_frames ) {
362
+ break ;
363
+ }
364
+ SDL_Delay (delay );
367
365
}
368
-
369
366
return true;
370
367
}
371
368
You can’t perform that action at this time.
0 commit comments