Skip to content

Commit

Permalink
Refactor into setup()
Browse files Browse the repository at this point in the history
So that buffer_alloc an use it as well.

Signed-off-by: Felipe Contreras <felipe.contreras@gmail.com>
  • Loading branch information
felipec committed Sep 19, 2010
1 parent 5154ab7 commit bb1e62b
Showing 1 changed file with 40 additions and 32 deletions.
72 changes: 40 additions & 32 deletions omapfb.c
Original file line number Original file line Diff line number Diff line change
Expand Up @@ -154,40 +154,9 @@ static struct page *get_page(struct gst_omapfb_sink *self)
return page; return page;
} }


static GstFlowReturn
buffer_alloc(GstBaseSink *base, guint64 offset, guint size, GstCaps *caps, GstBuffer **buf)
{
struct gst_omapfb_sink *self = (struct gst_omapfb_sink *)base;
GstBuffer *buffer;
struct page *page;

if (!self->enabled)
goto missing;

page = get_page(self);
if (!page)
goto missing;

buffer = gst_buffer_new();
GST_BUFFER_DATA(buffer) = page->buf;
GST_BUFFER_SIZE(buffer) = size;
gst_buffer_set_caps(buffer, caps);

*buf = buffer;

if (page == self->old_page)
ioctl(self->overlay_fd, OMAPFB_WAITFORVSYNC);

return GST_FLOW_OK;
missing:
*buf = NULL;
return GST_FLOW_OK;
}

static gboolean static gboolean
setcaps(GstBaseSink *base, GstCaps *caps) setup(struct gst_omapfb_sink *self, GstCaps *caps)
{ {
struct gst_omapfb_sink *self = (struct gst_omapfb_sink *)base;
GstStructure *structure; GstStructure *structure;
int width, height; int width, height;
int update_mode; int update_mode;
Expand Down Expand Up @@ -291,6 +260,45 @@ setcaps(GstBaseSink *base, GstCaps *caps)
return true; return true;
} }


static GstFlowReturn
buffer_alloc(GstBaseSink *base, guint64 offset, guint size, GstCaps *caps, GstBuffer **buf)
{
struct gst_omapfb_sink *self = (struct gst_omapfb_sink *)base;
GstBuffer *buffer;
struct page *page;

if (!self->enabled)
goto missing;

page = get_page(self);
if (!page)
goto missing;

buffer = gst_buffer_new();
GST_BUFFER_DATA(buffer) = page->buf;
GST_BUFFER_SIZE(buffer) = size;
gst_buffer_set_caps(buffer, caps);

*buf = buffer;

if (page == self->old_page)
ioctl(self->overlay_fd, OMAPFB_WAITFORVSYNC);

return GST_FLOW_OK;
missing:
*buf = NULL;
return GST_FLOW_OK;
}

static gboolean
setcaps(GstBaseSink *base, GstCaps *caps)
{
struct gst_omapfb_sink *self = (struct gst_omapfb_sink *)base;
if (self->enabled)
return true;
return setup(self, caps);
}

static gboolean static gboolean
start(GstBaseSink *base) start(GstBaseSink *base)
{ {
Expand Down

0 comments on commit bb1e62b

Please sign in to comment.