aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorJonny Lamb <jonny.lamb@collabora.co.uk>2011-07-27 18:39:21 +0800
committerJonny Lamb <jonny.lamb@collabora.co.uk>2011-07-28 16:34:47 +0800
commit2223a2eb1e505b857ad13a44bc888149dc3f0334 (patch)
tree9298fe7076f0c95df257f5853424d9fd29e03b9b /src
parent77712e75df674fb1f6fb58bd92a26ce75cf41787 (diff)
downloadgsoc2013-empathy-2223a2eb1e505b857ad13a44bc888149dc3f0334.tar
gsoc2013-empathy-2223a2eb1e505b857ad13a44bc888149dc3f0334.tar.gz
gsoc2013-empathy-2223a2eb1e505b857ad13a44bc888149dc3f0334.tar.bz2
gsoc2013-empathy-2223a2eb1e505b857ad13a44bc888149dc3f0334.tar.lz
gsoc2013-empathy-2223a2eb1e505b857ad13a44bc888149dc3f0334.tar.xz
gsoc2013-empathy-2223a2eb1e505b857ad13a44bc888149dc3f0334.tar.zst
gsoc2013-empathy-2223a2eb1e505b857ad13a44bc888149dc3f0334.zip
audio-src: add API for changing microphone
Signed-off-by: Jonny Lamb <jonny.lamb@collabora.co.uk>
Diffstat (limited to 'src')
-rw-r--r--src/empathy-audio-src.c79
-rw-r--r--src/empathy-audio-src.h5
2 files changed, 84 insertions, 0 deletions
diff --git a/src/empathy-audio-src.c b/src/empathy-audio-src.c
index 086b0a189..fee1e46cf 100644
--- a/src/empathy-audio-src.c
+++ b/src/empathy-audio-src.c
@@ -173,6 +173,42 @@ operation_get_microphones (EmpathyGstAudioSrc *self,
}
static void
+operation_change_microphone_cb (pa_context *context,
+ int success,
+ void *userdata)
+{
+ GSimpleAsyncResult *result = userdata;
+
+ if (!success)
+ {
+ g_simple_async_result_set_error (result, G_IO_ERROR, G_IO_ERROR_FAILED,
+ "Failed to change microphone. Reason unknown.");
+ }
+
+ g_simple_async_result_complete (result);
+ g_object_unref (result);
+}
+
+static void
+operation_change_microphone (EmpathyGstAudioSrc *self,
+ GSimpleAsyncResult *result)
+{
+ EmpathyGstAudioSrcPrivate *priv = EMPATHY_GST_AUDIO_SRC_GET_PRIVATE (self);
+ guint stream_idx, microphone;
+
+ g_object_get (priv->src, "stream-index", &stream_idx, NULL);
+
+ g_assert_cmpuint (pa_context_get_state (priv->context), ==, PA_CONTEXT_READY);
+ g_assert_cmpuint (stream_idx, !=, G_MAXUINT);
+
+ microphone = GPOINTER_TO_UINT (
+ g_simple_async_result_get_op_res_gpointer (result));
+
+ pa_context_move_source_output_by_index (priv->context, stream_idx, microphone,
+ operation_change_microphone_cb, result);
+}
+
+static void
operations_run (EmpathyGstAudioSrc *self)
{
EmpathyGstAudioSrcPrivate *priv = EMPATHY_GST_AUDIO_SRC_GET_PRIVATE (self);
@@ -559,3 +595,46 @@ empathy_audio_src_get_microphones_finish (EmpathyGstAudioSrc *src,
return queue->head;
}
+void
+empathy_audio_src_change_microphone_async (EmpathyGstAudioSrc *src,
+ guint microphone,
+ GAsyncReadyCallback callback,
+ gpointer user_data)
+{
+ EmpathyGstAudioSrcPrivate *priv = EMPATHY_GST_AUDIO_SRC_GET_PRIVATE (src);
+ guint stream_idx;
+ GSimpleAsyncResult *simple;
+ Operation *operation;
+
+ simple = g_simple_async_result_new (G_OBJECT (src), callback, user_data,
+ empathy_audio_src_change_microphone_async);
+
+ g_object_get (priv->src, "stream-index", &stream_idx, NULL);
+
+ if (stream_idx == G_MAXUINT)
+ {
+ g_simple_async_result_set_error (simple, G_IO_ERROR, G_IO_ERROR_FAILED,
+ "pulsesrc is not yet PLAYING");
+ g_simple_async_result_complete_in_idle (simple);
+ g_object_unref (simple);
+ return;
+ }
+
+ g_simple_async_result_set_op_res_gpointer (simple,
+ GUINT_TO_POINTER (microphone), NULL);
+
+ operation = operation_new (operation_change_microphone, simple);
+ g_queue_push_tail (priv->operations, operation);
+
+ /* gogogogo */
+ operations_run (src);
+}
+
+gboolean
+empathy_audio_src_change_microphone_finish (EmpathyGstAudioSrc *src,
+ GAsyncResult *result,
+ GError **error)
+{
+ empathy_implement_finish_void (src,
+ empathy_audio_src_change_microphone_async);
+}
diff --git a/src/empathy-audio-src.h b/src/empathy-audio-src.h
index 298d59c7d..c65f3696a 100644
--- a/src/empathy-audio-src.h
+++ b/src/empathy-audio-src.h
@@ -74,6 +74,11 @@ void empathy_audio_src_get_microphones_async (EmpathyGstAudioSrc *src,
const GList * empathy_audio_src_get_microphones_finish (EmpathyGstAudioSrc *src,
GAsyncResult *result, GError **error);
+void empathy_audio_src_change_microphone_async (EmpathyGstAudioSrc *src,
+ guint microphone, GAsyncReadyCallback callback, gpointer user_data);
+gboolean empathy_audio_src_change_microphone_finish (EmpathyGstAudioSrc *src,
+ GAsyncResult *result, GError **error);
+
G_END_DECLS
#endif /* #ifndef __EMPATHY_GST_AUDIO_SRC_H__*/