Mercurial > mplayer.hg
annotate Gui/interface.c @ 7566:ab5984ab6af0
- demuxer->audio->id is set to -2 when using 'frameno.avi', so
in that case, just skip audio packets.
- When processing NuppelVideo files with mencoder,
remaining time, estimated size, etc. fields are not computed.
SOLUTION: Update demuxer->filepos variable when reading the packets.
patch by Petr Pudlak <wandermind@centrum.cz>
author | arpi |
---|---|
date | Mon, 30 Sep 2002 21:10:41 +0000 |
parents | c7b61f316edf |
children | 4a233f3b09a7 |
rev | line source |
---|---|
6280 | 1 |
4845 | 2 #include <inttypes.h> |
3 #include <stdlib.h> | |
4 #include <stdio.h> | |
4818
3473ca9ef158
new gui interface, and gtk moved into mplayer process. fork ... bleh :)
pontscho
parents:
4798
diff
changeset
|
5 #include <string.h> |
4798 | 6 |
7 #include "ws.h" | |
8 #include "mplayer/play.h" | |
9 #include "interface.h" | |
6619
f554e7271587
fix volume handling ( step 2 ) -- add balance support and some code cleanup and fix
pontscho
parents:
6280
diff
changeset
|
10 #include "skin/skin.h" |
6627 | 11 #include "mplayer/gtk/eq.h" |
4818
3473ca9ef158
new gui interface, and gtk moved into mplayer process. fork ... bleh :)
pontscho
parents:
4798
diff
changeset
|
12 |
4798 | 13 #include "../mplayer.h" |
4818
3473ca9ef158
new gui interface, and gtk moved into mplayer process. fork ... bleh :)
pontscho
parents:
4798
diff
changeset
|
14 #include "mplayer/widgets.h" |
3473ca9ef158
new gui interface, and gtk moved into mplayer process. fork ... bleh :)
pontscho
parents:
4798
diff
changeset
|
15 #include "mplayer/mplayer.h" |
3473ca9ef158
new gui interface, and gtk moved into mplayer process. fork ... bleh :)
pontscho
parents:
4798
diff
changeset
|
16 #include "app.h" |
6794 | 17 #include "cfg.h" |
18 #include "../help_mp.h" | |
19 #include "../subreader.h" | |
4818
3473ca9ef158
new gui interface, and gtk moved into mplayer process. fork ... bleh :)
pontscho
parents:
4798
diff
changeset
|
20 #include "../libvo/x11_common.h" |
5789 | 21 #include "../libvo/video_out.h" |
6794 | 22 #include "../libvo/font_load.h" |
7169 | 23 #include "../libvo/sub.h" |
4858 | 24 #include "../input/input.h" |
6619
f554e7271587
fix volume handling ( step 2 ) -- add balance support and some code cleanup and fix
pontscho
parents:
6280
diff
changeset
|
25 #include "../libao2/audio_out.h" |
6627 | 26 #include "../mixer.h" |
27 #include "../libao2/audio_plugin.h" | |
28 #include "../libao2/eq.h" | |
5789 | 29 |
6280 | 30 #include <inttypes.h> |
31 #include <sys/types.h> | |
32 | |
6996 | 33 #ifdef USE_ICONV |
7128 | 34 #include <iconv.h> |
6996 | 35 #endif |
36 | |
5665 | 37 #include "../libmpdemux/stream.h" |
5789 | 38 #include "../libmpdemux/demuxer.h" |
7217 | 39 #include "../libmpdemux/stheader.h" |
40 #include "../libmpcodecs/dec_video.h" | |
4818
3473ca9ef158
new gui interface, and gtk moved into mplayer process. fork ... bleh :)
pontscho
parents:
4798
diff
changeset
|
41 |
3473ca9ef158
new gui interface, and gtk moved into mplayer process. fork ... bleh :)
pontscho
parents:
4798
diff
changeset
|
42 guiInterface_t guiIntfStruct; |
3473ca9ef158
new gui interface, and gtk moved into mplayer process. fork ... bleh :)
pontscho
parents:
4798
diff
changeset
|
43 |
6627 | 44 char * gstrcat( char ** dest,char * src ) |
45 { | |
46 char * tmp = NULL; | |
47 | |
48 if ( !src ) return NULL; | |
49 | |
50 if ( *dest ) | |
51 { | |
52 tmp=malloc( strlen( *dest ) + strlen( src ) + 1 ); | |
53 strcpy( tmp,*dest ); strcat( tmp,src ); free( *dest ); | |
54 } | |
55 else | |
56 { tmp=malloc( strlen( src ) + 1 ); strcpy( tmp,src ); } | |
57 *dest=tmp; | |
58 return tmp; | |
59 } | |
60 | |
6794 | 61 int gstrcmp( char * a,char * b ) |
62 { | |
63 if ( !a && !b ) return 0; | |
64 if ( !a || !b ) return -1; | |
65 return strcmp( a,b ); | |
66 } | |
67 | |
7019 | 68 int gstrncmp( char * a,char * b,int size ) |
69 { | |
70 if ( !a && !b ) return 0; | |
71 if ( !a || !b ) return -1; | |
72 return strncmp( a,b,size ); | |
73 } | |
74 | |
6794 | 75 char * gstrdup( char * str ) |
76 { | |
77 if ( !str ) return NULL; | |
78 return strdup( str ); | |
79 } | |
80 | |
81 void gfree( void ** p ) | |
82 { | |
83 if ( *p == NULL ) return; | |
84 free( *p ); *p=NULL; | |
85 } | |
86 | |
87 void gset( char ** str,char * what ) | |
88 { | |
89 if ( *str ) { if ( !strstr( *str,what ) ) gstrcat( str,"," ); gstrcat( str,what ); } | |
90 else gstrcat( str,what ); | |
91 } | |
92 | |
6996 | 93 #ifdef USE_ICONV |
94 char * gconvert_uri_to_filename( char * str ) | |
95 { | |
96 iconv_t d; | |
97 char * out = strdup( str ); | |
98 char * tmp = NULL; | |
99 char * ize; | |
100 size_t inb,outb; | |
101 char * charset = "ISO8859-1"; | |
102 char * cs; | |
103 | |
104 if ( !strchr( str,'%' ) ) return str; | |
105 | |
106 { | |
107 char * t = calloc( 1,strlen( out ) ); | |
108 int i,c = 0; | |
109 for ( i=0;i < (int)strlen( out );i++ ) | |
110 if ( out[i] != '%' ) t[c++]=out[i]; | |
111 else | |
112 { | |
113 char tmp[4] = "0xXX"; | |
114 // if ( out[++i] == '%' ) { t[c++]='%'; continue; }; | |
115 tmp[2]=out[++i]; tmp[3]=out[++i]; | |
116 t[c++]=(char)strtol( tmp,(char **)NULL,0 ); | |
117 } | |
118 free( out ); | |
119 out=t; | |
120 } | |
121 | |
122 if ( (cs=getenv( "CHARSET" )) && *cs ) charset=cs; | |
123 | |
124 inb=outb=strlen( out ); | |
125 tmp=calloc( 1,outb + 1 ); | |
126 ize=tmp; | |
127 d=iconv_open( charset,"UTF-8" ); | |
128 if ( (iconv_t)(-1) == d ) return str; | |
129 iconv( d,&out,&inb,&tmp,&outb ); | |
130 iconv_close( d ); | |
131 free( out ); | |
132 return ize; | |
133 } | |
134 #endif | |
135 | |
6218 | 136 void guiInit( void ) |
4818
3473ca9ef158
new gui interface, and gtk moved into mplayer process. fork ... bleh :)
pontscho
parents:
4798
diff
changeset
|
137 { |
3473ca9ef158
new gui interface, and gtk moved into mplayer process. fork ... bleh :)
pontscho
parents:
4798
diff
changeset
|
138 memset( &guiIntfStruct,0,sizeof( guiIntfStruct ) ); |
6898 | 139 guiIntfStruct.Balance=50.0f; |
140 guiIntfStruct.StreamType=-1; | |
141 | |
6627 | 142 memset( >kEquChannels,0,sizeof( gtkEquChannels ) ); |
6794 | 143 gtkAOOSSMixer=strdup( PATH_DEV_MIXER ); |
144 gtkAOOSSDevice=strdup( PATH_DEV_DSP ); | |
7538 | 145 fullscreen=gtkLoadFullscreen; |
6898 | 146 |
147 gtkInit(); | |
6912 | 148 wsXInit( (void *)mDisplay ); |
149 | |
7019 | 150 // cfg_read(); |
6218 | 151 appInit( (void*)mDisplay ); |
7538 | 152 |
7009 | 153 if ( plCurrent && !filename ) mplSetFileName( plCurrent->path,plCurrent->name,STREAMTYPE_FILE ); |
6973 | 154 if ( sub_name ) guiSetFilename( guiIntfStruct.Subtitlename,sub_name ); |
6797
06d29dbdf20d
upsz, sorry, i forgott this :) (skin name saving:)
pontscho
parents:
6794
diff
changeset
|
155 #if defined( USE_OSD ) || defined( USE_SUB ) |
06d29dbdf20d
upsz, sorry, i forgott this :) (skin name saving:)
pontscho
parents:
6794
diff
changeset
|
156 guiLoadFont(); |
06d29dbdf20d
upsz, sorry, i forgott this :) (skin name saving:)
pontscho
parents:
6794
diff
changeset
|
157 #endif |
4818
3473ca9ef158
new gui interface, and gtk moved into mplayer process. fork ... bleh :)
pontscho
parents:
4798
diff
changeset
|
158 } |
3473ca9ef158
new gui interface, and gtk moved into mplayer process. fork ... bleh :)
pontscho
parents:
4798
diff
changeset
|
159 |
3473ca9ef158
new gui interface, and gtk moved into mplayer process. fork ... bleh :)
pontscho
parents:
4798
diff
changeset
|
160 void guiDone( void ) |
3473ca9ef158
new gui interface, and gtk moved into mplayer process. fork ... bleh :)
pontscho
parents:
4798
diff
changeset
|
161 { |
3473ca9ef158
new gui interface, and gtk moved into mplayer process. fork ... bleh :)
pontscho
parents:
4798
diff
changeset
|
162 mp_msg( MSGT_GPLAYER,MSGL_V,"[mplayer] exit.\n" ); |
6794 | 163 cfg_write(); |
4818
3473ca9ef158
new gui interface, and gtk moved into mplayer process. fork ... bleh :)
pontscho
parents:
4798
diff
changeset
|
164 gtkDone(); |
3473ca9ef158
new gui interface, and gtk moved into mplayer process. fork ... bleh :)
pontscho
parents:
4798
diff
changeset
|
165 wsXDone(); |
3473ca9ef158
new gui interface, and gtk moved into mplayer process. fork ... bleh :)
pontscho
parents:
4798
diff
changeset
|
166 } |
4798 | 167 |
4858 | 168 int guiCMDArray[] = |
169 { | |
170 evLoad, | |
171 evLoadSubtitle, | |
172 evAbout, | |
173 evPlay, | |
174 evStop, | |
175 evPlayList, | |
176 evPreferences, | |
177 evFullScreen, | |
178 evSkinBrowser | |
179 }; | |
180 | |
6619
f554e7271587
fix volume handling ( step 2 ) -- add balance support and some code cleanup and fix
pontscho
parents:
6280
diff
changeset
|
181 extern ao_functions_t * audio_out; |
6755 | 182 extern vo_functions_t * video_out; |
6794 | 183 extern int frame_dropping; |
184 extern int stream_dump_type; | |
185 extern char ** vo_plugin_args; | |
186 | |
187 #if defined( USE_OSD ) || defined( USE_SUB ) | |
188 void guiLoadFont( void ) | |
189 { | |
7122
0dc9cb756b68
freetype 2.0/2.1+ support - disabled by default until bugs fixed
arpi
parents:
7111
diff
changeset
|
190 #ifdef HAVE_FREETYPE |
0dc9cb756b68
freetype 2.0/2.1+ support - disabled by default until bugs fixed
arpi
parents:
7111
diff
changeset
|
191 load_font(vo_image_width, vo_image_height); |
0dc9cb756b68
freetype 2.0/2.1+ support - disabled by default until bugs fixed
arpi
parents:
7111
diff
changeset
|
192 #else |
6794 | 193 if ( vo_font ) |
194 { | |
195 int i; | |
196 if ( vo_font->name ) free( vo_font->name ); | |
197 if ( vo_font->fpath ) free( vo_font->fpath ); | |
198 for ( i=0;i<16;i++ ) | |
199 if ( vo_font->pic_a[i] ) | |
200 { | |
201 if ( vo_font->pic_a[i]->bmp ) free( vo_font->pic_a[i]->bmp ); | |
202 if ( vo_font->pic_a[i]->pal ) free( vo_font->pic_a[i]->pal ); | |
203 } | |
204 for ( i=0;i<16;i++ ) | |
205 if ( vo_font->pic_b[i] ) | |
206 { | |
207 if ( vo_font->pic_b[i]->bmp ) free( vo_font->pic_b[i]->bmp ); | |
208 if ( vo_font->pic_b[i]->pal ) free( vo_font->pic_b[i]->pal ); | |
209 } | |
210 free( vo_font ); vo_font=NULL; | |
211 } | |
7019 | 212 if ( font_name ) |
6794 | 213 { |
7019 | 214 vo_font=read_font_desc( font_name,font_factor,0 ); |
6794 | 215 if ( !vo_font ) mp_msg( MSGT_CPLAYER,MSGL_ERR,MSGTR_CantLoadFont,font_name ); |
216 } | |
217 else | |
218 { | |
7019 | 219 font_name=gstrdup( get_path( "font/font.desc" ) ); |
220 vo_font=read_font_desc( font_name,font_factor,0 ); | |
6794 | 221 if ( !vo_font ) |
222 { | |
7019 | 223 gfree( (void **)&font_name ); font_name=gstrdup( DATADIR"/font/font.desc" ); |
224 vo_font=read_font_desc( font_name,font_factor,0 ); | |
6794 | 225 } |
226 } | |
7122
0dc9cb756b68
freetype 2.0/2.1+ support - disabled by default until bugs fixed
arpi
parents:
7111
diff
changeset
|
227 #endif |
6794 | 228 } |
229 #endif | |
6619
f554e7271587
fix volume handling ( step 2 ) -- add balance support and some code cleanup and fix
pontscho
parents:
6280
diff
changeset
|
230 |
7150 | 231 #ifdef USE_SUB |
7169 | 232 extern mp_osd_obj_t* vo_osd_list; |
233 | |
7150 | 234 void guiLoadSubtitle( char * name ) |
235 { | |
236 if ( guiIntfStruct.Playing == 0 ) | |
237 { | |
238 guiIntfStruct.SubtitleChanged=1; | |
239 return; | |
240 } | |
241 if ( subtitles ) | |
242 { | |
7169 | 243 mp_msg( MSGT_GPLAYER,MSGL_INFO,"[gui] Delete subtitles.\n" ); |
7150 | 244 sub_free( subtitles ); |
7169 | 245 subtitles=NULL; |
7170 | 246 gfree( (void **)&sub_name ); |
7150 | 247 vo_sub=NULL; |
7169 | 248 if ( vo_osd_list ) |
249 { | |
250 int len; | |
251 mp_osd_obj_t * osd = vo_osd_list; | |
252 while ( osd ) | |
253 { | |
254 if ( osd->type == OSDTYPE_SUBTITLE ) break; | |
255 osd=osd->next; | |
256 } | |
257 if ( osd && osd->flags&OSDFLAG_VISIBLE ) | |
258 { | |
259 len=osd->stride * ( osd->bbox.y2 - osd->bbox.y1 ); | |
260 memset( osd->bitmap_buffer,0,len ); | |
261 memset( osd->alpha_buffer,0,len ); | |
262 } | |
263 } | |
7150 | 264 } |
7169 | 265 if ( name ) |
266 { | |
267 mp_msg( MSGT_GPLAYER,MSGL_INFO,"[gui] Delete Load subtitle: %s\n",name ); | |
268 sub_name=gstrdup( name ); | |
269 subtitles=sub_read_file( sub_name,guiIntfStruct.FPS ); | |
270 } | |
7150 | 271 } |
272 #endif | |
273 | |
7009 | 274 static void add_vop( char * str ) |
275 { | |
276 mp_msg( MSGT_GPLAYER,MSGL_STATUS,"[gui] add video filter: %s\n",str ); | |
277 if ( vo_plugin_args ) | |
278 { | |
279 int i = 0; | |
280 while ( vo_plugin_args[i] ) if ( !gstrcmp( vo_plugin_args[i++],str ) ) { i=-1; break; } | |
281 if ( i != -1 ) | |
282 { vo_plugin_args=realloc( vo_plugin_args,( i + 2 ) * sizeof( char * ) ); vo_plugin_args[i]=strdup( str ); vo_plugin_args[i+1]=NULL; } | |
283 } else { vo_plugin_args=malloc( 2 * sizeof( char * ) ); vo_plugin_args[0]=strdup( str ); vo_plugin_args[1]=NULL; } | |
284 } | |
285 | |
286 static void remove_vop( char * str ) | |
287 { | |
288 int n = 0; | |
289 | |
290 if ( !vo_plugin_args ) return; | |
291 | |
292 mp_msg( MSGT_GPLAYER,MSGL_STATUS,"[gui] remove video filter: %s\n",str ); | |
293 | |
294 while ( vo_plugin_args[n++] ); n--; | |
295 if ( n > -1 ) | |
296 { | |
297 int i = 0,m = -1; | |
298 while ( vo_plugin_args[i] ) if ( !gstrcmp( vo_plugin_args[i++],str ) ) { m=i - 1; break; } | |
299 i--; | |
300 if ( m > -1 ) | |
301 { | |
302 if ( n == 1 ) { free( vo_plugin_args[0] ); free( vo_plugin_args ); vo_plugin_args=NULL; } | |
303 else memcpy( &vo_plugin_args[i],&vo_plugin_args[i + 1],( n - i ) * sizeof( char * ) ); | |
304 } | |
305 } | |
306 } | |
307 | |
308 int guiGetEvent( int type,char * arg ) | |
4798 | 309 { |
6280 | 310 stream_t * stream = (stream_t *) arg; |
5672
1f8b34f1e7c0
ifdef reading dvd args, without it non-dvd compilation fails.
eyck
parents:
5665
diff
changeset
|
311 #ifdef USE_DVDREAD |
5665 | 312 dvd_priv_t * dvdp = (dvd_priv_t *) arg; |
5672
1f8b34f1e7c0
ifdef reading dvd args, without it non-dvd compilation fails.
eyck
parents:
5665
diff
changeset
|
313 #endif |
6619
f554e7271587
fix volume handling ( step 2 ) -- add balance support and some code cleanup and fix
pontscho
parents:
6280
diff
changeset
|
314 |
4798 | 315 switch ( type ) |
316 { | |
317 case guiXEvent: | |
318 wsEvents( wsDisplay,(XEvent *)arg,NULL ); | |
4818
3473ca9ef158
new gui interface, and gtk moved into mplayer process. fork ... bleh :)
pontscho
parents:
4798
diff
changeset
|
319 gtkEventHandling(); |
3473ca9ef158
new gui interface, and gtk moved into mplayer process. fork ... bleh :)
pontscho
parents:
4798
diff
changeset
|
320 break; |
4798 | 321 case guiCEvent: |
4963 | 322 switch ( (int)arg ) |
323 { | |
324 case guiSetPlay: guiIntfStruct.Playing=1; mplState(); break; | |
325 case guiSetStop: guiIntfStruct.Playing=0; mplState(); break; | |
326 case guiSetPause: guiIntfStruct.Playing=2; mplState(); break; | |
327 } | |
4818
3473ca9ef158
new gui interface, and gtk moved into mplayer process. fork ... bleh :)
pontscho
parents:
4798
diff
changeset
|
328 break; |
5665 | 329 case guiSetState: |
330 mplState(); | |
331 break; | |
332 case guiSetFileName: | |
333 if ( arg ) guiSetFilename( guiIntfStruct.Filename,arg ); | |
334 break; | |
5789 | 335 case guiSetAudioOnly: |
336 guiIntfStruct.AudioOnly=(int)arg; | |
7009 | 337 if ( (int)arg ) { guiIntfStruct.NoWindow=True; wsVisibleWindow( &appMPlayer.subWindow,wsHideWindow ); } |
5789 | 338 else wsVisibleWindow( &appMPlayer.subWindow,wsShowWindow ); |
339 break; | |
340 case guiReDrawSubWindow: | |
341 wsPostRedisplay( &appMPlayer.subWindow ); | |
342 break; | |
343 case guiSetShVideo: | |
344 { | |
5986 | 345 if ( !appMPlayer.subWindow.isFullScreen ) |
346 { | |
347 wsResizeWindow( &appMPlayer.subWindow,vo_dwidth,vo_dheight ); | |
348 wsMoveWindow( &appMPlayer.subWindow,True,appMPlayer.sub.x,appMPlayer.sub.y ); | |
349 } | |
5955
caac20b1ca79
fix xmga fs, resize to movie size and mouse auto hide + dga
pontscho
parents:
5945
diff
changeset
|
350 guiIntfStruct.MovieWidth=vo_dwidth; |
5997
b5fb9a927bf3
add WM detection, and wm specific fullscreen code. (???)
pontscho
parents:
5986
diff
changeset
|
351 guiIntfStruct.MovieHeight=vo_dheight; |
5789 | 352 } |
353 break; | |
5665 | 354 #ifdef USE_DVDREAD |
355 case guiSetDVD: | |
356 guiIntfStruct.DVD.titles=dvdp->vmg_file->tt_srpt->nr_of_srpts; | |
357 guiIntfStruct.DVD.chapters=dvdp->vmg_file->tt_srpt->title[dvd_title].nr_of_ptts; | |
358 guiIntfStruct.DVD.angles=dvdp->vmg_file->tt_srpt->title[dvd_title].nr_of_angles; | |
359 guiIntfStruct.DVD.nr_of_audio_channels=dvdp->nr_of_channels; | |
360 memcpy( guiIntfStruct.DVD.audio_streams,dvdp->audio_streams,sizeof( dvdp->audio_streams ) ); | |
361 guiIntfStruct.DVD.nr_of_subtitles=dvdp->nr_of_subtitles; | |
362 memcpy( guiIntfStruct.DVD.subtitles,dvdp->subtitles,sizeof( dvdp->subtitles ) ); | |
363 guiIntfStruct.DVD.current_title=dvd_title + 1; | |
364 guiIntfStruct.DVD.current_chapter=dvd_chapter + 1; | |
365 guiIntfStruct.DVD.current_angle=dvd_angle + 1; | |
366 guiIntfStruct.Track=dvd_title + 1; | |
367 break; | |
368 #endif | |
6280 | 369 case guiSetStream: |
370 guiIntfStruct.StreamType=stream->type; | |
371 switch( stream->type ) | |
372 { | |
7150 | 373 #ifdef USE_DVDREAD |
6280 | 374 case STREAMTYPE_DVD: |
375 guiGetEvent( guiSetDVD,(char *)stream->priv ); | |
376 break; | |
7150 | 377 #endif |
6280 | 378 #ifdef HAVE_VCD |
379 case STREAMTYPE_VCD: | |
380 { | |
381 int i; | |
382 for ( i=1;i < 100;i++ ) | |
383 if ( vcd_seek_to_track( stream->fd,i ) < 0 ) break; | |
384 vcd_seek_to_track( stream->fd,vcd_track ); | |
385 guiIntfStruct.VCDTracks=--i; | |
386 mp_msg( MSGT_GPLAYER,MSGL_INFO,"[interface] vcd tracks: %d\n",guiIntfStruct.VCDTracks ); | |
387 guiIntfStruct.Track=vcd_track; | |
388 break; | |
389 } | |
390 #endif | |
7150 | 391 default: break; |
6280 | 392 } |
393 break; | |
4858 | 394 case guiIEvent: |
395 printf( "cmd: %d\n",(int)arg ); | |
396 switch( (int)arg ) | |
397 { | |
398 case MP_CMD_QUIT: | |
399 mplEventHandling( evExit,0 ); | |
400 break; | |
401 case MP_CMD_VO_FULLSCREEN: | |
402 mplEventHandling( evFullScreen,0 ); | |
403 break; | |
404 default: | |
405 mplEventHandling( guiCMDArray[ (int)arg - MP_CMD_GUI_EVENTS - 1 ],0 ); | |
406 } | |
407 break; | |
6619
f554e7271587
fix volume handling ( step 2 ) -- add balance support and some code cleanup and fix
pontscho
parents:
6280
diff
changeset
|
408 case guiReDraw: |
f554e7271587
fix volume handling ( step 2 ) -- add balance support and some code cleanup and fix
pontscho
parents:
6280
diff
changeset
|
409 mplEventHandling( evRedraw,0 ); |
f554e7271587
fix volume handling ( step 2 ) -- add balance support and some code cleanup and fix
pontscho
parents:
6280
diff
changeset
|
410 break; |
f554e7271587
fix volume handling ( step 2 ) -- add balance support and some code cleanup and fix
pontscho
parents:
6280
diff
changeset
|
411 case guiSetVolume: |
6903 | 412 if ( audio_out ) |
413 { | |
414 float l,r; | |
415 mixer_getvolume( &l,&r ); | |
416 guiIntfStruct.Volume=(r>l?r:l); | |
417 if ( r != l ) guiIntfStruct.Balance=( ( r - l ) + 100 ) * 0.5f; | |
418 else guiIntfStruct.Balance=50.0f; | |
419 btnModify( evSetVolume,guiIntfStruct.Volume ); | |
420 btnModify( evSetBalance,guiIntfStruct.Balance ); | |
421 } | |
422 break; | |
7009 | 423 case guiSetFileFormat: |
424 guiIntfStruct.FileFormat=(int)arg; | |
425 break; | |
6903 | 426 case guiSetValues: |
6912 | 427 // -- video |
7217 | 428 guiIntfStruct.sh_video=arg; |
6912 | 429 if ( arg ) |
430 { | |
7217 | 431 sh_video_t * sh = (sh_video_t *)arg; |
7150 | 432 guiIntfStruct.FPS=sh->fps; |
6912 | 433 } |
7009 | 434 |
435 if ( guiIntfStruct.NoWindow ) wsVisibleWindow( &appMPlayer.subWindow,wsHideWindow ); | |
436 | |
6794 | 437 // -- audio |
6619
f554e7271587
fix volume handling ( step 2 ) -- add balance support and some code cleanup and fix
pontscho
parents:
6280
diff
changeset
|
438 if ( audio_out ) |
f554e7271587
fix volume handling ( step 2 ) -- add balance support and some code cleanup and fix
pontscho
parents:
6280
diff
changeset
|
439 { |
f554e7271587
fix volume handling ( step 2 ) -- add balance support and some code cleanup and fix
pontscho
parents:
6280
diff
changeset
|
440 float l,r; |
f554e7271587
fix volume handling ( step 2 ) -- add balance support and some code cleanup and fix
pontscho
parents:
6280
diff
changeset
|
441 mixer_getvolume( &l,&r ); |
f554e7271587
fix volume handling ( step 2 ) -- add balance support and some code cleanup and fix
pontscho
parents:
6280
diff
changeset
|
442 guiIntfStruct.Volume=(r>l?r:l); |
f554e7271587
fix volume handling ( step 2 ) -- add balance support and some code cleanup and fix
pontscho
parents:
6280
diff
changeset
|
443 if ( r != l ) guiIntfStruct.Balance=( ( r - l ) + 100 ) * 0.5f; |
6627 | 444 else guiIntfStruct.Balance=50.0f; |
6619
f554e7271587
fix volume handling ( step 2 ) -- add balance support and some code cleanup and fix
pontscho
parents:
6280
diff
changeset
|
445 btnModify( evSetVolume,guiIntfStruct.Volume ); |
f554e7271587
fix volume handling ( step 2 ) -- add balance support and some code cleanup and fix
pontscho
parents:
6280
diff
changeset
|
446 btnModify( evSetBalance,guiIntfStruct.Balance ); |
f554e7271587
fix volume handling ( step 2 ) -- add balance support and some code cleanup and fix
pontscho
parents:
6280
diff
changeset
|
447 } |
6627 | 448 |
6794 | 449 if ( gtkAONoSound ) { if ( !muted ) mixer_mute(); } |
450 else if ( muted ) mixer_mute(); | |
451 | |
6627 | 452 if ( gtkEnableAudioEqualizer ) |
453 { | |
454 equalizer_t eq; | |
455 int i,j; | |
456 for ( i=0;i<6;i++ ) | |
457 for ( j=0;j<10;j++ ) | |
458 { | |
459 eq.channel=i; eq.band=j; eq.gain=gtkEquChannels[i][j]; | |
460 gtkSet( gtkSetEqualizer,0,&eq ); | |
461 } | |
462 } | |
6794 | 463 // -- subtitle |
7009 | 464 #ifdef HAVE_DXR3 |
7019 | 465 if ( !gstrcmp( video_driver,"dxr3" ) && guiIntfStruct.FileFormat != DEMUXER_TYPE_MPEG_PS && !gtkVopLAVC && !gtkVopFAME ) |
7009 | 466 { |
467 gtkMessageBox( GTK_MB_FATAL,MSGTR_NEEDLAVCFAME ); | |
468 guiIntfStruct.Playing=0; | |
469 return True; | |
470 } | |
471 #endif | |
6627 | 472 break; |
473 case guiSetDefaults: | |
6857 | 474 if ( filename && !guiIntfStruct.Filename ) |
6794 | 475 { |
476 gtkSet( gtkDelPl,0,NULL ); guiIntfStruct.StreamType=STREAMTYPE_FILE; | |
477 guiSetFilename( guiIntfStruct.Filename,filename ); | |
478 } | |
479 | |
480 guiIntfStruct.DiskChanged=0; | |
481 | |
7009 | 482 // --- video opts |
7019 | 483 |
484 if ( !video_driver ) | |
6794 | 485 { |
6797
06d29dbdf20d
upsz, sorry, i forgott this :) (skin name saving:)
pontscho
parents:
6794
diff
changeset
|
486 int i = 0; |
6903 | 487 while ( video_out_drivers[i++] ) |
488 if ( video_out_drivers[i - 1]->control( VOCTRL_GUISUPPORT,NULL ) == VO_TRUE ) | |
489 { | |
490 const vo_info_t *info = video_out_drivers[i - 1]->get_info(); | |
7019 | 491 video_driver=gstrdup( (char *)info->short_name ); |
6903 | 492 break; |
493 } | |
6794 | 494 } |
495 | |
7019 | 496 if ( !video_driver ) { gtkMessageBox( GTK_MB_FATAL,MSGTR_IDFGCVD ); exit_player( "gui init" ); } |
7009 | 497 |
498 { | |
499 int i = 0; | |
500 guiIntfStruct.NoWindow=False; | |
501 while ( video_out_drivers[i++] ) | |
502 if ( video_out_drivers[i - 1]->control( VOCTRL_GUISUPPORT,NULL ) == VO_TRUE ) | |
6794 | 503 { |
7009 | 504 const vo_info_t *info = video_out_drivers[i - 1]->get_info(); |
7019 | 505 if ( ( !gstrcmp( video_driver,(char *)info->short_name ) )&&( video_out_drivers[i - 1]->control( VOCTRL_GUI_NOWINDOW,NULL ) == VO_TRUE ) ) |
7009 | 506 { guiIntfStruct.NoWindow=True; break; } |
6794 | 507 } |
7009 | 508 } |
509 | |
510 #ifdef HAVE_DXR3 | |
511 remove_vop( "lavc" ); | |
512 remove_vop( "fame" ); | |
7019 | 513 if ( !gstrcmp( video_driver,"dxr3" ) ) |
7009 | 514 { |
515 if ( ( guiIntfStruct.StreamType != STREAMTYPE_DVD)&&( guiIntfStruct.StreamType != STREAMTYPE_VCD ) ) | |
516 { | |
517 if ( gtkVopLAVC ) add_vop( "lavc" ); | |
518 if ( gtkVopFAME ) add_vop( "fame" ); | |
519 } | |
520 } | |
521 #endif | |
522 // --- | |
7019 | 523 if ( gtkVopPP ) add_vop( "pp" ); |
524 else remove_vop( "pp" ); | |
6794 | 525 |
526 // --- audio opts | |
527 audio_delay=gtkAODelay; | |
528 if ( ao_plugin_cfg.plugin_list ) { free( ao_plugin_cfg.plugin_list ); ao_plugin_cfg.plugin_list=NULL; } | |
6840 | 529 if ( gtkAONorm ) gset( &ao_plugin_cfg.plugin_list,"volnorm" ); |
6794 | 530 if ( gtkEnableAudioEqualizer ) gset( &ao_plugin_cfg.plugin_list,"eq" ); |
531 if ( gtkAOExtraStereo ) | |
532 { | |
533 gset( &ao_plugin_cfg.plugin_list,"extrastereo" ); | |
534 ao_plugin_cfg.pl_extrastereo_mul=gtkAOExtraStereoMul; | |
535 } | |
536 mixer_device=gtkAOOSSMixer; | |
7019 | 537 if ( !gstrncmp( audio_driver,"oss",3 ) && gtkAOOSSDevice ) |
6794 | 538 { |
7019 | 539 char * tmp = calloc( 1,strlen( gtkAOOSSDevice ) + 5 ); |
540 sprintf( tmp,"oss:%s",gtkAOOSSDevice ); | |
541 gfree( (void *)&audio_driver ); | |
6794 | 542 audio_driver=tmp; |
7019 | 543 } |
6794 | 544 |
545 // -- subtitle | |
546 #ifdef USE_SUB | |
7170 | 547 sub_name=gstrdup( guiIntfStruct.Subtitlename ); |
6794 | 548 stream_dump_type=0; |
549 if ( gtkSubDumpMPSub ) stream_dump_type=4; | |
550 if ( gtkSubDumpSrt ) stream_dump_type=6; | |
551 gtkSubDumpMPSub=gtkSubDumpSrt=0; | |
6627 | 552 #endif |
6794 | 553 #if defined( USE_OSD ) || defined( USE_SUB ) |
554 guiLoadFont(); | |
6627 | 555 #endif |
556 | |
6794 | 557 // --- misc |
6627 | 558 if ( guiIntfStruct.AudioFile ) audio_stream=guiIntfStruct.AudioFile; |
559 else if ( guiIntfStruct.FilenameChanged ) audio_stream=NULL; | |
560 | |
561 break; | |
4798 | 562 } |
7009 | 563 return False; |
4798 | 564 } |
565 | |
6619
f554e7271587
fix volume handling ( step 2 ) -- add balance support and some code cleanup and fix
pontscho
parents:
6280
diff
changeset
|
566 extern unsigned int GetTimerMS( void ); |
f554e7271587
fix volume handling ( step 2 ) -- add balance support and some code cleanup and fix
pontscho
parents:
6280
diff
changeset
|
567 extern int mplTimer; |
f554e7271587
fix volume handling ( step 2 ) -- add balance support and some code cleanup and fix
pontscho
parents:
6280
diff
changeset
|
568 |
4798 | 569 void guiEventHandling( void ) |
570 { | |
7009 | 571 if ( !guiIntfStruct.Playing || guiIntfStruct.NoWindow ) wsHandleEvents(); |
4818
3473ca9ef158
new gui interface, and gtk moved into mplayer process. fork ... bleh :)
pontscho
parents:
4798
diff
changeset
|
572 gtkEventHandling(); |
6619
f554e7271587
fix volume handling ( step 2 ) -- add balance support and some code cleanup and fix
pontscho
parents:
6280
diff
changeset
|
573 mplTimer=GetTimerMS() / 20; |
4798 | 574 } |
6627 | 575 |
576 // --- | |
577 | |
578 float gtkEquChannels[6][10]; | |
579 | |
6713 | 580 plItem * plCurrent = NULL; |
581 plItem * plList = NULL; | |
582 plItem * plLastPlayed = NULL; | |
583 | |
7092
8e9607c5897e
- warning fixes from Dominik Mierzejewski <dominik@rangers.eu.org>
pontscho
parents:
7019
diff
changeset
|
584 URLItem *URLList = NULL; |
8e9607c5897e
- warning fixes from Dominik Mierzejewski <dominik@rangers.eu.org>
pontscho
parents:
7019
diff
changeset
|
585 |
6713 | 586 #if defined( MP_DEBUG ) && 0 |
587 void list( void ) | |
6627 | 588 { |
6713 | 589 plItem * next = plList; |
590 printf( "--- list ---\n" ); | |
591 while( next || next->next ) | |
592 { | |
593 printf( "item: %s/%s\n",next->path,next->name ); | |
594 if ( next->next ) next=next->next; else break; | |
595 } | |
596 printf( "--- end of list ---\n" ); | |
597 } | |
598 #else | |
599 #define list(); | |
600 #endif | |
601 | |
602 void * gtkSet( int cmd,float fparam, void * vparam ) | |
603 { | |
6627 | 604 equalizer_t * eq = (equalizer_t *)vparam; |
6713 | 605 plItem * item = (plItem *)vparam; |
6627 | 606 |
7092
8e9607c5897e
- warning fixes from Dominik Mierzejewski <dominik@rangers.eu.org>
pontscho
parents:
7019
diff
changeset
|
607 URLItem * url_item = (URLItem *)vparam; |
8e9607c5897e
- warning fixes from Dominik Mierzejewski <dominik@rangers.eu.org>
pontscho
parents:
7019
diff
changeset
|
608 int is_added = True; |
8e9607c5897e
- warning fixes from Dominik Mierzejewski <dominik@rangers.eu.org>
pontscho
parents:
7019
diff
changeset
|
609 |
6627 | 610 switch ( cmd ) |
611 { | |
6713 | 612 // --- handle playlist |
6755 | 613 case gtkAddPlItem: // add item to playlist |
6713 | 614 if ( plList ) |
615 { | |
616 plItem * next = plList; | |
617 while ( next->next ) { /*printf( "%s\n",next->name );*/ next=next->next; } | |
618 next->next=item; item->prev=next; | |
7092
8e9607c5897e
- warning fixes from Dominik Mierzejewski <dominik@rangers.eu.org>
pontscho
parents:
7019
diff
changeset
|
619 } else { item->prev=item->next=NULL; plCurrent=plList=item; } |
6713 | 620 list(); |
621 return NULL; | |
622 case gtkGetNextPlItem: // get current item from playlist | |
623 if ( plCurrent ) | |
624 { | |
625 plCurrent=plCurrent->next; | |
626 if ( !plCurrent && plList ) | |
627 { | |
628 plItem * next = plList; | |
629 while ( next->next ) { if ( !next->next ) break; next=next->next; } | |
630 plCurrent=next; | |
631 } | |
632 return plCurrent; | |
633 } | |
634 return NULL; | |
635 case gtkGetPrevPlItem: | |
636 if ( plCurrent ) | |
637 { | |
638 plCurrent=plCurrent->prev; | |
639 if ( !plCurrent && plList ) plCurrent=plList; | |
640 return plCurrent; | |
641 } | |
6794 | 642 return NULL; |
6713 | 643 case gtkGetCurrPlItem: // get current item |
644 return plCurrent; | |
645 case gtkDelPl: // delete list | |
646 { | |
647 plItem * curr = plList; | |
648 plItem * next; | |
649 if ( !plList ) return NULL; | |
650 if ( !curr->next ) | |
651 { | |
652 if ( curr->path ) free( curr->path ); | |
653 if ( curr->name ) free( curr->name ); | |
654 free( curr ); | |
655 } | |
656 else | |
657 { | |
658 while ( curr->next ) | |
659 { | |
660 next=curr->next; | |
661 if ( curr->path ) free( curr->path ); | |
662 if ( curr->name ) free( curr->name ); | |
663 free( curr ); | |
664 curr=next; | |
665 } | |
666 } | |
667 plList=NULL; plCurrent=NULL; | |
668 } | |
669 return NULL; | |
7092
8e9607c5897e
- warning fixes from Dominik Mierzejewski <dominik@rangers.eu.org>
pontscho
parents:
7019
diff
changeset
|
670 // ----- Handle url |
8e9607c5897e
- warning fixes from Dominik Mierzejewski <dominik@rangers.eu.org>
pontscho
parents:
7019
diff
changeset
|
671 case gtkAddURLItem: |
8e9607c5897e
- warning fixes from Dominik Mierzejewski <dominik@rangers.eu.org>
pontscho
parents:
7019
diff
changeset
|
672 if ( URLList ) |
8e9607c5897e
- warning fixes from Dominik Mierzejewski <dominik@rangers.eu.org>
pontscho
parents:
7019
diff
changeset
|
673 { |
8e9607c5897e
- warning fixes from Dominik Mierzejewski <dominik@rangers.eu.org>
pontscho
parents:
7019
diff
changeset
|
674 URLItem * next_url = URLList; |
8e9607c5897e
- warning fixes from Dominik Mierzejewski <dominik@rangers.eu.org>
pontscho
parents:
7019
diff
changeset
|
675 is_added = False; |
8e9607c5897e
- warning fixes from Dominik Mierzejewski <dominik@rangers.eu.org>
pontscho
parents:
7019
diff
changeset
|
676 while ( next_url->next ) |
8e9607c5897e
- warning fixes from Dominik Mierzejewski <dominik@rangers.eu.org>
pontscho
parents:
7019
diff
changeset
|
677 { |
8e9607c5897e
- warning fixes from Dominik Mierzejewski <dominik@rangers.eu.org>
pontscho
parents:
7019
diff
changeset
|
678 if ( !gstrcmp( next_url->url,url_item->url ) ) |
8e9607c5897e
- warning fixes from Dominik Mierzejewski <dominik@rangers.eu.org>
pontscho
parents:
7019
diff
changeset
|
679 { |
8e9607c5897e
- warning fixes from Dominik Mierzejewski <dominik@rangers.eu.org>
pontscho
parents:
7019
diff
changeset
|
680 is_added=True; |
8e9607c5897e
- warning fixes from Dominik Mierzejewski <dominik@rangers.eu.org>
pontscho
parents:
7019
diff
changeset
|
681 break; |
8e9607c5897e
- warning fixes from Dominik Mierzejewski <dominik@rangers.eu.org>
pontscho
parents:
7019
diff
changeset
|
682 } |
8e9607c5897e
- warning fixes from Dominik Mierzejewski <dominik@rangers.eu.org>
pontscho
parents:
7019
diff
changeset
|
683 next_url=next_url->next; |
8e9607c5897e
- warning fixes from Dominik Mierzejewski <dominik@rangers.eu.org>
pontscho
parents:
7019
diff
changeset
|
684 } |
8e9607c5897e
- warning fixes from Dominik Mierzejewski <dominik@rangers.eu.org>
pontscho
parents:
7019
diff
changeset
|
685 if ( ( !is_added )&&( gstrcmp( next_url->url,url_item->url ) ) ) next_url->next=url_item; |
8e9607c5897e
- warning fixes from Dominik Mierzejewski <dominik@rangers.eu.org>
pontscho
parents:
7019
diff
changeset
|
686 } else { url_item->next=NULL; URLList=url_item; } |
8e9607c5897e
- warning fixes from Dominik Mierzejewski <dominik@rangers.eu.org>
pontscho
parents:
7019
diff
changeset
|
687 return NULL; |
6794 | 688 // --- subtitle |
689 case gtkSetSubAuto: | |
7019 | 690 sub_auto=(int)fparam; |
6794 | 691 return NULL; |
692 case gtkSetSubDelay: | |
7019 | 693 sub_delay=fparam; |
6794 | 694 return NULL; |
695 case gtkSetSubFPS: | |
7019 | 696 sub_fps=(int)fparam; |
6794 | 697 return NULL; |
698 case gtkSetSubPos: | |
7019 | 699 sub_pos=(int)fparam; |
6794 | 700 return NULL; |
701 #if defined( USE_OSD ) || defined( USE_SUB ) | |
7139 | 702 #ifndef HAVE_FREETYPE |
6794 | 703 case gtkSetFontFactor: |
7019 | 704 font_factor=fparam; |
6794 | 705 guiLoadFont(); |
706 return NULL; | |
7139 | 707 #else |
708 case gtkSetFontOutLine: | |
709 subtitle_font_thickness=( 8.0f / 100.0f ) * fparam; | |
710 guiLoadFont(); | |
711 return NULL; | |
712 case gtkSetFontBlur: | |
713 subtitle_font_radius=( 8.0f / 100.0f ) * fparam; | |
714 guiLoadFont(); | |
715 return NULL; | |
716 case gtkSetFontTextScale: | |
717 text_font_scale_factor=fparam; | |
718 guiLoadFont(); | |
719 return NULL; | |
720 case gtkSetFontOSDScale: | |
721 osd_font_scale_factor=fparam; | |
722 guiLoadFont(); | |
723 return NULL; | |
724 case gtkSetFontEncoding: | |
725 if ( subtitle_font_encoding ) free( subtitle_font_encoding ); | |
726 subtitle_font_encoding=gstrdup( (char *)vparam ); | |
727 guiLoadFont(); | |
728 return NULL; | |
729 case gtkSetFontAutoScale: | |
730 subtitle_autoscale=(int)fparam; | |
731 guiLoadFont(); | |
732 return NULL; | |
733 #endif | |
6794 | 734 #endif |
735 // --- misc | |
736 case gtkClearStruct: | |
7009 | 737 if ( (unsigned int)vparam & guiFilenames ) |
6794 | 738 { |
739 gfree( (void **)&guiIntfStruct.Filename ); | |
740 gfree( (void **)&guiIntfStruct.Subtitlename ); | |
741 gfree( (void **)&guiIntfStruct.AudioFile ); | |
7009 | 742 gtkSet( gtkDelPl,0,NULL ); |
6794 | 743 } |
744 #ifdef USE_DVDREAD | |
7009 | 745 if ( (unsigned int)vparam & guiDVD ) memset( &guiIntfStruct.DVD,0,sizeof( guiDVDStruct ) ); |
6794 | 746 #endif |
747 #ifdef HAVE_VCD | |
7009 | 748 if ( (unsigned int)vparam & guiVCD ) guiIntfStruct.VCDTracks=0; |
6794 | 749 #endif |
750 return NULL; | |
7526 | 751 case gtkSetCacheSize: |
752 stream_cache_size=(int)fparam; | |
753 return NULL; | |
6794 | 754 case gtkSetExtraStereo: |
755 gtkAOExtraStereoMul=fparam; | |
756 audio_plugin_extrastereo.control( AOCONTROL_PLUGIN_ES_SET,(int)>kAOExtraStereoMul ); | |
757 return NULL; | |
758 case gtkSetAudioDelay: | |
759 audio_delay=gtkAODelay=fparam; | |
760 return NULL; | |
761 case gtkSetPanscan: | |
7217 | 762 { |
763 mp_cmd_t * mp_cmd; | |
764 mp_cmd=(mp_cmd_t *)calloc( 1,sizeof( *mp_cmd ) ); | |
765 mp_cmd->id=MP_CMD_PANSCAN; mp_cmd->name=strdup( "panscan" ); | |
766 mp_cmd->args[0].v.f=fparam; mp_cmd->args[1].v.i=1; | |
767 mp_input_queue_cmd( mp_cmd ); | |
768 } | |
6794 | 769 return NULL; |
770 case gtkSetAutoq: | |
7019 | 771 auto_quality=(int)fparam; |
6794 | 772 return NULL; |
6713 | 773 // --- set equalizers |
6627 | 774 case gtkSetContrast: |
7217 | 775 if ( guiIntfStruct.sh_video ) set_video_colors( guiIntfStruct.sh_video,"contrast",(int)fparam ); |
776 return NULL; | |
6627 | 777 case gtkSetBrightness: |
7217 | 778 if ( guiIntfStruct.sh_video ) set_video_colors( guiIntfStruct.sh_video,"brightness",(int)fparam ); |
779 return NULL; | |
6627 | 780 case gtkSetHue: |
7217 | 781 if ( guiIntfStruct.sh_video ) set_video_colors( guiIntfStruct.sh_video,"hue",(int)fparam ); |
782 return NULL; | |
6627 | 783 case gtkSetSaturation: |
7217 | 784 if ( guiIntfStruct.sh_video ) set_video_colors( guiIntfStruct.sh_video,"saturation",(int)fparam ); |
785 return NULL; | |
6627 | 786 case gtkSetEqualizer: |
787 if ( eq ) | |
788 { | |
789 gtkEquChannels[eq->channel][eq->band]=eq->gain; | |
790 audio_plugin_eq.control( AOCONTROL_PLUGIN_EQ_SET_GAIN,(int)eq ); | |
791 } | |
792 else | |
793 { | |
794 int i,j; equalizer_t tmp; tmp.gain=0.0f; | |
795 memset( gtkEquChannels,0,sizeof( gtkEquChannels ) ); | |
796 for ( i=0;i<6;i++ ) | |
797 for ( j=0;j<10;j++ ) | |
798 { tmp.channel=i; tmp.band=j; audio_plugin_eq.control( AOCONTROL_PLUGIN_EQ_SET_GAIN,(int)&tmp ); } | |
799 } | |
6713 | 800 return NULL; |
6627 | 801 } |
6713 | 802 return NULL; |
6627 | 803 } |