From patchwork Mon Jul 15 14:17:37 2013 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Benjamin Gaignard X-Patchwork-Id: 18359 Return-Path: X-Original-To: linaro@patches.linaro.org Delivered-To: linaro@patches.linaro.org Received: from mail-vc0-f199.google.com (mail-vc0-f199.google.com [209.85.220.199]) by ip-10-151-82-157.ec2.internal (Postfix) with ESMTPS id DDCB525E13 for ; Mon, 15 Jul 2013 14:17:39 +0000 (UTC) Received: by mail-vc0-f199.google.com with SMTP id gf11sf14144022vcb.6 for ; Mon, 15 Jul 2013 07:17:39 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20120113; h=x-beenthere:x-forwarded-to:x-forwarded-for:delivered-to :mime-version:date:message-id:subject:from:to:cc:x-gm-message-state :x-original-sender:x-original-authentication-results:precedence :mailing-list:list-id:x-google-group-id:list-post:list-help :list-archive:list-unsubscribe:content-type; bh=Ox3WU6f8O6IR5G0fKYmFaBC9PZHeKOBxuB+mLs409lA=; b=KPOO6Ww7lYmMUvzsu3F10shzuglCvwaWa7kGP4QQqrrchHGDhpn2z3lEIkshC2oOKq 5+O4REanqLi4QL2gfxRitIRQKBGqEnuXxZ/K9aQJZLPpCHElgxvr5lSZjFlBKjRDKxWJ hqyHSdGKcGn+Jm6tXXRxhpWbANyJ3AAl/kTRfx3D+5t0795r2iEsl+TIIY0HsDRQ5bAK rxeXcmEqiDHx8JSo7rg3eqRAz+Pq08ltwaEI+hJPowtiXAMXct0a7BUtZb5NiHT1n5PG xBX1whH9EBX/xgfk4ME7oKtZohNg8JNJ9d2E+tLkc2VpipgP0jZ6MZC++PUKmaVUoRzD 0ojw== X-Received: by 10.236.170.41 with SMTP id o29mr28148315yhl.53.1373897859548; Mon, 15 Jul 2013 07:17:39 -0700 (PDT) X-BeenThere: patchwork-forward@linaro.org Received: by 10.49.122.74 with SMTP id lq10ls4500663qeb.30.gmail; Mon, 15 Jul 2013 07:17:39 -0700 (PDT) X-Received: by 10.220.207.72 with SMTP id fx8mr27596942vcb.30.1373897859246; Mon, 15 Jul 2013 07:17:39 -0700 (PDT) Received: from mail-vc0-f170.google.com (mail-vc0-f170.google.com [209.85.220.170]) by mx.google.com with ESMTPS id i7si9001059vdv.99.2013.07.15.07.17.39 for (version=TLSv1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Mon, 15 Jul 2013 07:17:39 -0700 (PDT) Received-SPF: neutral (google.com: 209.85.220.170 is neither permitted nor denied by best guess record for domain of patch+caf_=patchwork-forward=linaro.org@linaro.org) client-ip=209.85.220.170; Received: by mail-vc0-f170.google.com with SMTP id hf12so9340923vcb.15 for ; Mon, 15 Jul 2013 07:17:39 -0700 (PDT) X-Received: by 10.58.187.4 with SMTP id fo4mr28588387vec.55.1373897859145; Mon, 15 Jul 2013 07:17:39 -0700 (PDT) X-Forwarded-To: patchwork-forward@linaro.org X-Forwarded-For: patch@linaro.org patchwork-forward@linaro.org Delivered-To: patches@linaro.org Received: by 10.220.149.77 with SMTP id s13csp71638vcv; Mon, 15 Jul 2013 07:17:38 -0700 (PDT) X-Received: by 10.152.4.163 with SMTP id l3mr24944696lal.60.1373897858049; Mon, 15 Jul 2013 07:17:38 -0700 (PDT) Received: from mail-lb0-f181.google.com (mail-lb0-f181.google.com [209.85.217.181]) by mx.google.com with ESMTPS id q6si20812869lbp.38.2013.07.15.07.17.37 for (version=TLSv1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Mon, 15 Jul 2013 07:17:38 -0700 (PDT) Received-SPF: neutral (google.com: 209.85.217.181 is neither permitted nor denied by best guess record for domain of benjamin.gaignard@linaro.org) client-ip=209.85.217.181; Received: by mail-lb0-f181.google.com with SMTP id w10so9459824lbi.12 for ; Mon, 15 Jul 2013 07:17:37 -0700 (PDT) MIME-Version: 1.0 X-Received: by 10.112.236.33 with SMTP id ur1mr24574105lbc.13.1373897857201; Mon, 15 Jul 2013 07:17:37 -0700 (PDT) Received: by 10.114.0.176 with HTTP; Mon, 15 Jul 2013 07:17:37 -0700 (PDT) Date: Mon, 15 Jul 2013 16:17:37 +0200 Message-ID: Subject: [PATCH] allocators: dmabuf: allow testing allocator type From: Benjamin Gaignard To: Benjamin Gaignard Cc: Patch Tracking X-Gm-Message-State: ALoCoQl1r3iczM2Z+NtrUmuLJ/qa00fpdmndvmRrfOPYsSl7b6maBHw5cUtrNFn2kf0Ox6rNtKco X-Original-Sender: benjamin.gaignard@linaro.org X-Original-Authentication-Results: mx.google.com; spf=neutral (google.com: 209.85.220.170 is neither permitted nor denied by best guess record for domain of patch+caf_=patchwork-forward=linaro.org@linaro.org) smtp.mail=patch+caf_=patchwork-forward=linaro.org@linaro.org Precedence: list Mailing-list: list patchwork-forward@linaro.org; contact patchwork-forward+owners@linaro.org List-ID: X-Google-Group-Id: 836684582541 List-Post: , List-Help: , List-Archive: List-Unsubscribe: , >From eea20304ca6836c400df703a2be26fd01bccb52d Mon Sep 17 00:00:00 2001 From: Benjamin Gaignard Date: Mon, 15 Jul 2013 15:23:17 +0200 Subject: [PATCH] allocators: dmabuf: allow testing allocator type In decide_allocation function some element may when to test the proposed allocator. For example like this: if (gst_query_get_n_allocation_params (query) > 0) { GstAllocator * allocator; GstAllocationParams params; gst_query_parse_nth_allocation_param (query, 0, &allocator, ¶ms); if (g_strcmp0(allocator->mem_type, GST_ALLOCATOR_DMABUF) == 0) GST_DEBUG("got dmabuf allocator"); else GST_DEBUG("got an other allocator"); } Signed-off-by: Benjamin Gaignard --- gst-libs/gst/allocators/gstdmabuf.c | 14 +++++--------- gst-libs/gst/allocators/gstdmabuf.h | 5 +++++ 2 files changed, 10 insertions(+), 9 deletions(-) fd, gsize size); @@ -31,4 +35,5 @@ gint gst_dmabuf_memory_get_fd (GstMemory * mem); gboolean gst_is_dmabuf_memory (GstMemory * mem); +G_END_DECLS #endif /* __GST_DMABUF_H__ */ diff --git a/gst-libs/gst/allocators/gstdmabuf.c b/gst-libs/gst/allocators/gstdmabuf.c index 4a95f47..1c8abc4 100644 --- a/gst-libs/gst/allocators/gstdmabuf.c +++ b/gst-libs/gst/allocators/gstdmabuf.c @@ -56,8 +56,6 @@ typedef struct GMutex lock; } GstDmaBufMemory; -#define ALLOCATOR_NAME "dmabuf" - GST_DEBUG_CATEGORY_STATIC (dmabuf_debug); #define GST_CAT_DEFAULT dmabuf_debug @@ -199,7 +197,7 @@ dmabuf_mem_allocator_init (GstDmaBufAllocator * allocator) { GstAllocator *alloc = GST_ALLOCATOR_CAST (allocator); - alloc->mem_type = ALLOCATOR_NAME; + alloc->mem_type = GST_ALLOCATOR_DMABUF; alloc->mem_map = gst_dmabuf_mem_map; alloc->mem_unmap = gst_dmabuf_mem_unmap; alloc->mem_share = gst_dmabuf_mem_share; @@ -213,7 +211,7 @@ gst_dmabuf_mem_init (void) { GstAllocator *allocator = g_object_new (dmabuf_mem_allocator_get_type (), NULL); - gst_allocator_register (ALLOCATOR_NAME, allocator); + gst_allocator_register (GST_ALLOCATOR_DMABUF, allocator); GST_DEBUG_CATEGORY_INIT (dmabuf_debug, "dmabuf", 0, "dmabuf memory"); } @@ -237,9 +235,9 @@ gst_dmabuf_allocator_obtain (void) g_once (&dmabuf_allocator_once, (GThreadFunc) gst_dmabuf_mem_init, NULL); - allocator = gst_allocator_find (ALLOCATOR_NAME); + allocator = gst_allocator_find (GST_ALLOCATOR_DMABUF); if (!allocator) - GST_WARNING ("No allocator named %s found", ALLOCATOR_NAME); + GST_WARNING ("No allocator named %s found", GST_ALLOCATOR_DMABUF); return allocator; } @@ -319,9 +317,7 @@ gst_dmabuf_memory_get_fd (GstMemory * mem) gboolean gst_is_dmabuf_memory (GstMemory * mem) { - g_return_val_if_fail (mem != NULL, FALSE); - - return g_strcmp0 (mem->allocator->mem_type, ALLOCATOR_NAME) == 0; + return gst_memory_is_type (mem, GST_ALLOCATOR_DMABUF); } #else /* !HAVE_MMAP */ diff --git a/gst-libs/gst/allocators/gstdmabuf.h b/gst-libs/gst/allocators/gstdmabuf.h index 1db233c..a4eca2a 100644 --- a/gst-libs/gst/allocators/gstdmabuf.h +++ b/gst-libs/gst/allocators/gstdmabuf.h @@ -23,6 +23,10 @@ #include +G_BEGIN_DECLS + +#define GST_ALLOCATOR_DMABUF "dmabuf" + GstAllocator * gst_dmabuf_allocator_obtain (void); GstMemory * gst_dmabuf_allocator_alloc (GstAllocator * allocator, gint