# HG changeset patch # User ib # Date 1309357479 0 # Node ID 45553d0f65c67281a74e0b4c0aeb5ed354b42223 # Parent 006a2db8bd5585d0e50c51a5f37ef7e7c84aa95e Don't let MPlayer directly call user interface functions. Provide uiEnd() as the new guiGetEvent type guiEndFile. That way, access is possible through the official interface function. diff -r 006a2db8bd55 -r 45553d0f65c6 gui/interface.c --- a/gui/interface.c Wed Jun 29 13:37:04 2011 +0000 +++ b/gui/interface.c Wed Jun 29 14:24:39 2011 +0000 @@ -555,6 +555,7 @@ #ifdef CONFIG_DVDREAD dvd_priv_t *dvd; #endif + plItem *next; if (guiInfo.mpcontext) mixer = mpctx_get_mixer(guiInfo.mpcontext); @@ -970,6 +971,50 @@ wsEvents(wsDisplay, arg); gtkEventHandling(); break; + + case guiEndFile: + + if (!uiGotoTheNext && guiInfo.Playing) { + uiGotoTheNext = 1; + break; + } + + if (guiInfo.Playing && (next = gtkSet(gtkGetNextPlItem, 0, NULL)) && (plLastPlayed != next)) { + plLastPlayed = next; + guiSetDF(guiInfo.Filename, next->path, next->name); + guiInfo.StreamType = STREAMTYPE_FILE; + guiInfo.FilenameChanged = guiInfo.NewPlay = 1; + gfree((void **)&guiInfo.AudioFile); + gfree((void **)&guiInfo.Subtitlename); + } else { + if (guiInfo.FilenameChanged || guiInfo.NewPlay) + break; + + guiInfo.TimeSec = 0; + guiInfo.Position = 0; + guiInfo.AudioChannels = 0; + guiInfo.MovieWindow = True; + +#ifdef CONFIG_DVDREAD + guiInfo.DVD.current_title = 1; + guiInfo.DVD.current_chapter = 1; + guiInfo.DVD.current_angle = 1; +#endif + + if (!guiApp.subWindow.isFullScreen && gtkShowVideoWindow) { + wsResizeWindow(&guiApp.subWindow, guiApp.sub.width, guiApp.sub.height); + wsMoveWindow(&guiApp.subWindow, True, guiApp.sub.x, guiApp.sub.y); + } else + wsVisibleWindow(&guiApp.subWindow, wsHideWindow); + + guiGetEvent(guiSetState, (void *)GUI_STOP); + uiSubRender = 1; + wsSetBackgroundRGB(&guiApp.subWindow, guiApp.sub.R, guiApp.sub.G, guiApp.sub.B); + wsClearWindow(guiApp.subWindow); + wsPostRedisplay(&guiApp.subWindow); + } + + break; } return True; diff -r 006a2db8bd55 -r 45553d0f65c6 gui/interface.h --- a/gui/interface.h Wed Jun 29 13:37:04 2011 +0000 +++ b/gui/interface.h Wed Jun 29 14:24:39 2011 +0000 @@ -51,6 +51,7 @@ #define guiPreparation 16 #define guiSetAfilter 17 #define guiSetContext 18 +#define guiEndFile 19 #define GUI_STOP 0 #define GUI_PLAY 1 diff -r 006a2db8bd55 -r 45553d0f65c6 gui/ui/actions.c --- a/gui/ui/actions.c Wed Jun 29 13:37:04 2011 +0000 +++ b/gui/ui/actions.c Wed Jun 29 14:24:39 2011 +0000 @@ -91,51 +91,6 @@ wsSetBackgroundRGB(&guiApp.subWindow, guiApp.sub.R, guiApp.sub.G, guiApp.sub.B); } -void uiEnd(void) -{ - plItem *next; - - if (!uiGotoTheNext && guiInfo.Playing) { - uiGotoTheNext = 1; - return; - } - - if (guiInfo.Playing && (next = gtkSet(gtkGetNextPlItem, 0, NULL)) && (plLastPlayed != next)) { - plLastPlayed = next; - guiSetDF(guiInfo.Filename, next->path, next->name); - guiInfo.StreamType = STREAMTYPE_FILE; - guiInfo.FilenameChanged = guiInfo.NewPlay = 1; - gfree((void **)&guiInfo.AudioFile); - gfree((void **)&guiInfo.Subtitlename); - } else { - if (guiInfo.FilenameChanged || guiInfo.NewPlay) - return; - - guiInfo.TimeSec = 0; - guiInfo.Position = 0; - guiInfo.AudioChannels = 0; - guiInfo.MovieWindow = True; - -#ifdef CONFIG_DVDREAD - guiInfo.DVD.current_title = 1; - guiInfo.DVD.current_chapter = 1; - guiInfo.DVD.current_angle = 1; -#endif - - if (!guiApp.subWindow.isFullScreen && gtkShowVideoWindow) { - wsResizeWindow(&guiApp.subWindow, guiApp.sub.width, guiApp.sub.height); - wsMoveWindow(&guiApp.subWindow, True, guiApp.sub.x, guiApp.sub.y); - } else - wsVisibleWindow(&guiApp.subWindow, wsHideWindow); - - guiGetEvent(guiSetState, (void *)GUI_STOP); - uiSubRender = 1; - wsSetBackgroundRGB(&guiApp.subWindow, guiApp.sub.R, guiApp.sub.G, guiApp.sub.B); - wsClearWindow(guiApp.subWindow); - wsPostRedisplay(&guiApp.subWindow); - } -} - void uiPlay(void) { if (!guiInfo.Filename || diff -r 006a2db8bd55 -r 45553d0f65c6 gui/ui/actions.h --- a/gui/ui/actions.h Wed Jun 29 13:37:04 2011 +0000 +++ b/gui/ui/actions.h Wed Jun 29 14:24:39 2011 +0000 @@ -24,7 +24,6 @@ void uiAbsSeek(float sec); void uiChangeSkin(char *name); void uiCurr(void); -void uiEnd(void); void uiFullScreen(void); void uiNext(void); void uiPause(void); diff -r 006a2db8bd55 -r 45553d0f65c6 gui/win32/interface.c --- a/gui/win32/interface.c Wed Jun 29 13:37:04 2011 +0000 +++ b/gui/win32/interface.c Wed Jun 29 14:24:39 2011 +0000 @@ -384,53 +384,6 @@ mygui->startplay(mygui); } -void uiEnd( void ) -{ - if(!uiGotoTheNext && guiInfo.Playing) - { - uiGotoTheNext = 1; - return; - } - - 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 = guiInfo.FilenameChanged = guiInfo.NewPlay = 1; - uiSetFileName(NULL, mygui->playlist->tracks[(mygui->playlist->current)++]->filename, STREAMTYPE_STREAM); - //sprintf(guiInfo.Filename, mygui->playlist->tracks[(mygui->playlist->current)++]->filename); - } - - if(guiInfo.FilenameChanged && guiInfo.NewPlay) - return; - - guiInfo.TimeSec = 0; - guiInfo.Position = 0; - guiInfo.AudioChannels = 0; - -#ifdef CONFIG_DVDREAD - guiInfo.DVD.current_title = 1; - guiInfo.DVD.current_chapter = 1; - guiInfo.DVD.current_angle = 1; -#endif - - 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->subwindow, GWL_STYLE, style); - } - guiGetEvent(guiSetState, (void *) GUI_STOP); -} - void uiStop(void) { guiGetEvent(guiSetState, (void *) GUI_STOP); @@ -745,6 +698,53 @@ } break; } + case guiEndFile: + { + 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 = guiInfo.FilenameChanged = guiInfo.NewPlay = 1; + uiSetFileName(NULL, mygui->playlist->tracks[(mygui->playlist->current)++]->filename, STREAMTYPE_STREAM); + //sprintf(guiInfo.Filename, mygui->playlist->tracks[(mygui->playlist->current)++]->filename); + } + + if(guiInfo.FilenameChanged && guiInfo.NewPlay) + break; + + guiInfo.TimeSec = 0; + guiInfo.Position = 0; + guiInfo.AudioChannels = 0; + +#ifdef CONFIG_DVDREAD + guiInfo.DVD.current_title = 1; + guiInfo.DVD.current_chapter = 1; + guiInfo.DVD.current_angle = 1; +#endif + + 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->subwindow, GWL_STYLE, style); + } + guiGetEvent(guiSetState, (void *) GUI_STOP); + break; + } default: mp_msg(MSGT_GPLAYER, MSGL_ERR, "[GUI] GOT UNHANDLED EVENT %i\n", type); } diff -r 006a2db8bd55 -r 45553d0f65c6 mplayer.c --- a/mplayer.c Wed Jun 29 13:37:04 2011 +0000 +++ b/mplayer.c Wed Jun 29 14:24:39 2011 +0000 @@ -4103,7 +4103,7 @@ #ifdef CONFIG_DVDREAD if (!guiInfo.DiskChanged) #endif - uiEnd(); + guiGetEvent(guiEndFile, NULL); } #endif