aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJonny Lamb <jonny.lamb@collabora.co.uk>2011-07-30 01:54:40 +0800
committerJonny Lamb <jonny.lamb@collabora.co.uk>2011-07-30 01:54:40 +0800
commite17e6184ca30b2164e7b30d1a35f504b87973400 (patch)
tree1c2281c72f5f6ed45a86982dba5334367372c782
parentcf7f9a1da8e7a830a0f0676accc0afa444ae8748 (diff)
downloadgsoc2013-empathy-e17e6184ca30b2164e7b30d1a35f504b87973400.tar
gsoc2013-empathy-e17e6184ca30b2164e7b30d1a35f504b87973400.tar.gz
gsoc2013-empathy-e17e6184ca30b2164e7b30d1a35f504b87973400.tar.bz2
gsoc2013-empathy-e17e6184ca30b2164e7b30d1a35f504b87973400.tar.lz
gsoc2013-empathy-e17e6184ca30b2164e7b30d1a35f504b87973400.tar.xz
gsoc2013-empathy-e17e6184ca30b2164e7b30d1a35f504b87973400.tar.zst
gsoc2013-empathy-e17e6184ca30b2164e7b30d1a35f504b87973400.zip
audio-src: check for new enough pulsesrc before trying to change mics
This means this feature will automatically start working when a new enough pulsesrc is used. Making _get_microphones() fail has a nice side-effect that the Edit menu item doesn't appear at all. Neat. Signed-off-by: Jonny Lamb <jonny.lamb@collabora.co.uk>
-rw-r--r--src/empathy-audio-src.c32
1 files changed, 32 insertions, 0 deletions
diff --git a/src/empathy-audio-src.c b/src/empathy-audio-src.c
index 129e75319..642628d7b 100644
--- a/src/empathy-audio-src.c
+++ b/src/empathy-audio-src.c
@@ -85,6 +85,18 @@ struct _EmpathyGstAudioSrcPrivate
(G_TYPE_INSTANCE_GET_PRIVATE ((o), EMPATHY_TYPE_GST_AUDIO_SRC, \
EmpathyGstAudioSrcPrivate))
+static gboolean
+empathy_audio_src_supports_changing_mic (EmpathyGstAudioSrc *self)
+{
+ EmpathyGstAudioSrcPrivate *priv = EMPATHY_GST_AUDIO_SRC_GET_PRIVATE (self);
+ GObjectClass *object_class;
+
+ object_class = G_OBJECT_GET_CLASS (priv->src);
+
+ return (g_object_class_find_property (object_class,
+ "source-output-index") != NULL);
+}
+
typedef void (*OperationFunc) (EmpathyGstAudioSrc *, GSimpleAsyncResult *);
typedef struct
@@ -730,6 +742,17 @@ empathy_audio_src_get_microphones_async (EmpathyGstAudioSrc *src,
simple = g_simple_async_result_new (G_OBJECT (src), callback, user_data,
empathy_audio_src_get_microphones_async);
+ /* If we can't change mic let's not pretend we can by returning the
+ * list of available mics. */
+ if (!empathy_audio_src_supports_changing_mic (src))
+ {
+ g_simple_async_result_set_error (simple, G_IO_ERROR, G_IO_ERROR_FAILED,
+ "pulsesrc is not new enough to support changing microphone");
+ g_simple_async_result_complete_in_idle (simple);
+ g_object_unref (simple);
+ return;
+ }
+
operation = operation_new (operation_get_microphones, simple);
g_queue_push_tail (priv->operations, operation);
@@ -778,6 +801,15 @@ empathy_audio_src_change_microphone_async (EmpathyGstAudioSrc *src,
simple = g_simple_async_result_new (G_OBJECT (src), callback, user_data,
empathy_audio_src_change_microphone_async);
+ if (!empathy_audio_src_supports_changing_mic (src))
+ {
+ g_simple_async_result_set_error (simple, G_IO_ERROR, G_IO_ERROR_FAILED,
+ "pulsesrc is not new enough to support changing microphone");
+ g_simple_async_result_complete_in_idle (simple);
+ g_object_unref (simple);
+ return;
+ }
+
g_object_get (priv->src, "source-output-index", &source_output_idx, NULL);
if (source_output_idx == PA_INVALID_INDEX)