aboutsummaryrefslogtreecommitdiff
path: root/plugins/dfsound/sdl.c
diff options
context:
space:
mode:
authorneonloop2021-03-14 18:54:30 +0000
committerneonloop2021-03-14 19:28:36 +0000
commitcc67e49563096e4367881e8bbe4554f1a7d21595 (patch)
tree393883d80d2b417d67a4fb2150dbd37392017802 /plugins/dfsound/sdl.c
parent34c62fb129becec9e61a48227d9ed89867cdd470 (diff)
downloadpcsx_rearmed-cc67e49563096e4367881e8bbe4554f1a7d21595.tar.gz
pcsx_rearmed-cc67e49563096e4367881e8bbe4554f1a7d21595.tar.bz2
pcsx_rearmed-cc67e49563096e4367881e8bbe4554f1a7d21595.zip
Adds frameskip based on free audio buffer space
Diffstat (limited to 'plugins/dfsound/sdl.c')
-rw-r--r--plugins/dfsound/sdl.c12
1 files changed, 8 insertions, 4 deletions
diff --git a/plugins/dfsound/sdl.c b/plugins/dfsound/sdl.c
index ce92b6e..5a5ca51 100644
--- a/plugins/dfsound/sdl.c
+++ b/plugins/dfsound/sdl.c
@@ -103,17 +103,20 @@ static void sdl_finish(void) {
pSndBuffer = NULL;
}
-static int sdl_busy(void) {
+static float sdl_capacity(void) {
int size;
- if (pSndBuffer == NULL) return 1;
+ if (pSndBuffer == NULL) return 0;
+ if (iBufSize == 0) return 0;
size = iReadPos - iWritePos;
if (size <= 0) size += iBufSize;
- if (size < iBufSize / 2) return 1;
+ return (float)size / iBufSize;
+}
- return 0;
+static int sdl_busy(void) {
+ return sdl_capacity() < 0.5;
}
static void sdl_feed(void *pSound, int lBytes) {
@@ -140,4 +143,5 @@ void out_register_sdl(struct out_driver *drv)
drv->finish = sdl_finish;
drv->busy = sdl_busy;
drv->feed = sdl_feed;
+ drv->capacity = sdl_capacity;
}