summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorWim Taymans <wim.taymans@collabora.co.uk>2009-08-31 15:33:32 (GMT)
committerWim Taymans <wim.taymans@collabora.co.uk>2009-08-31 16:48:03 (GMT)
commit25caf9f743256e602ee0f7ad216ff51d892c7de3 (patch)
tree36a0b94e2ea5911c8d5cdd5fa310dbad8a1f2462
parent4ef773164ac14d4ba93d976fac7ff6c98a5be90b (diff)
wildmidi: set caps on pad
Set the caps on the pad and use those caps instead of keeping a separate caps pointer around. Fix some whitespace.
-rw-r--r--ext/timidity/gstwildmidi.c10
-rw-r--r--ext/timidity/gstwildmidi.h49
2 files changed, 31 insertions, 28 deletions
diff --git a/ext/timidity/gstwildmidi.c b/ext/timidity/gstwildmidi.c
index 90ec529..bdfce5d 100644
--- a/ext/timidity/gstwildmidi.c
+++ b/ext/timidity/gstwildmidi.c
@@ -652,6 +652,7 @@ gst_wildmidi_loop (GstPad * sinkpad)
GstWildmidi *wildmidi = GST_WILDMIDI (GST_PAD_PARENT (sinkpad));
GstBuffer *out;
GstFlowReturn ret;
+ GstCaps *outcaps;
if (wildmidi->mididata_size == 0) {
if (!gst_wildmidi_get_upstream_size (wildmidi, &wildmidi->mididata_size)) {
@@ -724,6 +725,10 @@ gst_wildmidi_loop (GstPad * sinkpad)
info = WildMidi_GetInfo (wildmidi->song);
wildmidi->o_len = info->approx_total_samples;
+ outcaps = gst_caps_copy (gst_pad_get_pad_template_caps (wildmidi->srcpad));
+ gst_pad_set_caps (wildmidi->srcpad, outcaps);
+ gst_caps_unref (outcaps);
+
gst_segment_set_newsegment (wildmidi->o_segment, FALSE, 1.0,
GST_FORMAT_DEFAULT, 0, GST_CLOCK_TIME_NONE, 0);
@@ -787,7 +792,7 @@ gst_wildmidi_loop (GstPad * sinkpad)
wildmidi->o_seek = FALSE;
}
- gst_buffer_set_caps (out, wildmidi->out_caps);
+ gst_buffer_set_caps (out, GST_PAD_CAPS (wildmidi->srcpad));
ret = gst_pad_push (wildmidi->srcpad, out);
if (GST_FLOW_IS_FATAL (ret) || ret == GST_FLOW_NOT_LINKED)
@@ -819,8 +824,6 @@ gst_wildmidi_change_state (GstElement * element, GstStateChange transition)
switch (transition) {
case GST_STATE_CHANGE_NULL_TO_READY:
- wildmidi->out_caps =
- gst_caps_copy (gst_pad_get_pad_template_caps (wildmidi->srcpad));
wildmidi->mididata = NULL;
break;
case GST_STATE_CHANGE_READY_TO_PAUSED:
@@ -846,7 +849,6 @@ gst_wildmidi_change_state (GstElement * element, GstStateChange transition)
wildmidi->mididata = NULL;
break;
case GST_STATE_CHANGE_READY_TO_NULL:
- gst_caps_unref (wildmidi->out_caps);
break;
default:
break;
diff --git a/ext/timidity/gstwildmidi.h b/ext/timidity/gstwildmidi.h
index 37815ea..84802f7 100644
--- a/ext/timidity/gstwildmidi.h
+++ b/ext/timidity/gstwildmidi.h
@@ -1,6 +1,6 @@
/*
* gstwildmidi - wildmidi plugin for gstreamer
- *
+ *
* Copyright 2007 Wouter Paesen <wouter@blue-gate.be>
*
* This library is free software; you can redistribute it and/or
@@ -19,8 +19,8 @@
* Boston, MA 02111-1307, USA.
*
* Wrapper element for libtimidity. This element works in pull
- * based mode because that's essentially how libwildmidi works.
- * We create a libwildmidi stream that operates on the srcpad.
+ * based mode because that's essentially how libwildmidi works.
+ * We create a libwildmidi stream that operates on the srcpad.
* The sinkpad is in pull mode.
*/
@@ -32,6 +32,7 @@
#include <wildmidi_lib.h>
G_BEGIN_DECLS
+
#define GST_TYPE_WILDMIDI \
(gst_wildmidi_get_type())
#define GST_WILDMIDI(obj) \
@@ -42,39 +43,38 @@ G_BEGIN_DECLS
(G_TYPE_CHECK_INSTANCE_TYPE((obj),GST_TYPE_WILDMIDI))
#define GST_IS_WILDMIDI_CLASS(klass) \
(G_TYPE_CHECK_CLASS_TYPE((klass),GST_TYPE_WILDMIDI))
+
typedef struct _GstWildmidi GstWildmidi;
typedef struct _GstWildmidiClass GstWildmidiClass;
struct _GstWildmidi
{
- GstElement element;
+ GstElement element;
- GstPad *sinkpad, *srcpad;
+ GstPad *sinkpad, *srcpad;
- /* input stream properties */
- gint64 mididata_size, mididata_offset;
- gchar *mididata;
- gboolean mididata_filled;
+ /* input stream properties */
+ gint64 mididata_size, mididata_offset;
+ gchar *mididata;
+ gboolean mididata_filled;
- midi *song;
+ midi *song;
- /* output data */
- gboolean o_new_segment, o_segment_changed, o_seek;
- GstSegment o_segment[1];
- gint64 o_len;
+ /* output data */
+ gboolean o_new_segment, o_segment_changed, o_seek;
+ GstSegment o_segment[1];
+ gint64 o_len;
- /* format of the stream */
- gint64 bytes_per_frame;
- GstClockTime time_per_frame;
+ /* format of the stream */
+ gint64 bytes_per_frame;
+ GstClockTime time_per_frame;
- /* options */
- gboolean accurate_seek;
+ /* options */
+ gboolean accurate_seek;
- /* wildmidi settings */
- gboolean high_quality;
- gboolean linear_volume;
-
- GstCaps *out_caps;
+ /* wildmidi settings */
+ gboolean high_quality;
+ gboolean linear_volume;
};
struct _GstWildmidiClass
@@ -85,4 +85,5 @@ struct _GstWildmidiClass
GType gst_wildmidi_get_type (void);
G_END_DECLS
+
#endif /* __GST_WILDMIDI_H__ */