View Issue Details

IDProjectCategoryView StatusLast Update
0000009ardourbugspublic2003-10-01 00:50
Reporterrjo Assigned Totaybin  
PriorityhighSeverityminorReproducibilityalways
Status closedResolutionfixed 
Summary0000009: Panning in non-C locale problem on save/restore
DescriptionFrom the Debian BTS:

From: Arno Peters <a.w.peters@ieee.org>
To: Debian Bug Tracking System <submit@bugs.debian.org>
Subject: ardour-gtk: Panning in non-C locale problem on save/restore
Date: Sat, 30 Aug 2003 18:14:42 +0200
Message-Id: <E19t8ND-0000Hg-00@duronbox.nosuchnet>

Package: ardour-gtk
Version: 0.9beta3-2
Severity: normal

(as per maintainer request, I am submitting this formally through the
Debian bug tracking system)

I have discovered a problem with running ardour in a locale that
writes decimals with a comma (such as nl_NL). This is a problem in
the default.ardour file. The specification for panning for example

  (0.5,0.5)

turns into

  (0,5,0,5)

which in turn is read into ardour as four values, giving the following
error message:

[ERROR]: CP: improper pan list in XML node (0,5,0,5)
[ERROR]: incorrect number of pans specified in XML node (4 vs. 2

A proper solution for this problem is to revert back to C locale
during the time the XML files get written out (and probably also when
they are read in).

You can recreate this problem by starting ardour as:

  $ LANG=nl_NL ardour

Start a new session and then create a track with two outputs, try
setting the panning on that track full left, and save this session.
Then try to open the session again. You will see the error message
and the panning information on the track will have been ignored (set
to center again).
Additional Informationhttp://bugs.debian.org/cgi-bin/bugreport.cgi?bug=207896
TagsNo tags attached.

Activities

taybin

2003-09-16 03:51

administrator   ~0000005

I put a change in CVS that might fix this. Could someone test it please? It'll require saving a new session file and trying to open that one. Older session files will need to be modified.

rjo

2003-09-21 09:19

reporter   ~0000009

Still occurs with
Ardour/GTK 0.381.2 running with libardour 0.688.2

Debian snapshot from http://people.debian.org/~jordens/debs/
ardour_0.9beta3+cvs20030921-1

Testcase:

$ LANG=de_DE ardour
create a new session
add a stereo bus and change the panning
save
quit ardour
$ LANG=de_DE ardour
reload the session

[ERROR]: incorrect number of pans specified in XML node (4 vs. 2
[ERROR]: MC: improper pan list in XML node (0,945428,0,325832)

The session file says:
pans="0,945428,0,325832"

2003-09-30 16:21

 

32_fix-non-c-locale-pans.patch (708 bytes)   
--- libs/ardour/io.cc.orig	2003-09-30 17:50:45.000000000 +0200
+++ libs/ardour/io.cc	2003-09-30 17:53:14.000000000 +0200
@@ -21,6 +21,7 @@
 #include <algorithm>
 #include <unistd.h>
 #include <cmath>
+#include <locale.h>
 
 #include <sigc++/bind.h>
 
@@ -1098,13 +1099,17 @@
 
 	for (unsigned long n = 0; n < n_outputs(); ++n) {
 		if (n) str += ',';
+		setlocale(LC_NUMERIC, "C");
 		snprintf (buf, sizeof(buf), "%g", _pans[n]);
+		setlocale(LC_NUMERIC, "");
 		str += buf;
 	}
 
 	node->add_property ("pans", str);
 
+	setlocale(LC_NUMERIC, "C");
 	snprintf (buf, sizeof(buf), "%g", gain());
+	setlocale(LC_NUMERIC, "");
 	node->add_property ("gain", buf);
 
 	snprintf (buf, sizeof(buf)-1, "%d,%d,%d,%d",

rjo

2003-09-30 16:34

reporter   ~0000010

Sorry. The patch is crap. I overlooked you were doing it globally with setlocale(LC_NUMERIC, "POSIX"); in main.cc.
If you use setlocale(LC_NUMERIC, "C"); it works.

rjo

2003-09-30 17:24

reporter   ~0000011

Sorry again. setting LC_NUMERIC to C or POSIX in main.cc does _not_ work. setlocale seems to act locally. Surrounding the snprintf's with setlocale (as in the patch), works. I tested that. Surrounding the atof's should work as well (they are also locale dependent). Maybe the locale is local to the thread..

2003-09-30 22:26

 

32_fix-non-c-locale-pans.patch (1,828 bytes)   
--- gtk_ardour/main.cc.orig	2003-09-30 21:47:14.000000000 +0200
+++ gtk_ardour/main.cc	2003-09-30 21:48:23.000000000 +0200
@@ -26,7 +26,6 @@
 #include <signal.h>
 #include <unistd.h>
 #include <mcheck.h>
-#include <locale.h>
 
 #include <pbd/error.h>
 #include <pbd/textreceiver.h>
@@ -213,12 +212,6 @@
 	
 	gtk_set_locale ();
 	
-	/* force use of non-localized representation of decimal point, 
-	   since we use it a lot in XML files and so forth.
-	*/
-
-	setlocale (LC_NUMERIC, "POSIX");
-	
 	bindtextdomain (PACKAGE, LOCALEDIR);
 	textdomain (PACKAGE);
 
--- libs/ardour/io.cc.orig	2003-09-30 21:47:57.000000000 +0200
+++ libs/ardour/io.cc	2003-09-30 21:51:36.000000000 +0200
@@ -21,6 +21,7 @@
 #include <algorithm>
 #include <unistd.h>
 #include <cmath>
+#include <locale.h>
 
 #include <sigc++/bind.h>
 
@@ -1023,7 +1024,13 @@
 	bool need_outs = true;
 	LockMonitor lm (io_lock, __LINE__, __FILE__);
 
-	node->add_property("name", _name);	
+	/* force use of non-localized representation of decimal point,
+	   since we use it a lot in XML files and so forth.
+	*/
+
+    setlocale (LC_NUMERIC, "C");
+
+	node->add_property("name", _name);
 	snprintf (buf, sizeof(buf), "%Lu", id());
 	node->add_property("id", buf);
 
@@ -1137,6 +1144,8 @@
 
 	/* XXX same for pan etc. */
 
+    setlocale (LC_NUMERIC, "");
+
 	return *node;
 }
 
@@ -1178,6 +1187,12 @@
 {
 	const XMLProperty* prop;
 
+	/* force use of non-localized representation of decimal point,
+	   since we use it a lot in XML files and so forth.
+	*/
+
+    setlocale (LC_NUMERIC, "C");
+
 	if (node.name() != state_node_name) {
 		error << compose(_("incorrect XML node \"%1\" passed to IO object"), node.name()) << endmsg;
 		return -1;
@@ -1283,6 +1298,8 @@
 		pending_state_node = new XMLNode (node);
 	}
 
+    setlocale (LC_NUMERIC, "");
+
 	return 0;
 }
 
32_fix-non-c-locale-pans.patch (1,828 bytes)   

rjo

2003-09-30 22:28

reporter   ~0000012

The patch from 09-30-03 15:26 works. I tested it with the testcase mentioned above.

taybin

2003-09-30 23:08

administrator   ~0000013

The second patch from rjo fixed it.

Issue History

Date Modified Username Field Change
2003-09-16 00:05 rjo New Issue
2003-09-16 03:20 taybin Priority normal => high
2003-09-16 03:20 taybin Status new => confirmed
2003-09-16 03:43 taybin Severity tweak => minor
2003-09-16 03:51 taybin Note Added: 0000005
2003-09-16 03:52 taybin Status confirmed => assigned
2003-09-16 03:52 taybin Assigned To => taybin
2003-09-21 09:19 rjo Note Added: 0000009
2003-09-30 16:21 rjo File Added: 32_fix-non-c-locale-pans.patch
2003-09-30 16:34 rjo Note Added: 0000010
2003-09-30 17:24 rjo Note Added: 0000011
2003-09-30 22:26 rjo File Added: 32_fix-non-c-locale-pans.patch
2003-09-30 22:28 rjo Note Added: 0000012
2003-09-30 23:08 taybin Status assigned => resolved
2003-09-30 23:08 taybin Resolution open => fixed
2003-09-30 23:08 taybin Note Added: 0000013
2003-10-01 00:50 taybin Status resolved => closed