[asterisk-commits] oej: branch oej/silence-detection-games-1.8 r411915 - in /team/oej/silence-de...

SVN commits to the Asterisk project asterisk-commits at lists.digium.com
Tue Apr 8 04:00:47 CDT 2014


Author: oej
Date: Tue Apr  8 04:00:31 2014
New Revision: 411915

URL: http://svnview.digium.com/svn/asterisk?view=rev&rev=411915
Log:
Adding detach audiohook function in case of errors.

Modified:
    team/oej/silence-detection-games-1.8/channels/chan_sip.c
    team/oej/silence-detection-games-1.8/include/asterisk/silencedetection.h
    team/oej/silence-detection-games-1.8/main/silencedetection.c

Modified: team/oej/silence-detection-games-1.8/channels/chan_sip.c
URL: http://svnview.digium.com/svn/asterisk/team/oej/silence-detection-games-1.8/channels/chan_sip.c?view=diff&rev=411915&r1=411914&r2=411915
==============================================================================
--- team/oej/silence-detection-games-1.8/channels/chan_sip.c (original)
+++ team/oej/silence-detection-games-1.8/channels/chan_sip.c Tue Apr  8 04:00:31 2014
@@ -7469,17 +7469,18 @@
 
 	/* Check if we really want silence suppression */
 	if (!dialog || !dialog->rtp || !dialog->owner || !ast_test_flag(&dialog->flags[2], SIP_PAGE3_SILENCE_DETECTION)) {
-		ast_debug(3, "SILDET: Do not need silence detection on %s\n", dialog->callid);
+		ast_debug(3, "SILDET: Channel does not need silence suppression on %s\n", dialog->callid);
 		return FALSE;
 	}
 
 	if(ast_sildet_activate(dialog->owner, dialog->silencelevel, dialog->silenceframes)) {
 
 		/* We now have a call where we have a DSP. The rest of the magic is happening somewhere else in chan_sip. */
-		ast_debug(3, "SILDET: Activated silence detection on call %s\n", dialog->callid);
+		ast_debug(3, "SILDET: Activated silence suppression on call %s\n", dialog->callid);
 		if ((res = ast_set_read_format(dialog->owner, AST_FORMAT_SLINEAR)) < 0) {
 			/* Put channel in the right codec mode: SLINEAR */
 			ast_log(LOG_WARNING, "Unable to set channel to linear mode, giving up\n");
+			ast_sildet_deactivate(dialog->owner);
 			return FALSE;
 		}
 	} else {

Modified: team/oej/silence-detection-games-1.8/include/asterisk/silencedetection.h
URL: http://svnview.digium.com/svn/asterisk/team/oej/silence-detection-games-1.8/include/asterisk/silencedetection.h?view=diff&rev=411915&r1=411914&r2=411915
==============================================================================
--- team/oej/silence-detection-games-1.8/include/asterisk/silencedetection.h (original)
+++ team/oej/silence-detection-games-1.8/include/asterisk/silencedetection.h Tue Apr  8 04:00:31 2014
@@ -28,10 +28,16 @@
 #endif
 
 /*! \brief Activation of silence detection 
+	\param chan		The channel
 	\param silencelevel 	Audio treshold for silence
 	\param silenceframes	Number of frames before we react
 */
 int ast_sildet_activate(struct ast_channel *chan, unsigned int silencelevel, unsigned int silenceframes);
+
+/*! \brief Deactivation of silence detection 
+	\param chan		The channel
+*/
+int ast_sildet_deactivate(struct ast_channel *chan);
 
 #if defined(__cplusplus) || defined(c_plusplus)
 }

Modified: team/oej/silence-detection-games-1.8/main/silencedetection.c
URL: http://svnview.digium.com/svn/asterisk/team/oej/silence-detection-games-1.8/main/silencedetection.c?view=diff&rev=411915&r1=411914&r2=411915
==============================================================================
--- team/oej/silence-detection-games-1.8/main/silencedetection.c (original)
+++ team/oej/silence-detection-games-1.8/main/silencedetection.c Tue Apr  8 04:00:31 2014
@@ -272,3 +272,29 @@
 
 	return 1;
 }
+
+int ast_sildet_deactivate(struct ast_channel *chan)
+{
+	struct ast_datastore *datastore = NULL;
+	struct silence_detection_info *sildet = NULL;
+	if (!chan) {
+		ast_log(LOG_WARNING, "No channel was provided.\n" );
+		return -1;
+	}
+	ast_channel_lock(chan);
+	if (!(datastore = ast_channel_datastore_find(chan, &sildet_datastore, NULL))) {
+		ast_debug(4, "----> No silence detection datastore  for %s\n", chan->name);
+		ast_channel_unlock(chan);
+		return 0;
+	}
+	sildet = datastore->data;
+	if (!sildet) {
+		ast_debug(4, "----> No datastore data for silence detection for %s\n", chan->name);
+		ast_channel_unlock(chan);
+		return 0;
+	}
+	sildet->active = 0;
+	ast_audiohook_detach(&sildet->audiohook);
+	ast_channel_unlock(chan);
+	return 1;
+}




More information about the asterisk-commits mailing list