[pulseaudio-commits] r1639 - /branches/lennart/src/modules/module-oss.c
svnmailer-noreply at 0pointer.de
svnmailer-noreply at 0pointer.de
Sat Aug 11 10:09:08 PDT 2007
Author: lennart
Date: Sat Aug 11 19:09:07 2007
New Revision: 1639
URL: http://0pointer.de/cgi-bin/viewcvs.cgi?rev=3D1639&root=3Dpulseaudio&vi=
ew=3Drev
Log:
port oss driver to make use of the default fragment sizes as defined in pa_=
core: store in the sink/source description whether mmap is used; if mmap() =
fails, fall back to UNIX read/write mode instead of bailing out immediately
Modified:
branches/lennart/src/modules/module-oss.c
Modified: branches/lennart/src/modules/module-oss.c
URL: http://0pointer.de/cgi-bin/viewcvs.cgi/branches/lennart/src/modules/mo=
dule-oss.c?rev=3D1639&root=3Dpulseaudio&r1=3D1638&r2=3D1639&view=3Ddiff
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D
--- branches/lennart/src/modules/module-oss.c (original)
+++ branches/lennart/src/modules/module-oss.c Sat Aug 11 19:09:07 2007
@@ -102,9 +102,6 @@
"mmap=3D<enable memory mapping?>")
=
#define DEFAULT_DEVICE "/dev/dsp"
-
-#define DEFAULT_NFRAGS 4
-#define DEFAULT_FRAGSIZE_MSEC 25
=
struct userdata {
pa_core *core;
@@ -1103,8 +1100,8 @@
goto fail;
}
=
- nfrags =3D DEFAULT_NFRAGS;
- frag_size =3D pa_usec_to_bytes(DEFAULT_FRAGSIZE_MSEC*1000, &ss);
+ nfrags =3D m->core->default_n_fragments;
+ frag_size =3D pa_usec_to_bytes(m->core->default_fragment_size_msec*100=
0, &ss);
if (frag_size <=3D 0)
frag_size =3D pa_frame_size(&ss);
=
@@ -1127,7 +1124,7 @@
}
=
if (use_mmap && mode =3D=3D O_WRONLY) {
- pa_log_info("Device opened for write only, cannot do memory mappin=
g, falling back to UNIX read/write mode.");
+ pa_log_info("Device opened for playback only, cannot do memory map=
ping, falling back to UNIX write() mode.");
use_mmap =3D 0;
}
=
@@ -1188,17 +1185,11 @@
=
if (use_mmap) {
if ((u->in_mmap =3D mmap(NULL, u->in_hwbuf_size, PROT_READ, MA=
P_SHARED, fd, 0)) =3D=3D MAP_FAILED) {
- if (mode =3D=3D O_RDWR) {
- pa_log_debug("mmap() failed for input. Changing to O_W=
RONLY mode.");
- mode =3D O_WRONLY;
- goto try_write;
- } else {
- pa_log("mmap(): %s", pa_cstrerror(errno));
- goto fail;
- }
- }
-
- pa_log_debug("Successfully mmap()ed input buffer.");
+ pa_log_warn("mmap(PROT_READ) failed, reverting to non-mmap=
mode: %s", pa_cstrerror(errno));
+ use_mmap =3D u->use_mmap =3D 0;
+ u->in_mmap =3D NULL;
+ } else
+ pa_log_debug("Successfully mmap()ed input buffer.");
}
=
if ((name =3D pa_modargs_get_value(ma, "source_name", NULL)))
@@ -1221,11 +1212,12 @@
pa_source_set_module(u->source, m);
pa_source_set_asyncmsgq(u->source, u->thread_mq.inq);
pa_source_set_description(u->source, t =3D pa_sprintf_malloc(
- "OSS PCM on %s%s%s%s",
+ "OSS PCM on %s%s%s%s%s",
dev,
hwdesc[0] ? " (" : "",
hwdesc[0] ? hwdesc : "",
- hwdesc[0] ? ")" : ""));
+ hwdesc[0] ? ")" : "",
+ use_mmap ? " via DMA" : ""));
pa_xfree(t);
u->source->is_hardware =3D 1;
u->source->refresh_volume =3D 1;
@@ -1234,8 +1226,6 @@
u->in_mmap_memblocks =3D pa_xnew0(pa_memblock*, u->in_nfrags);
}
=
-try_write:
- =
if (mode !=3D O_RDONLY) {
char *name_buf =3D NULL;
=
@@ -1246,13 +1236,14 @@
mode =3D O_WRONLY;
goto go_on;
} else {
- pa_log("mmap(): %s", pa_cstrerror(errno));
- goto fail;
+ pa_log_warn("mmap(PROT_WRITE) failed, reverting to non=
-mmap mode: %s", pa_cstrerror(errno));
+ u->use_mmap =3D use_mmap =3D 0;
+ u->out_mmap =3D NULL;
}
- }
-
- pa_log_debug("Successfully mmap()ed output buffer.");
- pa_silence_memory(u->out_mmap, u->out_hwbuf_size, &ss);
+ } else {
+ pa_log_debug("Successfully mmap()ed output buffer.");
+ pa_silence_memory(u->out_mmap, u->out_hwbuf_size, &ss);
+ }
}
=
if ((name =3D pa_modargs_get_value(ma, "sink_name", NULL)))
@@ -1275,11 +1266,12 @@
pa_sink_set_module(u->sink, m);
pa_sink_set_asyncmsgq(u->sink, u->thread_mq.inq);
pa_sink_set_description(u->sink, t =3D pa_sprintf_malloc(
- "OSS PCM on %s%s%s%s",
+ "OSS PCM on %s%s%s%s%s",
dev,
hwdesc[0] ? " (" : "",
hwdesc[0] ? hwdesc : "",
- hwdesc[0] ? ")" : ""));
+ hwdesc[0] ? ")" : "",
+ use_mmap ? " via DMA" : ""));
pa_xfree(t);
u->sink->is_hardware =3D 1;
u->sink->refresh_volume =3D 1;
More information about the pulseaudio-commits
mailing list