summaryrefslogtreecommitdiff
path: root/backends/pulse/pulse-monitor.c
diff options
context:
space:
mode:
authorMichal Ratajsky <[email protected]>2014-07-05 01:35:00 +0200
committerMichal Ratajsky <[email protected]>2014-07-05 01:35:00 +0200
commit85070f3b97a3213d75a7bebf86ad973aaa21c55b (patch)
treefa3a29c788acd6233ca7a201ee9aaebffafa7d4c /backends/pulse/pulse-monitor.c
parent4793cbd87fed50678215b5dc1ba8e708fd4c9b58 (diff)
downloadlibmatemixer-85070f3b97a3213d75a7bebf86ad973aaa21c55b.tar.bz2
libmatemixer-85070f3b97a3213d75a7bebf86ad973aaa21c55b.tar.xz
Add ability to set monitor name and fix a few problems
Diffstat (limited to 'backends/pulse/pulse-monitor.c')
-rw-r--r--backends/pulse/pulse-monitor.c42
1 files changed, 37 insertions, 5 deletions
diff --git a/backends/pulse/pulse-monitor.c b/backends/pulse/pulse-monitor.c
index 4b83368..041f903 100644
--- a/backends/pulse/pulse-monitor.c
+++ b/backends/pulse/pulse-monitor.c
@@ -27,6 +27,7 @@ struct _PulseMonitorPrivate
pa_context *context;
pa_proplist *proplist;
pa_stream *stream;
+ gchar *name;
guint32 index_source;
guint32 index_sink_input;
gboolean enabled;
@@ -143,6 +144,11 @@ pulse_monitor_disable (PulseMonitor *monitor)
pa_stream_disconnect (monitor->priv->stream);
+ // XXX stream must be destroyed on disable, re-enabling does not work, this
+ // is just a quick temporary solution
+ pa_stream_unref (monitor->priv->stream);
+ monitor->priv->stream = NULL;
+
monitor->priv->enabled = FALSE;
}
@@ -182,17 +188,43 @@ pulse_monitor_update_index (PulseMonitor *monitor,
return TRUE;
}
+const gchar *
+pulse_monitor_get_name (PulseMonitor *monitor)
+{
+ g_return_val_if_fail (PULSE_IS_MONITOR (monitor), NULL);
+
+ return monitor->priv->name;
+}
+
+gboolean
+pulse_monitor_set_name (PulseMonitor *monitor, const gchar *name)
+{
+ g_return_val_if_fail (PULSE_IS_MONITOR (monitor), FALSE);
+
+ g_free (monitor->priv->name);
+
+ monitor->priv->name = g_strdup (name);
+ return TRUE;
+}
+
static gboolean
monitor_prepare (PulseMonitor *monitor)
{
- pa_sample_spec spec;
+ pa_sample_spec spec;
+ const gchar *name;
+
+ spec.channels = 1;
+ spec.format = PA_SAMPLE_FLOAT32;
+ spec.rate = 25;
- spec.channels = 1;
- spec.format = PA_SAMPLE_FLOAT32;
- spec.rate = 25;
+ if (monitor->priv->name != NULL)
+ name = monitor->priv->name;
+ else
+ name = "Peak detect";
monitor->priv->stream =
- pa_stream_new_with_proplist (monitor->priv->context, "Peak detect",
+ pa_stream_new_with_proplist (monitor->priv->context,
+ name,
&spec,
NULL,
monitor->priv->proplist);