[polypaudio-commits] r855 - in /trunk/src/modules: module-alsa-sink.c module-alsa-source.c module-oss.c

svnmailer-noreply at 0pointer.de svnmailer-noreply at 0pointer.de
Sat May 13 14:20:35 PDT 2006


Author: lennart
Date: Sat May 13 23:20:34 2006
New Revision: 855

URL: http://0pointer.de/cgi-bin/viewcvs.cgi?rev=855&root=polypaudio&view=rev
Log:
* set default fragment metrics depending on the sample specs of the device in OSS and ALSA
* fix fragment size calculation in module-alsa-sink

Modified:
    trunk/src/modules/module-alsa-sink.c
    trunk/src/modules/module-alsa-source.c
    trunk/src/modules/module-oss.c

Modified: trunk/src/modules/module-alsa-sink.c
URL: http://0pointer.de/cgi-bin/viewcvs.cgi/trunk/src/modules/module-alsa-sink.c?rev=855&root=polypaudio&r1=854&r2=855&view=diff
==============================================================================
--- trunk/src/modules/module-alsa-sink.c (original)
+++ trunk/src/modules/module-alsa-sink.c Sat May 13 23:20:34 2006
@@ -342,13 +342,17 @@
 
     frame_size = pa_frame_size(&ss);
     
+    /* Fix latency to 100ms */
     periods = 8;
-    fragsize = 1024;
+    fragsize = pa_bytes_per_second(&ss)/128;
+
+    pa_log("req: %i %i", periods, fragsize);
+
     if (pa_modargs_get_value_u32(ma, "fragments", &periods) < 0 || pa_modargs_get_value_u32(ma, "fragment_size", &fragsize) < 0) {
         pa_log(__FILE__": failed to parse buffer metrics");
         goto fail;
     }
-    period_size = fragsize;
+    period_size = fragsize/frame_size;
     
     u = pa_xmalloc0(sizeof(struct userdata));
     m->userdata = u;
@@ -431,7 +435,7 @@
     }
     
     u->frame_size = frame_size;
-    u->fragment_size = period_size;
+    u->fragment_size = period_size * frame_size;
 
     pa_log_info(__FILE__": using %u fragments of size %lu bytes.", periods, (long unsigned)u->fragment_size);
 

Modified: trunk/src/modules/module-alsa-source.c
URL: http://0pointer.de/cgi-bin/viewcvs.cgi/trunk/src/modules/module-alsa-source.c?rev=855&root=polypaudio&r1=854&r2=855&view=diff
==============================================================================
--- trunk/src/modules/module-alsa-source.c (original)
+++ trunk/src/modules/module-alsa-source.c Sat May 13 23:20:34 2006
@@ -333,9 +333,11 @@
     }
 
     frame_size = pa_frame_size(&ss);
-    
+
+    /* Fix latency to 100ms */
     periods = 12;
-    fragsize = frame_size*1024;
+    fragsize = pa_bytes_per_second(&ss)/128;
+    
     if (pa_modargs_get_value_u32(ma, "fragments", &periods) < 0 || pa_modargs_get_value_u32(ma, "fragment_size", &fragsize) < 0) {
         pa_log(__FILE__": failed to parse buffer metrics");
         goto fail;
@@ -425,7 +427,7 @@
     u->frame_size = frame_size;
     u->fragment_size = period_size * frame_size;
 
-    pa_log(__FILE__": using %u fragments of size %lu bytes.", periods, (long unsigned) u->fragment_size);
+    pa_log_info(__FILE__": using %u fragments of size %lu bytes.", periods, (long unsigned) u->fragment_size);
 
     u->memchunk.memblock = NULL;
     u->memchunk.index = u->memchunk.length = 0;

Modified: trunk/src/modules/module-oss.c
URL: http://0pointer.de/cgi-bin/viewcvs.cgi/trunk/src/modules/module-oss.c?rev=855&root=polypaudio&r1=854&r2=855&view=diff
==============================================================================
--- trunk/src/modules/module-oss.c (original)
+++ trunk/src/modules/module-oss.c Sat May 13 23:20:34 2006
@@ -97,8 +97,6 @@
 #define DEFAULT_SINK_NAME "oss_output"
 #define DEFAULT_SOURCE_NAME "oss_input"
 #define DEFAULT_DEVICE "/dev/dsp"
-#define DEFAULT_NFRAGS 12
-#define DEFAULT_FRAGSIZE 1024
 
 static void update_usage(struct userdata *u) {
    pa_module_set_used(u->module,
@@ -348,19 +346,21 @@
 
     mode = (playback&&record) ? O_RDWR : (playback ? O_WRONLY : (record ? O_RDONLY : 0));
 
-    nfrags = DEFAULT_NFRAGS;
-    frag_size = DEFAULT_FRAGSIZE;
-    if (pa_modargs_get_value_s32(ma, "fragments", &nfrags) < 0 || pa_modargs_get_value_s32(ma, "fragment_size", &frag_size) < 0) {
-        pa_log(__FILE__": failed to parse fragments arguments");
-        goto fail;
-    }
-
     ss = c->default_sample_spec;
     if (pa_modargs_get_sample_spec_and_channel_map(ma, &ss, &map) < 0) {
         pa_log(__FILE__": failed to parse sample specification or channel map");
         goto fail;
     }
     
+    /* Fix latency to 100ms */
+    nfrags = 12;
+    frag_size = pa_bytes_per_second(&ss)/128;
+    
+    if (pa_modargs_get_value_s32(ma, "fragments", &nfrags) < 0 || pa_modargs_get_value_s32(ma, "fragment_size", &frag_size) < 0) {
+        pa_log(__FILE__": failed to parse fragments arguments");
+        goto fail;
+    }
+
     if ((fd = pa_oss_open(p = pa_modargs_get_value(ma, "device", DEFAULT_DEVICE), &mode, NULL)) < 0)
         goto fail;
 




More information about the pulseaudio-commits mailing list