Mercurial > mplayer.hg
annotate gui/mplayer/play.c @ 32881:dd3b365972a4
Cosmetic: Format to MPlayer coding style.
author | ib |
---|---|
date | Fri, 25 Feb 2011 12:13:36 +0000 |
parents | 8fa2f43cb760 |
children | bd3ea059fe2d |
rev | line source |
---|---|
26458 | 1 /* |
2 * This file is part of MPlayer. | |
3 * | |
4 * MPlayer is free software; you can redistribute it and/or modify | |
5 * it under the terms of the GNU General Public License as published by | |
6 * the Free Software Foundation; either version 2 of the License, or | |
7 * (at your option) any later version. | |
8 * | |
9 * MPlayer is distributed in the hope that it will be useful, | |
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of | |
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |
12 * GNU General Public License for more details. | |
13 * | |
14 * You should have received a copy of the GNU General Public License along | |
15 * with MPlayer; if not, write to the Free Software Foundation, Inc., | |
16 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. | |
17 */ | |
23077 | 18 |
19 #include <stdlib.h> | |
20 #include <string.h> | |
21 | |
32881 | 22 #include "play.h" |
23 #include "gmplayer.h" | |
24 #include "gui/app.h" | |
25 #include "gui/interface.h" | |
26 #include "gui/skin/font.h" | |
27 #include "gui/skin/skin.h" | |
28 #include "gui/wm/wsxdnd.h" | |
29 #include "widgets.h" | |
23077 | 30 |
26382
b2f4abcf20ed
Make include paths consistent; do not use ../ in them.
diego
parents:
26365
diff
changeset
|
31 #include "config.h" |
b2f4abcf20ed
Make include paths consistent; do not use ../ in them.
diego
parents:
26365
diff
changeset
|
32 #include "help_mp.h" |
32881 | 33 #include "input/input.h" |
30653
3d23e24c5c60
Declare externally used variables from vd.c as extern in vd.h.
diego
parents:
29263
diff
changeset
|
34 #include "libmpcodecs/vd.h" |
26382
b2f4abcf20ed
Make include paths consistent; do not use ../ in them.
diego
parents:
26365
diff
changeset
|
35 #include "libvo/video_out.h" |
32881 | 36 #include "mp_core.h" |
23077 | 37 #include "stream/stream.h" |
38 | |
39 int mplGotoTheNext = 1; | |
40 | |
32881 | 41 void mplFullScreen(void) |
23077 | 42 { |
32881 | 43 if (guiIntfStruct.NoWindow && guiIntfStruct.Playing) |
44 return; | |
45 | |
46 if (guiIntfStruct.Playing && appMPlayer.subWindow.isFullScreen) { | |
47 appMPlayer.subWindow.OldWidth = guiIntfStruct.MovieWidth; | |
48 appMPlayer.subWindow.OldHeight = guiIntfStruct.MovieHeight; | |
49 | |
50 switch (appMPlayer.sub.x) { | |
51 case -1: | |
52 appMPlayer.subWindow.OldX = wsMaxX / 2 - appMPlayer.subWindow.OldWidth / 2 + wsOrgX; | |
53 break; | |
54 | |
55 case -2: | |
56 appMPlayer.subWindow.OldX = wsMaxX - appMPlayer.subWindow.OldWidth + wsOrgX; | |
57 break; | |
58 | |
59 default: | |
60 appMPlayer.subWindow.OldX = appMPlayer.sub.x; | |
61 break; | |
62 } | |
23077 | 63 |
32881 | 64 switch (appMPlayer.sub.y) { |
65 case -1: | |
66 appMPlayer.subWindow.OldY = wsMaxY / 2 - appMPlayer.subWindow.OldHeight / 2 + wsOrgY; | |
67 break; | |
68 | |
69 case -2: | |
70 appMPlayer.subWindow.OldY = wsMaxY - appMPlayer.subWindow.OldHeight + wsOrgY; | |
71 break; | |
23077 | 72 |
32881 | 73 default: |
74 appMPlayer.subWindow.OldY = appMPlayer.sub.y; | |
75 break; | |
76 } | |
77 } | |
78 | |
79 if (guiIntfStruct.Playing || gtkShowVideoWindow) | |
80 wsFullScreen(&appMPlayer.subWindow); | |
81 | |
82 fullscreen = vo_fs = appMPlayer.subWindow.isFullScreen; | |
83 wsSetLayer(wsDisplay, appMPlayer.mainWindow.WindowID, appMPlayer.subWindow.isFullScreen); | |
84 | |
85 if (appMPlayer.menuIsPresent) | |
86 wsSetLayer(wsDisplay, appMPlayer.menuWindow.WindowID, appMPlayer.subWindow.isFullScreen); | |
87 | |
88 if (guiIntfStruct.Playing) | |
89 wsSetBackgroundRGB(&appMPlayer.subWindow, 0, 0, 0); | |
90 else | |
91 wsSetBackgroundRGB(&appMPlayer.subWindow, appMPlayer.sub.R, appMPlayer.sub.G, appMPlayer.sub.B); | |
23077 | 92 } |
93 | |
32881 | 94 void mplEnd(void) |
23077 | 95 { |
32881 | 96 plItem *next; |
23077 | 97 |
32881 | 98 if (!mplGotoTheNext && guiIntfStruct.Playing) { |
99 mplGotoTheNext = 1; | |
100 return; | |
101 } | |
23077 | 102 |
32881 | 103 if (guiIntfStruct.Playing && (next = gtkSet(gtkGetNextPlItem, 0, NULL)) && (plLastPlayed != next)) { |
104 plLastPlayed = next; | |
105 guiSetDF(guiIntfStruct.Filename, next->path, next->name); | |
106 guiIntfStruct.StreamType = STREAMTYPE_FILE; | |
107 guiIntfStruct.FilenameChanged = guiIntfStruct.NewPlay = 1; | |
108 gfree((void **)&guiIntfStruct.AudioFile); | |
109 gfree((void **)&guiIntfStruct.Subtitlename); | |
110 } else { | |
111 if (guiIntfStruct.FilenameChanged || guiIntfStruct.NewPlay) | |
112 return; | |
23077 | 113 |
32881 | 114 guiIntfStruct.TimeSec = 0; |
115 guiIntfStruct.Position = 0; | |
116 guiIntfStruct.AudioType = 0; | |
117 guiIntfStruct.NoWindow = False; | |
23077 | 118 |
27341
e7c989f7a7c9
Start unifying names of internal preprocessor directives.
diego
parents:
26458
diff
changeset
|
119 #ifdef CONFIG_DVDREAD |
32881 | 120 guiIntfStruct.DVD.current_title = 1; |
121 guiIntfStruct.DVD.current_chapter = 1; | |
122 guiIntfStruct.DVD.current_angle = 1; | |
23077 | 123 #endif |
124 | |
32881 | 125 if (!appMPlayer.subWindow.isFullScreen && gtkShowVideoWindow) { |
126 wsResizeWindow(&appMPlayer.subWindow, appMPlayer.sub.width, appMPlayer.sub.height); | |
127 wsMoveWindow(&appMPlayer.subWindow, True, appMPlayer.sub.x, appMPlayer.sub.y); | |
128 } else | |
129 wsVisibleWindow(&appMPlayer.subWindow, wsHideWindow); | |
130 | |
131 guiGetEvent(guiCEvent, guiSetStop); | |
132 mplSubRender = 1; | |
133 wsSetBackgroundRGB(&appMPlayer.subWindow, appMPlayer.sub.R, appMPlayer.sub.G, appMPlayer.sub.B); | |
134 wsClearWindow(appMPlayer.subWindow); | |
135 wsPostRedisplay(&appMPlayer.subWindow); | |
23077 | 136 } |
137 } | |
138 | |
32881 | 139 void mplPlay(void) |
23077 | 140 { |
32881 | 141 if (!guiIntfStruct.Filename || |
142 (guiIntfStruct.Filename[0] == 0) || | |
143 (guiIntfStruct.Playing == 1)) | |
144 return; | |
23077 | 145 |
32881 | 146 if (guiIntfStruct.Playing == 2) { |
147 mplPause(); | |
148 return; | |
149 } | |
150 | |
151 guiGetEvent(guiCEvent, (void *)guiSetPlay); | |
152 mplSubRender = 0; | |
153 wsSetBackgroundRGB(&appMPlayer.subWindow, 0, 0, 0); | |
154 wsClearWindow(appMPlayer.subWindow); | |
23077 | 155 } |
156 | |
32881 | 157 void mplPause(void) |
23077 | 158 { |
32881 | 159 if (!guiIntfStruct.Playing) |
160 return; | |
161 | |
162 if (guiIntfStruct.Playing == 1) { | |
163 mp_cmd_t *cmd = calloc(1, sizeof(*cmd)); | |
164 cmd->id = MP_CMD_PAUSE; | |
165 cmd->name = strdup("pause"); | |
166 mp_input_queue_cmd(cmd); | |
167 } else | |
168 guiIntfStruct.Playing = 1; | |
23077 | 169 } |
170 | |
32881 | 171 void mplState(void) |
172 { | |
173 if (guiIntfStruct.Playing == 0 || guiIntfStruct.Playing == 2) { | |
174 btnModify(evPlaySwitchToPause, btnReleased); | |
175 btnModify(evPauseSwitchToPlay, btnDisabled); | |
176 } else { | |
177 btnModify(evPlaySwitchToPause, btnDisabled); | |
178 btnModify(evPauseSwitchToPlay, btnReleased); | |
179 } | |
23077 | 180 } |
181 | |
32881 | 182 float mplGetPosition(void) |
183 { | |
184 return guiIntfStruct.Position; // 0.0..100.0 | |
23077 | 185 } |
186 | |
32881 | 187 void mplRelSeek(float s) |
188 { | |
189 rel_seek_secs = s; // -+s | |
190 abs_seek_pos = 0; | |
191 } | |
192 | |
193 void mplAbsSeek(float s) | |
194 { | |
195 if (guiIntfStruct.StreamType == STREAMTYPE_STREAM) | |
196 return; | |
197 | |
198 rel_seek_secs = 0.01 * s; // 0.0..100.0 | |
199 abs_seek_pos = 3; | |
23077 | 200 } |
201 | |
202 listItems tmpList; | |
203 | |
32881 | 204 void ChangeSkin(char *name) |
23077 | 205 { |
32881 | 206 int prev, bprev, ret; |
207 | |
208 prev = appMPlayer.menuIsPresent; | |
209 bprev = appMPlayer.barIsPresent; | |
210 | |
211 mainVisible = 0; | |
212 | |
213 appInitStruct(&tmpList); | |
214 skinAppMPlayer = &tmpList; | |
215 fntFreeFont(); | |
216 ret = skinRead(name); | |
23077 | 217 |
32881 | 218 appInitStruct(&tmpList); |
219 skinAppMPlayer = &appMPlayer; | |
220 appInitStruct(&appMPlayer); | |
221 | |
222 if (ret) | |
223 name = skinName; | |
29263
0f1b5b68af32
whitespace cosmetics: Remove all trailing whitespace.
diego
parents:
27370
diff
changeset
|
224 |
32881 | 225 if (skinRead(name)) { |
226 mainVisible = 1; | |
227 return; | |
228 } | |
229 | |
230 // reload menu window | |
23077 | 231 |
32881 | 232 if (prev && appMPlayer.menuIsPresent) { |
233 free(mplMenuDrawBuffer); | |
234 mplMenuDrawBuffer = calloc(1, appMPlayer.menuBase.Bitmap.ImageSize); | |
235 | |
236 if (!mplMenuDrawBuffer) { | |
237 mp_msg(MSGT_GPLAYER, MSGL_STATUS, MSGTR_NEMDB); | |
238 return; | |
239 } | |
23077 | 240 |
32881 | 241 wsResizeWindow(&appMPlayer.menuWindow, appMPlayer.menuBase.width, appMPlayer.menuBase.height); |
242 wsResizeImage(&appMPlayer.menuWindow, appMPlayer.menuBase.width, appMPlayer.menuBase.height); | |
243 wsSetShape(&appMPlayer.menuWindow, appMPlayer.menuBase.Mask.Image); | |
244 wsVisibleWindow(&appMPlayer.menuWindow, wsHideWindow); | |
245 } else | |
246 mplMenuInit(); | |
247 | |
248 // reload sub window | |
23077 | 249 |
32881 | 250 if (appMPlayer.sub.Bitmap.Image) |
251 wsResizeImage(&appMPlayer.subWindow, appMPlayer.sub.Bitmap.Width, appMPlayer.sub.Bitmap.Height); | |
252 | |
253 if (!appMPlayer.subWindow.isFullScreen && !guiIntfStruct.Playing) { | |
254 wsResizeWindow(&appMPlayer.subWindow, appMPlayer.sub.width, appMPlayer.sub.height); | |
255 wsMoveWindow(&appMPlayer.subWindow, True, appMPlayer.sub.x, appMPlayer.sub.y); | |
256 } | |
257 | |
258 if (appMPlayer.sub.Bitmap.Image) | |
259 wsConvert(&appMPlayer.subWindow, appMPlayer.sub.Bitmap.Image, appMPlayer.sub.Bitmap.ImageSize); | |
23077 | 260 |
32881 | 261 if (!guiIntfStruct.Playing) { |
262 mplSubRender = 1; | |
263 wsSetBackgroundRGB(&appMPlayer.subWindow, appMPlayer.sub.R, appMPlayer.sub.G, appMPlayer.sub.B); | |
264 wsClearWindow(appMPlayer.subWindow); | |
265 wsPostRedisplay(&appMPlayer.subWindow); | |
266 } | |
267 | |
268 // reload play bar | |
269 | |
270 if (bprev) | |
271 wsDestroyWindow(&appMPlayer.barWindow); | |
272 | |
273 mplPBInit(); | |
23077 | 274 |
32881 | 275 // reload main window |
276 | |
277 free(mplDrawBuffer); | |
278 mplDrawBuffer = calloc(1, appMPlayer.main.Bitmap.ImageSize); | |
23077 | 279 |
32881 | 280 if (!mplDrawBuffer) { |
281 mp_msg(MSGT_GPLAYER, MSGL_STATUS, MSGTR_NEMDB); | |
282 return; | |
283 } | |
23077 | 284 |
32881 | 285 wsDestroyWindow(&appMPlayer.mainWindow); |
286 | |
287 wsCreateWindow(&appMPlayer.mainWindow, appMPlayer.main.x, appMPlayer.main.y, appMPlayer.main.width, appMPlayer.main.height, wsNoBorder, wsShowMouseCursor | wsHandleMouseButton | wsHandleMouseMove, wsShowFrame | wsMaxSize | wsHideWindow, "MPlayer"); | |
288 wsCreateImage(&appMPlayer.mainWindow, appMPlayer.main.Bitmap.Width, appMPlayer.main.Bitmap.Height); | |
289 wsSetShape(&appMPlayer.mainWindow, appMPlayer.main.Mask.Image); | |
290 wsSetIcon(wsDisplay, appMPlayer.mainWindow.WindowID, guiIcon, guiIconMask); | |
23077 | 291 |
32881 | 292 appMPlayer.mainWindow.ReDraw = (void *)mplMainDraw; |
293 appMPlayer.mainWindow.MouseHandler = mplMainMouseHandle; | |
294 appMPlayer.mainWindow.KeyHandler = mplMainKeyHandle; | |
295 appMPlayer.mainWindow.DandDHandler = mplDandDHandler; | |
296 | |
297 wsXDNDMakeAwareness(&appMPlayer.mainWindow); | |
23077 | 298 |
32881 | 299 if (!appMPlayer.mainDecoration) |
300 wsWindowDecoration(&appMPlayer.mainWindow, 0); | |
301 | |
302 wsVisibleWindow(&appMPlayer.mainWindow, wsShowWindow); | |
303 mainVisible = 1; | |
304 | |
305 btnModify(evSetVolume, guiIntfStruct.Volume); | |
306 btnModify(evSetBalance, guiIntfStruct.Balance); | |
307 btnModify(evSetMoviePosition, guiIntfStruct.Position); | |
308 btnModify(evFullScreen, !appMPlayer.subWindow.isFullScreen); | |
23077 | 309 |
32881 | 310 wsSetLayer(wsDisplay, appMPlayer.mainWindow.WindowID, appMPlayer.subWindow.isFullScreen); |
311 wsSetLayer(wsDisplay, appMPlayer.menuWindow.WindowID, appMPlayer.subWindow.isFullScreen); | |
312 } | |
313 | |
314 void mplSetFileName(char *dir, char *name, int type) | |
315 { | |
316 if (!name) | |
317 return; | |
23077 | 318 |
32881 | 319 if (!dir) |
320 guiSetFilename(guiIntfStruct.Filename, name) | |
321 else | |
322 guiSetDF(guiIntfStruct.Filename, dir, name) | |
23077 | 323 |
32881 | 324 guiIntfStruct.StreamType = type; |
325 gfree((void **)&guiIntfStruct.AudioFile); | |
326 gfree((void **)&guiIntfStruct.Subtitlename); | |
23077 | 327 } |
328 | |
32881 | 329 void mplCurr(void) |
23077 | 330 { |
32881 | 331 plItem *curr; |
332 int stop = 0; | |
23077 | 333 |
32881 | 334 if (guiIntfStruct.Playing == 2) |
335 return; | |
23077 | 336 |
32881 | 337 switch (guiIntfStruct.StreamType) { |
338 #ifdef CONFIG_DVDREAD | |
339 case STREAMTYPE_DVD: | |
340 break; | |
29263
0f1b5b68af32
whitespace cosmetics: Remove all trailing whitespace.
diego
parents:
27370
diff
changeset
|
341 |
23077 | 342 #endif |
27370
14c5017f40d2
Change a bunch of video/audio-output-specific preprocessor directives from
diego
parents:
27341
diff
changeset
|
343 #ifdef CONFIG_VCD |
32881 | 344 case STREAMTYPE_VCD: |
345 break; | |
346 | |
23077 | 347 #endif |
32881 | 348 default: |
349 | |
350 curr = gtkSet(gtkGetCurrPlItem, 0, NULL); | |
351 | |
352 if (curr) { | |
353 mplSetFileName(curr->path, curr->name, STREAMTYPE_FILE); | |
354 mplGotoTheNext = 0; | |
355 break; | |
356 } | |
357 | |
358 return; | |
359 } | |
360 | |
361 if (stop) | |
362 mplEventHandling(evStop, 0); | |
363 | |
364 if (guiIntfStruct.Playing == 1) | |
365 mplEventHandling(evPlay, 0); | |
23077 | 366 } |
367 | |
32881 | 368 void mplPrev(void) |
23077 | 369 { |
32881 | 370 plItem *prev; |
371 int stop = 0; | |
372 | |
373 if (guiIntfStruct.Playing == 2) | |
374 return; | |
375 | |
376 switch (guiIntfStruct.StreamType) { | |
377 #ifdef CONFIG_DVDREAD | |
378 case STREAMTYPE_DVD: | |
29263
0f1b5b68af32
whitespace cosmetics: Remove all trailing whitespace.
diego
parents:
27370
diff
changeset
|
379 |
32881 | 380 if (--guiIntfStruct.DVD.current_chapter == 0) { |
381 guiIntfStruct.DVD.current_chapter = 1; | |
382 | |
383 if (--guiIntfStruct.DVD.current_title <= 0) { | |
384 guiIntfStruct.DVD.current_title = 1; | |
385 stop = 1; | |
386 } | |
387 } | |
388 | |
389 guiIntfStruct.Track = guiIntfStruct.DVD.current_title; | |
390 break; | |
391 | |
23077 | 392 #endif |
27370
14c5017f40d2
Change a bunch of video/audio-output-specific preprocessor directives from
diego
parents:
27341
diff
changeset
|
393 #ifdef CONFIG_VCD |
32881 | 394 case STREAMTYPE_VCD: |
395 if (--guiIntfStruct.Track == 0) { | |
396 guiIntfStruct.Track = 1; | |
397 stop = 1; | |
398 } | |
399 break; | |
400 | |
23077 | 401 #endif |
32881 | 402 default: |
403 | |
404 prev = gtkSet(gtkGetPrevPlItem, 0, NULL); | |
405 | |
406 if (prev) { | |
407 mplSetFileName(prev->path, prev->name, STREAMTYPE_FILE); | |
408 mplGotoTheNext = 0; | |
409 break; | |
410 } | |
411 | |
412 return; | |
413 } | |
414 | |
415 if (stop) | |
416 mplEventHandling(evStop, 0); | |
417 | |
418 if (guiIntfStruct.Playing == 1) | |
419 mplEventHandling(evPlay, 0); | |
23077 | 420 } |
421 | |
32881 | 422 void mplNext(void) |
23077 | 423 { |
32881 | 424 int stop = 0; |
425 plItem *next; | |
23077 | 426 |
32881 | 427 if (guiIntfStruct.Playing == 2) |
428 return; | |
429 | |
430 switch (guiIntfStruct.StreamType) { | |
27341
e7c989f7a7c9
Start unifying names of internal preprocessor directives.
diego
parents:
26458
diff
changeset
|
431 #ifdef CONFIG_DVDREAD |
32881 | 432 case STREAMTYPE_DVD: |
433 | |
434 if (guiIntfStruct.DVD.current_chapter++ == guiIntfStruct.DVD.chapters) { | |
435 guiIntfStruct.DVD.current_chapter = 1; | |
436 | |
437 if (++guiIntfStruct.DVD.current_title > guiIntfStruct.DVD.titles) { | |
438 guiIntfStruct.DVD.current_title = guiIntfStruct.DVD.titles; | |
439 stop = 1; | |
440 } | |
441 } | |
442 | |
443 guiIntfStruct.Track = guiIntfStruct.DVD.current_title; | |
444 break; | |
445 | |
23077 | 446 #endif |
27370
14c5017f40d2
Change a bunch of video/audio-output-specific preprocessor directives from
diego
parents:
27341
diff
changeset
|
447 #ifdef CONFIG_VCD |
32881 | 448 case STREAMTYPE_VCD: |
449 if (++guiIntfStruct.Track > guiIntfStruct.VCDTracks) { | |
450 guiIntfStruct.Track = guiIntfStruct.VCDTracks; | |
451 stop = 1; | |
452 } | |
453 break; | |
454 | |
23077 | 455 #endif |
32881 | 456 default: |
457 | |
458 next = gtkSet(gtkGetNextPlItem, 0, NULL); | |
459 | |
460 if (next) { | |
461 mplSetFileName(next->path, next->name, STREAMTYPE_FILE); | |
462 mplGotoTheNext = 0; | |
463 break; | |
464 } | |
465 | |
466 return; | |
467 } | |
468 | |
469 if (stop) | |
470 mplEventHandling(evStop, 0); | |
471 | |
472 if (guiIntfStruct.Playing == 1) | |
473 mplEventHandling(evPlay, 0); | |
23077 | 474 } |