aboutsummaryrefslogtreecommitdiff
path: root/plugins/dfsound/oss.c
diff options
context:
space:
mode:
authornotaz2015-01-05 23:50:33 +0200
committernotaz2015-01-10 01:57:56 +0200
commite541b8e06ff03a7fe7bd75b1bc0ad53f60b2d0de (patch)
tree68a1291696301e90cf3b10c4fda1733dc4eab0b7 /plugins/dfsound/oss.c
parent3bd31caf9e9f5ddab2bf4fbdb5a129f4972c45f3 (diff)
downloadpcsx_rearmed-e541b8e06ff03a7fe7bd75b1bc0ad53f60b2d0de.tar.gz
pcsx_rearmed-e541b8e06ff03a7fe7bd75b1bc0ad53f60b2d0de.tar.bz2
pcsx_rearmed-e541b8e06ff03a7fe7bd75b1bc0ad53f60b2d0de.zip
spu: don't block on audio
Diffstat (limited to 'plugins/dfsound/oss.c')
-rw-r--r--plugins/dfsound/oss.c14
1 files changed, 11 insertions, 3 deletions
diff --git a/plugins/dfsound/oss.c b/plugins/dfsound/oss.c
index 8093ae4..6b1cb4a 100644
--- a/plugins/dfsound/oss.c
+++ b/plugins/dfsound/oss.c
@@ -34,6 +34,9 @@
#define OSS_SPEED_44100 44100
+#define FRAGMENT_SHIFT 12
+#define FRAGMENT_SIZE (1 << FRAGMENT_SHIFT)
+
static int oss_audio_fd = -1;
extern int errno;
@@ -46,7 +49,6 @@ static int oss_init(void)
int pspeed=44100;
int pstereo;
int format;
- int fragsize = 0;
int myfrag;
int oss_speed, oss_stereo;
@@ -69,8 +71,7 @@ static int oss_init(void)
// we use 64 fragments with 1024 bytes each
// rearmed: now using 10*4096 for better latency
- fragsize=12;
- myfrag=(10<<16)|fragsize;
+ myfrag = (10<<16) | FRAGMENT_SHIFT;
if(ioctl(oss_audio_fd,SNDCTL_DSP_SETFRAGMENT,&myfrag)==-1)
{
@@ -160,11 +161,18 @@ static void oss_feed(void *buf, int bytes)
if(oss_audio_fd == -1) return;
if(ioctl(oss_audio_fd,SNDCTL_DSP_GETOSPACE,&info)==0)
{
+ // for fast forward
+ if(bytes > info.fragments * FRAGMENT_SIZE)
+ bytes = info.fragments * FRAGMENT_SIZE;
+ if(bytes == 0)
+ return;
+
if(info.fragments==info.fragstotal)
{
memset(sbuf, 0, sizeof(sbuf));
write(oss_audio_fd, sbuf, sizeof(sbuf));
write(oss_audio_fd, sbuf, sizeof(sbuf));
+ write(oss_audio_fd, sbuf, sizeof(sbuf));
}
}