void mixer_mute(mixer_t *mixer) { if (mixer->muted) mixer_setvolume(mixer, mixer->last_l, mixer->last_r); else { mixer_getvolume(mixer, &mixer->last_l, &mixer->last_r); mixer_setvolume(mixer, 0, 0); mixer->muted=1; } }
void mixer_mute(mixer_t *mixer) { if (mixer->muted) { // unmuting to volume 0 makes no sense if (mixer->last_l == 0) mixer->last_l = 100; if (mixer->last_r == 0) mixer->last_r = 100; mixer_setvolume(mixer, mixer->last_l, mixer->last_r); } else { mixer_getvolume(mixer, &mixer->last_l, &mixer->last_r); mixer_setvolume(mixer, 0, 0); mixer->muted=1; } }
static void addvolume(struct mixer *mixer, float d) { checkvolume(mixer); mixer_setvolume(mixer, mixer->vol_l + d, mixer->vol_r + d); if (d > 0) mixer_setmute(mixer, false); }
void mixer_incvolume(mixer_t *mixer) { float mixer_l, mixer_r; mixer_getvolume(mixer, &mixer_l, &mixer_r); mixer_l += mixer->volstep; if ( mixer_l > 100 ) mixer_l = 100; mixer_r += mixer->volstep; if ( mixer_r > 100 ) mixer_r = 100; mixer_setvolume(mixer, mixer_l, mixer_r); }
void mixer_decvolume(mixer_t *mixer) { float mixer_l, mixer_r; mixer_getvolume(mixer, &mixer_l, &mixer_r); mixer_l -= mixer->volstep; if ( mixer_l < 0 ) mixer_l = 0; mixer_r -= mixer->volstep; if ( mixer_r < 0 ) mixer_r = 0; mixer_setvolume(mixer, mixer_l, mixer_r); }
// Called after the audio filter chain is built or rebuilt. void mixer_reinit(struct mixer *mixer, struct ao *ao) { mixer->ao = ao; /* Use checkvolume() to see if softvol needs to be enabled because of * lacking AO support, but first store values it could overwrite. */ float left = mixer->vol_l, right = mixer->vol_r; bool muted = mixer->muted_by_us; checkvolume(mixer); /* Try to avoid restoring volume stored from one control method with * another. Especially, restoring softvol volume (typically high) on * system mixer could have very nasty effects. */ const char *restore_reason = mixer->softvol ? "softvol" : mixer->ao->driver->info->short_name; if (mixer->restore_volume && !strcmp(mixer->restore_volume, restore_reason)) mixer_setvolume(mixer, left, right); /* We turn mute off at AO uninit, so it has to be restored (unless * we're reinitializing filter chain while keeping AO); but we only * enable mute, not turn external mute off. */ if (muted) mixer_setmute(mixer, true); if (mixer->balance != 0) mixer_setbalance(mixer, mixer->balance); }
/* this function gets called by the gui to update mplayer */ static void guiSetEvent(int event) { if(guiInfo.mpcontext) mixer = mpctx_get_mixer(guiInfo.mpcontext); switch(event) { case evPlay: case evPlaySwitchToPause: case evPauseSwitchToPlay: uiPlay(); break; case evPause: uiPause(); break; #ifdef CONFIG_DVDREAD case evPlayDVD: { static char dvdname[MAX_PATH]; guiInfo.Track = 1; guiInfo.Chapter = 1; guiInfo.Angle = 1; guiInfo.NewPlay = GUI_FILE_SAME; #ifdef __WINE__ // dvd_device is in the Windows style (D:\), which needs to be // converted for MPlayer, so that it will find the device in the // Linux filesystem. dvd_device = unix_device(dvd_device); #endif uiSetFileName(NULL, dvd_device, STREAMTYPE_DVD); dvdname[0] = 0; strcat(dvdname, "DVD Movie"); GetVolumeInformation(dvd_device, dvdname, MAX_PATH, NULL, NULL, NULL, NULL, 0); capitalize(dvdname); mp_msg(MSGT_GPLAYER, MSGL_V, "Opening DVD %s -> %s\n", dvd_device, dvdname); mygui->playlist->clear_playlist(mygui->playlist); mygui->playlist->add_track(mygui->playlist, filename, NULL, dvdname, 0); uiPlay(); break; } #endif #ifdef CONFIG_CDDA case evPlayCD: { int i; char track[10]; char trackname[10]; #ifdef CONFIG_LIBCDIO cdrom_drive_t *cd; #else cdrom_drive *cd; #endif int i_tracks; #ifdef __WINE__ // cdrom_device is in the Windows style (D:\), which needs to be // converted for MPlayer, so that it will find the device in the // Linux filesystem. cdrom_device = unix_device(cdrom_device); #endif cd = cdda_identify(cdrom_device, 0, NULL); if (cd) { if (cdda_open(cd) != 0) { cdda_close(cd); cd = NULL; } } if(!cd) { printf("Couldn't find a driver.\n"); break; } i_tracks = cdda_tracks(cd); mygui->playlist->clear_playlist(mygui->playlist); for(i=0;i<i_tracks;i++) { sprintf(track, "cdda://%d", i+1); sprintf(trackname, "Track %d", i+1); mygui->playlist->add_track(mygui->playlist, track, NULL, trackname, 0); } cdda_close(cd); mygui->startplay(mygui); break; } #endif case evFullScreen: mp_input_queue_cmd(mp_input_parse_cmd("vo_fullscreen")); break; case evExit: { /* We are asking mplayer to exit, later it will ask us after uninit is made this should be the only safe way to quit */ mygui->activewidget = NULL; mp_input_queue_cmd(mp_input_parse_cmd("quit")); break; } case evStop: if(guiInfo.Playing) gui(GUI_SET_STATE, (void *) GUI_STOP); break; case evSetMoviePosition: { rel_seek_secs = guiInfo.Position / 100.0f; abs_seek_pos = 3; break; } case evForward10sec: { rel_seek_secs = 10.0f; abs_seek_pos = 0; break; } case evBackward10sec: { rel_seek_secs = -10.0f; abs_seek_pos = 0; break; } case evSetBalance: case evSetVolume: { float l,r; if (guiInfo.Playing == GUI_STOP) break; if (guiInfo.Balance == 50.0f) mixer_setvolume(mixer, guiInfo.Volume, guiInfo.Volume); l = guiInfo.Volume * ((100.0f - guiInfo.Balance) / 50.0f); r = guiInfo.Volume * ((guiInfo.Balance) / 50.0f); if (l > guiInfo.Volume) l=guiInfo.Volume; if (r > guiInfo.Volume) r=guiInfo.Volume; mixer_setvolume(mixer, l, r); /* Check for balance support on mixer - there is a better way ?? */ if (r != l) { mixer_getvolume(mixer, &l, &r); if (r == l) { mp_msg(MSGT_GPLAYER, MSGL_V, "[GUI] Mixer doesn't support balanced audio\n"); mixer_setvolume(mixer, guiInfo.Volume, guiInfo.Volume); guiInfo.Balance = 50.0f; } } break; } case evMute: { mp_cmd_t * cmd = calloc(1, sizeof(*cmd)); cmd->id=MP_CMD_MUTE; cmd->name=strdup("mute"); mp_input_queue_cmd(cmd); break; } case evLoadPlay: { switch(guiInfo.StreamType) { case STREAMTYPE_DVD: { guiInfo.NewPlay = GUI_FILE_SAME; gui(GUI_SET_STATE, (void *) GUI_PLAY); break; } default: { guiInfo.NewPlay = GUI_FILE_NEW; update_playlistwindow(); uiGotoTheNext = guiInfo.Playing? 0 : 1; gui(GUI_SET_STATE, (void *) GUI_STOP); gui(GUI_SET_STATE, (void *) GUI_PLAY); break; } } break; } case evNext: uiNext(); break; case evPrev: uiPrev(); break; } }
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 } }
void uiEventHandling( int msg,float param ) { int iparam = (int)param; mixer_t *mixer = mpctx_get_mixer(guiInfo.mpcontext); switch( msg ) { /* user events */ case evExit: mplayer( MPLAYER_EXIT_GUI, EXIT_QUIT, 0 ); break; case evLoadURL: gtkShow( evLoadURL,NULL ); break; case ivSetAudio: if ( !mpctx_get_demuxer(guiInfo.mpcontext) || audio_id == iparam ) break; mp_property_do("switch_audio",M_PROPERTY_SET,&iparam,guiInfo.mpcontext); break; case ivSetVideo: if ( !mpctx_get_demuxer(guiInfo.mpcontext) || video_id == iparam ) break; mp_property_do("switch_video",M_PROPERTY_SET,&iparam,guiInfo.mpcontext); break; case ivSetSubtitle: mp_property_do("sub",M_PROPERTY_SET,&iparam,guiInfo.mpcontext); break; #ifdef CONFIG_CDDA case ivSetCDTrack: guiInfo.Track=iparam; case evPlayCD: guiInfoMediumClear ( CLEAR_ALL ); guiInfo.StreamType=STREAMTYPE_CDDA; goto play; #endif #ifdef CONFIG_VCD case ivSetVCDTrack: guiInfo.Track=iparam; case evPlayVCD: guiInfoMediumClear ( CLEAR_ALL ); guiInfo.StreamType=STREAMTYPE_VCD; goto play; #endif #ifdef CONFIG_DVDREAD case ivSetDVDSubtitle: dvdsub_id=iparam; uiEventHandling( ivPlayDVD, 0 ); break; case ivSetDVDAudio: audio_id=iparam; uiEventHandling( ivPlayDVD, 0 ); break; case ivSetDVDChapter: guiInfo.Chapter=iparam; uiEventHandling( ivPlayDVD, 0 ); break; case ivSetDVDTitle: guiInfo.Track=iparam; guiInfo.Chapter=1; guiInfo.Angle=1; uiEventHandling( ivPlayDVD, 0 ); break; case evPlayDVD: guiInfo.Track=1; guiInfo.Chapter=1; guiInfo.Angle=1; case ivPlayDVD: guiInfoMediumClear( CLEAR_ALL - CLEAR_DVD ); guiInfo.StreamType=STREAMTYPE_DVD; goto play; #endif case evPlay: case evPlaySwitchToPause: play: if ( ( msg == evPlaySwitchToPause )&&( guiInfo.Playing == GUI_PAUSE ) ) goto NoPause; if ( listMgr( PLAYLIST_ITEM_GET_CURR,0 ) &&( guiInfo.StreamType == STREAMTYPE_FILE ) ) { plItem * next = listMgr( PLAYLIST_ITEM_GET_CURR,0 ); uiSetFileName( next->path,next->name,SAME_STREAMTYPE ); } switch ( guiInfo.StreamType ) { case STREAMTYPE_FILE: case STREAMTYPE_STREAM: case STREAMTYPE_PLAYLIST: guiInfoMediumClear( CLEAR_ALL - CLEAR_FILE ); if ( !guiInfo.Track ) guiInfo.Track=1; guiInfo.NewPlay=GUI_FILE_NEW; break; case STREAMTYPE_CDDA: guiInfoMediumClear( CLEAR_ALL - CLEAR_VCD - CLEAR_FILE ); if ( guiInfo.Playing != GUI_PAUSE ) { if ( !guiInfo.Track ) guiInfo.Track=1; guiInfo.NewPlay=GUI_FILE_SAME; } break; case STREAMTYPE_VCD: guiInfoMediumClear( CLEAR_ALL - CLEAR_VCD - CLEAR_FILE ); if ( guiInfo.Playing != GUI_PAUSE ) { if ( !guiInfo.Track ) guiInfo.Track=2; guiInfo.NewPlay=GUI_FILE_SAME; } break; case STREAMTYPE_DVD: guiInfoMediumClear( CLEAR_ALL - CLEAR_DVD - CLEAR_FILE ); if ( guiInfo.Playing != GUI_PAUSE ) { guiInfo.NewPlay=GUI_FILE_SAME; } break; } uiPlay(); break; case evPause: case evPauseSwitchToPlay: NoPause: uiPause(); break; case evStop: guiInfo.Playing=GUI_STOP; uiState(); break; case evLoadPlay: uiMainAutoPlay=1; // guiInfo.StreamType=STREAMTYPE_FILE; case evLoad: listMgr( PLAYLIST_DELETE,0 ); gtkShow( evLoad,NULL ); break; case evLoadSubtitle: gtkShow( evLoadSubtitle,NULL ); break; case evDropSubtitle: nfree( guiInfo.SubtitleFilename ); mplayerLoadSubtitle( NULL ); break; case evLoadAudioFile: gtkShow( evLoadAudioFile,NULL ); break; case evPrev: uiPrev(); break; case evNext: uiNext(); 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: uiRelSeek( 600 ); break; case evBackward10min: uiRelSeek( -600 );break; case evForward1min: uiRelSeek( 60 ); break; case evBackward1min: uiRelSeek( -60 ); break; case evForward10sec: uiRelSeek( 10 ); break; case evBackward10sec: uiRelSeek( -10 ); break; case evSetMoviePosition: uiAbsSeek( param ); break; case evIncVolume: vo_x11_putkey( wsGrayMul ); break; case evDecVolume: vo_x11_putkey( wsGrayDiv ); break; case evMute: mixer_mute( mixer ); break; case evSetVolume: guiInfo.Volume=param; goto set_volume; case evSetBalance: guiInfo.Balance=param; set_volume: { float l = guiInfo.Volume * ( ( 100.0 - guiInfo.Balance ) / 50.0 ); float r = guiInfo.Volume * ( ( guiInfo.Balance ) / 50.0 ); if ( l > guiInfo.Volume ) l=guiInfo.Volume; if ( r > guiInfo.Volume ) r=guiInfo.Volume; // printf( "!!! v: %.2f b: %.2f -> %.2f x %.2f\n",guiInfo.Volume,guiInfo.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=( ( guiInfo.Volume ) * 256.0 ) / 100.0; vo_osd_changed( OSDTYPE_PROGBAR ); } break; case evMenu: /*if (guiApp.menuIsPresent) NOTE TO MYSELF: Uncomment only after mouse { pointer and cursor keys work gtkShow( ivHidePopUpMenu,NULL ); with this menu from skin as uiShowMenu( 0,0 ); they do with normal menus. } else*/ gtkShow( ivShowPopUpMenu,NULL ); break; case evIconify: switch ( iparam ) { case 0: wsIconify( guiApp.mainWindow ); break; case 1: wsIconify( guiApp.videoWindow ); break; } break; case evHalfSize: if ( guiInfo.VideoWindow && guiInfo.Playing ) { if ( guiApp.videoWindow.isFullScreen ) { uiFullScreen(); } wsResizeWindow( &guiApp.videoWindow, guiInfo.VideoWidth / 2, guiInfo.VideoHeight / 2 ); wsMoveWindow( &guiApp.videoWindow, False, guiApp.video.x, guiApp.video.y ); btnSet( evFullScreen,btnReleased ); } break; case evDoubleSize: if ( guiInfo.VideoWindow && guiInfo.Playing ) { if ( guiApp.videoWindow.isFullScreen ) { uiFullScreen(); } wsResizeWindow( &guiApp.videoWindow, guiInfo.VideoWidth * 2, guiInfo.VideoHeight * 2 ); wsMoveWindowWithin( &guiApp.videoWindow, False, guiApp.video.x, guiApp.video.y ); btnSet( evFullScreen,btnReleased ); } break; case evNormalSize: if ( guiInfo.VideoWindow && guiInfo.Playing ) { if ( guiApp.videoWindow.isFullScreen ) { uiFullScreen(); } wsResizeWindow( &guiApp.videoWindow, guiInfo.VideoWidth, guiInfo.VideoHeight ); wsMoveWindow( &guiApp.videoWindow, False, guiApp.video.x, guiApp.video.y ); btnSet( evFullScreen,btnReleased ); break; } else if ( !guiApp.videoWindow.isFullScreen ) break; case evFullScreen: if ( guiInfo.VideoWindow && guiInfo.Playing ) { uiFullScreen(); if ( !guiApp.videoWindow.isFullScreen ) { wsResizeWindow( &guiApp.videoWindow, guiInfo.VideoWidth, guiInfo.VideoHeight ); wsMoveWindow( &guiApp.videoWindow, False, guiApp.video.x, guiApp.video.y ); } } if ( guiApp.videoWindow.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( guiApp.videoWindow ); if ( guiInfo.StreamType == STREAMTYPE_VCD ) uiEventHandling( evPlayVCD, 0 ); else if ( guiInfo.StreamType == STREAMTYPE_DVD ) uiEventHandling( ivPlayDVD, 0 ); else guiInfo.NewPlay=GUI_FILE_NEW; break; /* timer events */ case ivRedraw: { unsigned now = GetTimerMS(); if ((now > last_redraw_time) && (now < last_redraw_time + GUI_REDRAW_WAIT) && !uiPlaybarFade && (iparam == 0)) break; last_redraw_time = now; } uiMainRender=1; wsPostRedisplay( &guiApp.mainWindow ); wsPostRedisplay( &guiApp.playbarWindow ); break; /* system events */ case evNone: mp_msg( MSGT_GPLAYER,MSGL_DBG2,"[main] uiEventHandling: evNone\n" ); break; default: mp_msg( MSGT_GPLAYER,MSGL_DBG2,"[main] uiEventHandling: unknown event %d, param %.2f\n", msg, param ); break; } }
void uiEvent(int ev, float param) { int iparam = (int)param; mixer_t *mixer = mpctx_get_mixer(guiInfo.mpcontext); float aspect; char cmd[40]; switch (ev) { /* user events */ case evExit: mplayer(MPLAYER_EXIT_GUI, EXIT_QUIT, 0); break; case evLoadURL: gtkShow(evLoadURL, NULL); break; case ivSetAudio: if (!mpctx_get_demuxer(guiInfo.mpcontext) || audio_id == iparam) break; mp_property_do("switch_audio", M_PROPERTY_SET, &iparam, guiInfo.mpcontext); break; case ivSetVideo: if (!mpctx_get_demuxer(guiInfo.mpcontext) || video_id == iparam) break; mp_property_do("switch_video", M_PROPERTY_SET, &iparam, guiInfo.mpcontext); break; case ivSetSubtitle: mp_property_do("sub", M_PROPERTY_SET, &iparam, guiInfo.mpcontext); break; #ifdef CONFIG_CDDA case ivSetCDTrack: guiInfo.Track = iparam; case evPlayCD: guiInfo.StreamType = STREAMTYPE_CDDA; goto play; #endif #ifdef CONFIG_VCD case ivSetVCDTrack: guiInfo.Track = iparam; case evPlayVCD: guiInfo.StreamType = STREAMTYPE_VCD; goto play; #endif #ifdef CONFIG_DVDREAD case ivSetDVDSubtitle: dvdsub_id = iparam; uiEvent(ivPlayDVD, 0); break; case ivSetDVDAudio: audio_id = iparam; uiEvent(ivPlayDVD, 0); break; case ivSetDVDChapter: guiInfo.Chapter = iparam; uiEvent(ivPlayDVD, 0); break; case ivSetDVDTitle: guiInfo.Track = iparam; guiInfo.Chapter = 1; guiInfo.Angle = 1; uiEvent(ivPlayDVD, 0); break; case evPlayDVD: guiInfo.Chapter = 1; guiInfo.Angle = 1; case ivPlayDVD: guiInfo.StreamType = STREAMTYPE_DVD; goto play; #endif #ifdef CONFIG_TV case evPlayTV: guiInfo.StreamType = guiTV[gui_tv_digital].StreamType; goto play; #endif case evPlay: case evPlaySwitchToPause: play: if (guiInfo.Playing != GUI_PAUSE) { MediumPrepare(guiInfo.StreamType); switch (guiInfo.StreamType) { case STREAMTYPE_FILE: case STREAMTYPE_STREAM: case STREAMTYPE_PLAYLIST: if (!guiInfo.Track) guiInfo.Track = 1; guiInfo.MediumChanged = GUI_MEDIUM_NEW; guiInfo.PlaylistNext = !guiInfo.Playing; break; case STREAMTYPE_CDDA: case STREAMTYPE_VCD: case STREAMTYPE_DVD: case STREAMTYPE_TV: case STREAMTYPE_DVB: if (!guiInfo.Track) guiInfo.Track = (guiInfo.StreamType == STREAMTYPE_VCD ? 2 : 1); case STREAMTYPE_BINCUE: // track 0 is OK and will auto-select first media data track guiInfo.MediumChanged = GUI_MEDIUM_SAME; break; } } uiPlay(); break; case evPause: case evPauseSwitchToPlay: uiPause(); break; case evStop: guiInfo.Playing = GUI_STOP; uiState(); break; case evLoadPlay: uiLoadPlay = True; // guiInfo.StreamType=STREAMTYPE_FILE; case evLoad: gtkShow(evLoad, NULL); break; case evLoadSubtitle: gtkShow(evLoadSubtitle, NULL); break; case evDropSubtitle: nfree(guiInfo.SubtitleFilename); mplayerLoadSubtitle(NULL); break; case evLoadAudioFile: gtkShow(evLoadAudioFile, NULL); break; case evPlayImage: gtkShow(evPlayImage, NULL); break; case evPrev: uiPrev(); break; case evNext: uiNext(); 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: uiRelSeek(600); break; case evBackward10min: uiRelSeek(-600); break; case evForward1min: uiRelSeek(60); break; case evBackward1min: uiRelSeek(-60); break; case evForward10sec: uiRelSeek(10); break; case evBackward10sec: uiRelSeek(-10); break; case evSetMoviePosition: guiInfo.Position = param; uiPctSeek(guiInfo.Position); break; case evIncVolume: mplayer_put_key(KEY_VOLUME_UP); break; case evDecVolume: mplayer_put_key(KEY_VOLUME_DOWN); break; case evMute: mixer_mute(mixer); break; case evSetVolume: case ivSetVolume: guiInfo.Volume = param; { float l = guiInfo.Volume * (100.0 - guiInfo.Balance) / 50.0; float r = guiInfo.Volume * guiInfo.Balance / 50.0; mixer_setvolume(mixer, FFMIN(l, guiInfo.Volume), FFMIN(r, guiInfo.Volume)); } if (ev == ivSetVolume) break; if (osd_level) { osd_visible = (GetTimerMS() + 1000) | 1; vo_osd_progbar_type = OSD_VOLUME; vo_osd_progbar_value = guiInfo.Volume * 256.0 / 100.0; vo_osd_changed(OSDTYPE_PROGBAR); } break; case evSetBalance: case ivSetBalance: guiInfo.Balance = param; mixer_setbalance(mixer, (guiInfo.Balance - 50.0) / 50.0); // transform 0..100 to -1..1 uiEvent(ivSetVolume, guiInfo.Volume); if (ev == ivSetBalance) break; if (osd_level) { osd_visible = (GetTimerMS() + 1000) | 1; vo_osd_progbar_type = OSD_BALANCE; vo_osd_progbar_value = guiInfo.Balance * 256.0 / 100.0; vo_osd_changed(OSDTYPE_PROGBAR); } break; case evMenu: /*if (guiApp.menuIsPresent) NOTE TO MYSELF: Uncomment only after mouse * { pointer and cursor keys work * gtkShow( ivHidePopUpMenu,NULL ); with this menu from skin as * uiMenuShow( 0,0 ); they do with normal menus. * } * else*/gtkShow(ivShowPopUpMenu, NULL); break; case evIconify: switch (iparam) { case 0: wsWindowIconify(&guiApp.mainWindow); break; case 1: wsWindowIconify(&guiApp.videoWindow); break; } break; case evHalfSize: if (guiInfo.VideoWindow && guiInfo.Playing) { if (guiApp.videoWindow.isFullScreen) { uiFullScreen(); } wsWindowResize(&guiApp.videoWindow, guiInfo.VideoWidth / 2, guiInfo.VideoHeight / 2); btnSet(evFullScreen, btnReleased); } break; case evDoubleSize: if (guiInfo.VideoWindow && guiInfo.Playing) { if (guiApp.videoWindow.isFullScreen) { uiFullScreen(); } wsWindowResize(&guiApp.videoWindow, guiInfo.VideoWidth * 2, guiInfo.VideoHeight * 2); wsWindowMoveWithin(&guiApp.videoWindow, False, guiApp.video.x, guiApp.video.y); btnSet(evFullScreen, btnReleased); } break; case evNormalSize: if (guiInfo.VideoWindow && guiInfo.Playing) { if (guiApp.videoWindow.isFullScreen) { uiFullScreen(); } wsWindowResize(&guiApp.videoWindow, guiInfo.VideoWidth, guiInfo.VideoHeight); btnSet(evFullScreen, btnReleased); break; } else if (!guiApp.videoWindow.isFullScreen) break; case evFullScreen: if (guiInfo.VideoWindow && (guiInfo.Playing || !iparam)) { uiFullScreen(); if (!guiApp.videoWindow.isFullScreen) wsWindowResize(&guiApp.videoWindow, iparam ? guiInfo.VideoWidth : guiApp.video.width, iparam ? guiInfo.VideoHeight : guiApp.video.height); } if (guiApp.videoWindow.isFullScreen) btnSet(evFullScreen, btnPressed); else btnSet(evFullScreen, btnReleased); break; case evSetAspect: switch (iparam) { case 2: aspect = 16.0f / 9.0f; break; case 3: aspect = 4.0f / 3.0f; break; case 4: aspect = 2.35f; break; case 1: default: aspect = -1; break; } snprintf(cmd, sizeof(cmd), "pausing_keep switch_ratio %f", aspect); mp_input_queue_cmd(mp_input_parse_cmd(cmd)); break; case evSetRotation: switch (iparam) { case 90: guiInfo.Rotation = 1; break; case -90: guiInfo.Rotation = 2; break; case 180: guiInfo.Rotation = 8; break; case 0: default: guiInfo.Rotation = -1; break; } guiInfo.MediumChanged = GUI_MEDIUM_SAME; break; /* timer events */ case ivRedraw: { unsigned int now = GetTimerMS(); if ((now > last_redraw_time) && (now < last_redraw_time + GUI_REDRAW_WAIT) && !uiPlaybarFade && (iparam == 0)) break; last_redraw_time = now; } uiMainRender = True; wsWindowRedraw(&guiApp.mainWindow); wsWindowRedraw(&guiApp.playbarWindow); break; /* system events */ case evNone: mp_msg(MSGT_GPLAYER, MSGL_DBG2, "[actions] uiEvent: evNone\n"); break; default: mp_msg(MSGT_GPLAYER, MSGL_DBG2, "[actions] uiEvent: unknown event %d, param %.2f\n", ev, param); break; } }