[Xfce4-commits] [apps/xfce4-volumed-pulse] 01/01: Add support for the MicMute key
noreply at xfce.org
noreply at xfce.org
Sun Sep 11 16:22:11 CEST 2016
This is an automated email from the git hooks/post-receive script.
ochosi pushed a commit to branch master
in repository apps/xfce4-volumed-pulse.
commit 268bc81455ebd3b3a10a4295927776b28d3fd2fe
Author: Christian Pointner <equinox-i at launchpad.net>
Date: Sun Sep 11 16:21:13 2016 +0200
Add support for the MicMute key
---
src/main.c | 2 +
src/xvd_data_types.h | 3 +
src/xvd_keys.c | 75 ++++++++++++---
src/xvd_notify.c | 72 ++++++++++----
src/xvd_notify.h | 5 +
src/xvd_pulse.c | 258 ++++++++++++++++++++++++++++++++++++++++++++++++++-
src/xvd_pulse.h | 5 +
7 files changed, 383 insertions(+), 37 deletions(-)
diff --git a/src/main.c b/src/main.c
index 00f84e9..5f9a88d 100644
--- a/src/main.c
+++ b/src/main.c
@@ -101,11 +101,13 @@ xvd_instance_init(XvdInstance *i)
i->pa_main_loop = NULL;
i->pulse_context = NULL;
i->sink_index = -1;
+ i->source_index = -1;
i->chan = NULL;
i->loop = NULL;
#ifdef HAVE_LIBNOTIFY
i->gauge_notifications = FALSE;
i->notification = NULL;
+ i->notification_mic = NULL;
#endif
}
diff --git a/src/xvd_data_types.h b/src/xvd_data_types.h
index e1cdc14..dfd33d0 100644
--- a/src/xvd_data_types.h
+++ b/src/xvd_data_types.h
@@ -55,8 +55,10 @@ typedef struct {
pa_glib_mainloop *pa_main_loop;
pa_context *pulse_context;
guint32 sink_index;
+ guint32 source_index;
pa_cvolume volume;
int mute;
+ int mic_mute;
/* Xfconf vars */
XfconfChannel *chan;
@@ -66,6 +68,7 @@ typedef struct {
/* Libnotify vars */
gboolean gauge_notifications;
NotifyNotification* notification;
+ NotifyNotification* notification_mic;
#endif
/* Other Xvd vars */
diff --git a/src/xvd_keys.c b/src/xvd_keys.c
index af4254f..5da6604 100644
--- a/src/xvd_keys.c
+++ b/src/xvd_keys.c
@@ -32,9 +32,9 @@ static
void xvd_raise_handler (const char *keystring, void *Inst)
{
XvdInstance *xvd_inst = (XvdInstance *) Inst;
-
+
g_debug ("The RaiseVolume key was pressed.");
-
+
xvd_update_volume (xvd_inst,
XVD_UP);
}
@@ -43,9 +43,9 @@ static
void xvd_lower_handler (const char *keystring, void *Inst)
{
XvdInstance *xvd_inst = (XvdInstance *) Inst;
-
+
g_debug ("The LowerVolume key was pressed.");
-
+
xvd_update_volume (xvd_inst,
XVD_DOWN);
}
@@ -54,12 +54,22 @@ static
void xvd_mute_handler (const char *keystring, void *Inst)
{
XvdInstance *xvd_inst = (XvdInstance *) Inst;
-
- g_debug ("The LowerVolume key was pressed.");
-
+
+ g_debug ("The Mute key was pressed.");
+
xvd_toggle_mute (xvd_inst);
}
+static
+void xvd_mic_mute_handler (const char *keystring, void *Inst)
+{
+ XvdInstance *xvd_inst = (XvdInstance *) Inst;
+
+ g_debug ("The MicMute key was pressed.");
+
+ xvd_toggle_mic_mute (xvd_inst);
+}
+
void
xvd_keys_init(XvdInstance *Inst)
{
@@ -81,8 +91,8 @@ xvd_keys_init(XvdInstance *Inst)
keybinder_bind ("<Ctrl><Alt><Super>XF86AudioRaiseVolume", xvd_raise_handler, Inst);
keybinder_bind ("<Shift><Alt><Super>XF86AudioRaiseVolume", xvd_raise_handler, Inst);
keybinder_bind ("<Ctrl><Shift><Alt><Super>XF86AudioRaiseVolume", xvd_raise_handler, Inst);
-
-
+
+
keybinder_bind ("XF86AudioLowerVolume", xvd_lower_handler, Inst);
keybinder_bind ("<Ctrl>XF86AudioLowerVolume", xvd_lower_handler, Inst);
keybinder_bind ("<Alt>XF86AudioLowerVolume", xvd_lower_handler, Inst);
@@ -99,8 +109,8 @@ xvd_keys_init(XvdInstance *Inst)
keybinder_bind ("<Ctrl><Alt><Super>XF86AudioLowerVolume", xvd_lower_handler, Inst);
keybinder_bind ("<Shift><Alt><Super>XF86AudioLowerVolume", xvd_lower_handler, Inst);
keybinder_bind ("<Ctrl><Shift><Alt><Super>XF86AudioLowerVolume", xvd_lower_handler, Inst);
-
-
+
+
keybinder_bind ("XF86AudioMute", xvd_mute_handler, Inst);
keybinder_bind ("<Ctrl>XF86AudioMute", xvd_mute_handler, Inst);
keybinder_bind ("<Alt>XF86AudioMute", xvd_mute_handler, Inst);
@@ -117,6 +127,24 @@ xvd_keys_init(XvdInstance *Inst)
keybinder_bind ("<Ctrl><Alt><Super>XF86AudioMute", xvd_mute_handler, Inst);
keybinder_bind ("<Shift><Alt><Super>XF86AudioMute", xvd_mute_handler, Inst);
keybinder_bind ("<Ctrl><Shift><Alt><Super>XF86AudioMute", xvd_mute_handler, Inst);
+
+
+ keybinder_bind ("XF86AudioMicMute", xvd_mic_mute_handler, Inst);
+ keybinder_bind ("<Ctrl>XF86AudioMicMute", xvd_mic_mute_handler, Inst);
+ keybinder_bind ("<Alt>XF86AudioMicMute", xvd_mic_mute_handler, Inst);
+ keybinder_bind ("<Super>XF86AudioMicMute", xvd_mic_mute_handler, Inst);
+ keybinder_bind ("<Shift>XF86AudioMicMute", xvd_mic_mute_handler, Inst);
+ keybinder_bind ("<Ctrl><Shift>XF86AudioMicMute", xvd_mic_mute_handler, Inst);
+ keybinder_bind ("<Ctrl><Alt>XF86AudioMicMute", xvd_mic_mute_handler, Inst);
+ keybinder_bind ("<Ctrl><Super>XF86AudioMicMute", xvd_mic_mute_handler, Inst);
+ keybinder_bind ("<Alt><Shift>XF86AudioMicMute", xvd_mic_mute_handler, Inst);
+ keybinder_bind ("<Alt><Super>XF86AudioMicMute", xvd_mic_mute_handler, Inst);
+ keybinder_bind ("<Shift><Super>XF86AudioMicMute", xvd_mic_mute_handler, Inst);
+ keybinder_bind ("<Ctrl><Shift><Super>XF86AudioMicMute", xvd_mic_mute_handler, Inst);
+ keybinder_bind ("<Ctrl><Shift><Alt>XF86AudioMicMute", xvd_mic_mute_handler, Inst);
+ keybinder_bind ("<Ctrl><Alt><Super>XF86AudioMicMute", xvd_mic_mute_handler, Inst);
+ keybinder_bind ("<Shift><Alt><Super>XF86AudioMicMute", xvd_mic_mute_handler, Inst);
+ keybinder_bind ("<Ctrl><Shift><Alt><Super>XF86AudioMicMute", xvd_mic_mute_handler, Inst);
}
void
@@ -139,8 +167,8 @@ xvd_keys_release (XvdInstance *Inst)
keybinder_unbind ("<Ctrl><Alt><Super>XF86AudioRaiseVolume", xvd_raise_handler);
keybinder_unbind ("<Shift><Alt><Super>XF86AudioRaiseVolume", xvd_raise_handler);
keybinder_unbind ("<Ctrl><Shift><Alt><Super>XF86AudioRaiseVolume", xvd_raise_handler);
-
-
+
+
keybinder_unbind ("XF86AudioLowerVolume", xvd_lower_handler);
keybinder_unbind ("<Ctrl>XF86AudioLowerVolume", xvd_lower_handler);
keybinder_unbind ("<Alt>XF86AudioLowerVolume", xvd_lower_handler);
@@ -157,8 +185,8 @@ xvd_keys_release (XvdInstance *Inst)
keybinder_unbind ("<Ctrl><Alt><Super>XF86AudioLowerVolume", xvd_lower_handler);
keybinder_unbind ("<Shift><Alt><Super>XF86AudioLowerVolume", xvd_lower_handler);
keybinder_unbind ("<Ctrl><Shift><Alt><Super>XF86AudioLowerVolume", xvd_lower_handler);
-
-
+
+
keybinder_unbind ("XF86AudioMute", xvd_mute_handler);
keybinder_unbind ("<Ctrl>XF86AudioMute", xvd_mute_handler);
keybinder_unbind ("<Alt>XF86AudioMute", xvd_mute_handler);
@@ -176,4 +204,21 @@ xvd_keys_release (XvdInstance *Inst)
keybinder_unbind ("<Shift><Alt><Super>XF86AudioMute", xvd_mute_handler);
keybinder_unbind ("<Ctrl><Shift><Alt><Super>XF86AudioMute", xvd_mute_handler);
+
+ keybinder_unbind ("XF86AudioMicMute", xvd_mic_mute_handler);
+ keybinder_unbind ("<Ctrl>XF86AudioMicMute", xvd_mic_mute_handler);
+ keybinder_unbind ("<Alt>XF86AudioMicMute", xvd_mic_mute_handler);
+ keybinder_unbind ("<Super>XF86AudioMicMute", xvd_mic_mute_handler);
+ keybinder_unbind ("<Shift>XF86AudioMicMute", xvd_mic_mute_handler);
+ keybinder_unbind ("<Ctrl><Shift>XF86AudioMicMute", xvd_mic_mute_handler);
+ keybinder_unbind ("<Ctrl><Alt>XF86AudioMicMute", xvd_mic_mute_handler);
+ keybinder_unbind ("<Ctrl><Super>XF86AudioMicMute", xvd_mic_mute_handler);
+ keybinder_unbind ("<Alt><Shift>XF86AudioMicMute", xvd_mic_mute_handler);
+ keybinder_unbind ("<Alt><Super>XF86AudioMicMute", xvd_mic_mute_handler);
+ keybinder_unbind ("<Shift><Super>XF86AudioMicMute", xvd_mic_mute_handler);
+ keybinder_unbind ("<Ctrl><Shift><Super>XF86AudioMicMute", xvd_mic_mute_handler);
+ keybinder_unbind ("<Ctrl><Shift><Alt>XF86AudioMicMute", xvd_mic_mute_handler);
+ keybinder_unbind ("<Ctrl><Alt><Super>XF86AudioMicMute", xvd_mic_mute_handler);
+ keybinder_unbind ("<Shift><Alt><Super>XF86AudioMicMute", xvd_mic_mute_handler);
+ keybinder_unbind ("<Ctrl><Shift><Alt><Super>XF86AudioMicMute", xvd_mic_mute_handler);
}
diff --git a/src/xvd_notify.c b/src/xvd_notify.c
index 98f0acd..6760c1f 100644
--- a/src/xvd_notify.c
+++ b/src/xvd_notify.c
@@ -29,9 +29,9 @@
#include "xvd_notify.h"
-void
-xvd_notify_notification(XvdInstance *Inst,
- gchar* icon,
+void
+xvd_notify_notification(XvdInstance *Inst,
+ gchar* icon,
gint value)
{
GError* error = NULL;
@@ -45,14 +45,14 @@ xvd_notify_notification(XvdInstance *Inst,
// TRANSLATORS: %d is the volume displayed as a percent, and %c is replaced by '%'. If it doesn't fit in your locale feel free to file a bug.
title = g_strdup_printf ("Volume is at %d%c", value, '%');
}
-
+
notify_notification_update (Inst->notification,
title,
NULL,
icon);
-
+
g_free (title);
-
+
if (Inst->gauge_notifications) {
notify_notification_set_hint_int32 (Inst->notification,
"value",
@@ -61,7 +61,7 @@ xvd_notify_notification(XvdInstance *Inst,
"x-canonical-private-synchronous",
"");
}
-
+
if (!notify_notification_show (Inst->notification, &error))
{
g_warning ("Error while sending notification : %s\n", error->message);
@@ -69,7 +69,7 @@ xvd_notify_notification(XvdInstance *Inst,
}
}
-void
+void
xvd_notify_volume_notification(XvdInstance *Inst)
{
gint vol = xvd_get_readable_volume (&Inst->volume);
@@ -86,7 +86,7 @@ xvd_notify_volume_notification(XvdInstance *Inst)
void
xvd_notify_overshoot_notification(XvdInstance *Inst)
{
- xvd_notify_notification (Inst,
+ xvd_notify_notification (Inst,
(Inst->mute) ? "audio-volume-muted" : "audio-volume-high",
(Inst->gauge_notifications) ? 101 : 100);
}
@@ -94,22 +94,53 @@ xvd_notify_overshoot_notification(XvdInstance *Inst)
void
xvd_notify_undershoot_notification(XvdInstance *Inst)
{
- xvd_notify_notification (Inst,
+ xvd_notify_notification (Inst,
(Inst->mute) ? "audio-volume-muted" : "audio-volume-low",
(Inst->gauge_notifications) ? -1 : 0);
}
-void
-xvd_notify_init(XvdInstance *Inst,
+void
+xvd_notify_mic_notification(XvdInstance *Inst)
+{
+ GError* error = NULL;
+ gchar* title = NULL;
+ gchar* icon = NULL;
+
+ title = g_strdup_printf ("Microphone is %s", (Inst->mic_mute) ? "muted" : "active");
+ icon = (Inst->mic_mute) ? "microphone-sensitivity-muted" : "microphone-sensitivity-high";
+
+ notify_notification_update (Inst->notification_mic,
+ title,
+ NULL,
+ icon);
+
+ g_free (title);
+
+ if (Inst->gauge_notifications) {
+ notify_notification_set_hint_int32 (Inst->notification_mic,
+ LAYOUT_ICON_ONLY,
+ 1);
+ }
+
+ if (!notify_notification_show (Inst->notification_mic, &error))
+ {
+ g_warning ("Error while sending mic notification : %s\n", error->message);
+ g_error_free (error);
+ }
+
+}
+
+void
+xvd_notify_init(XvdInstance *Inst,
const gchar *appname)
{
GList *caps_list = NULL;
Inst->gauge_notifications = TRUE;
notify_init (appname);
-
+
caps_list = notify_get_server_caps ();
-
+
if (caps_list)
{
GList *node;
@@ -117,29 +148,34 @@ xvd_notify_init(XvdInstance *Inst,
node = g_list_find_custom (caps_list, LAYOUT_ICON_ONLY, (GCompareFunc) g_strcmp0);
if (!node)
Inst->gauge_notifications = FALSE;
-
+
/* node = g_list_find_custom (caps_list, SYNCHRONOUS, (GCompareFunc) g_strcmp0);*/
/* if (!node)*/
/* Inst->gauge_notifications = FALSE;*/
-
+
g_list_free (caps_list);
}
-
+
#ifdef NOTIFY_CHECK_VERSION
#if NOTIFY_CHECK_VERSION (0, 7, 0)
Inst->notification = notify_notification_new ("Xfce4-Volumed", NULL, NULL);
+ Inst->notification_mic = notify_notification_new ("Xfce4-Volumed", NULL, NULL);
#else
Inst->notification = notify_notification_new ("Xfce4-Volumed", NULL, NULL, NULL);
+ Inst->notification_mic = notify_notification_new ("Xfce4-Volumed", NULL, NULL, NULL);
#endif
#else
Inst->notification = notify_notification_new ("Xfce4-Volumed", NULL, NULL, NULL);
+ Inst->notification_mic = notify_notification_new ("Xfce4-Volumed", NULL, NULL, NULL);
#endif
}
-void
+void
xvd_notify_uninit (XvdInstance *Inst)
{
g_object_unref (G_OBJECT (Inst->notification));
Inst->notification = NULL;
+ g_object_unref (G_OBJECT (Inst->notification_mic));
+ Inst->notification_mic = NULL;
notify_uninit ();
}
diff --git a/src/xvd_notify.h b/src/xvd_notify.h
index 25923ad..ea78d01 100644
--- a/src/xvd_notify.h
+++ b/src/xvd_notify.h
@@ -46,6 +46,11 @@ xvd_notify_overshoot_notification(XvdInstance *Inst);
void
xvd_notify_undershoot_notification(XvdInstance *Inst);
+
+void
+xvd_notify_mic_notification(XvdInstance *Inst);
+
+
void
xvd_notify_init(XvdInstance *Inst,
const gchar *appname);
diff --git a/src/xvd_pulse.c b/src/xvd_pulse.c
index a5678b0..67a1c17 100644
--- a/src/xvd_pulse.c
+++ b/src/xvd_pulse.c
@@ -39,14 +39,20 @@
static pa_cvolume old_volume;
static int old_mute;
+static int old_mic_mute;
#ifdef HAVE_LIBNOTIFY
static void xvd_notify_volume_callback (pa_context *c,
int success,
void *userdata);
+
+static void xvd_notify_mic_callback (pa_context *c,
+ int success,
+ void *userdata);
#else
#define xvd_notify_volume_callback NULL
+#define xvd_notify_mic_callback NULL
#endif
static void xvd_context_state_callback (pa_context *c,
@@ -76,6 +82,21 @@ static void xvd_update_sink_callback (pa_context *c,
int eol,
void *userdata);
+static void xvd_default_source_info_callback (pa_context *c,
+ const pa_source_info *info,
+ int eol,
+ void *userdata);
+
+static void xvd_source_info_callback (pa_context *c,
+ const pa_source_info *source,
+ int eol,
+ void *userdata);
+
+static void xvd_update_source_callback (pa_context *c,
+ const pa_source_info *info,
+ int eol,
+ void *userdata);
+
static gboolean xvd_connect_to_pulse (XvdInstance *i);
@@ -201,6 +222,47 @@ xvd_toggle_mute (XvdInstance *i)
}
+void
+xvd_toggle_mic_mute (XvdInstance *i)
+{
+ pa_operation *op = NULL;
+
+ if (!i || !i->pulse_context)
+ {
+ g_warning ("xvd_toggle_mic_mute: pulseaudio context is null");
+ return;
+ }
+
+ if (pa_context_get_state (i->pulse_context) != PA_CONTEXT_READY)
+ {
+ g_warning ("xvd_toggle_mic_mute: pulseaudio context isn't ready");
+ return;
+ }
+
+ if (i->source_index == PA_INVALID_INDEX)
+ {
+ g_warning ("xvd_toggle_mic_mute: undefined source");
+ return;
+ }
+
+ /* backup existing mute and update */
+ i->mic_mute = !(old_mic_mute = i->mic_mute);
+
+ op = pa_context_set_source_mute_by_index (i->pulse_context,
+ i->source_index,
+ i->mic_mute,
+ xvd_notify_mic_callback,
+ i);
+
+ if (!op)
+ {
+ g_warning ("xvd_toggle_mic_mute: failed");
+ return;
+ }
+ pa_operation_unref (op);
+}
+
+
gint
xvd_get_readable_volume (const pa_cvolume *vol)
{
@@ -259,13 +321,13 @@ xvd_notify_volume_callback (pa_context *c,
if (!c || !userdata)
{
- g_warning ("xvd_notify_volume_update: invalid argument");
+ g_warning ("xvd_notify_volume_callback: invalid argument");
return;
}
if (!success)
{
- g_warning ("xvd_notify_volume_update: operation failed, %s",
+ g_warning ("xvd_notify_volume_callback: operation failed, %s",
pa_strerror (pa_context_errno (c)));
return;
}
@@ -290,6 +352,39 @@ xvd_notify_volume_callback (pa_context *c,
else
xvd_notify_volume_notification (i);
}
+
+
+/**
+ * Shows Mic mute status notification
+ */
+static void
+xvd_notify_mic_callback (pa_context *c,
+ int success,
+ void *userdata)
+{
+ XvdInstance *i = (XvdInstance *) userdata;
+ guint32 r_oldv, r_curv;
+
+ if (!c || !userdata)
+ {
+ g_warning ("xvd_notify_mic_callback: invalid argument");
+ return;
+ }
+
+ if (!success)
+ {
+ g_warning ("xvd_notify_mic_callback: operation failed, %s",
+ pa_strerror (pa_context_errno (c)));
+ return;
+ }
+
+ /* the sink was (un)muted */
+ if (old_mic_mute != i->mic_mute)
+ {
+ xvd_notify_mic_notification (i);
+ return;
+ }
+}
#endif
@@ -335,6 +430,28 @@ xvd_subscribed_events_callback (pa_context *c,
pa_operation_unref (op);
}
break;
+ /* change on a source, re-fetch it */
+ case PA_SUBSCRIPTION_EVENT_SOURCE:
+ if (i->source_index != index)
+ return;
+
+ if ((t & PA_SUBSCRIPTION_EVENT_TYPE_MASK) == PA_SUBSCRIPTION_EVENT_REMOVE)
+ i->source_index = PA_INVALID_INDEX;
+ else
+ {
+ op = pa_context_get_source_info_by_index (c,
+ index,
+ xvd_update_source_callback,
+ userdata);
+
+ if (!op)
+ {
+ g_warning ("xvd_subscribed_events_callback: failed to get source info");
+ return;
+ }
+ pa_operation_unref (op);
+ }
+ break;
/* change on the server, re-fetch everything */
case PA_SUBSCRIPTION_EVENT_SERVER:
op = pa_context_get_server_info (c,
@@ -360,7 +477,7 @@ xvd_context_state_callback (pa_context *c,
void *userdata)
{
XvdInstance *i = (XvdInstance *) userdata;
- pa_subscription_mask_t mask = PA_SUBSCRIPTION_MASK_SINK | PA_SUBSCRIPTION_MASK_SERVER;
+ pa_subscription_mask_t mask = PA_SUBSCRIPTION_MASK_SINK | PA_SUBSCRIPTION_MASK_SOURCE | PA_SUBSCRIPTION_MASK_SERVER;
pa_operation *op = NULL;
if (!c || !userdata)
@@ -390,6 +507,7 @@ xvd_context_state_callback (pa_context *c,
case PA_CONTEXT_FAILED:
g_critical("xvd_context_state_callback: The connection failed or was disconnected, is PulseAudio Daemon running?");
i->sink_index = PA_INVALID_INDEX;
+ i->source_index = PA_INVALID_INDEX;
break;
case PA_CONTEXT_READY:
g_debug ("xvd_context_state_callback: The connection is established, the context is ready to execute operations");
@@ -397,7 +515,7 @@ xvd_context_state_callback (pa_context *c,
xvd_subscribed_events_callback,
userdata);
- /* subscribe to sink and server changes, we don't need more */
+ /* subscribe to sink/source and server changes, we don't need more */
op = pa_context_subscribe (c,
mask,
NULL,
@@ -476,6 +594,36 @@ xvd_server_info_callback (pa_context *c,
}
pa_operation_unref (op);
}
+
+ if (info->default_source_name)
+ {
+ op = pa_context_get_source_info_by_name (c,
+ info->default_source_name,
+ xvd_default_source_info_callback,
+ userdata);
+
+ if (!op)
+ {
+ g_warning("xvd_server_info_callback: pa_context_get_source_info_by_name() failed");
+ return;
+ }
+ pa_operation_unref (op);
+ }
+ else
+ {
+ /* when PulseAudio doesn't set a default source, look at all of them
+ and hope to find a usable one */
+ op = pa_context_get_source_info_list(c,
+ xvd_source_info_callback,
+ userdata);
+
+ if (!op)
+ {
+ g_warning("xvd_server_info_callback: pa_context_get_source_info_list() failed");
+ return;
+ }
+ pa_operation_unref (op);
+ }
}
@@ -584,3 +732,105 @@ xvd_update_sink_callback (pa_context *c,
#endif
}
}
+
+
+/**
+ * Callback to retrieve the infos of a given source.
+ */
+static void
+xvd_source_info_callback (pa_context *c,
+ const pa_source_info *source,
+ int eol,
+ void *userdata)
+{
+ XvdInstance *i = (XvdInstance *) userdata;
+
+ /* detect the end of the list */
+ if (eol > 0)
+ return;
+ else
+ {
+ if (!userdata || !source)
+ {
+ g_warning ("xvd_source_info_callback: invalid argument");
+ return;
+ }
+
+ /* If there's no default source, try to use this one */
+ if (i->source_index == PA_INVALID_INDEX
+ /* indicator-sound does that check */
+ && g_ascii_strncasecmp ("auto_null", source->name, 9) != 0)
+ {
+ i->source_index = source->index;
+ old_mic_mute = i->mic_mute = source->mute;
+ }
+ }
+}
+
+
+/**
+ * Callback to retrieve the infos of the default source.
+ */
+static void
+xvd_default_source_info_callback (pa_context *c,
+ const pa_source_info *info,
+ int eol,
+ void *userdata)
+{
+ XvdInstance *i = (XvdInstance *) userdata;
+
+ /* detect the end of the list */
+ if (eol > 0)
+ return;
+ else
+ {
+ if (!userdata || !info)
+ {
+ g_warning ("xvd_default_source_info_callback: invalid argument");
+ return;
+ }
+
+ /* is this a new default source? */
+ if (i->source_index != info->index)
+ {
+ i->source_index = info->index;
+ old_mic_mute = i->mic_mute = info->mute;
+ }
+ }
+}
+
+
+/**
+ * Callback for source changes reported by PulseAudio.
+ */
+static void
+xvd_update_source_callback (pa_context *c,
+ const pa_source_info *info,
+ int eol,
+ void *userdata)
+{
+ XvdInstance *i = (XvdInstance *) userdata;
+
+ /* detect the end of the list */
+ if (eol > 0)
+ return;
+ else
+ {
+ if (!c || !userdata || !info)
+ {
+ g_warning ("xvd_update_source_callback: invalid argument");
+ return;
+ }
+
+ /* re-fetch infos from PulseAudio */
+ i->source_index = info->index;
+ old_mic_mute = i->mic_mute;
+ i->mic_mute = info->mute;
+
+#ifdef HAVE_LIBNOTIFY
+ /* notify user of the possible changes */
+ if (old_mic_mute != i->mic_mute)
+ xvd_notify_mic_callback (c, 1, i);
+#endif
+ }
+}
diff --git a/src/xvd_pulse.h b/src/xvd_pulse.h
index 94fb118..4e0c3b3 100644
--- a/src/xvd_pulse.h
+++ b/src/xvd_pulse.h
@@ -47,6 +47,11 @@ void xvd_update_volume (XvdInstance *i,
void xvd_toggle_mute (XvdInstance *i);
/**
+ * Toggle mic mute.
+ */
+void xvd_toggle_mic_mute (XvdInstance *i);
+
+/**
* Returns a percentage volume (i.e. between 0 and 100, usable on notifications)
*/
gint xvd_get_readable_volume (const pa_cvolume *vol);
--
To stop receiving notification emails like this one, please contact
the administrator of this repository.
More information about the Xfce4-commits
mailing list