[PATCH 2/2] base: also use buffer durations

2 views
Skip to first unread message

Felipe Contreras

unread,
Dec 13, 2010, 2:20:27 PM12/13/10
to gst-dsp, Mark Nauwelaerts, Felipe Contreras, Víctor M. Jáquez L.
From: Felipe Contreras <felipe.c...@gmail.com>

Based on Mark Nauwelaerts's patch, reported by Víctor Jáquez.

Cc: Mark Nauwelaerts <mark.nau...@collabora.co.uk>
Cc: Víctor M. Jáquez L. <vja...@igalia.com>
Signed-off-by: Felipe Contreras <felipe.c...@gmail.com>
---
gstdspbase.c | 2 ++
gstdspbase.h | 1 +
2 files changed, 3 insertions(+), 0 deletions(-)

diff --git a/gstdspbase.c b/gstdspbase.c
index 6139972..53e3c37 100644
--- a/gstdspbase.c
+++ b/gstdspbase.c
@@ -459,6 +459,7 @@ output_loop(gpointer data)

g_mutex_lock(self->ts_mutex);
GST_BUFFER_TIMESTAMP(out_buf) = self->ts_array[self->ts_out_pos].time;
+ GST_BUFFER_DURATION(out_buf) = self->ts_array[self->ts_out_pos].duration;
self->ts_out_pos = (self->ts_out_pos + 1) % ARRAY_SIZE(self->ts_array);
self->ts_push_pos = self->ts_out_pos;
self->ts_count--;
@@ -1123,6 +1124,7 @@ pad_chain(GstPad *pad,

g_mutex_lock(self->ts_mutex);
self->ts_array[self->ts_in_pos].time = GST_BUFFER_TIMESTAMP(buf);
+ self->ts_array[self->ts_in_pos].duration = GST_BUFFER_DURATION(buf);
self->ts_in_pos = (self->ts_in_pos + 1) % ARRAY_SIZE(self->ts_array);
self->ts_count++;
g_mutex_unlock(self->ts_mutex);
diff --git a/gstdspbase.h b/gstdspbase.h
index 6bc31f2..79d9a9e 100644
--- a/gstdspbase.h
+++ b/gstdspbase.h
@@ -60,6 +60,7 @@ struct td_codec {

struct ts_item {
GstClockTime time;
+ GstClockTime duration;
GstEvent *event;
};

--
1.7.3.2

Felipe Contreras

unread,
Dec 13, 2010, 2:20:26 PM12/13/10
to gst-dsp, Mark Nauwelaerts, Felipe Contreras
Signed-off-by: Felipe Contreras <felipe.c...@nokia.com>
---
gstdspbase.c | 20 ++++++++++----------
gstdspbase.h | 8 ++++++--
2 files changed, 16 insertions(+), 12 deletions(-)

diff --git a/gstdspbase.c b/gstdspbase.c
index 953328a..6139972 100644
--- a/gstdspbase.c
+++ b/gstdspbase.c
@@ -361,8 +361,8 @@ output_loop(gpointer data)

/* first clear pending events */
g_mutex_lock(self->ts_mutex);
- while ((event = self->event_array[self->ts_out_pos])) {
- self->event_array[self->ts_out_pos] = NULL;
+ while ((event = self->ts_array[self->ts_out_pos].event)) {
+ self->ts_array[self->ts_out_pos].event = NULL;
flush_buffer = (self->ts_out_pos != self->ts_push_pos);


self->ts_out_pos = (self->ts_out_pos + 1) % ARRAY_SIZE(self->ts_array);

if (G_LIKELY(!flush_buffer)) {
@@ -396,7 +396,7 @@ output_loop(gpointer data)
if (G_UNLIKELY(flush_buffer)) {
g_mutex_lock(self->ts_mutex);
pr_debug(self, "ignored flushed output buffer for %" GST_TIME_FORMAT,
- GST_TIME_ARGS((self->ts_array[self->ts_out_pos])));
+ GST_TIME_ARGS((self->ts_array[self->ts_out_pos].time)));
self->ts_count--;


self->ts_out_pos = (self->ts_out_pos + 1) % ARRAY_SIZE(self->ts_array);

g_mutex_unlock(self->ts_mutex);
@@ -458,7 +458,7 @@ output_loop(gpointer data)
GST_BUFFER_FLAGS(out_buf) |= GST_BUFFER_FLAG_DELTA_UNIT;

g_mutex_lock(self->ts_mutex);
- GST_BUFFER_TIMESTAMP(out_buf) = self->ts_array[self->ts_out_pos];
+ GST_BUFFER_TIMESTAMP(out_buf) = self->ts_array[self->ts_out_pos].time;


self->ts_out_pos = (self->ts_out_pos + 1) % ARRAY_SIZE(self->ts_array);
self->ts_push_pos = self->ts_out_pos;
self->ts_count--;

@@ -769,10 +769,10 @@ _dsp_stop(GstDspBase *self)
}
}

- for (i = 0; i < ARRAY_SIZE(self->event_array); i++) {
- if (self->event_array[i]) {
- gst_event_unref(self->event_array[i]);
- self->event_array[i] = NULL;
+ for (i = 0; i < ARRAY_SIZE(self->ts_array); i++) {
+ if (self->ts_array[i].event) {
+ gst_event_unref(self->ts_array[i].event);
+ self->ts_array[i].event = NULL;
}
}
self->ts_in_pos = self->ts_out_pos = self->ts_push_pos = 0;
@@ -1122,7 +1122,7 @@ pad_chain(GstPad *pad,
}

g_mutex_lock(self->ts_mutex);
- self->ts_array[self->ts_in_pos] = GST_BUFFER_TIMESTAMP(buf);
+ self->ts_array[self->ts_in_pos].time = GST_BUFFER_TIMESTAMP(buf);


self->ts_in_pos = (self->ts_in_pos + 1) % ARRAY_SIZE(self->ts_array);
self->ts_count++;
g_mutex_unlock(self->ts_mutex);

@@ -1198,7 +1198,7 @@ sink_event(GstDspBase *self,
case GST_EVENT_NEWSEGMENT:
g_mutex_lock(self->ts_mutex);
pr_debug(self, "storing event");
- self->event_array[self->ts_in_pos] = event;
+ self->ts_array[self->ts_in_pos].event = event;


self->ts_in_pos = (self->ts_in_pos + 1) % ARRAY_SIZE(self->ts_array);

g_mutex_unlock(self->ts_mutex);
break;
diff --git a/gstdspbase.h b/gstdspbase.h
index 829b5b1..6bc31f2 100644
--- a/gstdspbase.h
+++ b/gstdspbase.h
@@ -58,6 +58,11 @@ struct td_codec {
void (*send_params)(GstDspBase *base, struct dsp_node *node);
};

+struct ts_item {
+ GstClockTime time;
+ GstEvent *event;
+};
+
struct _GstDspBase {
GstElement element;

@@ -78,8 +83,7 @@ struct _GstDspBase {

du_port_t *ports[2];
dmm_buffer_t *alg_ctrl;
- GstClockTime ts_array[20];
- GstEvent *event_array[20];
+ struct ts_item ts_array[20];
guint ts_in_pos, ts_out_pos, ts_push_pos;
GMutex *ts_mutex;
gulong ts_count;
--
1.7.3.2

Víctor M. Jáquez L.

unread,
Dec 16, 2010, 7:47:56 AM12/16/10
to Felipe Contreras, gst-dsp, Mark Nauwelaerts
On Mon, Dec 13, 2010 at 09:20:25PM +0200, Felipe Contreras wrote:
> Hi,
>
> These patches reorganize ts_array so that adding buffer durations is
> straightforward.

It works in my setup. Thanks!

vmjl

>
> Felipe Contreras (2):
> base: refactor ts_array/event_array
> base: also use buffer durations
>
> gstdspbase.c | 22 ++++++++++++----------
> gstdspbase.h | 9 +++++++--
> 2 files changed, 19 insertions(+), 12 deletions(-)

Reply all
Reply to author
Forward
0 new messages