diff options
Diffstat (limited to 'plugins/dfsound/oss.c')
-rw-r--r-- | plugins/dfsound/oss.c | 28 |
1 files changed, 15 insertions, 13 deletions
diff --git a/plugins/dfsound/oss.c b/plugins/dfsound/oss.c index 6b1cb4a..67ba4c9 100644 --- a/plugins/dfsound/oss.c +++ b/plugins/dfsound/oss.c @@ -128,25 +128,26 @@ static void oss_finish(void) } //////////////////////////////////////////////////////////////////////// -// GET BUFFERED STATUS +// GET BUFFER AVAILABLE //////////////////////////////////////////////////////////////////////// -static int oss_busy(void) +static float oss_capacity(void) { audio_buf_info info; - unsigned long l; - if(oss_audio_fd == -1) return 1; - if(ioctl(oss_audio_fd,SNDCTL_DSP_GETOSPACE,&info)==-1) - l=0; - else - { - if(info.fragments<(info.fragstotal>>1)) // can we write in at least the half of fragments? - l=1; // -> no? wait - else l=0; // -> else go on - } + if(oss_audio_fd == -1) return 0; + if(ioctl(oss_audio_fd,SNDCTL_DSP_GETOSPACE,&info)==-1) return 0; + if(info.fragstotal == 0) return 0; + return (float)info.fragments / info.fragstotal; +} - return l; +//////////////////////////////////////////////////////////////////////// +// GET BUFFERED STATUS +//////////////////////////////////////////////////////////////////////// + +static int oss_busy(void) +{ + return oss_capacity() < 0.5; } //////////////////////////////////////////////////////////////////////// @@ -186,4 +187,5 @@ void out_register_oss(struct out_driver *drv) drv->finish = oss_finish; drv->busy = oss_busy; drv->feed = oss_feed; + drv->capacity = oss_capacity; } |