annotate gui/mplayer/play.c @ 31366:0bf908d29807

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