changeset 7201:22beff6edf75

Improved MacOS X SDL support, enable SDL main() wrapper for Darwin, remove unused envp. Patch by Donnie Smith <xc0bead2d8130df59@f4n.org>, updated by me.
author atmos4
date Sat, 31 Aug 2002 15:04:18 +0000
parents 9a123ba671fd
children b414c2e34b2e
files Makefile cfgparser.c cfgparser.h libvo/vo_sdl.c mencoder.c mplayer.c
diffstat 6 files changed, 40 insertions(+), 8 deletions(-) [+]
line wrap: on
line diff
--- a/Makefile	Sat Aug 31 14:54:00 2002 +0000
+++ b/Makefile	Sat Aug 31 15:04:18 2002 +0000
@@ -50,7 +50,7 @@
 ifeq ($(VIDIX),yes)
 MISC_LIBS += -Llibdha -ldha vidix/libvidix.a
 endif
-CFLAGS = $(OPTFLAGS) -Ilibmpdemux -Iloader $(VO_INC) $(EXTRA_INC) $(CDPARANOIA_INC) $(FREETYPE_INC) # -Wall
+CFLAGS = $(OPTFLAGS) -Ilibmpdemux -Iloader $(VO_INC) $(EXTRA_INC) $(CDPARANOIA_INC) $(FREETYPE_INC) $(SDL_INC) # -Wall
 
 PARTS = libfame libmpdemux libmpcodecs mp3lib liba52 libmp1e libmpeg2 libavcodec libao2 drivers linux postproc input libmpdvdkit libvo
 ifeq ($(VIDIX),yes)
--- a/cfgparser.c	Sat Aug 31 14:54:00 2002 +0000
+++ b/cfgparser.c	Sat Aug 31 15:04:18 2002 +0000
@@ -1033,7 +1033,7 @@
 	return ret;
 }
 
-int m_config_parse_command_line(m_config_t *config, int argc, char **argv, char **envp)
+int m_config_parse_command_line(m_config_t *config, int argc, char **argv)
 {
 	int i;
 	int tmp;
@@ -1044,7 +1044,6 @@
 	assert(config != NULL);
 	assert(config->pt != NULL);
 	assert(argv != NULL);
-	assert(envp != NULL);
 	assert(argc >= 1);
 #endif
 	
--- a/cfgparser.h	Sat Aug 31 14:54:00 2002 +0000
+++ b/cfgparser.h	Sat Aug 31 15:04:18 2002 +0000
@@ -95,7 +95,7 @@
  * 	-1 on error (invalid option...)
  * 	 1 otherwise
  */
-int m_config_parse_command_line(m_config_t* config, int argc, char **argv, char **envp);
+int m_config_parse_command_line(m_config_t* config, int argc, char **argv);
 
 m_config_t* m_config_new(play_tree_t* pt);
 
--- a/libvo/vo_sdl.c	Sat Aug 31 14:54:00 2002 +0000
+++ b/libvo/vo_sdl.c	Sat Aug 31 15:04:18 2002 +0000
@@ -731,6 +731,29 @@
 	/* try to change to given fullscreenmode */
 	newsurface = SDL_SetVideoMode(priv->dstwidth, screen_surface_h, priv->bpp,
                                   priv->sdlfullflags);
+
+	/*
+	 * In Mac OS X (and possibly others?) SDL_SetVideoMode() appears to 
+	 * destroy the datastructure previously retrived, so we need to 
+	 * re-assign it.  The comment in sdl_close() seems to imply that we 
+	 * should not free() anything.
+	 */
+	#ifdef SYS_DARWIN
+	{
+	const SDL_VideoInfo *vidInfo = NULL;
+	vidInfo = SDL_GetVideoInfo ();
+
+	/* collect all fullscreen & hardware modes available */
+	if (!(priv->fullmodes = SDL_ListModes (vidInfo->vfmt, priv->sdlfullflags))) {
+
+	    /* non hardware accelerated fullscreen modes */
+	    priv->sdlfullflags &= ~SDL_HWSURFACE;
+	    priv->fullmodes = SDL_ListModes (vidInfo->vfmt, priv->sdlfullflags);
+	}
+	}
+	#endif
+
+
 	
 	/* if creation of new surface was successfull, save it and hide mouse cursor */
 	if(newsurface) {
--- a/mencoder.c	Sat Aug 31 14:54:00 2002 +0000
+++ b/mencoder.c	Sat Aug 31 15:04:18 2002 +0000
@@ -295,7 +295,7 @@
 }
 
 
-int main(int argc,char* argv[], char *envp[]){
+int main(int argc,char* argv[]){
 
 stream_t* stream=NULL;
 demuxer_t* demuxer=NULL;
@@ -373,7 +373,7 @@
   me_register_options(mconfig);
   parse_cfgfiles(mconfig);
 
-  if(m_config_parse_command_line(mconfig, argc, argv, envp) < 0) mencoder_exit(1, "error parsing cmdline");
+  if(m_config_parse_command_line(mconfig, argc, argv) < 0) mencoder_exit(1, "error parsing cmdline");
   playtree = play_tree_cleanup(playtree);
   if(playtree) {
     playtree_iter = play_tree_iter_new(playtree,mconfig);
--- a/mplayer.c	Sat Aug 31 14:54:00 2002 +0000
+++ b/mplayer.c	Sat Aug 31 15:04:18 2002 +0000
@@ -469,7 +469,17 @@
   return eof;
 }
 
-int main(int argc,char* argv[], char *envp[]){
+/*
+ * In Mac OS X the SDL-lib is built upon Cocoa. The easiest way to
+ * make it all work is to use the builtin SDL-bootstrap code, which 
+ * will be done automatically by replacing our main() if we include SDL.h.
+ */
+#if defined(SYS_DARWIN) && defined(HAVE_SDL)
+#include <SDL.h>
+#endif
+
+int main(int argc,char* argv[]){
+
 
 
 static demux_stream_t *d_audio=NULL;
@@ -564,7 +574,7 @@
     if ( use_gui ) cfg_read();
 #endif
 
-    if(m_config_parse_command_line(mconfig, argc, argv, envp) < 0) exit(1); // error parsing cmdline
+    if(m_config_parse_command_line(mconfig, argc, argv) < 0) exit(1); // error parsing cmdline
 
     playtree = play_tree_cleanup(playtree);
     if(playtree) {