mirror of
https://gitlab.freedesktop.org/gstreamer/gstreamer.git
synced 2025-02-20 04:56:24 +00:00
only renegotiate when relavent properties change
Original commit message from CVS: only renegotiate when relavent properties change
This commit is contained in:
parent
072a9310e7
commit
8e500986d1
2 changed files with 81 additions and 70 deletions
|
@ -341,7 +341,7 @@ gst_a52dec_reneg (GstPad * pad, int channels, int rate)
|
|||
{
|
||||
GST_INFO (GST_CAT_PLUGIN_INFO, "a52dec: reneg channels:%d rate:%d\n", channels, rate);
|
||||
|
||||
gst_pad_try_set_caps (pad,
|
||||
if (gst_pad_try_set_caps (pad,
|
||||
GST_CAPS_NEW ("a52dec_src_caps",
|
||||
"audio/raw",
|
||||
"format", GST_PROPS_STRING ("int"),
|
||||
|
@ -352,7 +352,9 @@ gst_a52dec_reneg (GstPad * pad, int channels, int rate)
|
|||
"depth", GST_PROPS_INT (16),
|
||||
"channels", GST_PROPS_INT (channels),
|
||||
"rate", GST_PROPS_INT (rate))
|
||||
);
|
||||
) <= 0) {
|
||||
gst_element_error (GST_PAD_PARENT (pad), "could not set caps on source pad, aborting...");
|
||||
}
|
||||
}
|
||||
|
||||
static void
|
||||
|
@ -383,9 +385,10 @@ gst_a52dec_loop (GstElement *element)
|
|||
GstA52Dec *a52dec;
|
||||
guint8 *data;
|
||||
int i, length, flags, sample_rate, bit_rate;
|
||||
int stream_channels;
|
||||
int channels;
|
||||
GstBuffer *buf;
|
||||
guint32 got_bytes;
|
||||
gboolean need_reneg;
|
||||
|
||||
a52dec = GST_A52DEC (element);
|
||||
|
||||
|
@ -404,26 +407,22 @@ gst_a52dec_loop (GstElement *element)
|
|||
else
|
||||
break;
|
||||
|
||||
/* FIXME this can potentially be an infinite loop, we have to
|
||||
* insert a yield operations here */
|
||||
/* FIXME this can potentially be an infinite loop, we might
|
||||
* have to insert a yield operation here */
|
||||
}
|
||||
|
||||
/* check if params have changed since last call */
|
||||
stream_channels = flags & A52_CHANNEL_MASK;
|
||||
need_reneg = FALSE;
|
||||
|
||||
if ((sample_rate != a52dec->sample_rate) ||
|
||||
(bit_rate != a52dec->bit_rate) ||
|
||||
(stream_channels != a52dec->stream_channels))
|
||||
{
|
||||
if (a52dec->sample_rate != sample_rate) {
|
||||
need_reneg = TRUE;
|
||||
a52dec->sample_rate = sample_rate;
|
||||
a52dec->bit_rate = bit_rate;
|
||||
a52dec->stream_channels = stream_channels;
|
||||
/* FIXME force stereo for now */
|
||||
a52dec->req_channels = A52_STEREO;
|
||||
gst_a52dec_reneg (a52dec->srcpad,
|
||||
gst_a52dec_channels (a52dec->req_channels), a52dec->sample_rate);
|
||||
}
|
||||
|
||||
a52dec->stream_channels = flags & A52_CHANNEL_MASK;
|
||||
|
||||
/* FIXME: perhaps this change should be announced? */
|
||||
a52dec->bit_rate = bit_rate;
|
||||
|
||||
/* read the header + rest of frame */
|
||||
got_bytes = gst_bytestream_read (a52dec->bs, &buf, length);
|
||||
if (got_bytes < length) {
|
||||
|
@ -433,7 +432,7 @@ gst_a52dec_loop (GstElement *element)
|
|||
data = GST_BUFFER_DATA (buf);
|
||||
|
||||
/* process */
|
||||
flags = a52dec->req_channels | A52_ADJUST_LEVEL;
|
||||
flags = a52dec->request_channels | A52_ADJUST_LEVEL;
|
||||
a52dec->level = 1;
|
||||
|
||||
if (a52_frame (a52dec->state, data, &flags, &a52dec->level, a52dec->bias)) {
|
||||
|
@ -441,8 +440,18 @@ gst_a52dec_loop (GstElement *element)
|
|||
goto end;
|
||||
}
|
||||
|
||||
if ((flags & A52_CHANNEL_MASK) != a52dec->req_channels) {
|
||||
gst_a52dec_reneg (a52dec->srcpad, gst_a52dec_channels (flags), a52dec->sample_rate);
|
||||
channels = flags & A52_CHANNEL_MASK;
|
||||
|
||||
if (a52dec->using_channels != channels) {
|
||||
need_reneg = TRUE;
|
||||
a52dec->using_channels = channels;
|
||||
}
|
||||
|
||||
if (need_reneg == TRUE) {
|
||||
fprintf (stderr, "a52dec reneg: sample_rate:%d stream_chans:%d using_chans:%d\n",
|
||||
a52dec->sample_rate, a52dec->stream_channels, a52dec->using_channels);
|
||||
gst_a52dec_reneg (a52dec->srcpad,
|
||||
gst_a52dec_channels (a52dec->using_channels), a52dec->sample_rate);
|
||||
}
|
||||
|
||||
if (a52dec->dynamic_range_compression == FALSE) {
|
||||
|
@ -455,7 +464,9 @@ gst_a52dec_loop (GstElement *element)
|
|||
continue;
|
||||
}
|
||||
/* push on */
|
||||
gst_a52dec_push (a52dec->srcpad, a52dec->req_channels, a52dec->samples, GST_BUFFER_TIMESTAMP (buf));
|
||||
if (gst_a52dec_push (a52dec->srcpad, a52dec->using_channels, a52dec->samples, GST_BUFFER_TIMESTAMP (buf))) {
|
||||
g_warning ("a52dec push error\n");
|
||||
}
|
||||
}
|
||||
|
||||
end:
|
||||
|
@ -477,8 +488,10 @@ gst_a52dec_change_state (GstElement * element)
|
|||
a52dec->samples = a52_samples (a52dec->state);
|
||||
a52dec->bit_rate = -1;
|
||||
a52dec->sample_rate = -1;
|
||||
a52dec->stream_channels = -1;
|
||||
a52dec->req_channels = -1;
|
||||
a52dec->stream_channels = A52_CHANNEL;
|
||||
/* FIXME force stereo for now */
|
||||
a52dec->request_channels = A52_STEREO;
|
||||
a52dec->using_channels = A52_CHANNEL;
|
||||
a52dec->level = 1;
|
||||
a52dec->bias = 384;
|
||||
break;
|
||||
|
|
|
@ -21,7 +21,6 @@
|
|||
#ifndef __GST_A52DEC_H__
|
||||
#define __GST_A52DEC_H__
|
||||
|
||||
|
||||
#include <config.h>
|
||||
#include <gst/gst.h>
|
||||
#include <gst/bytestream/bytestream.h>
|
||||
|
@ -30,7 +29,6 @@
|
|||
extern "C" {
|
||||
#endif /* __cplusplus */
|
||||
|
||||
|
||||
#define GST_TYPE_A52DEC \
|
||||
(gst_a52dec_get_type())
|
||||
#define GST_A52DEC(obj) \
|
||||
|
@ -53,7 +51,8 @@ struct _GstA52Dec {
|
|||
int bit_rate;
|
||||
int sample_rate;
|
||||
int stream_channels;
|
||||
int req_channels;
|
||||
int request_channels;
|
||||
int using_channels;
|
||||
sample_t level;
|
||||
sample_t bias;
|
||||
gboolean dynamic_range_compression;
|
||||
|
@ -70,5 +69,4 @@ struct _GstA52DecClass {
|
|||
}
|
||||
#endif /* __cplusplus */
|
||||
|
||||
|
||||
#endif /* __GST_A52DEC_H__ */
|
||||
|
|
Loading…
Reference in a new issue