From: Matthew Allum Date: Wed, 11 May 2005 12:52:01 +0000 (+0000) Subject: gl crash fixes X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=24cefa8d2a7e6c7af42e373648ef706301d2bc2b;p=profile%2Fivi%2Fclutter.git gl crash fixes --- diff --git a/ChangeLog b/ChangeLog index 4472d82..e9ad5fd 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,13 @@ +2005-05-11 mallum,,, + + * 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,,, * clutter/cltr-button.c: (cltr_button_new_with_label): diff --git a/clutter/cltr-video.c b/clutter/cltr-video.c index c55be0f..766af5f 100644 --- a/clutter/cltr-video.c +++ b/clutter/cltr-video.c @@ -23,7 +23,8 @@ struct CltrVideo float current_position; guint update_id; - char *last_error_message; + gchar *last_error_message; + gchar *mrl; }; @@ -42,6 +43,9 @@ parse_stream_info (CltrVideo *video); static gboolean cb_iterate (CltrVideo *video); +static void +reset_error_msg (CltrVideo *video); + static gboolean cltr_video_idler (CltrVideo *video); @@ -292,6 +296,16 @@ got_buffering (GstElement *play, #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 got_error (GstElement *play, @@ -579,11 +593,7 @@ cltr_video_play ( CltrVideo *video, GError ** error) { gboolean ret; - if (video->last_error_message) - { - g_free (video->last_error_message); - video->last_error_message = NULL; - } + reset_error_msg (video); ret = (gst_element_set_state (GST_ELEMENT (video->play), GST_STATE_PLAYING) == GST_STATE_SUCCESS); @@ -697,14 +707,25 @@ cltr_video_idler (CltrVideo *video) switch (signal->signal_id) { case CLTR_VIDEO_ASYNC_TEXTURE: - video->frame_texture = signal->signal_data.texture.ref; + { + Pixbuf *pixb = NULL; - /* - * we can actually grab the width and height from - * the textures pixbuf. - */ + video->frame_texture = signal->signal_data.texture.ref; + + 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_widget_queue_paint(CLTR_WIDGET(video)); + cltr_texture_unlock(video->frame_texture); + + cltr_widget_queue_paint(CLTR_WIDGET(video)); + } break; case CLTR_VIDEO_ASYNC_VIDEO_SIZE: video->video_width = signal->signal_data.video_size.width; @@ -730,13 +751,72 @@ cltr_video_idler (CltrVideo *video) } 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; } diff --git a/examples/photos.c b/examples/photos.c index 261cb21..6553c3b 100644 --- a/examples/photos.c +++ b/examples/photos.c @@ -131,12 +131,12 @@ main(int argc, char **argv) usage(argv[0]); } - win = cltr_window_new(640, 480); + win = cltr_window_new(800, 600); if (want_fullscreen) 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); diff --git a/examples/player.c b/examples/player.c index 0c6b62f..416fd60 100644 --- a/examples/player.c +++ b/examples/player.c @@ -41,6 +41,7 @@ handle_xevent(CltrWidget *win, XEvent *xev, void *cookie) else cltr_video_pause (video); Paused ^= 1; + break; } } @@ -65,17 +66,17 @@ main (int argc, char *argv[]) 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_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); diff --git a/gst/cltrimagesink.c b/gst/cltrimagesink.c index b86940a..6fb2b6e 100644 --- a/gst/cltrimagesink.c +++ b/gst/cltrimagesink.c @@ -331,21 +331,20 @@ gst_cltrimagesink_chain (GstPad * pad, GstData * data) if (pixb) { - /* memcpy (pixb->data, GST_BUFFER_DATA (buf), MIN (GST_BUFFER_SIZE (buf), 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) cltr_texture_force_rgb_data(cltrimagesink->texture, pixb->width, pixb->height, GST_BUFFER_DATA (buf)); - + */ } cltr_texture_unlock(cltrimagesink->texture);