int main(int argc, char *argv[]) { switch (argc) { case 1: printf("Loading Playlist %d\n", argc); init(); play_cur_dir(); break; case 2: if (init()) play(argv[1]); else exit_player("ERROR", "Unable to Load BASS Library"); break; case 3: init(); strcpy(path, argv[1]); printf("%s", path); play_cur_dir(); break; default: exit_player("ERROR", "Too many parameters"); printf("--------syntax-----------"); printf("play file_name.mp3\t-- to play a mp3\n"); printf("play folder_name folder\t-- to play a folder\n"); break; } shell(); }
static void pnm_write_image(mp_image_t *mpi) { static int framenum = 0, framecounter = 0, subdircounter = 0; char buf[BUFLENGTH]; static char subdirname[BUFLENGTH] = ""; FILE *outfile; if (!mpi) { mp_msg(MSGT_VO, MSGL_ERR, "%s: No image data suplied to video output driver\n", info.short_name ); exit_player(MSGTR_Exit_error); } /* Start writing to new subdirectory after a certain amount of frames */ if ( framecounter == pnm_maxfiles ) { framecounter = 0; } /* If framecounter is zero (or reset to zero), increment subdirectory * number and create the subdirectory. * If pnm_subdirs is not set, do nothing. */ if ( !framecounter && pnm_subdirs ) { subdircounter++; snprintf(subdirname, BUFLENGTH, "%s%08d", pnm_subdirs, subdircounter); snprintf(buf, BUFLENGTH, "%s/%s", pnm_outdir, subdirname); pnm_mkdir(buf, 0); /* This function only returns if creation was successful. If not, the player will exit. */ } framenum++; framecounter++; /* snprintf the full pathname of the outputfile */ snprintf(buf, BUFLENGTH, "%s/%s/%08d.%s", pnm_outdir, subdirname, framenum, pnm_file_extension); if ( (outfile = fopen(buf, "wb") ) == NULL ) { mp_msg(MSGT_VO, MSGL_ERR, "\n%s: %s\n", info.short_name, MSGTR_VO_CantCreateFile); mp_msg(MSGT_VO, MSGL_ERR, "%s: %s: %s\n", info.short_name, MSGTR_VO_GenericError, strerror(errno) ); exit_player(MSGTR_Exit_error); } pnm_write_pnm(outfile, mpi); fclose(outfile); }
static unsigned __stdcall GuiThread(void* param) { MSG msg; (void) param; if(!skinName) skinName = strdup("Blue"); if(!mygui) mygui = create_gui(get_path("skins"), guiSetEvent); if(!mygui) exit_player(EXIT_ERROR); if(autosync && autosync != gtkAutoSync) { gtkAutoSyncOn = TRUE; gtkAutoSync = autosync; } while(GetMessage(&msg, NULL, 0, 0)) { TranslateMessage(&msg); DispatchMessage(&msg); } fprintf(stderr, "[GUI] GUI thread terminated.\n"); fflush(stderr); return 0; }
const ao_functions_t* init_best_audio_out(char** ao_list,int use_plugin,int rate,int channels,int format,int flags){ int i; // first try the preferred drivers, with their optional subdevice param: if(ao_list && ao_list[0]) while(ao_list[0][0]){ char* ao=ao_list[0]; int ao_len; if (strncmp(ao, "alsa9", 5) == 0 || strncmp(ao, "alsa1x", 6) == 0) { mp_msg(MSGT_AO, MSGL_FATAL, MSGTR_AO_ALSA9_1x_Removed); exit_player(EXIT_NONE); } if (ao_subdevice) { free(ao_subdevice); ao_subdevice = NULL; } ao_subdevice=strchr(ao,':'); if(ao_subdevice){ ao_len = ao_subdevice - ao; ao_subdevice = strdup(&ao[ao_len + 1]); } else ao_len = strlen(ao); mp_msg(MSGT_AO, MSGL_V, MSGTR_AO_TryingPreferredAudioDriver, ao_len, ao, ao_subdevice ? ao_subdevice : "[none]"); for(i=0;audio_out_drivers[i];i++){ const ao_functions_t* audio_out=audio_out_drivers[i]; if(!strncmp(audio_out->info->short_name,ao,ao_len)){ // name matches, try it if(audio_out->init(rate,channels,format,flags)) return audio_out; // success! else mp_msg(MSGT_AO, MSGL_WARN, MSGTR_AO_FailedInit, ao); break; } } if (!audio_out_drivers[i]) // we searched through the entire list mp_msg(MSGT_AO, MSGL_WARN, MSGTR_AO_NoSuchDriver, ao_len, ao); // continue... ++ao_list; if(!(ao_list[0])) return NULL; // do NOT fallback to others } if (ao_subdevice) { free(ao_subdevice); ao_subdevice = NULL; } mp_msg(MSGT_AO, MSGL_V, MSGTR_AO_TryingEveryKnown); // now try the rest... for(i=0;audio_out_drivers[i];i++){ const ao_functions_t* audio_out=audio_out_drivers[i]; // if(audio_out->control(AOCONTROL_QUERY_FORMAT, (int)format) == CONTROL_TRUE) if(audio_out->init(rate,channels,format,flags)) return audio_out; // success! } return NULL; }
static int config(uint32_t width, uint32_t height, uint32_t d_width, uint32_t d_height, uint32_t flags, char *title, uint32_t format) { int success, success2; if (vo_config_count > 0 ) { /* Already configured */ return 0; } if (strcmp(fc_dumpfile, "-") == 0) dumpfile_fd = stdout; else if ( (dumpfile_fd = fopen(fc_dumpfile, "w") ) == NULL ) { mp_msg(MSGT_VO, MSGL_ERR, "\n%s: %s\n", info.short_name, MSGTR_VO_CantCreateFile); mp_msg(MSGT_VO, MSGL_ERR, "%s: %s: %s\n", info.short_name, MSGTR_VO_GenericError, strerror(errno) ); exit_player(EXIT_ERROR); } /* Add fullcirce stuff */ client = fcclient_new(); fprintf(dumpfile_fd, "# IP %s\n", fc_ip); success = fcclient_open(client, fc_ip); if (!success) { fprintf(dumpfile_fd, "Cannot connect to wall\n"); return 1; } else { printf("======== Fullcircle - Connecting ==========\n", success); do { /* call this function until we were successfull in receiving something */ success = fcclient_processNetwork(client); fprintf(dumpfile_fd, "Network: %d\n", success); /*FIXME update the function using "select()" with an timeout */ } while (!success); /* the server has answered */ success2 = fcclient_start(client); fprintf(dumpfile_fd, "Start: %d\n", success2); frame = malloc(client->width * client->height * 20); printf("======== Fullcircle - Waiting for start signal ==========\n", success); do { success = fcclient_processNetwork(client); fprintf(dumpfile_fd, "Received data [%d]\n", success); printf("."); } while (!client->connected); printf("\n"); } return 0; }
void play_cur_dir() { if (init_file_list()) { if (status == 1) stop(); play_list(); } else exit_player("ERROR", "Playlist cannot be made"); }
ao_functions_t* init_best_audio_out(char** ao_list,int use_plugin,int rate,int channels,int format,int flags){ int i; #ifndef __LINUX__ { // kprintf("init_best_audio_out:\n"); ao_functions_t* audio_out=&audio_out_noahos; // ao_functions_t* audio_out=&audio_out_pcm; if(audio_out->init(rate,channels,format,flags)) return audio_out; // success! } #endif // first try the preferred drivers, with their optional subdevice param: if(ao_list && ao_list[0]) while(ao_list[0][0]){ char* ao=ao_list[0]; int ao_len; if (strncmp(ao, "alsa9", 5) == 0 || strncmp(ao, "alsa1x", 6) == 0) { mp_msg(MSGT_AO, MSGL_FATAL, MSGTR_AO_ALSA9_1x_Removed); exit_player(NULL); } if (ao_subdevice) { free(ao_subdevice); ao_subdevice = NULL; } ao_subdevice=strchr(ao,':'); if(ao_subdevice){ ao_len = ao_subdevice - ao; ao_subdevice = strdup(&ao[ao_len + 1]); } else ao_len = strlen(ao); for(i=0;audio_out_drivers[i];i++){ ao_functions_t* audio_out=audio_out_drivers[i]; if(!strncmp(audio_out->info->short_name,ao,ao_len)){ // name matches, try it if(audio_out->init(rate,channels,format,flags)) return audio_out; // success! } } // continue... ++ao_list; if(!(ao_list[0])) return NULL; // do NOT fallback to others } if (ao_subdevice) { free(ao_subdevice); ao_subdevice = NULL; } // now try the rest... for(i=0;audio_out_drivers[i];i++){ ao_functions_t* audio_out=audio_out_drivers[i]; // if(audio_out->control(AOCONTROL_QUERY_FORMAT, (int)format) == CONTROL_TRUE) if(audio_out->init(rate,channels,format,flags)) return audio_out; // success! } return NULL; }
void shell() { printf("Type h for help\n"); printf("mp3 > "); while (key = getchar()) { switch (key) { case 'e': exit_player("Closed", "Program Exiting"); break; case 'i': getInfo(0); break; case 's': stop(); break; case 'p': if (status == 1) { BASS_ChannelPause(stream); status = 0; } else if (status == 0) { BASS_ChannelPlay(stream, 0); status = 1; } else if (status == 2) { play(getFile()); } break; case 'n': if (playcount < toatalcount) playcount++; else playcount = 1; play_list(); break; case 'b': if (playcount <= 1) playcount = toatalcount; else playcount--; play_list(); break; case 'h': help(); break; case 'a': printf("M2O2 player v0.2\n"); break; default: printf("mp3 > "); } } }
void mplSubDraw( void ) { if ( appMPlayer.subWindow.State == wsWindowClosed ) exit_player( EXIT_QUIT ); if ( appMPlayer.subWindow.State == wsWindowFocusIn ) SubVisible++; if ( appMPlayer.subWindow.State == wsWindowFocusOut && metacity_hack != 3 ) SubVisible--; if ( !appMPlayer.subWindow.Mapped || appMPlayer.subWindow.Visible == wsWindowNotVisible ) return; if ( guiIntfStruct.Playing ) mplSubRender=0; if ( mplSubRender && appMPlayer.subWindow.State == wsWindowExpose ) { if ( appMPlayer.sub.Bitmap.Image ) wsPutImage( &appMPlayer.subWindow ); } appMPlayer.subWindow.State=0; }
static int config(uint32_t width, uint32_t height, uint32_t d_width, uint32_t d_height, uint32_t flags, char *title, uint32_t format) { if (vo_config_count > 0 ) { /* Already configured */ return 0; } if ( (md5sum_fd = fopen(md5sum_outfile, "w") ) == NULL ) { mp_msg(MSGT_VO, MSGL_ERR, "\n%s: %s\n", info.short_name, MSGTR_VO_CantCreateFile); mp_msg(MSGT_VO, MSGL_ERR, "%s: %s: %s\n", info.short_name, MSGTR_VO_GenericError, strerror(errno) ); exit_player(EXIT_ERROR); } return 0; }
void mplMainDraw( void ) { if ( appMPlayer.mainWindow.State == wsWindowClosed ) exit_player( MSGTR_Exit_quit ); if ( appMPlayer.mainWindow.Visible == wsWindowNotVisible || !mainVisible ) return; // !appMPlayer.mainWindow.Mapped ) return; if ( mplMainRender && appMPlayer.mainWindow.State == wsWindowExpose ) { btnModify( evSetMoviePosition,guiIntfStruct.Position ); btnModify( evSetVolume,guiIntfStruct.Volume ); fast_memcpy( mplDrawBuffer,appMPlayer.main.Bitmap.Image,appMPlayer.main.Bitmap.ImageSize ); Render( &appMPlayer.mainWindow,appMPlayer.Items,appMPlayer.NumberOfItems,mplDrawBuffer,appMPlayer.main.Bitmap.ImageSize ); mplMainRender=0; } wsPutImage( &appMPlayer.mainWindow ); // XFlush( wsDisplay ); }
static void png_mkdir(char *buf, int verbose) { struct stat stat_p; #ifndef __MINGW32__ if ( mkdir(buf, 0755) < 0 ) { #else if ( mkdir(buf) < 0 ) { #endif switch (errno) { /* use switch in case other errors need to be caught and handled in the future */ case EEXIST: if ( stat(buf, &stat_p ) < 0 ) { mp_msg(MSGT_VO, MSGL_ERR, "%s: %s: %s\n", info.short_name, MSGTR_VO_GenericError, strerror(errno) ); mp_msg(MSGT_VO, MSGL_ERR, "%s: %s %s\n", info.short_name, MSGTR_VO_UnableToAccess,buf); exit_player(EXIT_ERROR); } if ( !S_ISDIR(stat_p.st_mode) ) { mp_msg(MSGT_VO, MSGL_ERR, "%s: %s %s\n", info.short_name, buf, MSGTR_VO_ExistsButNoDirectory); exit_player(EXIT_ERROR); } if ( !(stat_p.st_mode & S_IWUSR) ) { mp_msg(MSGT_VO, MSGL_ERR, "%s: %s - %s\n", info.short_name, buf, MSGTR_VO_DirExistsButNotWritable); exit_player(EXIT_ERROR); } mp_msg(MSGT_VO, MSGL_INFO, "%s: %s: %s\n", info.short_name, MSGTR_VO_OutputDirectory, buf); break; default: mp_msg(MSGT_VO, MSGL_ERR, "%s: %s: %s\n", info.short_name, MSGTR_VO_GenericError, strerror(errno) ); mp_msg(MSGT_VO, MSGL_ERR, "%s: %s - %s\n", info.short_name, buf, MSGTR_VO_CantCreateDirectory); exit_player(EXIT_ERROR); } /* end switch */ } else if ( verbose ) { mp_msg(MSGT_VO, MSGL_INFO, "%s: %s - %s\n", info.short_name, buf, MSGTR_VO_DirectoryCreateSuccess); } /* end if */ } static int config(uint32_t width, uint32_t height, uint32_t d_width, uint32_t d_height, uint32_t flags, char *title, uint32_t format) { char buf[BUFLENGTH]; if(z_compression == 0) { mp_msg(MSGT_VO,MSGL_INFO, MSGTR_LIBVO_PNG_Warning1); mp_msg(MSGT_VO,MSGL_INFO, MSGTR_LIBVO_PNG_Warning2); mp_msg(MSGT_VO,MSGL_INFO, MSGTR_LIBVO_PNG_Warning3); } snprintf(buf, BUFLENGTH, "%s", png_outdir); png_mkdir(buf, 1); mp_msg(MSGT_VO,MSGL_DBG2, "PNG Compression level %i\n", z_compression); if (avctx && png_format != format) { avcodec_close(avctx); av_freep(&avctx); } if (!avctx) { avctx = avcodec_alloc_context3(NULL); avctx->compression_level = z_compression; avctx->pix_fmt = imgfmt2pixfmt(format); avctx->width = width; avctx->height = height; if (avcodec_open2(avctx, avcodec_find_encoder(AV_CODEC_ID_PNG), NULL) < 0) { uninit(); return -1; } png_format = format; } return 0; }
static void pnm_mkdir(char *buf, int verbose) { struct stat stat_p; /* Silly MING32 bug workaround */ #ifndef __MINGW32__ if ( mkdir(buf, 0755) < 0 ) { #else if ( mkdir(buf) < 0 ) { #endif switch (errno) { /* use switch in case other errors need to be caught and handled in the future */ case EEXIST: if ( stat(buf, &stat_p ) < 0 ) { mp_msg(MSGT_VO, MSGL_ERR, "%s: %s: %s\n", info.short_name, MSGTR_VO_GenericError, strerror(errno) ); mp_msg(MSGT_VO, MSGL_ERR, "%s: %s %s\n", info.short_name, MSGTR_VO_UnableToAccess,buf); exit_player(MSGTR_Exit_error); } if ( !S_ISDIR(stat_p.st_mode) ) { mp_msg(MSGT_VO, MSGL_ERR, "%s: %s %s\n", info.short_name, buf, MSGTR_VO_ExistsButNoDirectory); exit_player(MSGTR_Exit_error); } if ( !(stat_p.st_mode & S_IWUSR) ) { mp_msg(MSGT_VO, MSGL_ERR, "%s: %s - %s\n", info.short_name, buf, MSGTR_VO_DirExistsButNotWritable); exit_player(MSGTR_Exit_error); } if (strcmp(buf, ".") != 0) { mp_msg(MSGT_VO, MSGL_INFO, "%s: %s - %s\n", info.short_name, buf, MSGTR_VO_DirExistsAndIsWritable); } break; default: mp_msg(MSGT_VO, MSGL_ERR, "%s: %s: %s\n", info.short_name, MSGTR_VO_GenericError, strerror(errno) ); mp_msg(MSGT_VO, MSGL_ERR, "%s: %s - %s\n", info.short_name, buf, MSGTR_VO_CantCreateDirectory); exit_player(MSGTR_Exit_error); } /* end switch */ } else if ( verbose ) { mp_msg(MSGT_VO, MSGL_INFO, "%s: %s - %s\n", info.short_name, buf, MSGTR_VO_DirectoryCreateSuccess); } /* end if */ } /* ------------------------------------------------------------------------- */ /** \brief Configure the video output driver. * * This functions configures the video output driver. It determines the * width and height of the image(s) and creates the output directory. * * \return 0 All went well. */ static int config(uint32_t width, uint32_t height, uint32_t d_width, uint32_t d_height, uint32_t flags, char *title, uint32_t format) { char buf[BUFLENGTH]; if (vo_config_count > 0 ) { /* Already configured */ return 0; } /* Create outdir. */ snprintf(buf, BUFLENGTH, "%s", pnm_outdir); pnm_mkdir(buf, 1); /* This function only returns if creation was successful. If not, the player will exit. */ if (pnm_type == PNM_TYPE_PPM) { pnm_file_extension = strdup("ppm"); } else if (pnm_type == PNM_TYPE_PGM) { pnm_file_extension = strdup("pgm"); } else if (pnm_type == PNM_TYPE_PGMYUV) { pnm_file_extension = strdup("pgmyuv"); } return 0; }
void mplEventHandling( int msg,float param ) { int iparam = (int)param; mixer_t *mixer = mpctx_get_mixer(guiIntfStruct.mpcontext); switch( msg ) { // --- user events case evExit: exit_player( "Exit" ); break; case evPlayNetwork: gfree( (void **)&guiIntfStruct.Subtitlename ); gfree( (void **)&guiIntfStruct.AudioFile ); guiIntfStruct.StreamType=STREAMTYPE_STREAM; goto play; case evSetURL: gtkShow( evPlayNetwork,NULL ); break; case evSetAudio: if ( !guiIntfStruct.demuxer || audio_id == iparam ) break; audio_id=iparam; goto play; case evSetVideo: if ( !guiIntfStruct.demuxer || video_id == iparam ) break; video_id=iparam; goto play; case evSetSubtitle: mp_property_do("sub",M_PROPERTY_SET,&iparam,guiIntfStruct.mpcontext); break; #ifdef CONFIG_VCD case evSetVCDTrack: guiIntfStruct.Track=iparam; case evPlayVCD: gtkSet( gtkClearStruct,0,(void *)guiALL ); guiIntfStruct.StreamType=STREAMTYPE_VCD; goto play; #endif #ifdef CONFIG_DVDREAD case evPlayDVD: guiIntfStruct.DVD.current_title=1; guiIntfStruct.DVD.current_chapter=1; guiIntfStruct.DVD.current_angle=1; play_dvd_2: gtkSet( gtkClearStruct,0,(void *)(guiALL - guiDVD) ); guiIntfStruct.StreamType=STREAMTYPE_DVD; goto play; #endif case evPlay: case evPlaySwitchToPause: play: if ( ( msg == evPlaySwitchToPause )&&( guiIntfStruct.Playing == 2 ) ) goto NoPause; if ( gtkSet( gtkGetCurrPlItem,0,NULL ) &&( guiIntfStruct.StreamType == STREAMTYPE_FILE ) ) { plItem * next = gtkSet( gtkGetCurrPlItem,0,NULL ); plLastPlayed=next; mplSetFileName( next->path,next->name,STREAMTYPE_FILE ); } switch ( guiIntfStruct.StreamType ) { case STREAMTYPE_STREAM: case STREAMTYPE_FILE: gtkSet( gtkClearStruct,0,(void *)(guiALL - guiFilenames) ); break; #ifdef CONFIG_VCD case STREAMTYPE_VCD: gtkSet( gtkClearStruct,0,(void *)(guiALL - guiVCD - guiFilenames) ); if ( !cdrom_device ) cdrom_device=gstrdup( DEFAULT_CDROM_DEVICE ); mplSetFileName( NULL,cdrom_device,STREAMTYPE_VCD ); if ( guiIntfStruct.Playing != 2 ) { if ( !guiIntfStruct.Track ) { if ( guiIntfStruct.VCDTracks > 1 ) guiIntfStruct.Track=2; else guiIntfStruct.Track=1; } guiIntfStruct.DiskChanged=1; } break; #endif #ifdef CONFIG_DVDREAD case STREAMTYPE_DVD: gtkSet( gtkClearStruct,0,(void *)(guiALL - guiDVD - guiFilenames) ); if ( !dvd_device ) dvd_device=gstrdup( DEFAULT_DVD_DEVICE ); mplSetFileName( NULL,dvd_device,STREAMTYPE_DVD ); if ( guiIntfStruct.Playing != 2 ) { guiIntfStruct.Title=guiIntfStruct.DVD.current_title; guiIntfStruct.Chapter=guiIntfStruct.DVD.current_chapter; guiIntfStruct.Angle=guiIntfStruct.DVD.current_angle; guiIntfStruct.DiskChanged=1; } break; #endif } guiIntfStruct.NewPlay=1; mplPlay(); break; #ifdef CONFIG_DVDREAD case evSetDVDSubtitle: dvdsub_id=iparam; goto play_dvd_2; break; case evSetDVDAudio: audio_id=iparam; goto play_dvd_2; break; case evSetDVDChapter: guiIntfStruct.DVD.current_chapter=iparam; goto play_dvd_2; break; case evSetDVDTitle: guiIntfStruct.DVD.current_title=iparam; guiIntfStruct.DVD.current_chapter=1; guiIntfStruct.DVD.current_angle=1; goto play_dvd_2; break; #endif case evPause: case evPauseSwitchToPlay: NoPause: mplPause(); break; case evStop: guiIntfStruct.Playing=guiSetStop; mplState(); guiIntfStruct.NoWindow=False; break; case evLoadPlay: mplMainAutoPlay=1; // guiIntfStruct.StreamType=STREAMTYPE_FILE; case evLoad: gtkSet( gtkDelPl,0,NULL ); gtkShow( evLoad,NULL ); break; case evLoadSubtitle: gtkShow( evLoadSubtitle,NULL ); break; case evDropSubtitle: gfree( (void **)&guiIntfStruct.Subtitlename ); guiLoadSubtitle( NULL ); break; case evLoadAudioFile: gtkShow( evLoadAudioFile,NULL ); break; case evPrev: mplPrev(); break; case evNext: mplNext(); break; case evPlayList: gtkShow( evPlayList,NULL ); break; case evSkinBrowser: gtkShow( evSkinBrowser,skinName ); break; case evAbout: gtkShow( evAbout,NULL ); break; case evPreferences: gtkShow( evPreferences,NULL ); break; case evEqualizer: gtkShow( evEqualizer,NULL ); break; case evForward10min: mplRelSeek( 600 ); break; case evBackward10min: mplRelSeek( -600 );break; case evForward1min: mplRelSeek( 60 ); break; case evBackward1min: mplRelSeek( -60 ); break; case evForward10sec: mplRelSeek( 10 ); break; case evBackward10sec: mplRelSeek( -10 ); break; case evSetMoviePosition: mplAbsSeek( param ); break; case evIncVolume: vo_x11_putkey( wsGrayMul ); break; case evDecVolume: vo_x11_putkey( wsGrayDiv ); break; case evMute: mixer_mute( mixer ); break; case evSetVolume: guiIntfStruct.Volume=param; goto set_volume; case evSetBalance: guiIntfStruct.Balance=param; set_volume: { float l = guiIntfStruct.Volume * ( ( 100.0 - guiIntfStruct.Balance ) / 50.0 ); float r = guiIntfStruct.Volume * ( ( guiIntfStruct.Balance ) / 50.0 ); if ( l > guiIntfStruct.Volume ) l=guiIntfStruct.Volume; if ( r > guiIntfStruct.Volume ) r=guiIntfStruct.Volume; // printf( "!!! v: %.2f b: %.2f -> %.2f x %.2f\n",guiIntfStruct.Volume,guiIntfStruct.Balance,l,r ); mixer_setvolume( mixer,l,r ); } if ( osd_level ) { osd_visible=(GetTimerMS() + 1000) | 1; vo_osd_progbar_type=OSD_VOLUME; vo_osd_progbar_value=( ( guiIntfStruct.Volume ) * 256.0 ) / 100.0; vo_osd_changed( OSDTYPE_PROGBAR ); } break; case evIconify: switch ( iparam ) { case 0: wsIconify( appMPlayer.mainWindow ); break; case 1: wsIconify( appMPlayer.subWindow ); break; } break; case evHalfSize: btnSet( evFullScreen,btnReleased ); if ( guiIntfStruct.Playing ) { if ( appMPlayer.subWindow.isFullScreen ) { mplFullScreen(); } wsResizeWindow( &appMPlayer.subWindow, guiIntfStruct.MovieWidth / 2, guiIntfStruct.MovieHeight / 2 ); wsMoveWindow( &appMPlayer.subWindow, 0, ( wsMaxX - guiIntfStruct.MovieWidth/2 )/2 + wsOrgX, ( wsMaxY - guiIntfStruct.MovieHeight/2 )/2 + wsOrgY ); } break; case evDoubleSize: btnSet( evFullScreen,btnReleased ); if ( guiIntfStruct.Playing ) { if ( appMPlayer.subWindow.isFullScreen ) { mplFullScreen(); } wsResizeWindow( &appMPlayer.subWindow, guiIntfStruct.MovieWidth * 2, guiIntfStruct.MovieHeight * 2 ); wsMoveWindow( &appMPlayer.subWindow, 0, ( wsMaxX - guiIntfStruct.MovieWidth*2 )/2 + wsOrgX, ( wsMaxY - guiIntfStruct.MovieHeight*2 )/2 + wsOrgY ); } break; case evNormalSize: btnSet( evFullScreen,btnReleased ); if ( guiIntfStruct.Playing ) { if ( appMPlayer.subWindow.isFullScreen ) { mplFullScreen(); } wsResizeWindow( &appMPlayer.subWindow, guiIntfStruct.MovieWidth, guiIntfStruct.MovieHeight ); wsMoveWindow( &appMPlayer.subWindow, 0, ( wsMaxX - guiIntfStruct.MovieWidth )/2 + wsOrgX, ( wsMaxY - guiIntfStruct.MovieHeight )/2 + wsOrgY ); break; } else if ( !appMPlayer.subWindow.isFullScreen ) break; case evFullScreen: if ( !guiIntfStruct.Playing && !gtkShowVideoWindow ) break; mplFullScreen(); if ( appMPlayer.subWindow.isFullScreen ) btnSet( evFullScreen,btnPressed ); else btnSet( evFullScreen,btnReleased ); break; case evSetAspect: switch ( iparam ) { case 2: movie_aspect=16.0f / 9.0f; break; case 3: movie_aspect=4.0f / 3.0f; break; case 4: movie_aspect=2.35; break; case 1: default: movie_aspect=-1; } wsClearWindow( appMPlayer.subWindow ); #ifdef CONFIG_DVDREAD if ( guiIntfStruct.StreamType == STREAMTYPE_DVD || guiIntfStruct.StreamType == STREAMTYPE_VCD ) goto play_dvd_2; else #endif guiIntfStruct.NewPlay=1; break; // --- timer events case evRedraw: { unsigned now = GetTimerMS(); extern int mplPBFade; if ((now > last_redraw_time) && (now < last_redraw_time + GUI_REDRAW_WAIT) && !mplPBFade) break; last_redraw_time = now; } mplMainRender=1; wsPostRedisplay( &appMPlayer.mainWindow ); wsPostRedisplay( &appMPlayer.barWindow ); break; // --- system events #ifdef MP_DEBUG case evNone: mp_msg( MSGT_GPLAYER,MSGL_STATUS,"[mw] event none received.\n" ); break; default: mp_msg( MSGT_GPLAYER,MSGL_STATUS,"[mw] unknown event received ( %d,%.2f ).\n",msg,param ); break; #endif } }
static uint32_t jpeg_write(uint8_t * name, uint8_t * buffer) { FILE *outfile; struct jpeg_compress_struct cinfo; struct jpeg_error_mgr jerr; JSAMPROW row_pointer[1]; int row_stride; if ( !buffer ) return 1; if ( (outfile = fopen(name, "wb") ) == NULL ) { mp_msg(MSGT_VO, MSGL_ERR, "\n%s: %s\n", info.short_name, MSGTR_VO_CantCreateFile); mp_msg(MSGT_VO, MSGL_ERR, "%s: %s: %s\n", info.short_name, MSGTR_VO_GenericError, strerror(errno) ); exit_player(MSGTR_Exit_error); } cinfo.err = jpeg_std_error(&jerr); jpeg_create_compress(&cinfo); jpeg_stdio_dest(&cinfo, outfile); cinfo.image_width = image_width; cinfo.image_height = image_height; cinfo.input_components = 3; cinfo.in_color_space = JCS_RGB; jpeg_set_defaults(&cinfo); /* Important: Header info must be set AFTER jpeg_set_defaults() */ cinfo.write_JFIF_header = TRUE; cinfo.JFIF_major_version = 1; cinfo.JFIF_minor_version = 2; cinfo.density_unit = 1; /* 0=unknown, 1=dpi, 2=dpcm */ /* Image DPI is determined by Y_density, so we leave that at jpeg_dpi if possible and crunch X_density instead (PAR > 1) */ cinfo.X_density = jpeg_dpi*image_width/image_d_width; cinfo.Y_density = jpeg_dpi*image_height/image_d_height; cinfo.write_Adobe_marker = TRUE; jpeg_set_quality(&cinfo,jpeg_quality, jpeg_baseline); cinfo.optimize_coding = jpeg_optimize; cinfo.smoothing_factor = jpeg_smooth; if ( jpeg_progressive_mode ) { jpeg_simple_progression(&cinfo); } jpeg_start_compress(&cinfo, TRUE); row_stride = image_width * 3; while (cinfo.next_scanline < cinfo.image_height) { row_pointer[0] = &buffer[cinfo.next_scanline * row_stride]; (void)jpeg_write_scanlines(&cinfo, row_pointer,1); } jpeg_finish_compress(&cinfo); fclose(outfile); jpeg_destroy_compress(&cinfo); return 0; }
// gets a datagram from the master with or without blocking. updates // master_position if successful. if the master has exited, returns 1. // returns -1 on error. // otherwise, returns 0. static int get_udp(int blocking, float *master_position) { char mesg[100]; int chars_received = -1; int n; static int sockfd = -1; if (sockfd == -1) { struct timeval tv = { .tv_sec = 30 }; struct sockaddr_in servaddr = { 0 }; sockfd = socket(AF_INET, SOCK_DGRAM, 0); if (sockfd == -1) return -1; servaddr.sin_family = AF_INET; servaddr.sin_addr.s_addr = htonl(INADDR_ANY); servaddr.sin_port = htons(udp_port); bind(sockfd, (struct sockaddr *)&servaddr, sizeof(servaddr)); setsockopt(sockfd, SOL_SOCKET, SO_RCVTIMEO, &tv, sizeof(tv)); } set_blocking(sockfd, blocking); while (-1 != (n = recvfrom(sockfd, mesg, sizeof(mesg)-1, 0, NULL, NULL))) { // flush out any further messages so we don't get behind if (chars_received == -1) set_blocking(sockfd, 0); chars_received = n; mesg[chars_received] = 0; if (strcmp(mesg, "bye") == 0) return 1; sscanf(mesg, "%f", master_position); } return 0; } void send_udp(const char *send_to_ip, int port, char *mesg) { static int sockfd = -1; static struct sockaddr_in socketinfo; if (sockfd == -1) { static const int one = 1; int ip_valid = 0; sockfd = socket(AF_INET, SOCK_DGRAM, 0); if (sockfd == -1) exit_player(EXIT_ERROR); // Enable broadcast setsockopt(sockfd, SOL_SOCKET, SO_BROADCAST, &one, sizeof(one)); #if HAVE_WINSOCK2_H socketinfo.sin_addr.s_addr = inet_addr(send_to_ip); ip_valid = socketinfo.sin_addr.s_addr != INADDR_NONE; #else ip_valid = inet_aton(send_to_ip, &socketinfo.sin_addr); #endif if (!ip_valid) { mp_msg(MSGT_CPLAYER, MSGL_FATAL, MSGTR_InvalidIP); exit_player(EXIT_ERROR); } socketinfo.sin_family = AF_INET; socketinfo.sin_port = htons(port); } sendto(sockfd, mesg, strlen(mesg), 0, (struct sockaddr *) &socketinfo, sizeof(socketinfo)); } // this function makes sure we stay as close as possible to the master's // position. returns 1 if the master tells us to exit, 0 otherwise. int udp_slave_sync(MPContext *mpctx) { // grab any waiting datagrams without blocking int master_exited = get_udp(0, &udp_master_position); while (!master_exited) { float my_position = mpctx->sh_video->pts; // if we're way off, seek to catch up if (FFABS(my_position - udp_master_position) > udp_seek_threshold) { abs_seek_pos = SEEK_ABSOLUTE; rel_seek_secs = udp_master_position; break; } // normally we expect that the master will have just played the // frame we're ready to play. break out and play it, and we'll be // right in sync. // or, the master might be up to a few seconds ahead of us, in // which case we also want to play the current frame immediately, // without waiting. // UDP_TIMING_TOLERANCE is a small value that lets us consider // the master equal to us even if it's very slightly ahead. if (udp_master_position + UDP_TIMING_TOLERANCE > my_position) break; // the remaining case is that we're slightly ahead of the master. // usually, it just means we called get_udp() before the datagram // arrived. call get_udp again, but this time block until we receive // a datagram. master_exited = get_udp(1, &udp_master_position); } return master_exited; }
static void pnm_write_error(void) { mp_msg(MSGT_VO, MSGL_ERR, MSGTR_ErrorWritingFile, info.short_name); exit_player(MSGTR_Exit_error); }
static void png_mkdir(char *buf, int verbose) { struct stat stat_p; #ifndef __MINGW32__ if ( mkdir(buf, 0755) < 0 ) { #else if ( mkdir(buf) < 0 ) { #endif switch (errno) { /* use switch in case other errors need to be caught and handled in the future */ case EEXIST: if ( stat(buf, &stat_p ) < 0 ) { mp_msg(MSGT_VO, MSGL_ERR, "%s: %s: %s\n", info.short_name, MSGTR_VO_GenericError, strerror(errno) ); mp_msg(MSGT_VO, MSGL_ERR, "%s: %s %s\n", info.short_name, MSGTR_VO_UnableToAccess,buf); exit_player(EXIT_ERROR); } if ( !S_ISDIR(stat_p.st_mode) ) { mp_msg(MSGT_VO, MSGL_ERR, "%s: %s %s\n", info.short_name, buf, MSGTR_VO_ExistsButNoDirectory); exit_player(EXIT_ERROR); } if ( !(stat_p.st_mode & S_IWUSR) ) { mp_msg(MSGT_VO, MSGL_ERR, "%s: %s - %s\n", info.short_name, buf, MSGTR_VO_DirExistsButNotWritable); exit_player(EXIT_ERROR); } mp_msg(MSGT_VO, MSGL_INFO, "%s: %s - %s\n", info.short_name, buf, MSGTR_VO_DirExistsAndIsWritable); break; default: mp_msg(MSGT_VO, MSGL_ERR, "%s: %s: %s\n", info.short_name, MSGTR_VO_GenericError, strerror(errno) ); mp_msg(MSGT_VO, MSGL_ERR, "%s: %s - %s\n", info.short_name, buf, MSGTR_VO_CantCreateDirectory); exit_player(EXIT_ERROR); } /* end switch */ } else if ( verbose ) { mp_msg(MSGT_VO, MSGL_INFO, "%s: %s - %s\n", info.short_name, buf, MSGTR_VO_DirectoryCreateSuccess); } /* end if */ } static int config(uint32_t width, uint32_t height, uint32_t d_width, uint32_t d_height, uint32_t flags, char *title, uint32_t format) { char buf[BUFLENGTH]; if(z_compression == 0) { mp_msg(MSGT_VO,MSGL_INFO, MSGTR_LIBVO_PNG_Warning1); mp_msg(MSGT_VO,MSGL_INFO, MSGTR_LIBVO_PNG_Warning2); mp_msg(MSGT_VO,MSGL_INFO, MSGTR_LIBVO_PNG_Warning3); } snprintf(buf, BUFLENGTH, "%s", png_outdir); png_mkdir(buf, 1); mp_msg(MSGT_VO,MSGL_DBG2, "PNG Compression level %i\n", z_compression); return 0; }
/* this function gets called by mplayer to update the gui */ int gui(int what, void *data) { stream_t *stream = data; #ifdef CONFIG_DVDREAD dvd_priv_t *dvdp; #endif if(!mygui || !mygui->skin) return 0; if(guiInfo.mpcontext) { audio_out = mpctx_get_audio_out(guiInfo.mpcontext); video_out = mpctx_get_video_out(guiInfo.mpcontext); mixer = mpctx_get_mixer(guiInfo.mpcontext); playtree = mpctx_get_playtree_iter(guiInfo.mpcontext); } switch (what) { case GUI_PREPARE: { audio_id = -1; video_id = -1; dvdsub_id = -1; vobsub_id = -1; stream_cache_size = -1; autosync = 0; force_fps = 0; if(!mygui->playlist->tracks) return 0; switch(guiInfo.StreamType) { case STREAMTYPE_FILE: case STREAMTYPE_STREAM: uiSetFileName(NULL, mygui->playlist->tracks[mygui->playlist->current]->filename, SAME_STREAMTYPE); guiInfo.Track = mygui->playlist->current + 1; break; case STREAMTYPE_DVD: { char tmp[512]; #ifdef CONFIG_DVDREAD dvd_chapter = guiInfo.Chapter; dvd_angle = guiInfo.Angle; #endif sprintf(tmp,"dvd://%d", guiInfo.Track); uiSetFileName(NULL, tmp, SAME_STREAMTYPE); break; } } guiInfo.VideoWindow = 1; if(gtkAONorm) listRepl(&af_cfg.list, "volnorm", "volnorm"); if(gtkAOExtraStereo) { char *name = malloc(12 + 20 + 1); snprintf(name, 12 + 20, "extrastereo=%f", gtkAOExtraStereoMul); name[12 + 20] = 0; listRepl(&af_cfg.list, "extrastereo", name); free(name); } if(gtkCacheOn) stream_cache_size = gtkCacheSize; if(gtkAutoSyncOn) autosync = gtkAutoSync; guiInfo.NewPlay = 0; break; } case GUI_SET_AUDIO: { if (data && !guiInfo.sh_video) guiInfo.VideoWindow = 0; if(IsWindowVisible(mygui->videowindow) && !guiInfo.VideoWindow) ShowWindow(mygui->videowindow, SW_HIDE); break; } case GUI_SET_CONTEXT: guiInfo.mpcontext = data; break; case GUI_SET_VIDEO: { guiInfo.sh_video = data; if (data) { sh_video_t *sh = data; codecname = sh->codec->name; /* we have video, show the video window */ if(!IsWindowVisible(mygui->videowindow) || IsIconic(mygui->videowindow)) ShowWindow(mygui->videowindow, SW_SHOWNORMAL); if(WinID == -1) update_videowindow(); } break; } case GUI_SETUP_VIDEO_WINDOW: { guiInfo.VideoWidth = vo_dwidth; guiInfo.VideoHeight = vo_dheight; video_aspect = (float)guiInfo.VideoWidth/guiInfo.VideoHeight; if(WinID != -1) update_videowindow(); break; } case GUI_SET_STREAM: { guiInfo.StreamType = stream->type; switch(stream->type) { case STREAMTYPE_DVD: guiInfo.Tracks = 0; stream_control(stream, STREAM_CTRL_GET_NUM_TITLES, &guiInfo.Tracks); guiInfo.Chapters = 0; stream_control(stream, STREAM_CTRL_GET_NUM_CHAPTERS, &guiInfo.Chapters); guiInfo.Angles = 0; stream_control(stream, STREAM_CTRL_GET_NUM_ANGLES, &guiInfo.Angles); guiInfo.Track = 0; stream_control(stream, STREAM_CTRL_GET_CURRENT_TITLE, &guiInfo.Track); guiInfo.Track++; // guiInfo.Chapter will be set by mplayer guiInfo.Angle = 1; stream_control(stream, STREAM_CTRL_GET_ANGLE, &guiInfo.Angle); #ifdef CONFIG_DVDREAD dvdp = stream->priv; guiInfo.AudioStreams = dvdp->nr_of_channels; memcpy(guiInfo.AudioStream, dvdp->audio_streams, sizeof(dvdp->audio_streams)); guiInfo.Subtitles = dvdp->nr_of_subtitles; memcpy(guiInfo.Subtitle, dvdp->subtitles, sizeof(dvdp->subtitles)); #endif break; } break; } case GUI_REDRAW: mygui->updatedisplay(mygui, mygui->mainwindow); break; case GUI_SET_AFILTER: guiInfo.afilter = data; break; case GUI_SET_STATE: { guiInfo.Playing = (int) data; switch (guiInfo.Playing) { case GUI_PLAY: { guiInfo.Playing = GUI_PLAY; break; } case GUI_STOP: { guiInfo.Playing = GUI_STOP; if(movie_aspect >= 0) movie_aspect = -1; update_videowindow(); break; } case GUI_PAUSE: guiInfo.Playing = GUI_PAUSE; break; } break; } case GUI_RUN_COMMAND: { mp_msg(MSGT_GPLAYER,MSGL_V, "cmd: %d\n", (int) data); /* MPlayer asks us to quit */ switch((int) data) { case MP_CMD_VO_FULLSCREEN: uiFullScreen(); break; case MP_CMD_QUIT: { mygui->uninit(mygui); nfree(mygui); exit_player(EXIT_QUIT); return 1; } case MP_CMD_PLAY_TREE_STEP: guiSetEvent(evNext); break; case -MP_CMD_PLAY_TREE_STEP: guiSetEvent(evPrev); break; case MP_CMD_STOP: guiSetEvent(evStop); break; default: break; } break; } case GUI_RUN_MESSAGE: break; case GUI_HANDLE_EVENTS: break; case GUI_SET_MIXER: { if(audio_out) { /* Some audio_out drivers do not support balance e.g. dsound */ /* FIXME this algo is not correct */ float l, r; mixer_getvolume(mixer, &l, &r); guiInfo.Volume = (r > l ? r : l); /* max(r,l) */ if (r != l) guiInfo.Balance = ((r-l) + 100.0f) * 0.5f; else guiInfo.Balance = 50.0f; } break; } case GUI_END_FILE: { if(!uiGotoTheNext && guiInfo.Playing) { uiGotoTheNext = 1; break; } if(uiGotoTheNext && guiInfo.Playing && (mygui->playlist->current < (mygui->playlist->trackcount - 1)) && guiInfo.StreamType != STREAMTYPE_DVD && guiInfo.StreamType != STREAMTYPE_DVDNAV) { /* we've finished this file, reset the aspect */ if(movie_aspect >= 0) movie_aspect = -1; uiGotoTheNext = 1; guiInfo.NewPlay = GUI_FILE_NEW; uiSetFileName(NULL, mygui->playlist->tracks[(mygui->playlist->current)++]->filename, STREAMTYPE_FILE); //sprintf(guiInfo.Filename, mygui->playlist->tracks[(mygui->playlist->current)++]->filename); } if(guiInfo.NewPlay == GUI_FILE_NEW) break; guiInfo.ElapsedTime = 0; guiInfo.Position = 0; guiInfo.AudioChannels = 0; guiInfo.Track = 1; guiInfo.Chapter = 1; guiInfo.Angle = 1; if (mygui->playlist->current == (mygui->playlist->trackcount - 1)) mygui->playlist->current = 0; fullscreen = 0; if(style == (WS_VISIBLE | WS_POPUP)) { style = WS_OVERLAPPEDWINDOW | WS_SIZEBOX; SetWindowLong(mygui->videowindow, GWL_STYLE, style); } gui(GUI_SET_STATE, (void *) GUI_STOP); break; } default: mp_msg(MSGT_GPLAYER, MSGL_ERR, "[GUI] GOT UNHANDLED EVENT %i\n", what); } return 1; }
int guiGetEvent( int type,void * arg ) { const ao_functions_t *audio_out = NULL; const vo_functions_t *video_out = NULL; mixer_t *mixer = NULL; stream_t * stream = arg; #ifdef CONFIG_DVDREAD dvd_priv_t * dvdp = arg; #endif if (guiIntfStruct.mpcontext) { audio_out = mpctx_get_audio_out(guiIntfStruct.mpcontext); video_out = mpctx_get_video_out(guiIntfStruct.mpcontext); mixer = mpctx_get_mixer(guiIntfStruct.mpcontext); } switch ( type ) { case guiXEvent: guiIntfStruct.event_struct=arg; wsEvents( wsDisplay,arg,NULL ); gtkEventHandling(); break; case guiCEvent: switch ( (int)arg ) { case guiSetPlay: guiIntfStruct.Playing=1; // if ( !gtkShowVideoWindow ) wsVisibleWindow( &appMPlayer.subWindow,wsHideWindow ); break; case guiSetStop: guiIntfStruct.Playing=0; // if ( !gtkShowVideoWindow ) wsVisibleWindow( &appMPlayer.subWindow,wsHideWindow ); break; case guiSetPause: guiIntfStruct.Playing=2; break; } mplState(); break; case guiSetState: mplState(); break; case guiSetFileName: if ( arg ) guiSetFilename( guiIntfStruct.Filename,arg ); break; case guiSetAudioOnly: guiIntfStruct.AudioOnly=(int)arg; if ( (int)arg ) { guiIntfStruct.NoWindow=True; wsVisibleWindow( &appMPlayer.subWindow,wsHideWindow ); } else wsVisibleWindow( &appMPlayer.subWindow,wsShowWindow ); break; case guiSetContext: guiIntfStruct.mpcontext=arg; case guiSetDemuxer: guiIntfStruct.demuxer=arg; break; case guiSetAfilter: guiIntfStruct.afilter=arg; break; case guiSetShVideo: { if ( !appMPlayer.subWindow.isFullScreen ) { wsResizeWindow( &appMPlayer.subWindow,vo_dwidth,vo_dheight ); wsMoveWindow( &appMPlayer.subWindow,True,appMPlayer.sub.x,appMPlayer.sub.y ); } guiIntfStruct.MovieWidth=vo_dwidth; guiIntfStruct.MovieHeight=vo_dheight; if (guiWinID>=0) wsMoveWindow( &appMPlayer.mainWindow,0,0, vo_dheight); WinID = appMPlayer.subWindow.WindowID; } break; #ifdef CONFIG_DVDREAD case guiSetDVD: guiIntfStruct.DVD.titles=dvdp->vmg_file->tt_srpt->nr_of_srpts; guiIntfStruct.DVD.chapters=dvdp->vmg_file->tt_srpt->title[dvd_title].nr_of_ptts; guiIntfStruct.DVD.angles=dvdp->vmg_file->tt_srpt->title[dvd_title].nr_of_angles; guiIntfStruct.DVD.nr_of_audio_channels=dvdp->nr_of_channels; memcpy( guiIntfStruct.DVD.audio_streams,dvdp->audio_streams,sizeof( dvdp->audio_streams ) ); guiIntfStruct.DVD.nr_of_subtitles=dvdp->nr_of_subtitles; memcpy( guiIntfStruct.DVD.subtitles,dvdp->subtitles,sizeof( dvdp->subtitles ) ); guiIntfStruct.DVD.current_title=dvd_title + 1; guiIntfStruct.DVD.current_chapter=dvd_chapter + 1; guiIntfStruct.DVD.current_angle=dvd_angle + 1; guiIntfStruct.Track=dvd_title + 1; break; #endif case guiSetStream: guiIntfStruct.StreamType=stream->type; switch( stream->type ) { #ifdef CONFIG_DVDREAD case STREAMTYPE_DVD: guiGetEvent( guiSetDVD,(char *)stream->priv ); break; #endif #ifdef CONFIG_VCD case STREAMTYPE_VCD: { int i; if (!stream->priv) { guiIntfStruct.VCDTracks=0; break; } for ( i=1;i < 100;i++ ) if ( vcd_seek_to_track( stream->priv,i ) < 0 ) break; vcd_seek_to_track( stream->priv,vcd_track ); guiIntfStruct.VCDTracks=--i; break; } #endif default: break; } break; case guiIEvent: mp_msg( MSGT_GPLAYER,MSGL_V,"cmd: %d\n",(int)arg ); switch( (int)arg ) { case MP_CMD_QUIT: mplEventHandling( evExit,0 ); break; case MP_CMD_VO_FULLSCREEN: mplEventHandling( evFullScreen,0 ); break; } break; case guiReDraw: mplEventHandling( evRedraw,0 ); break; case guiSetVolume: if ( audio_out ) { float l,r; mixer_getvolume( mixer,&l,&r ); guiIntfStruct.Volume=(r>l?r:l); if ( r != l ) guiIntfStruct.Balance=( ( r - l ) + 100 ) * 0.5f; else guiIntfStruct.Balance=50.0f; btnModify( evSetVolume,guiIntfStruct.Volume ); btnModify( evSetBalance,guiIntfStruct.Balance ); } break; case guiSetFileFormat: guiIntfStruct.FileFormat=(int)arg; break; case guiSetValues: // -- video guiIntfStruct.sh_video=arg; if ( arg ) { sh_video_t * sh = arg; guiIntfStruct.FPS=sh->fps; } if ( guiIntfStruct.NoWindow ) wsVisibleWindow( &appMPlayer.subWindow,wsHideWindow ); if ( guiIntfStruct.StreamType == STREAMTYPE_STREAM ) btnSet( evSetMoviePosition,btnDisabled ); else btnSet( evSetMoviePosition,btnReleased ); // -- audio if ( audio_out ) { float l,r; mixer_getvolume( mixer,&l,&r ); guiIntfStruct.Volume=(r>l?r:l); if ( r != l ) guiIntfStruct.Balance=( ( r - l ) + 100 ) * 0.5f; else guiIntfStruct.Balance=50.0f; btnModify( evSetVolume,guiIntfStruct.Volume ); btnModify( evSetBalance,guiIntfStruct.Balance ); } if ( gtkEnableAudioEqualizer ) { equalizer_t eq; int i,j; for ( i=0;i<6;i++ ) for ( j=0;j<10;j++ ) { eq.channel=i; eq.band=j; eq.gain=gtkEquChannels[i][j]; gtkSet( gtkSetEqualizer,0,&eq ); } } // -- subtitle #ifdef CONFIG_DXR3 if ( video_driver_list && !gstrcmp( video_driver_list[0],"dxr3" ) && guiIntfStruct.FileFormat != DEMUXER_TYPE_MPEG_PS && !gtkVfLAVC ) { gtkMessageBox( GTK_MB_FATAL,MSGTR_NEEDLAVC ); guiIntfStruct.Playing=0; return True; } #endif break; case guiSetDefaults: // if ( guiIntfStruct.Playing == 1 && guiIntfStruct.FilenameChanged ) if ( guiIntfStruct.FilenameChanged ) { audio_id=-1; video_id=-1; dvdsub_id=-1; vobsub_id=-1; stream_cache_size=-1; autosync=0; vcd_track=0; dvd_title=0; force_fps=0; } guiIntfStruct.demuxer=NULL; guiIntfStruct.sh_video=NULL; wsPostRedisplay( &appMPlayer.subWindow ); break; case guiSetParameters: guiGetEvent( guiSetDefaults,NULL ); switch ( guiIntfStruct.StreamType ) { case STREAMTYPE_PLAYLIST: break; #ifdef CONFIG_VCD case STREAMTYPE_VCD: { char tmp[512]; sprintf( tmp,"vcd://%d",guiIntfStruct.Track + 1 ); guiSetFilename( guiIntfStruct.Filename,tmp ); } break; #endif #ifdef CONFIG_DVDREAD case STREAMTYPE_DVD: { char tmp[512]; sprintf( tmp,"dvd://%d",guiIntfStruct.Title ); guiSetFilename( guiIntfStruct.Filename,tmp ); } dvd_chapter=guiIntfStruct.Chapter; dvd_angle=guiIntfStruct.Angle; break; #endif } //if ( guiIntfStruct.StreamType != STREAMTYPE_PLAYLIST ) // Does not make problems anymore! { if ( guiIntfStruct.Filename ) filename=gstrdup( guiIntfStruct.Filename ); else if ( filename ) guiSetFilename( guiIntfStruct.Filename,filename ); } // --- video opts if ( !video_driver_list ) { int i = 0; while ( video_out_drivers[i++] ) if ( video_out_drivers[i - 1]->control( VOCTRL_GUISUPPORT,NULL ) == VO_TRUE ) { gaddlist( &video_driver_list,(char *)video_out_drivers[i - 1]->info->short_name ); break; } } if ( !video_driver_list && !video_driver_list[0] ) { gtkMessageBox( GTK_MB_FATAL,MSGTR_IDFGCVD ); exit_player(EXIT_ERROR); } { int i = 0; guiIntfStruct.NoWindow=False; while ( video_out_drivers[i++] ) if ( video_out_drivers[i - 1]->control( VOCTRL_GUISUPPORT,NULL ) == VO_TRUE ) { 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 ) ) { guiIntfStruct.NoWindow=True; break; } } } #ifdef CONFIG_DXR3 remove_vf( "lavc" ); if ( video_driver_list && !gstrcmp( video_driver_list[0],"dxr3" ) ) { if ( ( guiIntfStruct.StreamType != STREAMTYPE_DVD)&&( guiIntfStruct.StreamType != STREAMTYPE_VCD ) ) { if ( gtkVfLAVC ) add_vf( "lavc" ); } } #endif // --- if ( gtkVfPP ) add_vf( "pp" ); else remove_vf( "pp" ); // --- audio opts // if ( ao_plugin_cfg.plugin_list ) { free( ao_plugin_cfg.plugin_list ); ao_plugin_cfg.plugin_list=NULL; } if (gtkAONorm) greplace(&af_cfg.list, "volnorm", "volnorm"); if (gtkEnableAudioEqualizer) greplace(&af_cfg.list, "equalizer", "equalizer"); if ( gtkAOExtraStereo ) { char *name = malloc(12 + 20 + 1); snprintf(name, 12 + 20, "extrastereo=%f", gtkAOExtraStereoMul); name[12 + 20] = 0; greplace(&af_cfg.list, "extrastereo", name); free(name); } #ifdef CONFIG_OSS_AUDIO if ( audio_driver_list && !gstrncmp( audio_driver_list[0],"oss",3 ) ) { char *tmp; mixer_device = gtkAOOSSMixer; mixer_channel = gtkAOOSSMixerChannel; if (gtkAOOSSDevice) { tmp = calloc( 1,strlen( gtkAOOSSDevice ) + 7 ); sprintf( tmp,"oss:%s",gtkAOOSSDevice ); } else tmp = strdup("oss"); gaddlist( &audio_driver_list,tmp ); free(tmp); } #endif #ifdef CONFIG_ALSA if ( audio_driver_list && !gstrncmp( audio_driver_list[0],"alsa",4 ) ) { char *tmp; mixer_device = gtkAOALSAMixer; mixer_channel = gtkAOALSAMixerChannel; if (gtkAOALSADevice) { tmp = calloc( 1,strlen( gtkAOALSADevice ) + 14 ); sprintf( tmp,"alsa:device=%s",gtkAOALSADevice ); } else tmp = strdup("alsa"); gaddlist( &audio_driver_list,tmp ); free(tmp); } #endif #ifdef CONFIG_SDL if ( audio_driver_list && !gstrncmp( audio_driver_list[0],"sdl",3 ) ) { char *tmp; if (gtkAOSDLDriver) { tmp = calloc( 1,strlen( gtkAOSDLDriver ) + 10 ); sprintf( tmp,"sdl:%s",gtkAOSDLDriver ); } else tmp = strdup("sdl"); gaddlist( &audio_driver_list,tmp ); free(tmp); } #endif #ifdef CONFIG_ESD if ( audio_driver_list && !gstrncmp( audio_driver_list[0],"esd",3 ) ) { char *tmp; if (gtkAOESDDevice) { tmp = calloc( 1,strlen( gtkAOESDDevice ) + 10 ); sprintf( tmp,"esd:%s",gtkAOESDDevice ); } else tmp = strdup("esd"); gaddlist( &audio_driver_list,tmp ); free(tmp); } #endif // -- subtitle //subdata->filename=gstrdup( guiIntfStruct.Subtitlename ); stream_dump_type=0; if ( gtkSubDumpMPSub ) stream_dump_type=4; if ( gtkSubDumpSrt ) stream_dump_type=6; gtkSubDumpMPSub=gtkSubDumpSrt=0; guiLoadFont(); // --- misc if ( gtkCacheOn ) stream_cache_size=gtkCacheSize; if ( gtkAutoSyncOn ) autosync=gtkAutoSync; if ( guiIntfStruct.AudioFile ) audio_stream=gstrdup( guiIntfStruct.AudioFile ); else if ( guiIntfStruct.FilenameChanged ) gfree( (void**)&audio_stream ); //audio_stream=NULL; guiIntfStruct.DiskChanged=0; guiIntfStruct.FilenameChanged=0; guiIntfStruct.NewPlay=0; #ifdef CONFIG_ASS ass_enabled = gtkASS.enabled; ass_use_margins = gtkASS.use_margins; ass_top_margin = gtkASS.top_margin; ass_bottom_margin = gtkASS.bottom_margin; #endif break; } return False; }
static void md5sum_write_error(void) { mp_msg(MSGT_VO, MSGL_ERR, MSGTR_ErrorWritingFile, info.short_name); exit_player(EXIT_ERROR); }
static void jpeg_mkdir(char *buf, int verbose) { struct stat stat_p; #ifndef __MINGW32__ if ( mkdir(buf, 0755) < 0 ) { #else if ( mkdir(buf) < 0 ) { #endif switch (errno) { /* use switch in case other errors need to be caught and handled in the future */ case EEXIST: if ( stat(buf, &stat_p ) < 0 ) { mp_msg(MSGT_VO, MSGL_ERR, "%s: %s: %s\n", info.short_name, MSGTR_VO_GenericError, strerror(errno) ); mp_msg(MSGT_VO, MSGL_ERR, "%s: %s %s\n", info.short_name, MSGTR_VO_UnableToAccess,buf); exit_player(MSGTR_Exit_error); } if ( !S_ISDIR(stat_p.st_mode) ) { mp_msg(MSGT_VO, MSGL_ERR, "%s: %s %s\n", info.short_name, buf, MSGTR_VO_ExistsButNoDirectory); exit_player(MSGTR_Exit_error); } if ( !(stat_p.st_mode & S_IWUSR) ) { mp_msg(MSGT_VO, MSGL_ERR, "%s: %s - %s\n", info.short_name, buf, MSGTR_VO_DirExistsButNotWritable); exit_player(MSGTR_Exit_error); } mp_msg(MSGT_VO, MSGL_INFO, "%s: %s - %s\n", info.short_name, buf, MSGTR_VO_DirExistsAndIsWritable); break; default: mp_msg(MSGT_VO, MSGL_ERR, "%s: %s: %s\n", info.short_name, MSGTR_VO_GenericError, strerror(errno) ); mp_msg(MSGT_VO, MSGL_ERR, "%s: %s - %s\n", info.short_name, buf, MSGTR_VO_CantCreateDirectory); exit_player(MSGTR_Exit_error); } /* end switch */ } else if ( verbose ) { mp_msg(MSGT_VO, MSGL_INFO, "%s: %s - %s\n", info.short_name, buf, MSGTR_VO_DirectoryCreateSuccess); } /* end if */ } /* ------------------------------------------------------------------------- */ static int config(uint32_t width, uint32_t height, uint32_t d_width, uint32_t d_height, uint32_t flags, char *title, uint32_t format) { char buf[BUFLENGTH]; /* Create outdir. */ snprintf(buf, BUFLENGTH, "%s", jpeg_outdir); jpeg_mkdir(buf, 1); /* This function only returns if creation was successful. If not, the player will exit. */ image_height = height; image_width = width; /* Save for JFIF-Header PAR */ image_d_width = d_width; image_d_height = d_height; return 0; }