Mercurial > mplayer.hg
annotate Gui/interface.c @ 6895:e0fa2a6a8843
updated - we're ready for a pre-release now
author | arpi |
---|---|
date | Sun, 04 Aug 2002 15:39:31 +0000 |
parents | e1c5f3128b3a |
children | 138a7ff52a26 |
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" |
4858 | 23 #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
|
24 #include "../libao2/audio_out.h" |
6627 | 25 #include "../mixer.h" |
26 #include "../libao2/audio_plugin.h" | |
27 #include "../libao2/eq.h" | |
5789 | 28 |
6280 | 29 #include <inttypes.h> |
30 #include <sys/types.h> | |
31 | |
5665 | 32 #include "../libmpdemux/stream.h" |
5789 | 33 #include "../libmpdemux/demuxer.h" |
4818
3473ca9ef158
new gui interface, and gtk moved into mplayer process. fork ... bleh :)
pontscho
parents:
4798
diff
changeset
|
34 |
3473ca9ef158
new gui interface, and gtk moved into mplayer process. fork ... bleh :)
pontscho
parents:
4798
diff
changeset
|
35 guiInterface_t guiIntfStruct; |
3473ca9ef158
new gui interface, and gtk moved into mplayer process. fork ... bleh :)
pontscho
parents:
4798
diff
changeset
|
36 |
6627 | 37 char * gstrcat( char ** dest,char * src ) |
38 { | |
39 char * tmp = NULL; | |
40 | |
41 if ( !src ) return NULL; | |
42 | |
43 if ( *dest ) | |
44 { | |
45 tmp=malloc( strlen( *dest ) + strlen( src ) + 1 ); | |
46 strcpy( tmp,*dest ); strcat( tmp,src ); free( *dest ); | |
47 } | |
48 else | |
49 { tmp=malloc( strlen( src ) + 1 ); strcpy( tmp,src ); } | |
50 *dest=tmp; | |
51 return tmp; | |
52 } | |
53 | |
6794 | 54 int gstrcmp( char * a,char * b ) |
55 { | |
56 if ( !a && !b ) return 0; | |
57 if ( !a || !b ) return -1; | |
58 return strcmp( a,b ); | |
59 } | |
60 | |
61 char * gstrdup( char * str ) | |
62 { | |
63 if ( !str ) return NULL; | |
64 return strdup( str ); | |
65 } | |
66 | |
67 void gfree( void ** p ) | |
68 { | |
69 if ( *p == NULL ) return; | |
70 free( *p ); *p=NULL; | |
71 } | |
72 | |
73 void gset( char ** str,char * what ) | |
74 { | |
75 if ( *str ) { if ( !strstr( *str,what ) ) gstrcat( str,"," ); gstrcat( str,what ); } | |
76 else gstrcat( str,what ); | |
77 } | |
78 | |
6218 | 79 void guiInit( void ) |
4818
3473ca9ef158
new gui interface, and gtk moved into mplayer process. fork ... bleh :)
pontscho
parents:
4798
diff
changeset
|
80 { |
3473ca9ef158
new gui interface, and gtk moved into mplayer process. fork ... bleh :)
pontscho
parents:
4798
diff
changeset
|
81 memset( &guiIntfStruct,0,sizeof( guiIntfStruct ) ); |
6627 | 82 memset( >kEquChannels,0,sizeof( gtkEquChannels ) ); |
6794 | 83 gtkAOOSSMixer=strdup( PATH_DEV_MIXER ); |
84 gtkAOOSSDevice=strdup( PATH_DEV_DSP ); | |
6891
e1c5f3128b3a
gui.conf parsing moved to after gtkInit() - should fix i18n problems
arpi
parents:
6857
diff
changeset
|
85 // cfg_read(); // !!! moved to Gui/mplayer/mplayer.c::mplInit() after gtkInit() |
6218 | 86 appInit( (void*)mDisplay ); |
6857 | 87 if ( plCurrent && !filename ) mplSetFileName( plCurrent->path,plCurrent->name ); |
6797
06d29dbdf20d
upsz, sorry, i forgott this :) (skin name saving:)
pontscho
parents:
6794
diff
changeset
|
88 #if defined( USE_OSD ) || defined( USE_SUB ) |
06d29dbdf20d
upsz, sorry, i forgott this :) (skin name saving:)
pontscho
parents:
6794
diff
changeset
|
89 guiLoadFont(); |
06d29dbdf20d
upsz, sorry, i forgott this :) (skin name saving:)
pontscho
parents:
6794
diff
changeset
|
90 #endif |
4818
3473ca9ef158
new gui interface, and gtk moved into mplayer process. fork ... bleh :)
pontscho
parents:
4798
diff
changeset
|
91 } |
3473ca9ef158
new gui interface, and gtk moved into mplayer process. fork ... bleh :)
pontscho
parents:
4798
diff
changeset
|
92 |
3473ca9ef158
new gui interface, and gtk moved into mplayer process. fork ... bleh :)
pontscho
parents:
4798
diff
changeset
|
93 void guiDone( void ) |
3473ca9ef158
new gui interface, and gtk moved into mplayer process. fork ... bleh :)
pontscho
parents:
4798
diff
changeset
|
94 { |
3473ca9ef158
new gui interface, and gtk moved into mplayer process. fork ... bleh :)
pontscho
parents:
4798
diff
changeset
|
95 mp_msg( MSGT_GPLAYER,MSGL_V,"[mplayer] exit.\n" ); |
6794 | 96 cfg_write(); |
4818
3473ca9ef158
new gui interface, and gtk moved into mplayer process. fork ... bleh :)
pontscho
parents:
4798
diff
changeset
|
97 gtkDone(); |
3473ca9ef158
new gui interface, and gtk moved into mplayer process. fork ... bleh :)
pontscho
parents:
4798
diff
changeset
|
98 wsXDone(); |
3473ca9ef158
new gui interface, and gtk moved into mplayer process. fork ... bleh :)
pontscho
parents:
4798
diff
changeset
|
99 } |
4798 | 100 |
4858 | 101 int guiCMDArray[] = |
102 { | |
103 evLoad, | |
104 evLoadSubtitle, | |
105 evAbout, | |
106 evPlay, | |
107 evStop, | |
108 evPlayList, | |
109 evPreferences, | |
110 evFullScreen, | |
111 evSkinBrowser | |
112 }; | |
113 | |
5789 | 114 typedef struct |
115 { | |
116 demux_stream_t *ds; | |
117 unsigned int format; | |
118 struct codecs_st *codec; | |
119 int inited; | |
120 // output format: | |
121 float timer; | |
122 float fps; | |
123 float frametime; | |
124 int i_bps; | |
125 int disp_w,disp_h; | |
126 } tmp_sh_video_t; | |
127 | |
6619
f554e7271587
fix volume handling ( step 2 ) -- add balance support and some code cleanup and fix
pontscho
parents:
6280
diff
changeset
|
128 extern ao_functions_t * audio_out; |
6755 | 129 extern vo_functions_t * video_out; |
6794 | 130 extern int flip; |
131 extern int frame_dropping; | |
132 extern int sub_pos; | |
133 extern int sub_unicode; | |
134 extern int stream_dump_type; | |
135 extern char ** vo_plugin_args; | |
136 extern int auto_quality; | |
137 | |
138 #if defined( USE_OSD ) || defined( USE_SUB ) | |
139 void guiLoadFont( void ) | |
140 { | |
141 font_factor=gtkSubFFactor; | |
142 if ( vo_font ) | |
143 { | |
144 int i; | |
145 if ( vo_font->name ) free( vo_font->name ); | |
146 if ( vo_font->fpath ) free( vo_font->fpath ); | |
147 for ( i=0;i<16;i++ ) | |
148 if ( vo_font->pic_a[i] ) | |
149 { | |
150 if ( vo_font->pic_a[i]->bmp ) free( vo_font->pic_a[i]->bmp ); | |
151 if ( vo_font->pic_a[i]->pal ) free( vo_font->pic_a[i]->pal ); | |
152 } | |
153 for ( i=0;i<16;i++ ) | |
154 if ( vo_font->pic_b[i] ) | |
155 { | |
156 if ( vo_font->pic_b[i]->bmp ) free( vo_font->pic_b[i]->bmp ); | |
157 if ( vo_font->pic_b[i]->pal ) free( vo_font->pic_b[i]->pal ); | |
158 } | |
159 free( vo_font ); vo_font=NULL; | |
160 } | |
161 if ( guiIntfStruct.Fontname ) | |
162 { | |
163 vo_font=read_font_desc( guiIntfStruct.Fontname,font_factor,0 ); | |
164 if ( !vo_font ) mp_msg( MSGT_CPLAYER,MSGL_ERR,MSGTR_CantLoadFont,font_name ); | |
165 } | |
166 else | |
167 { | |
168 guiIntfStruct.Fontname=gstrdup( get_path( "font/font.desc" ) ); | |
169 vo_font=read_font_desc( guiIntfStruct.Fontname,font_factor,0 ); | |
170 if ( !vo_font ) | |
171 { | |
172 gfree( (void **)&guiIntfStruct.Fontname ); guiIntfStruct.Fontname=gstrdup( DATADIR"/font/font.desc" ); | |
173 vo_font=read_font_desc( guiIntfStruct.Fontname,font_factor,0 ); | |
174 } | |
175 } | |
176 } | |
177 #endif | |
6619
f554e7271587
fix volume handling ( step 2 ) -- add balance support and some code cleanup and fix
pontscho
parents:
6280
diff
changeset
|
178 |
4798 | 179 void guiGetEvent( int type,char * arg ) |
180 { | |
6280 | 181 stream_t * stream = (stream_t *) arg; |
5672
1f8b34f1e7c0
ifdef reading dvd args, without it non-dvd compilation fails.
eyck
parents:
5665
diff
changeset
|
182 #ifdef USE_DVDREAD |
5665 | 183 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
|
184 #endif |
6619
f554e7271587
fix volume handling ( step 2 ) -- add balance support and some code cleanup and fix
pontscho
parents:
6280
diff
changeset
|
185 |
4798 | 186 switch ( type ) |
187 { | |
188 case guiXEvent: | |
189 wsEvents( wsDisplay,(XEvent *)arg,NULL ); | |
4818
3473ca9ef158
new gui interface, and gtk moved into mplayer process. fork ... bleh :)
pontscho
parents:
4798
diff
changeset
|
190 gtkEventHandling(); |
3473ca9ef158
new gui interface, and gtk moved into mplayer process. fork ... bleh :)
pontscho
parents:
4798
diff
changeset
|
191 break; |
4798 | 192 case guiCEvent: |
4963 | 193 switch ( (int)arg ) |
194 { | |
195 case guiSetPlay: guiIntfStruct.Playing=1; mplState(); break; | |
196 case guiSetStop: guiIntfStruct.Playing=0; mplState(); break; | |
197 case guiSetPause: guiIntfStruct.Playing=2; mplState(); break; | |
198 } | |
4818
3473ca9ef158
new gui interface, and gtk moved into mplayer process. fork ... bleh :)
pontscho
parents:
4798
diff
changeset
|
199 break; |
5665 | 200 case guiSetState: |
201 mplState(); | |
202 break; | |
203 case guiSetFileName: | |
204 if ( arg ) guiSetFilename( guiIntfStruct.Filename,arg ); | |
205 break; | |
5789 | 206 case guiSetAudioOnly: |
207 guiIntfStruct.AudioOnly=(int)arg; | |
208 if ( (int)arg ) wsVisibleWindow( &appMPlayer.subWindow,wsHideWindow ); | |
209 else wsVisibleWindow( &appMPlayer.subWindow,wsShowWindow ); | |
210 break; | |
211 case guiReDrawSubWindow: | |
212 wsPostRedisplay( &appMPlayer.subWindow ); | |
213 break; | |
214 case guiSetShVideo: | |
215 { | |
5986 | 216 if ( !appMPlayer.subWindow.isFullScreen ) |
217 { | |
218 wsResizeWindow( &appMPlayer.subWindow,vo_dwidth,vo_dheight ); | |
219 wsMoveWindow( &appMPlayer.subWindow,True,appMPlayer.sub.x,appMPlayer.sub.y ); | |
220 } | |
5955
caac20b1ca79
fix xmga fs, resize to movie size and mouse auto hide + dga
pontscho
parents:
5945
diff
changeset
|
221 guiIntfStruct.MovieWidth=vo_dwidth; |
5997
b5fb9a927bf3
add WM detection, and wm specific fullscreen code. (???)
pontscho
parents:
5986
diff
changeset
|
222 guiIntfStruct.MovieHeight=vo_dheight; |
5789 | 223 } |
224 break; | |
5665 | 225 #ifdef USE_DVDREAD |
226 case guiSetDVD: | |
227 guiIntfStruct.DVD.titles=dvdp->vmg_file->tt_srpt->nr_of_srpts; | |
228 guiIntfStruct.DVD.chapters=dvdp->vmg_file->tt_srpt->title[dvd_title].nr_of_ptts; | |
229 guiIntfStruct.DVD.angles=dvdp->vmg_file->tt_srpt->title[dvd_title].nr_of_angles; | |
230 guiIntfStruct.DVD.nr_of_audio_channels=dvdp->nr_of_channels; | |
231 memcpy( guiIntfStruct.DVD.audio_streams,dvdp->audio_streams,sizeof( dvdp->audio_streams ) ); | |
232 guiIntfStruct.DVD.nr_of_subtitles=dvdp->nr_of_subtitles; | |
233 memcpy( guiIntfStruct.DVD.subtitles,dvdp->subtitles,sizeof( dvdp->subtitles ) ); | |
234 guiIntfStruct.DVD.current_title=dvd_title + 1; | |
235 guiIntfStruct.DVD.current_chapter=dvd_chapter + 1; | |
236 guiIntfStruct.DVD.current_angle=dvd_angle + 1; | |
237 guiIntfStruct.Track=dvd_title + 1; | |
238 break; | |
239 #endif | |
6280 | 240 case guiSetStream: |
241 guiIntfStruct.StreamType=stream->type; | |
242 switch( stream->type ) | |
243 { | |
244 case STREAMTYPE_DVD: | |
245 guiGetEvent( guiSetDVD,(char *)stream->priv ); | |
246 break; | |
247 #ifdef HAVE_VCD | |
248 case STREAMTYPE_VCD: | |
249 { | |
250 int i; | |
251 for ( i=1;i < 100;i++ ) | |
252 if ( vcd_seek_to_track( stream->fd,i ) < 0 ) break; | |
253 vcd_seek_to_track( stream->fd,vcd_track ); | |
254 guiIntfStruct.VCDTracks=--i; | |
255 mp_msg( MSGT_GPLAYER,MSGL_INFO,"[interface] vcd tracks: %d\n",guiIntfStruct.VCDTracks ); | |
256 guiIntfStruct.Track=vcd_track; | |
257 break; | |
258 } | |
259 #endif | |
260 } | |
261 break; | |
5120 | 262 #ifdef HAVE_NEW_INPUT |
4858 | 263 case guiIEvent: |
264 printf( "cmd: %d\n",(int)arg ); | |
265 switch( (int)arg ) | |
266 { | |
267 case MP_CMD_QUIT: | |
268 mplEventHandling( evExit,0 ); | |
269 break; | |
270 case MP_CMD_VO_FULLSCREEN: | |
271 mplEventHandling( evFullScreen,0 ); | |
272 break; | |
273 default: | |
274 mplEventHandling( guiCMDArray[ (int)arg - MP_CMD_GUI_EVENTS - 1 ],0 ); | |
275 } | |
276 break; | |
5120 | 277 #endif |
6619
f554e7271587
fix volume handling ( step 2 ) -- add balance support and some code cleanup and fix
pontscho
parents:
6280
diff
changeset
|
278 case guiReDraw: |
f554e7271587
fix volume handling ( step 2 ) -- add balance support and some code cleanup and fix
pontscho
parents:
6280
diff
changeset
|
279 mplEventHandling( evRedraw,0 ); |
f554e7271587
fix volume handling ( step 2 ) -- add balance support and some code cleanup and fix
pontscho
parents:
6280
diff
changeset
|
280 break; |
f554e7271587
fix volume handling ( step 2 ) -- add balance support and some code cleanup and fix
pontscho
parents:
6280
diff
changeset
|
281 case guiSetVolume: |
6794 | 282 // -- audio |
6619
f554e7271587
fix volume handling ( step 2 ) -- add balance support and some code cleanup and fix
pontscho
parents:
6280
diff
changeset
|
283 if ( audio_out ) |
f554e7271587
fix volume handling ( step 2 ) -- add balance support and some code cleanup and fix
pontscho
parents:
6280
diff
changeset
|
284 { |
f554e7271587
fix volume handling ( step 2 ) -- add balance support and some code cleanup and fix
pontscho
parents:
6280
diff
changeset
|
285 float l,r; |
f554e7271587
fix volume handling ( step 2 ) -- add balance support and some code cleanup and fix
pontscho
parents:
6280
diff
changeset
|
286 mixer_getvolume( &l,&r ); |
f554e7271587
fix volume handling ( step 2 ) -- add balance support and some code cleanup and fix
pontscho
parents:
6280
diff
changeset
|
287 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
|
288 if ( r != l ) guiIntfStruct.Balance=( ( r - l ) + 100 ) * 0.5f; |
6627 | 289 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
|
290 btnModify( evSetVolume,guiIntfStruct.Volume ); |
f554e7271587
fix volume handling ( step 2 ) -- add balance support and some code cleanup and fix
pontscho
parents:
6280
diff
changeset
|
291 btnModify( evSetBalance,guiIntfStruct.Balance ); |
f554e7271587
fix volume handling ( step 2 ) -- add balance support and some code cleanup and fix
pontscho
parents:
6280
diff
changeset
|
292 } |
6627 | 293 |
6794 | 294 if ( gtkAONoSound ) { if ( !muted ) mixer_mute(); } |
295 else if ( muted ) mixer_mute(); | |
296 | |
6627 | 297 if ( gtkEnableAudioEqualizer ) |
298 { | |
299 equalizer_t eq; | |
300 int i,j; | |
301 for ( i=0;i<6;i++ ) | |
302 for ( j=0;j<10;j++ ) | |
303 { | |
304 eq.channel=i; eq.band=j; eq.gain=gtkEquChannels[i][j]; | |
305 gtkSet( gtkSetEqualizer,0,&eq ); | |
306 } | |
307 } | |
6794 | 308 // -- subtitle |
309 gtkSubUnicode=sub_unicode; | |
310 gtkSubDelay=sub_delay; | |
311 gtkSubFPS=sub_fps; | |
312 gtkSubPos=sub_pos; | |
313 #ifdef USE_OSD | |
314 gtkSubFFactor=font_factor; | |
315 #endif | |
6627 | 316 break; |
317 case guiSetDefaults: | |
6857 | 318 if ( filename && !guiIntfStruct.Filename ) |
6794 | 319 { |
320 gtkSet( gtkDelPl,0,NULL ); guiIntfStruct.StreamType=STREAMTYPE_FILE; | |
321 guiSetFilename( guiIntfStruct.Filename,filename ); | |
322 } | |
323 | |
324 guiIntfStruct.DiskChanged=0; | |
6842 | 325 // guiIntfStruct.FilenameChanged=0; |
6794 | 326 |
327 // --- video opts | |
328 if ( !gtkVODriver ) | |
329 { | |
6797
06d29dbdf20d
upsz, sorry, i forgott this :) (skin name saving:)
pontscho
parents:
6794
diff
changeset
|
330 int i = 0; |
6794 | 331 while ( video_out_drivers[i++] ) |
332 if ( video_out_drivers[i - 1]->control( VOCTRL_GUISUPPORT,NULL ) == VO_TRUE ) | |
333 { | |
334 const vo_info_t *info = video_out_drivers[i - 1]->get_info(); | |
335 { gtkVODriver=gstrdup( (char *)info->short_name ); break; } | |
336 } | |
337 } | |
338 | |
339 if ( gtkVODriver ) { if ( video_driver ) free( video_driver ); video_driver=strdup( gtkVODriver ); } | |
340 else { gtkMessageBox( GTK_MB_FATAL,MSGTR_IDFGCVD ); exit_player( "gui init" ); } | |
341 | |
342 if ( gtkVPP ) | |
343 { | |
344 if ( vo_plugin_args ) | |
345 { | |
346 int i = 0; | |
347 while ( vo_plugin_args[i] ) if ( !gstrcmp( vo_plugin_args[i++],"pp" ) ) { i=-1; break; } | |
348 if ( i != -1 ) | |
349 { vo_plugin_args=realloc( vo_plugin_args,( i + 2 ) * sizeof( char * ) ); vo_plugin_args[i]=strdup( "pp" ); vo_plugin_args[i+1]=NULL; } | |
350 } else { vo_plugin_args=malloc( 2 * sizeof( char * ) ); vo_plugin_args[0]=strdup( "pp" ); vo_plugin_args[1]=NULL; } | |
351 auto_quality=gtkVAutoq; | |
352 } | |
353 else | |
354 if ( vo_plugin_args ) | |
355 { | |
356 int n = 0; | |
357 while ( vo_plugin_args[n++] ); n--; | |
358 if ( n > -1 ) | |
359 { | |
360 int i = 0; | |
361 while ( vo_plugin_args[i] ) if ( !gstrcmp( vo_plugin_args[i++],"pp" ) ) break; i--; | |
362 if ( n == i ) | |
363 { | |
364 if ( n == 1 ) { free( vo_plugin_args[0] ); free( vo_plugin_args ); vo_plugin_args=NULL; } | |
365 else memcpy( &vo_plugin_args[i],&vo_plugin_args[i+1],( n - i ) * sizeof( char * ) ); | |
366 } | |
367 } | |
368 auto_quality=0; | |
369 } | |
370 vo_doublebuffering=gtkVODoubleBuffer; | |
371 vo_directrendering=gtkVODirectRendering; | |
372 frame_dropping=gtkVFrameDrop; | |
373 if ( gtkVHardFrameDrop ) frame_dropping=gtkVHardFrameDrop; | |
374 flip=gtkVFlip; | |
375 force_ni=gtkVNIAVI; | |
376 video_family=gtkVVFM; | |
377 | |
378 // --- audio opts | |
379 audio_delay=gtkAODelay; | |
380 if ( ao_plugin_cfg.plugin_list ) { free( ao_plugin_cfg.plugin_list ); ao_plugin_cfg.plugin_list=NULL; } | |
6840 | 381 if ( gtkAONorm ) gset( &ao_plugin_cfg.plugin_list,"volnorm" ); |
6794 | 382 if ( gtkEnableAudioEqualizer ) gset( &ao_plugin_cfg.plugin_list,"eq" ); |
383 if ( gtkAOExtraStereo ) | |
384 { | |
385 gset( &ao_plugin_cfg.plugin_list,"extrastereo" ); | |
386 ao_plugin_cfg.pl_extrastereo_mul=gtkAOExtraStereoMul; | |
387 } | |
388 mixer_device=gtkAOOSSMixer; | |
389 if ( audio_driver ) free( audio_driver ); | |
390 if ( !gstrcmp( gtkAODriver,"oss" ) && gtkAOOSSDevice ) | |
391 { | |
392 char * tmp = calloc( 1,strlen( gtkAODriver ) + strlen( gtkAOOSSDevice ) + 2 ); | |
393 sprintf( tmp,"%s:%s",gtkAODriver,gtkAOOSSDevice ); | |
394 audio_driver=tmp; | |
395 } else audio_driver=gstrdup( gtkAODriver ); | |
396 | |
397 // -- subtitle | |
398 #ifdef USE_SUB | |
399 sub_auto=0; | |
400 if ( gtkSubAuto && guiIntfStruct.StreamType == STREAMTYPE_FILE && !guiIntfStruct.Subtitlename ) | |
401 guiSetFilename( guiIntfStruct.Subtitlename,( guiIntfStruct.Filename ? sub_filename( get_path("sub/"),guiIntfStruct.Filename ): "default.sub" ) ); | |
402 sub_name=guiIntfStruct.Subtitlename; | |
403 sub_unicode=gtkSubUnicode; | |
404 sub_delay=gtkSubDelay; | |
405 sub_fps=gtkSubFPS; | |
406 sub_pos=gtkSubPos; | |
407 stream_dump_type=0; | |
408 if ( gtkSubDumpMPSub ) stream_dump_type=4; | |
409 if ( gtkSubDumpSrt ) stream_dump_type=6; | |
410 gtkSubDumpMPSub=gtkSubDumpSrt=0; | |
6627 | 411 #endif |
6794 | 412 #if defined( USE_OSD ) || defined( USE_SUB ) |
413 guiLoadFont(); | |
6627 | 414 #endif |
415 | |
6794 | 416 // --- misc |
6627 | 417 if ( guiIntfStruct.AudioFile ) audio_stream=guiIntfStruct.AudioFile; |
418 else if ( guiIntfStruct.FilenameChanged ) audio_stream=NULL; | |
6794 | 419 index_mode=gtkVIndex; |
6627 | 420 |
421 break; | |
4798 | 422 } |
423 } | |
424 | |
6619
f554e7271587
fix volume handling ( step 2 ) -- add balance support and some code cleanup and fix
pontscho
parents:
6280
diff
changeset
|
425 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
|
426 extern int mplTimer; |
f554e7271587
fix volume handling ( step 2 ) -- add balance support and some code cleanup and fix
pontscho
parents:
6280
diff
changeset
|
427 |
4798 | 428 void guiEventHandling( void ) |
429 { | |
6619
f554e7271587
fix volume handling ( step 2 ) -- add balance support and some code cleanup and fix
pontscho
parents:
6280
diff
changeset
|
430 if ( !guiIntfStruct.Playing || guiIntfStruct.AudioOnly ) wsHandleEvents(); |
4818
3473ca9ef158
new gui interface, and gtk moved into mplayer process. fork ... bleh :)
pontscho
parents:
4798
diff
changeset
|
431 gtkEventHandling(); |
6619
f554e7271587
fix volume handling ( step 2 ) -- add balance support and some code cleanup and fix
pontscho
parents:
6280
diff
changeset
|
432 mplTimer=GetTimerMS() / 20; |
4798 | 433 } |
6627 | 434 |
435 // --- | |
436 | |
437 float gtkEquChannels[6][10]; | |
438 | |
6713 | 439 plItem * plCurrent = NULL; |
440 plItem * plList = NULL; | |
441 plItem * plLastPlayed = NULL; | |
442 | |
443 #if defined( MP_DEBUG ) && 0 | |
444 void list( void ) | |
6627 | 445 { |
6713 | 446 plItem * next = plList; |
447 printf( "--- list ---\n" ); | |
448 while( next || next->next ) | |
449 { | |
450 printf( "item: %s/%s\n",next->path,next->name ); | |
451 if ( next->next ) next=next->next; else break; | |
452 } | |
453 printf( "--- end of list ---\n" ); | |
454 } | |
455 #else | |
456 #define list(); | |
457 #endif | |
458 | |
459 void * gtkSet( int cmd,float fparam, void * vparam ) | |
460 { | |
6794 | 461 mp_cmd_t * mp_cmd; |
6627 | 462 equalizer_t * eq = (equalizer_t *)vparam; |
6713 | 463 plItem * item = (plItem *)vparam; |
6627 | 464 |
465 switch ( cmd ) | |
466 { | |
6713 | 467 // --- handle playlist |
6755 | 468 case gtkAddPlItem: // add item to playlist |
6713 | 469 if ( plList ) |
470 { | |
471 plItem * next = plList; | |
472 while ( next->next ) { /*printf( "%s\n",next->name );*/ next=next->next; } | |
473 next->next=item; item->prev=next; | |
474 } | |
475 else { item->prev=item->next=NULL; plCurrent=plList=item; } | |
476 list(); | |
477 return NULL; | |
478 case gtkGetNextPlItem: // get current item from playlist | |
479 if ( plCurrent ) | |
480 { | |
481 plCurrent=plCurrent->next; | |
482 if ( !plCurrent && plList ) | |
483 { | |
484 plItem * next = plList; | |
485 while ( next->next ) { if ( !next->next ) break; next=next->next; } | |
486 plCurrent=next; | |
487 } | |
488 return plCurrent; | |
489 } | |
490 return NULL; | |
491 case gtkGetPrevPlItem: | |
492 if ( plCurrent ) | |
493 { | |
494 plCurrent=plCurrent->prev; | |
495 if ( !plCurrent && plList ) plCurrent=plList; | |
496 return plCurrent; | |
497 } | |
6794 | 498 return NULL; |
6713 | 499 case gtkGetCurrPlItem: // get current item |
500 return plCurrent; | |
501 case gtkDelPl: // delete list | |
502 { | |
503 plItem * curr = plList; | |
504 plItem * next; | |
505 if ( !plList ) return NULL; | |
506 if ( !curr->next ) | |
507 { | |
508 if ( curr->path ) free( curr->path ); | |
509 if ( curr->name ) free( curr->name ); | |
510 free( curr ); | |
511 } | |
512 else | |
513 { | |
514 while ( curr->next ) | |
515 { | |
516 next=curr->next; | |
517 if ( curr->path ) free( curr->path ); | |
518 if ( curr->name ) free( curr->name ); | |
519 free( curr ); | |
520 curr=next; | |
521 } | |
522 } | |
523 plList=NULL; plCurrent=NULL; | |
524 } | |
525 return NULL; | |
6794 | 526 // --- subtitle |
527 case gtkSetSubAuto: | |
528 gtkSubAuto=(int)fparam; | |
529 return NULL; | |
530 case gtkSetSubDelay: | |
531 // mp_cmd=(mp_cmd_t *)calloc( 1,sizeof( *mp_cmd ) ); | |
532 // mp_cmd->id=MP_CMD_SUB_DELAY; mp_cmd->name=strdup( "sub_delay" ); | |
533 // mp_cmd->args[0].v.f=fparam; mp_cmd->args[1].v.i=1; | |
534 // mp_input_queue_cmd( mp_cmd ); | |
535 gtkSubDelay=sub_delay=fparam; | |
536 return NULL; | |
537 case gtkSetSubFPS: | |
538 gtkSubFPS=sub_fps=(int)fparam; | |
539 return NULL; | |
540 case gtkSetSubPos: | |
541 gtkSubPos=sub_pos=(int)fparam; | |
542 return NULL; | |
543 #if defined( USE_OSD ) || defined( USE_SUB ) | |
544 case gtkSetFontFactor: | |
545 gtkSubFFactor=fparam; | |
546 guiLoadFont(); | |
547 return NULL; | |
548 #endif | |
549 // --- misc | |
550 case gtkClearStruct: | |
551 if ( (unsigned int)fparam & guiFilenames ) | |
552 { | |
553 gfree( (void **)&guiIntfStruct.Filename ); | |
554 gfree( (void **)&guiIntfStruct.Subtitlename ); | |
555 gfree( (void **)&guiIntfStruct.AudioFile ); | |
556 } | |
557 #ifdef USE_DVDREAD | |
558 if ( (unsigned int)fparam & guiDVD ) memset( &guiIntfStruct.DVD,0,sizeof( guiDVDStruct ) ); | |
559 #endif | |
560 #ifdef HAVE_VCD | |
561 if ( (unsigned int)fparam & guiVCD ) guiIntfStruct.VCDTracks=0; | |
562 #endif | |
563 return NULL; | |
564 case gtkSetExtraStereo: | |
565 gtkAOExtraStereoMul=fparam; | |
566 audio_plugin_extrastereo.control( AOCONTROL_PLUGIN_ES_SET,(int)>kAOExtraStereoMul ); | |
567 return NULL; | |
568 case gtkSetAudioDelay: | |
569 audio_delay=gtkAODelay=fparam; | |
570 return NULL; | |
571 case gtkSetPanscan: | |
572 mp_cmd=(mp_cmd_t *)calloc( 1,sizeof( *mp_cmd ) ); | |
573 mp_cmd->id=MP_CMD_PANSCAN; mp_cmd->name=strdup( "panscan" ); | |
574 mp_cmd->args[0].v.f=fparam; mp_cmd->args[1].v.i=1; | |
575 mp_input_queue_cmd( mp_cmd ); | |
576 return NULL; | |
577 case gtkSetAutoq: | |
578 auto_quality=gtkVAutoq=(int)fparam; | |
579 return NULL; | |
6713 | 580 // --- set equalizers |
6627 | 581 case gtkSetContrast: |
6794 | 582 mp_cmd=(mp_cmd_t *)calloc( 1,sizeof( *mp_cmd ) ); |
6627 | 583 mp_cmd->id=MP_CMD_CONTRAST; mp_cmd->name=strdup( "contrast" ); |
584 break; | |
585 case gtkSetBrightness: | |
6794 | 586 mp_cmd=(mp_cmd_t *)calloc( 1,sizeof( *mp_cmd ) ); |
6627 | 587 mp_cmd->id=MP_CMD_BRIGHTNESS; mp_cmd->name=strdup( "brightness" ); |
588 break; | |
589 case gtkSetHue: | |
6794 | 590 mp_cmd=(mp_cmd_t *)calloc( 1,sizeof( *mp_cmd ) ); |
6627 | 591 mp_cmd->id=MP_CMD_HUE; mp_cmd->name=strdup( "hue" ); |
592 break; | |
593 case gtkSetSaturation: | |
6794 | 594 mp_cmd=(mp_cmd_t *)calloc( 1,sizeof( *mp_cmd ) ); |
6627 | 595 mp_cmd->id=MP_CMD_SATURATION; mp_cmd->name=strdup( "saturation" ); |
596 break; | |
597 case gtkSetEqualizer: | |
598 if ( eq ) | |
599 { | |
600 gtkEquChannels[eq->channel][eq->band]=eq->gain; | |
601 audio_plugin_eq.control( AOCONTROL_PLUGIN_EQ_SET_GAIN,(int)eq ); | |
602 } | |
603 else | |
604 { | |
605 int i,j; equalizer_t tmp; tmp.gain=0.0f; | |
606 memset( gtkEquChannels,0,sizeof( gtkEquChannels ) ); | |
607 for ( i=0;i<6;i++ ) | |
608 for ( j=0;j<10;j++ ) | |
609 { tmp.channel=i; tmp.band=j; audio_plugin_eq.control( AOCONTROL_PLUGIN_EQ_SET_GAIN,(int)&tmp ); } | |
610 } | |
6713 | 611 return NULL; |
6794 | 612 default: return NULL; |
6627 | 613 } |
614 mp_cmd->args[0].v.i=(int)fparam; | |
615 mp_cmd->args[1].v.i=1; | |
616 mp_input_queue_cmd( mp_cmd ); | |
6713 | 617 return NULL; |
6627 | 618 } |