summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--backends/pulse/pulse-stream.c64
-rw-r--r--configure.ac2
-rw-r--r--libmatemixer/matemixer-stream.c18
-rw-r--r--libmatemixer/matemixer-stream.h5
4 files changed, 77 insertions, 12 deletions
diff --git a/backends/pulse/pulse-stream.c b/backends/pulse/pulse-stream.c
index 05783e6..49001b9 100644
--- a/backends/pulse/pulse-stream.c
+++ b/backends/pulse/pulse-stream.c
@@ -15,6 +15,12 @@
* License along with this library; if not, see <http://www.gnu.org/licenses/>.
*/
+// XXX
+// - make sure all functions work correctly with flags
+// - make sure all functions notify
+// - figure out whether functions should g_warning on errors
+// - distinguish MateMixer and Pulse variable names
+
#include <glib.h>
#include <glib-object.h>
#include <string.h>
@@ -45,8 +51,6 @@ struct _PulseStreamPrivate
pa_volume_t volume_base;
guint32 volume_steps;
pa_channel_map channel_map;
- gdouble balance;
- gdouble fade;
GList *ports;
MateMixerPort *port;
PulseConnection *connection;
@@ -141,11 +145,12 @@ static void stream_monitor_value (PulseMonitor
static const GList * stream_list_ports (MateMixerStream *stream);
static MateMixerPort * stream_get_active_port (MateMixerStream *stream);
static gboolean stream_set_active_port (MateMixerStream *stream,
- const gchar *port);
+ const gchar *port_name);
static gint64 stream_get_min_volume (MateMixerStream *stream);
static gint64 stream_get_max_volume (MateMixerStream *stream);
static gint64 stream_get_normal_volume (MateMixerStream *stream);
+static gint64 stream_get_base_volume (MateMixerStream *stream);
static gboolean stream_set_cvolume (MateMixerStream *stream,
pa_cvolume *volume);
@@ -190,6 +195,7 @@ mate_mixer_stream_interface_init (MateMixerStreamInterface *iface)
iface->get_min_volume = stream_get_min_volume;
iface->get_max_volume = stream_get_max_volume;
iface->get_normal_volume = stream_get_normal_volume;
+ iface->get_base_volume = stream_get_base_volume;
}
static void
@@ -549,8 +555,6 @@ pulse_stream_update_active_port (PulseStream *stream, const gchar *port_name)
return TRUE;
}
-// XXX check these functions according to flags
-
static const gchar *
stream_get_name (MateMixerStream *stream)
{
@@ -1001,13 +1005,38 @@ stream_get_active_port (MateMixerStream *stream)
}
static gboolean
-stream_set_active_port (MateMixerStream *stream, const gchar *port)
+stream_set_active_port (MateMixerStream *stream, const gchar *port_name)
{
+ PulseStream *pulse;
+ GList *list;
+ MateMixerPort *port = NULL;
+
g_return_val_if_fail (PULSE_IS_STREAM (stream), FALSE);
- g_return_val_if_fail (port != NULL, FALSE);
+ g_return_val_if_fail (port_name != NULL, FALSE);
+
+ pulse = PULSE_STREAM (stream);
+ list = pulse->priv->ports;
+ while (list) {
+ port = MATE_MIXER_PORT (list->data);
- // XXX save and notify
- return PULSE_STREAM_GET_CLASS (stream)->set_active_port (stream, port);
+ if (!g_strcmp0 (mate_mixer_port_get_name (port), port_name))
+ break;
+
+ port = NULL;
+ list = list->next;
+ }
+
+ if (port == NULL ||
+ PULSE_STREAM_GET_CLASS (stream)->set_active_port (stream, port_name) == FALSE)
+ return FALSE;
+
+ if (pulse->priv->port)
+ g_object_unref (pulse->priv->port);
+
+ pulse->priv->port = g_object_ref (port);
+
+ g_object_notify (G_OBJECT (stream), "active-port");
+ return TRUE;
}
static gint64
@@ -1028,6 +1057,23 @@ stream_get_normal_volume (MateMixerStream *stream)
return (gint64) PA_VOLUME_NORM;
}
+static gint64
+stream_get_base_volume (MateMixerStream *stream)
+{
+ PulseStream *pulse;
+
+ g_return_val_if_fail (PULSE_IS_STREAM (stream), 0);
+
+ pulse = PULSE_STREAM (stream);
+
+ /* The base volume as set by PulseAudio will never be 0, so treat 0 as a
+ * non-set value and use a default instead */
+ if (pulse->priv->volume_base)
+ return pulse->priv->volume_base;
+
+ return (gint64) PA_VOLUME_NORM;
+}
+
static gboolean
stream_set_cvolume (MateMixerStream *stream, pa_cvolume *volume)
{
diff --git a/configure.ac b/configure.ac
index ab68cba..844d3e7 100644
--- a/configure.ac
+++ b/configure.ac
@@ -41,7 +41,7 @@ AC_PROG_INSTALL
# Checks for header files.
AC_HEADER_STDC
-AC_CHECK_HEADERS([stdlib.h string.h math.h sys/types.h unistd.h locale.h])
+AC_CHECK_HEADERS([string.h math.h sys/types.h unistd.h locale.h])
# =======================================================================
# Libtool
diff --git a/libmatemixer/matemixer-stream.c b/libmatemixer/matemixer-stream.c
index fbf9293..b845d48 100644
--- a/libmatemixer/matemixer-stream.c
+++ b/libmatemixer/matemixer-stream.c
@@ -15,6 +15,9 @@
* License along with this library; if not, see <http://www.gnu.org/licenses/>.
*/
+// XXX
+// consider using guint for volumes, but see the other backends first
+
#include <glib.h>
#include <glib-object.h>
@@ -714,3 +717,18 @@ mate_mixer_stream_get_normal_volume (MateMixerStream *stream)
return 0;
}
+
+gint64
+mate_mixer_stream_get_base_volume (MateMixerStream *stream)
+{
+ MateMixerStreamInterface *iface;
+
+ g_return_val_if_fail (MATE_MIXER_IS_STREAM (stream), 0);
+
+ iface = MATE_MIXER_STREAM_GET_INTERFACE (stream);
+
+ if (iface->get_base_volume)
+ return iface->get_base_volume (stream);
+
+ return 0;
+}
diff --git a/libmatemixer/matemixer-stream.h b/libmatemixer/matemixer-stream.h
index 7b202b8..a9933e1 100644
--- a/libmatemixer/matemixer-stream.h
+++ b/libmatemixer/matemixer-stream.h
@@ -19,7 +19,6 @@
#define MATEMIXER_STREAM_H
#include <math.h>
-#include <stdlib.h>
#include <glib.h>
#include <glib-object.h>
@@ -32,7 +31,7 @@ G_BEGIN_DECLS
#ifdef INFINITY
#define MATE_MIXER_INFINITY INFINITY
#else
-#define MATE_MIXER_INFINITY (atof ("inf"))
+#define MATE_MIXER_INFINITY G_MAXDOUBLE
#endif
#define MATE_MIXER_TYPE_STREAM \
@@ -109,6 +108,7 @@ struct _MateMixerStreamInterface
gint64 (*get_min_volume) (MateMixerStream *stream);
gint64 (*get_max_volume) (MateMixerStream *stream);
gint64 (*get_normal_volume) (MateMixerStream *stream);
+ gint64 (*get_base_volume) (MateMixerStream *stream);
/* Signals */
void (*monitor_value) (MateMixerStream *stream,
@@ -192,6 +192,7 @@ gboolean mate_mixer_stream_set_active_port (MateMixerStre
gint64 mate_mixer_stream_get_min_volume (MateMixerStream *stream);
gint64 mate_mixer_stream_get_max_volume (MateMixerStream *stream);
gint64 mate_mixer_stream_get_normal_volume (MateMixerStream *stream);
+gint64 mate_mixer_stream_get_base_volume (MateMixerStream *stream);
G_END_DECLS