ext/mad/gstmad.c: Fix seeking in stand-alone mode. Fix nonexistant enum value introduced in previous commit. Improve ...

Original commit message from CVS:
* ext/mad/gstmad.c: (gst_mad_mode_get_type), (gst_mad_src_query),
(normal_seek), (gst_mad_sink_event), (gst_mad_chain):
Fix seeking in stand-alone mode. Fix nonexistant enum value
introduced in previous commit. Improve debug messages here and
there. Actually return a proper return value in the sink event
handler.
This commit is contained in:
Tim-Philipp Müller 2005-11-22 17:39:36 +00:00
parent fd183e8d6c
commit 750f0f9d13
2 changed files with 62 additions and 24 deletions

View file

@ -1,3 +1,12 @@
2005-11-22 Tim-Philipp Müller <tim at centricular dot net>
* ext/mad/gstmad.c: (gst_mad_mode_get_type), (gst_mad_src_query),
(normal_seek), (gst_mad_sink_event), (gst_mad_chain):
Fix seeking in stand-alone mode. Fix nonexistant enum value
introduced in previous commit. Improve debug messages here and
there. Actually return a proper return value in the sink event
handler.
2005-11-22 Thomas Vander Stichele <thomas at apestaart dot org> 2005-11-22 Thomas Vander Stichele <thomas at apestaart dot org>
* ext/lame/gstlame.c: * ext/lame/gstlame.c:

View file

@ -179,8 +179,6 @@ static GstIndex *gst_mad_get_index (GstElement * element);
static GstElementClass *parent_class = NULL; static GstElementClass *parent_class = NULL;
/* static guint gst_mad_signals[LAST_SIGNAL] = { 0 }; */
GType GType
gst_mad_get_type (void) gst_mad_get_type (void)
{ {
@ -232,7 +230,7 @@ gst_mad_mode_get_type (void)
static GType mad_mode_type = 0; static GType mad_mode_type = 0;
static GEnumValue mad_mode[] = { static GEnumValue mad_mode[] = {
{-1, "Unknown", "unknown"}, {-1, "Unknown", "unknown"},
{MAD_MODE_MONO, "Mono", "mono"}, {MAD_MODE_SINGLE_CHANNEL, "Mono", "mono"},
{MAD_MODE_DUAL_CHANNEL, "Dual Channel", "dual"}, {MAD_MODE_DUAL_CHANNEL, "Dual Channel", "dual"},
{MAD_MODE_JOINT_STEREO, "Joint Stereo", "joint"}, {MAD_MODE_JOINT_STEREO, "Joint Stereo", "joint"},
{MAD_MODE_STEREO, "Stereo", "stereo"}, {MAD_MODE_STEREO, "Stereo", "stereo"},
@ -573,8 +571,11 @@ gst_mad_src_query (GstPad * pad, GstQuery * query)
gst_query_set_position (query, format, cur); gst_query_set_position (query, format, cur);
GST_LOG_OBJECT (mad, if (format == GST_FORMAT_TIME) {
"position query: we return %llu (format %u)", cur, format); GST_LOG ("position=%" GST_TIME_FORMAT, GST_TIME_ARGS (cur));
} else {
GST_LOG ("position=%" G_GINT64_FORMAT ", format=%u", cur, format);
}
break; break;
} }
case GST_QUERY_DURATION: case GST_QUERY_DURATION:
@ -601,10 +602,12 @@ gst_mad_src_query (GstPad * pad, GstQuery * query)
/* get the returned format */ /* get the returned format */
gst_query_parse_duration (query, &rformat, &total_bytes); gst_query_parse_duration (query, &rformat, &total_bytes);
if (rformat == GST_FORMAT_BYTES) if (rformat == GST_FORMAT_BYTES) {
GST_LOG_OBJECT (mad, "peer pad returned total=%lld bytes", total_bytes); GST_LOG_OBJECT (mad, "peer pad returned total=%lld bytes", total_bytes);
else if (rformat == GST_FORMAT_TIME) } else if (rformat == GST_FORMAT_TIME) {
GST_LOG_OBJECT (mad, "peer pad returned time=%lld", total_bytes); GST_LOG_OBJECT (mad, "peer pad returned total time=%", GST_TIME_FORMAT,
GST_TIME_ARGS (total_bytes));
}
/* Check if requested format is returned format */ /* Check if requested format is returned format */
if (format == rformat) if (format == rformat)
@ -623,9 +626,11 @@ gst_mad_src_query (GstPad * pad, GstQuery * query)
} }
gst_query_set_duration (query, format, total); gst_query_set_duration (query, format, total);
if (format == GST_FORMAT_TIME) {
GST_LOG_OBJECT (mad, GST_LOG ("duration=%" GST_TIME_FORMAT, GST_TIME_ARGS (total));
"position query: we return %llu (format %u)", total, format); } else {
GST_LOG ("duration=%" G_GINT64_FORMAT ", format=%u", total, format);
}
break; break;
} }
case GST_QUERY_CONVERT: case GST_QUERY_CONVERT:
@ -730,7 +735,7 @@ normal_seek (GstMad * mad, GstPad * pad, GstEvent * event)
gint64 cur, stop; gint64 cur, stop;
gint64 time_cur, time_stop; gint64 time_cur, time_stop;
gint64 bytes_cur, bytes_stop; gint64 bytes_cur, bytes_stop;
guint flush; gboolean flush;
/* const GstFormat *peer_formats; */ /* const GstFormat *peer_formats; */
gboolean res; gboolean res;
@ -755,7 +760,7 @@ normal_seek (GstMad * mad, GstPad * pad, GstEvent * event)
GST_TIME_ARGS (time_cur), GST_TIME_ARGS (time_stop)); GST_TIME_ARGS (time_cur), GST_TIME_ARGS (time_stop));
/* shave off the flush flag, we'll need it later */ /* shave off the flush flag, we'll need it later */
flush = flags & GST_SEEK_FLAG_FLUSH; flush = ((flags & GST_SEEK_FLAG_FLUSH) != 0);
/* assume the worst */ /* assume the worst */
res = FALSE; res = FALSE;
@ -777,6 +782,13 @@ normal_seek (GstMad * mad, GstPad * pad, GstEvent * event)
/* do the seek */ /* do the seek */
res = gst_pad_push_event (mad->sinkpad, seek_event); res = gst_pad_push_event (mad->sinkpad, seek_event);
if (res) {
/* we need to break out of the processing loop on flush */
mad->restart = flush;
mad->segment_start = time_cur;
mad->last_ts = time_cur;
}
} }
#if 0 #if 0
peer_formats = gst_pad_get_formats (GST_PAD_PEER (mad->sinkpad)); peer_formats = gst_pad_get_formats (GST_PAD_PEER (mad->sinkpad));
@ -976,25 +988,42 @@ gst_mad_sink_event (GstPad * pad, GstEvent * event)
GstMad *mad = GST_MAD (GST_PAD_PARENT (pad)); GstMad *mad = GST_MAD (GST_PAD_PARENT (pad));
gboolean result; gboolean result;
GST_DEBUG ("handling event %d", GST_EVENT_TYPE (event)); GST_DEBUG ("handling %s event", GST_EVENT_TYPE_NAME (event));
switch (GST_EVENT_TYPE (event)) { switch (GST_EVENT_TYPE (event)) {
case GST_EVENT_NEWSEGMENT: case GST_EVENT_NEWSEGMENT:{
/* this isn't really correct? */ GstFormat format;
result = gst_pad_push_event (mad->srcpad, event);
mad->tempsize = 0; gst_event_parse_new_segment (event, NULL, NULL, &format, NULL, NULL,
/* we don't need to restart when we get here */ NULL);
mad->restart = FALSE;
if (format == GST_FORMAT_TIME) {
/* FIXME: is this really correct? */
mad->tempsize = 0;
result = gst_pad_push_event (mad->srcpad, event);
/* we don't need to restart when we get here */
mad->restart = FALSE;
} else {
GST_DEBUG ("dropping newsegment event in format %s",
gst_format_get_name (format));
/* on restart the chain function will generate a new
* newsegment event, so we can just drop this one */
mad->restart = TRUE;
gst_event_unref (event);
mad->tempsize = 0;
result = TRUE;
}
break; break;
}
case GST_EVENT_EOS: case GST_EVENT_EOS:
mad->caps_set = FALSE; /* could be a new stream */ mad->caps_set = FALSE; /* could be a new stream */
result = gst_pad_push_event (mad->srcpad, event); result = gst_pad_push_event (mad->srcpad, event);
break; break;
default: default:
result = gst_pad_push_event (mad->srcpad, event); result = gst_pad_event_default (pad, event);
break; break;
} }
return TRUE; return result;
} }
static gboolean static gboolean
@ -1250,8 +1279,8 @@ gst_mad_chain (GstPad * pad, GstBuffer * buffer)
* we can set this timestamp on the next outgoing buffer */ * we can set this timestamp on the next outgoing buffer */
if (mad->tempsize == 0) { if (mad->tempsize == 0) {
/* we have to save the result here because we can't yet convert /* we have to save the result here because we can't yet convert
* the timestamp to a sample offset yet, * the timestamp to a sample offset, as the samplerate might not
* the samplerate might not be known yet */ * be known yet */
mad->last_ts = timestamp; mad->last_ts = timestamp;
mad->base_byte_offset = GST_BUFFER_OFFSET (buffer); mad->base_byte_offset = GST_BUFFER_OFFSET (buffer);
mad->bytes_consumed = 0; mad->bytes_consumed = 0;