[svn-commits] russell: branch russell/jack r96771 - /team/russell/jack/apps/app_jack.c

SVN commits to the Digium repositories svn-commits at lists.digium.com
Sun Jan 6 12:04:25 CST 2008


Author: russell
Date: Sun Jan  6 12:04:25 2008
New Revision: 96771

URL: http://svn.digium.com/view/asterisk?view=rev&rev=96771
Log:
time for lunch!  Check in progress on JACK_HOOK ...

Modified:
    team/russell/jack/apps/app_jack.c

Modified: team/russell/jack/apps/app_jack.c
URL: http://svn.digium.com/view/asterisk/team/russell/jack/apps/app_jack.c?view=diff&rev=96771&r1=96770&r2=96771
==============================================================================
--- team/russell/jack/apps/app_jack.c (original)
+++ team/russell/jack/apps/app_jack.c Sun Jan  6 12:04:25 2008
@@ -58,6 +58,7 @@
 #include "asterisk/libresample.h"
 #include "asterisk/app.h"
 #include "asterisk/pbx.h"
+#include "asterisk/audiohook.h"
 
 #define RESAMPLE_QUALITY 0
 
@@ -709,12 +710,64 @@
 	return 0;
 }
 
+static void jack_hook_ds_destroy(void *data)
+{
+
+}
+
+static const struct ast_datastore_info jack_hook_ds_info = {
+	.type = "JACK_HOOK",
+	.destroy = jack_hook_ds_destroy,
+};
+
+static int enable_jack_hook(struct ast_channel *chan, char *data)
+{
+	/* XXX */
+
+	return 0;
+}
+
+static int disable_jack_hook(struct ast_channel *chan)
+{
+	struct ast_datastore *datastore;
+
+	ast_channel_lock(chan);
+
+	if (!(datastore = ast_channel_datastore_find(chan, &jack_hook_ds_info, NULL))) {
+		ast_channel_unlock(chan);
+		ast_log(LOG_WARNING, "No JACK_HOOK found to disable\n");
+		return -1;
+	}
+
+	ast_channel_datastore_remove(chan, datastore);
+
+	/* Keep the channel locked while we destroy the datastore, so that we can
+	 * ensure that all of the jack stuff is stopped just in case another frame
+	 * tries to come through the audiohook callback. */
+	ast_channel_datastore_free(datastore);
+
+	ast_channel_unlock(chan);
+
+	return 0;
+}
+
 static int jack_hook_write(struct ast_channel *chan, const char *cmd, char *data, 
 	const char *value)
 {
+	int res;
+	
 	ast_log(LOG_WARNING, "JACK_HOOK() not yet implemented.\n");
 
-	return 0;
+	if (!strcasecmp(value, "on"))
+		res = enable_jack_hook(chan, data);
+	else if (!strcasecmp(value, "off"))
+		res = disable_jack_hook(chan);
+	else {
+		ast_log(LOG_ERROR, "'%s' is not a valid value for JACK_HOOK()\n", value);	
+		res = -1;
+	}
+
+	return res;
 }
 
 static struct ast_custom_function jack_hook_function = {




More information about the svn-commits mailing list