[empathy] mic-monitor: add set_default function
- From: Jonny Lamb <jonnylamb src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [empathy] mic-monitor: add set_default function
- Date: Thu, 18 Aug 2011 15:34:42 +0000 (UTC)
commit fb90ae1ed068d4f0f0972b886cb8d1f643bf2f9f
Author: Jonny Lamb <jonny lamb collabora co uk>
Date: Wed Aug 17 16:28:39 2011 +0100
mic-monitor: add set_default function
Signed-off-by: Jonny Lamb <jonny lamb collabora co uk>
src/empathy-mic-monitor.c | 64 +++++++++++++++++++++++++++++++++++++++++++++
src/empathy-mic-monitor.h | 5 +++
2 files changed, 69 insertions(+), 0 deletions(-)
---
diff --git a/src/empathy-mic-monitor.c b/src/empathy-mic-monitor.c
index 2e1171b..1628828 100644
--- a/src/empathy-mic-monitor.c
+++ b/src/empathy-mic-monitor.c
@@ -622,3 +622,67 @@ empathy_mic_monitor_get_default_finish (EmpathyMicMonitor *self,
empathy_implement_finish_return_pointer (self,
empathy_mic_monitor_get_default_async);
}
+
+/* operation: set default */
+static void
+empathy_mic_monitor_set_default_cb (pa_context *c,
+ int success,
+ void *userdata)
+{
+ GSimpleAsyncResult *result = userdata;
+
+ if (!success)
+ {
+ g_simple_async_result_set_error (result,
+ G_IO_ERROR, G_IO_ERROR_FAILED,
+ "The operation failed for an unknown reason");
+ }
+
+ g_simple_async_result_complete (result);
+ g_object_unref (result);
+}
+
+static void
+operation_set_default (EmpathyMicMonitor *self,
+ GSimpleAsyncResult *result)
+{
+ EmpathyMicMonitorPrivate *priv = self->priv;
+ gchar *name;
+
+ g_assert_cmpuint (pa_context_get_state (priv->context), ==, PA_CONTEXT_READY);
+
+ name = g_simple_async_result_get_op_res_gpointer (result);
+
+ pa_context_set_default_source (priv->context, name,
+ empathy_mic_monitor_set_default_cb, result);
+}
+
+void
+empathy_mic_monitor_set_default_async (EmpathyMicMonitor *self,
+ const gchar *name,
+ 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_set_default_async);
+
+ g_simple_async_result_set_op_res_gpointer (simple, g_strdup (name), g_free);
+
+ operation = operation_new (operation_set_default, simple);
+ g_queue_push_tail (priv->operations, operation);
+
+ operations_run (self);
+}
+
+gboolean
+empathy_mic_monitor_set_default_finish (EmpathyMicMonitor *self,
+ GAsyncResult *result,
+ GError **error)
+{
+ empathy_implement_finish_void (self,
+ empathy_mic_monitor_set_default_async);
+}
diff --git a/src/empathy-mic-monitor.h b/src/empathy-mic-monitor.h
index 5e2a7c5..4ad4a28 100644
--- a/src/empathy-mic-monitor.h
+++ b/src/empathy-mic-monitor.h
@@ -80,6 +80,11 @@ void empathy_mic_monitor_get_default_async (EmpathyMicMonitor *self,
const gchar * empathy_mic_monitor_get_default_finish (EmpathyMicMonitor *self,
GAsyncResult *result, GError **error);
+void empathy_mic_monitor_set_default_async (EmpathyMicMonitor *self,
+ const gchar *name, GAsyncReadyCallback callback, gpointer user_data);
+gboolean empathy_mic_monitor_set_default_finish (EmpathyMicMonitor *self,
+ GAsyncResult *result, GError **error);
+
G_END_DECLS
#endif /* __EMPATHY_MIC_MONITOR_H__ */
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]