From d3deeade47c524006c5477073c02b56d50826f85 Mon Sep 17 00:00:00 2001 From: Jan Schmidt Date: Sun, 13 Jun 2004 10:58:34 +0000 Subject: ext/esd/esdsink.*: Close the esd connection on pause, because esd will just wait - blocking all other esd clients ind... Original commit message from CVS: * ext/esd/esdsink.c: (gst_esdsink_change_state): * ext/esd/esdsink.h: Close the esd connection on pause, because esd will just wait - blocking all other esd clients indefinitely. --- ext/esd/esdsink.c | 40 ++++++++++++++++++++++++++++++++-------- ext/esd/esdsink.h | 1 + 2 files changed, 33 insertions(+), 8 deletions(-) (limited to 'ext/esd') diff --git a/ext/esd/esdsink.c b/ext/esd/esdsink.c index 843fad92..7ccd0b9f 100644 --- a/ext/esd/esdsink.c +++ b/ext/esd/esdsink.c @@ -183,6 +183,7 @@ gst_esdsink_init (GTypeInstance * instance, gpointer g_class) GST_OBJECT (esdsink)); esdsink->sync = TRUE; esdsink->fallback = FALSE; + esdsink->link_open = FALSE; } #ifdef unused @@ -201,10 +202,13 @@ gst_esdsink_link (GstPad * pad, const GstCaps * caps) esdsink->bytes_per_sample = esdsink->channels * (esdsink->depth / 8); - gst_esdsink_close_audio (esdsink); - if (gst_esdsink_open_audio (esdsink)) { - esdsink->negotiated = TRUE; - return GST_PAD_LINK_OK; + if (esdsink->link_open) { + gst_esdsink_close_audio (esdsink); + if (gst_esdsink_open_audio (esdsink)) { + esdsink->negotiated = TRUE; + esdsink->link_open = TRUE; + return GST_PAD_LINK_OK; + } } /* FIXME: is it supposed to be correct to have closed audio when caps nego failed? */ @@ -457,25 +461,45 @@ gst_esdsink_change_state (GstElement * element) switch (GST_STATE_TRANSITION (element)) { case GST_STATE_NULL_TO_READY: - if (!gst_esdsink_open_audio (GST_ESDSINK (element))) { - return GST_STATE_FAILURE; - } break; case GST_STATE_READY_TO_PAUSED: + /* Open and close the link to test it's available */ + if (!esdsink->link_open) { + if (!gst_esdsink_open_audio (GST_ESDSINK (element))) { + return GST_STATE_FAILURE; + } + gst_esdsink_close_audio (GST_ESDSINK (element)); + } break; case GST_STATE_PAUSED_TO_PLAYING: + if (!esdsink->link_open) { + if (!gst_esdsink_open_audio (GST_ESDSINK (element))) { + return GST_STATE_FAILURE; + } + esdsink->link_open = TRUE; + } gst_audio_clock_set_active (GST_AUDIO_CLOCK (esdsink->provided_clock), TRUE); break; case GST_STATE_PLAYING_TO_PAUSED: gst_audio_clock_set_active (GST_AUDIO_CLOCK (esdsink->provided_clock), FALSE); + if (esdsink->link_open) { + gst_esdsink_close_audio (GST_ESDSINK (element)); + esdsink->link_open = FALSE; + } esdsink->resync = TRUE; break; case GST_STATE_PAUSED_TO_READY: + /* Make doubly sure we don't leave our esd connection open + * or we'll block the other users + */ + if (esdsink->link_open) { + gst_esdsink_close_audio (GST_ESDSINK (element)); + esdsink->link_open = FALSE; + } break; case GST_STATE_READY_TO_NULL: - gst_esdsink_close_audio (GST_ESDSINK (element)); break; default: break; diff --git a/ext/esd/esdsink.h b/ext/esd/esdsink.h index 9bf81641..7ad1e41d 100644 --- a/ext/esd/esdsink.h +++ b/ext/esd/esdsink.h @@ -58,6 +58,7 @@ struct _GstEsdsink { gchar *host; int handled; int bytes_per_sample; + gboolean link_open; gboolean sync; gboolean resync; gboolean fallback; -- cgit