From f49d8faa2893d84af255bf9a08066664539d8f5b Mon Sep 17 00:00:00 2001 From: Benjamin Otte Date: Thu, 1 Apr 2004 16:34:14 +0000 Subject: [PATCH] ext/alsa/gstalsa.c: handle case better where a soundcard can't pause Original commit message from CVS: * ext/alsa/gstalsa.c: (gst_alsa_change_state), (gst_alsa_close_audio): handle case better where a soundcard can't pause * ext/ogg/gstoggdemux.c: don't crash when we get events but don't have pads yet --- ChangeLog | 9 ++++++++- ext/alsa/gstalsa.c | 9 +++++++-- ext/ogg/gstoggdemux.c | 14 +++++++------- 3 files changed, 22 insertions(+), 10 deletions(-) diff --git a/ChangeLog b/ChangeLog index 94daf1948a..d28cdc18b6 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,11 @@ +2004-04-01 Benjamin Otte + + * ext/alsa/gstalsa.c: (gst_alsa_change_state), + (gst_alsa_close_audio): + handle case better where a soundcard can't pause + * ext/ogg/gstoggdemux.c: + don't crash when we get events but don't have pads yet + 2004-04-01 Thomas Vander Stichele * sys/oss/gstosselement.c: (gst_osselement_probe_caps): @@ -130,7 +138,6 @@ * ext/kio/kiosrc.cpp: (process_events): update handling event processing if inside KDE - untested ->>>>>>> 1.489 2004-03-29 David Schleef * ext/hermes/gsthermescolorspace.c: (plugin_init): decrease rank diff --git a/ext/alsa/gstalsa.c b/ext/alsa/gstalsa.c index 5780a51332..dbdd363c04 100644 --- a/ext/alsa/gstalsa.c +++ b/ext/alsa/gstalsa.c @@ -894,7 +894,7 @@ out: static GstElementStateReturn gst_alsa_change_state (GstElement * element) { - int err; + int err = 0; GstAlsa *this; g_return_val_if_fail (element != NULL, FALSE); @@ -931,10 +931,12 @@ gst_alsa_change_state (GstElement * element) if ((err = snd_pcm_pause (this->handle, 1)) < 0) { GST_ERROR_OBJECT (this, "Error pausing sound: %s", snd_strerror (err)); - return GST_STATE_FAILURE; + GST_ALSA_CAPS_SET (this, GST_ALSA_CAPS_PAUSE, 0); + goto cant_pause; } } } else { + cant_pause: /* if device doesn't know how to pause, we just stop */ if (GST_FLAG_IS_SET (element, GST_ALSA_RUNNING)) gst_alsa_stop_audio (this); @@ -1402,6 +1404,9 @@ gst_alsa_close_audio (GstAlsa * this) g_free (this->cardname); this->cardname = NULL; } + GST_ALSA_CAPS_SET (this, GST_ALSA_CAPS_PAUSE, 0); + GST_ALSA_CAPS_SET (this, GST_ALSA_CAPS_RESUME, 0); + GST_ALSA_CAPS_SET (this, GST_ALSA_CAPS_SYNC_START, 0); GST_FLAG_UNSET (this, GST_ALSA_OPEN); return TRUE; diff --git a/ext/ogg/gstoggdemux.c b/ext/ogg/gstoggdemux.c index 7dfc2dfd8b..12a487b0ce 100644 --- a/ext/ogg/gstoggdemux.c +++ b/ext/ogg/gstoggdemux.c @@ -90,9 +90,11 @@ GstOggChain; #define CURRENT_CHAIN(ogg) (&g_array_index ((ogg)->chains, GstOggChain, (ogg)->current_chain)) #define FOR_PAD_IN_CURRENT_CHAIN(ogg, _pad, ...) G_STMT_START{ \ GSList *_walk; \ - for (_walk = CURRENT_CHAIN (ogg)->pads; _walk; _walk = g_slist_next (_walk)) { \ - GstOggPad *_pad = (GstOggPad *) _walk->data; \ - __VA_ARGS__ \ + if ((ogg)->current_chain != -1) { \ + for (_walk = CURRENT_CHAIN (ogg)->pads; _walk; _walk = g_slist_next (_walk)) { \ + GstOggPad *_pad = (GstOggPad *) _walk->data; \ + __VA_ARGS__ \ + } \ } \ }G_STMT_END @@ -374,8 +376,7 @@ gst_ogg_demux_src_event (GstPad * pad, GstEvent * event) GST_OGG_SET_STATE (ogg, GST_OGG_STATE_SEEK); FOR_PAD_IN_CURRENT_CHAIN (ogg, pad, - pad->flags |= GST_OGG_PAD_NEEDS_DISCONT; - ); + pad->flags |= GST_OGG_PAD_NEEDS_DISCONT;); GST_DEBUG_OBJECT (ogg, "initiating seeking to offset %" G_GUINT64_FORMAT, offset); ogg->seek_pad = cur; @@ -422,8 +423,7 @@ gst_ogg_demux_handle_event (GstPad * pad, GstEvent * event) gst_event_unref (event); GST_FLAG_UNSET (ogg, GST_OGG_FLAG_WAIT_FOR_DISCONT); FOR_PAD_IN_CURRENT_CHAIN (ogg, pad, - pad->flags |= GST_OGG_PAD_NEEDS_DISCONT; - ); + pad->flags |= GST_OGG_PAD_NEEDS_DISCONT;); break; case GST_EVENT_EOS: if (ogg->state == GST_OGG_STATE_SETUP) {