summaryrefslogtreecommitdiffstats
path: root/src/module-oss.c
diff options
context:
space:
mode:
authorLennart Poettering <lennart@poettering.net>2004-07-16 17:51:53 +0000
committerLennart Poettering <lennart@poettering.net>2004-07-16 17:51:53 +0000
commit554b01b6b3a82d201da9a10c54187a66b4804501 (patch)
tree94f967af6bfffbbc1f43aa42bcb0f8b204382d8c /src/module-oss.c
parent74bbf31c37b327be3c52c8043be72b96b8fee8f4 (diff)
make oss sample spec configurable
git-svn-id: file:///home/lennart/svn/public/pulseaudio/trunk@77 fefdeb5f-60dc-0310-8127-8f9354f1896f
Diffstat (limited to 'src/module-oss.c')
-rw-r--r--src/module-oss.c27
1 files changed, 21 insertions, 6 deletions
diff --git a/src/module-oss.c b/src/module-oss.c
index 48d10486..324bab3b 100644
--- a/src/module-oss.c
+++ b/src/module-oss.c
@@ -38,6 +38,11 @@ static const char* const valid_modargs[] = {
"device",
"record",
"playback",
+ "fragments",
+ "fragment_size",
+ "format",
+ "rate",
+ "channels",
NULL
};
@@ -131,7 +136,7 @@ int pa_module_init(struct pa_core *c, struct pa_module*m) {
struct userdata *u = NULL;
const char *p;
int fd = -1;
- int frag_size, in_frag_size, out_frag_size;
+ int nfrags, frag_size, in_frag_size, out_frag_size;
int mode;
uint32_t record = 1, playback = 1;
struct pa_sample_spec ss;
@@ -154,16 +159,26 @@ int pa_module_init(struct pa_core *c, struct pa_module*m) {
goto fail;
}
+ nfrags = 12;
+ frag_size = 1024;
+ if (pa_modargs_get_value_u32(ma, "fragments", &nfrags) < 0 || nfrags < 2 || pa_modargs_get_value_u32(ma, "fragment_size", &frag_size) < 0 || frag_size < 1) {
+ fprintf(stderr, __FILE__": failed to parse fragments arguments\n");
+ goto fail;
+ }
+
+ ss = c->default_sample_spec;
+ if (pa_modargs_get_sample_spec(ma, &ss) < 0) {
+ fprintf(stderr, __FILE__": failed to parse sample specification\n");
+ goto fail;
+ }
+
if ((fd = pa_oss_open(p = pa_modargs_get_value(ma, "device", DEFAULT_DEVICE), &mode, NULL)) < 0)
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) 12 << 16) | 10; /* nfrags = 12; frag_size = 2^10 */
- if (ioctl(fd, SNDCTL_DSP_SETFRAGMENT, &frag_size) < 0) {
- fprintf(stderr, "SNDCTL_DSP_SETFRAGMENT: %s\n", strerror(errno));
+
+ if (pa_oss_set_fragments(fd, nfrags, frag_size) < 0)
goto fail;
- }
if (pa_oss_auto_format(fd, &ss) < 0)
goto fail;