[asterisk-commits] russell: branch russell/jack r93172 - /team/russell/jack/apps/app_jack.c

SVN commits to the Asterisk project asterisk-commits at lists.digium.com
Sun Dec 16 12:11:59 CST 2007


Author: russell
Date: Sun Dec 16 12:11:58 2007
New Revision: 93172

URL: http://svn.digium.com/view/asterisk?view=rev&rev=93172
Log:
Implement the function that runs in the channel thread to consume audio coming
from the jack input port and writes it to the channel.

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=93172&r1=93171&r2=93172
==============================================================================
--- team/russell/jack/apps/app_jack.c (original)
+++ team/russell/jack/apps/app_jack.c Sun Dec 16 12:11:58 2007
@@ -443,8 +443,34 @@
  * frames to the channel.
  */
 static void handle_jack_audio(struct ast_channel *chan, struct jack_data *jack_data)
-{
-	/* XXX */
+{	
+	short buf[160];
+	int res;	
+	struct ast_frame *fr;
+
+	for (;;) {
+		struct ast_frame f = {
+			.frametype = AST_FRAME_VOICE,
+			.subclass = AST_FORMAT_SLINEAR,
+			.src = "JACK",
+			.data = buf,
+		};
+
+		res = jack_ringbuffer_read(jack_data->input_rb, (char *) buf, sizeof(buf));
+
+		if (!res)
+			break;
+
+		f.datalen = res;
+		f.samples = res / sizeof(short);
+
+		ast_smoother_feed(jack_data->smoother, &f);
+	}
+
+	while ((fr = ast_smoother_read(jack_data->smoother))) {
+		ast_write(chan, fr);
+		ast_frfree(fr);
+	}
 }
 
 static int jack_exec(struct ast_channel *chan, void *data)




More information about the asterisk-commits mailing list