diff options
author | Jonny Lamb <jonny.lamb@collabora.co.uk> | 2011-08-17 22:59:29 +0800 |
---|---|---|
committer | Jonny Lamb <jonny.lamb@collabora.co.uk> | 2011-08-18 22:59:11 +0800 |
commit | e5cd9e64870fbca5bc57d205ba4fe9aadb726614 (patch) | |
tree | d5df18d01f374cf09036841629938b5e40152084 /src | |
parent | a719df5e3df6a31d0e629516cffcdfca9436e5ae (diff) | |
download | gsoc2013-empathy-e5cd9e64870fbca5bc57d205ba4fe9aadb726614.tar gsoc2013-empathy-e5cd9e64870fbca5bc57d205ba4fe9aadb726614.tar.gz gsoc2013-empathy-e5cd9e64870fbca5bc57d205ba4fe9aadb726614.tar.bz2 gsoc2013-empathy-e5cd9e64870fbca5bc57d205ba4fe9aadb726614.tar.lz gsoc2013-empathy-e5cd9e64870fbca5bc57d205ba4fe9aadb726614.tar.xz gsoc2013-empathy-e5cd9e64870fbca5bc57d205ba4fe9aadb726614.tar.zst gsoc2013-empathy-e5cd9e64870fbca5bc57d205ba4fe9aadb726614.zip |
mic-monitor: add get_default function
Signed-off-by: Jonny Lamb <jonny.lamb@collabora.co.uk>
Diffstat (limited to 'src')
-rw-r--r-- | src/empathy-mic-monitor.c | 58 | ||||
-rw-r--r-- | src/empathy-mic-monitor.h | 5 |
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__ */ |