pidgin.next.minor: 36f79817: Make the simple silence suppression stuf...

rekkanoryo at pidgin.im rekkanoryo at pidgin.im
Sun Mar 13 15:11:03 EDT 2011


----------------------------------------------------------------------
Revision: 36f7981726410932b6262c6e29dfa937447f7779
Parent:   c19ec832c04e880ed21deeabcb701b8b3c7e9ce0
Author:   jakub.adam at ktknet.cz
Date:     03/13/11 14:17:14
Branch:   im.pidgin.pidgin.next.minor
URL: http://d.pidgin.im/viewmtn/revision/info/36f7981726410932b6262c6e29dfa937447f7779

Changelog: 

Make the simple silence suppression stuff optional per-account.  Fixes #13180.

Changes against parent c19ec832c04e880ed21deeabcb701b8b3c7e9ce0

  patched  libpurple/account.c
  patched  libpurple/account.h
  patched  libpurple/media/backend-fs2.c
  patched  pidgin/gtkaccount.c

-------------- next part --------------
============================================================
--- libpurple/account.c	45bda46b184aff23682d6880c95063dc43ead7a3
+++ libpurple/account.c	ae1bbe60d7f44c53c7d2d37a4136cf40b3e340ee
@@ -1936,7 +1936,21 @@ purple_account_get_public_alias(PurpleAc
 	}
 }
 
+gboolean
+purple_account_get_silence_suppression(const PurpleAccount *account)
+{
+	return purple_account_get_bool(account, "silence-suppression", FALSE);
+}
+
 void
+purple_account_set_silence_suppression(PurpleAccount *account, gboolean value)
+{
+	g_return_if_fail(account != NULL);
+
+	purple_account_set_bool(account, "silence-suppression", value);
+}
+
+void
 purple_account_clear_settings(PurpleAccount *account)
 {
 	g_return_if_fail(account != NULL);
============================================================
--- libpurple/account.h	bdf8d47242609381bdda89f66bb89a62e3735095
+++ libpurple/account.h	4f02d23f6dede47618f0a9c481d96408f194e3a1
@@ -513,6 +513,24 @@ void purple_account_get_public_alias(Pur
 	PurpleGetPublicAliasFailureCallback failure_cb);
 
 /**
+ * Return whether silence suppression is used during voice call.
+ *
+ * @param account The account.
+ *
+ * @return @c TRUE if suppression is used, or @c FALSE if not.
+ */
+gboolean purple_account_get_silence_suppression(const PurpleAccount *account);
+
+/**
+ * Sets whether silence suppression is used during voice call.
+ *
+ * @param account The account.
+ * @param value   @c TRUE if suppression should be used.
+ */
+void purple_account_set_silence_suppression(PurpleAccount *account,
+											gboolean value);
+
+/**
  * Clears all protocol-specific settings on an account.
  *
  * @param account The account.
============================================================
--- pidgin/gtkaccount.c	4fac17132bd66961f22e59410c2a77cfe81bf49d
+++ pidgin/gtkaccount.c	4d02d24f81e788d1e85f2c87ed16b5bf64c4c8a5
@@ -143,6 +143,10 @@ typedef struct
 	GtkWidget *proxy_user_entry;
 	GtkWidget *proxy_pass_entry;
 
+	/* Voice & Video Options*/
+	GtkWidget *voice_frame;
+	GtkWidget *suppression_check;
+
 } AccountPrefsDialog;
 
 static AccountsWindow *accounts_window = NULL;
@@ -159,6 +163,7 @@ static void add_proxy_options(AccountPre
 static void add_user_options(AccountPrefsDialog *dialog, GtkWidget *parent);
 static void add_protocol_options(AccountPrefsDialog *dialog);
 static void add_proxy_options(AccountPrefsDialog *dialog, GtkWidget *parent);
+static void add_voice_options(AccountPrefsDialog *dialog);
 
 static GtkWidget *
 add_pref_box(AccountPrefsDialog *dialog, GtkWidget *parent,
@@ -237,6 +242,7 @@ set_account_protocol_cb(GtkWidget *item,
 	add_login_options(dialog,    dialog->top_vbox);
 	add_user_options(dialog,     dialog->top_vbox);
 	add_protocol_options(dialog);
+	add_voice_options(dialog);
 
 	gtk_widget_grab_focus(dialog->protocol_menu);
 
@@ -1163,6 +1169,39 @@ add_proxy_options(AccountPrefsDialog *di
 					 G_CALLBACK(proxy_type_changed_cb), dialog);
 }
 
+static void
+add_voice_options(AccountPrefsDialog *dialog)
+{
+#ifdef USE_VV
+	if (!dialog->prpl_info || !dialog->prpl_info->initiate_media) {
+		if (dialog->voice_frame) {
+			gtk_widget_destroy(dialog->voice_frame);
+			dialog->voice_frame = NULL;
+			dialog->suppression_check = NULL;
+		}
+		return;
+	}
+
+	if (!dialog->voice_frame) {
+		dialog->voice_frame = gtk_vbox_new(FALSE, PIDGIN_HIG_BORDER);
+		gtk_container_set_border_width(GTK_CONTAINER(dialog->voice_frame),
+										PIDGIN_HIG_BORDER);
+
+		dialog->suppression_check =
+				gtk_check_button_new_with_mnemonic(_("Use _silence suppression"));
+		gtk_box_pack_start(GTK_BOX(dialog->voice_frame), dialog->suppression_check,
+				FALSE, FALSE, 0);
+
+		gtk_notebook_append_page(GTK_NOTEBOOK(dialog->notebook),
+				dialog->voice_frame, gtk_label_new_with_mnemonic(_("_Voice and Video")));
+		gtk_widget_show_all(dialog->voice_frame);
+	}
+
+	gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(dialog->suppression_check),
+								purple_account_get_silence_suppression(dialog->account));
+#endif
+}
+
 static gboolean
 account_win_destroy_cb(GtkWidget *w, GdkEvent *event,
 					   AccountPrefsDialog *dialog)
@@ -1437,6 +1476,12 @@ ok_account_prefs_cb(GtkWidget *w, Accoun
 		proxy_info = NULL;
 	}
 
+	/* Voice and Video settings */
+	if (dialog->voice_frame) {
+		purple_account_set_silence_suppression(account,
+				gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(dialog->suppression_check)));
+	}
+
 	/* If this is a new account, add it to our list */
 	if (new_acct)
 		purple_accounts_add(account);
@@ -1558,6 +1603,8 @@ pidgin_account_dialog_show(PidginAccount
 	gtk_widget_show(dbox);
 	add_proxy_options(dialog, dbox);
 
+	add_voice_options(dialog);
+
 	/* Cancel button */
 	pidgin_dialog_add_button(GTK_DIALOG(win), GTK_STOCK_CANCEL, G_CALLBACK(cancel_account_prefs_cb), dialog);
 
============================================================
--- libpurple/media/backend-fs2.c	365d32be4d10f4919d04bce39d4fc9b5abc9ad52
+++ libpurple/media/backend-fs2.c	91b00b19579d6d6f26f50a86d6686ad9d76819c2
@@ -155,14 +155,8 @@ purple_media_backend_fs2_init(PurpleMedi
 
 static void
 purple_media_backend_fs2_init(PurpleMediaBackendFs2 *self)
-{
-	PurpleMediaBackendFs2Private *priv =
-			PURPLE_MEDIA_BACKEND_FS2_GET_PRIVATE(self);
+{}
 
-	priv->silence_threshold = purple_prefs_get_int(
-			"/purple/media/audio/silence_threshold") / 100.0;
-}
-
 static gboolean
 event_probe_cb(GstPad *srcpad, GstEvent *event, gboolean release_pad)
 {
@@ -817,9 +811,11 @@ gst_handle_message_element(GstBus *bus, 
 
 		if (!strncmp(name, "sendlevel_", 10)) {
 			session = get_session(self, name+10);
-			percent = gst_msg_db_to_percent(msg, "decay");
-			g_object_set(session->srcvalve,
-					"drop", (percent < priv->silence_threshold), NULL);
+			if (priv->silence_threshold > 0) {
+				percent = gst_msg_db_to_percent(msg, "decay");
+				g_object_set(session->srcvalve,
+						"drop", (percent < priv->silence_threshold), NULL);
+			}
 		}
 
 		g_free(name);
@@ -1255,6 +1251,13 @@ init_conference(PurpleMediaBackendFs2 *s
 		return FALSE;
 	}
 
+	if (purple_account_get_silence_suppression(
+				purple_media_get_account(priv->media)))
+		priv->silence_threshold = purple_prefs_get_int(
+				"/purple/media/audio/silence_threshold") / 100.0;
+	else
+		priv->silence_threshold = 0;
+
 	pipeline = purple_media_manager_get_pipeline(
 			purple_media_get_manager(priv->media));
 


More information about the Commits mailing list