Home Page

0.213 arcade OSX Popeye audio bug

Posted By: MacBox360

0.213 arcade OSX Popeye audio bug - 09/06/19 05:17 PM

I compiled the newly released 0.213 SDLmame (arcade games only, subtarget=arcade in configuration file) and it crashes on Popeye Rev.D with this error

Code
Driver popeye (file popeye.cpp): 1 errors, 0 warnings
Errors:
   Netlist Sound Device device 'snd_nl': netlist FATAL: Invalid number conversion ACCURACY : 1,000000000e-05
   

Driver popeyeb3 (file popeye.cpp): 1 errors, 0 warnings
Errors:
   Netlist Sound Device device 'snd_nl': netlist FATAL: Invalid number conversion ACCURACY : 1,000000000e-05
   

Driver popeyef (file popeye.cpp): 1 errors, 0 warnings
Errors:
   Netlist Sound Device device 'snd_nl': netlist FATAL: Invalid number conversion ACCURACY : 1,000000000e-05
   

Driver popeyehs (file popeye.cpp): 1 errors, 0 warnings
Errors:
   Netlist Sound Device device 'snd_nl': netlist FATAL: Invalid number conversion ACCURACY : 1,000000000e-05
   

Driver popeyeu (file popeye.cpp): 1 errors, 0 warnings
Errors:
   Netlist Sound Device device 'snd_nl': netlist FATAL: Invalid number conversion ACCURACY : 1,000000000e-05
   

Fatal error: netlist FATAL: Invalid number conversion ACCURACY : 1,000000000e-05

logout
Saving session...
...copying shared history...
...saving history...truncating history files...
...completed.



This does not occour on Popeye clones, only the parent one and it was present also in 0.212 release too. The host machine is a MacPro 2010 with dual Xeon 2.40 GHz and Mojave OS 10.14.6, latest Xcode and SDL installed.
Posted By: Vas Crabb

Re: 0.213 arcade OSX Popeye audio bug - 09/06/19 05:51 PM

Eugh, that's that bizarre netlist number conversion code. It was happening to lots of people on all netlist drivers at one point, but seemed to be hacked up enough to work most of the time. I still don't like the way the code is written. What are your locale settings?
Posted By: MacBox360

Re: 0.213 arcade OSX Popeye audio bug - 09/06/19 06:11 PM

If I correctly understand your question I think you are referring to Preferences panel of OSX where the decimal numbers syntax is set, if so here are my settings (I hope to translate it correctly)

Numeric spacer - Groups (dot) Decimals (comma)
Money value (euro) - Group (dot) Decimals (comma)
Measure Unit: Metric

If you need other infos I will be happy to answer.
Posted By: couriersud

Re: 0.213 arcade OSX Popeye audio bug - 09/09/19 07:46 PM

Can you please post the output of "locale" in your terminal, e.g.

Code
$ locale
LANG=
LC_COLLATE="C"
LC_CTYPE="UTF-8"
LC_MESSAGES="C"
LC_MONETARY="C"
LC_NUMERIC="C"
LC_TIME="C"
LC_ALL=


That will hopefully allow me to replicate the issue.
Posted By: couriersud

Re: 0.213 arcade OSX Popeye audio bug - 09/09/19 10:46 PM

Seems something is going wrong on OSX build - not netlist related.
If I understand the c++ documentation right, the use of localization is not enabled by default in c++ programs.
c++ programs explicitly have to call setlocale(LC_ALL, "") to enable localization.

In machine.cpp I placed a line which prints the current locale:

Code
	m_ui = manager().create_ui(*this);
	printf("Locale post  %s", std::setlocale(LC_ALL, NULL));


On linux this reports the "C" locale - even if a local locale is set, e.g.

Code
export LC_ALL=de_DE.utf8


On OSX however, it reports the local locale set by

Code
export LC_ALL=de_DE.UTF-8


i.e. "Locale post de_DE.UTF-8".

Consequently calls to vsnprintf (pfmt.cpp) use the local locale - and in this case "," instead of ".".

This means something somewhere is switching the locale on OSX. A grep for setlocale shows that some 3rd party libs are calling it but I don't have the time to further dig into it now.
Linux is behaving correctly here - all based on my understanding of the c++ locale docs I know.

Long term netlist - as a library - must be made immune against locale switches in calling programs. I can fix the exception in netlist. But there is an issue with one of the 3rd party libraries MAME uses in the first place.
Posted By: Vas Crabb

Re: 0.213 arcade OSX Popeye audio bug - 09/10/19 01:44 AM

You can't trust anything on cplusplus.com - the information there is various flavours of outdated, inaccurate and misleading. In any case, the netlist library shouldn't make an assumption about the global locale. It's supposed to be a library, so it shouldn't make assumptions about the hosting application. On macOS, the global locale is probably being set by the UI toolkit.
Posted By: couriersud

Re: 0.213 arcade OSX Popeye audio bug - 09/10/19 08:35 PM

Originally Posted by Vas Crabb
You can't trust anything on cplusplus.com - the information there is various flavours of outdated, inaccurate and misleading.


You should raise this with Bjarne. It's mentioned as a resource here: https://isocpp.org/get-started

Originally Posted by Vas Crabb
In any case, the netlist library shouldn't make an assumption about the global locale. It's supposed to be a library, so it shouldn't make assumptions about the hosting application. On macOS, the global locale is probably being set by the UI toolkit.


That's a double standard. Netlist shouldn't make an assumption about the global locale. Fine. I fixed that. But it is ok that the UI toolkit not only makes assumptions about the global locale but forces it on the application? Somewhere during initialization? After other application resources have been intialized? I consider the use of such libraries dangerous. Anyhow, fixed.
Posted By: R. Belmont

Re: 0.213 arcade OSX Popeye audio bug - 09/10/19 11:20 PM

The UI toolkit does have a vested interest in showing things correctly for your country and language and so on, so it's not surprising it does that.
Posted By: Vas Crabb

Re: 0.213 arcade OSX Popeye audio bug - 09/11/19 04:14 AM

The UI toolkit is designed to run as an IoC container - under normal circumstances, it is the main program. SDL somewhat subverts this, and MAME subverts it further by pumping events in the debugger (all this subversion is why some stuff doesn't work quite right in the debugger). Long-term, I want MAME to be more respectful of global locale/language settings in its own UI. The world doesn't all speak English and doesn't all use US conventions. Software should be able to deal with that by now. If you want a particular format for settings storage, logging, or something else, you shouldn't be using functions that depend on the global locale.
Posted By: couriersud

Re: 0.213 arcade OSX Popeye audio bug - 09/11/19 08:01 AM

Thanks a lot for the comments. Understood.

Currently on *nix we run MAME with the standard "C" locale and on OSX we run MAME with the system locale.
Shouldn't we have a common approach here? Should be as simple as inserting

Code
setlocale(LC_ALL,"");


and switching the standard io streams. The ui could get the language as well from the locale. That should work on Windows/mingw as well.
Posted By: R. Belmont

Re: 0.213 arcade OSX Popeye audio bug - 09/11/19 01:38 PM

I think we shouldn't change the system locale at all and instead should find some other way to convert between strings and floats.

I have a plan in the back of my head to convert the Mac version to native Cocoa all the way (Vas's work on CoreAudio helps with a chunk of that) but that's relatively time-consuming.
Posted By: couriersud

Re: 0.213 arcade OSX Popeye audio bug - 09/11/19 07:15 PM

Originally Posted by R. Belmont
I think we shouldn't change the system locale at all and instead should find some other way to convert between strings and floats..


OK, I'll leave it to Vas and you to sort this out.
Posted By: R. Belmont

Re: 0.213 arcade OSX Popeye audio bug - 09/11/19 08:03 PM

For string to float/double, atof_l() lets you specify a locale for the conversion without changing the system locale, but it might not be available on Linux. (It is on Windows, Mac, and other BSD-derived systems). Continuing research.
Posted By: Vas Crabb

Re: 0.213 arcade OSX Popeye audio bug - 09/12/19 04:15 AM

You can use a std::istream and call imbue.
Posted By: couriersud

Re: 0.213 arcade OSX Popeye audio bug - 09/13/19 10:18 AM

Originally Posted by Vas Crabb
You can use a std::istream and call imbue.


I am using this approach now in netlist. Also removing all c library stuff and moving to c++ library.

Another detail on the UI toolkit: The toolkit only changes the C library locale (setlocale). The c++ locale reports "C" on a call to locale().
So c++ functions use the "C" locale and c functions (stod and friends, printf ...) use the system locale when running on OSX.
Posted By: MacBox360

Re: 0.213 arcade OSX Popeye audio bug - 09/16/19 12:36 PM

Sorry for the delay, I was on holiday. Here is my locale configuration, the same I used for build latest 0.213 SDLmame:

Code
LANG="it_IT.UTF-8"
LC_COLLATE="it_IT.UTF-8"
LC_CTYPE="it_IT.UTF-8"
LC_MESSAGES="it_IT.UTF-8"
LC_MONETARY="it_IT.UTF-8"
LC_NUMERIC="it_IT.UTF-8"
LC_TIME="it_IT.UTF-8"
LC_ALL=

Posted By: couriersud

Re: 0.213 arcade OSX Popeye audio bug - 09/17/19 06:21 PM

The issue should be fixed now.
Posted By: R. Belmont

Re: 0.213 arcade OSX Popeye audio bug - 09/17/19 07:13 PM

Great, thanks couriersud!
Posted By: MacBox360

Re: 0.213 arcade OSX Popeye audio bug - 09/17/19 07:54 PM

Just compiled the GitHub snapshot, I confirm the issue is gone. Thank you very much! :-)
© 2020 Forums