[PD-dev] [ pure-data-Bugs-2978457 ] -nogui audio initialization problems under Debian

SourceForge.net noreply at sourceforge.net
Tue May 18 01:00:38 CEST 2010


Bugs item #2978457, was opened at 2010-03-29 10:01
Message generated for change (Comment added) made by nobody
You can respond by visiting: 
https://sourceforge.net/tracker/?func=detail&atid=478070&aid=2978457&group_id=55736

Please note that this message will contain a full copy of the comment thread,
including the initial issue submission, for this request,
not just the latest update.
Category: puredata
Group: None
Status: Open
Resolution: None
Priority: 5
Private: No
Submitted By: Nobody/Anonymous (nobody)
Assigned to: Nobody/Anonymous (nobody)
Summary: -nogui audio initialization problems under Debian

Initial Comment:
The [delread~] in the attached patch fails to initialize to the correct samplerate when started with -nogui under Debian and Pd 0.41.4 or 0.42-5. It seems to initialize to a samplerate of 0 instead. This problem persists independently from the audio driver used (ALS vs OSS). The patch works fine under Windows XP, however.

The patch contains a workaround which has been suggested on the Pd-list, i.e. to loadbang a [switch~] object to 0 and then set it to 1 when neded. However, this did not help in the current situation.

The patch also delays the loadbanged [;pd dsp 1( message by a [del 1000. This is a workaround addressing another manifestation of the audio initialisation problems with -nogui under Debian. If the [del 1000] is removed, the patch fails to load under -nogui with a "dev/dsp (read/write): Device or resource busy" message.

IOhannes has suggested on the list to set the samplerate explicitely at startup, i.e. by
  pd -nogui -r 44100
However, I cannot confirm this workaround to work with the attached patch.

Please note that the attached patch works fine under Windows XP and with -nogui enabled; also if the [del 1000] and [switch~] objects are omitted.

best,
flo.H

----------------------------------------------------------------------

Comment By: Nobody/Anonymous (nobody)
Date: 2010-05-17 23:00

Message:
move sigdelwrite_updatesr(delwriter, sp[0]->s_sr); inside if (delwriter) or
else you will get crashes due to null-pointer error.


----------------------------------------------------------------------

Comment By: Nobody/Anonymous (nobody)
Date: 2010-05-16 21:56

Message:
--- d_delay.c	(révision 13558)
+++ d_delay.c	(copie de travail)
@@ -24,6 +24,7 @@
 {
     t_object x_obj;
     t_symbol *x_sym;
+    t_float x_deltime;  /* delay in msec */
     t_delwritectl x_cspace;
     int x_sortno;   /* DSP sort number at which this was last put on
chain */
     int x_rsortno;  /* DSP sort # for first delread or write in chain */
@@ -34,6 +35,21 @@
 #define XTRASAMPS 4
 #define SAMPBLK 4
 
+static void sigdelwrite_updatesr (t_sigdelwrite *x, t_float sr)
+{
+    int nsamps = x->x_deltime * sr * (t_float)(0.001f);
+    if (nsamps < 1) nsamps = 1;
+    nsamps += ((- nsamps) & (SAMPBLK - 1));
+    nsamps += DEFDELVS;
+    if (x->x_cspace.c_n != nsamps) {
+      x->x_cspace.c_vec = (t_sample *)resizebytes(x->x_cspace.c_vec,
+        (x->x_cspace.c_n + XTRASAMPS) * sizeof(t_sample),
+        (         nsamps + XTRASAMPS) * sizeof(t_sample));
+      x->x_cspace.c_n = nsamps;
+      x->x_cspace.c_phase = XTRASAMPS;
+    }
+}
+
     /* routine to check that all delwrites/delreads/vds have same vecsize
*/
 static void sigdelwrite_checkvecsize(t_sigdelwrite *x, int vecsize)
 {
@@ -54,19 +70,13 @@
 
 static void *sigdelwrite_new(t_symbol *s, t_floatarg msec)
 {
-    int nsamps;
     t_sigdelwrite *x = (t_sigdelwrite *)pd_new(sigdelwrite_class);
     if (!*s->s_name) s = gensym("delwrite~");
     pd_bind(&x->x_obj.ob_pd, s);
     x->x_sym = s;
-    nsamps = msec * sys_getsr() * (t_float)(0.001f);
-    if (nsamps < 1) nsamps = 1;
-    nsamps += ((- nsamps) & (SAMPBLK - 1));
-    nsamps += DEFDELVS;
-    x->x_cspace.c_n = nsamps;
-    x->x_cspace.c_vec =
-        (t_sample *)getbytes((nsamps + XTRASAMPS) * sizeof(t_sample));
-    x->x_cspace.c_phase = XTRASAMPS;
+    x->x_deltime = msec;
+    x->x_cspace.c_n = 0;
+    x->x_cspace.c_vec = getbytes(XTRASAMPS * sizeof(t_sample));
     x->x_sortno = 0;
     x->x_vecsize = 0;
     x->x_f = 0;
@@ -109,6 +119,7 @@
     dsp_add(sigdelwrite_perform, 3, sp[0]->s_vec, &x->x_cspace,
sp[0]->s_n);
     x->x_sortno = ugen_getsortno();
     sigdelwrite_checkvecsize(x, sp[0]->s_n);
+    sigdelwrite_updatesr(x, sp[0]->s_sr);
 }
 
 static void sigdelwrite_free(t_sigdelwrite *x)
@@ -180,6 +191,7 @@
     int delsamps = *(int *)(w[3]);
     int n = (int)(w[4]);
     int phase = c->c_phase - delsamps, nsamps = c->c_n;
+
     t_sample *vp = c->c_vec, *bp, *ep = vp + (c->c_n + XTRASAMPS);
     if (phase < 0) phase += nsamps;
     bp = vp + phase;
@@ -197,6 +209,7 @@
     t_sigdelwrite *delwriter =
         (t_sigdelwrite *)pd_findbyclass(x->x_sym, sigdelwrite_class);
     x->x_sr = sp[0]->s_sr * 0.001;
+    sigdelwrite_updatesr(delwriter, sp[0]->s_sr);
     x->x_n = sp[0]->s_n;
     if (delwriter)
     {
@@ -206,8 +219,7 @@
         sigdelread_float(x, x->x_deltime);
         dsp_add(sigdelread_perform, 4,
             sp[0]->s_vec, &delwriter->x_cspace, &x->x_delsamps,
sp[0]->s_n);
-    }
-    else if (*x->x_sym->s_name)
+    } else if (*x->x_sym->s_name)
         error("delread~: %s: no such delwrite~",x->x_sym->s_name);
 }


----------------------------------------------------------------------

Comment By: Nobody/Anonymous (nobody)
Date: 2010-05-16 18:03

Message:
the bug is actually deeper than that, as delread does a bunch of "Invalid
read of size 4" according to valgrind, after this fix.

----------------------------------------------------------------------

Comment By: Nobody/Anonymous (nobody)
Date: 2010-05-16 17:48

Message:
the previous fix is leaking memory.

----------------------------------------------------------------------

Comment By: Nobody/Anonymous (nobody)
Date: 2010-05-16 17:45

Message:
--- d_delay.c	(révision 13539)
+++ d_delay.c	(copie de travail)
@@ -24,6 +24,7 @@
 {
     t_object x_obj;
     t_symbol *x_sym;
+    t_float x_deltime;  /* delay in msec */
     t_delwritectl x_cspace;
     int x_sortno;   /* DSP sort number at which this was last put on
chain */
     int x_rsortno;  /* DSP sort # for first delread or write in chain */
@@ -54,19 +55,13 @@
 
 static void *sigdelwrite_new(t_symbol *s, t_floatarg msec)
 {
-    int nsamps;
     t_sigdelwrite *x = (t_sigdelwrite *)pd_new(sigdelwrite_class);
     if (!*s->s_name) s = gensym("delwrite~");
     pd_bind(&x->x_obj.ob_pd, s);
     x->x_sym = s;
-    nsamps = msec * sys_getsr() * (t_float)(0.001f);
-    if (nsamps < 1) nsamps = 1;
-    nsamps += ((- nsamps) & (SAMPBLK - 1));
-    nsamps += DEFDELVS;
-    x->x_cspace.c_n = nsamps;
-    x->x_cspace.c_vec =
-        (t_sample *)getbytes((nsamps + XTRASAMPS) * sizeof(t_sample));
-    x->x_cspace.c_phase = XTRASAMPS;
+    x->x_deltime = msec;
+    x->x_cspace.c_n = 0;
+    x->x_cspace.c_vec = 0;
     x->x_sortno = 0;
     x->x_vecsize = 0;
     x->x_f = 0;
@@ -106,6 +101,18 @@
 
 static void sigdelwrite_dsp(t_sigdelwrite *x, t_signal **sp)
 {
+    int nsamps = x->x_deltime * sp[0]->s_sr * (t_float)(0.001f);
+    post("sigdelwrite_dsp: %f ms, with sr=%f",x->x_deltime,sys_getsr());
+    if (nsamps < 1) nsamps = 1;
+    nsamps += ((- nsamps) & (SAMPBLK - 1));
+    nsamps += DEFDELVS;
+    if (x->x_cspace.c_n != nsamps) {
+      x->x_cspace.c_n = nsamps;
+      x->x_cspace.c_vec =
+          (t_sample *)getbytes((nsamps + XTRASAMPS) * sizeof(t_sample));
+      x->x_cspace.c_phase = XTRASAMPS;
+    }
+
     dsp_add(sigdelwrite_perform, 3, sp[0]->s_vec, &x->x_cspace,
sp[0]->s_n);
     x->x_sortno = ugen_getsortno();
     sigdelwrite_checkvecsize(x, sp[0]->s_n);


----------------------------------------------------------------------

Comment By: Nobody/Anonymous (nobody)
Date: 2010-05-16 17:40

Message:
this also goes with another bug : [delwrite~] doesn't honour the sampling
rate set by [block~]

----------------------------------------------------------------------

Comment By: Nobody/Anonymous (nobody)
Date: 2010-05-16 17:20

Message:
this goes with another bug : [delwrite~] doesn't honour any change of
sampling rate (e.g. 44100 to 22050).

those bugs are related because the reason [delwrite~] doesn't work with
this, is that [delwrite~] is created while sys_getsr() still reports
sampling rate to be "0", because sys_dacsr has not been assigned to.

----------------------------------------------------------------------

Comment By: Nobody/Anonymous (nobody)
Date: 2010-05-16 17:00

Message:
if you load your patch using a «; pd open $1 .» message from a [delay]ed
[loadbang], the patch runs correctly.

----------------------------------------------------------------------

Comment By: Nobody/Anonymous (nobody)
Date: 2010-05-16 16:53

Message:
you can replace the [delay 1000] by just [delay], that is, [delay 0].


----------------------------------------------------------------------

You can respond by visiting: 
https://sourceforge.net/tracker/?func=detail&atid=478070&aid=2978457&group_id=55736




More information about the Pd-dev mailing list