aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--src/empathy-mic-monitor.c58
-rw-r--r--src/empathy-mic-monitor.h5
2 files changed, 63 insertions, 0 deletions
diff --git a/src/empathy-mic-monitor.c b/src/empathy-mic-monitor.c
index 5a90e1718..2e1171b14 100644
--- a/src/empathy-mic-monitor.c
+++ b/src/empathy-mic-monitor.c
@@ -564,3 +564,61 @@ empathy_mic_monitor_get_current_mic_finish (EmpathyMicMonitor *self,
return GPOINTER_TO_UINT (
g_simple_async_result_get_op_res_gpointer (simple));
}
+
+/* operation: get default */
+static void
+empathy_mic_monitor_get_default_cb (pa_context *context,
+ const pa_server_info *info,
+ void *userdata)
+{
+ GSimpleAsyncResult *result = userdata;
+
+ /* TODO: it would be nice in future, for consistency, if this gave
+ * the source idx instead of the name. */
+ g_simple_async_result_set_op_res_gpointer (result,
+ g_strdup (info->default_source_name), g_free);
+ g_simple_async_result_complete (result);
+ g_object_unref (result);
+}
+
+static void
+operation_get_default (EmpathyMicMonitor *self,
+ GSimpleAsyncResult *result)
+{
+ EmpathyMicMonitorPrivate *priv = self->priv;
+
+ g_assert_cmpuint (pa_context_get_state (priv->context), ==, PA_CONTEXT_READY);
+
+ /* unset this so we can use it in the cb */
+ g_simple_async_result_set_op_res_gpointer (result, NULL, NULL);
+
+ pa_context_get_server_info (priv->context, empathy_mic_monitor_get_default_cb,
+ result);
+}
+
+void
+empathy_mic_monitor_get_default_async (EmpathyMicMonitor *self,
+ GAsyncReadyCallback callback,
+ gpointer user_data)
+{
+ EmpathyMicMonitorPrivate *priv = self->priv;
+ Operation *operation;
+ GSimpleAsyncResult *simple;
+
+ simple = g_simple_async_result_new (G_OBJECT (self), callback, user_data,
+ empathy_mic_monitor_get_default_async);
+
+ operation = operation_new (operation_get_default, simple);
+ g_queue_push_tail (priv->operations, operation);
+
+ operations_run (self);
+}
+
+const gchar *
+empathy_mic_monitor_get_default_finish (EmpathyMicMonitor *self,
+ GAsyncResult *result,
+ GError **error)
+{
+ empathy_implement_finish_return_pointer (self,
+ empathy_mic_monitor_get_default_async);
+}
diff --git a/src/empathy-mic-monitor.h b/src/empathy-mic-monitor.h
index 69106c55d..5e2a7c504 100644
--- a/src/empathy-mic-monitor.h
+++ b/src/empathy-mic-monitor.h
@@ -75,6 +75,11 @@ void empathy_mic_monitor_get_current_mic_async (EmpathyMicMonitor *self,
guint empathy_mic_monitor_get_current_mic_finish (EmpathyMicMonitor *self,
GAsyncResult *result, GError **error);
+void empathy_mic_monitor_get_default_async (EmpathyMicMonitor *self,
+ GAsyncReadyCallback callback, gpointer user_data);
+const gchar * empathy_mic_monitor_get_default_finish (EmpathyMicMonitor *self,
+ GAsyncResult *result, GError **error);
+
G_END_DECLS
#endif /* __EMPATHY_MIC_MONITOR_H__ */