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