Mercurial > mplayer.hg
annotate gui/interface.c @ 24149:35fcce39b121
Remove redundant extern variable declarations, include proper headers instead.
| author | diego |
|---|---|
| date | Sat, 25 Aug 2007 12:25:34 +0000 |
| parents | f5b32d12b691 |
| children | 0bbfebce0583 |
| rev | line source |
|---|---|
| 23077 | 1 |
| 2 #include <inttypes.h> | |
| 3 #include <stdlib.h> | |
| 4 #include <stdio.h> | |
| 5 #include <string.h> | |
| 6 #include <sys/types.h> | |
| 7 | |
| 8 #include "wm/ws.h" | |
| 9 #include "wm/wsxdnd.h" | |
| 10 #include "interface.h" | |
| 11 #include "skin/skin.h" | |
| 12 | |
| 13 #include "mplayer/gtk/eq.h" | |
| 14 #include "mplayer/widgets.h" | |
| 15 #include "mplayer/gmplayer.h" | |
| 16 #include "mplayer/play.h" | |
| 17 | |
| 18 #include "access_mpcontext.h" | |
| 19 #include "app.h" | |
| 20 #include "cfg.h" | |
| 21 #include "help_mp.h" | |
| 22 #include "libvo/x11_common.h" | |
| 23 #include "libvo/video_out.h" | |
| 24 #include "libvo/font_load.h" | |
| 25 #include "libvo/sub.h" | |
| 26 #include "input/input.h" | |
| 27 #include "libao2/audio_out.h" | |
| 28 #include "mixer.h" | |
| 29 #include "libaf/af.h" | |
| 30 #include "libaf/equalizer.h" | |
| 31 | |
| 32 extern af_cfg_t af_cfg; | |
| 33 | |
| 34 #ifdef USE_ICONV | |
| 35 #include <iconv.h> | |
| 36 #endif | |
| 37 | |
| 38 #include "stream/stream.h" | |
| 39 #include "libmpdemux/demuxer.h" | |
| 40 #include "libmpdemux/stheader.h" | |
| 41 #include "libmpcodecs/dec_video.h" | |
| 42 | |
| 43 #ifdef USE_DVDREAD | |
| 44 #include "stream/stream_dvd.h" | |
| 45 #endif | |
| 46 | |
|
23603
c1221a031ab7
Add a (almost correct) prototype for vcd_seek_to_track
reimar
parents:
23341
diff
changeset
|
47 int vcd_seek_to_track(void *vcd, int track); |
| 23077 | 48 |
| 49 #include "m_config.h" | |
| 50 #include "m_option.h" | |
| 51 | |
| 52 | |
| 53 guiInterface_t guiIntfStruct; | |
| 54 int guiWinID=-1; | |
| 55 | |
| 56 char * gstrcat( char ** dest,const char * src ) | |
| 57 { | |
| 58 char * tmp = NULL; | |
| 59 | |
| 60 if ( !src ) return NULL; | |
| 61 | |
| 62 if ( *dest ) | |
| 63 { | |
| 64 tmp=malloc( strlen( *dest ) + strlen( src ) + 1 ); | |
| 65 | |
| 66 if ( tmp ) /* TODO: advanced error handling */ | |
| 67 { | |
| 68 strcpy( tmp,*dest ); strcat( tmp,src ); free( *dest ); | |
| 69 } | |
| 70 } | |
| 71 else | |
| 72 { tmp=malloc( strlen( src ) + 1 ); strcpy( tmp,src ); } | |
| 73 *dest=tmp; | |
| 74 return tmp; | |
| 75 } | |
| 76 | |
| 77 int gstrcmp( const char * a,const char * b ) | |
| 78 { | |
| 79 if ( !a && !b ) return 0; | |
| 80 if ( !a || !b ) return -1; | |
| 81 return strcmp( a,b ); | |
| 82 } | |
| 83 | |
| 84 int gstrncmp( const char * a,const char * b,int size ) | |
| 85 { | |
| 86 if ( !a && !b ) return 0; | |
| 87 if ( !a || !b ) return -1; | |
| 88 return strncmp( a,b,size ); | |
| 89 } | |
| 90 | |
| 91 char * gstrdup( const char * str ) | |
| 92 { | |
| 93 if ( !str ) return NULL; | |
| 94 return strdup( str ); | |
| 95 } | |
| 96 | |
| 97 char * gstrchr( char * str,int c ) | |
| 98 { | |
| 99 if ( !str ) return NULL; | |
| 100 return strchr( str,c ); | |
| 101 } | |
| 102 | |
| 103 void gfree( void ** p ) | |
| 104 { | |
| 105 if ( *p == NULL ) return; | |
| 106 free( *p ); *p=NULL; | |
| 107 } | |
| 108 | |
| 109 void gset( char ** str, const char * what ) | |
| 110 { | |
| 111 if ( *str ) { if ( !strstr( *str,what ) ) { gstrcat( str,"," ); gstrcat( str,what ); }} | |
| 112 else gstrcat( str,what ); | |
| 113 } | |
| 114 | |
| 115 /** | |
| 116 * \brief this actually creates a new list containing only one element... | |
| 117 */ | |
| 118 void gaddlist( char *** list,const char * entry ) | |
| 119 { | |
| 120 int i; | |
| 121 | |
| 122 if ( (*list) ) | |
| 123 { | |
| 124 for ( i=0;(*list)[i];i++ ) free( (*list)[i] ); | |
| 125 free( (*list) ); | |
| 126 } | |
| 127 | |
| 128 (*list)=malloc( 2 * sizeof(char **) ); | |
| 129 (*list)[0]=gstrdup( entry ); | |
| 130 (*list)[1]=NULL; | |
| 131 } | |
| 132 | |
| 133 /** | |
| 134 * \brief this replaces a string starting with search by replace. | |
| 135 * If not found, replace is appended. | |
| 136 */ | |
| 137 void greplace(char ***list, const char *search, const char *replace) | |
| 138 { | |
| 139 int i = 0; | |
| 140 int len = (search) ? strlen(search) : 0; | |
| 141 | |
| 142 if (*list) { | |
| 143 for (i = 0; (*list)[i]; i++) { | |
| 144 if (search && (strncmp((*list)[i], search, len) == 0)) { | |
| 145 free((*list)[i]); | |
| 146 (*list)[i] = gstrdup(replace); | |
| 147 return; | |
| 148 } | |
| 149 } | |
| 150 *list = realloc(*list, (i + 2) * sizeof(char *)); | |
| 151 } | |
| 152 else | |
| 153 *list = malloc(2 * sizeof(char *)); | |
| 154 | |
| 155 (*list)[i] = gstrdup(replace); | |
| 156 (*list)[i + 1] = NULL; | |
| 157 } | |
| 158 | |
| 159 void guiInit( void ) | |
| 160 { | |
| 161 int i; | |
| 162 | |
| 163 memset( &guiIntfStruct,0,sizeof( guiIntfStruct ) ); | |
| 164 guiIntfStruct.Balance=50.0f; | |
| 165 guiIntfStruct.StreamType=-1; | |
| 166 | |
| 167 memset( >kEquChannels,0,sizeof( gtkEquChannels ) ); | |
| 168 #ifdef HAVE_DXR3 | |
| 169 if ( !gtkDXR3Device ) gtkDXR3Device=strdup( "/dev/em8300-0" ); | |
| 170 #endif | |
| 171 if ( stream_cache_size > 0 ) { gtkCacheOn=1; gtkCacheSize=stream_cache_size; } | |
| 172 else if ( stream_cache_size == 0 ) gtkCacheOn = 0; | |
| 173 if ( autosync && autosync != gtkAutoSync ) { gtkAutoSyncOn=1; gtkAutoSync=autosync; } | |
| 174 | |
| 175 #ifdef USE_ASS | |
| 176 gtkASS.enabled = ass_enabled; | |
| 177 gtkASS.use_margins = ass_use_margins; | |
| 178 gtkASS.top_margin = ass_top_margin; | |
| 179 gtkASS.bottom_margin = ass_bottom_margin; | |
| 180 #endif | |
| 181 | |
| 182 gtkInit(); | |
| 183 // --- initialize X | |
| 184 wsXInit( (void *)mDisplay ); | |
| 185 // --- load skin | |
| 186 skinDirInHome=get_path("skins"); | |
| 187 skinDirInHome_obsolete=get_path("Skin"); | |
| 188 skinMPlayerDir=MPLAYER_DATADIR "/skins"; | |
| 189 skinMPlayerDir_obsolete=MPLAYER_DATADIR "/Skin"; | |
| 190 mp_msg( MSGT_GPLAYER,MSGL_V,"SKIN dir 1: '%s'\n",skinDirInHome); | |
| 191 mp_msg( MSGT_GPLAYER,MSGL_V,"SKIN dir 1 (obsolete): '%s'\n",skinDirInHome_obsolete); | |
| 192 mp_msg( MSGT_GPLAYER,MSGL_V,"SKIN dir 2: '%s'\n",skinMPlayerDir); | |
| 193 mp_msg( MSGT_GPLAYER,MSGL_V,"SKIN dir 2 (obsolete): '%s'\n",skinMPlayerDir_obsolete); | |
| 194 if ( !skinName ) skinName=strdup( "default" ); | |
| 195 i = skinRead( skinName ); | |
| 196 if ((i == -1) && strcmp(skinName,"default")) | |
| 197 { | |
| 198 mp_msg( MSGT_GPLAYER,MSGL_WARN,MSGTR_SKIN_SKINCFG_SelectedSkinNotFound, skinName); | |
| 199 skinName=strdup( "default" ); | |
| 200 i = skinRead( skinName ); | |
| 201 } | |
| 202 switch (i) { | |
| 203 case -1: mp_msg( MSGT_GPLAYER,MSGL_ERR,MSGTR_SKIN_SKINCFG_SkinNotFound,skinName ); exit( 0 ); | |
| 204 case -2: mp_msg( MSGT_GPLAYER,MSGL_ERR,MSGTR_SKIN_SKINCFG_SkinCfgReadError,skinName ); exit( 0 ); | |
| 205 } | |
| 206 // --- initialize windows | |
| 207 if ( ( mplDrawBuffer = malloc( appMPlayer.main.Bitmap.ImageSize ) ) == NULL ) | |
| 208 { | |
| 209 fprintf( stderr,MSGTR_NEMDB ); | |
| 210 exit( 0 ); | |
| 211 } | |
| 212 | |
| 213 if ( gui_save_pos ) | |
| 214 { | |
| 215 appMPlayer.main.x = gui_main_pos_x; | |
| 216 appMPlayer.main.y = gui_main_pos_y; | |
| 217 appMPlayer.sub.x = gui_sub_pos_x; | |
| 218 appMPlayer.sub.y = gui_sub_pos_y; | |
| 219 } | |
| 220 | |
| 221 if (WinID>0) | |
| 222 { | |
| 223 appMPlayer.subWindow.Parent=WinID; | |
| 224 appMPlayer.sub.x=0; | |
| 225 appMPlayer.sub.y=0; | |
| 226 } | |
| 227 if (guiWinID>=0) appMPlayer.mainWindow.Parent=guiWinID; | |
| 228 | |
| 229 wsCreateWindow( &appMPlayer.subWindow, | |
| 230 appMPlayer.sub.x,appMPlayer.sub.y,appMPlayer.sub.width,appMPlayer.sub.height, | |
| 231 wsNoBorder,wsShowMouseCursor|wsHandleMouseButton|wsHandleMouseMove,wsShowFrame|wsHideWindow,"MPlayer - Video" ); | |
| 232 | |
| 233 wsDestroyImage( &appMPlayer.subWindow ); | |
| 234 wsCreateImage( &appMPlayer.subWindow,appMPlayer.sub.Bitmap.Width,appMPlayer.sub.Bitmap.Height ); | |
| 235 wsXDNDMakeAwareness(&appMPlayer.subWindow); | |
| 236 | |
| 237 mplMenuInit(); | |
| 238 mplPBInit(); | |
| 239 | |
| 240 vo_setwindow( appMPlayer.subWindow.WindowID, appMPlayer.subWindow.wGC ); | |
| 241 | |
| 242 // i=wsHideFrame|wsMaxSize|wsHideWindow; | |
| 243 // if ( appMPlayer.mainDecoration ) i=wsShowFrame|wsMaxSize|wsHideWindow; | |
| 244 i=wsShowFrame|wsMaxSize|wsHideWindow; | |
| 245 wsCreateWindow( &appMPlayer.mainWindow, | |
| 246 appMPlayer.main.x,appMPlayer.main.y,appMPlayer.main.width,appMPlayer.main.height, | |
| 247 wsNoBorder,wsShowMouseCursor|wsHandleMouseButton|wsHandleMouseMove,i,"MPlayer" ); | |
| 248 | |
| 249 wsSetShape( &appMPlayer.mainWindow,appMPlayer.main.Mask.Image ); | |
| 250 wsXDNDMakeAwareness(&appMPlayer.mainWindow); | |
| 251 | |
| 252 #ifdef DEBUG | |
| 253 mp_msg( MSGT_GPLAYER,MSGL_DBG2,"[main] depth on screen: %d\n",wsDepthOnScreen ); | |
| 254 mp_msg( MSGT_GPLAYER,MSGL_DBG2,"[main] parent: 0x%x\n",(int)appMPlayer.mainWindow.WindowID ); | |
| 255 mp_msg( MSGT_GPLAYER,MSGL_DBG2,"[main] sub: 0x%x\n",(int)appMPlayer.subWindow.WindowID ); | |
| 256 #endif | |
| 257 | |
| 258 appMPlayer.mainWindow.ReDraw=(void *)mplMainDraw; | |
| 259 appMPlayer.mainWindow.MouseHandler=mplMainMouseHandle; | |
| 260 appMPlayer.mainWindow.KeyHandler=mplMainKeyHandle; | |
| 261 appMPlayer.mainWindow.DandDHandler=mplDandDHandler; | |
| 262 | |
| 263 appMPlayer.subWindow.ReDraw=(void *)mplSubDraw; | |
| 264 appMPlayer.subWindow.MouseHandler=mplSubMouseHandle; | |
| 265 appMPlayer.subWindow.KeyHandler=mplMainKeyHandle; | |
| 266 appMPlayer.subWindow.DandDHandler=mplDandDHandler; | |
| 267 | |
| 268 wsSetBackgroundRGB( &appMPlayer.subWindow,appMPlayer.sub.R,appMPlayer.sub.G,appMPlayer.sub.B ); | |
| 269 wsClearWindow( appMPlayer.subWindow ); | |
| 270 if ( appMPlayer.sub.Bitmap.Image ) wsConvert( &appMPlayer.subWindow,appMPlayer.sub.Bitmap.Image,appMPlayer.sub.Bitmap.ImageSize ); | |
| 271 | |
| 272 btnModify( evSetVolume,guiIntfStruct.Volume ); | |
| 273 btnModify( evSetBalance,guiIntfStruct.Balance ); | |
| 274 btnModify( evSetMoviePosition,guiIntfStruct.Position ); | |
| 275 | |
| 276 wsSetIcon( wsDisplay,appMPlayer.mainWindow.WindowID,guiIcon,guiIconMask ); | |
| 277 wsSetIcon( wsDisplay,appMPlayer.subWindow.WindowID,guiIcon,guiIconMask ); | |
| 278 | |
| 279 guiIntfStruct.Playing=0; | |
| 280 | |
| 281 if ( !appMPlayer.mainDecoration ) wsWindowDecoration( &appMPlayer.mainWindow,0 ); | |
| 282 | |
| 283 wsVisibleWindow( &appMPlayer.mainWindow,wsShowWindow ); | |
| 284 #if 0 | |
| 285 wsVisibleWindow( &appMPlayer.subWindow,wsShowWindow ); | |
| 286 | |
| 287 { | |
| 288 XEvent xev; | |
| 289 do { XNextEvent( wsDisplay,&xev ); } while ( xev.type != MapNotify || xev.xmap.event != appMPlayer.subWindow.WindowID ); | |
| 290 appMPlayer.subWindow.Mapped=wsMapped; | |
| 291 } | |
| 292 | |
| 293 if ( !fullscreen ) fullscreen=gtkLoadFullscreen; | |
| 294 if ( fullscreen ) | |
| 295 { | |
| 296 mplFullScreen(); | |
| 297 btnModify( evFullScreen,btnPressed ); | |
| 298 } | |
| 299 #else | |
| 300 if ( !fullscreen ) fullscreen=gtkLoadFullscreen; | |
| 301 if ( gtkShowVideoWindow ) | |
| 302 { | |
| 303 wsVisibleWindow( &appMPlayer.subWindow,wsShowWindow ); | |
| 304 { | |
| 305 XEvent xev; | |
| 306 do { XNextEvent( wsDisplay,&xev ); } while ( xev.type != MapNotify || xev.xmap.event != appMPlayer.subWindow.WindowID ); | |
| 307 appMPlayer.subWindow.Mapped=wsMapped; | |
| 308 } | |
| 309 | |
| 310 if ( fullscreen ) | |
| 311 { | |
| 312 mplFullScreen(); | |
| 313 btnModify( evFullScreen,btnPressed ); | |
| 314 } | |
| 315 } | |
| 316 else | |
| 317 { | |
| 318 if ( fullscreen ) | |
| 319 { | |
| 320 wsVisibleWindow( &appMPlayer.subWindow,wsShowWindow ); | |
| 321 { | |
| 322 XEvent xev; | |
| 323 do { XNextEvent( wsDisplay,&xev ); } while ( xev.type != MapNotify || xev.xmap.event != appMPlayer.subWindow.WindowID ); | |
| 324 appMPlayer.subWindow.Mapped=wsMapped; | |
| 325 } | |
| 326 wsVisibleWindow( &appMPlayer.subWindow, wsShowWindow ); | |
| 327 | |
| 328 mplFullScreen(); | |
| 329 btnModify( evFullScreen,btnPressed ); | |
| 330 } | |
| 331 } | |
| 332 #endif | |
| 333 mplSubRender=1; | |
| 334 // --- | |
| 335 | |
| 336 if ( filename ) mplSetFileName( NULL,filename,STREAMTYPE_FILE ); | |
| 337 if ( plCurrent && !filename ) mplSetFileName( plCurrent->path,plCurrent->name,STREAMTYPE_FILE ); | |
| 338 if ( subdata ) guiSetFilename( guiIntfStruct.Subtitlename, subdata->filename ); | |
| 339 guiLoadFont(); | |
| 340 } | |
| 341 | |
| 342 void guiDone( void ) | |
| 343 { | |
| 344 mplMainRender=0; | |
| 345 mp_msg( MSGT_GPLAYER,MSGL_V,"[GUI] done.\n" ); | |
| 346 | |
| 347 if ( gui_save_pos ) | |
| 348 { | |
| 349 gui_main_pos_x=appMPlayer.mainWindow.X; gui_main_pos_y=appMPlayer.mainWindow.Y; | |
| 350 gui_sub_pos_x=appMPlayer.subWindow.X; gui_sub_pos_y=appMPlayer.subWindow.Y; | |
| 351 } | |
| 352 | |
| 353 #ifdef USE_ASS | |
| 354 ass_enabled = gtkASS.enabled; | |
| 355 ass_use_margins = gtkASS.use_margins; | |
| 356 ass_top_margin = gtkASS.top_margin; | |
| 357 ass_bottom_margin = gtkASS.bottom_margin; | |
| 358 #endif | |
| 359 | |
| 360 cfg_write(); | |
| 361 wsXDone(); | |
| 362 } | |
| 363 | |
| 364 int guiCMDArray[] = | |
| 365 { | |
| 366 evLoadPlay, | |
| 367 evLoadSubtitle, | |
| 368 evAbout, | |
| 369 evPlay, | |
| 370 evStop, | |
| 371 evPlayList, | |
| 372 evPreferences, | |
| 373 evFullScreen, | |
| 374 evSkinBrowser | |
| 375 }; | |
| 376 | |
| 377 extern int stream_dump_type; | |
| 378 extern int vcd_track; | |
| 379 extern m_obj_settings_t * vf_settings; | |
| 380 | |
| 381 void guiLoadFont( void ) | |
| 382 { | |
| 383 #ifdef HAVE_FREETYPE | |
|
23341
74f5109611e2
missed part of gui code change while introducing -subfont option (patch by Piotr Kaczuba)
ben
parents:
23158
diff
changeset
|
384 load_font_ft(vo_image_width, vo_image_height, &vo_font, font_name); |
| 23077 | 385 #else |
| 386 if ( vo_font ) | |
| 387 { | |
| 388 int i; | |
| 389 if ( vo_font->name ) free( vo_font->name ); | |
| 390 if ( vo_font->fpath ) free( vo_font->fpath ); | |
| 391 for ( i=0;i<16;i++ ) | |
| 392 if ( vo_font->pic_a[i] ) | |
| 393 { | |
| 394 if ( vo_font->pic_a[i]->bmp ) free( vo_font->pic_a[i]->bmp ); | |
| 395 if ( vo_font->pic_a[i]->pal ) free( vo_font->pic_a[i]->pal ); | |
| 396 } | |
| 397 for ( i=0;i<16;i++ ) | |
| 398 if ( vo_font->pic_b[i] ) | |
| 399 { | |
| 400 if ( vo_font->pic_b[i]->bmp ) free( vo_font->pic_b[i]->bmp ); | |
| 401 if ( vo_font->pic_b[i]->pal ) free( vo_font->pic_b[i]->pal ); | |
| 402 } | |
| 403 free( vo_font ); vo_font=NULL; | |
| 404 } | |
| 405 if ( font_name ) | |
| 406 { | |
| 407 vo_font=read_font_desc( font_name,font_factor,0 ); | |
| 408 if ( !vo_font ) mp_msg( MSGT_CPLAYER,MSGL_ERR,MSGTR_CantLoadFont,font_name ); | |
| 409 } | |
| 410 else | |
| 411 { | |
| 412 font_name=gstrdup( get_path( "font/font.desc" ) ); | |
| 413 vo_font=read_font_desc( font_name,font_factor,0 ); | |
| 414 if ( !vo_font ) | |
| 415 { | |
| 416 gfree( (void **)&font_name ); font_name=gstrdup(MPLAYER_DATADIR "/font/font.desc" ); | |
| 417 vo_font=read_font_desc( font_name,font_factor,0 ); | |
| 418 } | |
| 419 } | |
| 420 #endif | |
| 421 } | |
| 422 | |
| 423 extern mp_osd_obj_t* vo_osd_list; | |
| 424 | |
| 425 extern char **sub_name; | |
| 426 | |
| 427 void guiLoadSubtitle( char * name ) | |
| 428 { | |
| 429 if ( guiIntfStruct.Playing == 0 ) | |
| 430 { | |
| 431 guiIntfStruct.SubtitleChanged=1; //what is this for? (mw) | |
| 432 return; | |
| 433 } | |
| 434 if ( subdata ) | |
| 435 { | |
| 436 mp_msg( MSGT_GPLAYER,MSGL_INFO,MSGTR_DeletingSubtitles ); | |
| 437 sub_free( subdata ); | |
| 438 subdata=NULL; | |
| 439 vo_sub=NULL; | |
| 440 if ( vo_osd_list ) | |
| 441 { | |
| 442 int len; | |
| 443 mp_osd_obj_t * osd = vo_osd_list; | |
| 444 while ( osd ) | |
| 445 { | |
| 446 if ( osd->type == OSDTYPE_SUBTITLE ) break; | |
| 447 osd=osd->next; | |
| 448 } | |
| 449 if ( osd && osd->flags&OSDFLAG_VISIBLE ) | |
| 450 { | |
| 451 len=osd->stride * ( osd->bbox.y2 - osd->bbox.y1 ); | |
| 452 memset( osd->bitmap_buffer,0,len ); | |
| 453 memset( osd->alpha_buffer,0,len ); | |
| 454 } | |
| 455 } | |
| 456 } | |
| 457 if ( name ) | |
| 458 { | |
| 459 mp_msg( MSGT_GPLAYER,MSGL_INFO,MSGTR_LoadingSubtitles,name ); | |
| 460 subdata=sub_read_file( name, guiIntfStruct.FPS ); | |
| 461 if ( !subdata ) mp_msg( MSGT_GPLAYER,MSGL_ERR,MSGTR_CantLoadSub,name ); | |
| 462 sub_name = (malloc(2 * sizeof(char*))); //when mplayer will be restarted | |
| 463 sub_name[0] = strdup(name); //sub_name[0] will be read | |
| 464 sub_name[1] = NULL; | |
| 465 } | |
| 466 update_set_of_subtitles(); | |
| 467 | |
| 468 } | |
| 469 | |
| 470 static void add_vf( char * str ) | |
| 471 { | |
| 472 mp_msg( MSGT_GPLAYER,MSGL_STATUS,MSGTR_AddingVideoFilter,str ); | |
| 473 if ( vf_settings ) | |
| 474 { | |
| 475 int i = 0; | |
| 476 while ( vf_settings[i].name ) if ( !gstrcmp( vf_settings[i++].name,str ) ) { i=-1; break; } | |
| 477 if ( i != -1 ) | |
| 478 { vf_settings=realloc( vf_settings,( i + 2 ) * sizeof( m_obj_settings_t ) ); vf_settings[i].name=strdup( str );vf_settings[i].attribs = NULL; vf_settings[i+1].name=NULL; } | |
| 479 } else { vf_settings=malloc( 2 * sizeof( m_obj_settings_t ) ); vf_settings[0].name=strdup( str );vf_settings[0].attribs = NULL; vf_settings[1].name=NULL; } | |
| 480 } | |
| 481 | |
| 482 static void remove_vf( char * str ) | |
| 483 { | |
| 484 int n = 0; | |
| 485 | |
| 486 if ( !vf_settings ) return; | |
| 487 | |
| 488 mp_msg( MSGT_GPLAYER,MSGL_STATUS,MSGTR_RemovingVideoFilter,str ); | |
| 489 | |
| 490 while ( vf_settings[n++].name ); n--; | |
| 491 if ( n > -1 ) | |
| 492 { | |
| 493 int i = 0,m = -1; | |
| 494 while ( vf_settings[i].name ) if ( !gstrcmp( vf_settings[i++].name,str ) ) { m=i - 1; break; } | |
| 495 i--; | |
| 496 if ( m > -1 ) | |
| 497 { | |
| 498 if ( n == 1 ) { free( vf_settings[0].name );free( vf_settings[0].attribs ); free( vf_settings ); vf_settings=NULL; } | |
| 499 else { free( vf_settings[i].name );free( vf_settings[i].attribs ); memcpy( &vf_settings[i],&vf_settings[i + 1],( n - i ) * sizeof( m_obj_settings_t ) ); } | |
| 500 } | |
| 501 } | |
| 502 } | |
| 503 | |
| 504 int guiGetEvent( int type,char * arg ) | |
| 505 { | |
| 506 ao_functions_t *audio_out = NULL; | |
| 507 vo_functions_t *video_out = NULL; | |
| 508 mixer_t *mixer = NULL; | |
| 509 | |
| 510 stream_t * stream = (stream_t *) arg; | |
| 511 #ifdef USE_DVDREAD | |
| 512 dvd_priv_t * dvdp = (dvd_priv_t *) arg; | |
| 513 #endif | |
| 514 | |
| 515 if (guiIntfStruct.mpcontext) { | |
| 516 audio_out = mpctx_get_audio_out(guiIntfStruct.mpcontext); | |
| 517 video_out = mpctx_get_video_out(guiIntfStruct.mpcontext); | |
| 518 mixer = mpctx_get_mixer(guiIntfStruct.mpcontext); | |
| 519 } | |
| 520 | |
| 521 switch ( type ) | |
| 522 { | |
| 523 case guiXEvent: | |
| 524 guiIntfStruct.event_struct=(void *)arg; | |
| 525 wsEvents( wsDisplay,(XEvent *)arg,NULL ); | |
| 526 gtkEventHandling(); | |
| 527 break; | |
| 528 case guiCEvent: | |
| 529 switch ( (int)arg ) | |
| 530 { | |
| 531 case guiSetPlay: | |
| 532 guiIntfStruct.Playing=1; | |
| 533 // if ( !gtkShowVideoWindow ) wsVisibleWindow( &appMPlayer.subWindow,wsHideWindow ); | |
| 534 break; | |
| 535 case guiSetStop: | |
| 536 guiIntfStruct.Playing=0; | |
| 537 // if ( !gtkShowVideoWindow ) wsVisibleWindow( &appMPlayer.subWindow,wsHideWindow ); | |
| 538 break; | |
| 539 case guiSetPause: guiIntfStruct.Playing=2; break; | |
| 540 } | |
| 541 mplState(); | |
| 542 break; | |
| 543 case guiSetState: | |
| 544 mplState(); | |
| 545 break; | |
| 546 case guiSetFileName: | |
| 547 if ( arg ) guiSetFilename( guiIntfStruct.Filename,arg ); | |
| 548 break; | |
| 549 case guiSetAudioOnly: | |
| 550 guiIntfStruct.AudioOnly=(int)arg; | |
| 551 if ( (int)arg ) { guiIntfStruct.NoWindow=True; wsVisibleWindow( &appMPlayer.subWindow,wsHideWindow ); } | |
| 552 else wsVisibleWindow( &appMPlayer.subWindow,wsShowWindow ); | |
| 553 break; | |
| 554 case guiSetContext: | |
| 555 guiIntfStruct.mpcontext=(void *)arg; | |
| 556 case guiSetDemuxer: | |
| 557 guiIntfStruct.demuxer=(void *)arg; | |
| 558 break; | |
| 559 case guiSetAfilter: | |
| 560 guiIntfStruct.afilter=(void *)arg; | |
| 561 break; | |
| 562 case guiSetShVideo: | |
| 563 { | |
| 564 if ( !appMPlayer.subWindow.isFullScreen ) | |
| 565 { | |
| 566 wsResizeWindow( &appMPlayer.subWindow,vo_dwidth,vo_dheight ); | |
| 567 wsMoveWindow( &appMPlayer.subWindow,True,appMPlayer.sub.x,appMPlayer.sub.y ); | |
| 568 } | |
| 569 guiIntfStruct.MovieWidth=vo_dwidth; | |
| 570 guiIntfStruct.MovieHeight=vo_dheight; | |
| 571 if (guiWinID>=0) | |
| 572 wsMoveWindow( &appMPlayer.mainWindow,0,0, vo_dheight); | |
| 573 } | |
| 574 break; | |
| 575 #ifdef USE_DVDREAD | |
| 576 case guiSetDVD: | |
| 577 guiIntfStruct.DVD.titles=dvdp->vmg_file->tt_srpt->nr_of_srpts; | |
| 578 guiIntfStruct.DVD.chapters=dvdp->vmg_file->tt_srpt->title[dvd_title].nr_of_ptts; | |
| 579 guiIntfStruct.DVD.angles=dvdp->vmg_file->tt_srpt->title[dvd_title].nr_of_angles; | |
| 580 guiIntfStruct.DVD.nr_of_audio_channels=dvdp->nr_of_channels; | |
| 581 memcpy( guiIntfStruct.DVD.audio_streams,dvdp->audio_streams,sizeof( dvdp->audio_streams ) ); | |
| 582 guiIntfStruct.DVD.nr_of_subtitles=dvdp->nr_of_subtitles; | |
| 583 memcpy( guiIntfStruct.DVD.subtitles,dvdp->subtitles,sizeof( dvdp->subtitles ) ); | |
| 584 guiIntfStruct.DVD.current_title=dvd_title + 1; | |
| 585 guiIntfStruct.DVD.current_chapter=dvd_chapter + 1; | |
| 586 guiIntfStruct.DVD.current_angle=dvd_angle + 1; | |
| 587 guiIntfStruct.Track=dvd_title + 1; | |
| 588 break; | |
| 589 #endif | |
| 590 case guiSetStream: | |
| 591 guiIntfStruct.StreamType=stream->type; | |
| 592 switch( stream->type ) | |
| 593 { | |
| 594 #ifdef USE_DVDREAD | |
| 595 case STREAMTYPE_DVD: | |
| 596 guiGetEvent( guiSetDVD,(char *)stream->priv ); | |
| 597 break; | |
| 598 #endif | |
| 599 #ifdef HAVE_VCD | |
| 600 case STREAMTYPE_VCD: | |
| 601 { | |
| 602 int i; | |
| 603 | |
| 604 if (!stream->priv) | |
| 605 { | |
| 606 guiIntfStruct.VCDTracks=0; | |
| 607 break; | |
| 608 } | |
| 609 for ( i=1;i < 100;i++ ) | |
| 610 if ( vcd_seek_to_track( stream->priv,i ) < 0 ) break; | |
| 611 vcd_seek_to_track( stream->priv,vcd_track ); | |
| 612 guiIntfStruct.VCDTracks=--i; | |
| 613 break; | |
| 614 } | |
| 615 #endif | |
| 616 default: break; | |
| 617 } | |
| 618 break; | |
| 619 case guiIEvent: | |
| 620 mp_msg( MSGT_GPLAYER,MSGL_V,"cmd: %d\n",(int)arg ); | |
| 621 switch( (int)arg ) | |
| 622 { | |
| 623 case MP_CMD_QUIT: | |
| 624 mplEventHandling( evExit,0 ); | |
| 625 break; | |
| 626 case MP_CMD_VO_FULLSCREEN: | |
| 627 mplEventHandling( evFullScreen,0 ); | |
| 628 break; | |
| 629 default: | |
| 630 mplEventHandling( guiCMDArray[ (int)arg - MP_CMD_GUI_EVENTS - 1 ],0 ); | |
| 631 } | |
| 632 break; | |
| 633 case guiReDraw: | |
| 634 mplEventHandling( evRedraw,0 ); | |
| 635 break; | |
| 636 case guiSetVolume: | |
| 637 if ( audio_out ) | |
| 638 { | |
| 639 float l,r; | |
| 640 mixer_getvolume( mixer,&l,&r ); | |
| 641 guiIntfStruct.Volume=(r>l?r:l); | |
| 642 if ( r != l ) guiIntfStruct.Balance=( ( r - l ) + 100 ) * 0.5f; | |
| 643 else guiIntfStruct.Balance=50.0f; | |
| 644 btnModify( evSetVolume,guiIntfStruct.Volume ); | |
| 645 btnModify( evSetBalance,guiIntfStruct.Balance ); | |
| 646 } | |
| 647 break; | |
| 648 case guiSetFileFormat: | |
| 649 guiIntfStruct.FileFormat=(int)arg; | |
| 650 break; | |
| 651 case guiSetValues: | |
| 652 // -- video | |
| 653 guiIntfStruct.sh_video=arg; | |
| 654 if ( arg ) | |
| 655 { | |
| 656 sh_video_t * sh = (sh_video_t *)arg; | |
| 657 guiIntfStruct.FPS=sh->fps; | |
| 658 } | |
| 659 | |
| 660 if ( guiIntfStruct.NoWindow ) wsVisibleWindow( &appMPlayer.subWindow,wsHideWindow ); | |
| 661 | |
| 662 if ( guiIntfStruct.StreamType == STREAMTYPE_STREAM ) btnSet( evSetMoviePosition,btnDisabled ); | |
| 663 else btnSet( evSetMoviePosition,btnReleased ); | |
| 664 | |
| 665 // -- audio | |
| 666 if ( audio_out ) | |
| 667 { | |
| 668 float l,r; | |
| 669 mixer_getvolume( mixer,&l,&r ); | |
| 670 guiIntfStruct.Volume=(r>l?r:l); | |
| 671 if ( r != l ) guiIntfStruct.Balance=( ( r - l ) + 100 ) * 0.5f; | |
| 672 else guiIntfStruct.Balance=50.0f; | |
| 673 btnModify( evSetVolume,guiIntfStruct.Volume ); | |
| 674 btnModify( evSetBalance,guiIntfStruct.Balance ); | |
| 675 } | |
| 676 | |
| 677 if ( gtkEnableAudioEqualizer ) | |
| 678 { | |
| 679 equalizer_t eq; | |
| 680 int i,j; | |
| 681 for ( i=0;i<6;i++ ) | |
| 682 for ( j=0;j<10;j++ ) | |
| 683 { | |
| 684 eq.channel=i; eq.band=j; eq.gain=gtkEquChannels[i][j]; | |
| 685 gtkSet( gtkSetEqualizer,0,&eq ); | |
| 686 } | |
| 687 } | |
| 688 // -- subtitle | |
| 689 #ifdef HAVE_DXR3 | |
| 690 if ( video_driver_list && !gstrcmp( video_driver_list[0],"dxr3" ) && guiIntfStruct.FileFormat != DEMUXER_TYPE_MPEG_PS | |
| 691 #ifdef USE_LIBAVCODEC | |
| 692 && !gtkVfLAVC | |
| 693 #endif | |
| 694 ) | |
| 695 { | |
| 696 gtkMessageBox( GTK_MB_FATAL,MSGTR_NEEDLAVC ); | |
| 697 guiIntfStruct.Playing=0; | |
| 698 return True; | |
| 699 } | |
| 700 #endif | |
| 701 break; | |
| 702 case guiSetDefaults: | |
| 703 // if ( guiIntfStruct.Playing == 1 && guiIntfStruct.FilenameChanged ) | |
| 704 if ( guiIntfStruct.FilenameChanged ) | |
| 705 { | |
| 706 audio_id=-1; | |
| 707 video_id=-1; | |
| 708 dvdsub_id=-1; | |
| 709 vobsub_id=-1; | |
| 710 stream_cache_size=-1; | |
| 711 autosync=0; | |
| 712 vcd_track=0; | |
| 713 dvd_title=0; | |
| 714 force_fps=0; | |
| 715 } | |
| 716 guiIntfStruct.demuxer=NULL; | |
| 717 guiIntfStruct.sh_video=NULL; | |
| 718 wsPostRedisplay( &appMPlayer.subWindow ); | |
| 719 break; | |
| 720 case guiSetParameters: | |
| 721 guiGetEvent( guiSetDefaults,NULL ); | |
| 722 switch ( guiIntfStruct.StreamType ) | |
| 723 { | |
| 724 case STREAMTYPE_PLAYLIST: | |
| 725 break; | |
| 726 #ifdef HAVE_VCD | |
| 727 case STREAMTYPE_VCD: | |
| 728 { | |
| 729 char tmp[512]; | |
| 730 sprintf( tmp,"vcd://%d",guiIntfStruct.Track + 1 ); | |
| 731 guiSetFilename( guiIntfStruct.Filename,tmp ); | |
| 732 } | |
| 733 break; | |
| 734 #endif | |
| 735 #ifdef USE_DVDREAD | |
| 736 case STREAMTYPE_DVD: | |
| 737 { | |
| 738 char tmp[512]; | |
| 739 sprintf( tmp,"dvd://%d",guiIntfStruct.Title ); | |
| 740 guiSetFilename( guiIntfStruct.Filename,tmp ); | |
| 741 } | |
| 742 dvd_chapter=guiIntfStruct.Chapter; | |
| 743 dvd_angle=guiIntfStruct.Angle; | |
| 744 break; | |
| 745 #endif | |
| 746 } | |
| 747 //if ( guiIntfStruct.StreamType != STREAMTYPE_PLAYLIST ) // Does not make problems anymore! | |
| 748 { | |
| 749 if ( guiIntfStruct.Filename ) filename=gstrdup( guiIntfStruct.Filename ); | |
| 750 else if ( filename ) guiSetFilename( guiIntfStruct.Filename,filename ); | |
| 751 } | |
| 752 // --- video opts | |
| 753 | |
| 754 if ( !video_driver_list ) | |
| 755 { | |
| 756 int i = 0; | |
| 757 while ( video_out_drivers[i++] ) | |
| 758 if ( video_out_drivers[i - 1]->control( VOCTRL_GUISUPPORT,NULL ) == VO_TRUE ) | |
| 759 { | |
| 760 gaddlist( &video_driver_list,(char *)video_out_drivers[i - 1]->info->short_name ); | |
| 761 break; | |
| 762 } | |
| 763 } | |
| 764 | |
| 765 if ( !video_driver_list && !video_driver_list[0] ) { gtkMessageBox( GTK_MB_FATAL,MSGTR_IDFGCVD ); exit_player( "gui init" ); } | |
| 766 | |
| 767 { | |
| 768 int i = 0; | |
| 769 guiIntfStruct.NoWindow=False; | |
| 770 while ( video_out_drivers[i++] ) | |
| 771 if ( video_out_drivers[i - 1]->control( VOCTRL_GUISUPPORT,NULL ) == VO_TRUE ) | |
| 772 { | |
| 773 if ( ( video_driver_list && !gstrcmp( video_driver_list[0],(char *)video_out_drivers[i - 1]->info->short_name ) )&&( video_out_drivers[i - 1]->control( VOCTRL_GUI_NOWINDOW,NULL ) == VO_TRUE ) ) | |
| 774 { guiIntfStruct.NoWindow=True; break; } | |
| 775 } | |
| 776 } | |
| 777 | |
| 778 #ifdef HAVE_DXR3 | |
| 779 #ifdef USE_LIBAVCODEC | |
| 780 remove_vf( "lavc" ); | |
| 781 #endif | |
| 782 if ( video_driver_list && !gstrcmp( video_driver_list[0],"dxr3" ) ) | |
| 783 { | |
| 784 if ( ( guiIntfStruct.StreamType != STREAMTYPE_DVD)&&( guiIntfStruct.StreamType != STREAMTYPE_VCD ) ) | |
| 785 { | |
| 786 #ifdef USE_LIBAVCODEC | |
| 787 if ( gtkVfLAVC ) add_vf( "lavc" ); | |
| 788 #endif | |
| 789 } | |
| 790 } | |
| 791 #endif | |
| 792 // --- | |
| 793 if ( gtkVfPP ) add_vf( "pp" ); | |
| 794 else remove_vf( "pp" ); | |
| 795 | |
| 796 // --- audio opts | |
| 797 // if ( ao_plugin_cfg.plugin_list ) { free( ao_plugin_cfg.plugin_list ); ao_plugin_cfg.plugin_list=NULL; } | |
| 798 if (gtkAONorm) | |
| 799 greplace(&af_cfg.list, "volnorm", "volnorm"); | |
| 800 if (gtkEnableAudioEqualizer) | |
| 801 greplace(&af_cfg.list, "equalizer", "equalizer"); | |
| 802 if ( gtkAOExtraStereo ) | |
| 803 { | |
| 804 char *name = malloc(12 + 20 + 1); | |
| 805 snprintf(name, 12 + 20, "extrastereo=%f", gtkAOExtraStereoMul); | |
| 806 name[12 + 20] = 0; | |
| 807 greplace(&af_cfg.list, "extrastereo", name); | |
| 808 free(name); | |
| 809 } | |
| 810 #ifdef USE_OSS_AUDIO | |
| 811 if ( audio_driver_list && !gstrncmp( audio_driver_list[0],"oss",3 ) ) | |
| 812 { | |
| 813 char *tmp; | |
| 814 mixer_device = gtkAOOSSMixer; | |
| 815 mixer_channel = gtkAOOSSMixerChannel; | |
| 816 if (gtkAOOSSDevice) { | |
| 817 tmp = calloc( 1,strlen( gtkAOOSSDevice ) + 7 ); | |
| 818 sprintf( tmp,"oss:%s",gtkAOOSSDevice ); | |
| 819 } else | |
| 820 tmp = strdup("oss"); | |
| 821 gaddlist( &audio_driver_list,tmp ); | |
| 822 free(tmp); | |
| 823 } | |
| 824 #endif | |
| 825 #if defined(HAVE_ALSA9) || defined (HAVE_ALSA1X) | |
| 826 if ( audio_driver_list && !gstrncmp( audio_driver_list[0],"alsa",4 ) ) | |
| 827 { | |
| 828 char *tmp; | |
| 829 mixer_device = gtkAOALSAMixer; | |
| 830 mixer_channel = gtkAOALSAMixerChannel; | |
| 831 if (gtkAOALSADevice) { | |
| 832 tmp = calloc( 1,strlen( gtkAOALSADevice ) + 14 ); | |
| 833 sprintf( tmp,"alsa:device=%s",gtkAOALSADevice ); | |
| 834 } else | |
| 835 tmp = strdup("alsa"); | |
| 836 gaddlist( &audio_driver_list,tmp ); | |
| 837 free(tmp); | |
| 838 } | |
| 839 #endif | |
| 840 #ifdef HAVE_SDL | |
| 841 if ( audio_driver_list && !gstrncmp( audio_driver_list[0],"sdl",3 ) ) | |
| 842 { | |
| 843 char *tmp; | |
| 844 if (gtkAOSDLDriver) { | |
| 845 tmp = calloc( 1,strlen( gtkAOSDLDriver ) + 10 ); | |
| 846 sprintf( tmp,"sdl:%s",gtkAOSDLDriver ); | |
| 847 } else | |
| 848 tmp = strdup("sdl"); | |
| 849 gaddlist( &audio_driver_list,tmp ); | |
| 850 free(tmp); | |
| 851 } | |
| 852 #endif | |
| 853 #ifdef USE_ESD | |
| 854 if ( audio_driver_list && !gstrncmp( audio_driver_list[0],"esd",3 ) ) | |
| 855 { | |
| 856 char *tmp; | |
| 857 if (gtkAOESDDevice) { | |
| 858 tmp = calloc( 1,strlen( gtkAOESDDevice ) + 10 ); | |
| 859 sprintf( tmp,"esd:%s",gtkAOESDDevice ); | |
| 860 } else | |
| 861 tmp = strdup("esd"); | |
| 862 gaddlist( &audio_driver_list,tmp ); | |
| 863 free(tmp); | |
| 864 } | |
| 865 #endif | |
| 866 // -- subtitle | |
| 867 //subdata->filename=gstrdup( guiIntfStruct.Subtitlename ); | |
| 868 stream_dump_type=0; | |
| 869 if ( gtkSubDumpMPSub ) stream_dump_type=4; | |
| 870 if ( gtkSubDumpSrt ) stream_dump_type=6; | |
| 871 gtkSubDumpMPSub=gtkSubDumpSrt=0; | |
| 872 guiLoadFont(); | |
| 873 | |
| 874 // --- misc | |
| 875 if ( gtkCacheOn ) stream_cache_size=gtkCacheSize; | |
| 876 if ( gtkAutoSyncOn ) autosync=gtkAutoSync; | |
| 877 | |
| 878 if ( guiIntfStruct.AudioFile ) audio_stream=gstrdup( guiIntfStruct.AudioFile ); | |
| 879 else if ( guiIntfStruct.FilenameChanged ) gfree( (void**)&audio_stream ); | |
| 880 //audio_stream=NULL; | |
| 881 | |
| 882 guiIntfStruct.DiskChanged=0; | |
| 883 guiIntfStruct.FilenameChanged=0; | |
| 884 guiIntfStruct.NewPlay=0; | |
| 885 | |
| 886 #ifdef USE_ASS | |
| 887 ass_enabled = gtkASS.enabled; | |
| 888 ass_use_margins = gtkASS.use_margins; | |
| 889 ass_top_margin = gtkASS.top_margin; | |
| 890 ass_bottom_margin = gtkASS.bottom_margin; | |
| 891 #endif | |
| 892 | |
| 893 break; | |
| 894 } | |
| 895 return False; | |
| 896 } | |
| 897 | |
| 898 void guiEventHandling( void ) | |
| 899 { | |
| 900 if ( !guiIntfStruct.Playing || guiIntfStruct.NoWindow ) wsHandleEvents(); | |
| 901 gtkEventHandling(); | |
| 902 } | |
| 903 | |
| 904 // --- | |
| 905 | |
| 906 float gtkEquChannels[6][10]; | |
| 907 | |
| 908 plItem * plCurrent = NULL; | |
| 909 plItem * plList = NULL; | |
| 910 plItem * plLastPlayed = NULL; | |
| 911 | |
| 912 URLItem *URLList = NULL; | |
| 913 | |
| 914 char *fsHistory[fsPersistant_MaxPos] = { NULL,NULL,NULL,NULL,NULL }; | |
| 915 | |
| 916 #if defined( MP_DEBUG ) && 0 | |
| 917 void list( void ) | |
| 918 { | |
| 919 plItem * next = plList; | |
| 920 printf( "--- list ---\n" ); | |
| 921 while( next || next->next ) | |
| 922 { | |
| 923 printf( "item: %s/%s\n",next->path,next->name ); | |
| 924 if ( next->next ) next=next->next; else break; | |
| 925 } | |
| 926 printf( "--- end of list ---\n" ); | |
| 927 } | |
| 928 #else | |
| 929 #define list(); | |
| 930 #endif | |
| 931 | |
| 932 void * gtkSet( int cmd,float fparam, void * vparam ) | |
| 933 { | |
| 934 equalizer_t * eq = (equalizer_t *)vparam; | |
| 935 plItem * item = (plItem *)vparam; | |
| 936 | |
| 937 URLItem * url_item = (URLItem *)vparam; | |
| 938 int is_added = True; | |
| 939 | |
| 940 switch ( cmd ) | |
| 941 { | |
| 942 // --- handle playlist | |
| 943 case gtkAddPlItem: // add item to playlist | |
| 944 if ( plList ) | |
| 945 { | |
| 946 plItem * next = plList; | |
| 947 while ( next->next ) { /*printf( "%s\n",next->name );*/ next=next->next; } | |
| 948 next->next=item; item->prev=next; | |
| 949 } else { item->prev=item->next=NULL; plCurrent=plList=item; } | |
| 950 list(); | |
| 951 return NULL; | |
| 952 case gtkInsertPlItem: // add item into playlist after current | |
| 953 if ( plCurrent ) | |
| 954 { | |
| 955 plItem * curr = plCurrent; | |
| 956 item->next=curr->next; | |
| 957 if (item->next) | |
| 958 item->next->prev=item; | |
| 959 item->prev=curr; | |
| 960 curr->next=item; | |
| 961 plCurrent=plCurrent->next; | |
| 962 return plCurrent; | |
| 963 } | |
| 964 else | |
| 965 return gtkSet(gtkAddPlItem,0,(void*)item); | |
| 966 return NULL; | |
| 967 case gtkGetNextPlItem: // get current item from playlist | |
| 968 if ( plCurrent && plCurrent->next) | |
| 969 { | |
| 970 plCurrent=plCurrent->next; | |
| 971 /*if ( !plCurrent && plList ) | |
| 972 { | |
| 973 plItem * next = plList; | |
| 974 while ( next->next ) { if ( !next->next ) break; next=next->next; } | |
| 975 plCurrent=next; | |
| 976 }*/ | |
| 977 return plCurrent; | |
| 978 } | |
| 979 return NULL; | |
| 980 case gtkGetPrevPlItem: | |
| 981 if ( plCurrent && plCurrent->prev) | |
| 982 { | |
| 983 plCurrent=plCurrent->prev; | |
| 984 //if ( !plCurrent && plList ) plCurrent=plList; | |
| 985 return plCurrent; | |
| 986 } | |
| 987 return NULL; | |
| 988 case gtkSetCurrPlItem: // set current item | |
| 989 plCurrent=item; | |
| 990 return plCurrent; | |
| 991 case gtkGetCurrPlItem: // get current item | |
| 992 return plCurrent; | |
| 993 case gtkDelCurrPlItem: // delete current item | |
| 994 { | |
| 995 plItem * curr = plCurrent; | |
| 996 | |
| 997 if (!curr) | |
| 998 return NULL; | |
| 999 if (curr->prev) | |
| 1000 curr->prev->next=curr->next; | |
| 1001 if (curr->next) | |
| 1002 curr->next->prev=curr->prev; | |
| 1003 if (curr==plList) | |
| 1004 plList=curr->next; | |
| 1005 plCurrent=curr->next; | |
| 1006 // Free it | |
| 1007 if ( curr->path ) free( curr->path ); | |
| 1008 if ( curr->name ) free( curr->name ); | |
| 1009 free( curr ); | |
| 1010 } | |
| 1011 mplCurr(); // Instead of using mplNext && mplPrev | |
| 1012 | |
| 1013 return plCurrent; | |
| 1014 case gtkDelPl: // delete list | |
| 1015 { | |
| 1016 plItem * curr = plList; | |
| 1017 plItem * next; | |
| 1018 if ( !plList ) return NULL; | |
| 1019 if ( !curr->next ) | |
| 1020 { | |
| 1021 if ( curr->path ) free( curr->path ); | |
| 1022 if ( curr->name ) free( curr->name ); | |
| 1023 free( curr ); | |
| 1024 } | |
| 1025 else | |
| 1026 { | |
| 1027 while ( curr->next ) | |
| 1028 { | |
| 1029 next=curr->next; | |
| 1030 if ( curr->path ) free( curr->path ); | |
| 1031 if ( curr->name ) free( curr->name ); | |
| 1032 free( curr ); | |
| 1033 curr=next; | |
| 1034 } | |
| 1035 } | |
| 1036 plList=NULL; plCurrent=NULL; | |
| 1037 } | |
| 1038 return NULL; | |
| 1039 // ----- Handle url | |
| 1040 case gtkAddURLItem: | |
| 1041 if ( URLList ) | |
| 1042 { | |
| 1043 URLItem * next_url = URLList; | |
| 1044 is_added = False; | |
| 1045 while ( next_url->next ) | |
| 1046 { | |
| 1047 if ( !gstrcmp( next_url->url,url_item->url ) ) | |
| 1048 { | |
| 1049 is_added=True; | |
| 1050 break; | |
| 1051 } | |
| 1052 next_url=next_url->next; | |
| 1053 } | |
| 1054 if ( ( !is_added )&&( gstrcmp( next_url->url,url_item->url ) ) ) next_url->next=url_item; | |
| 1055 } else { url_item->next=NULL; URLList=url_item; } | |
| 1056 return NULL; | |
| 1057 // --- subtitle | |
| 1058 #ifndef HAVE_FREETYPE | |
| 1059 case gtkSetFontFactor: | |
| 1060 font_factor=fparam; | |
| 1061 guiLoadFont(); | |
| 1062 return NULL; | |
| 1063 #else | |
| 1064 case gtkSetFontOutLine: | |
| 1065 subtitle_font_thickness=( 8.0f / 100.0f ) * fparam; | |
| 1066 guiLoadFont(); | |
| 1067 return NULL; | |
| 1068 case gtkSetFontBlur: | |
| 1069 subtitle_font_radius=( 8.0f / 100.0f ) * fparam; | |
| 1070 guiLoadFont(); | |
| 1071 return NULL; | |
| 1072 case gtkSetFontTextScale: | |
| 1073 text_font_scale_factor=fparam; | |
| 1074 guiLoadFont(); | |
| 1075 return NULL; | |
| 1076 case gtkSetFontOSDScale: | |
| 1077 osd_font_scale_factor=fparam; | |
| 1078 guiLoadFont(); | |
| 1079 return NULL; | |
| 1080 case gtkSetFontEncoding: | |
| 1081 gfree( (void **)&subtitle_font_encoding ); | |
| 1082 subtitle_font_encoding=gstrdup( (char *)vparam ); | |
| 1083 guiLoadFont(); | |
| 1084 return NULL; | |
| 1085 case gtkSetFontAutoScale: | |
| 1086 subtitle_autoscale=(int)fparam; | |
| 1087 guiLoadFont(); | |
| 1088 return NULL; | |
| 1089 #endif | |
| 1090 #ifdef USE_ICONV | |
| 1091 case gtkSetSubEncoding: | |
| 1092 gfree( (void **)&sub_cp ); | |
| 1093 sub_cp=gstrdup( (char *)vparam ); | |
| 1094 break; | |
| 1095 #endif | |
| 1096 // --- misc | |
| 1097 case gtkClearStruct: | |
| 1098 if ( (unsigned int)vparam & guiFilenames ) | |
| 1099 { | |
| 1100 gfree( (void **)&guiIntfStruct.Filename ); | |
| 1101 gfree( (void **)&guiIntfStruct.Subtitlename ); | |
| 1102 gfree( (void **)&guiIntfStruct.AudioFile ); | |
| 1103 gtkSet( gtkDelPl,0,NULL ); | |
| 1104 } | |
| 1105 #ifdef USE_DVDREAD | |
| 1106 if ( (unsigned int)vparam & guiDVD ) memset( &guiIntfStruct.DVD,0,sizeof( guiDVDStruct ) ); | |
| 1107 #endif | |
| 1108 #ifdef HAVE_VCD | |
| 1109 if ( (unsigned int)vparam & guiVCD ) guiIntfStruct.VCDTracks=0; | |
| 1110 #endif | |
| 1111 return NULL; | |
| 1112 case gtkSetExtraStereo: | |
| 1113 gtkAOExtraStereoMul=fparam; | |
| 1114 if (guiIntfStruct.afilter) | |
| 1115 af_control_any_rev(guiIntfStruct.afilter, | |
| 1116 AF_CONTROL_ES_MUL | AF_CONTROL_SET, >kAOExtraStereoMul); | |
| 1117 return NULL; | |
| 1118 case gtkSetPanscan: | |
| 1119 { | |
| 1120 mp_cmd_t * mp_cmd; | |
| 1121 mp_cmd=calloc( 1,sizeof( *mp_cmd ) ); | |
| 1122 mp_cmd->id=MP_CMD_PANSCAN; mp_cmd->name=strdup( "panscan" ); | |
| 1123 mp_cmd->args[0].v.f=fparam; mp_cmd->args[1].v.i=1; | |
| 1124 mp_input_queue_cmd( mp_cmd ); | |
| 1125 } | |
| 1126 return NULL; | |
| 1127 case gtkSetAutoq: | |
| 1128 auto_quality=(int)fparam; | |
| 1129 return NULL; | |
| 1130 // --- set equalizers | |
| 1131 case gtkSetContrast: | |
| 1132 if ( guiIntfStruct.sh_video ) set_video_colors( guiIntfStruct.sh_video,"contrast",(int)fparam ); | |
| 1133 return NULL; | |
| 1134 case gtkSetBrightness: | |
| 1135 if ( guiIntfStruct.sh_video ) set_video_colors( guiIntfStruct.sh_video,"brightness",(int)fparam ); | |
| 1136 return NULL; | |
| 1137 case gtkSetHue: | |
| 1138 if ( guiIntfStruct.sh_video ) set_video_colors( guiIntfStruct.sh_video,"hue",(int)fparam ); | |
| 1139 return NULL; | |
| 1140 case gtkSetSaturation: | |
| 1141 if ( guiIntfStruct.sh_video ) set_video_colors( guiIntfStruct.sh_video,"saturation",(int)fparam ); | |
| 1142 return NULL; | |
| 1143 case gtkSetEqualizer: | |
| 1144 { | |
| 1145 af_control_ext_t tmp; | |
| 1146 if ( eq ) | |
| 1147 { | |
| 1148 gtkEquChannels[eq->channel][eq->band]=eq->gain; | |
| 1149 tmp.ch = eq->channel; | |
| 1150 tmp.arg = gtkEquChannels[eq->channel]; | |
| 1151 if (guiIntfStruct.afilter) | |
| 1152 af_control_any_rev(guiIntfStruct.afilter, | |
| 1153 AF_CONTROL_EQUALIZER_GAIN | AF_CONTROL_SET, &tmp); | |
| 1154 } | |
| 1155 else | |
| 1156 { | |
| 1157 int i; | |
| 1158 memset( gtkEquChannels,0,sizeof( gtkEquChannels ) ); | |
| 1159 if (guiIntfStruct.afilter) | |
| 1160 for ( i=0;i<6;i++ ) | |
| 1161 { | |
| 1162 tmp.ch = i; | |
| 1163 tmp.arg = gtkEquChannels[i]; | |
| 1164 af_control_any_rev(guiIntfStruct.afilter, | |
| 1165 AF_CONTROL_EQUALIZER_GAIN | AF_CONTROL_SET, &tmp); | |
| 1166 } | |
| 1167 } | |
| 1168 return NULL; | |
| 1169 } | |
| 1170 } | |
| 1171 return NULL; | |
| 1172 } | |
| 1173 | |
| 1174 #define mp_basename(s) (strrchr(s,'/')==NULL?(char*)s:(strrchr(s,'/')+1)) | |
| 1175 | |
| 1176 #include "playtree.h" | |
| 1177 | |
| 1178 //This function adds/inserts one file into the gui playlist | |
| 1179 | |
| 1180 int import_file_into_gui(char* temp, int insert) | |
| 1181 { | |
| 1182 char *filename, *pathname; | |
| 1183 plItem * item; | |
| 1184 | |
| 1185 filename = strdup(mp_basename(temp)); | |
| 1186 pathname = strdup(temp); | |
| 1187 if (strlen(pathname)-strlen(filename)>0) | |
| 1188 pathname[strlen(pathname)-strlen(filename)-1]='\0'; // We have some path so remove / at end | |
| 1189 else | |
| 1190 pathname[strlen(pathname)-strlen(filename)]='\0'; | |
| 1191 mp_msg(MSGT_PLAYTREE,MSGL_V, "Adding filename %s && pathname %s\n",filename,pathname); //FIXME: Change to MSGL_DBG2 ? | |
| 1192 item=calloc( 1,sizeof( plItem ) ); | |
| 1193 if (!item) | |
| 1194 return 0; | |
| 1195 item->name=filename; | |
| 1196 item->path=pathname; | |
| 1197 if (insert) | |
| 1198 gtkSet( gtkInsertPlItem,0,(void*)item ); // Inserts the item after current, and makes current=item | |
| 1199 else | |
| 1200 gtkSet( gtkAddPlItem,0,(void*)item ); | |
| 1201 return 1; | |
| 1202 } | |
| 1203 | |
| 1204 | |
| 1205 // This function imports the initial playtree (based on cmd-line files) into the gui playlist | |
| 1206 // by either: | |
| 1207 // - overwriting gui pl (enqueue=0) | |
| 1208 // - appending it to gui pl (enqueue=1) | |
| 1209 | |
| 1210 int import_initial_playtree_into_gui(play_tree_t* my_playtree, m_config_t* config, int enqueue) | |
| 1211 { | |
| 1212 play_tree_iter_t* my_pt_iter=NULL; | |
| 1213 int result=0; | |
| 1214 | |
| 1215 if (!enqueue) // Delete playlist before "appending" | |
| 1216 gtkSet(gtkDelPl,0,0); | |
| 1217 | |
| 1218 if((my_pt_iter=pt_iter_create(&my_playtree,config))) | |
| 1219 { | |
| 1220 while ((filename=pt_iter_get_next_file(my_pt_iter))!=NULL) | |
| 1221 { | |
| 1222 if (import_file_into_gui(filename, 0)) // Add it to end of list | |
| 1223 result=1; | |
| 1224 } | |
| 1225 } | |
| 1226 | |
| 1227 mplCurr(); // Update filename | |
| 1228 mplGotoTheNext=1; | |
| 1229 | |
| 1230 if (!enqueue) | |
| 1231 filename=guiIntfStruct.Filename; // Backward compatibility; if file is specified on commandline, | |
| 1232 // gmplayer does directly start in Play-Mode. | |
| 1233 else | |
| 1234 filename=NULL; | |
| 1235 | |
| 1236 return result; | |
| 1237 } | |
| 1238 | |
| 1239 // This function imports and inserts an playtree, that is created "on the fly", for example by | |
| 1240 // parsing some MOV-Reference-File; or by loading an playlist with "File Open" | |
| 1241 // | |
| 1242 // The file which contained the playlist is thereby replaced with it's contents. | |
| 1243 | |
| 1244 int import_playtree_playlist_into_gui(play_tree_t* my_playtree, m_config_t* config) | |
| 1245 { | |
| 1246 play_tree_iter_t* my_pt_iter=NULL; | |
| 1247 int result=0; | |
| 1248 plItem * save=(plItem*)gtkSet( gtkGetCurrPlItem, 0, 0); // Save current item | |
| 1249 | |
| 1250 if((my_pt_iter=pt_iter_create(&my_playtree,config))) | |
| 1251 { | |
| 1252 while ((filename=pt_iter_get_next_file(my_pt_iter))!=NULL) | |
| 1253 { | |
| 1254 if (import_file_into_gui(filename, 1)) // insert it into the list and set plCurrent=new item | |
| 1255 result=1; | |
| 1256 } | |
| 1257 pt_iter_destroy(&my_pt_iter); | |
| 1258 } | |
| 1259 | |
| 1260 if (save) | |
| 1261 gtkSet(gtkSetCurrPlItem, 0, (void*)save); | |
| 1262 else | |
| 1263 gtkSet(gtkSetCurrPlItem, 0, (void*)plList); // go to head, if plList was empty before | |
| 1264 | |
| 1265 if (save && result) | |
| 1266 gtkSet(gtkDelCurrPlItem, 0, 0); | |
| 1267 | |
| 1268 mplCurr(); // Update filename | |
| 1269 filename=NULL; | |
| 1270 | |
| 1271 return result; | |
| 1272 } | |
| 1273 | |
| 1274 // wrapper function for mp_msg to display a message box for errors and warnings. | |
| 1275 | |
| 1276 void guiMessageBox(int level, char * str) { | |
| 1277 switch(level) { | |
| 1278 case MSGL_FATAL: | |
| 1279 gtkMessageBox(GTK_MB_FATAL|GTK_MB_SIMPLE, str); | |
| 1280 break; | |
| 1281 case MSGL_ERR: | |
| 1282 gtkMessageBox(GTK_MB_ERROR|GTK_MB_SIMPLE, str); | |
| 1283 break; | |
| 1284 #if 0 | |
| 1285 // WARNING! Do NOT enable this! There are too many non-critical messages with | |
| 1286 // MSGL_WARN, for example: broken SPU packets, codec's bit error messages, | |
| 1287 // etc etc, they should not raise up a new window every time. | |
| 1288 case MSGL_WARN: | |
| 1289 gtkMessageBox(GTK_MB_WARNING|GTK_MB_SIMPLE, str); | |
| 1290 break; | |
| 1291 #endif | |
| 1292 } | |
| 1293 } |
