diff options
author | Michal Ratajsky <[email protected]> | 2014-06-27 02:13:21 +0200 |
---|---|---|
committer | Michal Ratajsky <[email protected]> | 2014-06-27 02:13:21 +0200 |
commit | e13f443c1c4c73ef20dd00f1909f8c94c685b07f (patch) | |
tree | 01bb35090f47fb7a71b6513de129de95b9da9596 | |
parent | f235385f34c81d4cd9092b94cb24670eb25421fa (diff) | |
download | libmatemixer-e13f443c1c4c73ef20dd00f1909f8c94c685b07f.tar.bz2 libmatemixer-e13f443c1c4c73ef20dd00f1909f8c94c685b07f.tar.xz |
Fix pulse close function
-rw-r--r-- | backends/pulse/pulse-backend.c | 45 | ||||
-rw-r--r-- | backends/pulse/pulse-stream.c | 2 |
2 files changed, 22 insertions, 25 deletions
diff --git a/backends/pulse/pulse-backend.c b/backends/pulse/pulse-backend.c index 40e28e5..bdb3675 100644 --- a/backends/pulse/pulse-backend.c +++ b/backends/pulse/pulse-backend.c @@ -276,8 +276,18 @@ pulse_backend_init (PulseBackend *pulse) static void pulse_backend_dispose (GObject *object) { + PulseBackend *pulse; + backend_close (MATE_MIXER_BACKEND (object)); + pulse = PULSE_BACKEND (object); + + g_clear_pointer (&pulse->priv->devices, g_hash_table_destroy); + g_clear_pointer (&pulse->priv->sinks, g_hash_table_destroy); + g_clear_pointer (&pulse->priv->sink_inputs, g_hash_table_destroy); + g_clear_pointer (&pulse->priv->sources, g_hash_table_destroy); + g_clear_pointer (&pulse->priv->source_outputs, g_hash_table_destroy); + G_OBJECT_CLASS (pulse_backend_parent_class)->dispose (object); } @@ -395,6 +405,12 @@ backend_close (MateMixerBackend *backend) pulse = PULSE_BACKEND (backend); + /* IDLE is the state in which the backend is already closed */ + if (pulse->priv->state == MATE_MIXER_STATE_IDLE) + return; + + backend_remove_connect_source (pulse); + if (pulse->priv->connection) { g_signal_handlers_disconnect_by_data (pulse->priv->connection, pulse); @@ -402,30 +418,11 @@ backend_close (MateMixerBackend *backend) g_clear_object (&pulse->priv->connection); } - if (pulse->priv->devices) { - g_hash_table_destroy (pulse->priv->devices); - pulse->priv->devices = NULL; - } - - if (pulse->priv->sinks) { - g_hash_table_destroy (pulse->priv->sinks); - pulse->priv->sinks = NULL; - } - - if (pulse->priv->sink_inputs) { - g_hash_table_destroy (pulse->priv->sink_inputs); - pulse->priv->sink_inputs = NULL; - } - - if (pulse->priv->sources) { - g_hash_table_destroy (pulse->priv->sources); - pulse->priv->sources = NULL; - } - - if (pulse->priv->source_outputs) { - g_hash_table_destroy (pulse->priv->source_outputs); - pulse->priv->source_outputs = NULL; - } + g_hash_table_remove_all (pulse->priv->devices); + g_hash_table_remove_all (pulse->priv->sinks); + g_hash_table_remove_all (pulse->priv->sink_inputs); + g_hash_table_remove_all (pulse->priv->sources); + g_hash_table_remove_all (pulse->priv->source_outputs); g_clear_object (&pulse->priv->default_sink); g_clear_object (&pulse->priv->default_source); diff --git a/backends/pulse/pulse-stream.c b/backends/pulse/pulse-stream.c index 32e7047..54861bf 100644 --- a/backends/pulse/pulse-stream.c +++ b/backends/pulse/pulse-stream.c @@ -21,9 +21,9 @@ // - figure out whether functions should g_warning on errors // - distinguish MateMixer and Pulse variable names +#include <string.h> #include <glib.h> #include <glib-object.h> -#include <string.h> #include <libmatemixer/matemixer-device.h> #include <libmatemixer/matemixer-enums.h> |