mirror of
https://gitlab.freedesktop.org/gstreamer/gstreamer.git
synced 2024-11-23 02:01:12 +00:00
wavparse: reset when receiving STREAM_START
We need to reset the internal state to be able to parse a new stream. When doing so keep seek event and do not destroy the adapter. Part-of: <https://gitlab.freedesktop.org/gstreamer/gstreamer/-/merge_requests/6840>
This commit is contained in:
parent
b01305f60c
commit
210487b50a
1 changed files with 16 additions and 8 deletions
|
@ -213,8 +213,9 @@ gst_wavparse_labls_free (GstWavParseLabl * labl)
|
||||||
g_free (labl);
|
g_free (labl);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* reset seek event and destroy adapter if @hard is TRUE */
|
||||||
static void
|
static void
|
||||||
gst_wavparse_reset (GstWavParse * wav)
|
gst_wavparse_reset (GstWavParse * wav, gboolean hard)
|
||||||
{
|
{
|
||||||
wav->state = GST_WAVPARSE_START;
|
wav->state = GST_WAVPARSE_START;
|
||||||
|
|
||||||
|
@ -236,13 +237,13 @@ gst_wavparse_reset (GstWavParse * wav)
|
||||||
wav->got_fmt = FALSE;
|
wav->got_fmt = FALSE;
|
||||||
wav->first = TRUE;
|
wav->first = TRUE;
|
||||||
|
|
||||||
if (wav->seek_event)
|
if (hard)
|
||||||
gst_event_unref (wav->seek_event);
|
g_clear_pointer (&wav->seek_event, gst_event_unref);
|
||||||
wav->seek_event = NULL;
|
wav->seek_event = NULL;
|
||||||
if (wav->adapter) {
|
if (wav->adapter) {
|
||||||
gst_adapter_clear (wav->adapter);
|
gst_adapter_clear (wav->adapter);
|
||||||
g_object_unref (wav->adapter);
|
if (hard)
|
||||||
wav->adapter = NULL;
|
g_clear_object (&wav->adapter);
|
||||||
}
|
}
|
||||||
if (wav->tags)
|
if (wav->tags)
|
||||||
gst_tag_list_unref (wav->tags);
|
gst_tag_list_unref (wav->tags);
|
||||||
|
@ -273,7 +274,7 @@ gst_wavparse_dispose (GObject * object)
|
||||||
GstWavParse *wav = GST_WAVPARSE (object);
|
GstWavParse *wav = GST_WAVPARSE (object);
|
||||||
|
|
||||||
GST_DEBUG_OBJECT (wav, "WAV: Dispose");
|
GST_DEBUG_OBJECT (wav, "WAV: Dispose");
|
||||||
gst_wavparse_reset (wav);
|
gst_wavparse_reset (wav, TRUE);
|
||||||
|
|
||||||
G_OBJECT_CLASS (parent_class)->dispose (object);
|
G_OBJECT_CLASS (parent_class)->dispose (object);
|
||||||
}
|
}
|
||||||
|
@ -281,7 +282,7 @@ gst_wavparse_dispose (GObject * object)
|
||||||
static void
|
static void
|
||||||
gst_wavparse_init (GstWavParse * wavparse)
|
gst_wavparse_init (GstWavParse * wavparse)
|
||||||
{
|
{
|
||||||
gst_wavparse_reset (wavparse);
|
gst_wavparse_reset (wavparse, TRUE);
|
||||||
|
|
||||||
/* sink */
|
/* sink */
|
||||||
wavparse->sinkpad =
|
wavparse->sinkpad =
|
||||||
|
@ -2411,6 +2412,13 @@ gst_wavparse_sink_event (GstPad * pad, GstObject * parent, GstEvent * event)
|
||||||
GST_LOG_OBJECT (wav, "handling %s event", GST_EVENT_TYPE_NAME (event));
|
GST_LOG_OBJECT (wav, "handling %s event", GST_EVENT_TYPE_NAME (event));
|
||||||
|
|
||||||
switch (GST_EVENT_TYPE (event)) {
|
switch (GST_EVENT_TYPE (event)) {
|
||||||
|
case GST_EVENT_STREAM_START:
|
||||||
|
{
|
||||||
|
gst_wavparse_reset (wav, FALSE);
|
||||||
|
|
||||||
|
ret = gst_pad_event_default (wav->sinkpad, parent, event);
|
||||||
|
break;
|
||||||
|
}
|
||||||
case GST_EVENT_CAPS:
|
case GST_EVENT_CAPS:
|
||||||
{
|
{
|
||||||
/* discard, we'll come up with proper src caps */
|
/* discard, we'll come up with proper src caps */
|
||||||
|
@ -2974,7 +2982,7 @@ gst_wavparse_change_state (GstElement * element, GstStateChange transition)
|
||||||
case GST_STATE_CHANGE_PLAYING_TO_PAUSED:
|
case GST_STATE_CHANGE_PLAYING_TO_PAUSED:
|
||||||
break;
|
break;
|
||||||
case GST_STATE_CHANGE_PAUSED_TO_READY:
|
case GST_STATE_CHANGE_PAUSED_TO_READY:
|
||||||
gst_wavparse_reset (wav);
|
gst_wavparse_reset (wav, TRUE);
|
||||||
break;
|
break;
|
||||||
case GST_STATE_CHANGE_READY_TO_NULL:
|
case GST_STATE_CHANGE_READY_TO_NULL:
|
||||||
break;
|
break;
|
||||||
|
|
Loading…
Reference in a new issue