|
View:
New views
3 Messages
—
Rating Filter:
Alert me
|
|
|
problematic use of setlocale in xinelibHi all,
I'm using xinelib in my application and I noticed that the calls to setlocale in xine is really screwing things up in my application. From what I've understood, and please correct me if I'm wrong, since xine is multi-threaded and calls setlocale from different threads, I (and xinelib) cannot reliable call setlocale to set it to a desired value without any race conditions. The biggest problem I have right now, is that LC_NUMERIC is changed by xine to whatever locale is set by the user, while I rely on LC_NUMERIC to be set to "C" for proper string to double conversions. I did a grep on setlocale in the xine source code and I saw a few problematic ones: In utils.c:563 char *xine_get_system_encoding(void) { char *codeset = NULL; #ifdef HAVE_NL_LANGINFO setlocale(LC_ALL, ""); codeset = nl_langinfo(CODESET); #endif This function gets indirectly called via _x_meta_info_set from quite a few input and demuxer plugins and incidently the flac demuxer which I'm using here. It also is used by osd.c. I see two potential problems here: a) The LC_ALL overwrites LC_NUMERIC (big problem for me). Also to retrieve the CODESET in nl_langinfo, you only need to set LC_CTYPE. For me changing that would already be a big help. b) The return value of nl_langinfo is only garanteed to be valid until a next call to setlocale or nl_langinfo. Obviously in a multi-thread application there is no such garantee. Wouldn't it better to query the system encoding only once in xine_init and then use that value throughout xinelib? The other uses of setlocale are in input_smb and video_out_dxr3. I haven't looked closely at those yet. Cheers, Sander -- "And any fool knows a dog needs a home A shelter from pigs on the wing" ------------------------------------------------------------------------------ The NEW KODAK i700 Series Scanners deliver under ANY circumstances! Your production scanning environment may not be a perfect world - but thanks to Kodak, there's a perfect scanner to get the job done! With the NEW KODAK i700 Series Scanner you'll get full speed at 300 dpi even with all image processing features enabled. http://p.sf.net/sfu/kodak-com _______________________________________________ xine-devel mailing list xine-devel@... https://lists.sourceforge.net/lists/listinfo/xine-devel |
|
|
Re: problematic use of setlocale in xinelibI demand that s.jansen@... may or may not have written...
> I'm using xinelib in my application and I noticed that the calls to > setlocale in xine is really screwing things up in my application. From what > I've understood, and please correct me if I'm wrong, since xine is > multi-threaded and calls setlocale from different threads, I (and xinelib) > cannot reliably call setlocale to set it to a desired value without any > race conditions. Not sure. Thing is, this doesn't affect me so I've not had significant reason to go digging into it... oh, and you've just been volunteered to fix any problems in this area. ;-) [snip] > Wouldn't it better to query the system encoding only once in xine_init and > then use that value throughout xinelib? Quite likely, yes. (BTW, would you mind NOT posting with lines >80 columns wide? Some of us see alternating long lines and short lines...) -- | Darren Salt | linux at youmustbejoking | nr. Ashington, | Toon | Debian GNU/Linux | or ds ,demon,co,uk | Northumberland | Army | + Use more efficient products. Use less. BE MORE ENERGY EFFICIENT. "Smeg... I forgot to ask if there were any curry houses in Dallas..." ------------------------------------------------------------------------------ The NEW KODAK i700 Series Scanners deliver under ANY circumstances! Your production scanning environment may not be a perfect world - but thanks to Kodak, there's a perfect scanner to get the job done! With the NEW KODAK i700 Series Scanner you'll get full speed at 300 dpi even with all image processing features enabled. http://p.sf.net/sfu/kodak-com _______________________________________________ xine-devel mailing list xine-devel@... https://lists.sourceforge.net/lists/listinfo/xine-devel |
|
|
Re: problematic use of setlocale in xinelibOn Thu, May 7, 2009 at 9:36 AM, Darren Salt
<linux@...> wrote: > I demand that s.jansen@... may or may not have written... > >> I'm using xinelib in my application and I noticed that the calls to >> setlocale in xine is really screwing things up in my application. From what >> I've understood, and please correct me if I'm wrong, since xine is >> multi-threaded and calls setlocale from different threads, I (and xinelib) >> cannot reliably call setlocale to set it to a desired value without any >> race conditions. > > Not sure. Thing is, this doesn't affect me so I've not had significant reason > to go digging into it... oh, and you've just been volunteered to fix any > problems in this area. ;-) It didn't affect me either since my en_US locale already converts floats similary to the "C" locale. But for any other locale that uses a different decimal delimiter, things tend to misbehave. So before committing any major surgery in xine-lib, let me start by submitting the attached patch which changes the LC_ALL to LC_CTYPE in xine_get_system_encoding since the character encoding is stored in LC_CTYPE. I will also start looking at the some of _x_meta_info_set calls, which potentially can be replaced by _x_meta_info_set_utf8 instead (setting the XINE_META_INFO_TRACK_NUMBER in demux_flac.c comes to mind). On systems with GLIBC we can perhaps optionally use the newlocale / freelocale function calls to have per thread locale information (GNU extension). > > [snip] >> Wouldn't it better to query the system encoding only once in xine_init and >> then use that value throughout xinelib? > > Quite likely, yes. > > (BTW, would you mind NOT posting with lines >80 columns wide? Some of us see > alternating long lines and short lines...) Sorry, that was unintentionally done. Hopefully this email has the correct formatting. Cheers, Sander -- "And any fool knows a dog needs a home A shelter from pigs on the wing" ------------------------------------------------------------------------------ The NEW KODAK i700 Series Scanners deliver under ANY circumstances! Your production scanning environment may not be a perfect world - but thanks to Kodak, there's a perfect scanner to get the job done! With the NEW KODAK i700 Series Scanner you'll get full speed at 300 dpi even with all image processing features enabled. http://p.sf.net/sfu/kodak-com _______________________________________________ xine-devel mailing list xine-devel@... https://lists.sourceforge.net/lists/listinfo/xine-devel |
| Free embeddable forum powered by Nabble | Forum Help |