summaryrefslogtreecommitdiffstats
path: root/src/module-oss.c
diff options
context:
space:
mode:
authorLennart Poettering <lennart@poettering.net>2004-06-15 15:18:33 +0000
committerLennart Poettering <lennart@poettering.net>2004-06-15 15:18:33 +0000
commit78f386ad45dc046d673fca5441dff188a7297059 (patch)
tree9ffa89fb46457318184e0531bb0e68d3817ceb4d /src/module-oss.c
parent98f41f1e70e66dcfc4c457ae47bffb07ed83947f (diff)
more work
git-svn-id: file:///home/lennart/svn/public/pulseaudio/trunk@17 fefdeb5f-60dc-0310-8127-8f9354f1896f
Diffstat (limited to 'src/module-oss.c')
-rw-r--r--src/module-oss.c26
1 files changed, 15 insertions, 11 deletions
diff --git a/src/module-oss.c b/src/module-oss.c
index 7a1482e7..07a407d8 100644
--- a/src/module-oss.c
+++ b/src/module-oss.c
@@ -31,7 +31,7 @@ static void do_write(struct userdata *u) {
ssize_t r;
assert(u);
- if (!iochannel_is_writable(u->io))
+ if (!u->sink || !iochannel_is_writable(u->io))
return;
if (!u->memchunk.length) {
@@ -66,7 +66,7 @@ static void do_read(struct userdata *u) {
ssize_t r;
assert(u);
- if (!iochannel_is_readable(u->io))
+ if (!u->source || !iochannel_is_readable(u->io))
return;
memchunk.memblock = memblock_new(u->in_fragment_size);
@@ -103,7 +103,7 @@ int module_init(struct core *c, struct module*m) {
assert(c && m);
p = m->argument ? m->argument : "/dev/dsp";
- if ((fd = open(p, mode = O_RDWR)) >= 0) {
+ if ((fd = open(p, (mode = O_RDWR)|O_NDELAY)) >= 0) {
int caps;
ioctl(fd, SNDCTL_DSP_SETDUPLEX, 0);
@@ -120,15 +120,17 @@ int module_init(struct core *c, struct module*m) {
}
if (fd < 0) {
- if ((fd = open(p, mode = O_WRONLY)) < 0) {
- if ((fd = open(p, mode = O_RDONLY)) < 0) {
+ if ((fd = open(p, (mode = O_WRONLY)|O_NDELAY)) < 0) {
+ if ((fd = open(p, (mode = O_RDONLY)|O_NDELAY)) < 0) {
fprintf(stderr, "open('%s'): %s\n", p, strerror(errno));
goto fail;
}
}
}
+
+ fprintf(stderr, "module-oss: device opened in %s mode.\n", mode == O_WRONLY ? "O_WRONLY" : (mode == O_RDONLY ? "O_RDONLY" : "O_RDWR"));
- frag_size = ((int) 0x7ffff << 4) | 10; /* nfrags = 4; frag_size = 2^10 */
+ frag_size = ((int) 4 << 16) | 10; /* nfrags = 4; frag_size = 2^10 */
if (ioctl(fd, SNDCTL_DSP_SETFRAGMENT, &frag_size) < 0) {
fprintf(stderr, "SNDCTL_DSP_SETFRAGMENT: %s\n", strerror(errno));
goto fail;
@@ -174,12 +176,12 @@ int module_init(struct core *c, struct module*m) {
in_frag_size = out_frag_size = frag_size;
if (ioctl(fd, SNDCTL_DSP_GETISPACE, &info) >= 0) {
- fprintf(stderr, "INPUT: %u fragments of size %u.\n", info.fragstotal, info.fragsize);
+ fprintf(stderr, "module-oss: input -- %u fragments of size %u.\n", info.fragstotal, info.fragsize);
in_frag_size = info.fragsize;
}
if (ioctl(fd, SNDCTL_DSP_GETOSPACE, &info) >= 0) {
- fprintf(stderr, "OUTUT: %u fragments of size %u.\n", info.fragstotal, info.fragsize);
+ fprintf(stderr, "module-oss: output -- %u fragments of size %u.\n", info.fragstotal, info.fragsize);
out_frag_size = info.fragsize;
}
@@ -239,9 +241,11 @@ void module_done(struct core *c, struct module*m) {
memblock_unref(u->memchunk.memblock);
if (u->silence.memblock)
memblock_unref(u->silence.memblock);
-
- sink_free(u->sink);
- source_free(u->source);
+
+ if (u->sink)
+ sink_free(u->sink);
+ if (u->source)
+ source_free(u->source);
iochannel_free(u->io);
free(u);
}