mirror of
https://gitlab.freedesktop.org/gstreamer/gstreamer.git
synced 2025-01-02 05:28:48 +00:00
gst/audioresample/gstaudioresample.c: Implement GstBaseTransform::start and ::stop so that audioresample can clear it...
Original commit message from CVS: * gst/audioresample/gstaudioresample.c: (gst_audioresample_class_init), (gst_audioresample_init), (audioresample_start), (audioresample_stop), (gst_audioresample_set_property), (gst_audioresample_get_property): Implement GstBaseTransform::start and ::stop so that audioresample can clear its internal state properly and be reused insted of causing non-negotiated errors with playbin under some circumstances (#342789). * tests/check/elements/audioresample.c: (setup_audioresample), (cleanup_audioresample): Need to set element state here so that ::start and ::stop are called.
This commit is contained in:
parent
384fe0bda8
commit
ab841287a7
2 changed files with 35 additions and 25 deletions
|
@ -60,13 +60,6 @@ GST_ELEMENT_DETAILS ("Audio scaler",
|
||||||
"Resample audio",
|
"Resample audio",
|
||||||
"David Schleef <ds@schleef.org>");
|
"David Schleef <ds@schleef.org>");
|
||||||
|
|
||||||
/* GstAudioresample signals and args */
|
|
||||||
enum
|
|
||||||
{
|
|
||||||
/* FILL ME */
|
|
||||||
LAST_SIGNAL
|
|
||||||
};
|
|
||||||
|
|
||||||
#define DEFAULT_FILTERLEN 16
|
#define DEFAULT_FILTERLEN 16
|
||||||
|
|
||||||
enum
|
enum
|
||||||
|
@ -111,8 +104,6 @@ static GstStaticPadTemplate gst_audioresample_src_template =
|
||||||
GST_STATIC_PAD_TEMPLATE ("src",
|
GST_STATIC_PAD_TEMPLATE ("src",
|
||||||
GST_PAD_SRC, GST_PAD_ALWAYS, SUPPORTED_CAPS);
|
GST_PAD_SRC, GST_PAD_ALWAYS, SUPPORTED_CAPS);
|
||||||
|
|
||||||
static void gst_audioresample_dispose (GObject * object);
|
|
||||||
|
|
||||||
static void gst_audioresample_set_property (GObject * object,
|
static void gst_audioresample_set_property (GObject * object,
|
||||||
guint prop_id, const GValue * value, GParamSpec * pspec);
|
guint prop_id, const GValue * value, GParamSpec * pspec);
|
||||||
static void gst_audioresample_get_property (GObject * object,
|
static void gst_audioresample_get_property (GObject * object,
|
||||||
|
@ -133,8 +124,8 @@ static GstFlowReturn audioresample_pushthrough (GstAudioresample *
|
||||||
static GstFlowReturn audioresample_transform (GstBaseTransform * base,
|
static GstFlowReturn audioresample_transform (GstBaseTransform * base,
|
||||||
GstBuffer * inbuf, GstBuffer * outbuf);
|
GstBuffer * inbuf, GstBuffer * outbuf);
|
||||||
static gboolean audioresample_event (GstBaseTransform * base, GstEvent * event);
|
static gboolean audioresample_event (GstBaseTransform * base, GstEvent * event);
|
||||||
|
static gboolean audioresample_start (GstBaseTransform * base);
|
||||||
/*static guint gst_audioresample_signals[LAST_SIGNAL] = { 0 }; */
|
static gboolean audioresample_stop (GstBaseTransform * base);
|
||||||
|
|
||||||
#define DEBUG_INIT(bla) \
|
#define DEBUG_INIT(bla) \
|
||||||
GST_DEBUG_CATEGORY_INIT (audioresample_debug, "audioresample", 0, "audio resampling element");
|
GST_DEBUG_CATEGORY_INIT (audioresample_debug, "audioresample", 0, "audio resampling element");
|
||||||
|
@ -164,13 +155,16 @@ gst_audioresample_class_init (GstAudioresampleClass * klass)
|
||||||
|
|
||||||
gobject_class->set_property = gst_audioresample_set_property;
|
gobject_class->set_property = gst_audioresample_set_property;
|
||||||
gobject_class->get_property = gst_audioresample_get_property;
|
gobject_class->get_property = gst_audioresample_get_property;
|
||||||
gobject_class->dispose = gst_audioresample_dispose;
|
|
||||||
|
|
||||||
g_object_class_install_property (G_OBJECT_CLASS (klass), PROP_FILTERLEN,
|
g_object_class_install_property (G_OBJECT_CLASS (klass), PROP_FILTERLEN,
|
||||||
g_param_spec_int ("filter_length", "filter_length", "filter_length",
|
g_param_spec_int ("filter_length", "filter_length", "filter_length",
|
||||||
0, G_MAXINT, DEFAULT_FILTERLEN,
|
0, G_MAXINT, DEFAULT_FILTERLEN,
|
||||||
G_PARAM_READWRITE | G_PARAM_CONSTRUCT));
|
G_PARAM_READWRITE | G_PARAM_CONSTRUCT));
|
||||||
|
|
||||||
|
GST_BASE_TRANSFORM_CLASS (klass)->start =
|
||||||
|
GST_DEBUG_FUNCPTR (audioresample_start);
|
||||||
|
GST_BASE_TRANSFORM_CLASS (klass)->stop =
|
||||||
|
GST_DEBUG_FUNCPTR (audioresample_stop);
|
||||||
GST_BASE_TRANSFORM_CLASS (klass)->transform_size =
|
GST_BASE_TRANSFORM_CLASS (klass)->transform_size =
|
||||||
GST_DEBUG_FUNCPTR (audioresample_transform_size);
|
GST_DEBUG_FUNCPTR (audioresample_transform_size);
|
||||||
GST_BASE_TRANSFORM_CLASS (klass)->get_unit_size =
|
GST_BASE_TRANSFORM_CLASS (klass)->get_unit_size =
|
||||||
|
@ -191,7 +185,6 @@ static void
|
||||||
gst_audioresample_init (GstAudioresample * audioresample,
|
gst_audioresample_init (GstAudioresample * audioresample,
|
||||||
GstAudioresampleClass * klass)
|
GstAudioresampleClass * klass)
|
||||||
{
|
{
|
||||||
ResampleState *r;
|
|
||||||
GstBaseTransform *trans;
|
GstBaseTransform *trans;
|
||||||
|
|
||||||
trans = GST_BASE_TRANSFORM (audioresample);
|
trans = GST_BASE_TRANSFORM (audioresample);
|
||||||
|
@ -200,29 +193,39 @@ gst_audioresample_init (GstAudioresample * audioresample,
|
||||||
* is trivial in the passtrough case. */
|
* is trivial in the passtrough case. */
|
||||||
gst_pad_set_bufferalloc_function (trans->sinkpad, NULL);
|
gst_pad_set_bufferalloc_function (trans->sinkpad, NULL);
|
||||||
|
|
||||||
r = resample_new ();
|
audioresample->filter_length = DEFAULT_FILTERLEN;
|
||||||
audioresample->resample = r;
|
}
|
||||||
|
|
||||||
|
/* vmethods */
|
||||||
|
static gboolean
|
||||||
|
audioresample_start (GstBaseTransform * base)
|
||||||
|
{
|
||||||
|
GstAudioresample *audioresample = GST_AUDIORESAMPLE (base);
|
||||||
|
|
||||||
|
audioresample->resample = resample_new ();
|
||||||
audioresample->ts_offset = -1;
|
audioresample->ts_offset = -1;
|
||||||
audioresample->offset = -1;
|
audioresample->offset = -1;
|
||||||
audioresample->next_ts = -1;
|
audioresample->next_ts = -1;
|
||||||
|
|
||||||
resample_set_filter_length (r, DEFAULT_FILTERLEN);
|
resample_set_filter_length (audioresample->resample,
|
||||||
|
audioresample->filter_length);
|
||||||
|
|
||||||
|
return TRUE;
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static gboolean
|
||||||
gst_audioresample_dispose (GObject * object)
|
audioresample_stop (GstBaseTransform * base)
|
||||||
{
|
{
|
||||||
GstAudioresample *audioresample = GST_AUDIORESAMPLE (object);
|
GstAudioresample *audioresample = GST_AUDIORESAMPLE (base);
|
||||||
|
|
||||||
if (audioresample->resample) {
|
if (audioresample->resample) {
|
||||||
resample_free (audioresample->resample);
|
resample_free (audioresample->resample);
|
||||||
audioresample->resample = NULL;
|
audioresample->resample = NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
G_OBJECT_CLASS (parent_class)->dispose (object);
|
return TRUE;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* vmethods */
|
|
||||||
gboolean
|
gboolean
|
||||||
audioresample_get_unit_size (GstBaseTransform * base, GstCaps * caps,
|
audioresample_get_unit_size (GstBaseTransform * base, GstCaps * caps,
|
||||||
guint * size)
|
guint * size)
|
||||||
|
@ -639,7 +642,6 @@ gst_audioresample_set_property (GObject * object, guint prop_id,
|
||||||
{
|
{
|
||||||
GstAudioresample *audioresample;
|
GstAudioresample *audioresample;
|
||||||
|
|
||||||
g_return_if_fail (GST_IS_AUDIORESAMPLE (object));
|
|
||||||
audioresample = GST_AUDIORESAMPLE (object);
|
audioresample = GST_AUDIORESAMPLE (object);
|
||||||
|
|
||||||
switch (prop_id) {
|
switch (prop_id) {
|
||||||
|
@ -647,8 +649,10 @@ gst_audioresample_set_property (GObject * object, guint prop_id,
|
||||||
audioresample->filter_length = g_value_get_int (value);
|
audioresample->filter_length = g_value_get_int (value);
|
||||||
GST_DEBUG_OBJECT (GST_ELEMENT (audioresample), "new filter length %d",
|
GST_DEBUG_OBJECT (GST_ELEMENT (audioresample), "new filter length %d",
|
||||||
audioresample->filter_length);
|
audioresample->filter_length);
|
||||||
resample_set_filter_length (audioresample->resample,
|
if (audioresample->resample) {
|
||||||
audioresample->filter_length);
|
resample_set_filter_length (audioresample->resample,
|
||||||
|
audioresample->filter_length);
|
||||||
|
}
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
|
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
|
||||||
|
@ -662,7 +666,6 @@ gst_audioresample_get_property (GObject * object, guint prop_id,
|
||||||
{
|
{
|
||||||
GstAudioresample *audioresample;
|
GstAudioresample *audioresample;
|
||||||
|
|
||||||
g_return_if_fail (GST_IS_AUDIORESAMPLE (object));
|
|
||||||
audioresample = GST_AUDIORESAMPLE (object);
|
audioresample = GST_AUDIORESAMPLE (object);
|
||||||
|
|
||||||
switch (prop_id) {
|
switch (prop_id) {
|
||||||
|
|
|
@ -69,6 +69,10 @@ setup_audioresample (int channels, int inrate, int outrate)
|
||||||
"rate", G_TYPE_INT, inrate, NULL);
|
"rate", G_TYPE_INT, inrate, NULL);
|
||||||
fail_unless (gst_caps_is_fixed (caps));
|
fail_unless (gst_caps_is_fixed (caps));
|
||||||
|
|
||||||
|
fail_unless (gst_element_set_state (audioresample,
|
||||||
|
GST_STATE_PAUSED) == GST_STATE_CHANGE_SUCCESS,
|
||||||
|
"could not set to paused");
|
||||||
|
|
||||||
mysrcpad = gst_check_setup_src_pad (audioresample, &srctemplate, caps);
|
mysrcpad = gst_check_setup_src_pad (audioresample, &srctemplate, caps);
|
||||||
pad = gst_pad_get_peer (mysrcpad);
|
pad = gst_pad_get_peer (mysrcpad);
|
||||||
gst_pad_set_caps (pad, caps);
|
gst_pad_set_caps (pad, caps);
|
||||||
|
@ -100,6 +104,9 @@ cleanup_audioresample (GstElement * audioresample)
|
||||||
{
|
{
|
||||||
GST_DEBUG ("cleanup_audioresample");
|
GST_DEBUG ("cleanup_audioresample");
|
||||||
|
|
||||||
|
fail_unless (gst_element_set_state (audioresample,
|
||||||
|
GST_STATE_NULL) == GST_STATE_CHANGE_SUCCESS, "could not set to NULL");
|
||||||
|
|
||||||
gst_check_teardown_src_pad (audioresample);
|
gst_check_teardown_src_pad (audioresample);
|
||||||
gst_check_teardown_sink_pad (audioresample);
|
gst_check_teardown_sink_pad (audioresample);
|
||||||
gst_check_teardown_element (audioresample);
|
gst_check_teardown_element (audioresample);
|
||||||
|
|
Loading…
Reference in a new issue