bufferpool: improve _new function

This commit is contained in:
Wim Taymans 2011-07-18 10:51:21 +02:00
parent 9c087d7d85
commit 23656bbb72

View file

@ -523,13 +523,14 @@ GstBufferPool *
gst_v4l2_buffer_pool_new (GstV4l2Object * obj) gst_v4l2_buffer_pool_new (GstV4l2Object * obj)
{ {
GstV4l2BufferPool *pool; GstV4l2BufferPool *pool;
gint fd;
pool = (GstV4l2BufferPool *) g_object_new (GST_TYPE_V4L2_BUFFER_POOL, NULL); fd = v4l2_dup (obj->video_fd);
if (fd < 0)
pool->video_fd = v4l2_dup (obj->video_fd);
if (pool->video_fd < 0)
goto dup_failed; goto dup_failed;
pool = (GstV4l2BufferPool *) g_object_new (GST_TYPE_V4L2_BUFFER_POOL, NULL);
pool->video_fd = fd;
pool->obj = obj; pool->obj = obj;
return GST_BUFFER_POOL_CAST (pool); return GST_BUFFER_POOL_CAST (pool);
@ -537,9 +538,7 @@ gst_v4l2_buffer_pool_new (GstV4l2Object * obj)
/* ERRORS */ /* ERRORS */
dup_failed: dup_failed:
{ {
gint errnosave = errno; GST_DEBUG ("failed to dup fd %d (%s)", errno, g_strerror (errno));
gst_object_unref (pool);
errno = errnosave;
return NULL; return NULL;
} }
} }