Upgrade to thud
[AGL/meta-agl-devel.git] / meta-gstrecorder-rcar-gen3 / recipes-graphics / wayland / weston / 0005-gst-record-Add-omx-pool-retries.patch
1 gst-record: Add retry on omx buffer pool query
2
3 The omx encoder plugin seems to sometimes not be ready immediately to
4 answer the pad query to get the buffer pool, add a retry loop with a
5 slight delay between attempts to avoid failing.
6
7 Upstream-Status: Inappropriate [bugfix]
8
9 Signed-off-by: Scott Murray <scott.murray@konsulko.com>
10
11 diff --git a/libweston/gst-recorder.c b/libweston/gst-recorder.c
12 index 7dafd956..9c29d04b 100644
13 --- a/libweston/gst-recorder.c
14 +++ b/libweston/gst-recorder.c
15 @@ -833,6 +833,7 @@ static int
16  gst_recorder_find_omx_pool(struct gst_recorder *r)
17  {
18         int ret = 0;
19 +       int i;
20         GstCaps *caps;
21         GstQuery *query;
22         GstBufferPool *pool;
23 @@ -853,14 +854,24 @@ gst_recorder_find_omx_pool(struct gst_recorder *r)
24         /* find a pool for the negotiated caps now */
25         query = gst_query_new_allocation (caps, TRUE);
26  
27 -       if (!gst_pad_peer_query (r->appsrc_pad, query)) {
28 -               /* query failed, not a problem, we use the query defaults */
29 -               weston_log("allocation query failed\n");
30 +       /*
31 +        * The omx plugin seems to not always be ready to respond to queries
32 +        * immediately, try a few times with a delay to avoid failures.
33 +        */
34 +       for (i = 0; i < 5; i++) {
35 +               usleep(100000);
36 +               if (gst_pad_peer_query (r->appsrc_pad, query)) {
37 +                       break;
38 +               } else {
39 +                       weston_log("allocation query attempt %d failed\n", i + 1);
40 +               }
41 +       }
42 +       if (i == 5) {
43                 ret = -1;
44                 goto err;
45         }
46  
47 -       weston_log("goot %d pools\n", gst_query_get_n_allocation_pools (query));
48 +       weston_log("got %d pools\n", gst_query_get_n_allocation_pools (query));
49         if (gst_query_get_n_allocation_pools (query) > 0) {
50                 /* we got configuration from our peer, parse them */
51                 gst_query_parse_nth_allocation_pool (query, 0, &pool, &size, &min, &max);