[MPlayer-dev-eng] [PATCH] Windows GUI with mingw64 and cygwin
Stephen Sheldon
sfsheldo at gmail.com
Wed May 4 23:42:37 CEST 2011
I realize the the mplayer gui is deprecated as far as the mplayer developers
are concerned, but there has been a lot
of activity on the X11 version recently. I have some fixes for the
Windows version.
The Windows gui does not work when MPlayer is compiled with
the MingGW64 tool chain, or with cygwin. Apparently in some prior reorganization
of the code the gfree function was lost, and it was #defined as
free in gui/win32/dialogs.h. The problem is that gfree expects a
pointer to a pointer, but free expects a pointer. The mingw32 runtime
must not care about being passed a bad pointer to free, but mingw64 and
cygwin have access errors.
My solution is to get rid of the #define for gfree in gui/win32/dialogs.h and
fix the calls to gfree and free in the gui/win32 directory. I had to
change 2 macro definitions in the gui/interface.h file to get rid of
references to gfree. I did this rather than reintroduce gfree to gui/win32,
since it evidently was so confusing.
I also added a #include for process.h in gui/win32/interface.h, to satisfy
the call to _beginthreadx.
The change in gui/win32/wincfg.c is to get around a recent change in the X11 gui.
With this fix for gfree/free, the Windows gui also works when compiled
with cygwin, if you also apply the change mentioned in this email
http://lists.mplayerhq.hu/pipermail/mplayer-cygwin/2010-June/003305.html.
Index: gui/win32/interface.c
===================================================================
--- gui/win32/interface.c (revision 33366)
+++ gui/win32/interface.c (working copy)
@@ -22,6 +22,7 @@
*/
#include <windows.h>
+#include <process.h>
#include "path.h"
#include "gui/interface.h"
#include "m_option.h"
@@ -433,8 +434,10 @@
guiSetDF(guiIntfStruct.Filename, dir, name);
guiIntfStruct.StreamType = type;
- free((void **) &guiIntfStruct.AudioFile);
- free((void **) &guiIntfStruct.Subtitlename);
+ free(guiIntfStruct.AudioFile);
+ guiIntfStruct.AudioFile = NULL;
+ free(guiIntfStruct.Subtitlename);
+ guiIntfStruct.Subtitlename = NULL;
}
void mplFullScreen( void )
Index: gui/win32/preferences.c
===================================================================
--- gui/win32/preferences.c (revision 33366)
+++ gui/win32/preferences.c (working copy)
@@ -561,14 +561,16 @@
if(guiIntfStruct.Playing) guiGetEvent(guiCEvent, (void
*)guiSetStop);
/* Set the video driver */
- gfree(video_driver_list[0]);
+ free(video_driver_list[0]);
+ video_driver_list[0] = NULL;
strl = SendMessage(vo_driver, CB_GETCURSEL, 0, 0);
video_driver_list[0] = malloc(strl);
SendMessage(vo_driver, CB_GETLBTEXT, (WPARAM)strl,
(LPARAM)video_driver_list[0]);
/* Set the audio driver */
- gfree(audio_driver_list[0]);
+ free(audio_driver_list[0]);
+ audio_driver_list[0] = NULL;
strl = SendMessage(ao_driver, CB_GETCURSEL, 0, 0);
audio_driver_list[0] = malloc(strl);
SendMessage(ao_driver, CB_GETLBTEXT, (WPARAM)strl,
Index: gui/win32/dialogs.h
===================================================================
--- gui/win32/dialogs.h (revision 33366)
+++ gui/win32/dialogs.h (working copy)
@@ -34,7 +34,6 @@
#define SOLID_GREY (HBRUSH) CreateSolidBrush(RGB(232, 232, 232))
#define SOLID_GREY2 (HBRUSH) CreateSolidBrush(RGB(175, 175, 175))
-#define gfree free
#define MAXFILE 1024
Index: gui/win32/wincfg.c
===================================================================
--- gui/win32/wincfg.c (revision 33366)
+++ gui/win32/wincfg.c (working copy)
@@ -56,7 +56,7 @@
int gui_sub_pos_x = -1;
int gui_sub_pos_y = -1;
-static m_config_t *gui_conf;
+m_config_t *gui_conf;
static const m_option_t gui_opts[] =
{
{ "priority", &proc_priority, CONF_TYPE_STRING, 0, 0, 0, NULL},
Index: gui/interface.h
===================================================================
--- gui/interface.h (revision 33366)
+++ gui/interface.h (working copy)
@@ -93,13 +93,13 @@
#define guiSetFilename(s, n) \
{ \
- gfree((void **)&s); \
+ free((void *)s); \
s = gstrdup(n); \
}
#define guiSetDF(s, d, n) \
{ \
- gfree((void **)&s); \
+ free((void *)s); \
s = malloc(strlen(d) + strlen(n) + 5); \
sprintf(s, "%s/%s", d, n); \
}
More information about the MPlayer-dev-eng
mailing list