Mercurial > mplayer.hg
annotate gui/win32/interface.c @ 33770:6134493605c6
Use macro nfree() in Win32 GUI code.
author | ib |
---|---|
date | Sat, 09 Jul 2011 11:11:52 +0000 |
parents | 16286ee1fc71 |
children | b42abb9c7f2c |
rev | line source |
---|---|
23077 | 1 /* |
23079 | 2 * MPlayer GUI for Win32 |
3 * Copyright (C) 2003 Sascha Sommer <saschasommer@freenet.de> | |
4 * Copyright (C) 2006 Erik Augustson <erik_27can@yahoo.com> | |
5 * Copyright (C) 2006 Gianluigi Tiesi <sherpya@netfarm.it> | |
6 * | |
7 * This file is part of MPlayer. | |
8 * | |
9 * MPlayer is free software; you can redistribute it and/or modify | |
10 * it under the terms of the GNU General Public License as published by | |
11 * the Free Software Foundation; either version 2 of the License, or | |
12 * (at your option) any later version. | |
13 * | |
14 * MPlayer is distributed in the hope that it will be useful, | |
15 * but WITHOUT ANY WARRANTY; without even the implied warranty of | |
16 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |
17 * GNU General Public License for more details. | |
18 * | |
26457 | 19 * You should have received a copy of the GNU General Public License along |
20 * with MPlayer; if not, write to the Free Software Foundation, Inc., | |
21 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA | |
23079 | 22 */ |
23077 | 23 |
24 #include <windows.h> | |
33358 | 25 |
26 #if defined(__CYGWIN__) | |
27 #define _beginthreadex CreateThread | |
28 #else | |
29 #include <process.h> | |
30 #endif | |
31 | |
30901 | 32 #include "path.h" |
26372
76413880bfad
Update include paths to account for build system changes.
diego
parents:
26193
diff
changeset
|
33 #include "gui/interface.h" |
23091
52488bb09d90
Consistently use quotes instead of angled brackets in #include
diego
parents:
23079
diff
changeset
|
34 #include "m_option.h" |
52488bb09d90
Consistently use quotes instead of angled brackets in #include
diego
parents:
23079
diff
changeset
|
35 #include "mixer.h" |
52488bb09d90
Consistently use quotes instead of angled brackets in #include
diego
parents:
23079
diff
changeset
|
36 #include "mp_msg.h" |
52488bb09d90
Consistently use quotes instead of angled brackets in #include
diego
parents:
23079
diff
changeset
|
37 #include "help_mp.h" |
52488bb09d90
Consistently use quotes instead of angled brackets in #include
diego
parents:
23079
diff
changeset
|
38 #include "codec-cfg.h" |
52488bb09d90
Consistently use quotes instead of angled brackets in #include
diego
parents:
23079
diff
changeset
|
39 #include "stream/stream.h" |
52488bb09d90
Consistently use quotes instead of angled brackets in #include
diego
parents:
23079
diff
changeset
|
40 #include "libmpdemux/demuxer.h" |
52488bb09d90
Consistently use quotes instead of angled brackets in #include
diego
parents:
23079
diff
changeset
|
41 #include "libmpdemux/stheader.h" |
27341
e7c989f7a7c9
Start unifying names of internal preprocessor directives.
diego
parents:
26457
diff
changeset
|
42 #ifdef CONFIG_DVDREAD |
23091
52488bb09d90
Consistently use quotes instead of angled brackets in #include
diego
parents:
23079
diff
changeset
|
43 #include "stream/stream_dvd.h" |
23077 | 44 #endif |
23091
52488bb09d90
Consistently use quotes instead of angled brackets in #include
diego
parents:
23079
diff
changeset
|
45 #include "input/input.h" |
52488bb09d90
Consistently use quotes instead of angled brackets in #include
diego
parents:
23079
diff
changeset
|
46 #include "libvo/video_out.h" |
52488bb09d90
Consistently use quotes instead of angled brackets in #include
diego
parents:
23079
diff
changeset
|
47 #include "libao2/audio_out.h" |
52488bb09d90
Consistently use quotes instead of angled brackets in #include
diego
parents:
23079
diff
changeset
|
48 #include "access_mpcontext.h" |
30558 | 49 #include "libmpcodecs/vd.h" |
31425
2392ad3cec9c
Move af_cfg extern variable declaration to dec_audio.h.
diego
parents:
31312
diff
changeset
|
50 #include "libmpcodecs/dec_audio.h" |
33761 | 51 #include "gui/ui/actions.h" |
33557 | 52 #include "gui/ui/gmplayer.h" |
33770 | 53 #include "gui/util/mem.h" |
33761 | 54 #include "gui/util/list.h" |
55 #include "gui/util/string.h" | |
30558 | 56 #include "mp_core.h" |
32093 | 57 #include "mpcommon.h" |
23077 | 58 #include "gui.h" |
59 #include "dialogs.h" | |
27391
1d2faa1020fb
Rename a bunch of miscellaneous preprocessor directives.
diego
parents:
27341
diff
changeset
|
60 #ifdef CONFIG_LIBCDIO |
23077 | 61 #include <cdio/cdio.h> |
62 #endif | |
63 | |
64 int guiWinID = 0; | |
65 | |
66 char *skinName = NULL; | |
67 char *codecname = NULL; | |
33555 | 68 int uiGotoTheNext = 1; |
23077 | 69 static gui_t *mygui = NULL; |
70 static int update_subwindow(void); | |
71 static RECT old_rect; | |
72 static DWORD style; | |
24992 | 73 static HANDLE hThread; |
74 static unsigned threadId; | |
25765
304fc0bbefe1
audio_out / video_out structs should be treated as const
reimar
parents:
24992
diff
changeset
|
75 const ao_functions_t *audio_out = NULL; |
304fc0bbefe1
audio_out / video_out structs should be treated as const
reimar
parents:
24992
diff
changeset
|
76 const vo_functions_t *video_out = NULL; |
23077 | 77 mixer_t *mixer = NULL; |
78 | |
79 /* test for playlist files, no need to specify -playlist on the commandline. | |
80 * add any conceivable playlist extensions here. | |
81 * - Erik | |
82 */ | |
83 int parse_filename(char *file, play_tree_t *playtree, m_config_t *mconfig, int clear) | |
84 { | |
85 if(clear) | |
86 mygui->playlist->clear_playlist(mygui->playlist); | |
87 | |
88 if(strstr(file, ".m3u") || strstr(file, ".pls")) | |
89 { | |
90 playtree = parse_playlist_file(file); | |
33752 | 91 guiPlaylistAdd(playtree, mconfig); |
23077 | 92 return 1; |
93 } | |
94 return 0; | |
95 } | |
96 | |
33737 | 97 char *gstrdup(const char *str) |
98 { | |
99 if (!str) return NULL; | |
100 return strdup(str); | |
101 } | |
102 | |
33761 | 103 void setdup (char **old, const char *str) |
33740
2c02269701bd
Remove macros guiSetFilename() and guiSetDF() from interface.h.
ib
parents:
33737
diff
changeset
|
104 { |
2c02269701bd
Remove macros guiSetFilename() and guiSetDF() from interface.h.
ib
parents:
33737
diff
changeset
|
105 free(*old); |
2c02269701bd
Remove macros guiSetFilename() and guiSetDF() from interface.h.
ib
parents:
33737
diff
changeset
|
106 *old = gstrdup(str); |
2c02269701bd
Remove macros guiSetFilename() and guiSetDF() from interface.h.
ib
parents:
33737
diff
changeset
|
107 } |
2c02269701bd
Remove macros guiSetFilename() and guiSetDF() from interface.h.
ib
parents:
33737
diff
changeset
|
108 |
33761 | 109 void setddup (char **old, const char *dir, const char *name) |
33740
2c02269701bd
Remove macros guiSetFilename() and guiSetDF() from interface.h.
ib
parents:
33737
diff
changeset
|
110 { |
2c02269701bd
Remove macros guiSetFilename() and guiSetDF() from interface.h.
ib
parents:
33737
diff
changeset
|
111 free(*old); |
2c02269701bd
Remove macros guiSetFilename() and guiSetDF() from interface.h.
ib
parents:
33737
diff
changeset
|
112 *old = malloc(strlen(dir) + strlen(name) + 2); |
2c02269701bd
Remove macros guiSetFilename() and guiSetDF() from interface.h.
ib
parents:
33737
diff
changeset
|
113 if (*old) sprintf(*old, "%s/%s", dir, name); |
2c02269701bd
Remove macros guiSetFilename() and guiSetDF() from interface.h.
ib
parents:
33737
diff
changeset
|
114 } |
2c02269701bd
Remove macros guiSetFilename() and guiSetDF() from interface.h.
ib
parents:
33737
diff
changeset
|
115 |
23077 | 116 /** |
117 * \brief this actually creates a new list containing only one element... | |
118 */ | |
119 void gaddlist( char ***list, const char *entry) | |
120 { | |
121 int i; | |
122 | |
123 if (*list) | |
124 { | |
125 for (i=0; (*list)[i]; i++) free((*list)[i]); | |
126 free(*list); | |
127 } | |
128 | |
129 *list = malloc(2 * sizeof(char **)); | |
130 (*list)[0] = gstrdup(entry); | |
131 (*list)[1] = NULL; | |
132 } | |
133 | |
134 /** | |
135 * \brief this replaces a string starting with search by replace. | |
136 * If not found, replace is appended. | |
137 */ | |
33761 | 138 void greplace(char ***list, const char *search, const char *replace) |
23077 | 139 { |
140 int i = 0; | |
141 int len = (search) ? strlen(search) : 0; | |
142 | |
143 if (*list) | |
144 { | |
145 for (i = 0; (*list)[i]; i++) | |
146 { | |
147 if (search && (!strncmp((*list)[i], search, len))) | |
148 { | |
149 free((*list)[i]); | |
150 (*list)[i] = gstrdup(replace); | |
151 return; | |
152 } | |
153 } | |
154 *list = realloc(*list, (i + 2) * sizeof(char *)); | |
155 } | |
156 else | |
157 *list = malloc(2 * sizeof(char *)); | |
158 | |
159 (*list)[i] = gstrdup(replace); | |
160 (*list)[i + 1] = NULL; | |
161 } | |
162 | |
163 /* this function gets called by the gui to update mplayer */ | |
164 static void guiSetEvent(int event) | |
165 { | |
33555 | 166 if(guiInfo.mpcontext) |
167 mixer = mpctx_get_mixer(guiInfo.mpcontext); | |
23077 | 168 |
169 switch(event) | |
170 { | |
171 case evPlay: | |
172 case evPlaySwitchToPause: | |
23148
71efd1fc20c8
add missing case value, fixes functionality when using some skins.
vayne
parents:
23147
diff
changeset
|
173 case evPauseSwitchToPlay: |
33555 | 174 uiPlay(); |
23077 | 175 break; |
176 case evPause: | |
33555 | 177 uiPause(); |
23077 | 178 break; |
27341
e7c989f7a7c9
Start unifying names of internal preprocessor directives.
diego
parents:
26457
diff
changeset
|
179 #ifdef CONFIG_DVDREAD |
23077 | 180 case evPlayDVD: |
181 { | |
182 static char dvdname[MAX_PATH]; | |
33555 | 183 guiInfo.DVD.current_title = dvd_title; |
184 guiInfo.DVD.current_chapter = dvd_chapter; | |
185 guiInfo.DVD.current_angle = dvd_angle; | |
186 guiInfo.DiskChanged = 1; | |
23077 | 187 |
33555 | 188 uiSetFileName(NULL, dvd_device, STREAMTYPE_DVD); |
23077 | 189 dvdname[0] = 0; |
190 strcat(dvdname, "DVD Movie"); | |
191 GetVolumeInformation(dvd_device, dvdname, MAX_PATH, NULL, NULL, NULL, NULL, 0); | |
192 capitalize(dvdname); | |
193 mp_msg(MSGT_GPLAYER, MSGL_V, "Opening DVD %s -> %s\n", dvd_device, dvdname); | |
33731
81f71d910333
Cosmetic: Change prefix for symbolic constants from GMP to GUI.
ib
parents:
33730
diff
changeset
|
194 gui(GUI_PREPARE, (void *) STREAMTYPE_DVD); |
23077 | 195 mygui->playlist->clear_playlist(mygui->playlist); |
196 mygui->playlist->add_track(mygui->playlist, filename, NULL, dvdname, 0); | |
197 mygui->startplay(mygui); | |
198 break; | |
199 } | |
200 #endif | |
27391
1d2faa1020fb
Rename a bunch of miscellaneous preprocessor directives.
diego
parents:
27341
diff
changeset
|
201 #ifdef CONFIG_LIBCDIO |
23077 | 202 case evPlayCD: |
203 { | |
204 int i; | |
205 char track[10]; | |
206 char trackname[10]; | |
207 CdIo_t *p_cdio = cdio_open(NULL, DRIVER_UNKNOWN); | |
208 track_t i_tracks; | |
209 | |
210 if(p_cdio == NULL) printf("Couldn't find a driver.\n"); | |
211 i_tracks = cdio_get_num_tracks(p_cdio); | |
212 | |
213 mygui->playlist->clear_playlist(mygui->playlist); | |
214 for(i=0;i<i_tracks;i++) | |
215 { | |
216 sprintf(track, "cdda://%d", i+1); | |
217 sprintf(trackname, "Track %d", i+1); | |
218 mygui->playlist->add_track(mygui->playlist, track, NULL, trackname, 0); | |
219 } | |
220 cdio_destroy(p_cdio); | |
221 mygui->startplay(mygui); | |
222 break; | |
223 } | |
224 #endif | |
225 case evFullScreen: | |
226 mp_input_queue_cmd(mp_input_parse_cmd("vo_fullscreen")); | |
227 break; | |
228 case evExit: | |
229 { | |
230 /* We are asking mplayer to exit, later it will ask us after uninit is made | |
231 this should be the only safe way to quit */ | |
232 mygui->activewidget = NULL; | |
233 mp_input_queue_cmd(mp_input_parse_cmd("quit")); | |
234 break; | |
235 } | |
236 case evStop: | |
33555 | 237 if(guiInfo.Playing) |
33731
81f71d910333
Cosmetic: Change prefix for symbolic constants from GMP to GUI.
ib
parents:
33730
diff
changeset
|
238 gui(GUI_SET_STATE, (void *) GUI_STOP); |
23077 | 239 break; |
240 case evSetMoviePosition: | |
241 { | |
33555 | 242 rel_seek_secs = guiInfo.Position / 100.0f; |
23077 | 243 abs_seek_pos = 3; |
244 break; | |
245 } | |
246 case evForward10sec: | |
247 { | |
248 rel_seek_secs = 10.0f; | |
249 abs_seek_pos = 0; | |
250 break; | |
251 } | |
252 case evBackward10sec: | |
253 { | |
254 rel_seek_secs = -10.0f; | |
255 abs_seek_pos = 0; | |
256 break; | |
257 } | |
258 case evSetBalance: | |
259 case evSetVolume: | |
260 { | |
261 float l,r; | |
262 | |
33615
1f9a31d4f114
Replace all playback integer constants by their symbolic constants.
ib
parents:
33614
diff
changeset
|
263 if (guiInfo.Playing == GUI_STOP) |
23077 | 264 break; |
265 | |
33555 | 266 if (guiInfo.Balance == 50.0f) |
267 mixer_setvolume(mixer, guiInfo.Volume, guiInfo.Volume); | |
23077 | 268 |
33555 | 269 l = guiInfo.Volume * ((100.0f - guiInfo.Balance) / 50.0f); |
270 r = guiInfo.Volume * ((guiInfo.Balance) / 50.0f); | |
23077 | 271 |
33555 | 272 if (l > guiInfo.Volume) l=guiInfo.Volume; |
273 if (r > guiInfo.Volume) r=guiInfo.Volume; | |
23077 | 274 mixer_setvolume(mixer, l, r); |
275 /* Check for balance support on mixer - there is a better way ?? */ | |
276 if (r != l) | |
277 { | |
278 mixer_getvolume(mixer, &l, &r); | |
279 if (r == l) | |
280 { | |
281 mp_msg(MSGT_GPLAYER, MSGL_V, "[GUI] Mixer doesn't support balanced audio\n"); | |
33555 | 282 mixer_setvolume(mixer, guiInfo.Volume, guiInfo.Volume); |
283 guiInfo.Balance = 50.0f; | |
23077 | 284 } |
285 } | |
286 break; | |
287 } | |
288 case evMute: | |
289 { | |
290 mp_cmd_t * cmd = calloc(1, sizeof(*cmd)); | |
291 cmd->id=MP_CMD_MUTE; | |
292 cmd->name=strdup("mute"); | |
293 mp_input_queue_cmd(cmd); | |
294 break; | |
295 } | |
296 case evDropFile: | |
297 case evLoadPlay: | |
298 { | |
33555 | 299 switch(guiInfo.StreamType) |
23077 | 300 { |
27341
e7c989f7a7c9
Start unifying names of internal preprocessor directives.
diego
parents:
26457
diff
changeset
|
301 #ifdef CONFIG_DVDREAD |
23077 | 302 case STREAMTYPE_DVD: |
303 { | |
33555 | 304 guiInfo.Title = guiInfo.DVD.current_title; |
305 guiInfo.Chapter = guiInfo.DVD.current_chapter; | |
306 guiInfo.Angle = guiInfo.DVD.current_angle; | |
307 guiInfo.DiskChanged = 1; | |
33731
81f71d910333
Cosmetic: Change prefix for symbolic constants from GMP to GUI.
ib
parents:
33730
diff
changeset
|
308 gui(GUI_SET_STATE, (void *) GUI_PLAY); |
23077 | 309 break; |
310 } | |
23147
21c35763b178
compilation fix for disabling dvd functionality, patch by <bangbangbear at gmail dot com>, slightly modified by me.
vayne
parents:
23123
diff
changeset
|
311 #endif |
23077 | 312 default: |
313 { | |
33555 | 314 guiInfo.FilenameChanged = guiInfo.NewPlay = 1; |
23077 | 315 update_playlistwindow(); |
33555 | 316 uiGotoTheNext = guiInfo.Playing? 0 : 1; |
33731
81f71d910333
Cosmetic: Change prefix for symbolic constants from GMP to GUI.
ib
parents:
33730
diff
changeset
|
317 gui(GUI_SET_STATE, (void *) GUI_STOP); |
81f71d910333
Cosmetic: Change prefix for symbolic constants from GMP to GUI.
ib
parents:
33730
diff
changeset
|
318 gui(GUI_SET_STATE, (void *) GUI_PLAY); |
23077 | 319 break; |
320 } | |
321 } | |
322 break; | |
323 } | |
324 case evNext: | |
33555 | 325 uiNext(); |
23077 | 326 break; |
327 case evPrev: | |
33555 | 328 uiPrev(); |
23077 | 329 break; |
330 } | |
331 } | |
332 | |
33555 | 333 void uiPlay( void ) |
23077 | 334 { |
33555 | 335 if((!guiInfo.Filename ) || (guiInfo.Filename[0] == 0)) |
23077 | 336 return; |
337 | |
33615
1f9a31d4f114
Replace all playback integer constants by their symbolic constants.
ib
parents:
33614
diff
changeset
|
338 if(guiInfo.Playing > GUI_STOP) |
23077 | 339 { |
33555 | 340 uiPause(); |
23077 | 341 return; |
342 } | |
33555 | 343 guiInfo.NewPlay = 1; |
33731
81f71d910333
Cosmetic: Change prefix for symbolic constants from GMP to GUI.
ib
parents:
33730
diff
changeset
|
344 gui(GUI_SET_STATE, (void *) GUI_PLAY); |
23077 | 345 } |
346 | |
33555 | 347 void uiPause( void ) |
23077 | 348 { |
33555 | 349 if(!guiInfo.Playing) return; |
23077 | 350 |
33615
1f9a31d4f114
Replace all playback integer constants by their symbolic constants.
ib
parents:
33614
diff
changeset
|
351 if(guiInfo.Playing == GUI_PLAY) |
23077 | 352 { |
353 mp_cmd_t * cmd = calloc(1, sizeof(*cmd)); | |
354 cmd->id=MP_CMD_PAUSE; | |
355 cmd->name=strdup("pause"); | |
356 mp_input_queue_cmd(cmd); | |
33615
1f9a31d4f114
Replace all playback integer constants by their symbolic constants.
ib
parents:
33614
diff
changeset
|
357 } else guiInfo.Playing = GUI_PLAY; |
23077 | 358 } |
359 | |
33555 | 360 void uiNext(void) |
23077 | 361 { |
33615
1f9a31d4f114
Replace all playback integer constants by their symbolic constants.
ib
parents:
33614
diff
changeset
|
362 if(guiInfo.Playing == GUI_PAUSE) return; |
33555 | 363 switch(guiInfo.StreamType) |
23077 | 364 { |
27341
e7c989f7a7c9
Start unifying names of internal preprocessor directives.
diego
parents:
26457
diff
changeset
|
365 #ifdef CONFIG_DVDREAD |
23077 | 366 case STREAMTYPE_DVD: |
33555 | 367 if(guiInfo.DVD.current_chapter == (guiInfo.DVD.chapters - 1)) |
23077 | 368 return; |
33555 | 369 guiInfo.DVD.current_chapter++; |
23077 | 370 break; |
371 #endif | |
372 default: | |
373 if(mygui->playlist->current == (mygui->playlist->trackcount - 1)) | |
374 return; | |
33555 | 375 uiSetFileName(NULL, mygui->playlist->tracks[(mygui->playlist->current)++]->filename, |
23077 | 376 STREAMTYPE_STREAM); |
377 break; | |
378 } | |
379 mygui->startplay(mygui); | |
380 } | |
381 | |
33555 | 382 void uiPrev(void) |
23077 | 383 { |
33615
1f9a31d4f114
Replace all playback integer constants by their symbolic constants.
ib
parents:
33614
diff
changeset
|
384 if(guiInfo.Playing == GUI_PAUSE) return; |
33555 | 385 switch(guiInfo.StreamType) |
23077 | 386 { |
27341
e7c989f7a7c9
Start unifying names of internal preprocessor directives.
diego
parents:
26457
diff
changeset
|
387 #ifdef CONFIG_DVDREAD |
23077 | 388 case STREAMTYPE_DVD: |
33555 | 389 if(guiInfo.DVD.current_chapter == 1) |
23077 | 390 return; |
33555 | 391 guiInfo.DVD.current_chapter--; |
23077 | 392 break; |
393 #endif | |
394 default: | |
395 if(mygui->playlist->current == 0) | |
396 return; | |
33555 | 397 uiSetFileName(NULL, mygui->playlist->tracks[(mygui->playlist->current)--]->filename, |
23077 | 398 STREAMTYPE_STREAM); |
399 break; | |
400 } | |
401 mygui->startplay(mygui); | |
402 } | |
403 | |
33555 | 404 void uiSetFileName(char *dir, char *name, int type) |
23077 | 405 { |
406 if(!name) return; | |
407 if(!dir) | |
33740
2c02269701bd
Remove macros guiSetFilename() and guiSetDF() from interface.h.
ib
parents:
33737
diff
changeset
|
408 setdup(&guiInfo.Filename, name); |
23077 | 409 else |
33740
2c02269701bd
Remove macros guiSetFilename() and guiSetDF() from interface.h.
ib
parents:
33737
diff
changeset
|
410 setddup(&guiInfo.Filename, dir, name); |
23077 | 411 |
33555 | 412 guiInfo.StreamType = type; |
33770 | 413 nfree(guiInfo.AudioFile); |
414 nfree(guiInfo.Subtitlename); | |
23077 | 415 } |
416 | |
33555 | 417 void uiFullScreen( void ) |
23077 | 418 { |
33555 | 419 if(!guiInfo.sh_video) return; |
23077 | 420 |
421 if(sub_window) | |
422 { | |
423 if(!fullscreen && IsWindowVisible(mygui->subwindow) && !IsIconic(mygui->subwindow)) | |
424 GetWindowRect(mygui->subwindow, &old_rect); | |
425 | |
426 if(fullscreen) | |
427 { | |
428 fullscreen = 0; | |
429 style = WS_OVERLAPPEDWINDOW | WS_SIZEBOX; | |
430 } else { | |
431 fullscreen = 1; | |
432 style = WS_VISIBLE | WS_POPUP; | |
433 } | |
434 SetWindowLong(mygui->subwindow, GWL_STYLE, style); | |
435 update_subwindow(); | |
436 } | |
437 video_out->control(VOCTRL_FULLSCREEN, 0); | |
438 if(sub_window) ShowWindow(mygui->subwindow, SW_SHOW); | |
439 } | |
440 | |
24992 | 441 static unsigned __stdcall GuiThread(void* param) |
23077 | 442 { |
443 MSG msg; | |
444 | |
445 if(!skinName) skinName = strdup("Blue"); | |
446 if(!mygui) mygui = create_gui(get_path("skins"), skinName, guiSetEvent); | |
30558 | 447 if(!mygui) exit_player(EXIT_ERROR); |
23077 | 448 |
449 if(autosync && autosync != gtkAutoSync) | |
450 { | |
451 gtkAutoSyncOn = 1; | |
452 gtkAutoSync = autosync; | |
453 } | |
454 | |
24992 | 455 while(GetMessage(&msg, NULL, 0, 0)) |
23077 | 456 { |
457 TranslateMessage(&msg); | |
458 DispatchMessage(&msg); | |
459 } | |
23078 | 460 fprintf(stderr, "[GUI] GUI thread terminated.\n"); |
23077 | 461 fflush(stderr); |
462 return 0; | |
463 } | |
464 | |
465 void guiInit(void) | |
466 { | |
33555 | 467 memset(&guiInfo, 0, sizeof(guiInfo)); |
23077 | 468 /* Create The gui thread */ |
469 if (!mygui) | |
470 { | |
33358 | 471 hThread = _beginthreadex(NULL, 0, GuiThread, NULL, 0, &threadId); |
23077 | 472 mp_msg(MSGT_GPLAYER, MSGL_V, "[GUI] Creating GUI Thread 0x%04x\n", threadId); |
473 } | |
474 | |
475 /* Wait until the gui is created */ | |
476 while(!mygui) Sleep(100); | |
23078 | 477 mp_msg(MSGT_GPLAYER, MSGL_V, "[GUI] GUI thread started.\n"); |
23077 | 478 } |
479 | |
480 void guiDone(void) | |
481 { | |
482 if(mygui) | |
483 { | |
484 fprintf(stderr, "[GUI] Closed by main mplayer window\n"); | |
485 fflush(stderr); | |
24992 | 486 PostThreadMessage(threadId, WM_QUIT, 0, 0); |
487 WaitForSingleObject(hThread, INFINITE); | |
488 CloseHandle(hThread); | |
23077 | 489 mygui->uninit(mygui); |
33770 | 490 nfree(mygui); |
23077 | 491 } |
492 /* Remove tray icon */ | |
493 Shell_NotifyIcon(NIM_DELETE, &nid); | |
494 cfg_write(); | |
495 } | |
496 | |
497 /* this function gets called by mplayer to update the gui */ | |
33726 | 498 int gui(int what, void *arg) |
23077 | 499 { |
30722
b0342ca7ea61
Fix windows Gui compilation and remove some related typecasts.
reimar
parents:
30558
diff
changeset
|
500 stream_t *stream = arg; |
27341
e7c989f7a7c9
Start unifying names of internal preprocessor directives.
diego
parents:
26457
diff
changeset
|
501 #ifdef CONFIG_DVDREAD |
33730 | 502 dvd_priv_t *dvdp; |
23077 | 503 #endif |
504 if(!mygui || !mygui->skin) return 0; | |
505 | |
33555 | 506 if(guiInfo.mpcontext) |
23077 | 507 { |
33555 | 508 audio_out = mpctx_get_audio_out(guiInfo.mpcontext); |
509 video_out = mpctx_get_video_out(guiInfo.mpcontext); | |
510 mixer = mpctx_get_mixer(guiInfo.mpcontext); | |
511 playtree = mpctx_get_playtree_iter(guiInfo.mpcontext); | |
23077 | 512 } |
513 | |
33726 | 514 switch (what) |
23077 | 515 { |
33731
81f71d910333
Cosmetic: Change prefix for symbolic constants from GMP to GUI.
ib
parents:
33730
diff
changeset
|
516 case GUI_PREPARE: |
23077 | 517 { |
33731
81f71d910333
Cosmetic: Change prefix for symbolic constants from GMP to GUI.
ib
parents:
33730
diff
changeset
|
518 gui(GUI_SET_FILE, 0); |
33555 | 519 guiInfo.DiskChanged = 0; |
520 guiInfo.FilenameChanged = 0; | |
521 guiInfo.NewPlay = 0; | |
522 switch(guiInfo.StreamType) | |
23077 | 523 { |
524 case STREAMTYPE_PLAYLIST: | |
525 break; | |
27341
e7c989f7a7c9
Start unifying names of internal preprocessor directives.
diego
parents:
26457
diff
changeset
|
526 #ifdef CONFIG_DVDREAD |
23077 | 527 case STREAMTYPE_DVD: |
528 { | |
529 char tmp[512]; | |
33555 | 530 dvd_title = guiInfo.DVD.current_title; |
531 dvd_chapter = guiInfo.DVD.current_chapter; | |
532 dvd_angle = guiInfo.DVD.current_angle; | |
533 sprintf(tmp,"dvd://%d", guiInfo.Title); | |
33740
2c02269701bd
Remove macros guiSetFilename() and guiSetDF() from interface.h.
ib
parents:
33737
diff
changeset
|
534 setdup(&guiInfo.Filename, tmp); |
23077 | 535 break; |
536 } | |
537 #endif | |
538 } | |
33555 | 539 if(guiInfo.Filename) |
540 filename = strdup(guiInfo.Filename); | |
23077 | 541 else if(filename) |
33555 | 542 strcpy(guiInfo.Filename, filename); |
23077 | 543 break; |
544 } | |
33731
81f71d910333
Cosmetic: Change prefix for symbolic constants from GMP to GUI.
ib
parents:
33730
diff
changeset
|
545 case GUI_SET_AUDIO: |
23077 | 546 { |
33679 | 547 guiInfo.MovieWindow = (arg && !guiInfo.sh_video); |
33661 | 548 // NOTE: This type doesn't mean (and never meant) that we have |
549 // *just* audio, so there probably should be a check before | |
550 // hiding (see gui/interface.c). | |
23077 | 551 if(IsWindowVisible(mygui->subwindow)) |
552 ShowWindow(mygui->subwindow, SW_HIDE); | |
553 break; | |
554 } | |
33731
81f71d910333
Cosmetic: Change prefix for symbolic constants from GMP to GUI.
ib
parents:
33730
diff
changeset
|
555 case GUI_SET_CONTEXT: |
33555 | 556 guiInfo.mpcontext = arg; |
23077 | 557 break; |
33731
81f71d910333
Cosmetic: Change prefix for symbolic constants from GMP to GUI.
ib
parents:
33730
diff
changeset
|
558 case GUI_SET_VIDEO: |
23077 | 559 { |
33555 | 560 guiInfo.sh_video = arg; |
23077 | 561 if (arg) |
562 { | |
30722
b0342ca7ea61
Fix windows Gui compilation and remove some related typecasts.
reimar
parents:
30558
diff
changeset
|
563 sh_video_t *sh = arg; |
23077 | 564 codecname = sh->codec->name; |
33555 | 565 guiInfo.FPS = sh->fps; |
23077 | 566 |
567 /* we have video, show the subwindow */ | |
568 if(!IsWindowVisible(mygui->subwindow) || IsIconic(mygui->subwindow)) | |
569 ShowWindow(mygui->subwindow, SW_SHOWNORMAL); | |
570 if(WinID == -1) | |
571 update_subwindow(); | |
572 | |
573 } | |
574 break; | |
575 } | |
33731
81f71d910333
Cosmetic: Change prefix for symbolic constants from GMP to GUI.
ib
parents:
33730
diff
changeset
|
576 case GUI_SETUP_VIDEO_WINDOW: |
23077 | 577 { |
33555 | 578 guiInfo.MovieWidth = vo_dwidth; |
579 guiInfo.MovieHeight = vo_dheight; | |
23077 | 580 |
33555 | 581 sub_aspect = (float)guiInfo.MovieWidth/guiInfo.MovieHeight; |
23077 | 582 if(WinID != -1) |
583 update_subwindow(); | |
584 break; | |
585 } | |
33731
81f71d910333
Cosmetic: Change prefix for symbolic constants from GMP to GUI.
ib
parents:
33730
diff
changeset
|
586 case GUI_SET_STREAM: |
23077 | 587 { |
33555 | 588 guiInfo.StreamType = stream->type; |
23077 | 589 switch(stream->type) |
590 { | |
27341
e7c989f7a7c9
Start unifying names of internal preprocessor directives.
diego
parents:
26457
diff
changeset
|
591 #ifdef CONFIG_DVDREAD |
23077 | 592 case STREAMTYPE_DVD: |
33730 | 593 dvdp = stream->priv; |
594 guiInfo.DVD.titles = dvdp->vmg_file->tt_srpt->nr_of_srpts; | |
595 guiInfo.DVD.chapters = dvdp->vmg_file->tt_srpt->title[dvd_title].nr_of_ptts; | |
596 guiInfo.DVD.angles = dvdp->vmg_file->tt_srpt->title[dvd_title].nr_of_angles; | |
597 guiInfo.DVD.nr_of_audio_channels = dvdp->nr_of_channels; | |
598 memcpy(guiInfo.DVD.audio_streams, dvdp->audio_streams, sizeof(dvdp->audio_streams)); | |
599 guiInfo.DVD.nr_of_subtitles = dvdp->nr_of_subtitles; | |
600 memcpy(guiInfo.DVD.subtitles, dvdp->subtitles, sizeof(dvdp->subtitles)); | |
601 guiInfo.DVD.current_title = dvd_title + 1; | |
602 guiInfo.DVD.current_chapter = dvd_chapter + 1; | |
603 guiInfo.DVD.current_angle = dvd_angle + 1; | |
604 guiInfo.Track = dvd_title + 1; | |
23077 | 605 break; |
606 #endif | |
607 } | |
608 break; | |
609 } | |
33731
81f71d910333
Cosmetic: Change prefix for symbolic constants from GMP to GUI.
ib
parents:
33730
diff
changeset
|
610 case GUI_REDRAW: |
23077 | 611 mygui->updatedisplay(mygui, mygui->mainwindow); |
612 break; | |
33731
81f71d910333
Cosmetic: Change prefix for symbolic constants from GMP to GUI.
ib
parents:
33730
diff
changeset
|
613 case GUI_SET_AFILTER: |
33555 | 614 guiInfo.afilter = arg; |
23077 | 615 break; |
33731
81f71d910333
Cosmetic: Change prefix for symbolic constants from GMP to GUI.
ib
parents:
33730
diff
changeset
|
616 case GUI_SET_STATE: |
23077 | 617 { |
33555 | 618 guiInfo.Playing = (int) arg; |
619 switch (guiInfo.Playing) | |
23077 | 620 { |
33614 | 621 case GUI_PLAY: |
23077 | 622 { |
33615
1f9a31d4f114
Replace all playback integer constants by their symbolic constants.
ib
parents:
33614
diff
changeset
|
623 guiInfo.Playing = GUI_PLAY; |
23077 | 624 break; |
625 } | |
33614 | 626 case GUI_STOP: |
23077 | 627 { |
33615
1f9a31d4f114
Replace all playback integer constants by their symbolic constants.
ib
parents:
33614
diff
changeset
|
628 guiInfo.Playing = GUI_STOP; |
23077 | 629 if(movie_aspect >= 0) |
630 movie_aspect = -1; | |
631 update_subwindow(); | |
632 break; | |
633 } | |
33614 | 634 case GUI_PAUSE: |
33615
1f9a31d4f114
Replace all playback integer constants by their symbolic constants.
ib
parents:
33614
diff
changeset
|
635 guiInfo.Playing = GUI_PAUSE; |
23077 | 636 break; |
637 } | |
638 break; | |
639 } | |
33731
81f71d910333
Cosmetic: Change prefix for symbolic constants from GMP to GUI.
ib
parents:
33730
diff
changeset
|
640 case GUI_RUN_COMMAND: |
23077 | 641 { |
642 mp_msg(MSGT_GPLAYER,MSGL_V, "cmd: %d\n", (int) arg); | |
643 /* MPlayer asks us to quit */ | |
644 switch((int) arg) | |
645 { | |
31312
0b7792622c88
Remove Gui-specific slave commands and associated key-bindings and other code.
reimar
parents:
30901
diff
changeset
|
646 case MP_CMD_VO_FULLSCREEN: |
33555 | 647 uiFullScreen(); |
23077 | 648 break; |
649 case MP_CMD_QUIT: | |
650 { | |
651 mygui->uninit(mygui); | |
33770 | 652 nfree(mygui); |
30558 | 653 exit_player(EXIT_QUIT); |
33666
0f592e8530f1
Change return code of guiGetEvent() to indicate success.
ib
parents:
33661
diff
changeset
|
654 return 1; |
23077 | 655 } |
33696
24d919fb6778
Don't let MPlayer directly call user interface functions.
ib
parents:
33695
diff
changeset
|
656 case MP_CMD_PLAY_TREE_STEP: |
24d919fb6778
Don't let MPlayer directly call user interface functions.
ib
parents:
33695
diff
changeset
|
657 guiSetEvent(evNext); |
24d919fb6778
Don't let MPlayer directly call user interface functions.
ib
parents:
33695
diff
changeset
|
658 break; |
24d919fb6778
Don't let MPlayer directly call user interface functions.
ib
parents:
33695
diff
changeset
|
659 case -MP_CMD_PLAY_TREE_STEP: |
24d919fb6778
Don't let MPlayer directly call user interface functions.
ib
parents:
33695
diff
changeset
|
660 guiSetEvent(evPrev); |
24d919fb6778
Don't let MPlayer directly call user interface functions.
ib
parents:
33695
diff
changeset
|
661 break; |
24d919fb6778
Don't let MPlayer directly call user interface functions.
ib
parents:
33695
diff
changeset
|
662 case MP_CMD_STOP: |
24d919fb6778
Don't let MPlayer directly call user interface functions.
ib
parents:
33695
diff
changeset
|
663 guiSetEvent(evStop); |
24d919fb6778
Don't let MPlayer directly call user interface functions.
ib
parents:
33695
diff
changeset
|
664 break; |
23077 | 665 default: |
666 break; | |
667 } | |
668 break; | |
669 } | |
33731
81f71d910333
Cosmetic: Change prefix for symbolic constants from GMP to GUI.
ib
parents:
33730
diff
changeset
|
670 case GUI_SET_FILE: |
23077 | 671 { |
672 audio_id = -1; | |
673 video_id = -1; | |
674 dvdsub_id = -1; | |
675 vobsub_id = -1; | |
676 stream_cache_size = -1; | |
677 autosync = 0; | |
678 dvd_title = 0; | |
679 force_fps = 0; | |
680 if(!mygui->playlist->tracks) return 0; | |
33555 | 681 filename = guiInfo.Filename = mygui->playlist->tracks[mygui->playlist->current]->filename; |
682 guiInfo.Track = mygui->playlist->current + 1; | |
23077 | 683 if(gtkAONorm) greplace(&af_cfg.list, "volnorm", "volnorm"); |
684 if(gtkAOExtraStereo) | |
685 { | |
686 char *name = malloc(12 + 20 + 1); | |
687 snprintf(name, 12 + 20, "extrastereo=%f", gtkAOExtraStereoMul); | |
688 name[12 + 20] = 0; | |
689 greplace(&af_cfg.list, "extrastereo", name); | |
690 free(name); | |
691 } | |
692 if(gtkCacheOn) stream_cache_size = gtkCacheSize; | |
693 if(gtkAutoSyncOn) autosync = gtkAutoSync; | |
694 break; | |
695 } | |
33732 | 696 case GUI_HANDLE_EVENTS: |
697 break; | |
33731
81f71d910333
Cosmetic: Change prefix for symbolic constants from GMP to GUI.
ib
parents:
33730
diff
changeset
|
698 case GUI_SET_MIXER: |
23077 | 699 { |
700 if(audio_out) | |
701 { | |
702 /* Some audio_out drivers do not support balance e.g. dsound */ | |
703 /* FIXME this algo is not correct */ | |
704 float l, r; | |
705 mixer_getvolume(mixer, &l, &r); | |
33555 | 706 guiInfo.Volume = (r > l ? r : l); /* max(r,l) */ |
23077 | 707 if (r != l) |
33555 | 708 guiInfo.Balance = ((r-l) + 100.0f) * 0.5f; |
23077 | 709 else |
33555 | 710 guiInfo.Balance = 50.0f; |
23077 | 711 } |
712 break; | |
713 } | |
33731
81f71d910333
Cosmetic: Change prefix for symbolic constants from GMP to GUI.
ib
parents:
33730
diff
changeset
|
714 case GUI_END_FILE: |
33694
45553d0f65c6
Don't let MPlayer directly call user interface functions.
ib
parents:
33691
diff
changeset
|
715 { |
45553d0f65c6
Don't let MPlayer directly call user interface functions.
ib
parents:
33691
diff
changeset
|
716 if(!uiGotoTheNext && guiInfo.Playing) |
45553d0f65c6
Don't let MPlayer directly call user interface functions.
ib
parents:
33691
diff
changeset
|
717 { |
45553d0f65c6
Don't let MPlayer directly call user interface functions.
ib
parents:
33691
diff
changeset
|
718 uiGotoTheNext = 1; |
45553d0f65c6
Don't let MPlayer directly call user interface functions.
ib
parents:
33691
diff
changeset
|
719 break; |
45553d0f65c6
Don't let MPlayer directly call user interface functions.
ib
parents:
33691
diff
changeset
|
720 } |
45553d0f65c6
Don't let MPlayer directly call user interface functions.
ib
parents:
33691
diff
changeset
|
721 |
45553d0f65c6
Don't let MPlayer directly call user interface functions.
ib
parents:
33691
diff
changeset
|
722 if(uiGotoTheNext && guiInfo.Playing && |
45553d0f65c6
Don't let MPlayer directly call user interface functions.
ib
parents:
33691
diff
changeset
|
723 (mygui->playlist->current < (mygui->playlist->trackcount - 1)) && |
45553d0f65c6
Don't let MPlayer directly call user interface functions.
ib
parents:
33691
diff
changeset
|
724 guiInfo.StreamType != STREAMTYPE_DVD && |
45553d0f65c6
Don't let MPlayer directly call user interface functions.
ib
parents:
33691
diff
changeset
|
725 guiInfo.StreamType != STREAMTYPE_DVDNAV) |
45553d0f65c6
Don't let MPlayer directly call user interface functions.
ib
parents:
33691
diff
changeset
|
726 { |
45553d0f65c6
Don't let MPlayer directly call user interface functions.
ib
parents:
33691
diff
changeset
|
727 /* we've finished this file, reset the aspect */ |
45553d0f65c6
Don't let MPlayer directly call user interface functions.
ib
parents:
33691
diff
changeset
|
728 if(movie_aspect >= 0) |
45553d0f65c6
Don't let MPlayer directly call user interface functions.
ib
parents:
33691
diff
changeset
|
729 movie_aspect = -1; |
45553d0f65c6
Don't let MPlayer directly call user interface functions.
ib
parents:
33691
diff
changeset
|
730 |
45553d0f65c6
Don't let MPlayer directly call user interface functions.
ib
parents:
33691
diff
changeset
|
731 uiGotoTheNext = guiInfo.FilenameChanged = guiInfo.NewPlay = 1; |
45553d0f65c6
Don't let MPlayer directly call user interface functions.
ib
parents:
33691
diff
changeset
|
732 uiSetFileName(NULL, mygui->playlist->tracks[(mygui->playlist->current)++]->filename, STREAMTYPE_STREAM); |
45553d0f65c6
Don't let MPlayer directly call user interface functions.
ib
parents:
33691
diff
changeset
|
733 //sprintf(guiInfo.Filename, mygui->playlist->tracks[(mygui->playlist->current)++]->filename); |
45553d0f65c6
Don't let MPlayer directly call user interface functions.
ib
parents:
33691
diff
changeset
|
734 } |
45553d0f65c6
Don't let MPlayer directly call user interface functions.
ib
parents:
33691
diff
changeset
|
735 |
45553d0f65c6
Don't let MPlayer directly call user interface functions.
ib
parents:
33691
diff
changeset
|
736 if(guiInfo.FilenameChanged && guiInfo.NewPlay) |
45553d0f65c6
Don't let MPlayer directly call user interface functions.
ib
parents:
33691
diff
changeset
|
737 break; |
45553d0f65c6
Don't let MPlayer directly call user interface functions.
ib
parents:
33691
diff
changeset
|
738 |
45553d0f65c6
Don't let MPlayer directly call user interface functions.
ib
parents:
33691
diff
changeset
|
739 guiInfo.TimeSec = 0; |
45553d0f65c6
Don't let MPlayer directly call user interface functions.
ib
parents:
33691
diff
changeset
|
740 guiInfo.Position = 0; |
45553d0f65c6
Don't let MPlayer directly call user interface functions.
ib
parents:
33691
diff
changeset
|
741 guiInfo.AudioChannels = 0; |
45553d0f65c6
Don't let MPlayer directly call user interface functions.
ib
parents:
33691
diff
changeset
|
742 |
45553d0f65c6
Don't let MPlayer directly call user interface functions.
ib
parents:
33691
diff
changeset
|
743 #ifdef CONFIG_DVDREAD |
45553d0f65c6
Don't let MPlayer directly call user interface functions.
ib
parents:
33691
diff
changeset
|
744 guiInfo.DVD.current_title = 1; |
45553d0f65c6
Don't let MPlayer directly call user interface functions.
ib
parents:
33691
diff
changeset
|
745 guiInfo.DVD.current_chapter = 1; |
45553d0f65c6
Don't let MPlayer directly call user interface functions.
ib
parents:
33691
diff
changeset
|
746 guiInfo.DVD.current_angle = 1; |
45553d0f65c6
Don't let MPlayer directly call user interface functions.
ib
parents:
33691
diff
changeset
|
747 #endif |
45553d0f65c6
Don't let MPlayer directly call user interface functions.
ib
parents:
33691
diff
changeset
|
748 |
45553d0f65c6
Don't let MPlayer directly call user interface functions.
ib
parents:
33691
diff
changeset
|
749 if (mygui->playlist->current == (mygui->playlist->trackcount - 1)) |
45553d0f65c6
Don't let MPlayer directly call user interface functions.
ib
parents:
33691
diff
changeset
|
750 mygui->playlist->current = 0; |
45553d0f65c6
Don't let MPlayer directly call user interface functions.
ib
parents:
33691
diff
changeset
|
751 |
45553d0f65c6
Don't let MPlayer directly call user interface functions.
ib
parents:
33691
diff
changeset
|
752 fullscreen = 0; |
45553d0f65c6
Don't let MPlayer directly call user interface functions.
ib
parents:
33691
diff
changeset
|
753 if(style == WS_VISIBLE | WS_POPUP) |
45553d0f65c6
Don't let MPlayer directly call user interface functions.
ib
parents:
33691
diff
changeset
|
754 { |
45553d0f65c6
Don't let MPlayer directly call user interface functions.
ib
parents:
33691
diff
changeset
|
755 style = WS_OVERLAPPEDWINDOW | WS_SIZEBOX; |
45553d0f65c6
Don't let MPlayer directly call user interface functions.
ib
parents:
33691
diff
changeset
|
756 SetWindowLong(mygui->subwindow, GWL_STYLE, style); |
45553d0f65c6
Don't let MPlayer directly call user interface functions.
ib
parents:
33691
diff
changeset
|
757 } |
33731
81f71d910333
Cosmetic: Change prefix for symbolic constants from GMP to GUI.
ib
parents:
33730
diff
changeset
|
758 gui(GUI_SET_STATE, (void *) GUI_STOP); |
33694
45553d0f65c6
Don't let MPlayer directly call user interface functions.
ib
parents:
33691
diff
changeset
|
759 break; |
45553d0f65c6
Don't let MPlayer directly call user interface functions.
ib
parents:
33691
diff
changeset
|
760 } |
23077 | 761 default: |
33726 | 762 mp_msg(MSGT_GPLAYER, MSGL_ERR, "[GUI] GOT UNHANDLED EVENT %i\n", what); |
23077 | 763 } |
33666
0f592e8530f1
Change return code of guiGetEvent() to indicate success.
ib
parents:
33661
diff
changeset
|
764 return 1; |
23077 | 765 } |
766 | |
767 /* This function adds/inserts one file into the gui playlist */ | |
33579 | 768 static int import_file_into_gui(char *pathname, int insert) |
23077 | 769 { |
770 char filename[MAX_PATH]; | |
771 char *filepart = filename; | |
772 | |
773 if (strstr(pathname, "://")) | |
774 { | |
775 mp_msg(MSGT_GPLAYER, MSGL_V, "[GUI] Adding special %s\n", pathname); | |
776 mygui->playlist->add_track(mygui->playlist, pathname, NULL, NULL, 0); | |
777 return 1; | |
778 } | |
779 if (GetFullPathName(pathname, MAX_PATH, filename, &filepart)) | |
780 { | |
781 if (!(GetFileAttributes(filename) & FILE_ATTRIBUTE_DIRECTORY)) | |
782 { | |
783 mp_msg(MSGT_GPLAYER, MSGL_V, "[GUI] Adding filename: %s - fullpath: %s\n", filepart, filename); | |
784 mygui->playlist->add_track(mygui->playlist, filename, NULL, filepart, 0); | |
785 return 1; | |
786 } | |
787 else | |
788 mp_msg(MSGT_GPLAYER, MSGL_V, "[GUI] Cannot add %s\n", filename); | |
789 } | |
790 | |
791 return 0; | |
792 } | |
793 | |
794 /* This function imports the initial playtree (based on cmd-line files) into the gui playlist | |
795 by either: | |
796 - overwriting gui pl (enqueue=0) */ | |
797 | |
33752 | 798 int guiPlaylistInitialize(play_tree_t *my_playtree, m_config_t *config, int enqueue) |
23077 | 799 { |
800 play_tree_iter_t *my_pt_iter = NULL; | |
801 int result = 0; | |
802 | |
803 if(!mygui) guiInit(); | |
804 | |
805 if((my_pt_iter = pt_iter_create(&my_playtree, config))) | |
806 { | |
807 while ((filename = pt_iter_get_next_file(my_pt_iter)) != NULL) | |
808 { | |
809 if (parse_filename(filename, my_playtree, config, 0)) | |
810 result = 1; | |
811 else if (import_file_into_gui(filename, 0)) /* Add it to end of list */ | |
812 result = 1; | |
813 } | |
814 } | |
33555 | 815 uiGotoTheNext = 1; |
23077 | 816 |
817 if (result) | |
818 { | |
819 mygui->playlist->current = 0; | |
820 filename = mygui->playlist->tracks[0]->filename; | |
821 } | |
822 return result; | |
823 } | |
824 | |
825 /* This function imports and inserts an playtree, that is created "on the fly", for example by | |
826 parsing some MOV-Reference-File; or by loading an playlist with "File Open" | |
827 The file which contained the playlist is thereby replaced with it's contents. */ | |
828 | |
33752 | 829 int guiPlaylistAdd(play_tree_t *my_playtree, m_config_t *config) |
23077 | 830 { |
831 play_tree_iter_t *my_pt_iter = NULL; | |
832 int result = 0; | |
833 | |
834 if((my_pt_iter = pt_iter_create(&my_playtree, config))) | |
835 { | |
836 while ((filename = pt_iter_get_next_file(my_pt_iter)) != NULL) | |
837 if (import_file_into_gui(filename, 1)) /* insert it into the list and set plCurrent = new item */ | |
838 result = 1; | |
839 pt_iter_destroy(&my_pt_iter); | |
840 } | |
841 filename = NULL; | |
842 return result; | |
843 } | |
844 | |
33579 | 845 static inline void gtkMessageBox(int type, const char *str) |
23077 | 846 { |
847 if (type & GTK_MB_FATAL) | |
848 MessageBox(NULL, str, "MPlayer GUI for Windows Error", MB_OK | MB_ICONERROR); | |
849 | |
850 fprintf(stderr, "[GUI] MessageBox: %s\n", str); | |
851 fflush(stderr); | |
852 } | |
853 | |
854 static int update_subwindow(void) | |
855 { | |
856 int x,y; | |
857 RECT rd; | |
858 WINDOWPOS wp; | |
859 | |
860 if(!sub_window) | |
861 { | |
33567 | 862 WinID = -1; |
23077 | 863 |
33555 | 864 if(IsWindowVisible(mygui->subwindow) && guiInfo.sh_video && guiInfo.Playing) |
23077 | 865 { |
866 ShowWindow(mygui->subwindow, SW_HIDE); | |
867 return 0; | |
868 } | |
33679 | 869 else if(!guiInfo.MovieWindow) |
23077 | 870 return 0; |
871 else ShowWindow(mygui->subwindow, SW_SHOW); | |
872 } | |
873 | |
874 /* we've come out of fullscreen at the end of file */ | |
33679 | 875 if((!IsWindowVisible(mygui->subwindow) || IsIconic(mygui->subwindow)) && guiInfo.MovieWindow) |
23077 | 876 ShowWindow(mygui->subwindow, SW_SHOWNORMAL); |
877 | |
878 /* get our current window coordinates */ | |
879 GetWindowRect(mygui->subwindow, &rd); | |
880 | |
881 x = rd.left; | |
882 y = rd.top; | |
883 | |
884 /* restore sub window position when coming out of fullscreen */ | |
885 if(x <= 0) x = old_rect.left; | |
886 if(y <= 0) y = old_rect.top; | |
887 | |
33555 | 888 if(!guiInfo.Playing) |
23077 | 889 { |
890 window *desc = NULL; | |
891 int i; | |
892 | |
893 for (i=0; i<mygui->skin->windowcount; i++) | |
894 if(mygui->skin->windows[i]->type == wiSub) | |
895 desc = mygui->skin->windows[i]; | |
896 | |
897 rd.right = rd.left+desc->base->bitmap[0]->width; | |
898 rd.bottom = rd.top+desc->base->bitmap[0]->height; | |
899 sub_aspect = (float)(rd.right-rd.left)/(rd.bottom-rd.top); | |
900 } | |
901 else | |
902 { | |
33555 | 903 rd.right = rd.left+guiInfo.MovieWidth; |
904 rd.bottom = rd.top+guiInfo.MovieHeight; | |
23077 | 905 |
906 if (movie_aspect > 0.0) // forced aspect from the cmdline | |
907 sub_aspect = movie_aspect; | |
908 } | |
909 | |
910 | |
911 AdjustWindowRect(&rd, WS_OVERLAPPEDWINDOW | WS_SIZEBOX, 0); | |
912 SetWindowPos(mygui->subwindow, 0, x, y, rd.right-rd.left, rd.bottom-rd.top, SWP_NOOWNERZORDER); | |
913 | |
914 wp.hwnd = mygui->subwindow; | |
915 wp.x = rd.left; | |
916 wp.y = rd.top; | |
917 wp.cx = rd.right-rd.left; | |
918 wp.cy = rd.bottom-rd.top; | |
919 wp.flags = SWP_NOOWNERZORDER | SWP_SHOWWINDOW; | |
920 | |
921 /* erase the bitmap image if there's video */ | |
33615
1f9a31d4f114
Replace all playback integer constants by their symbolic constants.
ib
parents:
33614
diff
changeset
|
922 if(guiInfo.Playing != GUI_STOP && guiInfo.sh_video) |
23077 | 923 SendMessage(mygui->subwindow, WM_ERASEBKGND, (WPARAM)GetDC(mygui->subwindow), 0); |
924 | |
925 /* reset the window aspect */ | |
926 SendMessage(mygui->subwindow, WM_WINDOWPOSCHANGED, 0, (LPARAM)&wp); | |
927 return 0; | |
928 } |