summaryrefslogtreecommitdiffstats
path: root/src/modules/module-oss-mmap.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/modules/module-oss-mmap.c')
-rw-r--r--src/modules/module-oss-mmap.c86
1 files changed, 43 insertions, 43 deletions
diff --git a/src/modules/module-oss-mmap.c b/src/modules/module-oss-mmap.c
index 5ab08287..7bf6cbbd 100644
--- a/src/modules/module-oss-mmap.c
+++ b/src/modules/module-oss-mmap.c
@@ -2,17 +2,17 @@
/***
This file is part of PulseAudio.
-
+
PulseAudio is free software; you can redistribute it and/or modify
it under the terms of the GNU Lesser General Public License as published
by the Free Software Foundation; either version 2 of the License,
or (at your option) any later version.
-
+
PulseAudio is distributed in the hope that it will be useful, but
WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
General Public License for more details.
-
+
You should have received a copy of the GNU Lesser General Public License
along with PulseAudio; if not, write to the Free Software
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
@@ -113,7 +113,7 @@ static const char* const valid_modargs[] = {
#define DEFAULT_FRAGSIZE 1024
static void update_usage(struct userdata *u) {
- pa_module_set_used(u->module,
+ pa_module_set_used(u->module,
(u->sink ? pa_sink_used_by(u->sink) : 0) +
(u->source ? pa_source_used_by(u->source) : 0));
}
@@ -126,7 +126,7 @@ static void clear_up(struct userdata *u) {
pa_sink_unref(u->sink);
u->sink = NULL;
}
-
+
if (u->source) {
pa_source_disconnect(u->source);
pa_source_unref(u->source);
@@ -137,12 +137,12 @@ static void clear_up(struct userdata *u) {
munmap(u->in_mmap, u->in_mmap_length);
u->in_mmap = NULL;
}
-
+
if (u->out_mmap && u->out_mmap != MAP_FAILED) {
munmap(u->out_mmap, u->out_mmap_length);
u->out_mmap = NULL;
}
-
+
if (u->io_event) {
u->core->mainloop->io_free(u->io_event);
u->io_event = NULL;
@@ -156,13 +156,13 @@ static void clear_up(struct userdata *u) {
static void out_fill_memblocks(struct userdata *u, unsigned n) {
assert(u && u->out_memblocks);
-
+
while (n > 0) {
pa_memchunk chunk;
-
+
if (u->out_memblocks[u->out_current])
pa_memblock_unref_fixed(u->out_memblocks[u->out_current]);
-
+
chunk.memblock = u->out_memblocks[u->out_current] =
pa_memblock_new_fixed(
u->core->mempool,
@@ -172,13 +172,13 @@ static void out_fill_memblocks(struct userdata *u, unsigned n) {
assert(chunk.memblock);
chunk.length = chunk.memblock->length;
chunk.index = 0;
-
+
pa_sink_render_into_full(u->sink, &chunk);
-
+
u->out_current++;
while (u->out_current >= u->out_fragments)
u->out_current -= u->out_fragments;
-
+
n--;
}
}
@@ -188,7 +188,7 @@ static void do_write(struct userdata *u) {
assert(u && u->sink);
update_usage(u);
-
+
if (ioctl(u->fd, SNDCTL_DSP_GETOPTR, &info) < 0) {
pa_log("SNDCTL_DSP_GETOPTR: %s", pa_cstrerror(errno));
@@ -199,31 +199,31 @@ static void do_write(struct userdata *u) {
info.blocks += u->out_blocks_saved;
u->out_blocks_saved = 0;
-
+
if (!info.blocks)
return;
-
+
out_fill_memblocks(u, info.blocks);
}
static void in_post_memblocks(struct userdata *u, unsigned n) {
assert(u && u->in_memblocks);
-
+
while (n > 0) {
pa_memchunk chunk;
-
+
if (!u->in_memblocks[u->in_current]) {
chunk.memblock = u->in_memblocks[u->in_current] = pa_memblock_new_fixed(u->core->mempool, (uint8_t*) u->in_mmap+u->in_fragment_size*u->in_current, u->in_fragment_size, 1);
chunk.length = chunk.memblock->length;
chunk.index = 0;
-
+
pa_source_post(u->source, &chunk);
}
u->in_current++;
while (u->in_current >= u->in_fragments)
u->in_current -= u->in_fragments;
-
+
n--;
}
}
@@ -234,7 +234,7 @@ static void in_clear_memblocks(struct userdata*u, unsigned n) {
if (n > u->in_fragments)
n = u->in_fragments;
-
+
while (n > 0) {
if (u->in_memblocks[i]) {
pa_memblock_unref_fixed(u->in_memblocks[i]);
@@ -254,7 +254,7 @@ static void do_read(struct userdata *u) {
assert(u && u->source);
update_usage(u);
-
+
if (ioctl(u->fd, SNDCTL_DSP_GETIPTR, &info) < 0) {
pa_log("SNDCTL_DSP_GETIPTR: %s", pa_cstrerror(errno));
@@ -265,10 +265,10 @@ static void do_read(struct userdata *u) {
info.blocks += u->in_blocks_saved;
u->in_blocks_saved = 0;
-
+
if (!info.blocks)
return;
-
+
in_post_memblocks(u, info.blocks);
in_clear_memblocks(u, u->in_fragments/2);
}
@@ -311,7 +311,7 @@ static pa_usec_t sink_get_latency_cb(pa_sink *s) {
n = bpos - info.ptr;
/* pa_log("n = %u, bpos = %u, ptr = %u, total=%u, fragsize = %u, n_frags = %u\n", n, bpos, (unsigned) info.ptr, total, u->out_fragment_size, u->out_fragments); */
-
+
return pa_bytes_to_usec(n, &s->sample_spec);
}
@@ -337,7 +337,7 @@ static pa_usec_t source_get_latency_cb(pa_source *s) {
n = (u->in_fragments * u->in_fragment_size) - bpos + info.ptr;
/* pa_log("n = %u, bpos = %u, ptr = %u, total=%u, fragsize = %u, n_frags = %u\n", n, bpos, (unsigned) info.ptr, total, u->in_fragment_size, u->in_fragments); */
-
+
return pa_bytes_to_usec(n, &s->sample_spec);
}
@@ -416,7 +416,7 @@ int pa__init(pa_core *c, pa_module*m) {
pa_log("failed to parse module arguments.");
goto fail;
}
-
+
if (pa_modargs_get_value_boolean(ma, "record", &record) < 0 || pa_modargs_get_value_boolean(ma, "playback", &playback) < 0) {
pa_log("record= and playback= expect numeric arguments.");
goto fail;
@@ -460,7 +460,7 @@ int pa__init(pa_core *c, pa_module*m) {
if (nfrags >= 2 && frag_size >= 1)
if (pa_oss_set_fragments(u->fd, nfrags, frag_size) < 0)
goto fail;
-
+
if (pa_oss_auto_format(u->fd, &u->sample_spec) < 0)
goto fail;
@@ -491,7 +491,7 @@ int pa__init(pa_core *c, pa_module*m) {
if (!(u->source = pa_source_new(c, __FILE__, name, namereg_fail, &u->sample_spec, &map)))
goto fail;
-
+
u->source->userdata = u;
u->source->get_latency = source_get_latency_cb;
u->source->get_hw_volume = source_get_hw_volume;
@@ -504,22 +504,22 @@ int pa__init(pa_core *c, pa_module*m) {
hwdesc[0] ? ")" : ""));
pa_xfree(t);
u->source->is_hardware = 1;
-
+
u->in_memblocks = pa_xnew0(pa_memblock*, u->in_fragments);
-
+
enable_bits |= PCM_ENABLE_INPUT;
}
}
pa_xfree(name_buf);
name_buf = NULL;
-
+
if (mode != O_RDONLY) {
if (ioctl(u->fd, SNDCTL_DSP_GETOSPACE, &info) < 0) {
pa_log("SNDCTL_DSP_GETOSPACE: %s", pa_cstrerror(errno));
goto fail;
}
-
+
pa_log_info("output -- %u fragments of size %u.", info.fragstotal, info.fragsize);
u->out_mmap_length = (u->out_fragment_size = info.fragsize) * (u->out_fragments = info.fragstotal);
@@ -540,7 +540,7 @@ int pa__init(pa_core *c, pa_module*m) {
name = name_buf = pa_sprintf_malloc("oss_output.%s", pa_path_get_filename(p));
namereg_fail = 0;
}
-
+
if (!(u->sink = pa_sink_new(c, __FILE__, name, namereg_fail, &u->sample_spec, &map)))
goto fail;
@@ -555,28 +555,28 @@ int pa__init(pa_core *c, pa_module*m) {
hwdesc[0] ? hwdesc : "",
hwdesc[0] ? ")" : ""));
pa_xfree(t);
-
+
u->sink->is_hardware = 1;
u->out_memblocks = pa_xmalloc0(sizeof(struct memblock *)*u->out_fragments);
-
+
enable_bits |= PCM_ENABLE_OUTPUT;
}
}
pa_xfree(name_buf);
name_buf = NULL;
-
+
zero = 0;
if (ioctl(u->fd, SNDCTL_DSP_SETTRIGGER, &zero) < 0) {
pa_log("SNDCTL_DSP_SETTRIGGER: %s", pa_cstrerror(errno));
goto fail;
}
-
+
if (ioctl(u->fd, SNDCTL_DSP_SETTRIGGER, &enable_bits) < 0) {
pa_log("SNDCTL_DSP_SETTRIGGER: %s", pa_cstrerror(errno));
goto fail;
}
-
+
assert(u->source || u->sink);
u->io_event = c->mainloop->io_new(c->mainloop, u->fd, (u->source ? PA_IO_EVENT_INPUT : 0) | (u->sink ? PA_IO_EVENT_OUTPUT : 0), io_callback, u);
@@ -589,7 +589,7 @@ int pa__init(pa_core *c, pa_module*m) {
source_get_hw_volume(u->source);
if (u->sink)
sink_get_hw_volume(u->sink);
-
+
return 0;
fail:
@@ -599,13 +599,13 @@ fail:
pa_modargs_free(ma);
pa_xfree(name_buf);
-
+
return -1;
}
void pa__done(pa_core *c, pa_module*m) {
struct userdata *u;
-
+
assert(c);
assert(m);
@@ -629,6 +629,6 @@ void pa__done(pa_core *c, pa_module*m) {
pa_memblock_unref_fixed(u->in_memblocks[i]);
pa_xfree(u->in_memblocks);
}
-
+
pa_xfree(u);
}