Sophie

Sophie

distrib > Mandriva > 2010.1 > i586 > media > main-testing-src > by-pkgid > 863d6bb7085bef9decfd3ec6b01c8cbe > files > 3

gstreamer0.10-plugins-good-0.10.22-1.1.4mdv2010.1.src.rpm

From 4a492f2c8a4dc3b00773ac222146344aea311a5a Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Sebastian=20Dr=C3=B6ge?= <sebastian.droege@collabora.co.uk>
Date: Thu, 6 May 2010 14:03:11 +0200
Subject: pulsesrc: Allocate/free PA mainloop during state changes

...also destroy the stream and context during state changes.
---
 ext/pulse/pulsesrc.c |   31 +++++++++++++++++--------------
 1 files changed, 17 insertions(+), 14 deletions(-)

diff --git a/ext/pulse/pulsesrc.c b/ext/pulse/pulsesrc.c
index 9fe7f51..0ddaa43 100644
--- a/ext/pulse/pulsesrc.c
+++ b/ext/pulse/pulsesrc.c
@@ -250,8 +250,6 @@ gst_pulsesrc_class_init (GstPulseSrcClass * klass)
 static void
 gst_pulsesrc_init (GstPulseSrc * pulsesrc, GstPulseSrcClass * klass)
 {
-  int e;
-
   pulsesrc->server = NULL;
   pulsesrc->device = NULL;
   pulsesrc->device_description = NULL;
@@ -274,12 +272,6 @@ gst_pulsesrc_init (GstPulseSrc * pulsesrc, GstPulseSrcClass * klass)
   pulsesrc->paused = FALSE;
   pulsesrc->in_read = FALSE;
 
-  pulsesrc->mainloop = pa_threaded_mainloop_new ();
-  g_assert (pulsesrc->mainloop);
-
-  e = pa_threaded_mainloop_start (pulsesrc->mainloop);
-  g_assert (e == 0);
-
   pulsesrc->mixer = NULL;
 
   pulsesrc->probe = gst_pulseprobe_new (G_OBJECT (pulsesrc), G_OBJECT_GET_CLASS (pulsesrc), PROP_DEVICE, pulsesrc->server, FALSE, TRUE);        /* FALSE for sinks, TRUE for sources */
@@ -320,15 +312,9 @@ gst_pulsesrc_finalize (GObject * object)
 {
   GstPulseSrc *pulsesrc = GST_PULSESRC_CAST (object);
 
-  pa_threaded_mainloop_stop (pulsesrc->mainloop);
-
-  gst_pulsesrc_destroy_context (pulsesrc);
-
   g_free (pulsesrc->server);
   g_free (pulsesrc->device);
 
-  pa_threaded_mainloop_free (pulsesrc->mainloop);
-
   if (pulsesrc->mixer) {
     gst_pulsemixer_ctrl_free (pulsesrc->mixer);
     pulsesrc->mixer = NULL;
@@ -1177,9 +1163,16 @@ gst_pulsesrc_change_state (GstElement * element, GstStateChange transition)
 {
   GstStateChangeReturn ret;
   GstPulseSrc *this = GST_PULSESRC_CAST (element);
+  int e;
 
   switch (transition) {
     case GST_STATE_CHANGE_NULL_TO_READY:
+      this->mainloop = pa_threaded_mainloop_new ();
+      g_assert (this->mainloop);
+
+      e = pa_threaded_mainloop_start (this->mainloop);
+      g_assert (e == 0);
+
       if (!this->mixer)
         this->mixer =
             gst_pulsemixer_ctrl_new (G_OBJECT (this), this->server,
@@ -1212,6 +1205,16 @@ gst_pulsesrc_change_state (GstElement * element, GstStateChange transition)
         gst_pulsemixer_ctrl_free (this->mixer);
         this->mixer = NULL;
       }
+
+      if (this->mainloop)
+        pa_threaded_mainloop_stop (this->mainloop);
+
+      gst_pulsesrc_destroy_context (this);
+
+      if (this->mainloop) {
+        pa_threaded_mainloop_free (this->mainloop);
+        this->mainloop = NULL;
+      }
       break;
     default:
       break;
-- 
1.7.1