summaryrefslogtreecommitdiff
path: root/plugins/oss
diff options
context:
space:
mode:
authorGravatar Alexey Yakovenko <wakeroid@gmail.com>2010-01-20 21:48:03 +0100
committerGravatar Alexey Yakovenko <wakeroid@gmail.com>2010-01-20 21:48:03 +0100
commit4872a51d33d9b449f8270a97aa3497e28cd0b3eb (patch)
treef22fc2fb1c3e0741ef401d569afe2f1277cb822d /plugins/oss
parent56650db1e4d6f39d11167c308b23e70507b05a5c (diff)
oss plugin updates (supports both v3 and v4 now)
Diffstat (limited to 'plugins/oss')
-rw-r--r--plugins/oss/Makefile.am2
-rw-r--r--plugins/oss/oss.c36
2 files changed, 31 insertions, 7 deletions
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 <http://www.gnu.org/licenses/>.
*/
+#ifdef HAVE_CONFIG_H
+# include "../../config.h"
+#endif
#include <stdint.h>
#include <unistd.h>
#ifdef __linux__
@@ -22,16 +25,16 @@
#endif
#include <stdio.h>
#include <string.h>
+#if HAVE_SYS_SOUNDCARD_H
#include <sys/soundcard.h>
+#else
+#include <soundcard.h>
+#endif
#include <fcntl.h>
#include <sys/ioctl.h>
#include <stdlib.h>
#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);