[asterisk-commits] bbryant: branch bbryant/noise_reduction_and_agc r114920 - in /team/bbryant/no...

SVN commits to the Asterisk project asterisk-commits at lists.digium.com
Thu May 1 10:11:55 CDT 2008


Author: bbryant
Date: Thu May  1 10:11:55 2008
New Revision: 114920

URL: http://svn.digium.com/view/asterisk?view=rev&rev=114920
Log:
Add new audiohook api call to remove a audiohook from within a channel's thread. Update func_speex to latest version.

Modified:
    team/bbryant/noise_reduction_and_agc/funcs/func_speex.c
    team/bbryant/noise_reduction_and_agc/include/asterisk/audiohook.h
    team/bbryant/noise_reduction_and_agc/main/audiohook.c

Modified: team/bbryant/noise_reduction_and_agc/funcs/func_speex.c
URL: http://svn.digium.com/view/asterisk/team/bbryant/noise_reduction_and_agc/funcs/func_speex.c?view=diff&rev=114920&r1=114919&r2=114920
==============================================================================
--- team/bbryant/noise_reduction_and_agc/funcs/func_speex.c (original)
+++ team/bbryant/noise_reduction_and_agc/funcs/func_speex.c Thu May  1 10:11:55 2008
@@ -181,7 +181,7 @@
 	}
 
 	if (!*sdi) {
-		if (!(*sdi = ast_calloc(1, sizeof(*sdi)))) {
+		if (!(*sdi = ast_calloc(1, sizeof(**sdi)))) {
 			return 0;
 		}
 		/* Right now, the audiohooks API will _only_ provide us 8 kHz slinear
@@ -231,10 +231,10 @@
 			ast_channel_lock(chan);
 			ast_channel_datastore_remove(chan, datastore);
 			ast_channel_unlock(chan);
-		}
-
-		ast_audiohook_detach(&si->audiohook);
-
+			ast_audiohook_remove(chan, &si->audiohook);
+			ast_audiohook_detach(&si->audiohook);
+		}
+		
 		ast_channel_datastore_free(datastore);
 	}
 

Modified: team/bbryant/noise_reduction_and_agc/include/asterisk/audiohook.h
URL: http://svn.digium.com/view/asterisk/team/bbryant/noise_reduction_and_agc/include/asterisk/audiohook.h?view=diff&rev=114920&r1=114919&r2=114920
==============================================================================
--- team/bbryant/noise_reduction_and_agc/include/asterisk/audiohook.h (original)
+++ team/bbryant/noise_reduction_and_agc/include/asterisk/audiohook.h Thu May  1 10:11:55 2008
@@ -160,6 +160,18 @@
  */
 int ast_audiohook_detach_source(struct ast_channel *chan, const char *source);
 
+/*!
+ * \brief Remove an audiohook from a specified channel
+ *
+ * \param chan Channel to remove from
+ * \param audiohook Audiohook to remove
+ *
+ * \return Returns 0 on success, -1 on failure
+ *
+ * \note The channel does not need to be locked before calling this function
+ */
+int ast_audiohook_remove(struct ast_channel *chan, struct ast_audiohook *audiohook);
+
 /*! \brief Pass a frame off to be handled by the audiohook core
  * \param chan Channel that the list is coming off of
  * \param audiohook_list List of audiohooks

Modified: team/bbryant/noise_reduction_and_agc/main/audiohook.c
URL: http://svn.digium.com/view/asterisk/team/bbryant/noise_reduction_and_agc/main/audiohook.c?view=diff&rev=114920&r1=114919&r2=114920
==============================================================================
--- team/bbryant/noise_reduction_and_agc/main/audiohook.c (original)
+++ team/bbryant/noise_reduction_and_agc/main/audiohook.c Thu May  1 10:11:55 2008
@@ -453,6 +453,40 @@
 		audiohook->status = AST_AUDIOHOOK_STATUS_SHUTDOWN;
 
 	return (audiohook ? 0 : -1);
+}
+
+/*!
+ * \brief Remove an audiohook from a specified channel
+ *
+ * \param chan Channel to remove from
+ * \param audiohook Audiohook to remove
+ *
+ * \return Returns 0 on success, -1 on failure
+ *
+ * \note The channel does not need to be locked before calling this function
+ */
+int ast_audiohook_remove(struct ast_channel *chan, struct ast_audiohook *audiohook)
+{
+	ast_channel_lock(chan);
+
+	if (!chan->audiohooks)
+		return -1;
+
+	if (audiohook->type == AST_AUDIOHOOK_TYPE_SPY)
+		AST_LIST_REMOVE(&chan->audiohooks->spy_list, audiohook, list);
+	else if (audiohook->type == AST_AUDIOHOOK_TYPE_WHISPER)
+		AST_LIST_REMOVE(&chan->audiohooks->whisper_list, audiohook, list);
+	else if (audiohook->type == AST_AUDIOHOOK_TYPE_MANIPULATE)
+		AST_LIST_REMOVE(&chan->audiohooks->manipulate_list, audiohook, list);
+
+	ast_audiohook_lock(audiohook);
+	audiohook->status = AST_AUDIOHOOK_STATUS_DONE;
+	ast_cond_signal(&audiohook->trigger);
+	ast_audiohook_unlock(audiohook);
+
+	ast_channel_unlock(chan);
+
+	return 0;
 }
 
 /*! \brief Pass a DTMF frame off to be handled by the audiohook core




More information about the asterisk-commits mailing list