summaryrefslogtreecommitdiff
path: root/backends
diff options
context:
space:
mode:
authorMichal Ratajsky <[email protected]>2016-01-09 19:54:30 +0100
committerraveit65 <[email protected]>2017-02-21 11:55:59 +0100
commitcf087148400ad5510bb781db2516962b19768f4f (patch)
tree320ea02a4027a9b716579929c0a53b8fff4df5cb /backends
parent21f2fbad0fb9e453adcb794eca3ab82f1a39bbf3 (diff)
downloadlibmatemixer-cf087148400ad5510bb781db2516962b19768f4f.tar.bz2
libmatemixer-cf087148400ad5510bb781db2516962b19768f4f.tar.xz
oss: Make sure device stream list is always correct
Diffstat (limited to 'backends')
-rw-r--r--backends/oss/oss-device.c50
1 files changed, 14 insertions, 36 deletions
diff --git a/backends/oss/oss-device.c b/backends/oss/oss-device.c
index dc60ebf..d408c80 100644
--- a/backends/oss/oss-device.c
+++ b/backends/oss/oss-device.c
@@ -198,8 +198,6 @@ static guint create_poll_source (OssDevice *device,
OssPollMode mode);
static guint create_poll_restore_source (OssDevice *device);
-static void free_stream_list (OssDevice *device);
-
static gint compare_stream_control_devnum (gconstpointer a,
gconstpointer b);
@@ -249,8 +247,6 @@ oss_device_dispose (GObject *object)
g_clear_object (&device->priv->input);
g_clear_object (&device->priv->output);
- free_stream_list (device);
-
G_OBJECT_CLASS (oss_device_parent_class)->dispose (object);
}
@@ -364,12 +360,11 @@ oss_device_close (OssDevice *device)
/* Make each stream remove its controls and switch */
if (device->priv->input != NULL) {
- oss_stream_remove_all (device->priv->input);
- free_stream_list (device);
-
stream = device->priv->input;
+ oss_stream_remove_all (stream);
+ device->priv->streams = g_list_remove (device->priv->streams, stream);
- /* Makes the stream getter return NULL when the signal is emitted */
+ /* Make the stream getter return NULL when the signal is emitted */
device->priv->input = NULL;
g_signal_emit_by_name (G_OBJECT (device),
"stream-removed",
@@ -379,12 +374,11 @@ oss_device_close (OssDevice *device)
}
if (device->priv->output != NULL) {
- oss_stream_remove_all (device->priv->output);
- free_stream_list (device);
-
stream = device->priv->output;
+ oss_stream_remove_all (stream);
+ device->priv->streams = g_list_remove (device->priv->streams, stream);
- /* Makes the stream getter return NULL when the signal is emitted */
+ /* Make the stream getter return NULL when the signal is emitted */
device->priv->output = NULL;
g_signal_emit_by_name (G_OBJECT (device),
"stream-removed",
@@ -471,14 +465,20 @@ oss_device_load (OssDevice *device)
} else
g_clear_object (&device->priv->output);
- if (device->priv->input != NULL)
+ if (device->priv->input != NULL) {
+ device->priv->streams = g_list_append (device->priv->streams,
+ device->priv->input);
g_signal_emit_by_name (G_OBJECT (device),
"stream-added",
MATE_MIXER_STREAM (device->priv->input));
- if (device->priv->output != NULL)
+ }
+ if (device->priv->output != NULL) {
+ device->priv->streams = g_list_append (device->priv->streams,
+ device->priv->output);
g_signal_emit_by_name (G_OBJECT (device),
"stream-added",
MATE_MIXER_STREAM (device->priv->output));
+ }
/*
* See if we can use the modify_counter field to optimize polling.
@@ -545,16 +545,6 @@ oss_device_list_streams (MateMixerDevice *mmd)
g_return_val_if_fail (OSS_IS_DEVICE (mmd), NULL);
device = OSS_DEVICE (mmd);
-
- if (device->priv->streams == NULL) {
- if (device->priv->output != NULL)
- device->priv->streams = g_list_prepend (device->priv->streams,
- g_object_ref (device->priv->output));
-
- if (device->priv->input != NULL)
- device->priv->streams = g_list_prepend (device->priv->streams,
- g_object_ref (device->priv->input));
- }
return device->priv->streams;
}
@@ -775,18 +765,6 @@ create_poll_restore_source (OssDevice *device)
return tag;
}
-static void
-free_stream_list (OssDevice *device)
-{
- /* This function is called each time the stream list changes */
- if (device->priv->streams == NULL)
- return;
-
- g_list_free_full (device->priv->streams, g_object_unref);
-
- device->priv->streams = NULL;
-}
-
static gint
compare_stream_control_devnum (gconstpointer a, gconstpointer b)
{