Hi,

There are no special considerations to using Agar in a multi-threaded
application (Agar does not use threads internally; enabling threads
support only creates the locks required for the API to be thread-safe).

I would suspect the video refresh is a problem, you could try adding
a bunch of delays and printfs to the loop to confirm that. I'm assuming
you're initializing Agar with the AG_VIDEO_OVERLAY flag to prevent it
from clearing the background or swapping buffers?

Even then, I can't see any situation where you would want two event
loops running concurrently. Even if it weren't halting, it would be
inefficient and the input events probably wouldn't be handled correctly.
The proper way to do it would be to have a single event loop that lets
ffplay process low-level events. The MyEventLoop() in
demos/customeventloop/ has a good example of that:

        do {
                AG_DriverEvent dev;
                if (AG_GetNextEvent(NULL, &dev) == 1) {
                        switch (dev.type) {
                        case AG_DRIVER_MOUSE_BUTTON_DOWN:
                                /* Process in ffplay ... */
                        }
                        /* Process in Agar */
                        if (AG_ProcessEvent(NULL, &dev) == -1) 
                                return;
                }
        } while (AG_PendingEvents(NULL) > 0);

The nice thing about this is that it's driver-independent. You could
easily remove the SDL dependencies from ffplay and run your application
with either bare Xlib, SDL, etc.

On Mon, Jun 21, 2010 at 04:26:44PM +0000, Austin M wrote:
> Hi,
> 
> I am currently using the agar GUI to add buttons to FFplay. To do this, I 
> constructed another thread (FFplay is multi-threaded), and ran the event loop 
> from there. 
> However, the loop I constructed halts the other threads. The buttons 
> are displayed and work when clicked on, however the video does not play. I 
> have 
> narrowed it down to the event processing, which seems to halt the other 
> threads. 
> The thread is properly constructed, as removing the event handling portion of 
> the button thread allows FFplay to display the buttons as well as play the 
> video (sans button events working). 
> 
> My question is, is there something I should be explicit about when dealing 
> with 
> Agar in a multi-threaded application? Could it be that the SDL event handling 
> in 
> FFplay's event loop has problems with AG event handling running concurrently? 
> The FFplay event loop is responsible for handling the video refresh calls, 
> which 
> could be why.
> 
> Regards,
> Austin
> 
> _______________________________________________
> Agar mailing list
> [email protected]
> http://libagar.org/lists.html
_______________________________________________
Agar mailing list
[email protected]
http://libagar.org/lists.html

Reply via email to