openbsd-ports/x11/gmtk/patches/patch-src_gmtk_media_player_c
dcoppa 4f222f2285 Fix a subtle segmentation fault at program exit time:
gmtk_media_player_dispose() would be called multiple times, leading
to a double free from gdk_color_free()
(upstream svn revision r143)
2012-06-22 15:08:44 +00:00

180 lines
7.2 KiB
Plaintext

$OpenBSD: patch-src_gmtk_media_player_c,v 1.9 2012/06/22 15:08:45 dcoppa Exp $
Set black background color for all GTK states on media widget
(upstream svn revision r105)
Fix a subtle segmentation fault at program exit time:
gmtk_media_player_dispose() would be called multiple times, leading
to a double free from gdk_color_free()
(upstream svn revision r143)
Fix a couple of keyboard shortcuts as they were in the wrong shift
state, similar to gnome-mplayer fix (upstream svn revision r118)
Correct situation where media player window allocation is too small
or incorrect (upstream svn revision r109)
Protect against possible divide by zero in gmtk_media_player_size_allocate
(upstream svn revision r111)
Monitor subtitle visibility better
(upstream svn revision r112)
Fix logic error in ERROR_RETRY
(upstream svn revision r107)
If mplayer emits a signal at position 0, retry once
(upstream svn revision r108)
Replace deprecated g_strncasecmp with g_ascii_strncasecmp
(upstream svn revision r106)
--- src/gmtk_media_player.c.orig Fri Apr 6 15:19:32 2012
+++ src/gmtk_media_player.c Fri Jun 22 16:47:51 2012
@@ -56,6 +56,11 @@ static void socket_realized(GtkWidget * widget, gpoint
player->socket_id = GPOINTER_TO_INT(gtk_socket_get_id(GTK_SOCKET(widget)));
style = gtk_widget_get_style(GTK_WIDGET(player));
gtk_widget_modify_bg(GTK_WIDGET(player), GTK_STATE_NORMAL, &(style->black));
+ gtk_widget_modify_bg(GTK_WIDGET(player->alignment), GTK_STATE_NORMAL, &(style->black));
+ gtk_widget_modify_bg(GTK_WIDGET(player), GTK_STATE_ACTIVE, &(style->black));
+ gtk_widget_modify_bg(GTK_WIDGET(player), GTK_STATE_SELECTED, &(style->black));
+ gtk_widget_modify_bg(GTK_WIDGET(player), GTK_STATE_PRELIGHT, &(style->black));
+ gtk_widget_modify_bg(GTK_WIDGET(player), GTK_STATE_INSENSITIVE, &(style->black));
if (player->vo != NULL) {
if (!(g_ascii_strncasecmp(player->vo, "vdpau", strlen("vdpau")) == 0)) {
gtk_widget_modify_bg(GTK_WIDGET(player->socket), GTK_STATE_NORMAL, &(style->black));
@@ -338,6 +343,7 @@ static void gmtk_media_player_init(GmtkMediaPlayer * p
player->profile = NULL;
player->alang = NULL;
player->slang = NULL;
+ player->disposed = FALSE;
}
static void gmtk_media_player_dispose(GObject * object)
@@ -345,6 +351,11 @@ static void gmtk_media_player_dispose(GObject * object
GmtkMediaPlayer *player = GMTK_MEDIA_PLAYER(object);
+ if (player->disposed) {
+ return;
+ }
+ player->disposed = TRUE;
+
// cleanup the memory used
if (player->uri != NULL) {
@@ -444,7 +455,7 @@ static gboolean player_key_press_event_callback(GtkWid
if (event->is_modifier)
return TRUE;
- if ((event->state & GDK_SHIFT_MASK) == 0 && (event->state & GDK_CONTROL_MASK) == 0
+ if ((event->state & GDK_CONTROL_MASK) == 0
&& (event->state & GDK_MOD1_MASK) == 0) {
switch (event->keyval) {
case GDK_Right:
@@ -635,6 +646,15 @@ static void gmtk_media_player_size_allocate(GtkWidget
gdouble widget_aspect;
gfloat xscale, yscale;
+ if (allocation->width == 0 || allocation->height == 0) {
+ gmtk_get_allocation(widget, allocation);
+ }
+
+ // protect against possible divide by zero
+ if (allocation->width == 0 || allocation->height == 0) {
+ return;
+ }
+
if (player->video_width == 0 || player->video_height == 0 || !gmtk_widget_get_realized(widget)) {
gtk_alignment_set(GTK_ALIGNMENT(player->alignment), 0.0, 0.0, 1.0, 1.0);
} else {
@@ -1018,9 +1038,7 @@ gboolean gmtk_media_player_get_attribute_boolean(GmtkM
switch (attribute) {
case ATTRIBUTE_SUB_VISIBLE:
- if (g_list_length(player->subtitles) != 0) {
- ret = player->sub_visible;
- }
+ ret = player->sub_visible;
break;
case ATTRIBUTE_ENABLE_FRAME_DROP:
@@ -2578,10 +2596,10 @@ gpointer launch_mplayer(gpointer data)
break;
case ERROR_RETRY:
if (last_error == NO_ERROR) {
- last_error == ERROR_RETRY;
+ last_error = ERROR_RETRY;
} else {
- last_error == NO_ERROR;
- player->playback_error == NO_ERROR;
+ last_error = NO_ERROR;
+ player->playback_error = NO_ERROR;
}
break;
@@ -2679,10 +2697,18 @@ gboolean thread_reader_error(GIOChannel * source, GIOC
if (player->position == 0) {
player->playback_error = ERROR_RETRY;
}
+ } else if (strstr(mplayer_output->str, "filter video") != NULL) {
+ player->playback_error = ERROR_RETRY;
} else {
error_msg = g_strdup(mplayer_output->str);
}
}
+ if (strstr(mplayer_output->str, "Error when calling vdp_output_surface_create") != NULL) {
+ create_event_int(player, "attribute-changed", ATTRIBUTE_SIZE);
+ if (player->position == 0) {
+ player->playback_error = ERROR_RETRY;
+ }
+ }
if (strstr(mplayer_output->str, "Failed creating VDPAU decoder") != NULL) {
if (player->enable_divx && (g_ascii_strncasecmp(player->vo, "vdpau", strlen("vdpau")) == 0))
@@ -2886,6 +2912,7 @@ gboolean thread_reader(GIOChannel * source, GIOConditi
create_event_allocation(player, "size_allocate", &allocation);
player->video_present = TRUE;
write_to_mplayer(player, "get_property sub_source\n");
+ write_to_mplayer(player, "get_property sub_visibility\n");
create_event_int(player, "attribute-changed", ATTRIBUTE_SIZE);
create_event_int(player, "attribute-changed", ATTRIBUTE_VIDEO_PRESENT);
create_event_int(player, "subtitles-changed", g_list_length(player->subtitles));
@@ -2993,6 +3020,14 @@ gboolean thread_reader(GIOChannel * source, GIOConditi
create_event_int(player, "attribute-changed", ATTRIBUTE_SUBTITLE);
}
+ if (strstr(mplayer_output->str, "ANS_sub_visibility") != 0) {
+ if (strstr(mplayer_output->str, "ANS_sub_visibility=yes") != 0) {
+ player->sub_visible = TRUE;
+ } else {
+ player->sub_visible = FALSE;
+ }
+ create_event_int(player, "attribute-changed", ATTRIBUTE_SUB_VISIBLE);
+ }
if (strstr(mplayer_output->str, "DVDNAV_TITLE_IS_MENU") != 0) {
player->title_is_menu = TRUE;
@@ -3463,6 +3498,12 @@ gboolean thread_reader(GIOChannel * source, GIOConditi
message = NULL;
}
+ if (strstr(mplayer_output->str, "ID_SIGNAL") != 0) {
+ if (player->position == 0) {
+ player->playback_error = ERROR_RETRY;
+ }
+ }
+
}
g_string_free(mplayer_output, TRUE);
@@ -3521,7 +3562,7 @@ gboolean write_to_mplayer(GmtkMediaPlayer * player, co
if (player->use_mplayer2) {
pkf_cmd = g_strdup(cmd);
} else {
- if (g_strncasecmp(cmd, "pause", strlen("pause")) == 0) {
+ if (g_ascii_strncasecmp(cmd, "pause", strlen("pause")) == 0) {
pkf_cmd = g_strdup(cmd);
} else {
pkf_cmd = g_strdup_printf("pausing_keep_force %s", cmd);