MAMEWorld >> Programming
Previous thread Previous  View all threads Index   Next thread Next   Flat Mode Flat  

Bryan Ischo
MAME Fan
Reged: 03/28/10
Posts: 358
Send PM
Re: What is the policy on distributing patches?
10/14/11 10:06 PM


> It sounds as if you intend to try and violate MAMEdev's intent in that specific way,
> in sort of a "no, Mr. Bond, I expect you to die" manner. I'm sure you're not actually
> planning to do that, so please explain your *real* use case.

Sure. The specific details are this:

If you examine the libmame API that I wrote about in another post on this forum, you will see that once a game is started, the application using the library is responsible for three things:

1. Displaying the textures that come out of the emulator every frame.
2. Playing the audio that comes out of the emulator every frame.
3. Providing game control input to the game on every frame.

This is very much a thin wrapper around the OSD layer so these should be pretty familiar to you.

In my frontend program, I was linking MAME in using libmame and starting a game up in its own thread and displaying the game in an OpenGL texture mapped to a spot in the frontend's 3d scene.

What I found was that while this worked, it opened up the frontend to being crashed by MAME, which unfortunately happens sometimes. Some games crash 100% of the time in fact.

So what I decided to do was to run MAME in a separate process instead of a separate thread. So when I want to start a game, I allocate a shared memory segment, set up some message queue structures in it, then fork and in the forked program run the MAME emulator and deliver the audio and video and game input over the shared memory segment. This means that even if MAME crashes, the frontend program is unaffected (it detects that no more messages are coming from MAME and kills it off and releases the shared memory segment).

Works great. I can even run many games simultaneously this way if I wanted to, which I currently do not, except that when the user wants to switch to a new game, I start the new one before the old one has even finished shutting down so during those brief periods there are two games running simultaneously.

Now, I have every intention of releasing the source to my frontend once it is ready (if that ever happens), but if someone had the same idea as I did and *didn't* want to release their source, then I wanted to know whether that would be allowed. And since my patches to MAME are what enable this kind of functionality, I want to be able to provide guidance on this licensing issue to anyone else who uses libmame.

As an aside, this works great on Linux because fork() and exec() are two separate calls and I can easily have the forked child access the anonymous shared memory segment that it inherited from its parent. I'm still figuring out how to make this work on Windows, but I'm thinking that probably the spawned child process will be spawned with a command line argument identifying the not-anonymous shared memory segment so that it can attach to it. Hiding this behind an API that works the same on both Linux and Windows is a challenging bit, that I haven't quite gotten to yet because I can't even compile my frontend on Windows yet because it has dependencies on libraries that are easily available on Linux but much harder to come by on Windows.







Entire thread
Subject Posted by Posted on
* What is the policy on distributing patches? Bryan Ischo 10/13/11 02:15 AM
. * Re: What is the policy on distributing patches? R. Belmont  10/14/11 05:42 PM
. * Re: What is the policy on distributing patches? Bryan Ischo  10/14/11 06:31 PM
. * Re: What is the policy on distributing patches? R. Belmont  10/14/11 09:29 PM
. * Re: What is the policy on distributing patches? Bryan Ischo  10/14/11 10:06 PM
. * Re: What is the policy on distributing patches? R. Belmont  10/14/11 11:02 PM
. * Re: What is the policy on distributing patches? Bryan Ischo  10/14/11 11:18 PM
. * Re: What is the policy on distributing patches? R. Belmont  10/15/11 12:54 AM
. * Re: What is the policy on distributing patches? Bryan Ischo  10/15/11 01:04 AM
. * Re: What is the policy on distributing patches? R. Belmont  10/15/11 02:50 AM

Extra information Permissions
Moderator:  Pi 
0 registered and 29 anonymous users are browsing this forum.
You cannot start new topics
You cannot reply to topics
HTML is enabled
UBBCode is enabled
Thread views: 3296