diff --git a/audio/drivers/dsound.c b/audio/drivers/dsound.c index f3b8d88cfa..08a75ec4d2 100644 --- a/audio/drivers/dsound.c +++ b/audio/drivers/dsound.c @@ -176,25 +176,27 @@ static void dsound_thread(void *data) /* No space to write, or we don't have data in our fifo, * but we can wait some time before it underruns ... */ - rarch_sleep(1); /* We could opt for using the notification interface, * but it is not guaranteed to work, so use high * priority sleeping patterns. */ + rarch_sleep(1); + continue; } - else if (fifo_avail < CHUNK_SIZE) + + if (!grab_region(ds, write_ptr, ®ion)) + { + ds->thread_alive = false; + SetEvent(ds->event); + break; + } + + if (fifo_avail < CHUNK_SIZE) { /* Got space to write, but nothing in FIFO (underrun), * fill block with silence. */ - if (!grab_region(ds, write_ptr, ®ion)) - { - ds->thread_alive = false; - SetEvent(ds->event); - break; - } - memset(region.chunk1, 0, region.size1); memset(region.chunk2, 0, region.size2); @@ -205,13 +207,6 @@ static void dsound_thread(void *data) { /* All is good. Pull from it and notify FIFO. */ - if (!grab_region(ds, write_ptr, ®ion)) - { - ds->thread_alive = false; - SetEvent(ds->event); - break; - } - EnterCriticalSection(&ds->crit); if (region.chunk1) fifo_read(ds->buffer, region.chunk1, region.size1);