mirror of
https://gitlab.freedesktop.org/gstreamer/gstreamer.git
synced 2024-11-27 04:01:08 +00:00
gst/mixmatrix/mixmatrix.c: create a NULL-initialized array of pads, so we don't think they exist already. (fixes #143...
Original commit message from CVS: reviewed by Benjamin Otte <otte@gnome.org> * gst/mixmatrix/mixmatrix.c: (gst_mixmatrix_init): create a NULL-initialized array of pads, so we don't think they exist already. (fixes #143130)
This commit is contained in:
parent
2fa9ba3892
commit
1a0ceb7f99
2 changed files with 60 additions and 43 deletions
15
ChangeLog
15
ChangeLog
|
@ -1,3 +1,18 @@
|
||||||
|
2004-06-07 Tim-Philipp Müller <t.i.m@zen.co.uk>
|
||||||
|
|
||||||
|
reviewed by Benjamin Otte <otte@gnome.org>
|
||||||
|
|
||||||
|
* gst/mixmatrix/mixmatrix.c: (gst_mixmatrix_init):
|
||||||
|
create a NULL-initialized array of pads, so we don't think they
|
||||||
|
exist already. (fixes #143130)
|
||||||
|
|
||||||
|
2004-06-07 Benjamin Otte <otte@gnome.org>
|
||||||
|
|
||||||
|
* gst/mixmatrix/mixmatrix.c: (gst_mixmatrix_init),
|
||||||
|
(mixmatrix_resize), (gst_mixmatrix_set_all_caps),
|
||||||
|
(gst_mixmatrix_request_new_pad), (gst_mixmatrix_loop):
|
||||||
|
don't use // coments
|
||||||
|
|
||||||
2004-06-07 Benjamin Otte <otte@gnome.org>
|
2004-06-07 Benjamin Otte <otte@gnome.org>
|
||||||
|
|
||||||
* ext/alsa/gstalsa.c: (gst_alsa_samples_to_timestamp):
|
* ext/alsa/gstalsa.c: (gst_alsa_samples_to_timestamp):
|
||||||
|
|
|
@ -230,20 +230,20 @@ gst_mixmatrix_init (GstMixMatrix * mix)
|
||||||
mix->grpsize = 8;
|
mix->grpsize = 8;
|
||||||
mix->outsize = 1024;
|
mix->outsize = 1024;
|
||||||
|
|
||||||
// start with zero pads
|
/* start with zero pads */
|
||||||
mix->sinkpadalloc = mix->grpsize;
|
mix->sinkpadalloc = mix->grpsize;
|
||||||
mix->srcpadalloc = mix->grpsize;
|
mix->srcpadalloc = mix->grpsize;
|
||||||
|
|
||||||
// allocate the pads
|
/* allocate the pads */
|
||||||
mix->sinkpads = g_new (GstPad *, mix->sinkpadalloc);
|
mix->sinkpads = g_new0 (GstPad *, mix->sinkpadalloc);
|
||||||
mix->sinkbs = g_new (GstByteStream *, mix->sinkpadalloc);
|
mix->sinkbs = g_new0 (GstByteStream *, mix->sinkpadalloc);
|
||||||
|
|
||||||
mix->srcpads = g_new (GstPad *, mix->srcpadalloc);
|
mix->srcpads = g_new0 (GstPad *, mix->srcpadalloc);
|
||||||
|
|
||||||
// allocate a similarly sized matrix
|
/* allocate a similarly sized matrix */
|
||||||
mix->matrix = mixmatrix_alloc_matrix (mix->sinkpadalloc, mix->srcpadalloc);
|
mix->matrix = mixmatrix_alloc_matrix (mix->sinkpadalloc, mix->srcpadalloc);
|
||||||
|
|
||||||
// set the loop function that does all the work
|
/* set the loop function that does all the work */
|
||||||
gst_element_set_loop_function (GST_ELEMENT (mix), gst_mixmatrix_loop);
|
gst_element_set_loop_function (GST_ELEMENT (mix), gst_mixmatrix_loop);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -269,7 +269,7 @@ mixmatrix_resize (GstMixMatrix * mix, int sinkpads, int srcpads)
|
||||||
|
|
||||||
GST_DEBUG ("mixmatrix: resizing matrix!!!!\n");
|
GST_DEBUG ("mixmatrix: resizing matrix!!!!\n");
|
||||||
|
|
||||||
// check the sinkpads list
|
/* check the sinkpads list */
|
||||||
if (sinkresize) {
|
if (sinkresize) {
|
||||||
mix->sinkpads =
|
mix->sinkpads =
|
||||||
(GstPad **) grow_ptrlist ((void **) mix->sinkpads, mix->sinkpadalloc,
|
(GstPad **) grow_ptrlist ((void **) mix->sinkpads, mix->sinkpadalloc,
|
||||||
|
@ -278,29 +278,29 @@ mixmatrix_resize (GstMixMatrix * mix, int sinkpads, int srcpads)
|
||||||
(GstByteStream **) grow_ptrlist ((void **) mix->sinkbs,
|
(GstByteStream **) grow_ptrlist ((void **) mix->sinkbs,
|
||||||
mix->sinkpadalloc, sinkpads);
|
mix->sinkpadalloc, sinkpads);
|
||||||
}
|
}
|
||||||
// check the srcpads list
|
/* check the srcpads list */
|
||||||
if (srcresize) {
|
if (srcresize) {
|
||||||
mix->srcpads =
|
mix->srcpads =
|
||||||
(GstPad **) grow_ptrlist ((void **) mix->srcpads, mix->srcpadalloc,
|
(GstPad **) grow_ptrlist ((void **) mix->srcpads, mix->srcpadalloc,
|
||||||
srcpads);
|
srcpads);
|
||||||
}
|
}
|
||||||
// now resize the matrix if either has changed
|
/* now resize the matrix if either has changed */
|
||||||
if (sinkresize || srcresize) {
|
if (sinkresize || srcresize) {
|
||||||
// allocate the new matrix
|
/* allocate the new matrix */
|
||||||
newmatrix = mixmatrix_alloc_matrix (sinkpads, srcpads);
|
newmatrix = mixmatrix_alloc_matrix (sinkpads, srcpads);
|
||||||
// if only the srcpad count changed (y axis), we can just copy
|
/* if only the srcpad count changed (y axis), we can just copy */
|
||||||
if (!sinkresize) {
|
if (!sinkresize) {
|
||||||
memcpy (newmatrix, mix->matrix, sizeof (gfloat *) * sinkpads);
|
memcpy (newmatrix, mix->matrix, sizeof (gfloat *) * sinkpads);
|
||||||
// otherwise we have to copy line by line
|
/* otherwise we have to copy line by line */
|
||||||
} else {
|
} else {
|
||||||
for (i = 0; i < mix->srcpadalloc; i++)
|
for (i = 0; i < mix->srcpadalloc; i++)
|
||||||
memcpy (newmatrix[i], mix->matrix[i],
|
memcpy (newmatrix[i], mix->matrix[i],
|
||||||
sizeof (gfloat) * mix->srcpadalloc);
|
sizeof (gfloat) * mix->srcpadalloc);
|
||||||
}
|
}
|
||||||
|
|
||||||
// would signal here!
|
/* would signal here! */
|
||||||
|
|
||||||
// free old matrix and replace it
|
/* free old matrix and replace it */
|
||||||
mixmatrix_free_matrix (mix->matrix, mix->sinkpadalloc);
|
mixmatrix_free_matrix (mix->matrix, mix->sinkpadalloc);
|
||||||
mix->matrix = newmatrix;
|
mix->matrix = newmatrix;
|
||||||
}
|
}
|
||||||
|
@ -309,31 +309,33 @@ mixmatrix_resize (GstMixMatrix * mix, int sinkpads, int srcpads)
|
||||||
mix->srcpadalloc = srcpads;
|
mix->srcpadalloc = srcpads;
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
#if 0
|
||||||
static gboolean
|
static gboolean
|
||||||
gst_mixmatrix_set_all_caps (GstMixMatrix *mix)
|
gst_mixmatrix_set_all_caps (GstMixMatrix * mix)
|
||||||
{
|
{
|
||||||
int i;
|
int i;
|
||||||
|
|
||||||
// sink pads
|
/* sink pads */
|
||||||
for (i=0;i<mix->sinkpadalloc;i++) {
|
for (i = 0; i < mix->sinkpadalloc; i++) {
|
||||||
if (mix->sinkpads[i]) {
|
if (mix->sinkpads[i]) {
|
||||||
if (GST_PAD_CAPS(mix->sinkpads[i]) == NULL)
|
if (GST_PAD_CAPS (mix->sinkpads[i]) == NULL)
|
||||||
if (gst_pad_try_set_caps(mix->sinkpads[i],mix->caps) <= 0) return FALSE;
|
if (gst_pad_try_set_caps (mix->sinkpads[i], mix->caps) <= 0)
|
||||||
|
return FALSE;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// src pads
|
/* src pads */
|
||||||
for (i=0;i<mix->srcpadalloc;i++) {
|
for (i = 0; i < mix->srcpadalloc; i++) {
|
||||||
if (mix->srcpads[i]) {
|
if (mix->srcpads[i]) {
|
||||||
if (GST_PAD_CAPS(mix->srcpads[i]) == NULL)
|
if (GST_PAD_CAPS (mix->srcpads[i]) == NULL)
|
||||||
if (gst_pad_try_set_caps(mix->srcpads[i],mix->caps) <= 0) return FALSE;
|
if (gst_pad_try_set_caps (mix->srcpads[i], mix->caps) <= 0)
|
||||||
|
return FALSE;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return TRUE;
|
return TRUE;
|
||||||
}
|
}
|
||||||
*/
|
#endif
|
||||||
|
|
||||||
static GstPadLinkReturn
|
static GstPadLinkReturn
|
||||||
gst_mixmatrix_connect (GstPad * pad, const GstCaps * caps)
|
gst_mixmatrix_connect (GstPad * pad, const GstCaps * caps)
|
||||||
|
@ -369,13 +371,13 @@ gst_mixmatrix_request_new_pad (GstElement * element, GstPadTemplate * templ,
|
||||||
|
|
||||||
mix = GST_MIXMATRIX (element);
|
mix = GST_MIXMATRIX (element);
|
||||||
|
|
||||||
// figure out if it's a sink pad
|
/* figure out if it's a sink pad */
|
||||||
if (sscanf (name, "sink%d", &padnum)) {
|
if (sscanf (name, "sink%d", &padnum)) {
|
||||||
// check to see if it already exists
|
/* check to see if it already exists */
|
||||||
if (padnum < mix->sinkpadalloc && mix->sinkpads[padnum])
|
if (padnum < mix->sinkpadalloc && mix->sinkpads[padnum])
|
||||||
return mix->sinkpads[padnum];
|
return mix->sinkpads[padnum];
|
||||||
|
|
||||||
// determine if it's bigger than the current size
|
/* determine if it's bigger than the current size */
|
||||||
if (padnum >= mix->sinkpadalloc)
|
if (padnum >= mix->sinkpadalloc)
|
||||||
mixmatrix_resize (mix, ROUND_UP (padnum, mix->grpsize),
|
mixmatrix_resize (mix, ROUND_UP (padnum, mix->grpsize),
|
||||||
mix->sinkpadalloc);
|
mix->sinkpadalloc);
|
||||||
|
@ -385,22 +387,22 @@ gst_mixmatrix_request_new_pad (GstElement * element, GstPadTemplate * templ,
|
||||||
(&mixmatrix_sink_template), name);
|
(&mixmatrix_sink_template), name);
|
||||||
GST_PAD_ELEMENT_PRIVATE (pad) = GINT_TO_POINTER (padnum);
|
GST_PAD_ELEMENT_PRIVATE (pad) = GINT_TO_POINTER (padnum);
|
||||||
gst_element_add_pad (GST_ELEMENT (mix), pad);
|
gst_element_add_pad (GST_ELEMENT (mix), pad);
|
||||||
// g_signal_connect(G_OBJECT(pad), "unlink", G_CALLBACK(sink_unlinked), mix);
|
/* g_signal_connect(G_OBJECT(pad), "unlink", G_CALLBACK(sink_unlinked), mix); */
|
||||||
gst_pad_set_link_function (pad, gst_mixmatrix_connect);
|
gst_pad_set_link_function (pad, gst_mixmatrix_connect);
|
||||||
|
|
||||||
// create a bytestream for it
|
/* create a bytestream for it */
|
||||||
mix->sinkbs[padnum] = gst_bytestream_new (pad);
|
mix->sinkbs[padnum] = gst_bytestream_new (pad);
|
||||||
|
|
||||||
// store away the pad and account for it
|
/* store away the pad and account for it */
|
||||||
mix->sinkpads[padnum] = pad;
|
mix->sinkpads[padnum] = pad;
|
||||||
}
|
}
|
||||||
// or it's a src pad
|
/* or it's a src pad */
|
||||||
else if (sscanf (name, "src%d", &padnum)) {
|
else if (sscanf (name, "src%d", &padnum)) {
|
||||||
// check to see if it already exists
|
/* check to see if it already exists */
|
||||||
if (padnum < mix->srcpadalloc && mix->srcpads[padnum])
|
if (padnum < mix->srcpadalloc && mix->srcpads[padnum])
|
||||||
return mix->srcpads[padnum];
|
return mix->srcpads[padnum];
|
||||||
|
|
||||||
// determine if it's bigger than the current size
|
/* determine if it's bigger than the current size */
|
||||||
if (padnum >= mix->srcpadalloc)
|
if (padnum >= mix->srcpadalloc)
|
||||||
mixmatrix_resize (mix, ROUND_UP (padnum, mix->grpsize), mix->srcpadalloc);
|
mixmatrix_resize (mix, ROUND_UP (padnum, mix->grpsize), mix->srcpadalloc);
|
||||||
|
|
||||||
|
@ -409,10 +411,10 @@ gst_mixmatrix_request_new_pad (GstElement * element, GstPadTemplate * templ,
|
||||||
(&mixmatrix_src_template), name);
|
(&mixmatrix_src_template), name);
|
||||||
GST_PAD_ELEMENT_PRIVATE (pad) = GINT_TO_POINTER (padnum);
|
GST_PAD_ELEMENT_PRIVATE (pad) = GINT_TO_POINTER (padnum);
|
||||||
gst_element_add_pad (GST_ELEMENT (mix), pad);
|
gst_element_add_pad (GST_ELEMENT (mix), pad);
|
||||||
// g_signal_connect(G_OBJECT(pad), "unlink", G_CALLBACK(sink_unlinked), mix);
|
/* g_signal_connect(G_OBJECT(pad), "unlink", G_CALLBACK(sink_unlinked), mix); */
|
||||||
//gst_pad_set_link_function (pad, gst_mixmatrix_connect);
|
/* gst_pad_set_link_function (pad, gst_mixmatrix_connect); */
|
||||||
|
|
||||||
// store away the pad and account for it
|
/* store away the pad and account for it */
|
||||||
mix->srcpads[padnum] = pad;
|
mix->srcpads[padnum] = pad;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -431,7 +433,7 @@ gst_mixmatrix_loop (GstElement * element)
|
||||||
int bytesize = sizeof (gfloat) * mix->outsize;
|
int bytesize = sizeof (gfloat) * mix->outsize;
|
||||||
gfloat gain;
|
gfloat gain;
|
||||||
|
|
||||||
// create the output buffers
|
/* create the output buffers */
|
||||||
outbufs = g_new (GstBuffer *, mix->srcpadalloc);
|
outbufs = g_new (GstBuffer *, mix->srcpadalloc);
|
||||||
outfloats = g_new (gfloat *, mix->srcpadalloc);
|
outfloats = g_new (gfloat *, mix->srcpadalloc);
|
||||||
for (i = 0; i < mix->srcpadalloc; i++) {
|
for (i = 0; i < mix->srcpadalloc; i++) {
|
||||||
|
@ -442,14 +444,14 @@ gst_mixmatrix_loop (GstElement * element)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// go through all the input buffers and pull them
|
/* go through all the input buffers and pull them */
|
||||||
inbufs = g_new (GstBuffer *, mix->sinkpadalloc);
|
inbufs = g_new (GstBuffer *, mix->sinkpadalloc);
|
||||||
infloats = g_new (gfloat *, mix->sinkpadalloc);
|
infloats = g_new (gfloat *, mix->sinkpadalloc);
|
||||||
for (i = 0; i < mix->sinkpadalloc; i++) {
|
for (i = 0; i < mix->sinkpadalloc; i++) {
|
||||||
if (mix->sinkpads[i] != NULL) {
|
if (mix->sinkpads[i] != NULL) {
|
||||||
gst_bytestream_read (mix->sinkbs[i], &inbufs[i], bytesize);
|
gst_bytestream_read (mix->sinkbs[i], &inbufs[i], bytesize);
|
||||||
infloats[i] = (gfloat *) GST_BUFFER_DATA (inbufs[i]);
|
infloats[i] = (gfloat *) GST_BUFFER_DATA (inbufs[i]);
|
||||||
// loop through each src pad
|
/* loop through each src pad */
|
||||||
for (j = 0; j < mix->srcpadalloc; j++) {
|
for (j = 0; j < mix->srcpadalloc; j++) {
|
||||||
if (mix->srcpads[j] != NULL) {
|
if (mix->srcpads[j] != NULL) {
|
||||||
/*
|
/*
|
||||||
|
@ -463,7 +465,7 @@ gst_mixmatrix_loop (GstElement * element)
|
||||||
fprintf(stderr,"attempting to get gain for %dx%d\n",i,j);
|
fprintf(stderr,"attempting to get gain for %dx%d\n",i,j);
|
||||||
*/
|
*/
|
||||||
gain = mix->matrix[i][j];
|
gain = mix->matrix[i][j];
|
||||||
// fprintf(stderr,"%d->%d=%0.2f ",i,j,gain);
|
/* fprintf(stderr,"%d->%d=%0.2f ",i,j,gain); */
|
||||||
for (k = 0; k < mix->outsize; k++) {
|
for (k = 0; k < mix->outsize; k++) {
|
||||||
outfloats[j][k] += infloats[i][k] * gain;
|
outfloats[j][k] += infloats[i][k] * gain;
|
||||||
}
|
}
|
||||||
|
@ -471,7 +473,7 @@ fprintf(stderr,"attempting to get gain for %dx%d\n",i,j);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
// fprintf(stderr,"\n");
|
/* fprintf(stderr,"\n"); */
|
||||||
|
|
||||||
for (i = 0; i < mix->srcpadalloc; i++) {
|
for (i = 0; i < mix->srcpadalloc; i++) {
|
||||||
if (mix->srcpads[i] != NULL) {
|
if (mix->srcpads[i] != NULL) {
|
||||||
|
|
Loading…
Reference in a new issue