From e17e6184ca30b2164e7b30d1a35f504b87973400 Mon Sep 17 00:00:00 2001 From: Jonny Lamb Date: Fri, 29 Jul 2011 18:54:40 +0100 Subject: 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 --- src/empathy-audio-src.c | 32 ++++++++++++++++++++++++++++++++ 1 file changed, 32 insertions(+) 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) -- cgit v1.2.3