Mercurial > sdl-ios-xcode
annotate test/testhread.c @ 4106:12bb6311fd5d SDL-1.2
Hans de Goede fixed bug #495
When running boswars: http://www.boswars.org/ on a machine with intel
integrathed graphics it crashes when it tries to play the initial theora
splashscreen video:
X Error of failed request: BadAlloc (insufficient resources for operation)
Major opcode of failed request: 140 (XVideo)
Minor opcode of failed request: 19 ()
Serial number of failed request: 25
Current serial number in output stream: 26
boswars: xcb_xlib.c:41: xcb_xlib_lock: Assertion `!c->xlib.lock' failed.
Aborted
I recognized this problem from a few years back, when I encountered it while
working on the Xv blitter for xmame. The problem is that for some reason
creation the Xvport and XvImage succeeds, and failure (lack of resources / hw
capability?) is only indicated during the first XvPut[Shm]Image. I've written a
patch for SDL using the work around for this I developed for xmame (and which
is still used successfully in xmame after many years of usage).
I'll admit it isn't very pretty, but after investigating several possibilities
this was the best option, any other fixes would need changes to the SDL api and
abi.
author | Sam Lantinga <slouken@libsdl.org> |
---|---|
date | Sat, 29 Dec 2007 02:23:48 +0000 |
parents | 290b5baf2fca |
children | 782fd950bd46 c121d94672cb |
rev | line source |
---|---|
0 | 1 |
2 /* Simple test of the SDL threading code */ | |
3 | |
4 #include <stdio.h> | |
5 #include <stdlib.h> | |
6 #include <signal.h> | |
7 | |
8 #include "SDL.h" | |
9 #include "SDL_thread.h" | |
10 | |
11 static int alive = 0; | |
12 | |
1151
be9c9c8f6d53
Removed atexit() from most of the test programs; atexit(SDL_Quit) isn't safe
Ryan C. Gordon <icculus@icculus.org>
parents:
0
diff
changeset
|
13 /* Call this instead of exit(), so we can clean up SDL: atexit() is evil. */ |
be9c9c8f6d53
Removed atexit() from most of the test programs; atexit(SDL_Quit) isn't safe
Ryan C. Gordon <icculus@icculus.org>
parents:
0
diff
changeset
|
14 static void quit(int rc) |
be9c9c8f6d53
Removed atexit() from most of the test programs; atexit(SDL_Quit) isn't safe
Ryan C. Gordon <icculus@icculus.org>
parents:
0
diff
changeset
|
15 { |
be9c9c8f6d53
Removed atexit() from most of the test programs; atexit(SDL_Quit) isn't safe
Ryan C. Gordon <icculus@icculus.org>
parents:
0
diff
changeset
|
16 SDL_Quit(); |
be9c9c8f6d53
Removed atexit() from most of the test programs; atexit(SDL_Quit) isn't safe
Ryan C. Gordon <icculus@icculus.org>
parents:
0
diff
changeset
|
17 exit(rc); |
be9c9c8f6d53
Removed atexit() from most of the test programs; atexit(SDL_Quit) isn't safe
Ryan C. Gordon <icculus@icculus.org>
parents:
0
diff
changeset
|
18 } |
be9c9c8f6d53
Removed atexit() from most of the test programs; atexit(SDL_Quit) isn't safe
Ryan C. Gordon <icculus@icculus.org>
parents:
0
diff
changeset
|
19 |
1769 | 20 int SDLCALL ThreadFunc(void *data) |
0 | 21 { |
22 printf("Started thread %s: My thread id is %u\n", | |
23 (char *)data, SDL_ThreadID()); | |
24 while ( alive ) { | |
25 printf("Thread '%s' is alive!\n", (char *)data); | |
26 SDL_Delay(1*1000); | |
27 } | |
28 printf("Thread '%s' exiting!\n", (char *)data); | |
29 return(0); | |
30 } | |
31 | |
32 static void killed(int sig) | |
33 { | |
34 printf("Killed with SIGTERM, waiting 5 seconds to exit\n"); | |
35 SDL_Delay(5*1000); | |
36 alive = 0; | |
1151
be9c9c8f6d53
Removed atexit() from most of the test programs; atexit(SDL_Quit) isn't safe
Ryan C. Gordon <icculus@icculus.org>
parents:
0
diff
changeset
|
37 quit(0); |
0 | 38 } |
39 | |
40 int main(int argc, char *argv[]) | |
41 { | |
42 SDL_Thread *thread; | |
43 | |
44 /* Load the SDL library */ | |
45 if ( SDL_Init(0) < 0 ) { | |
46 fprintf(stderr, "Couldn't initialize SDL: %s\n",SDL_GetError()); | |
1151
be9c9c8f6d53
Removed atexit() from most of the test programs; atexit(SDL_Quit) isn't safe
Ryan C. Gordon <icculus@icculus.org>
parents:
0
diff
changeset
|
47 return(1); |
0 | 48 } |
49 | |
50 alive = 1; | |
51 thread = SDL_CreateThread(ThreadFunc, "#1"); | |
52 if ( thread == NULL ) { | |
53 fprintf(stderr, "Couldn't create thread: %s\n", SDL_GetError()); | |
1151
be9c9c8f6d53
Removed atexit() from most of the test programs; atexit(SDL_Quit) isn't safe
Ryan C. Gordon <icculus@icculus.org>
parents:
0
diff
changeset
|
54 quit(1); |
0 | 55 } |
56 SDL_Delay(5*1000); | |
57 printf("Waiting for thread #1\n"); | |
58 alive = 0; | |
59 SDL_WaitThread(thread, NULL); | |
60 | |
61 alive = 1; | |
62 thread = SDL_CreateThread(ThreadFunc, "#2"); | |
63 if ( thread == NULL ) { | |
64 fprintf(stderr, "Couldn't create thread: %s\n", SDL_GetError()); | |
1151
be9c9c8f6d53
Removed atexit() from most of the test programs; atexit(SDL_Quit) isn't safe
Ryan C. Gordon <icculus@icculus.org>
parents:
0
diff
changeset
|
65 quit(1); |
0 | 66 } |
67 SDL_Delay(5*1000); | |
68 printf("Killing thread #2\n"); | |
69 SDL_KillThread(thread); | |
70 | |
71 alive = 1; | |
72 signal(SIGTERM, killed); | |
73 thread = SDL_CreateThread(ThreadFunc, "#3"); | |
74 if ( thread == NULL ) { | |
75 fprintf(stderr, "Couldn't create thread: %s\n", SDL_GetError()); | |
1151
be9c9c8f6d53
Removed atexit() from most of the test programs; atexit(SDL_Quit) isn't safe
Ryan C. Gordon <icculus@icculus.org>
parents:
0
diff
changeset
|
76 quit(1); |
0 | 77 } |
78 raise(SIGTERM); | |
79 | |
1151
be9c9c8f6d53
Removed atexit() from most of the test programs; atexit(SDL_Quit) isn't safe
Ryan C. Gordon <icculus@icculus.org>
parents:
0
diff
changeset
|
80 SDL_Quit(); /* Never reached */ |
0 | 81 return(0); /* Never reached */ |
82 } |