Mercurial > pygame
annotate src/_gcommand.c @ 3194:9fcb7abf3185 default tip
Remove some gcc 4.7.2 compiler warnings
| author | Lenard Lindstrom <len-l@telus.net> |
|---|---|
| date | Tue, 23 Apr 2013 19:53:36 -0700 |
| parents | ecec7d7c1642 |
| children |
| rev | line source |
|---|---|
|
1935
ecec7d7c1642
Merged tylerthemovie branch changes r2168:2614 into the trunk
zeroth
parents:
diff
changeset
|
1 /* |
|
ecec7d7c1642
Merged tylerthemovie branch changes r2168:2614 into the trunk
zeroth
parents:
diff
changeset
|
2 pygame - Python Game Library |
|
ecec7d7c1642
Merged tylerthemovie branch changes r2168:2614 into the trunk
zeroth
parents:
diff
changeset
|
3 |
|
ecec7d7c1642
Merged tylerthemovie branch changes r2168:2614 into the trunk
zeroth
parents:
diff
changeset
|
4 This library is free software; you can redistribute it and/or |
|
ecec7d7c1642
Merged tylerthemovie branch changes r2168:2614 into the trunk
zeroth
parents:
diff
changeset
|
5 modify it under the terms of the GNU Library General Public |
|
ecec7d7c1642
Merged tylerthemovie branch changes r2168:2614 into the trunk
zeroth
parents:
diff
changeset
|
6 License as published by the Free Software Foundation; either |
|
ecec7d7c1642
Merged tylerthemovie branch changes r2168:2614 into the trunk
zeroth
parents:
diff
changeset
|
7 version 2 of the License, or (at your option) any later version. |
|
ecec7d7c1642
Merged tylerthemovie branch changes r2168:2614 into the trunk
zeroth
parents:
diff
changeset
|
8 |
|
ecec7d7c1642
Merged tylerthemovie branch changes r2168:2614 into the trunk
zeroth
parents:
diff
changeset
|
9 This library is distributed in the hope that it will be useful, |
|
ecec7d7c1642
Merged tylerthemovie branch changes r2168:2614 into the trunk
zeroth
parents:
diff
changeset
|
10 but WITHOUT ANY WARRANTY; without even the implied warranty of |
|
ecec7d7c1642
Merged tylerthemovie branch changes r2168:2614 into the trunk
zeroth
parents:
diff
changeset
|
11 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
|
ecec7d7c1642
Merged tylerthemovie branch changes r2168:2614 into the trunk
zeroth
parents:
diff
changeset
|
12 Library General Public License for more details. |
|
ecec7d7c1642
Merged tylerthemovie branch changes r2168:2614 into the trunk
zeroth
parents:
diff
changeset
|
13 |
|
ecec7d7c1642
Merged tylerthemovie branch changes r2168:2614 into the trunk
zeroth
parents:
diff
changeset
|
14 You should have received a copy of the GNU Library General Public |
|
ecec7d7c1642
Merged tylerthemovie branch changes r2168:2614 into the trunk
zeroth
parents:
diff
changeset
|
15 License along with this library; if not, write to the Free |
|
ecec7d7c1642
Merged tylerthemovie branch changes r2168:2614 into the trunk
zeroth
parents:
diff
changeset
|
16 Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA |
|
ecec7d7c1642
Merged tylerthemovie branch changes r2168:2614 into the trunk
zeroth
parents:
diff
changeset
|
17 |
|
ecec7d7c1642
Merged tylerthemovie branch changes r2168:2614 into the trunk
zeroth
parents:
diff
changeset
|
18 */ |
|
ecec7d7c1642
Merged tylerthemovie branch changes r2168:2614 into the trunk
zeroth
parents:
diff
changeset
|
19 |
|
ecec7d7c1642
Merged tylerthemovie branch changes r2168:2614 into the trunk
zeroth
parents:
diff
changeset
|
20 /* |
|
ecec7d7c1642
Merged tylerthemovie branch changes r2168:2614 into the trunk
zeroth
parents:
diff
changeset
|
21 * _movie - movie support for pygame with ffmpeg |
|
ecec7d7c1642
Merged tylerthemovie branch changes r2168:2614 into the trunk
zeroth
parents:
diff
changeset
|
22 * Author: Tyler Laing |
|
ecec7d7c1642
Merged tylerthemovie branch changes r2168:2614 into the trunk
zeroth
parents:
diff
changeset
|
23 * |
|
ecec7d7c1642
Merged tylerthemovie branch changes r2168:2614 into the trunk
zeroth
parents:
diff
changeset
|
24 * This module allows for the loading of, playing, pausing, stopping, and so on |
|
ecec7d7c1642
Merged tylerthemovie branch changes r2168:2614 into the trunk
zeroth
parents:
diff
changeset
|
25 * of a video file. Any format supported by ffmpeg is supported by this |
|
ecec7d7c1642
Merged tylerthemovie branch changes r2168:2614 into the trunk
zeroth
parents:
diff
changeset
|
26 * video player. Any bugs, please email trinioler@gmail.com :) |
|
ecec7d7c1642
Merged tylerthemovie branch changes r2168:2614 into the trunk
zeroth
parents:
diff
changeset
|
27 */ |
|
ecec7d7c1642
Merged tylerthemovie branch changes r2168:2614 into the trunk
zeroth
parents:
diff
changeset
|
28 |
|
ecec7d7c1642
Merged tylerthemovie branch changes r2168:2614 into the trunk
zeroth
parents:
diff
changeset
|
29 #include "_gcommand.h" |
|
ecec7d7c1642
Merged tylerthemovie branch changes r2168:2614 into the trunk
zeroth
parents:
diff
changeset
|
30 |
|
ecec7d7c1642
Merged tylerthemovie branch changes r2168:2614 into the trunk
zeroth
parents:
diff
changeset
|
31 /* command queue management routines... I make a lot of queues, don't I? */ |
|
ecec7d7c1642
Merged tylerthemovie branch changes r2168:2614 into the trunk
zeroth
parents:
diff
changeset
|
32 void addCommand(CommandQueue *q, Command *comm) |
|
ecec7d7c1642
Merged tylerthemovie branch changes r2168:2614 into the trunk
zeroth
parents:
diff
changeset
|
33 { |
|
ecec7d7c1642
Merged tylerthemovie branch changes r2168:2614 into the trunk
zeroth
parents:
diff
changeset
|
34 SDL_LockMutex(q->q_mutex); |
|
ecec7d7c1642
Merged tylerthemovie branch changes r2168:2614 into the trunk
zeroth
parents:
diff
changeset
|
35 comm->next=NULL; |
|
ecec7d7c1642
Merged tylerthemovie branch changes r2168:2614 into the trunk
zeroth
parents:
diff
changeset
|
36 q->registry[comm->type]++; |
|
ecec7d7c1642
Merged tylerthemovie branch changes r2168:2614 into the trunk
zeroth
parents:
diff
changeset
|
37 if(!q->size) |
|
ecec7d7c1642
Merged tylerthemovie branch changes r2168:2614 into the trunk
zeroth
parents:
diff
changeset
|
38 { |
|
ecec7d7c1642
Merged tylerthemovie branch changes r2168:2614 into the trunk
zeroth
parents:
diff
changeset
|
39 q->first=comm; |
|
ecec7d7c1642
Merged tylerthemovie branch changes r2168:2614 into the trunk
zeroth
parents:
diff
changeset
|
40 q->size++; |
|
ecec7d7c1642
Merged tylerthemovie branch changes r2168:2614 into the trunk
zeroth
parents:
diff
changeset
|
41 SDL_UnlockMutex(q->q_mutex); |
|
ecec7d7c1642
Merged tylerthemovie branch changes r2168:2614 into the trunk
zeroth
parents:
diff
changeset
|
42 return; |
|
ecec7d7c1642
Merged tylerthemovie branch changes r2168:2614 into the trunk
zeroth
parents:
diff
changeset
|
43 } |
|
ecec7d7c1642
Merged tylerthemovie branch changes r2168:2614 into the trunk
zeroth
parents:
diff
changeset
|
44 if(q->size==1) |
|
ecec7d7c1642
Merged tylerthemovie branch changes r2168:2614 into the trunk
zeroth
parents:
diff
changeset
|
45 { |
|
ecec7d7c1642
Merged tylerthemovie branch changes r2168:2614 into the trunk
zeroth
parents:
diff
changeset
|
46 q->last=comm; |
|
ecec7d7c1642
Merged tylerthemovie branch changes r2168:2614 into the trunk
zeroth
parents:
diff
changeset
|
47 q->first->next=comm; |
|
ecec7d7c1642
Merged tylerthemovie branch changes r2168:2614 into the trunk
zeroth
parents:
diff
changeset
|
48 q->size++; |
|
ecec7d7c1642
Merged tylerthemovie branch changes r2168:2614 into the trunk
zeroth
parents:
diff
changeset
|
49 SDL_UnlockMutex(q->q_mutex); |
|
ecec7d7c1642
Merged tylerthemovie branch changes r2168:2614 into the trunk
zeroth
parents:
diff
changeset
|
50 return; |
|
ecec7d7c1642
Merged tylerthemovie branch changes r2168:2614 into the trunk
zeroth
parents:
diff
changeset
|
51 } |
|
ecec7d7c1642
Merged tylerthemovie branch changes r2168:2614 into the trunk
zeroth
parents:
diff
changeset
|
52 q->last->next=comm; |
|
ecec7d7c1642
Merged tylerthemovie branch changes r2168:2614 into the trunk
zeroth
parents:
diff
changeset
|
53 q->last=comm; |
|
ecec7d7c1642
Merged tylerthemovie branch changes r2168:2614 into the trunk
zeroth
parents:
diff
changeset
|
54 q->size++; |
|
ecec7d7c1642
Merged tylerthemovie branch changes r2168:2614 into the trunk
zeroth
parents:
diff
changeset
|
55 SDL_UnlockMutex(q->q_mutex); |
|
ecec7d7c1642
Merged tylerthemovie branch changes r2168:2614 into the trunk
zeroth
parents:
diff
changeset
|
56 return; |
|
ecec7d7c1642
Merged tylerthemovie branch changes r2168:2614 into the trunk
zeroth
parents:
diff
changeset
|
57 } |
|
ecec7d7c1642
Merged tylerthemovie branch changes r2168:2614 into the trunk
zeroth
parents:
diff
changeset
|
58 |
|
ecec7d7c1642
Merged tylerthemovie branch changes r2168:2614 into the trunk
zeroth
parents:
diff
changeset
|
59 Command *getCommand(CommandQueue *q) |
|
ecec7d7c1642
Merged tylerthemovie branch changes r2168:2614 into the trunk
zeroth
parents:
diff
changeset
|
60 { |
|
ecec7d7c1642
Merged tylerthemovie branch changes r2168:2614 into the trunk
zeroth
parents:
diff
changeset
|
61 SDL_LockMutex(q->q_mutex); |
|
ecec7d7c1642
Merged tylerthemovie branch changes r2168:2614 into the trunk
zeroth
parents:
diff
changeset
|
62 Command *comm; |
|
ecec7d7c1642
Merged tylerthemovie branch changes r2168:2614 into the trunk
zeroth
parents:
diff
changeset
|
63 if(!q->last && q->first) |
|
ecec7d7c1642
Merged tylerthemovie branch changes r2168:2614 into the trunk
zeroth
parents:
diff
changeset
|
64 { |
|
ecec7d7c1642
Merged tylerthemovie branch changes r2168:2614 into the trunk
zeroth
parents:
diff
changeset
|
65 comm=q->first; |
|
ecec7d7c1642
Merged tylerthemovie branch changes r2168:2614 into the trunk
zeroth
parents:
diff
changeset
|
66 q->size--; |
|
ecec7d7c1642
Merged tylerthemovie branch changes r2168:2614 into the trunk
zeroth
parents:
diff
changeset
|
67 SDL_UnlockMutex(q->q_mutex); |
|
ecec7d7c1642
Merged tylerthemovie branch changes r2168:2614 into the trunk
zeroth
parents:
diff
changeset
|
68 return comm; |
|
ecec7d7c1642
Merged tylerthemovie branch changes r2168:2614 into the trunk
zeroth
parents:
diff
changeset
|
69 } |
|
ecec7d7c1642
Merged tylerthemovie branch changes r2168:2614 into the trunk
zeroth
parents:
diff
changeset
|
70 else if (!q->last && !q->first) |
|
ecec7d7c1642
Merged tylerthemovie branch changes r2168:2614 into the trunk
zeroth
parents:
diff
changeset
|
71 { |
|
ecec7d7c1642
Merged tylerthemovie branch changes r2168:2614 into the trunk
zeroth
parents:
diff
changeset
|
72 SDL_UnlockMutex(q->q_mutex); |
|
ecec7d7c1642
Merged tylerthemovie branch changes r2168:2614 into the trunk
zeroth
parents:
diff
changeset
|
73 return NULL; |
|
ecec7d7c1642
Merged tylerthemovie branch changes r2168:2614 into the trunk
zeroth
parents:
diff
changeset
|
74 } |
|
ecec7d7c1642
Merged tylerthemovie branch changes r2168:2614 into the trunk
zeroth
parents:
diff
changeset
|
75 comm=q->first; |
|
ecec7d7c1642
Merged tylerthemovie branch changes r2168:2614 into the trunk
zeroth
parents:
diff
changeset
|
76 q->first=q->first->next; |
|
ecec7d7c1642
Merged tylerthemovie branch changes r2168:2614 into the trunk
zeroth
parents:
diff
changeset
|
77 q->size--; |
|
ecec7d7c1642
Merged tylerthemovie branch changes r2168:2614 into the trunk
zeroth
parents:
diff
changeset
|
78 SDL_UnlockMutex(q->q_mutex); |
|
ecec7d7c1642
Merged tylerthemovie branch changes r2168:2614 into the trunk
zeroth
parents:
diff
changeset
|
79 return comm; |
|
ecec7d7c1642
Merged tylerthemovie branch changes r2168:2614 into the trunk
zeroth
parents:
diff
changeset
|
80 } |
|
ecec7d7c1642
Merged tylerthemovie branch changes r2168:2614 into the trunk
zeroth
parents:
diff
changeset
|
81 |
|
ecec7d7c1642
Merged tylerthemovie branch changes r2168:2614 into the trunk
zeroth
parents:
diff
changeset
|
82 inline int hasCommand(CommandQueue *q) |
|
ecec7d7c1642
Merged tylerthemovie branch changes r2168:2614 into the trunk
zeroth
parents:
diff
changeset
|
83 { |
|
ecec7d7c1642
Merged tylerthemovie branch changes r2168:2614 into the trunk
zeroth
parents:
diff
changeset
|
84 if(q->size>0) |
|
ecec7d7c1642
Merged tylerthemovie branch changes r2168:2614 into the trunk
zeroth
parents:
diff
changeset
|
85 return 1; |
|
ecec7d7c1642
Merged tylerthemovie branch changes r2168:2614 into the trunk
zeroth
parents:
diff
changeset
|
86 return 0; |
|
ecec7d7c1642
Merged tylerthemovie branch changes r2168:2614 into the trunk
zeroth
parents:
diff
changeset
|
87 } |
|
ecec7d7c1642
Merged tylerthemovie branch changes r2168:2614 into the trunk
zeroth
parents:
diff
changeset
|
88 |
|
ecec7d7c1642
Merged tylerthemovie branch changes r2168:2614 into the trunk
zeroth
parents:
diff
changeset
|
89 void flushCommands(CommandQueue *q) |
|
ecec7d7c1642
Merged tylerthemovie branch changes r2168:2614 into the trunk
zeroth
parents:
diff
changeset
|
90 { |
|
ecec7d7c1642
Merged tylerthemovie branch changes r2168:2614 into the trunk
zeroth
parents:
diff
changeset
|
91 SDL_LockMutex(q->q_mutex); |
|
ecec7d7c1642
Merged tylerthemovie branch changes r2168:2614 into the trunk
zeroth
parents:
diff
changeset
|
92 Command *prev; |
|
ecec7d7c1642
Merged tylerthemovie branch changes r2168:2614 into the trunk
zeroth
parents:
diff
changeset
|
93 Command *cur = q->first; |
|
ecec7d7c1642
Merged tylerthemovie branch changes r2168:2614 into the trunk
zeroth
parents:
diff
changeset
|
94 while(cur!=NULL) |
|
ecec7d7c1642
Merged tylerthemovie branch changes r2168:2614 into the trunk
zeroth
parents:
diff
changeset
|
95 { |
|
ecec7d7c1642
Merged tylerthemovie branch changes r2168:2614 into the trunk
zeroth
parents:
diff
changeset
|
96 prev=cur; |
|
ecec7d7c1642
Merged tylerthemovie branch changes r2168:2614 into the trunk
zeroth
parents:
diff
changeset
|
97 cur=cur->next; |
|
ecec7d7c1642
Merged tylerthemovie branch changes r2168:2614 into the trunk
zeroth
parents:
diff
changeset
|
98 PyMem_Free(prev); |
|
ecec7d7c1642
Merged tylerthemovie branch changes r2168:2614 into the trunk
zeroth
parents:
diff
changeset
|
99 q->size--; |
|
ecec7d7c1642
Merged tylerthemovie branch changes r2168:2614 into the trunk
zeroth
parents:
diff
changeset
|
100 } |
|
ecec7d7c1642
Merged tylerthemovie branch changes r2168:2614 into the trunk
zeroth
parents:
diff
changeset
|
101 SDL_UnlockMutex(q->q_mutex); |
|
ecec7d7c1642
Merged tylerthemovie branch changes r2168:2614 into the trunk
zeroth
parents:
diff
changeset
|
102 } |
|
ecec7d7c1642
Merged tylerthemovie branch changes r2168:2614 into the trunk
zeroth
parents:
diff
changeset
|
103 |
|
ecec7d7c1642
Merged tylerthemovie branch changes r2168:2614 into the trunk
zeroth
parents:
diff
changeset
|
104 /* registers a command with a particular movie object's command queue. |
|
ecec7d7c1642
Merged tylerthemovie branch changes r2168:2614 into the trunk
zeroth
parents:
diff
changeset
|
105 * Basically, this means, theoretically, different movie objects could have different commands... |
|
ecec7d7c1642
Merged tylerthemovie branch changes r2168:2614 into the trunk
zeroth
parents:
diff
changeset
|
106 */ |
|
ecec7d7c1642
Merged tylerthemovie branch changes r2168:2614 into the trunk
zeroth
parents:
diff
changeset
|
107 int registerCommand(CommandQueue *q) |
|
ecec7d7c1642
Merged tylerthemovie branch changes r2168:2614 into the trunk
zeroth
parents:
diff
changeset
|
108 { |
|
ecec7d7c1642
Merged tylerthemovie branch changes r2168:2614 into the trunk
zeroth
parents:
diff
changeset
|
109 //int cur = q->reg_ix; |
|
ecec7d7c1642
Merged tylerthemovie branch changes r2168:2614 into the trunk
zeroth
parents:
diff
changeset
|
110 if(q->reg_ix>=1024) |
|
ecec7d7c1642
Merged tylerthemovie branch changes r2168:2614 into the trunk
zeroth
parents:
diff
changeset
|
111 q->reg_ix=0; |
|
ecec7d7c1642
Merged tylerthemovie branch changes r2168:2614 into the trunk
zeroth
parents:
diff
changeset
|
112 q->registry[q->reg_ix]=0; |
|
ecec7d7c1642
Merged tylerthemovie branch changes r2168:2614 into the trunk
zeroth
parents:
diff
changeset
|
113 q->reg_ix++; |
|
ecec7d7c1642
Merged tylerthemovie branch changes r2168:2614 into the trunk
zeroth
parents:
diff
changeset
|
114 return q->reg_ix-1; |
|
ecec7d7c1642
Merged tylerthemovie branch changes r2168:2614 into the trunk
zeroth
parents:
diff
changeset
|
115 } |
