mirror of
https://gitlab.freedesktop.org/gstreamer/gstreamer.git
synced 2025-04-26 05:16:13 +00:00
va: allocator: broadcast when flushing
This patch handles when the bufferpool request a new buffer while flushing. Also fixes the usage of g_cond_wait(), which demands to be used inside a loop to avoid spurious wakeups. Part-of: <https://gitlab.freedesktop.org/gstreamer/gst-plugins-bad/-/merge_requests/1815>
This commit is contained in:
parent
72ab56c376
commit
8fc50891b1
2 changed files with 24 additions and 5 deletions
|
@ -407,6 +407,8 @@ struct _GstVaDmabufAllocator
|
||||||
|
|
||||||
GstVideoInfo info;
|
GstVideoInfo info;
|
||||||
guint usage_hint;
|
guint usage_hint;
|
||||||
|
|
||||||
|
gboolean flushing;
|
||||||
};
|
};
|
||||||
|
|
||||||
#define gst_va_dmabuf_allocator_parent_class dmabuf_parent_class
|
#define gst_va_dmabuf_allocator_parent_class dmabuf_parent_class
|
||||||
|
@ -659,9 +661,14 @@ gst_va_dmabuf_allocator_prepare_buffer (GstAllocator * allocator,
|
||||||
GST_OBJECT_LOCK (self);
|
GST_OBJECT_LOCK (self);
|
||||||
|
|
||||||
/* if available mems, use them */
|
/* if available mems, use them */
|
||||||
if (gst_atomic_queue_length (self->available_mems) == 0)
|
while (gst_atomic_queue_length (self->available_mems) == 0 && !self->flushing)
|
||||||
g_cond_wait (&self->buffer_cond, GST_OBJECT_GET_LOCK (self));
|
g_cond_wait (&self->buffer_cond, GST_OBJECT_GET_LOCK (self));
|
||||||
|
|
||||||
|
if (self->flushing) {
|
||||||
|
GST_OBJECT_UNLOCK (self);
|
||||||
|
return FALSE;
|
||||||
|
}
|
||||||
|
|
||||||
mem[0] = gst_atomic_queue_pop (self->available_mems);
|
mem[0] = gst_atomic_queue_pop (self->available_mems);
|
||||||
surface = gst_va_memory_get_surface (mem[0]);
|
surface = gst_va_memory_get_surface (mem[0]);
|
||||||
|
|
||||||
|
@ -696,9 +703,11 @@ gst_va_dmabuf_allocator_flush (GstAllocator * allocator)
|
||||||
GstVaDmabufAllocator *self = GST_VA_DMABUF_ALLOCATOR (allocator);
|
GstVaDmabufAllocator *self = GST_VA_DMABUF_ALLOCATOR (allocator);
|
||||||
|
|
||||||
GST_OBJECT_LOCK (self);
|
GST_OBJECT_LOCK (self);
|
||||||
|
self->flushing = TRUE;
|
||||||
_available_mems_flush (self->display, self->available_mems,
|
_available_mems_flush (self->display, self->available_mems,
|
||||||
&self->surface_count);
|
&self->surface_count);
|
||||||
g_cond_signal (&self->buffer_cond);
|
self->flushing = FALSE;
|
||||||
|
g_cond_broadcast (&self->buffer_cond);
|
||||||
GST_OBJECT_UNLOCK (self);
|
GST_OBJECT_UNLOCK (self);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -862,6 +871,8 @@ struct _GstVaAllocator
|
||||||
|
|
||||||
GstVideoInfo info;
|
GstVideoInfo info;
|
||||||
guint usage_hint;
|
guint usage_hint;
|
||||||
|
|
||||||
|
gboolean flushing;
|
||||||
};
|
};
|
||||||
|
|
||||||
typedef struct _GstVaMemory GstVaMemory;
|
typedef struct _GstVaMemory GstVaMemory;
|
||||||
|
@ -1293,8 +1304,14 @@ gst_va_allocator_prepare_buffer (GstAllocator * allocator, GstBuffer * buffer)
|
||||||
VASurfaceID surface;
|
VASurfaceID surface;
|
||||||
|
|
||||||
GST_OBJECT_LOCK (self);
|
GST_OBJECT_LOCK (self);
|
||||||
|
|
||||||
|
if (self->flushing) {
|
||||||
|
GST_OBJECT_UNLOCK (self);
|
||||||
|
return FALSE;
|
||||||
|
}
|
||||||
|
|
||||||
/* if available mems, use them */
|
/* if available mems, use them */
|
||||||
if (gst_atomic_queue_length (self->available_mems) == 0)
|
while (gst_atomic_queue_length (self->available_mems) == 0)
|
||||||
g_cond_wait (&self->buffer_cond, GST_OBJECT_GET_LOCK (self));
|
g_cond_wait (&self->buffer_cond, GST_OBJECT_GET_LOCK (self));
|
||||||
|
|
||||||
mem = gst_atomic_queue_pop (self->available_mems);
|
mem = gst_atomic_queue_pop (self->available_mems);
|
||||||
|
@ -1315,9 +1332,11 @@ gst_va_allocator_flush (GstAllocator * allocator)
|
||||||
GstVaAllocator *self = GST_VA_ALLOCATOR (allocator);
|
GstVaAllocator *self = GST_VA_ALLOCATOR (allocator);
|
||||||
|
|
||||||
GST_OBJECT_LOCK (self);
|
GST_OBJECT_LOCK (self);
|
||||||
|
self->flushing = TRUE;
|
||||||
_available_mems_flush (self->display, self->available_mems,
|
_available_mems_flush (self->display, self->available_mems,
|
||||||
&self->surface_count);
|
&self->surface_count);
|
||||||
g_cond_signal (&self->buffer_cond);
|
self->flushing = FALSE;
|
||||||
|
g_cond_broadcast (&self->buffer_cond);
|
||||||
GST_OBJECT_UNLOCK (self);
|
GST_OBJECT_UNLOCK (self);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -315,7 +315,7 @@ gst_va_pool_acquire_buffer (GstBufferPool * pool, GstBuffer ** buffer,
|
||||||
}
|
}
|
||||||
|
|
||||||
gst_buffer_replace (buffer, NULL);
|
gst_buffer_replace (buffer, NULL);
|
||||||
return GST_FLOW_ERROR;
|
return GST_FLOW_FLUSHING;
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
|
|
Loading…
Reference in a new issue