[cogl/cogl-1.16] cogl-gst: protect public API using type checks
- From: Lionel Landwerlin <llandwerlin src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [cogl/cogl-1.16] cogl-gst: protect public API using type checks
- Date: Tue, 9 Jul 2013 12:30:50 +0000 (UTC)
commit 86cd26b67c7d2a796bea0f1b74ab99063c11a9e3
Author: Lionel Landwerlin <llandwerlin gmail com>
Date: Fri Jul 5 17:27:34 2013 +0100
cogl-gst: protect public API using type checks
(cherry picked from commit 9a8c6536088368060a85f74d082c3dd8487b877c)
cogl-gst/cogl-gst-video-sink.c | 37 ++++++++++++++++++++++++++++++++-----
1 files changed, 32 insertions(+), 5 deletions(-)
---
diff --git a/cogl-gst/cogl-gst-video-sink.c b/cogl-gst/cogl-gst-video-sink.c
index b4dada5..22326e5 100644
--- a/cogl-gst/cogl-gst-video-sink.c
+++ b/cogl-gst/cogl-gst-video-sink.c
@@ -246,6 +246,8 @@ void
cogl_gst_video_sink_set_first_layer (CoglGstVideoSink *sink,
int first_layer)
{
+ g_return_if_fail (COGL_GST_IS_VIDEO_SINK (sink));
+
if (first_layer != sink->priv->custom_start)
{
sink->priv->custom_start = first_layer;
@@ -261,6 +263,8 @@ void
cogl_gst_video_sink_set_default_sample (CoglGstVideoSink *sink,
CoglBool default_sample)
{
+ g_return_if_fail (COGL_GST_IS_VIDEO_SINK (sink));
+
if (default_sample != sink->priv->default_sample)
{
sink->priv->default_sample = default_sample;
@@ -272,7 +276,10 @@ void
cogl_gst_video_sink_setup_pipeline (CoglGstVideoSink *sink,
CoglPipeline *pipeline)
{
- sink->priv->renderer->setup_pipeline (sink, pipeline);
+ g_return_if_fail (COGL_GST_IS_VIDEO_SINK (sink));
+
+ if (sink->priv->renderer)
+ sink->priv->renderer->setup_pipeline (sink, pipeline);
}
static SnippetCacheEntry *
@@ -368,7 +375,11 @@ setup_pipeline_from_cache_entry (CoglGstVideoSink *sink,
CoglPipeline *
cogl_gst_video_sink_get_pipeline (CoglGstVideoSink *vt)
{
- CoglGstVideoSinkPrivate *priv = vt->priv;
+ CoglGstVideoSinkPrivate *priv;
+
+ g_return_val_if_fail (COGL_GST_IS_VIDEO_SINK (vt), NULL);
+
+ priv = vt->priv;
if (priv->pipeline == NULL)
{
@@ -1272,7 +1283,11 @@ cogl_gst_video_sink_new (CoglContext *ctx)
float
cogl_gst_video_sink_get_aspect (CoglGstVideoSink *vt)
{
- GstVideoInfo *info = &vt->priv->info;
+ GstVideoInfo *info;
+
+ g_return_val_if_fail (COGL_GST_IS_VIDEO_SINK (vt), 0.);
+
+ info = &vt->priv->info;
return ((float)info->width * (float)info->par_n) /
((float)info->height * (float)info->par_d);
}
@@ -1281,7 +1296,11 @@ float
cogl_gst_video_sink_get_width_for_height (CoglGstVideoSink *vt,
float height)
{
- float aspect = cogl_gst_video_sink_get_aspect (vt);
+ float aspect;
+
+ g_return_val_if_fail (COGL_GST_IS_VIDEO_SINK (vt), 0.);
+
+ aspect = cogl_gst_video_sink_get_aspect (vt);
return height * aspect;
}
@@ -1289,7 +1308,11 @@ float
cogl_gst_video_sink_get_height_for_width (CoglGstVideoSink *vt,
float width)
{
- float aspect = cogl_gst_video_sink_get_aspect (vt);
+ float aspect;
+
+ g_return_val_if_fail (COGL_GST_IS_VIDEO_SINK (vt), 0.);
+
+ aspect = cogl_gst_video_sink_get_aspect (vt);
return width / aspect;
}
@@ -1298,6 +1321,10 @@ cogl_gst_video_sink_fit_size (CoglGstVideoSink *vt,
const CoglGstRectangle *available,
CoglGstRectangle *output)
{
+ g_return_if_fail (COGL_GST_IS_VIDEO_SINK (vt));
+ g_return_if_fail (available != NULL);
+ g_return_if_fail (output != NULL);
+
if (available->height == 0.0f)
{
output->x = available->x;
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]