gl crash fixes

This commit is contained in:
Matthew Allum 2005-05-11 12:52:01 +00:00
parent f085407d41
commit 24cefa8d2a
5 changed files with 116 additions and 26 deletions

View File

@ -1,3 +1,13 @@
2005-05-11 mallum,,, <mallum@openedhand.com>
* clutter/cltr-video.c: (got_buffering), (cltr_video_new),
(cltr_video_play), (cltr_video_idler):
* examples/photos.c: (main):
* examples/player.c: (handle_xevent), (main):
* gst/cltrimagesink.c: (gst_cltrimagesink_chain):
Fix Gl thread related crash on video playback
Make examples less bound to my laptop ;)
2005-05-06 mallum,,, <mallum@openedhand.com> 2005-05-06 mallum,,, <mallum@openedhand.com>
* clutter/cltr-button.c: (cltr_button_new_with_label): * clutter/cltr-button.c: (cltr_button_new_with_label):

View File

@ -23,7 +23,8 @@ struct CltrVideo
float current_position; float current_position;
guint update_id; guint update_id;
char *last_error_message; gchar *last_error_message;
gchar *mrl;
}; };
@ -42,6 +43,9 @@ parse_stream_info (CltrVideo *video);
static gboolean static gboolean
cb_iterate (CltrVideo *video); cb_iterate (CltrVideo *video);
static void
reset_error_msg (CltrVideo *video);
static gboolean static gboolean
cltr_video_idler (CltrVideo *video); cltr_video_idler (CltrVideo *video);
@ -292,6 +296,16 @@ got_buffering (GstElement *play,
#endif #endif
} }
static void
reset_error_msg (CltrVideo *video)
{
if (video->last_error_message)
{
g_free (video->last_error_message);
video->last_error_message = NULL;
}
}
static void static void
got_error (GstElement *play, got_error (GstElement *play,
@ -579,11 +593,7 @@ cltr_video_play ( CltrVideo *video, GError ** error)
{ {
gboolean ret; gboolean ret;
if (video->last_error_message) reset_error_msg (video);
{
g_free (video->last_error_message);
video->last_error_message = NULL;
}
ret = (gst_element_set_state (GST_ELEMENT (video->play), ret = (gst_element_set_state (GST_ELEMENT (video->play),
GST_STATE_PLAYING) == GST_STATE_SUCCESS); GST_STATE_PLAYING) == GST_STATE_SUCCESS);
@ -697,14 +707,25 @@ cltr_video_idler (CltrVideo *video)
switch (signal->signal_id) switch (signal->signal_id)
{ {
case CLTR_VIDEO_ASYNC_TEXTURE: case CLTR_VIDEO_ASYNC_TEXTURE:
video->frame_texture = signal->signal_data.texture.ref; {
Pixbuf *pixb = NULL;
/* video->frame_texture = signal->signal_data.texture.ref;
* we can actually grab the width and height from
* the textures pixbuf.
*/
cltr_widget_queue_paint(CLTR_WIDGET(video)); cltr_texture_lock(video->frame_texture);
pixb = cltr_texture_get_pixbuf(video->frame_texture);
if (pixb)
cltr_texture_force_rgb_data(video->frame_texture,
pixb->width,
pixb->height,
pixb->data);
cltr_texture_unlock(video->frame_texture);
cltr_widget_queue_paint(CLTR_WIDGET(video));
}
break; break;
case CLTR_VIDEO_ASYNC_VIDEO_SIZE: case CLTR_VIDEO_ASYNC_VIDEO_SIZE:
video->video_width = signal->signal_data.video_size.width; video->video_width = signal->signal_data.video_size.width;
@ -730,13 +751,72 @@ cltr_video_idler (CltrVideo *video)
} }
gboolean gboolean
cltr_video_set_source(CltrVideo *video, char *location) cltr_video_set_source(CltrVideo *video, char *mrl)
{ {
/* if (!gst_play_set_location (video->play, location)) */ gboolean ret;
g_object_set (G_OBJECT (video->play), "uri", location, NULL); if (video->mrl && !strcmp (video->mrl, mrl))
return TRUE;
if (video->mrl)
g_free (video->mrl);
video->mrl = g_strdup (mrl);
gst_element_set_state (GST_ELEMENT (video->play), GST_STATE_READY);
reset_error_msg (video);
/* video->got_redirect = FALSE; */
video->has_video = FALSE;
video->stream_length = 0;
/* Dont handle subtitles as yet
if (g_strrstr (video->mrl, "#subtitle:"))
{
gchar **uris;
uris = g_strsplit (video->mrl, "#subtitle:", 2);
g_object_set (G_OBJECT (video->play), "uri",
uris[0], "suburi", uris[1], NULL);
g_strfreev (uris);
}
else
{
g_object_set (G_OBJECT (video->play), "uri",
video->mrl, "suburi", subtitle_uri, NULL);
}
*/
g_object_set (G_OBJECT (video->play), "uri",
video->mrl, "suburi", NULL, NULL);
ret = (gst_element_set_state (video->play,
GST_STATE_PAUSED) == GST_STATE_SUCCESS);
if (!ret /* && !video->got_redirect */)
{
/*
g_set_error (error, 0, 0, "%s", video->last_error_message ?
video->last_error_message : "Failed to open; reason unknown");
*/
g_free (video->mrl);
video->mrl = NULL;
return FALSE;
}
/*
if (ret)
g_signal_emit (bvw, bvw_table_signals[SIGNAL_CHANNELS_CHANGE], 0);
*/
return ret;
return TRUE;
} }

View File

@ -131,12 +131,12 @@ main(int argc, char **argv)
usage(argv[0]); usage(argv[0]);
} }
win = cltr_window_new(640, 480); win = cltr_window_new(800, 600);
if (want_fullscreen) if (want_fullscreen)
cltr_window_set_fullscreen(CLTR_WINDOW(win)); cltr_window_set_fullscreen(CLTR_WINDOW(win));
grid = cltr_photo_grid_new(640, 480, cols, cols, ImgPath); grid = cltr_photo_grid_new(800, 600, cols, cols, ImgPath);
cltr_window_focus_widget(CLTR_WINDOW(win), grid); cltr_window_focus_widget(CLTR_WINDOW(win), grid);

View File

@ -41,6 +41,7 @@ handle_xevent(CltrWidget *win, XEvent *xev, void *cookie)
else else
cltr_video_pause (video); cltr_video_pause (video);
Paused ^= 1; Paused ^= 1;
break; break;
} }
} }
@ -65,17 +66,17 @@ main (int argc, char *argv[])
font = font_new("Sans bold 96"); font = font_new("Sans bold 96");
win = cltr_window_new(1400, 1050); win = cltr_window_new(800, 600);
video = cltr_video_new(1400, 1050); video = cltr_video_new(800, 600);
cltr_video_set_source(CLTR_VIDEO(video), argv[1]); cltr_video_set_source(CLTR_VIDEO(video), argv[1]);
cltr_widget_add_child(win, video, 0, 0); cltr_widget_add_child(win, video, 0, 0);
// label = cltr_label_new("hello world", font, &col); label = cltr_label_new("hello world", font, &col);
// cltr_widget_add_child(win, label, 100, 300); cltr_widget_add_child(win, label, 100, 300);
cltr_window_on_xevent(CLTR_WINDOW(win), handle_xevent, video); cltr_window_on_xevent(CLTR_WINDOW(win), handle_xevent, video);

View File

@ -331,21 +331,20 @@ gst_cltrimagesink_chain (GstPad * pad, GstData * data)
if (pixb) if (pixb)
{ {
/*
memcpy (pixb->data, memcpy (pixb->data,
GST_BUFFER_DATA (buf), GST_BUFFER_DATA (buf),
MIN (GST_BUFFER_SIZE (buf), MIN (GST_BUFFER_SIZE (buf),
pixb->bytes_per_line * pixb->width)); pixb->bytes_per_line * pixb->width));
*/
/* EVIL */ /* Below faster but threading issues causing DRI to bomb out */
/*
if (GST_BUFFER_SIZE (buf) >= pixb->width * pixb->height * 3) if (GST_BUFFER_SIZE (buf) >= pixb->width * pixb->height * 3)
cltr_texture_force_rgb_data(cltrimagesink->texture, cltr_texture_force_rgb_data(cltrimagesink->texture,
pixb->width, pixb->width,
pixb->height, pixb->height,
GST_BUFFER_DATA (buf)); GST_BUFFER_DATA (buf));
*/
} }
cltr_texture_unlock(cltrimagesink->texture); cltr_texture_unlock(cltrimagesink->texture);