From 4872a51d33d9b449f8270a97aa3497e28cd0b3eb Mon Sep 17 00:00:00 2001 From: Alexey Yakovenko Date: Wed, 20 Jan 2010 21:48:03 +0100 Subject: oss plugin updates (supports both v3 and v4 now) --- plugins/oss/Makefile.am | 2 +- plugins/oss/oss.c | 36 ++++++++++++++++++++++++++++++------ 2 files changed, 31 insertions(+), 7 deletions(-) (limited to 'plugins') diff --git a/plugins/oss/Makefile.am b/plugins/oss/Makefile.am index 810bd249..697f4d32 100644 --- a/plugins/oss/Makefile.am +++ b/plugins/oss/Makefile.am @@ -1,6 +1,6 @@ ossdir = $(libdir)/$(PACKAGE) pkglib_LTLIBRARIES = oss.la -AM_CFLAGS = $(CFLAGS) $(OSS4_CFLAGS) +AM_CFLAGS = $(CFLAGS) $(OSS_CFLAGS) oss_la_SOURCES = oss.c oss_la_LDFLAGS = -module diff --git a/plugins/oss/oss.c b/plugins/oss/oss.c index 193970ad..b8602cf7 100644 --- a/plugins/oss/oss.c +++ b/plugins/oss/oss.c @@ -15,6 +15,9 @@ You should have received a copy of the GNU General Public License along with this program. If not, see . */ +#ifdef HAVE_CONFIG_H +# include "../../config.h" +#endif #include #include #ifdef __linux__ @@ -22,16 +25,16 @@ #endif #include #include +#if HAVE_SYS_SOUNDCARD_H #include +#else +#include +#endif #include #include #include #include "../../deadbeef.h" -//#if OSS_VERSION<0x040000 -//#error oss4 plugin: at least oss v4.0 is required to build this plugin -//#endif - #define trace(...) { fprintf(stderr, __VA_ARGS__); } //#define trace(fmt,...) @@ -44,6 +47,7 @@ static int oss_rate = 44100; static int state; static int fd; static uintptr_t mutex; +static int blksize; static void oss_thread (void *context); @@ -68,6 +72,18 @@ oss_init (void) { return -1; } +#if OSS_VERSION>=0x040000 +/* + int cooked = 1; + ioctl (fd, SNDCTL_DSP_COOKEDMODE, &cooked); + trace ("oss: cooked_mode=%d\n", cooked); + + int policy = 3; + ioctl (fd, SNDCTL_DSP_POLICY, &policy); + trace ("oss: policy=%d\n", policy); +*/ +#endif + int fmt = AFMT_S16_NE; if (ioctl (fd, SNDCTL_DSP_SETFMT, &fmt) == -1) { trace ("oss: failed to set format\n"); @@ -104,6 +120,14 @@ oss_init (void) { trace ("oss: samplerate: %d\n", oss_rate); +// audio_buf_info bi; +// ioctl (fd, SNDCTL_DSP_GETOSPACE, &bi); +// trace ("oss: bi.bytes=%d, bi.fragsize=%d, bi.fragstotal=%d\n", bi.bytes, bi.fragsize, bi.fragstotal); +// blksize = bi.fragsize; + + ioctl (fd, SNDCTL_DSP_GETBLKSIZE, &blksize); + trace ("oss: blksize: %d\n", blksize); + mutex = deadbeef->mutex_create (); oss_tid = deadbeef->thread_start (oss_thread, NULL); @@ -227,8 +251,8 @@ oss_thread (void *context) { continue; } - char buf[1024]; - oss_callback (buf, 1024); + char buf[blksize]; + oss_callback (buf, sizeof (buf)); deadbeef->mutex_lock (mutex); int res = write (fd, buf, sizeof (buf)); deadbeef->mutex_unlock (mutex); -- cgit v1.2.3