diff options
author | Ronald S. Bultje <rbultje@ronald.bitfreak.net> | 2004-11-10 22:01:20 +0000 |
---|---|---|
committer | Ronald S. Bultje <rbultje@ronald.bitfreak.net> | 2004-11-10 22:01:20 +0000 |
commit | dabc952211f68c81c17ec992d24fe4dfbe979a3e (patch) | |
tree | be4b927321cfa26a4871378ab6241cbe566ba78d /ext/sdl | |
parent | b1e26428d0023642e7dbf94777ba610629c89952 (diff) | |
download | gst-plugins-bad-dabc952211f68c81c17ec992d24fe4dfbe979a3e.tar.gz gst-plugins-bad-dabc952211f68c81c17ec992d24fe4dfbe979a3e.tar.bz2 gst-plugins-bad-dabc952211f68c81c17ec992d24fe4dfbe979a3e.zip |
ext/alsa/gstalsasink.c: This seems to be antique leftover. It needs to pass error checking.
Original commit message from CVS:
* ext/alsa/gstalsasink.c: (gst_alsa_sink_get_time):
This seems to be antique leftover. It needs to pass error
checking.
* ext/sdl/sdlvideosink.c: (gst_sdlvideosink_init),
(gst_sdlvideosink_deinitsdl), (gst_sdlvideosink_initsdl),
(gst_sdlvideosink_destroy), (gst_sdlvideosink_create),
(gst_sdlvideosink_sinkconnect), (gst_sdlvideosink_chain):
Fix GstXOverlay implementation (#151059).
Diffstat (limited to 'ext/sdl')
-rw-r--r-- | ext/sdl/sdlvideosink.c | 67 |
1 files changed, 44 insertions, 23 deletions
diff --git a/ext/sdl/sdlvideosink.c b/ext/sdl/sdlvideosink.c index 0d8c719c..b765215e 100644 --- a/ext/sdl/sdlvideosink.c +++ b/ext/sdl/sdlvideosink.c @@ -279,7 +279,6 @@ gst_sdlvideosink_init (GstSDLVideoSink * sdlvideosink) #endif GST_FLAG_SET (sdlvideosink, GST_ELEMENT_THREAD_SUGGESTED); - GST_FLAG_SET (sdlvideosink, GST_ELEMENT_EVENT_AWARE); } static void @@ -390,10 +389,14 @@ gst_sdlvideosink_unlock (GstSDLVideoSink * sdlvideosink) static void gst_sdlvideosink_deinitsdl (GstSDLVideoSink * sdlvideosink) { + g_mutex_lock (sdlvideosink->lock); + if (sdlvideosink->init) { SDL_Quit (); sdlvideosink->init = FALSE; } + + g_mutex_unlock (sdlvideosink->lock); } static gboolean @@ -401,6 +404,8 @@ gst_sdlvideosink_initsdl (GstSDLVideoSink * sdlvideosink) { gst_sdlvideosink_deinitsdl (sdlvideosink); + g_mutex_lock (sdlvideosink->lock); + if (!sdlvideosink->xwindow_id) { unsetenv ("SDL_WINDOWID"); } else { @@ -414,15 +419,22 @@ gst_sdlvideosink_initsdl (GstSDLVideoSink * sdlvideosink) if (SDL_Init (SDL_INIT_VIDEO | SDL_INIT_NOPARACHUTE) < 0) { GST_ELEMENT_ERROR (sdlvideosink, LIBRARY, INIT, (NULL), ("Couldn't initialize SDL: %s", SDL_GetError ())); + g_mutex_unlock (sdlvideosink->lock); return FALSE; } + sdlvideosink->init = TRUE; + + g_mutex_unlock (sdlvideosink->lock); + return TRUE; } static void gst_sdlvideosink_destroy (GstSDLVideoSink * sdlvideosink) { + g_mutex_lock (sdlvideosink->lock); + if (sdlvideosink->overlay) { SDL_FreeYUVOverlay (sdlvideosink->overlay); sdlvideosink->overlay = NULL; @@ -432,6 +444,8 @@ gst_sdlvideosink_destroy (GstSDLVideoSink * sdlvideosink) SDL_FreeSurface (sdlvideosink->screen); sdlvideosink->screen = NULL; } + + g_mutex_unlock (sdlvideosink->lock); } static gboolean @@ -444,6 +458,8 @@ gst_sdlvideosink_create (GstSDLVideoSink * sdlvideosink) gst_sdlvideosink_destroy (sdlvideosink); + g_mutex_lock (sdlvideosink->lock); + /* create a SDL window of the size requested by the user */ sdlvideosink->screen = SDL_SetVideoMode (GST_VIDEOSINK_WIDTH (sdlvideosink), GST_VIDEOSINK_HEIGHT (sdlvideosink), 0, SDL_HWSURFACE | SDL_RESIZABLE); @@ -451,6 +467,7 @@ gst_sdlvideosink_create (GstSDLVideoSink * sdlvideosink) GST_ELEMENT_ERROR (sdlvideosink, LIBRARY, TOO_LAZY, (NULL), ("SDL: Couldn't set %dx%d: %s", GST_VIDEOSINK_WIDTH (sdlvideosink), GST_VIDEOSINK_HEIGHT (sdlvideosink), SDL_GetError ())); + g_mutex_unlock (sdlvideosink->lock); return FALSE; } @@ -462,6 +479,7 @@ gst_sdlvideosink_create (GstSDLVideoSink * sdlvideosink) ("SDL: Couldn't create SDL YUV overlay (%dx%d \'" GST_FOURCC_FORMAT "\'): %s", sdlvideosink->width, sdlvideosink->height, GST_FOURCC_ARGS (sdlvideosink->format), SDL_GetError ())); + g_mutex_unlock (sdlvideosink->lock); return FALSE; } else { GST_DEBUG ("Using a %dx%d %dbpp SDL screen with a %dx%d \'" @@ -476,13 +494,13 @@ gst_sdlvideosink_create (GstSDLVideoSink * sdlvideosink) sdlvideosink->rect.w = GST_VIDEOSINK_WIDTH (sdlvideosink); sdlvideosink->rect.h = GST_VIDEOSINK_HEIGHT (sdlvideosink); - SDL_DisplayYUVOverlay (sdlvideosink->overlay, &(sdlvideosink->rect)); + /*SDL_DisplayYUVOverlay (sdlvideosink->overlay, &(sdlvideosink->rect)); */ GST_DEBUG ("sdlvideosink: setting %08x (" GST_FOURCC_FORMAT ")", sdlvideosink->format, GST_FOURCC_ARGS (sdlvideosink->format)); - gst_x_overlay_got_desired_size (GST_X_OVERLAY (sdlvideosink), - GST_VIDEOSINK_WIDTH (sdlvideosink), GST_VIDEOSINK_HEIGHT (sdlvideosink)); + g_mutex_unlock (sdlvideosink->lock); + return TRUE; } @@ -532,6 +550,9 @@ gst_sdlvideosink_sinkconnect (GstPad * pad, const GstCaps * vscapslist) if (!sdlvideosink->format || !gst_sdlvideosink_create (sdlvideosink)) return GST_PAD_LINK_REFUSED; + gst_x_overlay_got_desired_size (GST_X_OVERLAY (sdlvideosink), + sdlvideosink->width, sdlvideosink->height); + return GST_PAD_LINK_OK; } @@ -539,40 +560,38 @@ gst_sdlvideosink_sinkconnect (GstPad * pad, const GstCaps * vscapslist) static void gst_sdlvideosink_chain (GstPad * pad, GstData * _data) { - GstBuffer *buf = GST_BUFFER (_data); + GstBuffer *buf; GstSDLVideoSink *sdlvideosink; SDL_Event sdl_event; g_return_if_fail (pad != NULL); g_return_if_fail (GST_IS_PAD (pad)); - g_return_if_fail (buf != NULL); + g_return_if_fail (_data != NULL); - sdlvideosink = GST_SDLVIDEOSINK (gst_pad_get_parent (pad)); - - if (GST_IS_EVENT (buf)) { - GstEvent *event = GST_EVENT (buf); - gint64 offset; - - switch (GST_EVENT_TYPE (event)) { - case GST_EVENT_DISCONTINUOUS: - offset = GST_EVENT_DISCONT_OFFSET (event, 0).value; - /*gst_clock_handle_discont (sdlvideosink->clock, - (guint64) GST_EVENT_DISCONT_OFFSET (event, 0).value); */ - break; - default: - gst_pad_event_default (pad, event); - return; - } - gst_event_unref (event); + if (GST_IS_EVENT (_data)) { + gst_pad_event_default (pad, GST_EVENT (_data)); return; } + buf = GST_BUFFER (_data); + sdlvideosink = GST_SDLVIDEOSINK (gst_pad_get_parent (pad)); + if (GST_VIDEOSINK_CLOCK (sdlvideosink) && GST_BUFFER_TIMESTAMP_IS_VALID (buf)) { gst_element_wait (GST_ELEMENT (sdlvideosink), GST_BUFFER_TIMESTAMP (buf)); } + g_mutex_lock (sdlvideosink->lock); + if (!sdlvideosink->init || + !sdlvideosink->overlay || !sdlvideosink->overlay->pixels) { + g_warning ("Not init!"); + gst_buffer_unref (buf); + g_mutex_unlock (sdlvideosink->lock); + return; + } + if (GST_BUFFER_DATA (buf) != sdlvideosink->overlay->pixels[0]) { if (!gst_sdlvideosink_lock (sdlvideosink)) { + g_mutex_unlock (sdlvideosink->lock); return; } @@ -611,6 +630,8 @@ gst_sdlvideosink_chain (GstPad * pad, GstData * _data) break; } } + + g_mutex_unlock (sdlvideosink->lock); } |