- audioresample->sinkpad =
- gst_pad_new_from_template (gst_static_pad_template_get
- (&gst_audioresample_sink_template), "sink");
- gst_element_add_pad (GST_ELEMENT (audioresample), audioresample->sinkpad);
- gst_pad_set_chain_function (audioresample->sinkpad, gst_audioresample_chain);
- gst_pad_set_link_function (audioresample->sinkpad, gst_audioresample_link);
- gst_pad_set_getcaps_function (audioresample->sinkpad,
- gst_audioresample_getcaps);
- gst_pad_set_fixate_function (audioresample->sinkpad,
- gst_audioresample_fixate);
-
- audioresample->srcpad =
- gst_pad_new_from_template (gst_static_pad_template_get
- (&gst_audioresample_src_template), "src");
-
- gst_element_add_pad (GST_ELEMENT (audioresample), audioresample->srcpad);
- gst_pad_set_link_function (audioresample->srcpad, gst_audioresample_link);
- gst_pad_set_getcaps_function (audioresample->srcpad,
- gst_audioresample_getcaps);
- gst_pad_set_fixate_function (audioresample->srcpad, gst_audioresample_fixate);
+ /* if the caps are the ones that _set_caps got called with; we can use
+ * our own state; otherwise we'll have to create a state */
+ if (gst_caps_is_equal (sinkcaps, audioresample->sinkcaps) &&
+ gst_caps_is_equal (srccaps, audioresample->srccaps)) {
+ use_internal = TRUE;
+ state = audioresample->resample;
+ } else {
+ state = resample_new ();
+ resample_set_state_from_caps (state, sinkcaps, srccaps, NULL, NULL, NULL);
+ }