"Xlib: unexpected async reply" with Mplayer embedded?

Hi Everyone,I have an SDL application which has a Mplayer embedded. I often get the error: “Xlib: unexpected async reply”. I found in mail-list there are a lot of discussions about “Xlib: unexpected async reply” problem. Based on these discussions, I guess, this problem is because Xlib functions are called in two threads(one is my main thread, i think there is another one in Mplayer). For my case, I can’t combine two threads into one, what should I do to avoid this problem? Any suggestion would be very appreciated.Thanks_________________________________________________________________
Enter today for your chance to win $1000 a day?today until May 12th. Learn more at SignInAndWIN.ca
http://g.msn.ca/ca55/215

This happens because the Xlib seem to be not thread-safe.

You would need to only ensure that the display updates happens only from the main thread only, you would not face this issue.

From the thread receiving asynchronous message, you need to signal the thread waiting under the context of main thread as and when asych message arrives and the main thread should do the job of display updates.

Hope this helps.

Best Regards

Vijay
(Vijayendra Mohan Agrawal)
53/3 Hosur Main Road
Madiwala,
Bangalore - 560068
India
Ph. +91-80-41381423
Mobile +91-98453-49045
VOIP 8067104 (Wipro Internal)________________________________

From: sdl-bounces@lists.libsdl.org [mailto:sdl-bounces at lists.libsdl.org] On Behalf Of Miles Qi
Sent: Friday, April 04, 2008 1:59 AM
To: sdl at lists.libsdl.org
Subject: [SDL] “Xlib: unexpected async reply” with Mplayer embedded?

Hi Everyone,

I have an SDL application which has a Mplayer embedded. I often get the error: “Xlib: unexpected async reply”. I found in mail-list there are a lot of discussions about “Xlib: unexpected async reply” problem. Based on these discussions, I guess, this problem is because Xlib functions are called in two threads(one is my main thread, i think there is another one in Mplayer). For my case, I can’t combine two threads into one, what should I do to avoid this problem? Any suggestion would be very appreciated.

Thanks


Sign in to Windows Live Messenger, and enter for your chance to win $1000 a day?today until May 12th. Visit SignInAndWIN.ca http://g.msn.ca/ca55/210

Please do not print this email unless it is absolutely necessary.

The information contained in this electronic message and any attachments to this message are intended for the exclusive use of the addressee(s) and may contain proprietary, confidential or privileged information. If you are not the intended recipient, you should not disseminate, distribute or copy this e-mail. Please notify the sender immediately and destroy all copies of this message and any attachments.

WARNING: Computer viruses can be transmitted via email. The recipient should check this email and any attachments for the presence of viruses. The company accepts no liability for any damage caused by any virus transmitted by this email.

Is the SDL event subsystem thread-safe ? Can you for example post an expose
event (or a user one) from the secondary thread to signal some redraw has to
be done ?

This happens because the Xlib seem to be not thread-safe.

You would need to only ensure that the display updates happens only from
the main thread only, you would not face this issue.

From the thread receiving asynchronous message, you need to signal the
thread waiting under the context of main thread as and when asych message
arrives and the main thread should do the job of display updates.

Hi,

Do you, by any chance, have an ATI card?

FYI, yes, virtually everything in SDL is thread-safe, unless:

  1. The documentation states that it is not.
  2. You have found a bug.

Eddy

Miles Qi wrote:> Hi Everyone,

I have an SDL application which has a Mplayer embedded. I often get the
error: “Xlib: unexpected async reply”. I found in mail-list there are a
lot of discussions about “Xlib: unexpected async reply” problem. Based
on these discussions, I guess, this problem is because Xlib functions
are called in two threads(one is my main thread, i think there is
another one in Mplayer). For my case, I can’t combine two threads into
one, what should I do to avoid this problem? Any suggestion would be
very appreciated.

Thanks

Sign in to Windows Live Messenger, and enter for your chance to win
$1000 a day?today until May 12th. Visit SignInAndWIN.ca
http://g.msn.ca/ca55/210



SDL mailing list
SDL at lists.libsdl.org
http://lists.libsdl.org/listinfo.cgi/sdl-libsdl.org

It’s not ATI-related. Really, graphics SDL are not thread safe, you
can only do graphics from the thread that created the graphics
context.

As for the original poster, there’s no other option than merging the
two pieces of code into the same codebase. Maybe you’ll want to use
smpeg instead of mplayer to help with that.

StephaneOn 5/9/08, Eddy Cullen wrote:

Hi,

Do you, by any chance, have an ATI card?

FYI, yes, virtually everything in SDL is thread-safe, unless:

Okay,

That was a brain-fart… perhaps what I mean was reentrant-safe…

There is no reason why one couldn’t have multiple threads accessing a
surface - as long as you make each access thread-safe, using a mutex or
some other locking mechanism.

Of course, that makes life 100x more difficult than it need be. so
you’re right, you’re probably better off just having one thread doing
drawing if you can…

Jitsu Love,

Eddy

Stephane Marchesin wrote:> On 5/9/08, Eddy Cullen wrote:

Hi,

Do you, by any chance, have an ATI card?

FYI, yes, virtually everything in SDL is thread-safe, unless:

It’s not ATI-related. Really, graphics SDL are not thread safe, you
can only do graphics from the thread that created the graphics
context.

As for the original poster, there’s no other option than merging the
two pieces of code into the same codebase. Maybe you’ll want to use
smpeg instead of mplayer to help with that.

Stephane


SDL mailing list
SDL at lists.libsdl.org
http://lists.libsdl.org/listinfo.cgi/sdl-libsdl.org